=== Applying patches on top of PostgreSQL commit ID 8db08e2522954916009dccdd88a634b1658bc522 === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Thu Sep 10 17:31:31 UTC 2026 On branch cf/7163 nothing to commit, working tree clean === using 'git am' to apply patch ./v2-0001-Make-pgbench-gset-and-aset-store-SQL-NULL-as-the-.patch === Applying: Make pgbench \gset and \aset store SQL NULL as the null value Using index info to reconstruct a base tree... M src/bin/pgbench/pgbench.c M src/bin/pgbench/t/001_pgbench_with_server.pl Falling back to patching base and 3-way merge... Auto-merging src/bin/pgbench/t/001_pgbench_with_server.pl CONFLICT (content): Merge conflict in src/bin/pgbench/t/001_pgbench_with_server.pl Auto-merging src/bin/pgbench/pgbench.c CONFLICT (content): Merge conflict in src/bin/pgbench/pgbench.c error: Failed to merge in the changes. hint: Use 'git am --show-current-patch=diff' to see the failed patch Patch failed at 0001 Make pgbench \gset and \aset store SQL NULL as the null value When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort". === using patch(1) to apply patch ./v2-0001-Make-pgbench-gset-and-aset-store-SQL-NULL-as-the-.patch === patching file src/bin/pgbench/pgbench.c Hunk #1 FAILED at 3319. Hunk #2 FAILED at 3338. 2 out of 2 hunks FAILED -- saving rejects to file src/bin/pgbench/pgbench.c.rej patching file src/bin/pgbench/t/001_pgbench_with_server.pl Hunk #1 succeeded at 864 (offset 14 lines). Unstaged changes after reset: M src/bin/pgbench/t/001_pgbench_with_server.pl Removing src/bin/pgbench/pgbench.c.rej === using 'git apply' to apply patch ./v2-0001-Make-pgbench-gset-and-aset-store-SQL-NULL-as-the-.patch === Applied patch to 'src/bin/pgbench/pgbench.c' with conflicts. Applied patch to 'src/bin/pgbench/t/001_pgbench_with_server.pl' with conflicts. U src/bin/pgbench/pgbench.c U src/bin/pgbench/t/001_pgbench_with_server.pl diff --cc src/bin/pgbench/pgbench.c index 181f0d892ef,bfd33383f7d..00000000000 --- a/src/bin/pgbench/pgbench.c +++ b/src/bin/pgbench/pgbench.c @@@ -3319,7 -3319,7 +3319,11 @@@ readCommandResponse(CState *st, MetaCom if ((is_last && meta == META_GSET) || meta == META_ASET) { int ntuples = PQntuples(res); ++<<<<<<< ours + const char *context = (meta == META_ASET) ? "aset" : "gset"; ++======= + const char *context = meta == META_ASET ? "aset" : "gset"; ++>>>>>>> theirs if (meta == META_GSET && ntuples != 1) { @@@ -3345,7 -3345,7 +3349,11 @@@ if (*varprefix != '\0') varname = psprintf("%s%s", varprefix, varname); ++<<<<<<< ours + /* store last row result */ ++======= + /* store last row result, SQL NULL as null value */ ++>>>>>>> theirs if (PQgetisnull(res, ntuples - 1, fld)) { PgBenchValue nullval; diff --cc src/bin/pgbench/t/001_pgbench_with_server.pl index b669ad9d92f,8913dc62c42..00000000000 --- a/src/bin/pgbench/t/001_pgbench_with_server.pl +++ b/src/bin/pgbench/t/001_pgbench_with_server.pl @@@ -850,7 -850,7 +850,11 @@@ SELECT 5432 AS fail UNION SELECT 5433 O } }); ++<<<<<<< ours +# \gset stores a SQL NULL as the null value. ++======= + # \gset stores a SQL NULL as the null value, which expressions can use. ++>>>>>>> theirs $node->pgbench( '-t 1', 0, [ qr{type: .*/001_pgbench_gset_null}, qr{processed: 1/1} ], @@@ -864,6 -864,59 +868,62 @@@ SELECT NULL AS nv \gse } }); ++<<<<<<< ours ++======= + # NULL and empty string captured by \gset stay distinct when interpolated + $node->safe_psql('postgres', + 'CREATE UNLOGGED TABLE gset_null_tab(id INTEGER, t TEXT);'); + + $node->pgbench( + '-t 1', 0, + [ qr{type: .*/001_pgbench_gset_null_interp}, qr{processed: 1/1} ], + [], + 'pgbench gset NULL interpolation', + { + '001_pgbench_gset_null_interp' => q{-- interpolate NULL and '' + SELECT NULL AS nv, ''::text AS es \gset + INSERT INTO gset_null_tab VALUES (1, :nv); + INSERT INTO gset_null_tab VALUES (2, ':es'); + } + }); + + is( $node->safe_psql( + 'postgres', 'SELECT t IS NULL FROM gset_null_tab WHERE id = 1;'), + 't', + 'gset NULL interpolates as SQL NULL'); + is( $node->safe_psql( + 'postgres', "SELECT t = '' FROM gset_null_tab WHERE id = 2;"), + 't', + 'gset empty string stays empty'); + + # In the extended and prepared query modes a NULL-valued variable is bound as + # the string "NULL", not as an SQL null parameter. + for my $mode ('extended', 'prepared') + { + $node->pgbench( + "-t 1 -M $mode", + 0, + [ qr{type: .*/001_pgbench_gset_null_param_$mode}, qr{processed: 1/1} ], + [], + "pgbench gset NULL as query parameter ($mode)", + { + "001_pgbench_gset_null_param_$mode" => + q{-- NULL bound as a query parameter + SELECT NULL AS nv \gset + INSERT INTO gset_null_tab VALUES (3, :nv); + } + }); + } + + is( $node->safe_psql( + 'postgres', + "SELECT count(*) FROM gset_null_tab WHERE id = 3 AND t = 'NULL';"), + '2', + 'gset NULL is bound as the string NULL in extended and prepared modes'); + + $node->safe_psql('postgres', 'DROP TABLE gset_null_tab;'); + ++>>>>>>> theirs # working \aset # Valid cases. $node->pgbench(