Skip to content

Commit 61cff7b

Browse files
committed
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.
1 parent 68e5248 commit 61cff7b

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

src/bin/pgbench/pgbench.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ usage(void)
716716
" -q, --quiet quiet logging (one message each 5 seconds)\n"
717717
" -s, --scale=NUM scaling factor\n"
718718
" --foreign-keys create foreign key constraints between tables\n"
719-
" --use-unique-keys make the indexes that are created non-unique indexes\n"
719+
" --use-non-unique-keys make the indexes that are created non-unique indexes\n"
720720
" (default: unique)\n"
721721
" --index-tablespace=TABLESPACE\n"
722722
" create indexes in the specified tablespace\n"
@@ -4382,7 +4382,11 @@ initCreatePKeys(PGconn *con)
43824382
int i;
43834383
PQExpBufferData query;
43844384

4385-
fprintf(stderr, "creating primary keys...\n");
4385+
if (use_unique_key)
4386+
fprintf(stderr, "creating primary keys...\n");
4387+
else
4388+
fprintf(stderr, "creating non-unique keys...\n");
4389+
43864390
initPQExpBuffer(&query);
43874391

43884392
for (i = 0; i < lengthof(DDLINDEXes); i++)
@@ -5837,7 +5841,8 @@ main(int argc, char **argv)
58375841
{"show-script", required_argument, NULL, 10},
58385842
{"partitions", required_argument, NULL, 11},
58395843
{"partition-method", required_argument, NULL, 12},
5840-
{"use-unique-keys", no_argument, &use_unique_key, 1},
5844+
/* Cloudberry-specific */
5845+
{"use-non-unique-keys", no_argument, NULL, 13},
58415846
{NULL, 0, NULL, 0}
58425847
};
58435848

@@ -6217,6 +6222,9 @@ main(int argc, char **argv)
62176222
exit(1);
62186223
}
62196224
break;
6225+
case 13:
6226+
use_unique_key = 0;
6227+
break;
62206228
default:
62216229
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
62226230
exit(1);

src/bin/pgbench/t/001_pgbench_with_server.pl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,19 @@
100100
],
101101
'pgbench --init-steps');
102102

103+
104+
# Test interaction of --init-steps with legacy step-selection options
105+
$node->pgbench(
106+
'--initialize --use-non-unique-keys',
107+
0,
108+
[qr{^$}],
109+
[
110+
qr{creating tables},
111+
qr{reating non-unique keys},
112+
qr{done in \d+\.\d\d s }
113+
],
114+
'pgbench --use-non-unique-keys');
115+
103116
# Run all builtin scripts, for a few transactions each
104117
$node->pgbench(
105118
'--transactions=5 -Dfoo=bla --client=2 --protocol=simple --builtin=t'

0 commit comments

Comments
 (0)