This is an automated email from the ASF dual-hosted git repository.

reshke pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git


The following commit(s) were added to refs/heads/main by this push:
     new 8bde32cc2d4 Fix and rename --use-unique-keys option and add TAP test 
(#1508)
8bde32cc2d4 is described below

commit 8bde32cc2d427750a3a689b6c3fee4a49f7778d6
Author: reshke <[email protected]>
AuthorDate: Fri Dec 26 01:37:19 2025 +0500

    Fix and rename --use-unique-keys option and add TAP test (#1508)
    
    * 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.
    
    * Update 001_pgbench_with_server.pl
---
 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..282ccc24aeb 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 @@ $node->pgbench(
        ],
        '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{creating 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'


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to