Skip to content

Add idle session timeout error #963

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 22, 2022
Merged

Add idle session timeout error #963

merged 4 commits into from
Nov 22, 2022

Conversation

jkosh44
Copy link
Contributor

@jkosh44 jkosh44 commented Nov 21, 2022

This commit adds the idle session timeout error (57P05). See https://www.postgresql.org/docs/current/errcodes-appendix.html

@@ -1498,6 +1503,7 @@ static SQLSTATE_MAP: phf::Map<&'static str, SqlState> =
("55006", SqlState::OBJECT_IN_USE),
("42P01", SqlState::UNDEFINED_TABLE),
("25P03", SqlState::IDLE_IN_TRANSACTION_SESSION_TIMEOUT),
("57P05", SqlState::IDLE_SESSION_TIMEOUT),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It didn't seem like there was any specific order here, so I just put this next to a similar timeout error. Let me know if I missed something.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is generated by the codegen crate in this repo. The proper way to update it is to update errcodes.txt, pg_range.dat, and pg_type.dat and cargo run the codegen.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, totally missed the comment at the top. I'll do that now.

Copy link
Contributor Author

@jkosh44 jkosh44 Nov 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like there have been quite a few changes since this was last updated. Specifically multi-ranges causes the type gen code to panic becuase it thinks the oid is for the normal range type. I can take a look and see how we can update the code for multi-ranges. Let me know if you have any thoughts/ideas.

@jkosh44
Copy link
Contributor Author

jkosh44 commented Nov 21, 2022

I copied errcodes.txt, pg_range.dat, and pg_type.dat from the 51b5834cd53f0bd068729043b55f7da3ca6bb15f commit of PostgreSQL.

EDIT: I should note that the file contents are identical to commit c5dc80c1bc216f0e21a2f79f5e0415c2d4cfb35d which was the official 15.1 release.

Comment on lines +222 to +230
"r" => range_elements[&oid],
"m" => multi_range_elements[&oid],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can find the description of this field in the pg_type catalog table (https://www.postgresql.org/docs/current/catalog-pg-type.html). The relevant part is:

r for a range type, or m for a multirange type.

@sfackler
Copy link
Owner

It looks like multirange types are currently mapping to Kind::Range, but it would probably make more sense to create a separate Kind::Multirange.

You'll also need to run cargo fmt on the project after the codegen'd files are recreated.

@jkosh44
Copy link
Contributor Author

jkosh44 commented Nov 21, 2022

It looks like multirange types are currently mapping to Kind::Range, but it would probably make more sense to create a separate Kind::Multirange.

You'll also need to run cargo fmt on the project after the codegen'd files are recreated.

Just did both. Let me know if you have notes on the approach.

@jkosh44
Copy link
Contributor Author

jkosh44 commented Nov 21, 2022

@sfackler The test and clippy failures look like they're in parts of the code that I haven't touched. Any ideas what's going on?

@sfackler
Copy link
Owner

Those should be fixed on master now if you merge/rebase.

@sfackler
Copy link
Owner

LGTM otherwise!

@jkosh44
Copy link
Contributor Author

jkosh44 commented Nov 22, 2022

Those should be fixed on master now if you merge/rebase.

Just rebased from master

@sfackler sfackler merged commit 5ebe602 into sfackler:master Nov 22, 2022
@sfackler
Copy link
Owner

Thanks!

@jkosh44 jkosh44 deleted the idle-session-timeout branch November 22, 2022 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants