1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-02 09:02:37 +03:00

Code and docs review for commit 3187d6de0e.

Fix up check for high-bit-set characters, which provoked "comparison is
always true due to limited range of data type" warnings on some compilers,
and was unlike the way we do it elsewhere anyway.  Fix omission of "$"
from the set of valid identifier continuation characters.  Get rid of
sanitize_text(), which was utterly inconsistent with any other error report
anywhere in the system, and wasn't even well designed on its own terms
(double-quoting the result string without escaping contained double quotes
doesn't seem very well thought out).  Fix up error messages, which didn't
follow the message style guidelines very well, and were overly specific in
situations where the actual mistake might not be what they said.  Improve
documentation.

(I started out just intending to fix the compiler warning, but the more
I looked at the patch the less I liked it.)
This commit is contained in:
Tom Lane
2016-03-28 01:00:30 -04:00
parent 499a50571c
commit d12e5bb79b
3 changed files with 100 additions and 149 deletions

View File

@ -142,7 +142,7 @@ SELECT parse_ident('foo.boo');
(1 row)
SELECT parse_ident('foo.boo[]'); -- should fail
ERROR: identifier contains disallowed characters: "foo.boo[]"
ERROR: string is not a valid identifier: "foo.boo[]"
SELECT parse_ident('foo.boo[]', strict => false); -- ok
parse_ident
-------------
@ -151,15 +151,17 @@ SELECT parse_ident('foo.boo[]', strict => false); -- ok
-- should fail
SELECT parse_ident(' ');
ERROR: missing valid identifier: " "
ERROR: string is not a valid identifier: " "
SELECT parse_ident(' .aaa');
ERROR: missing valid identifier before "." symbol: " .aaa"
ERROR: string is not a valid identifier: " .aaa"
DETAIL: No valid identifier before "." symbol.
SELECT parse_ident(' aaa . ');
ERROR: missing valid identifier after "." symbol: " aaa . "
ERROR: string is not a valid identifier: " aaa . "
DETAIL: No valid identifier after "." symbol.
SELECT parse_ident('aaa.a%b');
ERROR: identifier contains disallowed characters: "aaa.a%b"
ERROR: string is not a valid identifier: "aaa.a%b"
SELECT parse_ident(E'X\rXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
ERROR: identifier contains disallowed characters: "X\rXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
ERROR: string is not a valid identifier: "X
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
SELECT length(a[1]), length(a[2]) from parse_ident('"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx".yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy') as a ;
length | length
@ -179,14 +181,17 @@ SELECT parse_ident(' first . " second " ." third ". " ' || repeat('x',66)
{first," second "," third "," xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}
(1 row)
ERROR: identifier contains disallowed characters: ""c".X XXXX\u0002XXXXXX"
SELECT parse_ident(E'"c".X XXXX\002XXXXXX');
ERROR: string is not a valid identifier: ""c".X XXXXXXXXXX"
ERROR: missing valid identifier: "1020"
SELECT parse_ident('1020');
ERROR: string is not a valid identifier: "1020"
ERROR: missing valid identifier: "10.20"
SELECT parse_ident('10.20');
ERROR: string is not a valid identifier: "10.20"
ERROR: missing valid identifier before "." symbol: "."
SELECT parse_ident('.');
ERROR: string is not a valid identifier: "."
DETAIL: No valid identifier before "." symbol.
ERROR: missing valid identifier before "." symbol: ".1020"
SELECT parse_ident('.1020');
ERROR: string is not a valid identifier: ".1020"
DETAIL: No valid identifier before "." symbol.
ERROR: missing valid identifier after "." symbol: "xxx.1020"
SELECT parse_ident('xxx.1020');
ERROR: string is not a valid identifier: "xxx.1020"