Conversation
…cribe
A query with parameters that is new to a connection is sent as Parse and
Describe first, and only bound once the server has described its
parameter types. If a parameter then fails to serialize (for example
`new Date(NaN)`, whose serializer throws a RangeError), the query is
rejected and a bare Sync is sent. The server answers that Sync without an
error, so a transaction the query was pipelined in goes on and commits
without it:
const reserved = await sql.reserve()
await Promise.all([
reserved`begin`,
reserved`insert into test values (1)`,
reserved`select ${ new Date(NaN) }::timestamptz`, // rejects
reserved`insert into test values (2)`,
reserved`commit` // commits 1 and 2
])
Bind the query with no parameters instead. The server refuses it, since
the query takes at least one parameter (or it would not have been
described first). That aborts the transaction, the refusal answers in the
query's place, and the query is rejected with its own error, as a retried
query already is. It is no longer a cursor either, whose error would send
a Sync of its own and shift the next answer.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Author
|
I made a few PRs from Claude which fix some problems I was having. Can you take a look? |
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.
A query with parameters that is new to a connection is sent as Parse and Describe first, and only bound once the server has described its parameter types. If a parameter then fails to serialize (for example
new Date(NaN), whose serializer throws a RangeError), the query is rejected and a bare Sync is sent. The server answers that Sync without an error, so a transaction the query was pipelined in goes on and commits without it:Bind the query with no parameters instead. The server refuses it, since the query takes at least one parameter (or it would not have been described first). That aborts the transaction, the refusal answers in the query's place, and the query is rejected with its own error, as a retried query already is. It is no longer a cursor either, whose error would send a Sync of its own and shift the next answer.