File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -179,6 +179,9 @@ private final class PostgresParameterizedQuery: PostgresRequest {
179179 }
180180
181181 func start( ) throws -> [ PostgresMessage ] {
182+ guard self . binds. count <= Int16 . max else {
183+ throw PostgresError . protocol ( " Bind count must be <= \( Int16 . max) . " )
184+ }
182185 let parse = PostgresMessage . Parse (
183186 statementName: " " ,
184187 query: self . query,
Original file line number Diff line number Diff line change @@ -904,7 +904,16 @@ final class PostgresNIOTests: XCTestCase {
904904 XCTAssertEqual ( rows. metadata. oid, nil )
905905 XCTAssertEqual ( rows. metadata. rows, 0 )
906906 }
907-
907+
908+ func testTooManyBinds( ) throws {
909+ let conn = try PostgresConnection . test ( on: eventLoop) . wait ( )
910+ defer { try ! conn. close ( ) . wait ( ) }
911+ let binds = [ PostgresData ] . init ( repeating: . null, count: Int ( Int16 . max) + 1 )
912+ do {
913+ _ = try conn. query ( " SELECT version() " , binds) . wait ( )
914+ XCTFail ( " Should have failed " )
915+ } catch PostgresError . connectionClosed { }
916+ }
908917}
909918
910919let isLoggingConfigured : Bool = {
You can’t perform that action at this time.
0 commit comments