MCPcopy
hub / github.com/jackc/pgx / TestConnExecParamsTooManyParams

Function TestConnExecParamsTooManyParams

pgconn/pgconn_test.go:1302–1326  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1300}
1301
1302func TestConnExecParamsTooManyParams(t *testing.T) {
1303 t.Parallel()
1304
1305 ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
1306 defer cancel()
1307
1308 pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
1309 require.NoError(t, err)
1310 defer closeConn(t, pgConn)
1311
1312 paramCount := math.MaxUint16 + 1
1313 params := make([]string, 0, paramCount)
1314 args := make([][]byte, 0, paramCount)
1315 for i := range paramCount {
1316 params = append(params, fmt.Sprintf("($%d::text)", i+1))
1317 args = append(args, []byte(strconv.Itoa(i)))
1318 }
1319 sql := "values" + strings.Join(params, ", ")
1320
1321 result := pgConn.ExecParams(ctx, sql, args, nil, nil, nil).Read()
1322 require.Error(t, result.Err)
1323 require.Equal(t, "extended protocol limited to 65535 parameters", result.Err.Error())
1324
1325 ensureConnValid(t, pgConn)
1326}
1327
1328func TestConnExecParamsCanceled(t *testing.T) {
1329 t.Parallel()

Callers

nothing calls this directly

Calls 6

ConnectFunction · 0.92
closeConnFunction · 0.70
ensureConnValidFunction · 0.70
ReadMethod · 0.45
ExecParamsMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected