1
0
mirror of https://github.com/postgres/postgres.git synced 2026-01-05 23:38:41 +03:00
Files
postgres/src/test/regress/sql/oid.sql
Michael Paquier b8da37b3ad Rework pg_input_error_message(), now renamed pg_input_error_info()
pg_input_error_info() is now a SQL function able to return a row with
more than just the error message generated for incorrect data type
inputs when these are able to handle soft failures, returning more
contents of ErrorData, as of:
- The error message (same as before).
- The error detail, if set.
- The error hint, if set.
- SQL error code.

All the regression tests that relied on pg_input_error_message() are
updated to reflect the effects of the rename.

Per discussion with Tom Lane and Andrew Dunstan.

Author: Nathan Bossart
Discussion: https://postgr.es/m/139a68e1-bd1f-a9a7-b5fe-0be9845c6311@dunslane.net
2023-02-28 08:04:13 +09:00

58 lines
1.8 KiB
SQL

--
-- OID
--
CREATE TABLE OID_TBL(f1 oid);
INSERT INTO OID_TBL(f1) VALUES ('1234');
INSERT INTO OID_TBL(f1) VALUES ('1235');
INSERT INTO OID_TBL(f1) VALUES ('987');
INSERT INTO OID_TBL(f1) VALUES ('-1040');
INSERT INTO OID_TBL(f1) VALUES ('99999999');
INSERT INTO OID_TBL(f1) VALUES ('5 ');
INSERT INTO OID_TBL(f1) VALUES (' 10 ');
-- leading/trailing hard tab is also allowed
INSERT INTO OID_TBL(f1) VALUES (' 15 ');
-- bad inputs
INSERT INTO OID_TBL(f1) VALUES ('');
INSERT INTO OID_TBL(f1) VALUES (' ');
INSERT INTO OID_TBL(f1) VALUES ('asdfasd');
INSERT INTO OID_TBL(f1) VALUES ('99asdfasd');
INSERT INTO OID_TBL(f1) VALUES ('5 d');
INSERT INTO OID_TBL(f1) VALUES (' 5d');
INSERT INTO OID_TBL(f1) VALUES ('5 5');
INSERT INTO OID_TBL(f1) VALUES (' - 500');
INSERT INTO OID_TBL(f1) VALUES ('32958209582039852935');
INSERT INTO OID_TBL(f1) VALUES ('-23582358720398502385');
SELECT * FROM OID_TBL;
-- Also try it with non-error-throwing API
SELECT pg_input_is_valid('1234', 'oid');
SELECT pg_input_is_valid('01XYZ', 'oid');
SELECT * FROM pg_input_error_info('01XYZ', 'oid');
SELECT pg_input_is_valid('9999999999', 'oid');
SELECT * FROM pg_input_error_info('9999999999', 'oid');
-- While we're here, check oidvector as well
SELECT pg_input_is_valid(' 1 2 4 ', 'oidvector');
SELECT pg_input_is_valid('01 01XYZ', 'oidvector');
SELECT * FROM pg_input_error_info('01 01XYZ', 'oidvector');
SELECT pg_input_is_valid('01 9999999999', 'oidvector');
SELECT * FROM pg_input_error_info('01 9999999999', 'oidvector');
SELECT o.* FROM OID_TBL o WHERE o.f1 = 1234;
SELECT o.* FROM OID_TBL o WHERE o.f1 <> '1234';
SELECT o.* FROM OID_TBL o WHERE o.f1 <= '1234';
SELECT o.* FROM OID_TBL o WHERE o.f1 < '1234';
SELECT o.* FROM OID_TBL o WHERE o.f1 >= '1234';
SELECT o.* FROM OID_TBL o WHERE o.f1 > '1234';
DROP TABLE OID_TBL;