Repository navigation
Conversation
PostgreSQL reads the 16-bit parameter counts in Bind and ParameterDescription as unsigned and documents a limit of 65,535 query parameters, but asyncpg stored them in int16_t and refused more than 32767 arguments. Keep the count as uint16_t and raise the limit to 65535.
This branch has not been deployed
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.
Fixes #1390.
PostgreSQL reads the 16-bit parameter count in Bind as unsigned and documents a limit of 65,535 query parameters, but asyncpg keeps the count in
int16_tand refuses more than 32767 arguments (the check from #127).args_numand theParameterDescriptioncount areuint16_tnow. Bind still writes them withwrite_int16through anint16_tcast, so the bytes on the wire are the same as before for up to 32767 arguments.test_prepare_28_max_argsnow runs a query with 65535 arguments and expects the error at 65536.Tested against PostgreSQL 17 (
PGHOSTpointing at a local server):test_prepare,test_execute,test_codecs,test_cursor,test_copy,test_cache_invalidation,test_record,test_introspection,test_exceptionsandtest_timeoutpass (197 passed, 3 skipped), andflake8 asyncpg testsis clean. The updated test fails on master. The script from the issue now prints the same counts for asyncpg and psycopg at 32767, 32768 and 65535 arguments, and a multi-rowINSERTwith 40000 parameters goes through.