File tree 2 files changed +12
-0
lines changed
2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,9 @@ cdef class PreparedStatementState:
91
91
WriteBuffer writer
92
92
Codec codec
93
93
94
+ if len (args) > 32767 :
95
+ raise ValueError (' number of arguments cannot exceed 32767' )
96
+
94
97
self ._ensure_args_encoder()
95
98
self ._ensure_rows_decoder()
96
99
Original file line number Diff line number Diff line change @@ -534,3 +534,12 @@ async def test_prepare_27_max_cacheable_statement_size(self):
534
534
# Test that short prepared statements can still be cached.
535
535
await self .con .prepare ('SELECT 2' )
536
536
self .assertEqual (len (cache ), 2 )
537
+
538
+ async def test_prepare_28_max_args (self ):
539
+ N = 32768
540
+ args = ',' .join ('${}' .format (i ) for i in range (1 , N + 1 ))
541
+ query = 'SELECT ARRAY[{}]' .format (args )
542
+
543
+ with self .assertRaisesRegex (ValueError ,
544
+ 'number of arguments cannot exceed 32767' ):
545
+ await self .con .fetchval (query , * range (1 , N + 1 ))
You can’t perform that action at this time.
0 commit comments