2
0

Rename ForEachScannedRow to ForEachRow

This commit is contained in:
Jack Christensen
2022-07-09 16:47:28 -05:00
parent da192291f7
commit 90c2dc6f68
8 changed files with 89 additions and 89 deletions
+1 -1
View File
@@ -138,7 +138,7 @@ The `RowScanner` interface allows a single argument to Rows.Scan to scan the ent
## Rows Result Helpers
* `CollectRows` and `RowTo*` functions simplify collecting results into a slice.
* `QueryFunc` has been replaced by using `ForEachScannedRow`.
* `ForEachRow` simplifies scanning each row and executing code using the scanned values. `ForEachRow` replaces `QueryFunc`.
## SendBatch Uses Pipeline Mode When Appropriate
+1 -1
View File
@@ -109,7 +109,7 @@ func TestConnSendBatch(t *testing.T) {
rowCount = 0
rows, _ = br.Query()
_, err = pgx.ForEachScannedRow(rows, []any{&id, &description, &amount}, func() error {
_, err = pgx.ForEachRow(rows, []any{&id, &description, &amount}, func() error {
if id != selectFromLedgerExpectedRows[rowCount].id {
t.Errorf("id => %v, want %v", id, selectFromLedgerExpectedRows[rowCount].id)
}
+1 -1
View File
@@ -1163,7 +1163,7 @@ where attrelid=$1
order by attnum`,
typrelid,
)
_, err = ForEachScannedRow(rows, []any{&fieldName, &fieldOID}, func() error {
_, err = ForEachRow(rows, []any{&fieldName, &fieldOID}, func() error {
dt, ok := c.TypeMap().TypeForOID(fieldOID)
if !ok {
return fmt.Errorf("unknown composite type field OID: %v", fieldOID)
+2 -2
View File
@@ -63,11 +63,11 @@ pgx implements Query and Scan in the familiar database/sql style.
// No errors found - do something with sum
ForEachScannedRow can be used to execute a callback function for every row. This is often easier than iterating over rows directly.
ForEachRow can be used to execute a callback function for every row. This is often easier than iterating over rows directly.
var sum, n int32
rows, _ := conn.Query(context.Background(), "select generate_series(1,$1)", 10)
_, err := pgx.ForEachScannedRow(rows, []any{&n}, func(pgx.QueryFuncRow) error {
_, err := pgx.ForEachRow(rows, []any{&n}, func(pgx.QueryFuncRow) error {
sum += n
return nil
})
+70 -70
View File
@@ -18,7 +18,7 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_int16_1_rows_1_columns(b *test
`select n::int4 + 0 from generate_series(1, 1) n`,
[]any{pgx.QueryResultFormats{pgx.TextFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -36,7 +36,7 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_int16_1_rows_1_columns(b *te
`select n::int4 + 0 from generate_series(1, 1) n`,
[]any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -54,7 +54,7 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_int16_1_rows_10_columns(b *tes
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 1) n`,
[]any{pgx.QueryResultFormats{pgx.TextFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -72,7 +72,7 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_int16_1_rows_10_columns(b *t
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 1) n`,
[]any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -90,7 +90,7 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_int16_10_rows_1_columns(b *tes
`select n::int4 + 0 from generate_series(1, 10) n`,
[]any{pgx.QueryResultFormats{pgx.TextFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -108,7 +108,7 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_int16_10_rows_1_columns(b *t
`select n::int4 + 0 from generate_series(1, 10) n`,
[]any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -126,7 +126,7 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_int16_100_rows_10_columns(b *t
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 100) n`,
[]any{pgx.QueryResultFormats{pgx.TextFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -144,7 +144,7 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_int16_100_rows_10_columns(b
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 100) n`,
[]any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -162,7 +162,7 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_int32_1_rows_1_columns(b *test
`select n::int4 + 0 from generate_series(1, 1) n`,
[]any{pgx.QueryResultFormats{pgx.TextFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -180,7 +180,7 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_int32_1_rows_1_columns(b *te
`select n::int4 + 0 from generate_series(1, 1) n`,
[]any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -198,7 +198,7 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_int32_1_rows_10_columns(b *tes
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 1) n`,
[]any{pgx.QueryResultFormats{pgx.TextFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -216,7 +216,7 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_int32_1_rows_10_columns(b *t
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 1) n`,
[]any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -234,7 +234,7 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_int32_10_rows_1_columns(b *tes
`select n::int4 + 0 from generate_series(1, 10) n`,
[]any{pgx.QueryResultFormats{pgx.TextFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -252,7 +252,7 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_int32_10_rows_1_columns(b *t
`select n::int4 + 0 from generate_series(1, 10) n`,
[]any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -270,7 +270,7 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_int32_100_rows_10_columns(b *t
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 100) n`,
[]any{pgx.QueryResultFormats{pgx.TextFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -288,7 +288,7 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_int32_100_rows_10_columns(b
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 100) n`,
[]any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -306,7 +306,7 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_int64_1_rows_1_columns(b *test
`select n::int4 + 0 from generate_series(1, 1) n`,
[]any{pgx.QueryResultFormats{pgx.TextFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -324,7 +324,7 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_int64_1_rows_1_columns(b *te
`select n::int4 + 0 from generate_series(1, 1) n`,
[]any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -342,7 +342,7 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_int64_1_rows_10_columns(b *tes
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 1) n`,
[]any{pgx.QueryResultFormats{pgx.TextFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -360,7 +360,7 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_int64_1_rows_10_columns(b *t
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 1) n`,
[]any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -378,7 +378,7 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_int64_10_rows_1_columns(b *tes
`select n::int4 + 0 from generate_series(1, 10) n`,
[]any{pgx.QueryResultFormats{pgx.TextFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -396,7 +396,7 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_int64_10_rows_1_columns(b *t
`select n::int4 + 0 from generate_series(1, 10) n`,
[]any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -414,7 +414,7 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_int64_100_rows_10_columns(b *t
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 100) n`,
[]any{pgx.QueryResultFormats{pgx.TextFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -432,7 +432,7 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_int64_100_rows_10_columns(b
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 100) n`,
[]any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -450,7 +450,7 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_uint64_1_rows_1_columns(b *tes
`select n::int4 + 0 from generate_series(1, 1) n`,
[]any{pgx.QueryResultFormats{pgx.TextFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -468,7 +468,7 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_uint64_1_rows_1_columns(b *t
`select n::int4 + 0 from generate_series(1, 1) n`,
[]any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -486,7 +486,7 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_uint64_1_rows_10_columns(b *te
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 1) n`,
[]any{pgx.QueryResultFormats{pgx.TextFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -504,7 +504,7 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_uint64_1_rows_10_columns(b *
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 1) n`,
[]any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -522,7 +522,7 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_uint64_10_rows_1_columns(b *te
`select n::int4 + 0 from generate_series(1, 10) n`,
[]any{pgx.QueryResultFormats{pgx.TextFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -540,7 +540,7 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_uint64_10_rows_1_columns(b *
`select n::int4 + 0 from generate_series(1, 10) n`,
[]any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -558,7 +558,7 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_uint64_100_rows_10_columns(b *
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 100) n`,
[]any{pgx.QueryResultFormats{pgx.TextFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -576,7 +576,7 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_uint64_100_rows_10_columns(b
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 100) n`,
[]any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -594,7 +594,7 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_pgtype_Int4_1_rows_1_columns(b
`select n::int4 + 0 from generate_series(1, 1) n`,
[]any{pgx.QueryResultFormats{pgx.TextFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -612,7 +612,7 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_pgtype_Int4_1_rows_1_columns
`select n::int4 + 0 from generate_series(1, 1) n`,
[]any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -630,7 +630,7 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_pgtype_Int4_1_rows_10_columns(
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 1) n`,
[]any{pgx.QueryResultFormats{pgx.TextFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -648,7 +648,7 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_pgtype_Int4_1_rows_10_column
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 1) n`,
[]any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -666,7 +666,7 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_pgtype_Int4_10_rows_1_columns(
`select n::int4 + 0 from generate_series(1, 10) n`,
[]any{pgx.QueryResultFormats{pgx.TextFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -684,7 +684,7 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_pgtype_Int4_10_rows_1_column
`select n::int4 + 0 from generate_series(1, 10) n`,
[]any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -702,7 +702,7 @@ func BenchmarkQueryTextFormatDecode_PG_int4_to_Go_pgtype_Int4_100_rows_10_column
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 100) n`,
[]any{pgx.QueryResultFormats{pgx.TextFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -720,7 +720,7 @@ func BenchmarkQueryBinaryFormatDecode_PG_int4_to_Go_pgtype_Int4_100_rows_10_colu
`select n::int4 + 0, n::int4 + 1, n::int4 + 2, n::int4 + 3, n::int4 + 4, n::int4 + 5, n::int4 + 6, n::int4 + 7, n::int4 + 8, n::int4 + 9 from generate_series(1, 100) n`,
[]any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -738,7 +738,7 @@ func BenchmarkQueryTextFormatDecode_PG_numeric_to_Go_int64_1_rows_1_columns(b *t
`select n::numeric + 0 from generate_series(1, 1) n`,
[]any{pgx.QueryResultFormats{pgx.TextFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -756,7 +756,7 @@ func BenchmarkQueryBinaryFormatDecode_PG_numeric_to_Go_int64_1_rows_1_columns(b
`select n::numeric + 0 from generate_series(1, 1) n`,
[]any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -774,7 +774,7 @@ func BenchmarkQueryTextFormatDecode_PG_numeric_to_Go_int64_1_rows_10_columns(b *
`select n::numeric + 0, n::numeric + 1, n::numeric + 2, n::numeric + 3, n::numeric + 4, n::numeric + 5, n::numeric + 6, n::numeric + 7, n::numeric + 8, n::numeric + 9 from generate_series(1, 1) n`,
[]any{pgx.QueryResultFormats{pgx.TextFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -792,7 +792,7 @@ func BenchmarkQueryBinaryFormatDecode_PG_numeric_to_Go_int64_1_rows_10_columns(b
`select n::numeric + 0, n::numeric + 1, n::numeric + 2, n::numeric + 3, n::numeric + 4, n::numeric + 5, n::numeric + 6, n::numeric + 7, n::numeric + 8, n::numeric + 9 from generate_series(1, 1) n`,
[]any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -810,7 +810,7 @@ func BenchmarkQueryTextFormatDecode_PG_numeric_to_Go_int64_10_rows_1_columns(b *
`select n::numeric + 0 from generate_series(1, 10) n`,
[]any{pgx.QueryResultFormats{pgx.TextFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -828,7 +828,7 @@ func BenchmarkQueryBinaryFormatDecode_PG_numeric_to_Go_int64_10_rows_1_columns(b
`select n::numeric + 0 from generate_series(1, 10) n`,
[]any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -846,7 +846,7 @@ func BenchmarkQueryTextFormatDecode_PG_numeric_to_Go_int64_100_rows_10_columns(b
`select n::numeric + 0, n::numeric + 1, n::numeric + 2, n::numeric + 3, n::numeric + 4, n::numeric + 5, n::numeric + 6, n::numeric + 7, n::numeric + 8, n::numeric + 9 from generate_series(1, 100) n`,
[]any{pgx.QueryResultFormats{pgx.TextFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -864,7 +864,7 @@ func BenchmarkQueryBinaryFormatDecode_PG_numeric_to_Go_int64_100_rows_10_columns
`select n::numeric + 0, n::numeric + 1, n::numeric + 2, n::numeric + 3, n::numeric + 4, n::numeric + 5, n::numeric + 6, n::numeric + 7, n::numeric + 8, n::numeric + 9 from generate_series(1, 100) n`,
[]any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -882,7 +882,7 @@ func BenchmarkQueryTextFormatDecode_PG_numeric_to_Go_float64_1_rows_1_columns(b
`select n::numeric + 0 from generate_series(1, 1) n`,
[]any{pgx.QueryResultFormats{pgx.TextFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -900,7 +900,7 @@ func BenchmarkQueryBinaryFormatDecode_PG_numeric_to_Go_float64_1_rows_1_columns(
`select n::numeric + 0 from generate_series(1, 1) n`,
[]any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -918,7 +918,7 @@ func BenchmarkQueryTextFormatDecode_PG_numeric_to_Go_float64_1_rows_10_columns(b
`select n::numeric + 0, n::numeric + 1, n::numeric + 2, n::numeric + 3, n::numeric + 4, n::numeric + 5, n::numeric + 6, n::numeric + 7, n::numeric + 8, n::numeric + 9 from generate_series(1, 1) n`,
[]any{pgx.QueryResultFormats{pgx.TextFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -936,7 +936,7 @@ func BenchmarkQueryBinaryFormatDecode_PG_numeric_to_Go_float64_1_rows_10_columns
`select n::numeric + 0, n::numeric + 1, n::numeric + 2, n::numeric + 3, n::numeric + 4, n::numeric + 5, n::numeric + 6, n::numeric + 7, n::numeric + 8, n::numeric + 9 from generate_series(1, 1) n`,
[]any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -954,7 +954,7 @@ func BenchmarkQueryTextFormatDecode_PG_numeric_to_Go_float64_10_rows_1_columns(b
`select n::numeric + 0 from generate_series(1, 10) n`,
[]any{pgx.QueryResultFormats{pgx.TextFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -972,7 +972,7 @@ func BenchmarkQueryBinaryFormatDecode_PG_numeric_to_Go_float64_10_rows_1_columns
`select n::numeric + 0 from generate_series(1, 10) n`,
[]any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -990,7 +990,7 @@ func BenchmarkQueryTextFormatDecode_PG_numeric_to_Go_float64_100_rows_10_columns
`select n::numeric + 0, n::numeric + 1, n::numeric + 2, n::numeric + 3, n::numeric + 4, n::numeric + 5, n::numeric + 6, n::numeric + 7, n::numeric + 8, n::numeric + 9 from generate_series(1, 100) n`,
[]any{pgx.QueryResultFormats{pgx.TextFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -1008,7 +1008,7 @@ func BenchmarkQueryBinaryFormatDecode_PG_numeric_to_Go_float64_100_rows_10_colum
`select n::numeric + 0, n::numeric + 1, n::numeric + 2, n::numeric + 3, n::numeric + 4, n::numeric + 5, n::numeric + 6, n::numeric + 7, n::numeric + 8, n::numeric + 9 from generate_series(1, 100) n`,
[]any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -1026,7 +1026,7 @@ func BenchmarkQueryTextFormatDecode_PG_numeric_to_Go_pgtype_Numeric_1_rows_1_col
`select n::numeric + 0 from generate_series(1, 1) n`,
[]any{pgx.QueryResultFormats{pgx.TextFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -1044,7 +1044,7 @@ func BenchmarkQueryBinaryFormatDecode_PG_numeric_to_Go_pgtype_Numeric_1_rows_1_c
`select n::numeric + 0 from generate_series(1, 1) n`,
[]any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -1062,7 +1062,7 @@ func BenchmarkQueryTextFormatDecode_PG_numeric_to_Go_pgtype_Numeric_1_rows_10_co
`select n::numeric + 0, n::numeric + 1, n::numeric + 2, n::numeric + 3, n::numeric + 4, n::numeric + 5, n::numeric + 6, n::numeric + 7, n::numeric + 8, n::numeric + 9 from generate_series(1, 1) n`,
[]any{pgx.QueryResultFormats{pgx.TextFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -1080,7 +1080,7 @@ func BenchmarkQueryBinaryFormatDecode_PG_numeric_to_Go_pgtype_Numeric_1_rows_10_
`select n::numeric + 0, n::numeric + 1, n::numeric + 2, n::numeric + 3, n::numeric + 4, n::numeric + 5, n::numeric + 6, n::numeric + 7, n::numeric + 8, n::numeric + 9 from generate_series(1, 1) n`,
[]any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -1098,7 +1098,7 @@ func BenchmarkQueryTextFormatDecode_PG_numeric_to_Go_pgtype_Numeric_10_rows_1_co
`select n::numeric + 0 from generate_series(1, 10) n`,
[]any{pgx.QueryResultFormats{pgx.TextFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -1116,7 +1116,7 @@ func BenchmarkQueryBinaryFormatDecode_PG_numeric_to_Go_pgtype_Numeric_10_rows_1_
`select n::numeric + 0 from generate_series(1, 10) n`,
[]any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -1134,7 +1134,7 @@ func BenchmarkQueryTextFormatDecode_PG_numeric_to_Go_pgtype_Numeric_100_rows_10_
`select n::numeric + 0, n::numeric + 1, n::numeric + 2, n::numeric + 3, n::numeric + 4, n::numeric + 5, n::numeric + 6, n::numeric + 7, n::numeric + 8, n::numeric + 9 from generate_series(1, 100) n`,
[]any{pgx.QueryResultFormats{pgx.TextFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -1152,7 +1152,7 @@ func BenchmarkQueryBinaryFormatDecode_PG_numeric_to_Go_pgtype_Numeric_100_rows_1
`select n::numeric + 0, n::numeric + 1, n::numeric + 2, n::numeric + 3, n::numeric + 4, n::numeric + 5, n::numeric + 6, n::numeric + 7, n::numeric + 8, n::numeric + 9 from generate_series(1, 100) n`,
[]any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v[0], &v[1], &v[2], &v[3], &v[4], &v[5], &v[6], &v[7], &v[8], &v[9]}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -1170,7 +1170,7 @@ func BenchmarkQueryTextFormatDecode_PG_Int4Array_With_Go_Int4Array_10(b *testing
`select array_agg(n) from generate_series(1, 10) n`,
[]any{pgx.QueryResultFormats{pgx.TextFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -1188,7 +1188,7 @@ func BenchmarkQueryBinaryFormatDecode_PG_Int4Array_With_Go_Int4Array_10(b *testi
`select array_agg(n) from generate_series(1, 10) n`,
[]any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -1206,7 +1206,7 @@ func BenchmarkQueryTextFormatDecode_PG_Int4Array_With_Go_Int4Array_100(b *testin
`select array_agg(n) from generate_series(1, 100) n`,
[]any{pgx.QueryResultFormats{pgx.TextFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -1224,7 +1224,7 @@ func BenchmarkQueryBinaryFormatDecode_PG_Int4Array_With_Go_Int4Array_100(b *test
`select array_agg(n) from generate_series(1, 100) n`,
[]any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -1242,7 +1242,7 @@ func BenchmarkQueryTextFormatDecode_PG_Int4Array_With_Go_Int4Array_1000(b *testi
`select array_agg(n) from generate_series(1, 1000) n`,
[]any{pgx.QueryResultFormats{pgx.TextFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -1260,7 +1260,7 @@ func BenchmarkQueryBinaryFormatDecode_PG_Int4Array_With_Go_Int4Array_1000(b *tes
`select array_agg(n) from generate_series(1, 1000) n`,
[]any{pgx.QueryResultFormats{pgx.BinaryFormatCode}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
+2 -2
View File
@@ -27,7 +27,7 @@ func BenchmarkQuery<%= format_name %>FormatDecode_PG_<%= pg_type %>_to_Go_<%= go
`select <% columns.times do |col_idx| %><% if col_idx != 0 %>, <% end %>n::<%= pg_type %> + <%= col_idx%><% end %> from generate_series(1, <%= rows %>) n`,
[]any{pgx.QueryResultFormats{<%= format_code %>}},
)
_, err := pgx.ForEachScannedRow(rows, []any{<% columns.times do |col_idx| %><% if col_idx != 0 %>, <% end %>&v[<%= col_idx%>]<% end %>}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{<% columns.times do |col_idx| %><% if col_idx != 0 %>, <% end %>&v[<%= col_idx%>]<% end %>}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
@@ -51,7 +51,7 @@ func BenchmarkQuery<%= format_name %>FormatDecode_PG_Int4Array_With_Go_Int4Array
`select array_agg(n) from generate_series(1, <%= array_size %>) n`,
[]any{pgx.QueryResultFormats{<%= format_code %>}},
)
_, err := pgx.ForEachScannedRow(rows, []any{&v}, func() error { return nil })
_, err := pgx.ForEachRow(rows, []any{&v}, func() error { return nil })
if err != nil {
b.Fatal(err)
}
+3 -3
View File
@@ -371,10 +371,10 @@ func RowsFromResultReader(typeMap *pgtype.Map, resultReader *pgconn.ResultReader
}
}
// ForEachScannedRow iterates through rows. For each row it scans into the elements of scans and calls fn. If any row
// ForEachRow iterates through rows. For each row it scans into the elements of scans and calls fn. If any row
// fails to scan or fn returns an error the query will be aborted and the error will be returned. Rows will be closed
// when ForEachScannedRow returns.
func ForEachScannedRow(rows Rows, scans []any, fn func() error) (pgconn.CommandTag, error) {
// when ForEachRow returns.
func ForEachRow(rows Rows, scans []any, fn func() error) (pgconn.CommandTag, error) {
defer rows.Close()
for rows.Next() {
+9 -9
View File
@@ -35,7 +35,7 @@ func TestRowScanner(t *testing.T) {
})
}
func TestForEachScannedRow(t *testing.T) {
func TestForEachRow(t *testing.T) {
t.Parallel()
pgxtest.RunWithQueryExecModes(context.Background(), t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -47,7 +47,7 @@ func TestForEachScannedRow(t *testing.T) {
3,
)
var a, b int
ct, err := pgx.ForEachScannedRow(rows, []any{&a, &b}, func() error {
ct, err := pgx.ForEachRow(rows, []any{&a, &b}, func() error {
actualResults = append(actualResults, []any{a, b})
return nil
})
@@ -63,7 +63,7 @@ func TestForEachScannedRow(t *testing.T) {
})
}
func TestForEachScannedRowScanError(t *testing.T) {
func TestForEachRowScanError(t *testing.T) {
t.Parallel()
pgxtest.RunWithQueryExecModes(context.Background(), t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -75,7 +75,7 @@ func TestForEachScannedRowScanError(t *testing.T) {
3,
)
var a, b int
ct, err := pgx.ForEachScannedRow(rows, []any{&a, &b}, func() error {
ct, err := pgx.ForEachRow(rows, []any{&a, &b}, func() error {
actualResults = append(actualResults, []any{a, b})
return nil
})
@@ -84,7 +84,7 @@ func TestForEachScannedRowScanError(t *testing.T) {
})
}
func TestForEachScannedRowAbort(t *testing.T) {
func TestForEachRowAbort(t *testing.T) {
t.Parallel()
pgxtest.RunWithQueryExecModes(context.Background(), t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
@@ -94,7 +94,7 @@ func TestForEachScannedRowAbort(t *testing.T) {
3,
)
var a, b int
ct, err := pgx.ForEachScannedRow(rows, []any{&a, &b}, func() error {
ct, err := pgx.ForEachRow(rows, []any{&a, &b}, func() error {
return errors.New("abort")
})
require.EqualError(t, err, "abort")
@@ -102,7 +102,7 @@ func TestForEachScannedRowAbort(t *testing.T) {
})
}
func ExampleForEachScannedRow() {
func ExampleForEachRow() {
conn, err := pgx.Connect(context.Background(), os.Getenv("PGX_TEST_DATABASE"))
if err != nil {
fmt.Printf("Unable to establish connection: %v", err)
@@ -115,12 +115,12 @@ func ExampleForEachScannedRow() {
3,
)
var a, b int
_, err = pgx.ForEachScannedRow(rows, []any{&a, &b}, func() error {
_, err = pgx.ForEachRow(rows, []any{&a, &b}, func() error {
fmt.Printf("%v, %v\n", a, b)
return nil
})
if err != nil {
fmt.Printf("ForEachScannedRow error: %v", err)
fmt.Printf("ForEachRow error: %v", err)
return
}