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

Commitec0dc2c

Browse files
committed
pgbench: fix misprocessing of some nested \if constructs.
An \if command appearing within a false (not-to-be-executed) \ifbranch was incorrectly treated the same as \elif. This could allowstatements within the inner \if to be executed when they shouldnot be. Also the missing inner \if stack entry would result in anassertion failure (in assert-enabled builds) when the final \endifis reached.Report and patch by Michail Nikolaev. Back-patch to allsupported branches.Discussion:https://postgr.es/m/CANtu0oiA1ke=SP6tauhNqkUdv5QFsJtS1p=aOOf_iU+EhyKkjQ@mail.gmail.com
1 parentb6df2d6 commitec0dc2c

File tree

2 files changed

+59
-7
lines changed

2 files changed

+59
-7
lines changed

‎src/bin/pgbench/pgbench.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3133,8 +3133,14 @@ advanceConnectionState(TState *thread, CState *st, StatsData *agg)
31333133
switch (conditional_stack_peek(st->cstack))
31343134
{
31353135
caseIFSTATE_FALSE:
3136-
if (command->meta==META_IF||
3137-
command->meta==META_ELIF)
3136+
if (command->meta==META_IF)
3137+
{
3138+
/* nested if in skipped branch - ignore */
3139+
conditional_stack_push(st->cstack,
3140+
IFSTATE_IGNORED);
3141+
st->command++;
3142+
}
3143+
elseif (command->meta==META_ELIF)
31383144
{
31393145
/* we must evaluate the condition */
31403146
st->state=CSTATE_START_COMMAND;
@@ -3153,11 +3159,7 @@ advanceConnectionState(TState *thread, CState *st, StatsData *agg)
31533159
conditional_stack_pop(st->cstack);
31543160
if (conditional_active(st->cstack))
31553161
st->state=CSTATE_START_COMMAND;
3156-
3157-
/*
3158-
* else state remains in
3159-
* CSTATE_SKIP_COMMAND
3160-
*/
3162+
/* else state remains CSTATE_SKIP_COMMAND */
31613163
st->command++;
31623164
}
31633165
break;

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

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,56 @@ sub pgbench
623623
}
624624
});
625625

626+
# test nested \if constructs
627+
$node->pgbench(
628+
'--no-vacuum --client=1 --transactions=1',
629+
0,
630+
[qr{actually processed}],
631+
[qr{^$}],
632+
'nested ifs',
633+
{
634+
'pgbench_nested_if'=>q(
635+
\if false
636+
SELECT 1 / 0;
637+
\if true
638+
SELECT 1 / 0;
639+
\elif true
640+
SELECT 1 / 0;
641+
\else
642+
SELECT 1 / 0;
643+
\endif
644+
SELECT 1 / 0;
645+
\elif false
646+
\if true
647+
SELECT 1 / 0;
648+
\elif true
649+
SELECT 1 / 0;
650+
\else
651+
SELECT 1 / 0;
652+
\endif
653+
\else
654+
\if false
655+
SELECT 1 / 0;
656+
\elif false
657+
SELECT 1 / 0;
658+
\else
659+
SELECT 'correct';
660+
\endif
661+
\endif
662+
\if true
663+
SELECT 'correct';
664+
\else
665+
\if true
666+
SELECT 1 / 0;
667+
\elif true
668+
SELECT 1 / 0;
669+
\else
670+
SELECT 1 / 0;
671+
\endif
672+
\endif
673+
)
674+
});
675+
626676
# random determinism when seeded
627677
$node->safe_psql('postgres',
628678
'CREATE UNLOGGED TABLE seeded_random(seed INT8 NOT NULL, rand TEXT NOT NULL, val INTEGER NOT NULL);'

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp