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

Commit3ff01b2

Browse files
Adjust pgbench option for debug mode.
Many other utilities use -d to specify the database to use, butpgbench uses it to enable debug mode. This is causing some usersto accidentally enable it. This commit changes -d to accept thedatabase name and introduces --dbname. Debug mode can still beenabled with --debug. This is a backward-incompatible change, butit has been judged to be worth the trade-off, i.e., some scriptsthat use pgbench will need to be updated.Author: Greg Sabino MullaneReviewed-by: Tomas Vondra, Euler Taveira, Alvaro Herrera, David ChristensenDiscussion:https://postgr.es/m/CAKAnmmLjAzwVtb%3DVEaeuCtnmOLpzkJ1uJ_XiQ362YdD9B72HSg%40mail.gmail.com
1 parent374c7a2 commit3ff01b2

File tree

4 files changed

+24
-16
lines changed

4 files changed

+24
-16
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
162162
<variablelist>
163163

164164
<varlistentry id="pgbench-option-dbname">
165-
<term><replaceable class="parameter">dbname</replaceable></term>
165+
<term><option><optional>-d</optional> <replaceable class="parameter">dbname</replaceable></option></term>
166+
<term><option><optional>--dbname=</optional><replaceable class="parameter">dbname</replaceable></option></term>
166167
<listitem>
167168
<para>
168169
Specifies the name of the database to test in. If this is
@@ -463,7 +464,6 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
463464
</varlistentry>
464465

465466
<varlistentry id="pgbench-option-debug">
466-
<term><option>-d</option></term>
467467
<term><option>--debug</option></term>
468468
<listitem>
469469
<para>

‎src/bin/pgbench/pgbench.c

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,8 @@ usage(void)
933933
" --show-script=NAME show builtin script code, then exit\n"
934934
" --verbose-errors print messages of all errors\n"
935935
"\nCommon options:\n"
936-
" -d, --debug print debugging output\n"
936+
" --debug print debugging output\n"
937+
" -d, --dbname=DBNAME database name to connect to\n"
937938
" -h, --host=HOSTNAME database server host or socket directory\n"
938939
" -p, --port=PORT database server port number\n"
939940
" -U, --username=USERNAME connect as specified database user\n"
@@ -6620,7 +6621,7 @@ main(int argc, char **argv)
66206621
{"builtin",required_argument,NULL,'b'},
66216622
{"client",required_argument,NULL,'c'},
66226623
{"connect",no_argument,NULL,'C'},
6623-
{"debug",no_argument,NULL,'d'},
6624+
{"dbname",required_argument,NULL,'d'},
66246625
{"define",required_argument,NULL,'D'},
66256626
{"file",required_argument,NULL,'f'},
66266627
{"fillfactor",required_argument,NULL,'F'},
@@ -6661,6 +6662,7 @@ main(int argc, char **argv)
66616662
{"max-tries",required_argument,NULL,14},
66626663
{"verbose-errors",no_argument,NULL,15},
66636664
{"exit-on-abort",no_argument,NULL,16},
6665+
{"debug",no_argument,NULL,17},
66646666
{NULL,0,NULL,0}
66656667
};
66666668

@@ -6732,7 +6734,7 @@ main(int argc, char **argv)
67326734
if (!set_random_seed(getenv("PGBENCH_RANDOM_SEED")))
67336735
pg_fatal("error while setting random seed from PGBENCH_RANDOM_SEED environment variable");
67346736

6735-
while ((c=getopt_long(argc,argv,"b:c:CdD:f:F:h:iI:j:lL:M:nNp:P:qrR:s:St:T:U:v",long_options,&optindex))!=-1)
6737+
while ((c=getopt_long(argc,argv,"b:c:Cd:D:f:F:h:iI:j:lL:M:nNp:P:qrR:s:St:T:U:v",long_options,&optindex))!=-1)
67366738
{
67376739
char*script;
67386740

@@ -6773,7 +6775,7 @@ main(int argc, char **argv)
67736775
is_connect= true;
67746776
break;
67756777
case'd':
6776-
pg_logging_increase_verbosity();
6778+
dbName=pg_strdup(optarg);
67776779
break;
67786780
case'D':
67796781
{
@@ -6998,6 +7000,9 @@ main(int argc, char **argv)
69987000
benchmarking_option_set= true;
69997001
exit_on_abort= true;
70007002
break;
7003+
case17:/* debug */
7004+
pg_logging_increase_verbosity();
7005+
break;
70017006
default:
70027007
/* getopt_long already emitted a complaint */
70037008
pg_log_error_hint("Try \"%s --help\" for more information.",progname);
@@ -7048,16 +7053,19 @@ main(int argc, char **argv)
70487053
*/
70497054
throttle_delay *=nthreads;
70507055

7051-
if (argc>optind)
7052-
dbName=argv[optind++];
7053-
else
7056+
if (dbName==NULL)
70547057
{
7055-
if ((env=getenv("PGDATABASE"))!=NULL&&*env!='\0')
7056-
dbName=env;
7057-
elseif ((env=getenv("PGUSER"))!=NULL&&*env!='\0')
7058-
dbName=env;
7058+
if (argc>optind)
7059+
dbName=argv[optind++];
70597060
else
7060-
dbName=get_user_name_or_exit(progname);
7061+
{
7062+
if ((env=getenv("PGDATABASE"))!=NULL&&*env!='\0')
7063+
dbName=env;
7064+
elseif ((env=getenv("PGUSER"))!=NULL&&*env!='\0')
7065+
dbName=env;
7066+
else
7067+
dbName=get_user_name_or_exit(progname);
7068+
}
70617069
}
70627070

70637071
if (optind<argc)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1352,7 +1352,7 @@ sub check_pgbench_logs
13521352
."\\1";
13531353

13541354
$node->pgbench(
1355-
"-n -c 2 -t 1 -d --verbose-errors --max-tries 2",
1355+
"-n -c 2 -t 1 --debug --verbose-errors --max-tries 2",
13561356
0,
13571357
[
13581358
qr{processed: 2/2\b},

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ sub pgbench_scripts
6666
# name, options, stderr checks
6767
[
6868
'bad option',
69-
'-h home -p 5432 -U calvin -d --bad-option',
69+
'-h home -p 5432 -U calvin ---debug --bad-option',
7070
[qr{--help.*more information}]
7171
],
7272
[

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp