Provide pgbench --show-script to dump built-in scripts.
Author: Fabien Coelho Reviewed-by: Ibrar Ahmed Discussion: https://postgr.es/m/alpine.DEB.2.21.1904081737390.5867%40lancre
This commit is contained in:
parent
ce8f946764
commit
5823677acc
|
@ -355,7 +355,6 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><option>-c</option> <replaceable>clients</replaceable></term>
|
<term><option>-c</option> <replaceable>clients</replaceable></term>
|
||||||
<term><option>--client=</option><replaceable>clients</replaceable></term>
|
<term><option>--client=</option><replaceable>clients</replaceable></term>
|
||||||
|
@ -617,6 +616,16 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><option>--show-script</option><replaceable>scriptname</replaceable></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Show the actual code of builtin script <replaceable>scriptname</replaceable>
|
||||||
|
on stderr, and exit immediately.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><option>-t</option> <replaceable>transactions</replaceable></term>
|
<term><option>-t</option> <replaceable>transactions</replaceable></term>
|
||||||
<term><option>--transactions=</option><replaceable>transactions</replaceable></term>
|
<term><option>--transactions=</option><replaceable>transactions</replaceable></term>
|
||||||
|
|
|
@ -651,6 +651,7 @@ usage(void)
|
||||||
" --progress-timestamp use Unix epoch timestamps for progress\n"
|
" --progress-timestamp use Unix epoch timestamps for progress\n"
|
||||||
" --random-seed=SEED set random seed (\"time\", \"rand\", integer)\n"
|
" --random-seed=SEED set random seed (\"time\", \"rand\", integer)\n"
|
||||||
" --sampling-rate=NUM fraction of transactions to log (e.g., 0.01 for 1%%)\n"
|
" --sampling-rate=NUM fraction of transactions to log (e.g., 0.01 for 1%%)\n"
|
||||||
|
" --show-script=NAME show builtin script code, then exit\n"
|
||||||
"\nCommon options:\n"
|
"\nCommon options:\n"
|
||||||
" -d, --debug print debugging output\n"
|
" -d, --debug print debugging output\n"
|
||||||
" -h, --host=HOSTNAME database server host or socket directory\n"
|
" -h, --host=HOSTNAME database server host or socket directory\n"
|
||||||
|
@ -4684,7 +4685,7 @@ listAvailableScripts(void)
|
||||||
|
|
||||||
fprintf(stderr, "Available builtin scripts:\n");
|
fprintf(stderr, "Available builtin scripts:\n");
|
||||||
for (i = 0; i < lengthof(builtin_script); i++)
|
for (i = 0; i < lengthof(builtin_script); i++)
|
||||||
fprintf(stderr, "\t%s\n", builtin_script[i].name);
|
fprintf(stderr, " %13s: %s\n", builtin_script[i].name, builtin_script[i].desc);
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5124,6 +5125,7 @@ main(int argc, char **argv)
|
||||||
{"log-prefix", required_argument, NULL, 7},
|
{"log-prefix", required_argument, NULL, 7},
|
||||||
{"foreign-keys", no_argument, NULL, 8},
|
{"foreign-keys", no_argument, NULL, 8},
|
||||||
{"random-seed", required_argument, NULL, 9},
|
{"random-seed", required_argument, NULL, 9},
|
||||||
|
{"show-script", required_argument, NULL, 10},
|
||||||
{NULL, 0, NULL, 0}
|
{NULL, 0, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -5476,6 +5478,14 @@ main(int argc, char **argv)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 10: /* list */
|
||||||
|
{
|
||||||
|
const BuiltinScript *s = findBuiltin(optarg);
|
||||||
|
|
||||||
|
fprintf(stderr, "-- %s: %s\n%s\n", s->name, s->desc, s->script);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
|
fprintf(stderr, _("Try \"%s --help\" for more information.\n"), progname);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
|
@ -218,6 +218,15 @@ pgbench(
|
||||||
],
|
],
|
||||||
'pgbench builtin list');
|
'pgbench builtin list');
|
||||||
|
|
||||||
|
# builtin listing
|
||||||
|
pgbench(
|
||||||
|
'--show-script se',
|
||||||
|
0,
|
||||||
|
[qr{^$}],
|
||||||
|
[ qr{select-only: }, qr{SELECT abalance FROM pgbench_accounts WHERE},
|
||||||
|
qr{(?!UPDATE)}, qr{(?!INSERT)} ],
|
||||||
|
'pgbench builtin listing');
|
||||||
|
|
||||||
my @script_tests = (
|
my @script_tests = (
|
||||||
|
|
||||||
# name, err, { file => contents }
|
# name, err, { file => contents }
|
||||||
|
|
Loading…
Reference in New Issue