4 /* If objects exist, return oids */
5 CREATE ROLE regress_regrole_test;
13 SELECT regoperator('+(int4,int4)');
19 SELECT regproc('now');
25 SELECT regprocedure('abs(numeric)');
31 SELECT regclass('pg_class');
37 SELECT regtype('int4');
43 SELECT regcollation('"POSIX"');
49 SELECT to_regoper('||/');
55 SELECT to_regoperator('+(int4,int4)');
61 SELECT to_regproc('now');
67 SELECT to_regprocedure('abs(numeric)');
73 SELECT to_regclass('pg_class');
79 SELECT to_regtype('int4');
85 SELECT to_regcollation('"POSIX"');
92 SELECT regoper('pg_catalog.||/');
98 SELECT regoperator('pg_catalog.+(int4,int4)');
104 SELECT regproc('pg_catalog.now');
110 SELECT regprocedure('pg_catalog.abs(numeric)');
116 SELECT regclass('pg_catalog.pg_class');
122 SELECT regtype('pg_catalog.int4');
128 SELECT regcollation('pg_catalog."POSIX"');
134 SELECT to_regoper('pg_catalog.||/');
140 SELECT to_regproc('pg_catalog.now');
146 SELECT to_regprocedure('pg_catalog.abs(numeric)');
152 SELECT to_regclass('pg_catalog.pg_class');
158 SELECT to_regtype('pg_catalog.int4');
164 SELECT to_regcollation('pg_catalog."POSIX"');
170 -- schemaname not applicable
171 SELECT regrole('regress_regrole_test');
173 ----------------------
177 SELECT regrole('"regress_regrole_test"');
179 ----------------------
183 SELECT regnamespace('pg_catalog');
189 SELECT regnamespace('"pg_catalog"');
195 SELECT to_regrole('regress_regrole_test');
197 ----------------------
201 SELECT to_regrole('"regress_regrole_test"');
203 ----------------------
207 SELECT to_regnamespace('pg_catalog');
213 SELECT to_regnamespace('"pg_catalog"');
219 /* If objects don't exist, raise errors. */
220 DROP ROLE regress_regrole_test;
221 -- without schemaname
222 SELECT regoper('||//');
223 ERROR: operator does not exist: ||//
224 LINE 1: SELECT regoper('||//');
226 SELECT regoperator('++(int4,int4)');
227 ERROR: operator does not exist: ++(int4,int4)
228 LINE 1: SELECT regoperator('++(int4,int4)');
230 SELECT regproc('know');
231 ERROR: function "know" does not exist
232 LINE 1: SELECT regproc('know');
234 SELECT regprocedure('absinthe(numeric)');
235 ERROR: function "absinthe(numeric)" does not exist
236 LINE 1: SELECT regprocedure('absinthe(numeric)');
238 SELECT regclass('pg_classes');
239 ERROR: relation "pg_classes" does not exist
240 LINE 1: SELECT regclass('pg_classes');
242 SELECT regtype('int3');
243 ERROR: type "int3" does not exist
244 LINE 1: SELECT regtype('int3');
247 SELECT regoper('ng_catalog.||/');
248 ERROR: operator does not exist: ng_catalog.||/
249 LINE 1: SELECT regoper('ng_catalog.||/');
251 SELECT regoperator('ng_catalog.+(int4,int4)');
252 ERROR: operator does not exist: ng_catalog.+(int4,int4)
253 LINE 1: SELECT regoperator('ng_catalog.+(int4,int4)');
255 SELECT regproc('ng_catalog.now');
256 ERROR: function "ng_catalog.now" does not exist
257 LINE 1: SELECT regproc('ng_catalog.now');
259 SELECT regprocedure('ng_catalog.abs(numeric)');
260 ERROR: function "ng_catalog.abs(numeric)" does not exist
261 LINE 1: SELECT regprocedure('ng_catalog.abs(numeric)');
263 SELECT regclass('ng_catalog.pg_class');
264 ERROR: relation "ng_catalog.pg_class" does not exist
265 LINE 1: SELECT regclass('ng_catalog.pg_class');
267 SELECT regtype('ng_catalog.int4');
268 ERROR: schema "ng_catalog" does not exist
269 LINE 1: SELECT regtype('ng_catalog.int4');
271 \set VERBOSITY sqlstate \\ -- error message is encoding-dependent
272 SELECT regcollation('ng_catalog."POSIX"');
274 \set VERBOSITY default
275 -- schemaname not applicable
276 SELECT regrole('regress_regrole_test');
277 ERROR: role "regress_regrole_test" does not exist
278 LINE 1: SELECT regrole('regress_regrole_test');
280 SELECT regrole('"regress_regrole_test"');
281 ERROR: role "regress_regrole_test" does not exist
282 LINE 1: SELECT regrole('"regress_regrole_test"');
284 SELECT regrole('Nonexistent');
285 ERROR: role "nonexistent" does not exist
286 LINE 1: SELECT regrole('Nonexistent');
288 SELECT regrole('"Nonexistent"');
289 ERROR: role "Nonexistent" does not exist
290 LINE 1: SELECT regrole('"Nonexistent"');
292 SELECT regrole('foo.bar');
293 ERROR: invalid name syntax
294 LINE 1: SELECT regrole('foo.bar');
296 SELECT regnamespace('Nonexistent');
297 ERROR: schema "nonexistent" does not exist
298 LINE 1: SELECT regnamespace('Nonexistent');
300 SELECT regnamespace('"Nonexistent"');
301 ERROR: schema "Nonexistent" does not exist
302 LINE 1: SELECT regnamespace('"Nonexistent"');
304 SELECT regnamespace('foo.bar');
305 ERROR: invalid name syntax
306 LINE 1: SELECT regnamespace('foo.bar');
308 /* If objects don't exist, return NULL with no error. */
309 -- without schemaname
310 SELECT to_regoper('||//');
316 SELECT to_regoperator('++(int4,int4)');
322 SELECT to_regproc('know');
328 SELECT to_regprocedure('absinthe(numeric)');
334 SELECT to_regclass('pg_classes');
340 SELECT to_regtype('int3');
346 SELECT to_regcollation('notacollation');
353 SELECT to_regoper('ng_catalog.||/');
359 SELECT to_regoperator('ng_catalog.+(int4,int4)');
365 SELECT to_regproc('ng_catalog.now');
371 SELECT to_regprocedure('ng_catalog.abs(numeric)');
377 SELECT to_regclass('ng_catalog.pg_class');
383 SELECT to_regtype('ng_catalog.int4');
389 SELECT to_regcollation('ng_catalog."POSIX"');
395 -- schemaname not applicable
396 SELECT to_regrole('regress_regrole_test');
402 SELECT to_regrole('"regress_regrole_test"');
408 SELECT to_regrole('foo.bar');
414 SELECT to_regrole('Nonexistent');
420 SELECT to_regrole('"Nonexistent"');
426 SELECT to_regrole('foo.bar');
432 SELECT to_regnamespace('Nonexistent');
438 SELECT to_regnamespace('"Nonexistent"');
444 SELECT to_regnamespace('foo.bar');
450 -- Test to_regtypemod
451 SELECT to_regtypemod('text');
457 SELECT to_regtypemod('timestamp(4)');
463 SELECT to_regtypemod('no_such_type(4)');
469 SELECT format_type(to_regtype('varchar(32)'), to_regtypemod('varchar(32)'));
471 -----------------------
472 character varying(32)
475 SELECT format_type(to_regtype('bit'), to_regtypemod('bit'));
481 SELECT format_type(to_regtype('"bit"'), to_regtypemod('"bit"'));
487 -- Test soft-error API
488 SELECT * FROM pg_input_error_info('ng_catalog.pg_class', 'regclass');
489 message | detail | hint | sql_error_code
490 -----------------------------------------------+--------+------+----------------
491 relation "ng_catalog.pg_class" does not exist | | | 42P01
494 SELECT pg_input_is_valid('ng_catalog."POSIX"', 'regcollation');
500 SELECT * FROM pg_input_error_info('no_such_config', 'regconfig');
501 message | detail | hint | sql_error_code
502 -----------------------------------------------------------+--------+------+----------------
503 text search configuration "no_such_config" does not exist | | | 42704
506 SELECT * FROM pg_input_error_info('no_such_dictionary', 'regdictionary');
507 message | detail | hint | sql_error_code
508 ------------------------------------------------------------+--------+------+----------------
509 text search dictionary "no_such_dictionary" does not exist | | | 42704
512 SELECT * FROM pg_input_error_info('Nonexistent', 'regnamespace');
513 message | detail | hint | sql_error_code
514 -------------------------------------+--------+------+----------------
515 schema "nonexistent" does not exist | | | 3F000
518 SELECT * FROM pg_input_error_info('ng_catalog.||/', 'regoper');
519 message | detail | hint | sql_error_code
520 -----------------------------------------+--------+------+----------------
521 operator does not exist: ng_catalog.||/ | | | 42883
524 SELECT * FROM pg_input_error_info('-', 'regoper');
525 message | detail | hint | sql_error_code
526 --------------------------------+--------+------+----------------
527 more than one operator named - | | | 42725
530 SELECT * FROM pg_input_error_info('ng_catalog.+(int4,int4)', 'regoperator');
531 message | detail | hint | sql_error_code
532 --------------------------------------------------+--------+------+----------------
533 operator does not exist: ng_catalog.+(int4,int4) | | | 42883
536 SELECT * FROM pg_input_error_info('-', 'regoperator');
537 message | detail | hint | sql_error_code
538 -----------------------------+--------+------+----------------
539 expected a left parenthesis | | | 22P02
542 SELECT * FROM pg_input_error_info('ng_catalog.now', 'regproc');
543 message | detail | hint | sql_error_code
544 ------------------------------------------+--------+------+----------------
545 function "ng_catalog.now" does not exist | | | 42883
548 SELECT * FROM pg_input_error_info('ng_catalog.abs(numeric)', 'regprocedure');
549 message | detail | hint | sql_error_code
550 ---------------------------------------------------+--------+------+----------------
551 function "ng_catalog.abs(numeric)" does not exist | | | 42883
554 SELECT * FROM pg_input_error_info('ng_catalog.abs(numeric', 'regprocedure');
555 message | detail | hint | sql_error_code
556 ------------------------------+--------+------+----------------
557 expected a right parenthesis | | | 22P02
560 SELECT * FROM pg_input_error_info('regress_regrole_test', 'regrole');
561 message | detail | hint | sql_error_code
562 --------------------------------------------+--------+------+----------------
563 role "regress_regrole_test" does not exist | | | 42704
566 SELECT * FROM pg_input_error_info('no_such_type', 'regtype');
567 message | detail | hint | sql_error_code
568 ------------------------------------+--------+------+----------------
569 type "no_such_type" does not exist | | | 42704
572 -- Some cases that should be soft errors, but are not yet
573 SELECT * FROM pg_input_error_info('incorrect type name syntax', 'regtype');
574 ERROR: syntax error at or near "type"
575 LINE 1: SELECT * FROM pg_input_error_info('incorrect type name synta...
577 CONTEXT: invalid type name "incorrect type name syntax"
578 SELECT * FROM pg_input_error_info('numeric(1,2,3)', 'regtype'); -- bogus typmod
579 ERROR: invalid NUMERIC type modifier
580 SELECT * FROM pg_input_error_info('way.too.many.names', 'regtype');
581 ERROR: improper qualified name (too many dotted names): way.too.many.names
582 SELECT * FROM pg_input_error_info('no_such_catalog.schema.name', 'regtype');
583 ERROR: cross-database references are not implemented: no_such_catalog.schema.name