From 61cff7b1be3ae89623c51f711ec618978cf4df98 Mon Sep 17 00:00:00 2001 From: reshke Date: Wed, 24 Dec 2025 21:36:38 +0000 Subject: [PATCH 1/2] Fix and rename --use-unique-keys option and add TAP test Cloudberry has --use-unique-keys options since cc797b9. However, it does not work, at least at current HEAD. Fix that, and also rename option, to better indicate its use case. If user does NOT use this option, pgbenc will create unique index. If use does use this option, pgbench will not. So, rename to --use-non-unique-keys. Found during PG16 kernel rebase. --- src/bin/pgbench/pgbench.c | 14 +++++++++++--- src/bin/pgbench/t/001_pgbench_with_server.pl | 13 +++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c index cf8dec81eec..e0dfadcf414 100644 --- a/src/bin/pgbench/pgbench.c +++ b/src/bin/pgbench/pgbench.c @@ -716,7 +716,7 @@ usage(void) " -q, --quiet quiet logging (one message each 5 seconds)\n" " -s, --scale=NUM scaling factor\n" " --foreign-keys create foreign key constraints between tables\n" - " --use-unique-keys make the indexes that are created non-unique indexes\n" + " --use-non-unique-keys make the indexes that are created non-unique indexes\n" " (default: unique)\n" " --index-tablespace=TABLESPACE\n" " create indexes in the specified tablespace\n" @@ -4382,7 +4382,11 @@ initCreatePKeys(PGconn *con) int i; PQExpBufferData query; - fprintf(stderr, "creating primary keys...\n"); + if (use_unique_key) + fprintf(stderr, "creating primary keys...\n"); + else + fprintf(stderr, "creating non-unique keys...\n"); + initPQExpBuffer(&query); for (i = 0; i < lengthof(DDLINDEXes); i++) @@ -5837,7 +5841,8 @@ main(int argc, char **argv) {"show-script", required_argument, NULL, 10}, {"partitions", required_argument, NULL, 11}, {"partition-method", required_argument, NULL, 12}, - {"use-unique-keys", no_argument, &use_unique_key, 1}, + /* Cloudberry-specific */ + {"use-non-unique-keys", no_argument, NULL, 13}, {NULL, 0, NULL, 0} }; @@ -6217,6 +6222,9 @@ main(int argc, char **argv) exit(1); } break; + case 13: + use_unique_key = 0; + break; default: fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname); exit(1); diff --git a/src/bin/pgbench/t/001_pgbench_with_server.pl b/src/bin/pgbench/t/001_pgbench_with_server.pl index 796eb57208d..4fe586bffa9 100644 --- a/src/bin/pgbench/t/001_pgbench_with_server.pl +++ b/src/bin/pgbench/t/001_pgbench_with_server.pl @@ -100,6 +100,19 @@ ], 'pgbench --init-steps'); + +# Test interaction of --init-steps with legacy step-selection options +$node->pgbench( + '--initialize --use-non-unique-keys', + 0, + [qr{^$}], + [ + qr{creating tables}, + qr{reating non-unique keys}, + qr{done in \d+\.\d\d s } + ], + 'pgbench --use-non-unique-keys'); + # Run all builtin scripts, for a few transactions each $node->pgbench( '--transactions=5 -Dfoo=bla --client=2 --protocol=simple --builtin=t' From af01c9155a503978a78ea8e7d6258db2d3c10352 Mon Sep 17 00:00:00 2001 From: reshke Date: Thu, 25 Dec 2025 11:12:55 +0500 Subject: [PATCH 2/2] Update 001_pgbench_with_server.pl --- src/bin/pgbench/t/001_pgbench_with_server.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/pgbench/t/001_pgbench_with_server.pl b/src/bin/pgbench/t/001_pgbench_with_server.pl index 4fe586bffa9..282ccc24aeb 100644 --- a/src/bin/pgbench/t/001_pgbench_with_server.pl +++ b/src/bin/pgbench/t/001_pgbench_with_server.pl @@ -108,7 +108,7 @@ [qr{^$}], [ qr{creating tables}, - qr{reating non-unique keys}, + qr{creating non-unique keys}, qr{done in \d+\.\d\d s } ], 'pgbench --use-non-unique-keys');