mirror of
https://github.com/postgres/postgres.git
synced 2025-05-28 05:21:27 +03:00
Re-forbid underscore in positional parameters
Underscores were added to numeric literals in faff8f8e47. This change also affected the positional parameters (e.g., $1) rule, which uses the same production for its digits. But this did not actually work, because the digits for parameters are processed using atol(), which does not handle underscores and ignores whatever it cannot parse. The underscores notation is probably not useful for positional parameters, so for simplicity revert that rule to its old form that only accepts digits 0-9. Author: Erik Wienhold <ewie@ewie.name> Reviewed-by: Michael Paquier <michael@paquier.xyz> Discussion: https://www.postgresql.org/message-id/flat/5d216d1c-91f6-4cbe-95e2-b4cbd930520c%40ewie.name
This commit is contained in:
parent
987ab19ec9
commit
315661ecaf
@ -419,8 +419,9 @@ bininteger_junk {bininteger}{ident_start}
|
||||
numeric_junk {numeric}{ident_start}
|
||||
real_junk {real}{ident_start}
|
||||
|
||||
param \${decinteger}
|
||||
param_junk \${decinteger}{ident_start}
|
||||
/* Positional parameters don't accept underscores. */
|
||||
param \${decdigit}+
|
||||
param_junk \${decdigit}+{ident_start}
|
||||
|
||||
other .
|
||||
|
||||
|
@ -355,8 +355,9 @@ bininteger_junk {bininteger}{ident_start}
|
||||
numeric_junk {numeric}{ident_start}
|
||||
real_junk {real}{ident_start}
|
||||
|
||||
param \${decinteger}
|
||||
param_junk \${decinteger}{ident_start}
|
||||
/* Positional parameters don't accept underscores. */
|
||||
param \${decdigit}+
|
||||
param_junk \${decdigit}+{ident_start}
|
||||
|
||||
/* psql-specific: characters allowed in variable names */
|
||||
variable_char [A-Za-z\200-\377_0-9]
|
||||
|
@ -388,8 +388,9 @@ bininteger_junk {bininteger}{ident_start}
|
||||
numeric_junk {numeric}{ident_start}
|
||||
real_junk {real}{ident_start}
|
||||
|
||||
param \${decinteger}
|
||||
param_junk \${decinteger}{ident_start}
|
||||
/* Positional parameters don't accept underscores. */
|
||||
param \${decdigit}+
|
||||
param_junk \${decdigit}+{ident_start}
|
||||
|
||||
/* special characters for other dbms */
|
||||
/* we have to react differently in compat mode */
|
||||
|
@ -330,6 +330,10 @@ SELECT 1_000.5e_1;
|
||||
ERROR: trailing junk after numeric literal at or near "1_000.5e"
|
||||
LINE 1: SELECT 1_000.5e_1;
|
||||
^
|
||||
PREPARE p1 AS SELECT $0_1;
|
||||
ERROR: trailing junk after parameter at or near "$0_"
|
||||
LINE 1: PREPARE p1 AS SELECT $0_1;
|
||||
^
|
||||
--
|
||||
-- Test implicit type conversions
|
||||
-- This fails for Postgres v6.1 (and earlier?)
|
||||
|
@ -88,6 +88,7 @@ SELECT 1_000._5;
|
||||
SELECT 1_000.5_;
|
||||
SELECT 1_000.5e_1;
|
||||
|
||||
PREPARE p1 AS SELECT $0_1;
|
||||
|
||||
--
|
||||
-- Test implicit type conversions
|
||||
|
Loading…
x
Reference in New Issue
Block a user