1
0
mirror of https://github.com/postgres/postgres.git synced 2025-04-24 10:47:04 +03:00

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
This commit is contained in:
Michael Paquier 2024-01-19 14:18:20 +09:00
parent 3ada0d2cae
commit 04c0897d3b
3 changed files with 4 additions and 0 deletions

View File

@ -486,6 +486,8 @@ exec_command_bind(PsqlScanState scan_state, bool active_branch)
pset.bind_nparams = nparams;
pset.bind_flag = true;
}
else
ignore_slash_options(scan_state);
return status;
}

View File

@ -4506,6 +4506,7 @@ bar 'bar' "bar"
\echo `nosuchcommand` :foo :'foo' :"foo"
\pset fieldsep | `nosuchcommand` :foo :'foo' :"foo"
\a
SELECT $1 \bind 1 \g
\C arg1
\c arg1 arg2 arg3 arg4
\cd arg1

View File

@ -989,6 +989,7 @@ select \if false \\ (bogus \else \\ 42 \endif \\ forty_two;
\echo `nosuchcommand` :foo :'foo' :"foo"
\pset fieldsep | `nosuchcommand` :foo :'foo' :"foo"
\a
SELECT $1 \bind 1 \g
\C arg1
\c arg1 arg2 arg3 arg4
\cd arg1