]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix options listing of pg_test_timing --cutoff
authorPeter Eisentraut <peter@eisentraut.org>
Thu, 25 Jun 2026 05:39:59 +0000 (07:39 +0200)
committerPeter Eisentraut <peter@eisentraut.org>
Thu, 25 Jun 2026 05:43:24 +0000 (07:43 +0200)
The new pg_test_timing --cutoff option (commit 0b096e379e6) appeared
out of order in the documentation and the code.  Fix that.

doc/src/sgml/ref/pgtesttiming.sgml
src/bin/pg_test_timing/pg_test_timing.c

index bbb511ae94a1fbd2fc8d7451a92b81d9520f2b7f..285f27f7c3135ac3360df12e3cbfb30ffa3e6df6 100644 (file)
@@ -62,19 +62,6 @@ PostgreSQL documentation
 
     <variablelist>
 
-     <varlistentry>
-      <term><option>-d <replaceable class="parameter">duration</replaceable></option></term>
-      <term><option>--duration=<replaceable class="parameter">duration</replaceable></option></term>
-      <listitem>
-       <para>
-        Specifies the test duration, in seconds. Longer durations
-        give slightly better accuracy, and are more likely to discover
-        problems with the system clock moving backwards. The default
-        test duration is 3 seconds.
-       </para>
-      </listitem>
-     </varlistentry>
-
      <varlistentry>
       <term><option>-c <replaceable class="parameter">cutoff</replaceable></option></term>
       <term><option>--cutoff=<replaceable class="parameter">cutoff</replaceable></option></term>
@@ -90,6 +77,19 @@ PostgreSQL documentation
       </listitem>
      </varlistentry>
 
+     <varlistentry>
+      <term><option>-d <replaceable class="parameter">duration</replaceable></option></term>
+      <term><option>--duration=<replaceable class="parameter">duration</replaceable></option></term>
+      <listitem>
+       <para>
+        Specifies the test duration, in seconds. Longer durations
+        give slightly better accuracy, and are more likely to discover
+        problems with the system clock moving backwards. The default
+        test duration is 3 seconds.
+       </para>
+      </listitem>
+     </varlistentry>
+
      <varlistentry>
       <term><option>-V</option></term>
       <term><option>--version</option></term>
index fcfd0456b5544aad1b7630a1583e8769b7cbc07a..d63018f270fb38caa47078e7f1e3d6c52afc5ca5 100644 (file)
@@ -62,8 +62,8 @@ static void
 handle_args(int argc, char *argv[])
 {
        static struct option long_options[] = {
-               {"duration", required_argument, NULL, 'd'},
                {"cutoff", required_argument, NULL, 'c'},
+               {"duration", required_argument, NULL, 'd'},
                {NULL, 0, NULL, 0}
        };
 
@@ -76,7 +76,7 @@ handle_args(int argc, char *argv[])
        {
                if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-?") == 0)
                {
-                       printf(_("Usage: %s [-d DURATION] [-c CUTOFF]\n"), progname);
+                       printf(_("Usage: %s [-c CUTOFF] [-d DURATION]\n"), progname);
                        exit(0);
                }
                if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0)
@@ -86,49 +86,49 @@ handle_args(int argc, char *argv[])
                }
        }
 
-       while ((option = getopt_long(argc, argv, "d:c:",
+       while ((option = getopt_long(argc, argv, "c:d:",
                                                                 long_options, &optindex)) != -1)
        {
                switch (option)
                {
-                       case 'd':
+                       case 'c':
                                errno = 0;
-                               optval = strtoul(optarg, &endptr, 10);
+                               max_rprct = strtod(optarg, &endptr);
 
-                               if (endptr == optarg || *endptr != '\0' ||
-                                       errno != 0 || optval != (unsigned int) optval)
+                               if (endptr == optarg || *endptr != '\0' || errno != 0)
                                {
                                        fprintf(stderr, _("%s: invalid argument for option %s\n"),
-                                                       progname, "--duration");
+                                                       progname, "--cutoff");
                                        fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
                                        exit(1);
                                }
 
-                               test_duration = (unsigned int) optval;
-                               if (test_duration == 0)
+                               if (max_rprct < 0 || max_rprct > 100)
                                {
                                        fprintf(stderr, _("%s: %s must be in range %u..%u\n"),
-                                                       progname, "--duration", 1, UINT_MAX);
+                                                       progname, "--cutoff", 0, 100);
                                        exit(1);
                                }
                                break;
 
-                       case 'c':
+                       case 'd':
                                errno = 0;
-                               max_rprct = strtod(optarg, &endptr);
+                               optval = strtoul(optarg, &endptr, 10);
 
-                               if (endptr == optarg || *endptr != '\0' || errno != 0)
+                               if (endptr == optarg || *endptr != '\0' ||
+                                       errno != 0 || optval != (unsigned int) optval)
                                {
                                        fprintf(stderr, _("%s: invalid argument for option %s\n"),
-                                                       progname, "--cutoff");
+                                                       progname, "--duration");
                                        fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
                                        exit(1);
                                }
 
-                               if (max_rprct < 0 || max_rprct > 100)
+                               test_duration = (unsigned int) optval;
+                               if (test_duration == 0)
                                {
                                        fprintf(stderr, _("%s: %s must be in range %u..%u\n"),
-                                                       progname, "--cutoff", 0, 100);
+                                                       progname, "--duration", 1, UINT_MAX);
                                        exit(1);
                                }
                                break;