aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2024-01-19 14:18:20 +0900
committerMichael Paquier <michael@paquier.xyz>2024-01-19 14:18:20 +0900
commit04c0897d3bcafe4ca61967d5ab1b5669f3cbe80b (patch)
tree51a0e97f67944d6d75c9087f0a3f231c7fa4eec0 /src
parent3ada0d2cae4d9d3e045c72e3ee0b37ccb6e13902 (diff)
downloadpostgresql-04c0897d3bcafe4ca61967d5ab1b5669f3cbe80b.tar.gz
postgresql-04c0897d3bcafe4ca61967d5ab1b5669f3cbe80b.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/bin/psql/command.c2
-rw-r--r--src/test/regress/expected/psql.out1
-rw-r--r--src/test/regress/sql/psql.sql1
3 files changed, 4 insertions, 0 deletions
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 9ad911e28d5..5c906e48068 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -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;
}
diff --git a/src/test/regress/expected/psql.out b/src/test/regress/expected/psql.out
index 4f3fd464207..ad027725624 100644
--- a/src/test/regress/expected/psql.out
+++ b/src/test/regress/expected/psql.out
@@ -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
diff --git a/src/test/regress/sql/psql.sql b/src/test/regress/sql/psql.sql
index c997106b9f3..129f8533537 100644
--- a/src/test/regress/sql/psql.sql
+++ b/src/test/regress/sql/psql.sql
@@ -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