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

Commita478415

Browse files
committed
pgbench: increase the maximum number of variables/arguments
pgbench's arbitrary limit of 10 arguments for SQL statements ormetacommands is far too low. Increase it to 256.This results in a very modest increase in memory usage, not enough toworry about.The maximum includes the SQL statement or metacommand. This is reflectedin the comments and revised TAP tests.Simon Riggs and Dagfinn Ilmari Mannsåker with some light editing by me.Reviewed by: David Rowley and Fabien CoelhoDiscussion:https://postgr.es/m/CANP8+jJiMJOAf-dLoHuR-8GENiK+eHTY=Omw38Qx7j2g0NDTXA@mail.gmail.com
1 parenta6e48da commita478415

File tree

3 files changed

+21
-24
lines changed

3 files changed

+21
-24
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,8 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
916916
value can be inserted into a SQL command by writing
917917
<literal>:</literal><replaceable>variablename</replaceable>. When running more than
918918
one client session, each session has its own set of variables.
919+
<application>pgbench</application> supports up to 255 variable uses in one
920+
statement.
919921
</para>
920922

921923
<table id="pgbench-automatic-variables">

‎src/bin/pgbench/pgbench.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,12 @@ typedef struct
476476
*/
477477
#defineSQL_COMMAND1
478478
#defineMETA_COMMAND2
479-
#defineMAX_ARGS10
479+
480+
/*
481+
* max number of backslash command arguments or SQL variables,
482+
* including the command or SQL statement itself
483+
*/
484+
#defineMAX_ARGS256
480485

481486
typedefenumMetaCommand
482487
{
@@ -4124,6 +4129,10 @@ parseQuery(Command *cmd)
41244129
continue;
41254130
}
41264131

4132+
/*
4133+
* cmd->argv[0] is the SQL statement itself, so the max number of
4134+
* arguments is one less than MAX_ARGS
4135+
*/
41274136
if (cmd->argc >=MAX_ARGS)
41284137
{
41294138
fprintf(stderr,"statement has too many arguments (maximum is %d): %s\n",
@@ -4461,6 +4470,10 @@ process_backslash_command(PsqlScanState sstate, const char *source)
44614470
/* For all other commands, collect remaining words. */
44624471
while (expr_lex_one_word(sstate,&word_buf,&word_offset))
44634472
{
4473+
/*
4474+
* my_command->argv[0] is the command itself, so the max number of
4475+
* arguments is one less than MAX_ARGS
4476+
*/
44644477
if (j >=MAX_ARGS)
44654478
syntax_error(source,lineno,my_command->first_line,my_command->argv[0],
44664479
"too many arguments",NULL,-1);

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

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -597,11 +597,10 @@ sub pgbench
597597
}
598598
],
599599
[
600-
'sql too many args', 1, [qr{statement has too many arguments.*\b9\b}],
601-
q{-- MAX_ARGS=10 for prepared
600+
'sql too many args', 1, [qr{statement has too many arguments.*\b255\b}],
601+
q{-- MAX_ARGS=256 for prepared
602602
\set i 0
603-
SELECT LEAST(:i, :i, :i, :i, :i, :i, :i, :i, :i, :i, :i);
604-
}
603+
SELECT LEAST(}.join(',', (':i')x256).q{)}
605604
],
606605

607606
# SHELL
@@ -619,25 +618,8 @@ sub pgbench
619618
['shell missing command', 1, [qr{missing command}],q{\shell} ],
620619
[
621620
'shell too many args', 1, [qr{too many arguments in command "shell"}],
622-
q{-- 257 arguments to \shell
623-
\shell echo \
624-
0 1 2 3 4 5 6 7 8 9 A B C D E F \
625-
0 1 2 3 4 5 6 7 8 9 A B C D E F \
626-
0 1 2 3 4 5 6 7 8 9 A B C D E F \
627-
0 1 2 3 4 5 6 7 8 9 A B C D E F \
628-
0 1 2 3 4 5 6 7 8 9 A B C D E F \
629-
0 1 2 3 4 5 6 7 8 9 A B C D E F \
630-
0 1 2 3 4 5 6 7 8 9 A B C D E F \
631-
0 1 2 3 4 5 6 7 8 9 A B C D E F \
632-
0 1 2 3 4 5 6 7 8 9 A B C D E F \
633-
0 1 2 3 4 5 6 7 8 9 A B C D E F \
634-
0 1 2 3 4 5 6 7 8 9 A B C D E F \
635-
0 1 2 3 4 5 6 7 8 9 A B C D E F \
636-
0 1 2 3 4 5 6 7 8 9 A B C D E F \
637-
0 1 2 3 4 5 6 7 8 9 A B C D E F \
638-
0 1 2 3 4 5 6 7 8 9 A B C D E F \
639-
0 1 2 3 4 5 6 7 8 9 A B C D E F
640-
}
621+
q{-- 256 arguments to \shell
622+
\shell echo}.join('', ('arg')x255)
641623
],
642624

643625
# SET

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp