Repository navigation
Prepare statements again after a schema change - #10
Merged
Merged
Conversation
A cached statement kept its old param types after a table was rebuilt, so '007' sent to a new text column was stored as '7'. A pool-wide schema counter is now part of the statement cache key.
Contributor
Author
Bot reviewVerdict: OK. Nothing blocks. Checks I ran (Postgres 16 in a throwaway container):
What I checked:
Nits (do not block):
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A text param can be stored with the wrong type after a table is changed on the same pool.
Example on one connection:
vis anintcolumn.INSERT ... VALUES ($1)runs with'7'. Then the table is dropped and made again withv text. The same insert with'007'stores'7'. The sameSELECT ... WHERE v = $1then fails with42883 operator does not exist: text = integer.Cause
Strings are sent with type oid 0, so Postgres picks the param type at Parse time (here
int4). The driver caches the statement. When the table changes, Postgres plans the statement again, but it keeps the old param types. No error comes for the insert, so an error retry can not catch it.Fix
schemacounter. It goes up when a connection gets aCommandCompleteofCREATE,ALTERorDROP.DOor a function.No FFI change, no version or ABI bump.
Tests
7) and passes now.cargo fmt,cargo clippy -D warnings,cargo test(new unit test for the DDL tag check),dart analyze, fulldart teston Postgres 16: all pass.