3 -- all inputs are silently truncated at NAMEDATALEN-1 (63) characters
5 -- fixed-length by reference
6 SELECT name 'name string' = name 'name string' AS "True";
12 SELECT name 'name string' = name 'name string ' AS "False";
21 CREATE TABLE NAME_TBL(f1 name);
22 INSERT INTO NAME_TBL(f1) VALUES ('1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQR');
23 INSERT INTO NAME_TBL(f1) VALUES ('1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqr');
24 INSERT INTO NAME_TBL(f1) VALUES ('asdfghjkl;');
25 INSERT INTO NAME_TBL(f1) VALUES ('343f%2a');
26 INSERT INTO NAME_TBL(f1) VALUES ('d34aaasdf');
27 INSERT INTO NAME_TBL(f1) VALUES ('');
28 INSERT INTO NAME_TBL(f1) VALUES ('1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ');
29 SELECT * FROM NAME_TBL;
31 -----------------------------------------------------------------
32 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQ
33 1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopq
38 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQ
41 SELECT c.f1 FROM NAME_TBL c WHERE c.f1 <> '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQR';
43 -----------------------------------------------------------------
44 1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopq
51 SELECT c.f1 FROM NAME_TBL c WHERE c.f1 = '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQR';
53 -----------------------------------------------------------------
54 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQ
55 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQ
58 SELECT c.f1 FROM NAME_TBL c WHERE c.f1 < '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQR';
64 SELECT c.f1 FROM NAME_TBL c WHERE c.f1 <= '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQR';
66 -----------------------------------------------------------------
67 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQ
69 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQ
72 SELECT c.f1 FROM NAME_TBL c WHERE c.f1 > '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQR';
74 -----------------------------------------------------------------
75 1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopq
81 SELECT c.f1 FROM NAME_TBL c WHERE c.f1 >= '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQR';
83 -----------------------------------------------------------------
84 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQ
85 1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopq
89 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQ
92 SELECT c.f1 FROM NAME_TBL c WHERE c.f1 ~ '.*';
94 -----------------------------------------------------------------
95 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQ
96 1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopq
101 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQ
104 SELECT c.f1 FROM NAME_TBL c WHERE c.f1 !~ '.*';
109 SELECT c.f1 FROM NAME_TBL c WHERE c.f1 ~ '[0-9]';
111 -----------------------------------------------------------------
112 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQ
113 1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopq
116 1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890ABCDEFGHIJKLMNOPQ
119 SELECT c.f1 FROM NAME_TBL c WHERE c.f1 ~ '.*asdf.*';
130 r := parse_ident('Schemax.Tabley');
131 RAISE NOTICE '%', format('%I.%I', r[1], r[2]);
132 r := parse_ident('"SchemaX"."TableY"');
133 RAISE NOTICE '%', format('%I.%I', r[1], r[2]);
136 NOTICE: schemax.tabley
137 NOTICE: "SchemaX"."TableY"
138 SELECT parse_ident('foo.boo');
144 SELECT parse_ident('foo.boo[]'); -- should fail
145 ERROR: string is not a valid identifier: "foo.boo[]"
146 SELECT parse_ident('foo.boo[]', strict => false); -- ok
153 SELECT parse_ident(' ');
154 ERROR: string is not a valid identifier: " "
155 SELECT parse_ident(' .aaa');
156 ERROR: string is not a valid identifier: " .aaa"
157 DETAIL: No valid identifier before ".".
158 SELECT parse_ident(' aaa . ');
159 ERROR: string is not a valid identifier: " aaa . "
160 DETAIL: No valid identifier after ".".
161 SELECT parse_ident('aaa.a%b');
162 ERROR: string is not a valid identifier: "aaa.a%b"
163 SELECT parse_ident(E'X\rXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
164 ERROR: string is not a valid identifier: "X
\rXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
165 SELECT length(a[1]), length(a[2]) from parse_ident('"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx".yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy') as a ;
171 SELECT parse_ident(' first . " second " ." third ". " ' || repeat('x',66) || '"');
173 -----------------------------------------------------------------------------------------------------------
174 {first," second "," third "," xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}
177 SELECT parse_ident(' first . " second " ." third ". " ' || repeat('x',66) || '"')::name[];
179 ------------------------------------------------------------------------------------------------------
180 {first," second "," third "," xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}
183 SELECT parse_ident(E'"c".X XXXX\002XXXXXX');
184 ERROR: string is not a valid identifier: ""c".X XXXX
\x02XXXXXX"
185 SELECT parse_ident('1020');
186 ERROR: string is not a valid identifier: "1020"
187 SELECT parse_ident('10.20');
188 ERROR: string is not a valid identifier: "10.20"
189 SELECT parse_ident('.');
190 ERROR: string is not a valid identifier: "."
191 DETAIL: No valid identifier before ".".
192 SELECT parse_ident('.1020');
193 ERROR: string is not a valid identifier: ".1020"
194 DETAIL: No valid identifier before ".".
195 SELECT parse_ident('xxx.1020');
196 ERROR: string is not a valid identifier: "xxx.1020"
197 DETAIL: No valid identifier after ".".