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

Commitd561f1c

Browse files
committed
pgbench: accept unambiguous builtin prefixes for -b
This makes it easier to use "-b se" instead of typing the full "-bselect-only".Author: Fabien CoelhoReviewed-by: Michaël Paquier
1 parent2c83f43 commitd561f1c

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
269269
Add the specified builtin script to the list of executed scripts.
270270
Available builtin scripts are: <literal>tpcb-like</>,
271271
<literal>simple-update</> and <literal>select-only</>.
272+
Unambiguous prefixes of builtin names are accepted.
272273
With special name <literal>list</>, show the list of builtin scripts
273274
and exit immediately.
274275
</para>

‎src/bin/pgbench/pgbench.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2746,22 +2746,36 @@ listAvailableScripts(void)
27462746
fprintf(stderr,"\n");
27472747
}
27482748

2749+
/* return builtin script "name" if unambiguous */
27492750
staticchar*
27502751
findBuiltin(constchar*name,char**desc)
27512752
{
2752-
inti;
2753+
inti,
2754+
found=0,
2755+
len=strlen(name);
2756+
char*commands=NULL;
27532757

27542758
for (i=0;i<N_BUILTIN;i++)
27552759
{
2756-
if (strncmp(builtin_script[i].name,name,
2757-
strlen(builtin_script[i].name))==0)
2760+
if (strncmp(builtin_script[i].name,name,len)==0)
27582761
{
27592762
*desc=builtin_script[i].desc;
2760-
returnbuiltin_script[i].commands;
2763+
commands=builtin_script[i].commands;
2764+
found++;
27612765
}
27622766
}
27632767

2764-
fprintf(stderr,"no builtin script found for name \"%s\"\n",name);
2768+
/* ok, unambiguous result */
2769+
if (found==1)
2770+
returncommands;
2771+
2772+
/* error cases */
2773+
if (found==0)
2774+
fprintf(stderr,"no builtin script found for name \"%s\"\n",name);
2775+
else/* found > 1 */
2776+
fprintf(stderr,
2777+
"ambiguous builtin name: %d builtin scripts found for prefix \"%s\"\n",found,name);
2778+
27652779
listAvailableScripts();
27662780
exit(1);
27672781
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp