fix: re-Parse unprepared statements in protocol.bind for cursors#1339
Open
Solaris-star wants to merge 1 commit into
Open
fix: re-Parse unprepared statements in protocol.bind for cursors#1339Solaris-star wants to merge 1 commit into
Solaris-star wants to merge 1 commit into
Conversation
When statement_cache_size=0, prepare(name=None) uses the unnamed statement "". Type introspection also uses "", which clobbers the user statement and marks it unprepared. bind_execute already re-Parses when state.prepared is False, but cursor.bind did not. Opening a server-side cursor after prepare then failed with ProtocolViolationError about mismatched bind parameters. Re-Parse before Bind in protocol.bind, and accept ParseComplete in _process__bind, matching bind_execute. Fixes MagicStack#1335
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.
Description
With
statement_cache_size=0,prepare(name=None)creates the unnamed statement""(since #1245 / 0.31.0). When the result type needs introspection (e.g. an enum), asyncpg's type-introspection query also uses"", which replaces the user statement on the server. The client marks the user statement unprepared.bind_executealready re-Parses whenstate.preparedis False. Cursor paths useprotocol.bind, which did not re-Parse, so:Fix
protocol.bind: ifnot state.prepared, call_send_parse_messagebefore Bind (same asbind_execute)._process__bind: accept ParseComplete (b'1') when re-parsing.statement_cache_size=0+ enum +prepare+cursor.Linked Issue
Closes #1335