Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5823677

Browse files
committed
Provide pgbench --show-script to dump built-in scripts.
Author: Fabien CoelhoReviewed-by: Ibrar AhmedDiscussion:https://postgr.es/m/alpine.DEB.2.21.1904081737390.5867%40lancre
1 parentce8f946 commit5823677

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

‎doc/src/sgml/ref/pgbench.sgml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,6 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
355355
</listitem>
356356
</varlistentry>
357357

358-
359358
<varlistentry>
360359
<term><option>-c</option> <replaceable>clients</replaceable></term>
361360
<term><option>--client=</option><replaceable>clients</replaceable></term>
@@ -617,6 +616,16 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
617616
</listitem>
618617
</varlistentry>
619618

619+
<varlistentry>
620+
<term><option>--show-script</option><replaceable>scriptname</replaceable></term>
621+
<listitem>
622+
<para>
623+
Show the actual code of builtin script <replaceable>scriptname</replaceable>
624+
on stderr, and exit immediately.
625+
</para>
626+
</listitem>
627+
</varlistentry>
628+
620629
<varlistentry>
621630
<term><option>-t</option> <replaceable>transactions</replaceable></term>
622631
<term><option>--transactions=</option><replaceable>transactions</replaceable></term>

‎src/bin/pgbench/pgbench.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,7 @@ usage(void)
651651
" --progress-timestamp use Unix epoch timestamps for progress\n"
652652
" --random-seed=SEED set random seed (\"time\", \"rand\", integer)\n"
653653
" --sampling-rate=NUM fraction of transactions to log (e.g., 0.01 for 1%%)\n"
654+
" --show-script=NAME show builtin script code, then exit\n"
654655
"\nCommon options:\n"
655656
" -d, --debug print debugging output\n"
656657
" -h, --host=HOSTNAME database server host or socket directory\n"
@@ -4684,7 +4685,7 @@ listAvailableScripts(void)
46844685

46854686
fprintf(stderr,"Available builtin scripts:\n");
46864687
for (i=0;i<lengthof(builtin_script);i++)
4687-
fprintf(stderr,"\t%s\n",builtin_script[i].name);
4688+
fprintf(stderr," %13s: %s\n",builtin_script[i].name,builtin_script[i].desc);
46884689
fprintf(stderr,"\n");
46894690
}
46904691

@@ -5124,6 +5125,7 @@ main(int argc, char **argv)
51245125
{"log-prefix",required_argument,NULL,7},
51255126
{"foreign-keys",no_argument,NULL,8},
51265127
{"random-seed",required_argument,NULL,9},
5128+
{"show-script",required_argument,NULL,10},
51275129
{NULL,0,NULL,0}
51285130
};
51295131

@@ -5476,6 +5478,14 @@ main(int argc, char **argv)
54765478
exit(1);
54775479
}
54785480
break;
5481+
case10:/* list */
5482+
{
5483+
constBuiltinScript*s=findBuiltin(optarg);
5484+
5485+
fprintf(stderr,"-- %s: %s\n%s\n",s->name,s->desc,s->script);
5486+
exit(0);
5487+
}
5488+
break;
54795489
default:
54805490
fprintf(stderr,_("Try \"%s --help\" for more information.\n"),progname);
54815491
exit(1);

‎src/bin/pgbench/t/002_pgbench_no_server.pl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,15 @@ sub pgbench_scripts
218218
],
219219
'pgbench builtin list');
220220

221+
# builtin listing
222+
pgbench(
223+
'--show-script se',
224+
0,
225+
[qr{^$}],
226+
[qr{select-only:},qr{SELECT abalance FROM pgbench_accounts WHERE},
227+
qr{(?!UPDATE)},qr{(?!INSERT)} ],
228+
'pgbench builtin listing');
229+
221230
my@script_tests = (
222231

223232
# name, err, { file => contents }

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp