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

Function TestConnExecParamsMaxNumberOfParams

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

Source from the content-addressed store, hash-verified

1274}
1275
1276func TestConnExecParamsMaxNumberOfParams(t *testing.T) {
1277 t.Parallel()
1278
1279 ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
1280 defer cancel()
1281
1282 pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE"))
1283 require.NoError(t, err)
1284 defer closeConn(t, pgConn)
1285
1286 paramCount := math.MaxUint16
1287 params := make([]string, 0, paramCount)
1288 args := make([][]byte, 0, paramCount)
1289 for i := range paramCount {
1290 params = append(params, fmt.Sprintf("($%d::text)", i+1))
1291 args = append(args, []byte(strconv.Itoa(i)))
1292 }
1293 sql := "values" + strings.Join(params, ", ")
1294
1295 result := pgConn.ExecParams(ctx, sql, args, nil, nil, nil).Read()
1296 require.NoError(t, result.Err)
1297 require.Len(t, result.Rows, paramCount)
1298
1299 ensureConnValid(t, pgConn)
1300}
1301
1302func TestConnExecParamsTooManyParams(t *testing.T) {
1303 t.Parallel()

Callers

nothing calls this directly

Calls 6

ConnectFunction · 0.92
closeConnFunction · 0.70
ensureConnValidFunction · 0.70
LenMethod · 0.65
ReadMethod · 0.45
ExecParamsMethod · 0.45

Tested by

no test coverage detected