Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb8da37b

Browse files
committed
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 withmore than just the error message generated for incorrect data typeinputs when these are able to handle soft failures, returning morecontents 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() areupdated to reflect the effects of the rename.Per discussion with Tom Lane and Andrew Dunstan.Author: Nathan BossartDiscussion:https://postgr.es/m/139a68e1-bd1f-a9a7-b5fe-0be9845c6311@dunslane.net
1 parent728560d commitb8da37b

File tree

117 files changed

+768
-682
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+768
-682
lines changed

‎contrib/cube/expected/cube.out‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,10 @@ SELECT pg_input_is_valid('-1e-700', 'cube');
344344
f
345345
(1 row)
346346

347-
SELECTpg_input_error_message('-1e-700', 'cube');
348-
pg_input_error_message
349-
-----------------------------------------------------
350-
"-1e-700" is out of range for type double precision
347+
SELECT* FROM pg_input_error_info('-1e-700', 'cube');
348+
message | detail | hint | sql_error_code
349+
-----------------------------------------------------+--------+------+----------------
350+
"-1e-700" is out of range for type double precision | | | 22003
351351
(1 row)
352352

353353
--

‎contrib/cube/sql/cube.sql‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ SELECT '-1e-700'::cube AS cube; -- out of range
8383
SELECT pg_input_is_valid('(1,2)','cube');
8484
SELECT pg_input_is_valid('[(1),]','cube');
8585
SELECT pg_input_is_valid('-1e-700','cube');
86-
SELECTpg_input_error_message('-1e-700','cube');
86+
SELECT*FROM pg_input_error_info('-1e-700','cube');
8787

8888
--
8989
-- Testing building cubes from float8 values

‎contrib/hstore/expected/hstore.out‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -265,16 +265,16 @@ select pg_input_is_valid('a=b', 'hstore');
265265
f
266266
(1 row)
267267

268-
selectpg_input_error_message('a=b', 'hstore');
269-
pg_input_error_message
270-
------------------------------------------------
271-
syntax error in hstore, near "b" at position 2
268+
select* from pg_input_error_info('a=b', 'hstore');
269+
message | detail | hint | sql_error_code
270+
------------------------------------------------+--------+------+----------------
271+
syntax error in hstore, near "b" at position 2 | | | 42601
272272
(1 row)
273273

274-
selectpg_input_error_message(' =>b', 'hstore');
275-
pg_input_error_message
276-
------------------------------------------------
277-
syntax error in hstore, near "=" at position 1
274+
select* from pg_input_error_info(' =>b', 'hstore');
275+
message | detail | hint | sql_error_code
276+
------------------------------------------------+--------+------+----------------
277+
syntax error in hstore, near "=" at position 1 | | | 42601
278278
(1 row)
279279

280280
-- -> operator

‎contrib/hstore/sql/hstore.sql‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ select 'aa=>"'::hstore;
6060
-- also try it with non-error-throwing API
6161
select pg_input_is_valid('a=>b','hstore');
6262
select pg_input_is_valid('a=b','hstore');
63-
selectpg_input_error_message('a=b','hstore');
64-
selectpg_input_error_message(' =>b','hstore');
63+
select*from pg_input_error_info('a=b','hstore');
64+
select*from pg_input_error_info(' =>b','hstore');
6565

6666

6767
-- -> operator

‎contrib/intarray/expected/_int.out‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -401,16 +401,20 @@ SELECT '1&(2&(4&(5|!6)))'::query_int;
401401
-- test non-error-throwing input
402402
SELECT str as "query_int",
403403
pg_input_is_valid(str,'query_int') as ok,
404-
pg_input_error_message(str,'query_int') as errmsg
404+
errinfo.sql_error_code,
405+
errinfo.message,
406+
errinfo.detail,
407+
errinfo.hint
405408
FROM (VALUES ('1&(2&(4&(5|6)))'),
406409
('1#(2&(4&(5&6)))'),
407410
('foo'))
408-
AS a(str);
409-
query_int | ok | errmsg
410-
-----------------+----+--------------
411-
1&(2&(4&(5|6))) | t |
412-
1#(2&(4&(5&6))) | f | syntax error
413-
foo | f | syntax error
411+
AS a(str),
412+
LATERAL pg_input_error_info(a.str, 'query_int') as errinfo;
413+
query_int | ok | sql_error_code | message | detail | hint
414+
-----------------+----+----------------+--------------+--------+------
415+
1&(2&(4&(5|6))) | t | | | |
416+
1#(2&(4&(5&6))) | f | 42601 | syntax error | |
417+
foo | f | 42601 | syntax error | |
414418
(3 rows)
415419

416420
CREATE TABLE test__int( a int[] );

‎contrib/intarray/sql/_int.sql‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,15 @@ SELECT '1&(2&(4&(5|!6)))'::query_int;
7979

8080
SELECT stras"query_int",
8181
pg_input_is_valid(str,'query_int')as ok,
82-
pg_input_error_message(str,'query_int')as errmsg
82+
errinfo.sql_error_code,
83+
errinfo.message,
84+
errinfo.detail,
85+
errinfo.hint
8386
FROM (VALUES ('1&(2&(4&(5|6)))'),
8487
('1#(2&(4&(5&6)))'),
8588
('foo'))
86-
AS a(str);
89+
AS a(str),
90+
LATERAL pg_input_error_info(a.str,'query_int')as errinfo;
8791

8892

8993

‎contrib/isn/expected/isn.out‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -263,16 +263,20 @@ SELECT '12345679'::ISSN = '9771234567003'::EAN13 AS "ok",
263263
-- test non-error-throwing input API
264264
SELECT str as isn, typ as "type",
265265
pg_input_is_valid(str,typ) as ok,
266-
pg_input_error_message(str,typ) as errmsg
266+
errinfo.sql_error_code,
267+
errinfo.message,
268+
errinfo.detail,
269+
errinfo.hint
267270
FROM (VALUES ('9780123456786', 'UPC'),
268271
('postgresql...','EAN13'),
269272
('9771234567003','ISSN'))
270-
AS a(str,typ);
271-
isn | type | ok | errmsg
272-
---------------+-------+----+--------------------------------------------------------
273-
9780123456786 | UPC | f | cannot cast ISBN to UPC for number: "9780123456786"
274-
postgresql... | EAN13 | f | invalid input syntax for EAN13 number: "postgresql..."
275-
9771234567003 | ISSN | t |
273+
AS a(str,typ),
274+
LATERAL pg_input_error_info(a.str, a.typ) as errinfo;
275+
isn | type | ok | sql_error_code | message | detail | hint
276+
---------------+-------+----+----------------+--------------------------------------------------------+--------+------
277+
9780123456786 | UPC | f | 22P02 | cannot cast ISBN to UPC for number: "9780123456786" | |
278+
postgresql... | EAN13 | f | 22P02 | invalid input syntax for EAN13 number: "postgresql..." | |
279+
9771234567003 | ISSN | t | | | |
276280
(3 rows)
277281

278282
--

‎contrib/isn/sql/isn.sql‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,15 @@ SELECT '12345679'::ISSN = '9771234567003'::EAN13 AS "ok",
110110
-- test non-error-throwing input API
111111
SELECT stras isn, typas"type",
112112
pg_input_is_valid(str,typ)as ok,
113-
pg_input_error_message(str,typ)as errmsg
113+
errinfo.sql_error_code,
114+
errinfo.message,
115+
errinfo.detail,
116+
errinfo.hint
114117
FROM (VALUES ('9780123456786','UPC'),
115118
('postgresql...','EAN13'),
116119
('9771234567003','ISSN'))
117-
AS a(str,typ);
120+
AS a(str,typ),
121+
LATERAL pg_input_error_info(a.str,a.typ)as errinfo;
118122

119123
--
120124
-- cleanup

‎contrib/ltree/expected/ltree.out‎

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8101,7 +8101,10 @@ SELECT count(*) FROM _ltreetest WHERE t ? '{23.*.1,23.*.2}' ;
81018101
-- test non-error-throwing input
81028102
SELECT str as "value", typ as "type",
81038103
pg_input_is_valid(str,typ) as ok,
8104-
pg_input_error_message(str,typ) as errmsg
8104+
errinfo.sql_error_code,
8105+
errinfo.message,
8106+
errinfo.detail,
8107+
errinfo.hint
81058108
FROM (VALUES ('.2.3', 'ltree'),
81068109
('1.2.', 'ltree'),
81078110
('1.2.3','ltree'),
@@ -8110,16 +8113,17 @@ FROM (VALUES ('.2.3', 'ltree'),
81108113
('1.2.3','lquery'),
81118114
('$tree & aWdf@*','ltxtquery'),
81128115
('!tree & aWdf@*','ltxtquery'))
8113-
AS a(str,typ);
8114-
value | type | ok | errmsg
8115-
----------------+-----------+----+------------------------------------
8116-
.2.3 | ltree | f | ltree syntax error at character 1
8117-
1.2. | ltree | f | ltree syntax error
8118-
1.2.3 | ltree | t |
8119-
@.2.3 | lquery | f | lquery syntax error at character 1
8120-
2.3 | lquery | f | lquery syntax error at character 1
8121-
1.2.3 | lquery | t |
8122-
$tree & aWdf@* | ltxtquery | f | operand syntax error
8123-
!tree & aWdf@* | ltxtquery | t |
8116+
AS a(str,typ),
8117+
LATERAL pg_input_error_info(a.str, a.typ) as errinfo;
8118+
value | type | ok | sql_error_code | message | detail | hint
8119+
----------------+-----------+----+----------------+------------------------------------+--------------------------+------
8120+
.2.3 | ltree | f | 42601 | ltree syntax error at character 1 | |
8121+
1.2. | ltree | f | 42601 | ltree syntax error | Unexpected end of input. |
8122+
1.2.3 | ltree | t | | | |
8123+
@.2.3 | lquery | f | 42601 | lquery syntax error at character 1 | |
8124+
2.3 | lquery | f | 42601 | lquery syntax error at character 1 | |
8125+
1.2.3 | lquery | t | | | |
8126+
$tree & aWdf@* | ltxtquery | f | 42601 | operand syntax error | |
8127+
!tree & aWdf@* | ltxtquery | t | | | |
81248128
(8 rows)
81258129

‎contrib/ltree/sql/ltree.sql‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,10 @@ SELECT count(*) FROM _ltreetest WHERE t ? '{23.*.1,23.*.2}' ;
393393

394394
SELECT stras"value", typas"type",
395395
pg_input_is_valid(str,typ)as ok,
396-
pg_input_error_message(str,typ)as errmsg
396+
errinfo.sql_error_code,
397+
errinfo.message,
398+
errinfo.detail,
399+
errinfo.hint
397400
FROM (VALUES ('.2.3','ltree'),
398401
('1.2.','ltree'),
399402
('1.2.3','ltree'),
@@ -402,4 +405,5 @@ FROM (VALUES ('.2.3', 'ltree'),
402405
('1.2.3','lquery'),
403406
('$tree & aWdf@*','ltxtquery'),
404407
('!tree & aWdf@*','ltxtquery'))
405-
AS a(str,typ);
408+
AS a(str,typ),
409+
LATERAL pg_input_error_info(a.str,a.typ)as errinfo;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp