pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/MagicStack/asyncpg/pull/1339

ll-requests-be6017ec12798e73.css" /> fix: re-Parse unprepared statements in protocol.bind for cursors by Solaris-star · Pull Request #1339 · MagicStack/asyncpg · GitHub
Skip to content

fix: re-Parse unprepared statements in protocol.bind for cursors - #1339

Open
Solaris-star wants to merge 1 commit into
MagicStack:masterfrom
Solaris-star:fix/1335-unnamed-stmt-collision
Open

fix: re-Parse unprepared statements in protocol.bind for cursors#1339
Solaris-star wants to merge 1 commit into
MagicStack:masterfrom
Solaris-star:fix/1335-unnamed-stmt-collision

Conversation

@Solaris-star

Copy link
Copy Markdown

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_execute already re-Parses when state.prepared is False. Cursor paths use protocol.bind, which did not re-Parse, so:

asyncpg.exceptions.ProtocolViolationError:
bind message supplies N parameters, but prepared statement "" requires M

Fix

  1. protocol.bind: if not state.prepared, call _send_parse_message before Bind (same as bind_execute).
  2. _process__bind: accept ParseComplete (b'1') when re-parsing.
  3. Regression test: statement_cache_size=0 + enum + prepare + cursor.

Linked Issue

Closes #1335

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy