Skip to content

Commit 04c0897

Browse files
committed
psql: Add ignore_slash_options in bind's inactive branch
All commands accepting arguments, handling them with OT_NORMAL, OT_SQLID or OT_SQLIDHACK, should call ignore_slash_options() in inactive branch to scan and discard extra arguments. All the backslash commands that handle arguments do so, except \bind. This commit adds the missing ignore_slash_options to \bind's inactive branch. This inconsistency is a logic bug, however the behavior happens to be unchanged as any extra arguments are discarded later in HandleSlashCmds(), so no backpatch is done. While on it, this adds \bind to the list of backslash commands where inactive \if branches are checked in the tests for psql. Reported-by: Jelte Fennema-Nio Author: Anthonin Bonnefoy Discussion: https://postgr.es/m/CAGECzQR1+udGKz+FbHiCQ7CWDiF1fCGi2xYuvQUODdMAfJbaLA@mail.gmail.com
1 parent 3ada0d2 commit 04c0897

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

src/bin/psql/command.c

+2
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,8 @@ exec_command_bind(PsqlScanState scan_state, bool active_branch)
486486
pset.bind_nparams = nparams;
487487
pset.bind_flag = true;
488488
}
489+
else
490+
ignore_slash_options(scan_state);
489491

490492
return status;
491493
}

src/test/regress/expected/psql.out

+1
Original file line numberDiff line numberDiff line change
@@ -4506,6 +4506,7 @@ bar 'bar' "bar"
45064506
\echo `nosuchcommand` :foo :'foo' :"foo"
45074507
\pset fieldsep | `nosuchcommand` :foo :'foo' :"foo"
45084508
\a
4509+
SELECT $1 \bind 1 \g
45094510
\C arg1
45104511
\c arg1 arg2 arg3 arg4
45114512
\cd arg1

src/test/regress/sql/psql.sql

+1
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,7 @@ select \if false \\ (bogus \else \\ 42 \endif \\ forty_two;
989989
\echo `nosuchcommand` :foo :'foo' :"foo"
990990
\pset fieldsep | `nosuchcommand` :foo :'foo' :"foo"
991991
\a
992+
SELECT $1 \bind 1 \g
992993
\C arg1
993994
\c arg1 arg2 arg3 arg4
994995
\cd arg1

0 commit comments

Comments
 (0)