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
This commit is contained in:
Michael Paquier 2023-02-28 08:04:13 +09:00
parent 728560db7d
commit b8da37b3ad
117 changed files with 768 additions and 682 deletions

View File

@ -344,10 +344,10 @@ SELECT pg_input_is_valid('-1e-700', 'cube');
f f
(1 row) (1 row)
SELECT pg_input_error_message('-1e-700', 'cube'); SELECT * FROM pg_input_error_info('-1e-700', 'cube');
pg_input_error_message message | detail | hint | sql_error_code
----------------------------------------------------- -----------------------------------------------------+--------+------+----------------
"-1e-700" is out of range for type double precision "-1e-700" is out of range for type double precision | | | 22003
(1 row) (1 row)
-- --

View File

@ -83,7 +83,7 @@ SELECT '-1e-700'::cube AS cube; -- out of range
SELECT pg_input_is_valid('(1,2)', 'cube'); SELECT pg_input_is_valid('(1,2)', 'cube');
SELECT pg_input_is_valid('[(1),]', 'cube'); SELECT pg_input_is_valid('[(1),]', 'cube');
SELECT pg_input_is_valid('-1e-700', 'cube'); SELECT pg_input_is_valid('-1e-700', 'cube');
SELECT pg_input_error_message('-1e-700', 'cube'); SELECT * FROM pg_input_error_info('-1e-700', 'cube');
-- --
-- Testing building cubes from float8 values -- Testing building cubes from float8 values

View File

@ -265,16 +265,16 @@ select pg_input_is_valid('a=b', 'hstore');
f f
(1 row) (1 row)
select pg_input_error_message('a=b', 'hstore'); select * from pg_input_error_info('a=b', 'hstore');
pg_input_error_message message | detail | hint | sql_error_code
------------------------------------------------ ------------------------------------------------+--------+------+----------------
syntax error in hstore, near "b" at position 2 syntax error in hstore, near "b" at position 2 | | | 42601
(1 row) (1 row)
select pg_input_error_message(' =>b', 'hstore'); select * from pg_input_error_info(' =>b', 'hstore');
pg_input_error_message message | detail | hint | sql_error_code
------------------------------------------------ ------------------------------------------------+--------+------+----------------
syntax error in hstore, near "=" at position 1 syntax error in hstore, near "=" at position 1 | | | 42601
(1 row) (1 row)
-- -> operator -- -> operator

View File

@ -60,8 +60,8 @@ select 'aa=>"'::hstore;
-- also try it with non-error-throwing API -- also try it with non-error-throwing API
select pg_input_is_valid('a=>b', 'hstore'); select pg_input_is_valid('a=>b', 'hstore');
select pg_input_is_valid('a=b', 'hstore'); select pg_input_is_valid('a=b', 'hstore');
select pg_input_error_message('a=b', 'hstore'); select * from pg_input_error_info('a=b', 'hstore');
select pg_input_error_message(' =>b', 'hstore'); select * from pg_input_error_info(' =>b', 'hstore');
-- -> operator -- -> operator

View File

@ -401,16 +401,20 @@ SELECT '1&(2&(4&(5|!6)))'::query_int;
-- test non-error-throwing input -- test non-error-throwing input
SELECT str as "query_int", SELECT str as "query_int",
pg_input_is_valid(str,'query_int') as ok, pg_input_is_valid(str,'query_int') as ok,
pg_input_error_message(str,'query_int') as errmsg errinfo.sql_error_code,
errinfo.message,
errinfo.detail,
errinfo.hint
FROM (VALUES ('1&(2&(4&(5|6)))'), FROM (VALUES ('1&(2&(4&(5|6)))'),
('1#(2&(4&(5&6)))'), ('1#(2&(4&(5&6)))'),
('foo')) ('foo'))
AS a(str); AS a(str),
query_int | ok | errmsg LATERAL pg_input_error_info(a.str, 'query_int') as errinfo;
-----------------+----+-------------- query_int | ok | sql_error_code | message | detail | hint
1&(2&(4&(5|6))) | t | -----------------+----+----------------+--------------+--------+------
1#(2&(4&(5&6))) | f | syntax error 1&(2&(4&(5|6))) | t | | | |
foo | f | syntax error 1#(2&(4&(5&6))) | f | 42601 | syntax error | |
foo | f | 42601 | syntax error | |
(3 rows) (3 rows)
CREATE TABLE test__int( a int[] ); CREATE TABLE test__int( a int[] );

View File

@ -79,11 +79,15 @@ SELECT '1&(2&(4&(5|!6)))'::query_int;
SELECT str as "query_int", SELECT str as "query_int",
pg_input_is_valid(str,'query_int') as ok, pg_input_is_valid(str,'query_int') as ok,
pg_input_error_message(str,'query_int') as errmsg errinfo.sql_error_code,
errinfo.message,
errinfo.detail,
errinfo.hint
FROM (VALUES ('1&(2&(4&(5|6)))'), FROM (VALUES ('1&(2&(4&(5|6)))'),
('1#(2&(4&(5&6)))'), ('1#(2&(4&(5&6)))'),
('foo')) ('foo'))
AS a(str); AS a(str),
LATERAL pg_input_error_info(a.str, 'query_int') as errinfo;

View File

@ -263,16 +263,20 @@ SELECT '12345679'::ISSN = '9771234567003'::EAN13 AS "ok",
-- test non-error-throwing input API -- test non-error-throwing input API
SELECT str as isn, typ as "type", SELECT str as isn, typ as "type",
pg_input_is_valid(str,typ) as ok, pg_input_is_valid(str,typ) as ok,
pg_input_error_message(str,typ) as errmsg errinfo.sql_error_code,
errinfo.message,
errinfo.detail,
errinfo.hint
FROM (VALUES ('9780123456786', 'UPC'), FROM (VALUES ('9780123456786', 'UPC'),
('postgresql...','EAN13'), ('postgresql...','EAN13'),
('9771234567003','ISSN')) ('9771234567003','ISSN'))
AS a(str,typ); AS a(str,typ),
isn | type | ok | errmsg LATERAL pg_input_error_info(a.str, a.typ) as errinfo;
---------------+-------+----+-------------------------------------------------------- isn | type | ok | sql_error_code | message | detail | hint
9780123456786 | UPC | f | cannot cast ISBN to UPC for number: "9780123456786" ---------------+-------+----+----------------+--------------------------------------------------------+--------+------
postgresql... | EAN13 | f | invalid input syntax for EAN13 number: "postgresql..." 9780123456786 | UPC | f | 22P02 | cannot cast ISBN to UPC for number: "9780123456786" | |
9771234567003 | ISSN | t | postgresql... | EAN13 | f | 22P02 | invalid input syntax for EAN13 number: "postgresql..." | |
9771234567003 | ISSN | t | | | |
(3 rows) (3 rows)
-- --

View File

@ -110,11 +110,15 @@ SELECT '12345679'::ISSN = '9771234567003'::EAN13 AS "ok",
-- test non-error-throwing input API -- test non-error-throwing input API
SELECT str as isn, typ as "type", SELECT str as isn, typ as "type",
pg_input_is_valid(str,typ) as ok, pg_input_is_valid(str,typ) as ok,
pg_input_error_message(str,typ) as errmsg errinfo.sql_error_code,
errinfo.message,
errinfo.detail,
errinfo.hint
FROM (VALUES ('9780123456786', 'UPC'), FROM (VALUES ('9780123456786', 'UPC'),
('postgresql...','EAN13'), ('postgresql...','EAN13'),
('9771234567003','ISSN')) ('9771234567003','ISSN'))
AS a(str,typ); AS a(str,typ),
LATERAL pg_input_error_info(a.str, a.typ) as errinfo;
-- --
-- cleanup -- cleanup

View File

@ -8101,7 +8101,10 @@ SELECT count(*) FROM _ltreetest WHERE t ? '{23.*.1,23.*.2}' ;
-- test non-error-throwing input -- test non-error-throwing input
SELECT str as "value", typ as "type", SELECT str as "value", typ as "type",
pg_input_is_valid(str,typ) as ok, pg_input_is_valid(str,typ) as ok,
pg_input_error_message(str,typ) as errmsg errinfo.sql_error_code,
errinfo.message,
errinfo.detail,
errinfo.hint
FROM (VALUES ('.2.3', 'ltree'), FROM (VALUES ('.2.3', 'ltree'),
('1.2.', 'ltree'), ('1.2.', 'ltree'),
('1.2.3','ltree'), ('1.2.3','ltree'),
@ -8110,16 +8113,17 @@ FROM (VALUES ('.2.3', 'ltree'),
('1.2.3','lquery'), ('1.2.3','lquery'),
('$tree & aWdf@*','ltxtquery'), ('$tree & aWdf@*','ltxtquery'),
('!tree & aWdf@*','ltxtquery')) ('!tree & aWdf@*','ltxtquery'))
AS a(str,typ); AS a(str,typ),
value | type | ok | errmsg LATERAL pg_input_error_info(a.str, a.typ) as errinfo;
----------------+-----------+----+------------------------------------ value | type | ok | sql_error_code | message | detail | hint
.2.3 | ltree | f | ltree syntax error at character 1 ----------------+-----------+----+----------------+------------------------------------+--------------------------+------
1.2. | ltree | f | ltree syntax error .2.3 | ltree | f | 42601 | ltree syntax error at character 1 | |
1.2.3 | ltree | t | 1.2. | ltree | f | 42601 | ltree syntax error | Unexpected end of input. |
@.2.3 | lquery | f | lquery syntax error at character 1 1.2.3 | ltree | t | | | |
2.3 | lquery | f | lquery syntax error at character 1 @.2.3 | lquery | f | 42601 | lquery syntax error at character 1 | |
1.2.3 | lquery | t | 2.3 | lquery | f | 42601 | lquery syntax error at character 1 | |
$tree & aWdf@* | ltxtquery | f | operand syntax error 1.2.3 | lquery | t | | | |
!tree & aWdf@* | ltxtquery | t | $tree & aWdf@* | ltxtquery | f | 42601 | operand syntax error | |
!tree & aWdf@* | ltxtquery | t | | | |
(8 rows) (8 rows)

View File

@ -393,7 +393,10 @@ SELECT count(*) FROM _ltreetest WHERE t ? '{23.*.1,23.*.2}' ;
SELECT str as "value", typ as "type", SELECT str as "value", typ as "type",
pg_input_is_valid(str,typ) as ok, pg_input_is_valid(str,typ) as ok,
pg_input_error_message(str,typ) as errmsg errinfo.sql_error_code,
errinfo.message,
errinfo.detail,
errinfo.hint
FROM (VALUES ('.2.3', 'ltree'), FROM (VALUES ('.2.3', 'ltree'),
('1.2.', 'ltree'), ('1.2.', 'ltree'),
('1.2.3','ltree'), ('1.2.3','ltree'),
@ -402,4 +405,5 @@ FROM (VALUES ('.2.3', 'ltree'),
('1.2.3','lquery'), ('1.2.3','lquery'),
('$tree & aWdf@*','ltxtquery'), ('$tree & aWdf@*','ltxtquery'),
('!tree & aWdf@*','ltxtquery')) ('!tree & aWdf@*','ltxtquery'))
AS a(str,typ); AS a(str,typ),
LATERAL pg_input_error_info(a.str, a.typ) as errinfo;

View File

@ -1276,20 +1276,24 @@ FROM test_seg WHERE s @> '11.2..11.3' OR s IS NULL ORDER BY s;
-- test non error throwing API -- test non error throwing API
SELECT str as seg, SELECT str as seg,
pg_input_is_valid(str,'seg') as ok, pg_input_is_valid(str,'seg') as ok,
pg_input_error_message(str,'seg') as errmsg errinfo.sql_error_code,
errinfo.message,
errinfo.detail,
errinfo.hint
FROM unnest(ARRAY['-1 .. 1'::text, FROM unnest(ARRAY['-1 .. 1'::text,
'100(+-)1', '100(+-)1',
'', '',
'ABC', 'ABC',
'1 e7', '1 e7',
'1e700']) str; '1e700']) str,
seg | ok | errmsg LATERAL pg_input_error_info(str, 'seg') as errinfo;
----------+----+--------------------------------------- seg | ok | sql_error_code | message | detail | hint
-1 .. 1 | t | ----------+----+----------------+---------------------------------------+------------------------------+------
100(+-)1 | t | -1 .. 1 | t | | | |
| f | bad seg representation 100(+-)1 | t | | | |
ABC | f | bad seg representation | f | 42601 | bad seg representation | syntax error at end of input |
1 e7 | f | bad seg representation ABC | f | 42601 | bad seg representation | syntax error at or near "A" |
1e700 | f | "1e700" is out of range for type real 1 e7 | f | 42601 | bad seg representation | syntax error at or near "e" |
1e700 | f | 22003 | "1e700" is out of range for type real | |
(6 rows) (6 rows)

View File

@ -244,10 +244,14 @@ FROM test_seg WHERE s @> '11.2..11.3' OR s IS NULL ORDER BY s;
SELECT str as seg, SELECT str as seg,
pg_input_is_valid(str,'seg') as ok, pg_input_is_valid(str,'seg') as ok,
pg_input_error_message(str,'seg') as errmsg errinfo.sql_error_code,
errinfo.message,
errinfo.detail,
errinfo.hint
FROM unnest(ARRAY['-1 .. 1'::text, FROM unnest(ARRAY['-1 .. 1'::text,
'100(+-)1', '100(+-)1',
'', '',
'ABC', 'ABC',
'1 e7', '1 e7',
'1e700']) str; '1e700']) str,
LATERAL pg_input_error_info(str, 'seg') as errinfo;

View File

@ -24775,19 +24775,23 @@ SELECT collation for ('foo' COLLATE "de_DE");
<row> <row>
<entry role="func_table_entry"><para role="func_signature"> <entry role="func_table_entry"><para role="func_signature">
<indexterm> <indexterm>
<primary>pg_input_error_message</primary> <primary>pg_input_error_info</primary>
</indexterm> </indexterm>
<function>pg_input_error_message</function> ( <function>pg_input_error_info</function> (
<parameter>string</parameter> <type>text</type>, <parameter>string</parameter> <type>text</type>,
<parameter>type</parameter> <type>text</type> <parameter>type</parameter> <type>text</type>
) )
<returnvalue>text</returnvalue> <returnvalue>record</returnvalue>
( <parameter>message</parameter> <type>text</type>,
<parameter>detail</parameter> <type>text</type>,
<parameter>hint</parameter> <type>text</type>,
<parameter>sql_error_code</parameter> <type>text</type> )
</para> </para>
<para> <para>
Tests whether the given <parameter>string</parameter> is valid Tests whether the given <parameter>string</parameter> is valid
input for the specified data type; if not, return the error input for the specified data type; if not, return the details of
message that would have been thrown. If the input is valid, the the error would have been thrown. If the input is valid, the
result is NULL. The inputs are the same as results are NULL. The inputs are the same as
for <function>pg_input_is_valid</function>. for <function>pg_input_is_valid</function>.
</para> </para>
<para> <para>
@ -24798,12 +24802,17 @@ SELECT collation for ('foo' COLLATE "de_DE");
directly. directly.
</para> </para>
<para> <para>
<literal>pg_input_error_message('42000000000', 'integer')</literal> <programlisting>
<returnvalue>value "42000000000" is out of range for type integer</returnvalue> SELECT * FROM pg_input_error_info('42000000000', 'integer');
</para> message | detail | hint | sql_error_code
<para> ------------------------------------------------------+--------+------+----------------
<literal>pg_input_error_message('1234.567', 'numeric(7,4)')</literal> value "42000000000" is out of range for type integer | | | 22003
<returnvalue>numeric field overflow</returnvalue>
SELECT * FROM pg_input_error_info('1234.567', 'numeric(7,4)');
message | detail | hint | sql_error_code
------------------------+-----------------------------------------------------------------------------------+------+----------------
numeric field overflow | A field with precision 7, scale 4 must round to an absolute value less than 10^3. | | 22003
</programlisting>
</para></entry> </para></entry>
</row> </row>
</tbody> </tbody>

View File

@ -660,32 +660,60 @@ pg_input_is_valid(PG_FUNCTION_ARGS)
} }
/* /*
* pg_input_error_message - test whether string is valid input for datatype. * pg_input_error_info - test whether string is valid input for datatype.
* *
* Returns NULL if OK, else the primary message string from the error. * Returns NULL if OK, else the primary message, detail message, hint message
* and sql error code from the error.
* *
* This will only work usefully if the datatype's input function has been * This will only work usefully if the datatype's input function has been
* updated to return "soft" errors via errsave/ereturn. * updated to return "soft" errors via errsave/ereturn.
*/ */
Datum Datum
pg_input_error_message(PG_FUNCTION_ARGS) pg_input_error_info(PG_FUNCTION_ARGS)
{ {
text *txt = PG_GETARG_TEXT_PP(0); text *txt = PG_GETARG_TEXT_PP(0);
text *typname = PG_GETARG_TEXT_PP(1); text *typname = PG_GETARG_TEXT_PP(1);
ErrorSaveContext escontext = {T_ErrorSaveContext}; ErrorSaveContext escontext = {T_ErrorSaveContext};
TupleDesc tupdesc;
Datum values[4];
bool isnull[4];
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
elog(ERROR, "return type must be a row type");
/* Enable details_wanted */ /* Enable details_wanted */
escontext.details_wanted = true; escontext.details_wanted = true;
if (pg_input_is_valid_common(fcinfo, txt, typname, if (pg_input_is_valid_common(fcinfo, txt, typname,
&escontext)) &escontext))
PG_RETURN_NULL(); memset(isnull, true, sizeof(isnull));
else
{
char *sqlstate;
Assert(escontext.error_occurred); Assert(escontext.error_occurred);
Assert(escontext.error_data != NULL); Assert(escontext.error_data != NULL);
Assert(escontext.error_data->message != NULL); Assert(escontext.error_data->message != NULL);
PG_RETURN_TEXT_P(cstring_to_text(escontext.error_data->message)); memset(isnull, false, sizeof(isnull));
values[0] = CStringGetTextDatum(escontext.error_data->message);
if (escontext.error_data->detail != NULL)
values[1] = CStringGetTextDatum(escontext.error_data->detail);
else
isnull[1] = true;
if (escontext.error_data->hint != NULL)
values[2] = CStringGetTextDatum(escontext.error_data->hint);
else
isnull[2] = true;
sqlstate = unpack_sql_state(escontext.error_data->sqlerrcode);
values[3] = CStringGetTextDatum(sqlstate);
}
return HeapTupleGetDatum(heap_form_tuple(tupdesc, values, isnull));
} }
/* Common subroutine for the above */ /* Common subroutine for the above */

View File

@ -7118,9 +7118,13 @@
proname => 'pg_input_is_valid', provolatile => 's', prorettype => 'bool', proname => 'pg_input_is_valid', provolatile => 's', prorettype => 'bool',
proargtypes => 'text text', prosrc => 'pg_input_is_valid' }, proargtypes => 'text text', prosrc => 'pg_input_is_valid' },
{ oid => '8051', { oid => '8051',
descr => 'get error message if string is not valid input for data type', descr => 'get error details if string is not valid input for data type',
proname => 'pg_input_error_message', provolatile => 's', prorettype => 'text', proname => 'pg_input_error_info', provolatile => 's', prorettype => 'record',
proargtypes => 'text text', prosrc => 'pg_input_error_message' }, proargtypes => 'text text',
proallargtypes => '{text,text,text,text,text,text}',
proargmodes => '{i,i,o,o,o,o}',
proargnames => '{value,type_name,message,detail,hint,sql_error_code}',
prosrc => 'pg_input_error_info' },
{ oid => '1268', { oid => '1268',
descr => 'parse qualified identifier to array of identifiers', descr => 'parse qualified identifier to array of identifiers',

View File

@ -201,10 +201,10 @@ SELECT pg_input_is_valid('{1,zed}', 'integer[]');
f f
(1 row) (1 row)
SELECT pg_input_error_message('{1,zed}', 'integer[]'); SELECT * FROM pg_input_error_info('{1,zed}', 'integer[]');
pg_input_error_message message | detail | hint | sql_error_code
---------------------------------------------- ----------------------------------------------+--------+------+----------------
invalid input syntax for type integer: "zed" invalid input syntax for type integer: "zed" | | | 22P02
(1 row) (1 row)
-- test mixed slice/scalar subscripting -- test mixed slice/scalar subscripting

View File

@ -753,10 +753,10 @@ SELECT pg_input_is_valid('01010001', 'bit(10)');
f f
(1 row) (1 row)
SELECT pg_input_error_message('01010001', 'bit(10)'); SELECT * FROM pg_input_error_info('01010001', 'bit(10)');
pg_input_error_message message | detail | hint | sql_error_code
------------------------------------------------- -------------------------------------------------+--------+------+----------------
bit string length 8 does not match type bit(10) bit string length 8 does not match type bit(10) | | | 22026
(1 row) (1 row)
SELECT pg_input_is_valid('01010Z01', 'bit(8)'); SELECT pg_input_is_valid('01010Z01', 'bit(8)');
@ -765,10 +765,10 @@ SELECT pg_input_is_valid('01010Z01', 'bit(8)');
f f
(1 row) (1 row)
SELECT pg_input_error_message('01010Z01', 'bit(8)'); SELECT * FROM pg_input_error_info('01010Z01', 'bit(8)');
pg_input_error_message message | detail | hint | sql_error_code
--------------------------------- ---------------------------------+--------+------+----------------
"Z" is not a valid binary digit "Z" is not a valid binary digit | | | 22P02
(1 row) (1 row)
SELECT pg_input_is_valid('x01010Z01', 'bit(32)'); SELECT pg_input_is_valid('x01010Z01', 'bit(32)');
@ -777,10 +777,10 @@ SELECT pg_input_is_valid('x01010Z01', 'bit(32)');
f f
(1 row) (1 row)
SELECT pg_input_error_message('x01010Z01', 'bit(32)'); SELECT * FROM pg_input_error_info('x01010Z01', 'bit(32)');
pg_input_error_message message | detail | hint | sql_error_code
-------------------------------------- --------------------------------------+--------+------+----------------
"Z" is not a valid hexadecimal digit "Z" is not a valid hexadecimal digit | | | 22P02
(1 row) (1 row)
SELECT pg_input_is_valid('01010Z01', 'varbit'); SELECT pg_input_is_valid('01010Z01', 'varbit');
@ -789,10 +789,10 @@ SELECT pg_input_is_valid('01010Z01', 'varbit');
f f
(1 row) (1 row)
SELECT pg_input_error_message('01010Z01', 'varbit'); SELECT * FROM pg_input_error_info('01010Z01', 'varbit');
pg_input_error_message message | detail | hint | sql_error_code
--------------------------------- ---------------------------------+--------+------+----------------
"Z" is not a valid binary digit "Z" is not a valid binary digit | | | 22P02
(1 row) (1 row)
SELECT pg_input_is_valid('x01010Z01', 'varbit'); SELECT pg_input_is_valid('x01010Z01', 'varbit');
@ -801,9 +801,9 @@ SELECT pg_input_is_valid('x01010Z01', 'varbit');
f f
(1 row) (1 row)
SELECT pg_input_error_message('x01010Z01', 'varbit'); SELECT * FROM pg_input_error_info('x01010Z01', 'varbit');
pg_input_error_message message | detail | hint | sql_error_code
-------------------------------------- --------------------------------------+--------+------+----------------
"Z" is not a valid hexadecimal digit "Z" is not a valid hexadecimal digit | | | 22P02
(1 row) (1 row)

View File

@ -155,10 +155,10 @@ SELECT pg_input_is_valid('asdf', 'bool');
f f
(1 row) (1 row)
SELECT pg_input_error_message('junk', 'bool'); SELECT * FROM pg_input_error_info('junk', 'bool');
pg_input_error_message message | detail | hint | sql_error_code
----------------------------------------------- -----------------------------------------------+--------+------+----------------
invalid input syntax for type boolean: "junk" invalid input syntax for type boolean: "junk" | | | 22P02
(1 row) (1 row)
-- and, or, not in qualifications -- and, or, not in qualifications

View File

@ -646,10 +646,10 @@ SELECT pg_input_is_valid('200', 'box');
f f
(1 row) (1 row)
SELECT pg_input_error_message('200', 'box'); SELECT * FROM pg_input_error_info('200', 'box');
pg_input_error_message message | detail | hint | sql_error_code
------------------------------------------ ------------------------------------------+--------+------+----------------
invalid input syntax for type box: "200" invalid input syntax for type box: "200" | | | 22P02
(1 row) (1 row)
SELECT pg_input_is_valid('((200,300),(500, xyz))', 'box'); SELECT pg_input_is_valid('((200,300),(500, xyz))', 'box');
@ -658,9 +658,9 @@ SELECT pg_input_is_valid('((200,300),(500, xyz))', 'box');
f f
(1 row) (1 row)
SELECT pg_input_error_message('((200,300),(500, xyz))', 'box'); SELECT * FROM pg_input_error_info('((200,300),(500, xyz))', 'box');
pg_input_error_message message | detail | hint | sql_error_code
------------------------------------------------------------- -------------------------------------------------------------+--------+------+----------------
invalid input syntax for type box: "((200,300),(500, xyz))" invalid input syntax for type box: "((200,300),(500, xyz))" | | | 22P02
(1 row) (1 row)

View File

@ -132,10 +132,10 @@ SELECT pg_input_is_valid('abcde', 'char(4)');
f f
(1 row) (1 row)
SELECT pg_input_error_message('abcde', 'char(4)'); SELECT * FROM pg_input_error_info('abcde', 'char(4)');
pg_input_error_message message | detail | hint | sql_error_code
-------------------------------------- --------------------------------------+--------+------+----------------
value too long for type character(4) value too long for type character(4) | | | 22001
(1 row) (1 row)
-- --

View File

@ -132,10 +132,10 @@ SELECT pg_input_is_valid('abcde', 'char(4)');
f f
(1 row) (1 row)
SELECT pg_input_error_message('abcde', 'char(4)'); SELECT * FROM pg_input_error_info('abcde', 'char(4)');
pg_input_error_message message | detail | hint | sql_error_code
-------------------------------------- --------------------------------------+--------+------+----------------
value too long for type character(4) value too long for type character(4) | | | 22001
(1 row) (1 row)
-- --

View File

@ -132,10 +132,10 @@ SELECT pg_input_is_valid('abcde', 'char(4)');
f f
(1 row) (1 row)
SELECT pg_input_error_message('abcde', 'char(4)'); SELECT * FROM pg_input_error_info('abcde', 'char(4)');
pg_input_error_message message | detail | hint | sql_error_code
-------------------------------------- --------------------------------------+--------+------+----------------
value too long for type character(4) value too long for type character(4) | | | 22001
(1 row) (1 row)
-- --

View File

@ -859,16 +859,16 @@ SELECT pg_input_is_valid('6874898-01-01', 'date');
f f
(1 row) (1 row)
SELECT pg_input_error_message('garbage', 'date'); SELECT * FROM pg_input_error_info('garbage', 'date');
pg_input_error_message message | detail | hint | sql_error_code
----------------------------------------------- -----------------------------------------------+--------+------+----------------
invalid input syntax for type date: "garbage" invalid input syntax for type date: "garbage" | | | 22007
(1 row) (1 row)
SELECT pg_input_error_message('6874898-01-01', 'date'); SELECT * FROM pg_input_error_info('6874898-01-01', 'date');
pg_input_error_message message | detail | hint | sql_error_code
------------------------------------ ------------------------------------+--------+------+----------------
date out of range: "6874898-01-01" date out of range: "6874898-01-01" | | | 22008
(1 row) (1 row)
RESET datestyle; RESET datestyle;

View File

@ -108,32 +108,32 @@ select pg_input_is_valid('-1', 'positiveint');
f f
(1 row) (1 row)
select pg_input_error_message('junk', 'positiveint'); select * from pg_input_error_info('junk', 'positiveint');
pg_input_error_message message | detail | hint | sql_error_code
----------------------------------------------- -----------------------------------------------+--------+------+----------------
invalid input syntax for type integer: "junk" invalid input syntax for type integer: "junk" | | | 22P02
(1 row) (1 row)
select pg_input_error_message('-1', 'positiveint'); select * from pg_input_error_info('-1', 'positiveint');
pg_input_error_message message | detail | hint | sql_error_code
---------------------------------------------------------------------------- ----------------------------------------------------------------------------+--------+------+----------------
value for domain positiveint violates check constraint "positiveint_check" value for domain positiveint violates check constraint "positiveint_check" | | | 23514
(1 row) (1 row)
select pg_input_error_message('junk', 'weirdfloat'); select * from pg_input_error_info('junk', 'weirdfloat');
pg_input_error_message message | detail | hint | sql_error_code
-------------------------------------------------------- --------------------------------------------------------+--------+------+----------------
invalid input syntax for type double precision: "junk" invalid input syntax for type double precision: "junk" | | | 22P02
(1 row) (1 row)
select pg_input_error_message('0.01', 'weirdfloat'); select * from pg_input_error_info('0.01', 'weirdfloat');
pg_input_error_message message | detail | hint | sql_error_code
-------------------------------------------------------------------------- --------------------------------------------------------------------------+--------+------+----------------
value for domain weirdfloat violates check constraint "weirdfloat_check" value for domain weirdfloat violates check constraint "weirdfloat_check" | | | 23514
(1 row) (1 row)
-- We currently can't trap errors raised in the CHECK expression itself -- We currently can't trap errors raised in the CHECK expression itself
select pg_input_error_message('0', 'weirdfloat'); select * from pg_input_error_info('0', 'weirdfloat');
ERROR: division by zero ERROR: division by zero
drop domain positiveint; drop domain positiveint;
drop domain weirdfloat; drop domain weirdfloat;

View File

@ -37,18 +37,21 @@ SELECT pg_input_is_valid('mauve', 'rainbow');
f f
(1 row) (1 row)
SELECT pg_input_error_message('mauve', 'rainbow'); SELECT * FROM pg_input_error_info('mauve', 'rainbow');
pg_input_error_message message | detail | hint | sql_error_code
----------------------------------------------- -----------------------------------------------+--------+------+----------------
invalid input value for enum rainbow: "mauve" invalid input value for enum rainbow: "mauve" | | | 22P02
(1 row) (1 row)
SELECT pg_input_error_message(repeat('too_long', 32), 'rainbow'); \x
pg_input_error_message SELECT * FROM pg_input_error_info(repeat('too_long', 32), 'rainbow');
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -[ RECORD 1 ]--+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
invalid input value for enum rainbow: "too_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_long" message | invalid input value for enum rainbow: "too_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_longtoo_long"
(1 row) detail |
hint |
sql_error_code | 22P02
\x
-- --
-- adding new values -- adding new values
-- --

View File

@ -100,10 +100,10 @@ SELECT pg_input_is_valid('1e400', 'float4');
f f
(1 row) (1 row)
SELECT pg_input_error_message('1e400', 'float4'); SELECT * FROM pg_input_error_info('1e400', 'float4');
pg_input_error_message message | detail | hint | sql_error_code
--------------------------------------- ---------------------------------------+--------+------+----------------
"1e400" is out of range for type real "1e400" is out of range for type real | | | 22003
(1 row) (1 row)
-- special inputs -- special inputs

View File

@ -100,10 +100,10 @@ SELECT pg_input_is_valid('1e400', 'float4');
f f
(1 row) (1 row)
SELECT pg_input_error_message('1e400', 'float4'); SELECT * FROM pg_input_error_info('1e400', 'float4');
pg_input_error_message message | detail | hint | sql_error_code
--------------------------------------- ---------------------------------------+--------+------+----------------
"1e400" is out of range for type real "1e400" is out of range for type real | | | 22003
(1 row) (1 row)
-- special inputs -- special inputs

View File

@ -87,10 +87,10 @@ SELECT pg_input_is_valid('1e4000', 'float8');
f f
(1 row) (1 row)
SELECT pg_input_error_message('1e4000', 'float8'); SELECT * FROM pg_input_error_info('1e4000', 'float8');
pg_input_error_message message | detail | hint | sql_error_code
---------------------------------------------------- ----------------------------------------------------+--------+------+----------------
"1e4000" is out of range for type double precision "1e4000" is out of range for type double precision | | | 22003
(1 row) (1 row)
-- special inputs -- special inputs

View File

@ -5302,10 +5302,10 @@ SELECT pg_input_is_valid('(1', 'circle');
f f
(1 row) (1 row)
SELECT pg_input_error_message('1,', 'circle'); SELECT * FROM pg_input_error_info('1,', 'circle');
pg_input_error_message message | detail | hint | sql_error_code
-------------------------------------------- --------------------------------------------+--------+------+----------------
invalid input syntax for type circle: "1," invalid input syntax for type circle: "1," | | | 22P02
(1 row) (1 row)
SELECT pg_input_is_valid('(1,2),-1', 'circle'); SELECT pg_input_is_valid('(1,2),-1', 'circle');
@ -5314,9 +5314,9 @@ SELECT pg_input_is_valid('(1,2),-1', 'circle');
f f
(1 row) (1 row)
SELECT pg_input_error_message('(1,2),-1', 'circle'); SELECT * FROM pg_input_error_info('(1,2),-1', 'circle');
pg_input_error_message message | detail | hint | sql_error_code
-------------------------------------------------- --------------------------------------------------+--------+------+----------------
invalid input syntax for type circle: "(1,2),-1" invalid input syntax for type circle: "(1,2),-1" | | | 22P02
(1 row) (1 row)

View File

@ -1063,10 +1063,10 @@ SELECT pg_input_is_valid('1234', 'cidr');
f f
(1 row) (1 row)
SELECT pg_input_error_message('1234', 'cidr'); SELECT * FROM pg_input_error_info('1234', 'cidr');
pg_input_error_message message | detail | hint | sql_error_code
-------------------------------------------- --------------------------------------------+--------+------+----------------
invalid input syntax for type cidr: "1234" invalid input syntax for type cidr: "1234" | | | 22P02
(1 row) (1 row)
SELECT pg_input_is_valid('192.168.198.200/24', 'cidr'); SELECT pg_input_is_valid('192.168.198.200/24', 'cidr');
@ -1075,10 +1075,10 @@ SELECT pg_input_is_valid('192.168.198.200/24', 'cidr');
f f
(1 row) (1 row)
SELECT pg_input_error_message('192.168.198.200/24', 'cidr'); SELECT * FROM pg_input_error_info('192.168.198.200/24', 'cidr');
pg_input_error_message message | detail | hint | sql_error_code
------------------------------------------ ------------------------------------------+--------------------------------------+------+----------------
invalid cidr value: "192.168.198.200/24" invalid cidr value: "192.168.198.200/24" | Value has bits set to right of mask. | | 22P02
(1 row) (1 row)
SELECT pg_input_is_valid('1234', 'inet'); SELECT pg_input_is_valid('1234', 'inet');
@ -1087,9 +1087,9 @@ SELECT pg_input_is_valid('1234', 'inet');
f f
(1 row) (1 row)
SELECT pg_input_error_message('1234', 'inet'); SELECT * FROM pg_input_error_info('1234', 'inet');
pg_input_error_message message | detail | hint | sql_error_code
-------------------------------------------- --------------------------------------------+--------+------+----------------
invalid input syntax for type inet: "1234" invalid input syntax for type inet: "1234" | | | 22P02
(1 row) (1 row)

View File

@ -64,10 +64,10 @@ SELECT pg_input_is_valid('50000', 'int2');
f f
(1 row) (1 row)
SELECT pg_input_error_message('50000', 'int2'); SELECT * FROM pg_input_error_info('50000', 'int2');
pg_input_error_message message | detail | hint | sql_error_code
------------------------------------------------- -------------------------------------------------+--------+------+----------------
value "50000" is out of range for type smallint value "50000" is out of range for type smallint | | | 22003
(1 row) (1 row)
-- While we're here, check int2vector as well -- While we're here, check int2vector as well
@ -77,16 +77,16 @@ SELECT pg_input_is_valid(' 1 3 5 ', 'int2vector');
t t
(1 row) (1 row)
SELECT pg_input_error_message('1 asdf', 'int2vector'); SELECT * FROM pg_input_error_info('1 asdf', 'int2vector');
pg_input_error_message message | detail | hint | sql_error_code
------------------------------------------------ ------------------------------------------------+--------+------+----------------
invalid input syntax for type smallint: "asdf" invalid input syntax for type smallint: "asdf" | | | 22P02
(1 row) (1 row)
SELECT pg_input_error_message('50000', 'int2vector'); SELECT * FROM pg_input_error_info('50000', 'int2vector');
pg_input_error_message message | detail | hint | sql_error_code
------------------------------------------------- -------------------------------------------------+--------+------+----------------
value "50000" is out of range for type smallint value "50000" is out of range for type smallint | | | 22003
(1 row) (1 row)
SELECT * FROM INT2_TBL AS f(a, b); SELECT * FROM INT2_TBL AS f(a, b);

View File

@ -64,10 +64,10 @@ SELECT pg_input_is_valid('1000000000000', 'int4');
f f
(1 row) (1 row)
SELECT pg_input_error_message('1000000000000', 'int4'); SELECT * FROM pg_input_error_info('1000000000000', 'int4');
pg_input_error_message message | detail | hint | sql_error_code
-------------------------------------------------------- --------------------------------------------------------+--------+------+----------------
value "1000000000000" is out of range for type integer value "1000000000000" is out of range for type integer | | | 22003
(1 row) (1 row)
SELECT i.* FROM INT4_TBL i WHERE i.f1 <> int2 '0'; SELECT i.* FROM INT4_TBL i WHERE i.f1 <> int2 '0';

View File

@ -61,10 +61,10 @@ SELECT pg_input_is_valid('10000000000000000000', 'int8');
f f
(1 row) (1 row)
SELECT pg_input_error_message('10000000000000000000', 'int8'); SELECT * FROM pg_input_error_info('10000000000000000000', 'int8');
pg_input_error_message message | detail | hint | sql_error_code
-------------------------------------------------------------- --------------------------------------------------------------+--------+------+----------------
value "10000000000000000000" is out of range for type bigint value "10000000000000000000" is out of range for type bigint | | | 22003
(1 row) (1 row)
-- int8/int8 cmp -- int8/int8 cmp

View File

@ -91,16 +91,16 @@ SELECT pg_input_is_valid('@ 30 eons ago', 'interval');
f f
(1 row) (1 row)
SELECT pg_input_error_message('garbage', 'interval'); SELECT * FROM pg_input_error_info('garbage', 'interval');
pg_input_error_message message | detail | hint | sql_error_code
--------------------------------------------------- ---------------------------------------------------+--------+------+----------------
invalid input syntax for type interval: "garbage" invalid input syntax for type interval: "garbage" | | | 22007
(1 row) (1 row)
SELECT pg_input_error_message('@ 30 eons ago', 'interval'); SELECT * FROM pg_input_error_info('@ 30 eons ago', 'interval');
pg_input_error_message message | detail | hint | sql_error_code
--------------------------------------------------------- ---------------------------------------------------------+--------+------+----------------
invalid input syntax for type interval: "@ 30 eons ago" invalid input syntax for type interval: "@ 30 eons ago" | | | 22007
(1 row) (1 row)
-- test interval operators -- test interval operators

View File

@ -333,10 +333,10 @@ select pg_input_is_valid('{"a":true', 'json');
f f
(1 row) (1 row)
select pg_input_error_message('{"a":true', 'json'); select * from pg_input_error_info('{"a":true', 'json');
pg_input_error_message message | detail | hint | sql_error_code
------------------------------------ ------------------------------------+--------------------------------------+------+----------------
invalid input syntax for type json invalid input syntax for type json | The input string ended unexpectedly. | | 22P02
(1 row) (1 row)
--constructors --constructors

View File

@ -261,9 +261,9 @@ SELECT jsonb '{ "a": "null \\u0000 escape" }' ->> 'a' as not_an_escape;
(1 row) (1 row)
-- soft error for input-time failure -- soft error for input-time failure
select pg_input_error_message('{ "a": "\ud83d\ude04\ud83d\udc36" }', 'jsonb'); select * from pg_input_error_info('{ "a": "\ud83d\ude04\ud83d\udc36" }', 'jsonb');
pg_input_error_message message | detail | hint | sql_error_code
------------------------ ---------+--------+------+----------------
| | |
(1 row) (1 row)

View File

@ -257,9 +257,9 @@ SELECT jsonb '{ "a": "null \\u0000 escape" }' ->> 'a' as not_an_escape;
(1 row) (1 row)
-- soft error for input-time failure -- soft error for input-time failure
select pg_input_error_message('{ "a": "\ud83d\ude04\ud83d\udc36" }', 'jsonb'); select * from pg_input_error_info('{ "a": "\ud83d\ude04\ud83d\udc36" }', 'jsonb');
pg_input_error_message message | detail | hint | sql_error_code
------------------------------------- -------------------------------------+----------------------------------------------------------------------------------+------+----------------
unsupported Unicode escape sequence unsupported Unicode escape sequence | Unicode escape value could not be translated to the server's encoding SQL_ASCII. | | 22P05
(1 row) (1 row)

View File

@ -323,16 +323,16 @@ select pg_input_is_valid('{"a":true', 'jsonb');
f f
(1 row) (1 row)
select pg_input_error_message('{"a":true', 'jsonb'); select * from pg_input_error_info('{"a":true', 'jsonb');
pg_input_error_message message | detail | hint | sql_error_code
------------------------------------ ------------------------------------+--------------------------------------+------+----------------
invalid input syntax for type json invalid input syntax for type json | The input string ended unexpectedly. | | 22P02
(1 row) (1 row)
select pg_input_error_message('{"a":1e1000000}', 'jsonb'); select * from pg_input_error_info('{"a":1e1000000}', 'jsonb');
pg_input_error_message message | detail | hint | sql_error_code
-------------------------------- --------------------------------+--------+------+----------------
value overflows numeric format value overflows numeric format | | | 22003
(1 row) (1 row)
-- make sure jsonb is passed through json generators without being escaped -- make sure jsonb is passed through json generators without being escaped

View File

@ -1035,18 +1035,22 @@ select '1?(2>3)'::jsonpath;
-- test non-error-throwing API -- test non-error-throwing API
SELECT str as jsonpath, SELECT str as jsonpath,
pg_input_is_valid(str,'jsonpath') as ok, pg_input_is_valid(str,'jsonpath') as ok,
pg_input_error_message(str,'jsonpath') as errmsg errinfo.sql_error_code,
errinfo.message,
errinfo.detail,
errinfo.hint
FROM unnest(ARRAY['$ ? (@ like_regex "pattern" flag "smixq")'::text, FROM unnest(ARRAY['$ ? (@ like_regex "pattern" flag "smixq")'::text,
'$ ? (@ like_regex "pattern" flag "a")', '$ ? (@ like_regex "pattern" flag "a")',
'@ + 1', '@ + 1',
'00', '00',
'1a']) str; '1a']) str,
jsonpath | ok | errmsg LATERAL pg_input_error_info(str, 'jsonpath') as errinfo;
-------------------------------------------+----+----------------------------------------------------------------------- jsonpath | ok | sql_error_code | message | detail | hint
$ ? (@ like_regex "pattern" flag "smixq") | t | -------------------------------------------+----+----------------+-----------------------------------------------------------------------+----------------------------------------------------------+------
$ ? (@ like_regex "pattern" flag "a") | f | invalid input syntax for type jsonpath $ ? (@ like_regex "pattern" flag "smixq") | t | | | |
@ + 1 | f | @ is not allowed in root expressions $ ? (@ like_regex "pattern" flag "a") | f | 42601 | invalid input syntax for type jsonpath | Unrecognized flag character "a" in LIKE_REGEX predicate. |
00 | f | trailing junk after numeric literal at or near "00" of jsonpath input @ + 1 | f | 42601 | @ is not allowed in root expressions | |
1a | f | trailing junk after numeric literal at or near "1a" of jsonpath input 00 | f | 42601 | trailing junk after numeric literal at or near "00" of jsonpath input | |
1a | f | 42601 | trailing junk after numeric literal at or near "1a" of jsonpath input | |
(5 rows) (5 rows)

View File

@ -92,10 +92,10 @@ SELECT pg_input_is_valid('{1, 1}', 'line');
f f
(1 row) (1 row)
SELECT pg_input_error_message('{1, 1}', 'line'); SELECT * FROM pg_input_error_info('{1, 1}', 'line');
pg_input_error_message message | detail | hint | sql_error_code
---------------------------------------------- ----------------------------------------------+--------+------+----------------
invalid input syntax for type line: "{1, 1}" invalid input syntax for type line: "{1, 1}" | | | 22P02
(1 row) (1 row)
SELECT pg_input_is_valid('{0, 0, 0}', 'line'); SELECT pg_input_is_valid('{0, 0, 0}', 'line');
@ -104,10 +104,10 @@ SELECT pg_input_is_valid('{0, 0, 0}', 'line');
f f
(1 row) (1 row)
SELECT pg_input_error_message('{0, 0, 0}', 'line'); SELECT * FROM pg_input_error_info('{0, 0, 0}', 'line');
pg_input_error_message message | detail | hint | sql_error_code
--------------------------------------------------------- ---------------------------------------------------------+--------+------+----------------
invalid line specification: A and B cannot both be zero invalid line specification: A and B cannot both be zero | | | 22P02
(1 row) (1 row)
SELECT pg_input_is_valid('{1, 1, a}', 'line'); SELECT pg_input_is_valid('{1, 1, a}', 'line');
@ -116,10 +116,10 @@ SELECT pg_input_is_valid('{1, 1, a}', 'line');
f f
(1 row) (1 row)
SELECT pg_input_error_message('{1, 1, a}', 'line'); SELECT * FROM pg_input_error_info('{1, 1, a}', 'line');
pg_input_error_message message | detail | hint | sql_error_code
------------------------------------------------- -------------------------------------------------+--------+------+----------------
invalid input syntax for type line: "{1, 1, a}" invalid input syntax for type line: "{1, 1, a}" | | | 22P02
(1 row) (1 row)
SELECT pg_input_is_valid('{1, 1, 1e400}', 'line'); SELECT pg_input_is_valid('{1, 1, 1e400}', 'line');
@ -128,10 +128,10 @@ SELECT pg_input_is_valid('{1, 1, 1e400}', 'line');
f f
(1 row) (1 row)
SELECT pg_input_error_message('{1, 1, 1e400}', 'line'); SELECT * FROM pg_input_error_info('{1, 1, 1e400}', 'line');
pg_input_error_message message | detail | hint | sql_error_code
--------------------------------------------------- ---------------------------------------------------+--------+------+----------------
"1e400" is out of range for type double precision "1e400" is out of range for type double precision | | | 22003
(1 row) (1 row)
SELECT pg_input_is_valid('(1, 1), (1, 1e400)', 'line'); SELECT pg_input_is_valid('(1, 1), (1, 1e400)', 'line');
@ -140,9 +140,9 @@ SELECT pg_input_is_valid('(1, 1), (1, 1e400)', 'line');
f f
(1 row) (1 row)
SELECT pg_input_error_message('(1, 1), (1, 1e400)', 'line'); SELECT * FROM pg_input_error_info('(1, 1), (1, 1e400)', 'line');
pg_input_error_message message | detail | hint | sql_error_code
--------------------------------------------------- ---------------------------------------------------+--------+------+----------------
"1e400" is out of range for type double precision "1e400" is out of range for type double precision | | | 22003
(1 row) (1 row)

View File

@ -49,9 +49,9 @@ SELECT pg_input_is_valid('[(1,2),(3)]', 'lseg');
f f
(1 row) (1 row)
SELECT pg_input_error_message('[(1,2),(3)]', 'lseg'); SELECT * FROM pg_input_error_info('[(1,2),(3)]', 'lseg');
pg_input_error_message message | detail | hint | sql_error_code
--------------------------------------------------- ---------------------------------------------------+--------+------+----------------
invalid input syntax for type lseg: "[(1,2),(3)]" invalid input syntax for type lseg: "[(1,2),(3)]" | | | 22P02
(1 row) (1 row)

View File

@ -165,10 +165,10 @@ SELECT pg_input_is_valid('08:00:2b:01:02:ZZ', 'macaddr');
f f
(1 row) (1 row)
SELECT pg_input_error_message('08:00:2b:01:02:ZZ', 'macaddr'); SELECT * FROM pg_input_error_info('08:00:2b:01:02:ZZ', 'macaddr');
pg_input_error_message message | detail | hint | sql_error_code
------------------------------------------------------------ ------------------------------------------------------------+--------+------+----------------
invalid input syntax for type macaddr: "08:00:2b:01:02:ZZ" invalid input syntax for type macaddr: "08:00:2b:01:02:ZZ" | | | 22P02
(1 row) (1 row)
SELECT pg_input_is_valid('08:00:2b:01:02:', 'macaddr'); SELECT pg_input_is_valid('08:00:2b:01:02:', 'macaddr');
@ -177,9 +177,9 @@ SELECT pg_input_is_valid('08:00:2b:01:02:', 'macaddr');
f f
(1 row) (1 row)
SELECT pg_input_error_message('08:00:2b:01:02:', 'macaddr'); SELECT * FROM pg_input_error_info('08:00:2b:01:02:', 'macaddr');
pg_input_error_message message | detail | hint | sql_error_code
---------------------------------------------------------- ----------------------------------------------------------+--------+------+----------------
invalid input syntax for type macaddr: "08:00:2b:01:02:" invalid input syntax for type macaddr: "08:00:2b:01:02:" | | | 22P02
(1 row) (1 row)

View File

@ -359,10 +359,10 @@ SELECT pg_input_is_valid('08:00:2b:01:02:03:04:ZZ', 'macaddr8');
f f
(1 row) (1 row)
SELECT pg_input_error_message('08:00:2b:01:02:03:04:ZZ', 'macaddr8'); SELECT * FROM pg_input_error_info('08:00:2b:01:02:03:04:ZZ', 'macaddr8');
pg_input_error_message message | detail | hint | sql_error_code
------------------------------------------------------------------- -------------------------------------------------------------------+--------+------+----------------
invalid input syntax for type macaddr8: "08:00:2b:01:02:03:04:ZZ" invalid input syntax for type macaddr8: "08:00:2b:01:02:03:04:ZZ" | | | 22P02
(1 row) (1 row)
SELECT pg_input_is_valid('08:00:2b:01:02:03:04:', 'macaddr8'); SELECT pg_input_is_valid('08:00:2b:01:02:03:04:', 'macaddr8');
@ -371,9 +371,9 @@ SELECT pg_input_is_valid('08:00:2b:01:02:03:04:', 'macaddr8');
f f
(1 row) (1 row)
SELECT pg_input_error_message('08:00:2b:01:02:03:04:', 'macaddr8'); SELECT * FROM pg_input_error_info('08:00:2b:01:02:03:04:', 'macaddr8');
pg_input_error_message message | detail | hint | sql_error_code
----------------------------------------------------------------- -----------------------------------------------------------------+--------+------+----------------
invalid input syntax for type macaddr8: "08:00:2b:01:02:03:04:" invalid input syntax for type macaddr8: "08:00:2b:01:02:03:04:" | | | 22P02
(1 row) (1 row)

View File

@ -338,10 +338,10 @@ SELECT pg_input_is_valid('\x0001', 'money');
f f
(1 row) (1 row)
SELECT pg_input_error_message('\x0001', 'money'); SELECT * FROM pg_input_error_info('\x0001', 'money');
pg_input_error_message message | detail | hint | sql_error_code
----------------------------------------------- -----------------------------------------------+--------+------+----------------
invalid input syntax for type money: "\x0001" invalid input syntax for type money: "\x0001" | | | 22P02
(1 row) (1 row)
SELECT pg_input_is_valid('192233720368547758.07', 'money'); SELECT pg_input_is_valid('192233720368547758.07', 'money');
@ -350,10 +350,10 @@ SELECT pg_input_is_valid('192233720368547758.07', 'money');
f f
(1 row) (1 row)
SELECT pg_input_error_message('192233720368547758.07', 'money'); SELECT * FROM pg_input_error_info('192233720368547758.07', 'money');
pg_input_error_message message | detail | hint | sql_error_code
-------------------------------------------------------------- --------------------------------------------------------------+--------+------+----------------
value "192233720368547758.07" is out of range for type money value "192233720368547758.07" is out of range for type money | | | 22003
(1 row) (1 row)
-- documented minimums and maximums -- documented minimums and maximums

View File

@ -287,10 +287,10 @@ select pg_input_is_valid('{[1,2], [4,5]', 'int4multirange');
f f
(1 row) (1 row)
select pg_input_error_message('{[1,2], [4,5]', 'int4multirange'); select * from pg_input_error_info('{[1,2], [4,5]', 'int4multirange');
pg_input_error_message message | detail | hint | sql_error_code
----------------------------------------------- -----------------------------------------------+--------------------------+------+----------------
malformed multirange literal: "{[1,2], [4,5]" malformed multirange literal: "{[1,2], [4,5]" | Unexpected end of input. | | 22P02
(1 row) (1 row)
select pg_input_is_valid('{[1,2], [4,zed]}', 'int4multirange'); select pg_input_is_valid('{[1,2], [4,zed]}', 'int4multirange');
@ -299,10 +299,10 @@ select pg_input_is_valid('{[1,2], [4,zed]}', 'int4multirange');
f f
(1 row) (1 row)
select pg_input_error_message('{[1,2], [4,zed]}', 'int4multirange'); select * from pg_input_error_info('{[1,2], [4,zed]}', 'int4multirange');
pg_input_error_message message | detail | hint | sql_error_code
---------------------------------------------- ----------------------------------------------+--------+------+----------------
invalid input syntax for type integer: "zed" invalid input syntax for type integer: "zed" | | | 22P02
(1 row) (1 row)
-- --

View File

@ -2312,10 +2312,10 @@ SELECT pg_input_is_valid('1e400000', 'numeric');
f f
(1 row) (1 row)
SELECT pg_input_error_message('1e400000', 'numeric'); SELECT * FROM pg_input_error_info('1e400000', 'numeric');
pg_input_error_message message | detail | hint | sql_error_code
-------------------------------- --------------------------------+--------+------+----------------
value overflows numeric format value overflows numeric format | | | 22003
(1 row) (1 row)
SELECT pg_input_is_valid('1234.567', 'numeric(8,4)'); SELECT pg_input_is_valid('1234.567', 'numeric(8,4)');
@ -2330,16 +2330,16 @@ SELECT pg_input_is_valid('1234.567', 'numeric(7,4)');
f f
(1 row) (1 row)
SELECT pg_input_error_message('1234.567', 'numeric(7,4)'); SELECT * FROM pg_input_error_info('1234.567', 'numeric(7,4)');
pg_input_error_message message | detail | hint | sql_error_code
------------------------ ------------------------+-----------------------------------------------------------------------------------+------+----------------
numeric field overflow numeric field overflow | A field with precision 7, scale 4 must round to an absolute value less than 10^3. | | 22003
(1 row) (1 row)
SELECT pg_input_error_message('0x1234.567', 'numeric'); SELECT * FROM pg_input_error_info('0x1234.567', 'numeric');
pg_input_error_message message | detail | hint | sql_error_code
----------------------------------------------------- -----------------------------------------------------+--------+------+----------------
invalid input syntax for type numeric: "0x1234.567" invalid input syntax for type numeric: "0x1234.567" | | | 22P02
(1 row) (1 row)
-- --

View File

@ -78,10 +78,10 @@ SELECT pg_input_is_valid('01XYZ', 'oid');
f f
(1 row) (1 row)
SELECT pg_input_error_message('01XYZ', 'oid'); SELECT * FROM pg_input_error_info('01XYZ', 'oid');
pg_input_error_message message | detail | hint | sql_error_code
-------------------------------------------- --------------------------------------------+--------+------+----------------
invalid input syntax for type oid: "01XYZ" invalid input syntax for type oid: "01XYZ" | | | 22P02
(1 row) (1 row)
SELECT pg_input_is_valid('9999999999', 'oid'); SELECT pg_input_is_valid('9999999999', 'oid');
@ -90,10 +90,10 @@ SELECT pg_input_is_valid('9999999999', 'oid');
f f
(1 row) (1 row)
SELECT pg_input_error_message('9999999999', 'oid'); SELECT * FROM pg_input_error_info('9999999999', 'oid');
pg_input_error_message message | detail | hint | sql_error_code
------------------------------------------------- -------------------------------------------------+--------+------+----------------
value "9999999999" is out of range for type oid value "9999999999" is out of range for type oid | | | 22003
(1 row) (1 row)
-- While we're here, check oidvector as well -- While we're here, check oidvector as well
@ -109,10 +109,10 @@ SELECT pg_input_is_valid('01 01XYZ', 'oidvector');
f f
(1 row) (1 row)
SELECT pg_input_error_message('01 01XYZ', 'oidvector'); SELECT * FROM pg_input_error_info('01 01XYZ', 'oidvector');
pg_input_error_message message | detail | hint | sql_error_code
------------------------------------------ ------------------------------------------+--------+------+----------------
invalid input syntax for type oid: "XYZ" invalid input syntax for type oid: "XYZ" | | | 22P02
(1 row) (1 row)
SELECT pg_input_is_valid('01 9999999999', 'oidvector'); SELECT pg_input_is_valid('01 9999999999', 'oidvector');
@ -121,10 +121,10 @@ SELECT pg_input_is_valid('01 9999999999', 'oidvector');
f f
(1 row) (1 row)
SELECT pg_input_error_message('01 9999999999', 'oidvector'); SELECT * FROM pg_input_error_info('01 9999999999', 'oidvector');
pg_input_error_message message | detail | hint | sql_error_code
------------------------------------------------- -------------------------------------------------+--------+------+----------------
value "9999999999" is out of range for type oid value "9999999999" is out of range for type oid | | | 22003
(1 row) (1 row)
SELECT o.* FROM OID_TBL o WHERE o.f1 = 1234; SELECT o.* FROM OID_TBL o WHERE o.f1 = 1234;

View File

@ -87,10 +87,10 @@ SELECT pg_input_is_valid('[(1,2),(3)]', 'path');
f f
(1 row) (1 row)
SELECT pg_input_error_message('[(1,2),(3)]', 'path'); SELECT * FROM pg_input_error_info('[(1,2),(3)]', 'path');
pg_input_error_message message | detail | hint | sql_error_code
--------------------------------------------------- ---------------------------------------------------+--------+------+----------------
invalid input syntax for type path: "[(1,2),(3)]" invalid input syntax for type path: "[(1,2),(3)]" | | | 22P02
(1 row) (1 row)
SELECT pg_input_is_valid('[(1,2,6),(3,4,6)]', 'path'); SELECT pg_input_is_valid('[(1,2,6),(3,4,6)]', 'path');
@ -99,9 +99,9 @@ SELECT pg_input_is_valid('[(1,2,6),(3,4,6)]', 'path');
f f
(1 row) (1 row)
SELECT pg_input_error_message('[(1,2,6),(3,4,6)]', 'path'); SELECT * FROM pg_input_error_info('[(1,2,6),(3,4,6)]', 'path');
pg_input_error_message message | detail | hint | sql_error_code
--------------------------------------------------------- ---------------------------------------------------------+--------+------+----------------
invalid input syntax for type path: "[(1,2,6),(3,4,6)]" invalid input syntax for type path: "[(1,2,6),(3,4,6)]" | | | 22P02
(1 row) (1 row)

View File

@ -33,10 +33,10 @@ SELECT pg_input_is_valid('16AE7F7', 'pg_lsn');
f f
(1 row) (1 row)
SELECT pg_input_error_message('16AE7F7', 'pg_lsn'); SELECT * FROM pg_input_error_info('16AE7F7', 'pg_lsn');
pg_input_error_message message | detail | hint | sql_error_code
------------------------------------------------- -------------------------------------------------+--------+------+----------------
invalid input syntax for type pg_lsn: "16AE7F7" invalid input syntax for type pg_lsn: "16AE7F7" | | | 22P02
(1 row) (1 row)
-- Min/Max aggregation -- Min/Max aggregation

View File

@ -470,9 +470,9 @@ SELECT pg_input_is_valid('1,y', 'point');
f f
(1 row) (1 row)
SELECT pg_input_error_message('1,y', 'point'); SELECT * FROM pg_input_error_info('1,y', 'point');
pg_input_error_message message | detail | hint | sql_error_code
-------------------------------------------- --------------------------------------------+--------+------+----------------
invalid input syntax for type point: "1,y" invalid input syntax for type point: "1,y" | | | 22P02
(1 row) (1 row)

View File

@ -313,10 +313,10 @@ SELECT pg_input_is_valid('(2.0,0.8,0.1)', 'polygon');
f f
(1 row) (1 row)
SELECT pg_input_error_message('(2.0,0.8,0.1)', 'polygon'); SELECT * FROM pg_input_error_info('(2.0,0.8,0.1)', 'polygon');
pg_input_error_message message | detail | hint | sql_error_code
-------------------------------------------------------- --------------------------------------------------------+--------+------+----------------
invalid input syntax for type polygon: "(2.0,0.8,0.1)" invalid input syntax for type polygon: "(2.0,0.8,0.1)" | | | 22P02
(1 row) (1 row)
SELECT pg_input_is_valid('(2.0,xyz)', 'polygon'); SELECT pg_input_is_valid('(2.0,xyz)', 'polygon');
@ -325,9 +325,9 @@ SELECT pg_input_is_valid('(2.0,xyz)', 'polygon');
f f
(1 row) (1 row)
SELECT pg_input_error_message('(2.0,xyz)', 'polygon'); SELECT * FROM pg_input_error_info('(2.0,xyz)', 'polygon');
pg_input_error_message message | detail | hint | sql_error_code
---------------------------------------------------- ----------------------------------------------------+--------+------+----------------
invalid input syntax for type polygon: "(2.0,xyz)" invalid input syntax for type polygon: "(2.0,xyz)" | | | 22P02
(1 row) (1 row)

View File

@ -2246,10 +2246,10 @@ SELECT pg_input_is_valid('regress_priv_user1=r/', 'aclitem');
f f
(1 row) (1 row)
SELECT pg_input_error_message('regress_priv_user1=r/', 'aclitem'); SELECT * FROM pg_input_error_info('regress_priv_user1=r/', 'aclitem');
pg_input_error_message message | detail | hint | sql_error_code
--------------------------------- ---------------------------------+--------+------+----------------
a name must follow the "/" sign a name must follow the "/" sign | | | 22P02
(1 row) (1 row)
SELECT pg_input_is_valid('regress_priv_user1=r/regress_no_such_user', 'aclitem'); SELECT pg_input_is_valid('regress_priv_user1=r/regress_no_such_user', 'aclitem');
@ -2258,10 +2258,10 @@ SELECT pg_input_is_valid('regress_priv_user1=r/regress_no_such_user', 'aclitem')
f f
(1 row) (1 row)
SELECT pg_input_error_message('regress_priv_user1=r/regress_no_such_user', 'aclitem'); SELECT * FROM pg_input_error_info('regress_priv_user1=r/regress_no_such_user', 'aclitem');
pg_input_error_message message | detail | hint | sql_error_code
-------------------------------------------- --------------------------------------------+--------+------+----------------
role "regress_no_such_user" does not exist role "regress_no_such_user" does not exist | | | 42704
(1 row) (1 row)
SELECT pg_input_is_valid('regress_priv_user1=rY', 'aclitem'); SELECT pg_input_is_valid('regress_priv_user1=rY', 'aclitem');
@ -2270,10 +2270,10 @@ SELECT pg_input_is_valid('regress_priv_user1=rY', 'aclitem');
f f
(1 row) (1 row)
SELECT pg_input_error_message('regress_priv_user1=rY', 'aclitem'); SELECT * FROM pg_input_error_info('regress_priv_user1=rY', 'aclitem');
pg_input_error_message message | detail | hint | sql_error_code
---------------------------------------------------------- ----------------------------------------------------------+--------+------+----------------
invalid mode character: must be one of "arwdDxtXUCTcsAm" invalid mode character: must be one of "arwdDxtXUCTcsAm" | | | 22P02
(1 row) (1 row)
-- --

View File

@ -188,10 +188,10 @@ select pg_input_is_valid('(1,4', 'int4range');
f f
(1 row) (1 row)
select pg_input_error_message('(1,4', 'int4range'); select * from pg_input_error_info('(1,4', 'int4range');
pg_input_error_message message | detail | hint | sql_error_code
--------------------------------- ---------------------------------+--------------------------+------+----------------
malformed range literal: "(1,4" malformed range literal: "(1,4" | Unexpected end of input. | | 22P02
(1 row) (1 row)
select pg_input_is_valid('(4,1)', 'int4range'); select pg_input_is_valid('(4,1)', 'int4range');
@ -200,10 +200,10 @@ select pg_input_is_valid('(4,1)', 'int4range');
f f
(1 row) (1 row)
select pg_input_error_message('(4,1)', 'int4range'); select * from pg_input_error_info('(4,1)', 'int4range');
pg_input_error_message message | detail | hint | sql_error_code
------------------------------------------------------------------- -------------------------------------------------------------------+--------+------+----------------
range lower bound must be less than or equal to range upper bound range lower bound must be less than or equal to range upper bound | | | 22000
(1 row) (1 row)
select pg_input_is_valid('(4,zed)', 'int4range'); select pg_input_is_valid('(4,zed)', 'int4range');
@ -212,10 +212,10 @@ select pg_input_is_valid('(4,zed)', 'int4range');
f f
(1 row) (1 row)
select pg_input_error_message('(4,zed)', 'int4range'); select * from pg_input_error_info('(4,zed)', 'int4range');
pg_input_error_message message | detail | hint | sql_error_code
---------------------------------------------- ----------------------------------------------+--------+------+----------------
invalid input syntax for type integer: "zed" invalid input syntax for type integer: "zed" | | | 22P02
(1 row) (1 row)
select pg_input_is_valid('[1,2147483647]', 'int4range'); select pg_input_is_valid('[1,2147483647]', 'int4range');
@ -224,10 +224,10 @@ select pg_input_is_valid('[1,2147483647]', 'int4range');
f f
(1 row) (1 row)
select pg_input_error_message('[1,2147483647]', 'int4range'); select * from pg_input_error_info('[1,2147483647]', 'int4range');
pg_input_error_message message | detail | hint | sql_error_code
------------------------ ----------------------+--------+------+----------------
integer out of range integer out of range | | | 22003
(1 row) (1 row)
select pg_input_is_valid('[2000-01-01,5874897-12-31]', 'daterange'); select pg_input_is_valid('[2000-01-01,5874897-12-31]', 'daterange');
@ -236,10 +236,10 @@ select pg_input_is_valid('[2000-01-01,5874897-12-31]', 'daterange');
f f
(1 row) (1 row)
select pg_input_error_message('[2000-01-01,5874897-12-31]', 'daterange'); select * from pg_input_error_info('[2000-01-01,5874897-12-31]', 'daterange');
pg_input_error_message message | detail | hint | sql_error_code
------------------------ -------------------+--------+------+----------------
date out of range date out of range | | | 22008
(1 row) (1 row)
-- --

View File

@ -448,10 +448,10 @@ SELECT to_regnamespace('foo.bar');
(1 row) (1 row)
-- Test soft-error API -- Test soft-error API
SELECT pg_input_error_message('ng_catalog.pg_class', 'regclass'); SELECT * FROM pg_input_error_info('ng_catalog.pg_class', 'regclass');
pg_input_error_message message | detail | hint | sql_error_code
----------------------------------------------- -----------------------------------------------+--------+------+----------------
relation "ng_catalog.pg_class" does not exist relation "ng_catalog.pg_class" does not exist | | | 42P01
(1 row) (1 row)
SELECT pg_input_is_valid('ng_catalog."POSIX"', 'regcollation'); SELECT pg_input_is_valid('ng_catalog."POSIX"', 'regcollation');
@ -460,87 +460,87 @@ SELECT pg_input_is_valid('ng_catalog."POSIX"', 'regcollation');
f f
(1 row) (1 row)
SELECT pg_input_error_message('no_such_config', 'regconfig'); SELECT * FROM pg_input_error_info('no_such_config', 'regconfig');
pg_input_error_message message | detail | hint | sql_error_code
----------------------------------------------------------- -----------------------------------------------------------+--------+------+----------------
text search configuration "no_such_config" does not exist text search configuration "no_such_config" does not exist | | | 42704
(1 row) (1 row)
SELECT pg_input_error_message('no_such_dictionary', 'regdictionary'); SELECT * FROM pg_input_error_info('no_such_dictionary', 'regdictionary');
pg_input_error_message message | detail | hint | sql_error_code
------------------------------------------------------------ ------------------------------------------------------------+--------+------+----------------
text search dictionary "no_such_dictionary" does not exist text search dictionary "no_such_dictionary" does not exist | | | 42704
(1 row) (1 row)
SELECT pg_input_error_message('Nonexistent', 'regnamespace'); SELECT * FROM pg_input_error_info('Nonexistent', 'regnamespace');
pg_input_error_message message | detail | hint | sql_error_code
------------------------------------- -------------------------------------+--------+------+----------------
schema "nonexistent" does not exist schema "nonexistent" does not exist | | | 3F000
(1 row) (1 row)
SELECT pg_input_error_message('ng_catalog.||/', 'regoper'); SELECT * FROM pg_input_error_info('ng_catalog.||/', 'regoper');
pg_input_error_message message | detail | hint | sql_error_code
----------------------------------------- -----------------------------------------+--------+------+----------------
operator does not exist: ng_catalog.||/ operator does not exist: ng_catalog.||/ | | | 42883
(1 row) (1 row)
SELECT pg_input_error_message('-', 'regoper'); SELECT * FROM pg_input_error_info('-', 'regoper');
pg_input_error_message message | detail | hint | sql_error_code
-------------------------------- --------------------------------+--------+------+----------------
more than one operator named - more than one operator named - | | | 42725
(1 row) (1 row)
SELECT pg_input_error_message('ng_catalog.+(int4,int4)', 'regoperator'); SELECT * FROM pg_input_error_info('ng_catalog.+(int4,int4)', 'regoperator');
pg_input_error_message message | detail | hint | sql_error_code
-------------------------------------------------- --------------------------------------------------+--------+------+----------------
operator does not exist: ng_catalog.+(int4,int4) operator does not exist: ng_catalog.+(int4,int4) | | | 42883
(1 row) (1 row)
SELECT pg_input_error_message('-', 'regoperator'); SELECT * FROM pg_input_error_info('-', 'regoperator');
pg_input_error_message message | detail | hint | sql_error_code
----------------------------- -----------------------------+--------+------+----------------
expected a left parenthesis expected a left parenthesis | | | 22P02
(1 row) (1 row)
SELECT pg_input_error_message('ng_catalog.now', 'regproc'); SELECT * FROM pg_input_error_info('ng_catalog.now', 'regproc');
pg_input_error_message message | detail | hint | sql_error_code
------------------------------------------ ------------------------------------------+--------+------+----------------
function "ng_catalog.now" does not exist function "ng_catalog.now" does not exist | | | 42883
(1 row) (1 row)
SELECT pg_input_error_message('ng_catalog.abs(numeric)', 'regprocedure'); SELECT * FROM pg_input_error_info('ng_catalog.abs(numeric)', 'regprocedure');
pg_input_error_message message | detail | hint | sql_error_code
--------------------------------------------------- ---------------------------------------------------+--------+------+----------------
function "ng_catalog.abs(numeric)" does not exist function "ng_catalog.abs(numeric)" does not exist | | | 42883
(1 row) (1 row)
SELECT pg_input_error_message('ng_catalog.abs(numeric', 'regprocedure'); SELECT * FROM pg_input_error_info('ng_catalog.abs(numeric', 'regprocedure');
pg_input_error_message message | detail | hint | sql_error_code
------------------------------ ------------------------------+--------+------+----------------
expected a right parenthesis expected a right parenthesis | | | 22P02
(1 row) (1 row)
SELECT pg_input_error_message('regress_regrole_test', 'regrole'); SELECT * FROM pg_input_error_info('regress_regrole_test', 'regrole');
pg_input_error_message message | detail | hint | sql_error_code
-------------------------------------------- --------------------------------------------+--------+------+----------------
role "regress_regrole_test" does not exist role "regress_regrole_test" does not exist | | | 42704
(1 row) (1 row)
SELECT pg_input_error_message('no_such_type', 'regtype'); SELECT * FROM pg_input_error_info('no_such_type', 'regtype');
pg_input_error_message message | detail | hint | sql_error_code
------------------------------------ ------------------------------------+--------+------+----------------
type "no_such_type" does not exist type "no_such_type" does not exist | | | 42704
(1 row) (1 row)
-- Some cases that should be soft errors, but are not yet -- Some cases that should be soft errors, but are not yet
SELECT pg_input_error_message('incorrect type name syntax', 'regtype'); SELECT * FROM pg_input_error_info('incorrect type name syntax', 'regtype');
ERROR: syntax error at or near "type" ERROR: syntax error at or near "type"
LINE 1: SELECT pg_input_error_message('incorrect type name syntax', ... LINE 1: SELECT * FROM pg_input_error_info('incorrect type name synta...
^ ^
CONTEXT: invalid type name "incorrect type name syntax" CONTEXT: invalid type name "incorrect type name syntax"
SELECT pg_input_error_message('numeric(1,2,3)', 'regtype'); -- bogus typmod SELECT * FROM pg_input_error_info('numeric(1,2,3)', 'regtype'); -- bogus typmod
ERROR: invalid NUMERIC type modifier ERROR: invalid NUMERIC type modifier
SELECT pg_input_error_message('way.too.many.names', 'regtype'); SELECT * FROM pg_input_error_info('way.too.many.names', 'regtype');
ERROR: improper qualified name (too many dotted names): way.too.many.names ERROR: improper qualified name (too many dotted names): way.too.many.names
SELECT pg_input_error_message('no_such_catalog.schema.name', 'regtype'); SELECT * FROM pg_input_error_info('no_such_catalog.schema.name', 'regtype');
ERROR: cross-database references are not implemented: no_such_catalog.schema.name ERROR: cross-database references are not implemented: no_such_catalog.schema.name

View File

@ -88,16 +88,16 @@ SELECT pg_input_is_valid('(1,zed)', 'complex');
f f
(1 row) (1 row)
SELECT pg_input_error_message('(1,zed)', 'complex'); SELECT * FROM pg_input_error_info('(1,zed)', 'complex');
pg_input_error_message message | detail | hint | sql_error_code
------------------------------------------------------- -------------------------------------------------------+--------+------+----------------
invalid input syntax for type double precision: "zed" invalid input syntax for type double precision: "zed" | | | 22P02
(1 row) (1 row)
SELECT pg_input_error_message('(1,1e400)', 'complex'); SELECT * FROM pg_input_error_info('(1,1e400)', 'complex');
pg_input_error_message message | detail | hint | sql_error_code
--------------------------------------------------- ---------------------------------------------------+--------+------+----------------
"1e400" is out of range for type double precision "1e400" is out of range for type double precision | | | 22003
(1 row) (1 row)
create temp table quadtable(f1 int, q quad); create temp table quadtable(f1 int, q quad);

View File

@ -280,22 +280,22 @@ SELECT pg_input_is_valid(E'\\xDeAdBeE', 'bytea');
f f
(1 row) (1 row)
SELECT pg_input_error_message(E'\\xDeAdBeE', 'bytea'); SELECT * FROM pg_input_error_info(E'\\xDeAdBeE', 'bytea');
pg_input_error_message message | detail | hint | sql_error_code
------------------------------------------------ ------------------------------------------------+--------+------+----------------
invalid hexadecimal data: odd number of digits invalid hexadecimal data: odd number of digits | | | 22023
(1 row) (1 row)
SELECT pg_input_error_message(E'\\xDeAdBeEx', 'bytea'); SELECT * FROM pg_input_error_info(E'\\xDeAdBeEx', 'bytea');
pg_input_error_message message | detail | hint | sql_error_code
-------------------------------- --------------------------------+--------+------+----------------
invalid hexadecimal digit: "x" invalid hexadecimal digit: "x" | | | 22023
(1 row) (1 row)
SELECT pg_input_error_message(E'foo\\99bar', 'bytea'); SELECT * FROM pg_input_error_info(E'foo\\99bar', 'bytea');
pg_input_error_message message | detail | hint | sql_error_code
------------------------------------- -------------------------------------+--------+------+----------------
invalid input syntax for type bytea invalid input syntax for type bytea | | | 22P02
(1 row) (1 row)
-- --

View File

@ -24,10 +24,10 @@ SELECT pg_input_is_valid('(0)', 'tid');
f f
(1 row) (1 row)
SELECT pg_input_error_message('(0)', 'tid'); SELECT * FROM pg_input_error_info('(0)', 'tid');
pg_input_error_message message | detail | hint | sql_error_code
------------------------------------------ ------------------------------------------+--------+------+----------------
invalid input syntax for type tid: "(0)" invalid input syntax for type tid: "(0)" | | | 22P02
(1 row) (1 row)
SELECT pg_input_is_valid('(0,-1)', 'tid'); SELECT pg_input_is_valid('(0,-1)', 'tid');
@ -36,10 +36,10 @@ SELECT pg_input_is_valid('(0,-1)', 'tid');
f f
(1 row) (1 row)
SELECT pg_input_error_message('(0,-1)', 'tid'); SELECT * FROM pg_input_error_info('(0,-1)', 'tid');
pg_input_error_message message | detail | hint | sql_error_code
--------------------------------------------- ---------------------------------------------+--------+------+----------------
invalid input syntax for type tid: "(0,-1)" invalid input syntax for type tid: "(0,-1)" | | | 22P02
(1 row) (1 row)
-- tests for functions related to TID handling -- tests for functions related to TID handling

View File

@ -133,16 +133,16 @@ SELECT pg_input_is_valid('15:36:39 America/New_York', 'time');
f f
(1 row) (1 row)
SELECT pg_input_error_message('25:00:00', 'time'); SELECT * FROM pg_input_error_info('25:00:00', 'time');
pg_input_error_message message | detail | hint | sql_error_code
------------------------------------------------ ------------------------------------------------+--------+------+----------------
date/time field value out of range: "25:00:00" date/time field value out of range: "25:00:00" | | | 22008
(1 row) (1 row)
SELECT pg_input_error_message('15:36:39 America/New_York', 'time'); SELECT * FROM pg_input_error_info('15:36:39 America/New_York', 'time');
pg_input_error_message message | detail | hint | sql_error_code
----------------------------------------------------------------- -----------------------------------------------------------------+--------+------+----------------
invalid input syntax for type time: "15:36:39 America/New_York" invalid input syntax for type time: "15:36:39 America/New_York" | | | 22007
(1 row) (1 row)
-- --

View File

@ -144,16 +144,16 @@ SELECT pg_input_is_valid('2001-01-01 00:00 Nehwon/Lankhmar', 'timestamp');
f f
(1 row) (1 row)
SELECT pg_input_error_message('garbage', 'timestamp'); SELECT * FROM pg_input_error_info('garbage', 'timestamp');
pg_input_error_message message | detail | hint | sql_error_code
---------------------------------------------------- ----------------------------------------------------+--------+------+----------------
invalid input syntax for type timestamp: "garbage" invalid input syntax for type timestamp: "garbage" | | | 22007
(1 row) (1 row)
SELECT pg_input_error_message('2001-01-01 00:00 Nehwon/Lankhmar', 'timestamp'); SELECT * FROM pg_input_error_info('2001-01-01 00:00 Nehwon/Lankhmar', 'timestamp');
pg_input_error_message message | detail | hint | sql_error_code
-------------------------------------------- --------------------------------------------+--------+------+----------------
time zone "nehwon/lankhmar" not recognized time zone "nehwon/lankhmar" not recognized | | | 22023
(1 row) (1 row)
-- Check date conversion and date arithmetic -- Check date conversion and date arithmetic

View File

@ -195,16 +195,16 @@ SELECT pg_input_is_valid('2001-01-01 00:00 Nehwon/Lankhmar', 'timestamptz');
f f
(1 row) (1 row)
SELECT pg_input_error_message('garbage', 'timestamptz'); SELECT * FROM pg_input_error_info('garbage', 'timestamptz');
pg_input_error_message message | detail | hint | sql_error_code
------------------------------------------------------------------- -------------------------------------------------------------------+--------+------+----------------
invalid input syntax for type timestamp with time zone: "garbage" invalid input syntax for type timestamp with time zone: "garbage" | | | 22007
(1 row) (1 row)
SELECT pg_input_error_message('2001-01-01 00:00 Nehwon/Lankhmar', 'timestamptz'); SELECT * FROM pg_input_error_info('2001-01-01 00:00 Nehwon/Lankhmar', 'timestamptz');
pg_input_error_message message | detail | hint | sql_error_code
-------------------------------------------- --------------------------------------------+--------+------+----------------
time zone "nehwon/lankhmar" not recognized time zone "nehwon/lankhmar" not recognized | | | 22023
(1 row) (1 row)
-- Check date conversion and date arithmetic -- Check date conversion and date arithmetic

View File

@ -150,16 +150,16 @@ SELECT pg_input_is_valid('15:36:39 America/New_York', 'timetz');
f f
(1 row) (1 row)
SELECT pg_input_error_message('25:00:00 PDT', 'timetz'); SELECT * FROM pg_input_error_info('25:00:00 PDT', 'timetz');
pg_input_error_message message | detail | hint | sql_error_code
---------------------------------------------------- ----------------------------------------------------+--------+------+----------------
date/time field value out of range: "25:00:00 PDT" date/time field value out of range: "25:00:00 PDT" | | | 22008
(1 row) (1 row)
SELECT pg_input_error_message('15:36:39 America/New_York', 'timetz'); SELECT * FROM pg_input_error_info('15:36:39 America/New_York', 'timetz');
pg_input_error_message message | detail | hint | sql_error_code
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------+--------+------+----------------
invalid input syntax for type time with time zone: "15:36:39 America/New_York" invalid input syntax for type time with time zone: "15:36:39 America/New_York" | | | 22007
(1 row) (1 row)
-- --

View File

@ -102,10 +102,10 @@ SELECT pg_input_is_valid($$''$$, 'tsvector');
f f
(1 row) (1 row)
SELECT pg_input_error_message($$''$$, 'tsvector'); SELECT * FROM pg_input_error_info($$''$$, 'tsvector');
pg_input_error_message message | detail | hint | sql_error_code
-------------------------------- --------------------------------+--------+------+----------------
syntax error in tsvector: "''" syntax error in tsvector: "''" | | | 42601
(1 row) (1 row)
--Base tsquery test --Base tsquery test
@ -404,16 +404,16 @@ SELECT pg_input_is_valid('foo!', 'tsquery');
f f
(1 row) (1 row)
SELECT pg_input_error_message('foo!', 'tsquery'); SELECT * FROM pg_input_error_info('foo!', 'tsquery');
pg_input_error_message message | detail | hint | sql_error_code
--------------------------------- ---------------------------------+--------+------+----------------
syntax error in tsquery: "foo!" syntax error in tsquery: "foo!" | | | 42601
(1 row) (1 row)
SELECT pg_input_error_message('a <100000> b', 'tsquery'); SELECT * FROM pg_input_error_info('a <100000> b', 'tsquery');
pg_input_error_message message | detail | hint | sql_error_code
--------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------+--------+------+----------------
distance in phrase operator must be an integer value between zero and 16384 inclusive distance in phrase operator must be an integer value between zero and 16384 inclusive | | | 22023
(1 row) (1 row)
--comparisons --comparisons

View File

@ -46,10 +46,10 @@ SELECT pg_input_is_valid('11', 'uuid');
f f
(1 row) (1 row)
SELECT pg_input_error_message('11', 'uuid'); SELECT * FROM pg_input_error_info('11', 'uuid');
pg_input_error_message message | detail | hint | sql_error_code
------------------------------------------ ------------------------------------------+--------+------+----------------
invalid input syntax for type uuid: "11" invalid input syntax for type uuid: "11" | | | 22P02
(1 row) (1 row)
--inserting three input formats --inserting three input formats

View File

@ -124,9 +124,9 @@ SELECT pg_input_is_valid('abcde', 'varchar(4)');
f f
(1 row) (1 row)
SELECT pg_input_error_message('abcde', 'varchar(4)'); SELECT * FROM pg_input_error_info('abcde', 'varchar(4)');
pg_input_error_message message | detail | hint | sql_error_code
---------------------------------------------- ----------------------------------------------+--------+------+----------------
value too long for type character varying(4) value too long for type character varying(4) | | | 22001
(1 row) (1 row)

View File

@ -124,9 +124,9 @@ SELECT pg_input_is_valid('abcde', 'varchar(4)');
f f
(1 row) (1 row)
SELECT pg_input_error_message('abcde', 'varchar(4)'); SELECT * FROM pg_input_error_info('abcde', 'varchar(4)');
pg_input_error_message message | detail | hint | sql_error_code
---------------------------------------------- ----------------------------------------------+--------+------+----------------
value too long for type character varying(4) value too long for type character varying(4) | | | 22001
(1 row) (1 row)

View File

@ -124,9 +124,9 @@ SELECT pg_input_is_valid('abcde', 'varchar(4)');
f f
(1 row) (1 row)
SELECT pg_input_error_message('abcde', 'varchar(4)'); SELECT * FROM pg_input_error_info('abcde', 'varchar(4)');
pg_input_error_message message | detail | hint | sql_error_code
---------------------------------------------- ----------------------------------------------+--------+------+----------------
value too long for type character varying(4) value too long for type character varying(4) | | | 22001
(1 row) (1 row)

View File

@ -43,10 +43,10 @@ SELECT pg_input_is_valid('asdf', 'xid');
f f
(1 row) (1 row)
SELECT pg_input_error_message('0xffffffffff', 'xid'); SELECT * FROM pg_input_error_info('0xffffffffff', 'xid');
pg_input_error_message message | detail | hint | sql_error_code
--------------------------------------------------- ---------------------------------------------------+--------+------+----------------
value "0xffffffffff" is out of range for type xid value "0xffffffffff" is out of range for type xid | | | 22003
(1 row) (1 row)
SELECT pg_input_is_valid('42', 'xid8'); SELECT pg_input_is_valid('42', 'xid8');
@ -61,10 +61,10 @@ SELECT pg_input_is_valid('asdf', 'xid8');
f f
(1 row) (1 row)
SELECT pg_input_error_message('0xffffffffffffffffffff', 'xid8'); SELECT * FROM pg_input_error_info('0xffffffffffffffffffff', 'xid8');
pg_input_error_message message | detail | hint | sql_error_code
-------------------------------------------------------------- --------------------------------------------------------------+--------+------+----------------
value "0xffffffffffffffffffff" is out of range for type xid8 value "0xffffffffffffffffffff" is out of range for type xid8 | | | 22003
(1 row) (1 row)
-- equality -- equality
@ -223,10 +223,10 @@ select pg_input_is_valid('31:12:', 'pg_snapshot');
f f
(1 row) (1 row)
select pg_input_error_message('31:12:', 'pg_snapshot'); select * from pg_input_error_info('31:12:', 'pg_snapshot');
pg_input_error_message message | detail | hint | sql_error_code
----------------------------------------------------- -----------------------------------------------------+--------+------+----------------
invalid input syntax for type pg_snapshot: "31:12:" invalid input syntax for type pg_snapshot: "31:12:" | | | 22P02
(1 row) (1 row)
select pg_input_is_valid('12:16:14,13', 'pg_snapshot'); select pg_input_is_valid('12:16:14,13', 'pg_snapshot');
@ -235,10 +235,10 @@ select pg_input_is_valid('12:16:14,13', 'pg_snapshot');
f f
(1 row) (1 row)
select pg_input_error_message('12:16:14,13', 'pg_snapshot'); select * from pg_input_error_info('12:16:14,13', 'pg_snapshot');
pg_input_error_message message | detail | hint | sql_error_code
---------------------------------------------------------- ----------------------------------------------------------+--------+------+----------------
invalid input syntax for type pg_snapshot: "12:16:14,13" invalid input syntax for type pg_snapshot: "12:16:14,13" | | | 22P02
(1 row) (1 row)
create temp table snapshot_test ( create temp table snapshot_test (

View File

@ -31,9 +31,9 @@ SELECT pg_input_is_valid('<value>one</', 'xml');
f f
(1 row) (1 row)
SELECT pg_input_error_message('<value>one</', 'xml'); SELECT message FROM pg_input_error_info('<value>one</', 'xml');
pg_input_error_message message
------------------------ ---------------------
invalid XML content invalid XML content
(1 row) (1 row)
@ -43,8 +43,8 @@ SELECT pg_input_is_valid('<?xml version="1.0" standalone="y"?><foo/>', 'xml');
f f
(1 row) (1 row)
SELECT pg_input_error_message('<?xml version="1.0" standalone="y"?><foo/>', 'xml'); SELECT message FROM pg_input_error_info('<?xml version="1.0" standalone="y"?><foo/>', 'xml');
pg_input_error_message message
---------------------------------------------- ----------------------------------------------
invalid XML content: invalid XML declaration invalid XML content: invalid XML declaration
(1 row) (1 row)

View File

@ -29,13 +29,13 @@ DETAIL: This functionality requires the server to be built with libxml support.
SELECT pg_input_is_valid('<value>one</', 'xml'); SELECT pg_input_is_valid('<value>one</', 'xml');
ERROR: unsupported XML feature ERROR: unsupported XML feature
DETAIL: This functionality requires the server to be built with libxml support. DETAIL: This functionality requires the server to be built with libxml support.
SELECT pg_input_error_message('<value>one</', 'xml'); SELECT message FROM pg_input_error_info('<value>one</', 'xml');
ERROR: unsupported XML feature ERROR: unsupported XML feature
DETAIL: This functionality requires the server to be built with libxml support. DETAIL: This functionality requires the server to be built with libxml support.
SELECT pg_input_is_valid('<?xml version="1.0" standalone="y"?><foo/>', 'xml'); SELECT pg_input_is_valid('<?xml version="1.0" standalone="y"?><foo/>', 'xml');
ERROR: unsupported XML feature ERROR: unsupported XML feature
DETAIL: This functionality requires the server to be built with libxml support. DETAIL: This functionality requires the server to be built with libxml support.
SELECT pg_input_error_message('<?xml version="1.0" standalone="y"?><foo/>', 'xml'); SELECT message FROM pg_input_error_info('<?xml version="1.0" standalone="y"?><foo/>', 'xml');
ERROR: unsupported XML feature ERROR: unsupported XML feature
DETAIL: This functionality requires the server to be built with libxml support. DETAIL: This functionality requires the server to be built with libxml support.
SELECT xmlcomment('test'); SELECT xmlcomment('test');

View File

@ -29,8 +29,8 @@ SELECT pg_input_is_valid('<value>one</', 'xml');
f f
(1 row) (1 row)
SELECT pg_input_error_message('<value>one</', 'xml'); SELECT message FROM pg_input_error_info('<value>one</', 'xml');
pg_input_error_message message
------------------------ ------------------------
invalid XML content invalid XML content
(1 row) (1 row)
@ -41,8 +41,8 @@ SELECT pg_input_is_valid('<?xml version="1.0" standalone="y"?><foo/>', 'xml');
f f
(1 row) (1 row)
SELECT pg_input_error_message('<?xml version="1.0" standalone="y"?><foo/>', 'xml'); SELECT message FROM pg_input_error_info('<?xml version="1.0" standalone="y"?><foo/>', 'xml');
pg_input_error_message message
---------------------------------------------- ----------------------------------------------
invalid XML content: invalid XML declaration invalid XML content: invalid XML declaration
(1 row) (1 row)

View File

@ -117,7 +117,7 @@ SELECT a,b,c FROM arrtest;
SELECT pg_input_is_valid('{1,2,3}', 'integer[]'); SELECT pg_input_is_valid('{1,2,3}', 'integer[]');
SELECT pg_input_is_valid('{1,2', 'integer[]'); SELECT pg_input_is_valid('{1,2', 'integer[]');
SELECT pg_input_is_valid('{1,zed}', 'integer[]'); SELECT pg_input_is_valid('{1,zed}', 'integer[]');
SELECT pg_input_error_message('{1,zed}', 'integer[]'); SELECT * FROM pg_input_error_info('{1,zed}', 'integer[]');
-- test mixed slice/scalar subscripting -- test mixed slice/scalar subscripting
select '{{1,2,3},{4,5,6},{7,8,9}}'::int[]; select '{{1,2,3},{4,5,6},{7,8,9}}'::int[];

View File

@ -232,13 +232,13 @@ TABLE bit_defaults;
-- test non-error-throwing API for some core types -- test non-error-throwing API for some core types
SELECT pg_input_is_valid('01010001', 'bit(10)'); SELECT pg_input_is_valid('01010001', 'bit(10)');
SELECT pg_input_error_message('01010001', 'bit(10)'); SELECT * FROM pg_input_error_info('01010001', 'bit(10)');
SELECT pg_input_is_valid('01010Z01', 'bit(8)'); SELECT pg_input_is_valid('01010Z01', 'bit(8)');
SELECT pg_input_error_message('01010Z01', 'bit(8)'); SELECT * FROM pg_input_error_info('01010Z01', 'bit(8)');
SELECT pg_input_is_valid('x01010Z01', 'bit(32)'); SELECT pg_input_is_valid('x01010Z01', 'bit(32)');
SELECT pg_input_error_message('x01010Z01', 'bit(32)'); SELECT * FROM pg_input_error_info('x01010Z01', 'bit(32)');
SELECT pg_input_is_valid('01010Z01', 'varbit'); SELECT pg_input_is_valid('01010Z01', 'varbit');
SELECT pg_input_error_message('01010Z01', 'varbit'); SELECT * FROM pg_input_error_info('01010Z01', 'varbit');
SELECT pg_input_is_valid('x01010Z01', 'varbit'); SELECT pg_input_is_valid('x01010Z01', 'varbit');
SELECT pg_input_error_message('x01010Z01', 'varbit'); SELECT * FROM pg_input_error_info('x01010Z01', 'varbit');

View File

@ -65,7 +65,7 @@ SELECT bool '' AS error;
-- Also try it with non-error-throwing API -- Also try it with non-error-throwing API
SELECT pg_input_is_valid('true', 'bool'); SELECT pg_input_is_valid('true', 'bool');
SELECT pg_input_is_valid('asdf', 'bool'); SELECT pg_input_is_valid('asdf', 'bool');
SELECT pg_input_error_message('junk', 'bool'); SELECT * FROM pg_input_error_info('junk', 'bool');
-- and, or, not in qualifications -- and, or, not in qualifications

View File

@ -284,6 +284,6 @@ RESET enable_bitmapscan;
-- test non-error-throwing API for some core types -- test non-error-throwing API for some core types
SELECT pg_input_is_valid('200', 'box'); SELECT pg_input_is_valid('200', 'box');
SELECT pg_input_error_message('200', 'box'); SELECT * FROM pg_input_error_info('200', 'box');
SELECT pg_input_is_valid('((200,300),(500, xyz))', 'box'); SELECT pg_input_is_valid('((200,300),(500, xyz))', 'box');
SELECT pg_input_error_message('((200,300),(500, xyz))', 'box'); SELECT * FROM pg_input_error_info('((200,300),(500, xyz))', 'box');

View File

@ -75,7 +75,7 @@ SELECT * FROM CHAR_TBL;
-- Also try it with non-error-throwing API -- Also try it with non-error-throwing API
SELECT pg_input_is_valid('abcd ', 'char(4)'); SELECT pg_input_is_valid('abcd ', 'char(4)');
SELECT pg_input_is_valid('abcde', 'char(4)'); SELECT pg_input_is_valid('abcde', 'char(4)');
SELECT pg_input_error_message('abcde', 'char(4)'); SELECT * FROM pg_input_error_info('abcde', 'char(4)');
-- --
-- Also test "char", which is an ad-hoc one-byte type. It can only -- Also test "char", which is an ad-hoc one-byte type. It can only

View File

@ -197,8 +197,8 @@ SELECT date '5874898-01-01'; -- out of range
SELECT pg_input_is_valid('now', 'date'); SELECT pg_input_is_valid('now', 'date');
SELECT pg_input_is_valid('garbage', 'date'); SELECT pg_input_is_valid('garbage', 'date');
SELECT pg_input_is_valid('6874898-01-01', 'date'); SELECT pg_input_is_valid('6874898-01-01', 'date');
SELECT pg_input_error_message('garbage', 'date'); SELECT * FROM pg_input_error_info('garbage', 'date');
SELECT pg_input_error_message('6874898-01-01', 'date'); SELECT * FROM pg_input_error_info('6874898-01-01', 'date');
RESET datestyle; RESET datestyle;

View File

@ -77,12 +77,12 @@ create domain weirdfloat float8 check((1 / value) < 10);
select pg_input_is_valid('1', 'positiveint'); select pg_input_is_valid('1', 'positiveint');
select pg_input_is_valid('junk', 'positiveint'); select pg_input_is_valid('junk', 'positiveint');
select pg_input_is_valid('-1', 'positiveint'); select pg_input_is_valid('-1', 'positiveint');
select pg_input_error_message('junk', 'positiveint'); select * from pg_input_error_info('junk', 'positiveint');
select pg_input_error_message('-1', 'positiveint'); select * from pg_input_error_info('-1', 'positiveint');
select pg_input_error_message('junk', 'weirdfloat'); select * from pg_input_error_info('junk', 'weirdfloat');
select pg_input_error_message('0.01', 'weirdfloat'); select * from pg_input_error_info('0.01', 'weirdfloat');
-- We currently can't trap errors raised in the CHECK expression itself -- We currently can't trap errors raised in the CHECK expression itself
select pg_input_error_message('0', 'weirdfloat'); select * from pg_input_error_info('0', 'weirdfloat');
drop domain positiveint; drop domain positiveint;
drop domain weirdfloat; drop domain weirdfloat;

View File

@ -18,8 +18,10 @@ SELECT 'mauve'::rainbow;
-- Also try it with non-error-throwing API -- Also try it with non-error-throwing API
SELECT pg_input_is_valid('red', 'rainbow'); SELECT pg_input_is_valid('red', 'rainbow');
SELECT pg_input_is_valid('mauve', 'rainbow'); SELECT pg_input_is_valid('mauve', 'rainbow');
SELECT pg_input_error_message('mauve', 'rainbow'); SELECT * FROM pg_input_error_info('mauve', 'rainbow');
SELECT pg_input_error_message(repeat('too_long', 32), 'rainbow'); \x
SELECT * FROM pg_input_error_info(repeat('too_long', 32), 'rainbow');
\x
-- --
-- adding new values -- adding new values

View File

@ -40,7 +40,7 @@ INSERT INTO FLOAT4_TBL(f1) VALUES ('123 5');
SELECT pg_input_is_valid('34.5', 'float4'); SELECT pg_input_is_valid('34.5', 'float4');
SELECT pg_input_is_valid('xyz', 'float4'); SELECT pg_input_is_valid('xyz', 'float4');
SELECT pg_input_is_valid('1e400', 'float4'); SELECT pg_input_is_valid('1e400', 'float4');
SELECT pg_input_error_message('1e400', 'float4'); SELECT * FROM pg_input_error_info('1e400', 'float4');
-- special inputs -- special inputs
SELECT 'NaN'::float4; SELECT 'NaN'::float4;

View File

@ -38,7 +38,7 @@ INSERT INTO FLOAT8_TBL(f1) VALUES ('123 5');
SELECT pg_input_is_valid('34.5', 'float8'); SELECT pg_input_is_valid('34.5', 'float8');
SELECT pg_input_is_valid('xyz', 'float8'); SELECT pg_input_is_valid('xyz', 'float8');
SELECT pg_input_is_valid('1e4000', 'float8'); SELECT pg_input_is_valid('1e4000', 'float8');
SELECT pg_input_error_message('1e4000', 'float8'); SELECT * FROM pg_input_error_info('1e4000', 'float8');
-- special inputs -- special inputs
SELECT 'NaN'::float8; SELECT 'NaN'::float8;

View File

@ -526,6 +526,6 @@ SELECT * FROM polygon_tbl WHERE f1 @> '((1,1),(2,2),(2,1))'::polygon
-- test non-error-throwing API for some core types -- test non-error-throwing API for some core types
SELECT pg_input_is_valid('(1', 'circle'); SELECT pg_input_is_valid('(1', 'circle');
SELECT pg_input_error_message('1,', 'circle'); SELECT * FROM pg_input_error_info('1,', 'circle');
SELECT pg_input_is_valid('(1,2),-1', 'circle'); SELECT pg_input_is_valid('(1,2),-1', 'circle');
SELECT pg_input_error_message('(1,2),-1', 'circle'); SELECT * FROM pg_input_error_info('(1,2),-1', 'circle');

View File

@ -255,9 +255,9 @@ SELECT a FROM (VALUES
-- test non-error-throwing API for some core types -- test non-error-throwing API for some core types
SELECT pg_input_is_valid('1234', 'cidr'); SELECT pg_input_is_valid('1234', 'cidr');
SELECT pg_input_error_message('1234', 'cidr'); SELECT * FROM pg_input_error_info('1234', 'cidr');
SELECT pg_input_is_valid('192.168.198.200/24', 'cidr'); SELECT pg_input_is_valid('192.168.198.200/24', 'cidr');
SELECT pg_input_error_message('192.168.198.200/24', 'cidr'); SELECT * FROM pg_input_error_info('192.168.198.200/24', 'cidr');
SELECT pg_input_is_valid('1234', 'inet'); SELECT pg_input_is_valid('1234', 'inet');
SELECT pg_input_error_message('1234', 'inet'); SELECT * FROM pg_input_error_info('1234', 'inet');

View File

@ -21,12 +21,12 @@ SELECT * FROM INT2_TBL;
SELECT pg_input_is_valid('34', 'int2'); SELECT pg_input_is_valid('34', 'int2');
SELECT pg_input_is_valid('asdf', 'int2'); SELECT pg_input_is_valid('asdf', 'int2');
SELECT pg_input_is_valid('50000', 'int2'); SELECT pg_input_is_valid('50000', 'int2');
SELECT pg_input_error_message('50000', 'int2'); SELECT * FROM pg_input_error_info('50000', 'int2');
-- While we're here, check int2vector as well -- While we're here, check int2vector as well
SELECT pg_input_is_valid(' 1 3 5 ', 'int2vector'); SELECT pg_input_is_valid(' 1 3 5 ', 'int2vector');
SELECT pg_input_error_message('1 asdf', 'int2vector'); SELECT * FROM pg_input_error_info('1 asdf', 'int2vector');
SELECT pg_input_error_message('50000', 'int2vector'); SELECT * FROM pg_input_error_info('50000', 'int2vector');
SELECT * FROM INT2_TBL AS f(a, b); SELECT * FROM INT2_TBL AS f(a, b);

View File

@ -21,7 +21,7 @@ SELECT * FROM INT4_TBL;
SELECT pg_input_is_valid('34', 'int4'); SELECT pg_input_is_valid('34', 'int4');
SELECT pg_input_is_valid('asdf', 'int4'); SELECT pg_input_is_valid('asdf', 'int4');
SELECT pg_input_is_valid('1000000000000', 'int4'); SELECT pg_input_is_valid('1000000000000', 'int4');
SELECT pg_input_error_message('1000000000000', 'int4'); SELECT * FROM pg_input_error_info('1000000000000', 'int4');
SELECT i.* FROM INT4_TBL i WHERE i.f1 <> int2 '0'; SELECT i.* FROM INT4_TBL i WHERE i.f1 <> int2 '0';

View File

@ -20,7 +20,7 @@ SELECT * FROM INT8_TBL;
SELECT pg_input_is_valid('34', 'int8'); SELECT pg_input_is_valid('34', 'int8');
SELECT pg_input_is_valid('asdf', 'int8'); SELECT pg_input_is_valid('asdf', 'int8');
SELECT pg_input_is_valid('10000000000000000000', 'int8'); SELECT pg_input_is_valid('10000000000000000000', 'int8');
SELECT pg_input_error_message('10000000000000000000', 'int8'); SELECT * FROM pg_input_error_info('10000000000000000000', 'int8');
-- int8/int8 cmp -- int8/int8 cmp
SELECT * FROM INT8_TBL WHERE q2 = 4567890123456789; SELECT * FROM INT8_TBL WHERE q2 = 4567890123456789;

View File

@ -36,8 +36,8 @@ INSERT INTO INTERVAL_TBL (f1) VALUES ('@ 30 eons ago');
SELECT pg_input_is_valid('1.5 weeks', 'interval'); SELECT pg_input_is_valid('1.5 weeks', 'interval');
SELECT pg_input_is_valid('garbage', 'interval'); SELECT pg_input_is_valid('garbage', 'interval');
SELECT pg_input_is_valid('@ 30 eons ago', 'interval'); SELECT pg_input_is_valid('@ 30 eons ago', 'interval');
SELECT pg_input_error_message('garbage', 'interval'); SELECT * FROM pg_input_error_info('garbage', 'interval');
SELECT pg_input_error_message('@ 30 eons ago', 'interval'); SELECT * FROM pg_input_error_info('@ 30 eons ago', 'interval');
-- test interval operators -- test interval operators

View File

@ -84,7 +84,7 @@ SELECT '{
-- test non-error-throwing input -- test non-error-throwing input
select pg_input_is_valid('{"a":true}', 'json'); select pg_input_is_valid('{"a":true}', 'json');
select pg_input_is_valid('{"a":true', 'json'); select pg_input_is_valid('{"a":true', 'json');
select pg_input_error_message('{"a":true', 'json'); select * from pg_input_error_info('{"a":true', 'json');
--constructors --constructors
-- array_to_json -- array_to_json

View File

@ -79,4 +79,4 @@ SELECT jsonb '{ "a": "null \\u0000 escape" }' ->> 'a' as not_an_escape;
-- soft error for input-time failure -- soft error for input-time failure
select pg_input_error_message('{ "a": "\ud83d\ude04\ud83d\udc36" }', 'jsonb'); select * from pg_input_error_info('{ "a": "\ud83d\ude04\ud83d\udc36" }', 'jsonb');

View File

@ -89,8 +89,8 @@ SELECT '{
-- test non-error-throwing input -- test non-error-throwing input
select pg_input_is_valid('{"a":true}', 'jsonb'); select pg_input_is_valid('{"a":true}', 'jsonb');
select pg_input_is_valid('{"a":true', 'jsonb'); select pg_input_is_valid('{"a":true', 'jsonb');
select pg_input_error_message('{"a":true', 'jsonb'); select * from pg_input_error_info('{"a":true', 'jsonb');
select pg_input_error_message('{"a":1e1000000}', 'jsonb'); select * from pg_input_error_info('{"a":1e1000000}', 'jsonb');
-- make sure jsonb is passed through json generators without being escaped -- make sure jsonb is passed through json generators without being escaped
SELECT array_to_json(ARRAY [jsonb '{"a":1}', jsonb '{"b":[2,3]}']); SELECT array_to_json(ARRAY [jsonb '{"a":1}', jsonb '{"b":[2,3]}']);

View File

@ -192,9 +192,13 @@ select '1?(2>3)'::jsonpath;
SELECT str as jsonpath, SELECT str as jsonpath,
pg_input_is_valid(str,'jsonpath') as ok, pg_input_is_valid(str,'jsonpath') as ok,
pg_input_error_message(str,'jsonpath') as errmsg errinfo.sql_error_code,
errinfo.message,
errinfo.detail,
errinfo.hint
FROM unnest(ARRAY['$ ? (@ like_regex "pattern" flag "smixq")'::text, FROM unnest(ARRAY['$ ? (@ like_regex "pattern" flag "smixq")'::text,
'$ ? (@ like_regex "pattern" flag "a")', '$ ? (@ like_regex "pattern" flag "a")',
'@ + 1', '@ + 1',
'00', '00',
'1a']) str; '1a']) str,
LATERAL pg_input_error_info(str, 'jsonpath') as errinfo;

View File

@ -43,12 +43,12 @@ select '{nan, 1, nan}'::line = '{nan, 1, nan}'::line as true,
-- test non-error-throwing API for some core types -- test non-error-throwing API for some core types
SELECT pg_input_is_valid('{1, 1}', 'line'); SELECT pg_input_is_valid('{1, 1}', 'line');
SELECT pg_input_error_message('{1, 1}', 'line'); SELECT * FROM pg_input_error_info('{1, 1}', 'line');
SELECT pg_input_is_valid('{0, 0, 0}', 'line'); SELECT pg_input_is_valid('{0, 0, 0}', 'line');
SELECT pg_input_error_message('{0, 0, 0}', 'line'); SELECT * FROM pg_input_error_info('{0, 0, 0}', 'line');
SELECT pg_input_is_valid('{1, 1, a}', 'line'); SELECT pg_input_is_valid('{1, 1, a}', 'line');
SELECT pg_input_error_message('{1, 1, a}', 'line'); SELECT * FROM pg_input_error_info('{1, 1, a}', 'line');
SELECT pg_input_is_valid('{1, 1, 1e400}', 'line'); SELECT pg_input_is_valid('{1, 1, 1e400}', 'line');
SELECT pg_input_error_message('{1, 1, 1e400}', 'line'); SELECT * FROM pg_input_error_info('{1, 1, 1e400}', 'line');
SELECT pg_input_is_valid('(1, 1), (1, 1e400)', 'line'); SELECT pg_input_is_valid('(1, 1), (1, 1e400)', 'line');
SELECT pg_input_error_message('(1, 1), (1, 1e400)', 'line'); SELECT * FROM pg_input_error_info('(1, 1), (1, 1e400)', 'line');

View File

@ -25,4 +25,4 @@ select * from LSEG_TBL;
-- test non-error-throwing API for some core types -- test non-error-throwing API for some core types
SELECT pg_input_is_valid('[(1,2),(3)]', 'lseg'); SELECT pg_input_is_valid('[(1,2),(3)]', 'lseg');
SELECT pg_input_error_message('[(1,2),(3)]', 'lseg'); SELECT * FROM pg_input_error_info('[(1,2),(3)]', 'lseg');

View File

@ -44,6 +44,6 @@ DROP TABLE macaddr_data;
-- test non-error-throwing API for some core types -- test non-error-throwing API for some core types
SELECT pg_input_is_valid('08:00:2b:01:02:ZZ', 'macaddr'); SELECT pg_input_is_valid('08:00:2b:01:02:ZZ', 'macaddr');
SELECT pg_input_error_message('08:00:2b:01:02:ZZ', 'macaddr'); SELECT * FROM pg_input_error_info('08:00:2b:01:02:ZZ', 'macaddr');
SELECT pg_input_is_valid('08:00:2b:01:02:', 'macaddr'); SELECT pg_input_is_valid('08:00:2b:01:02:', 'macaddr');
SELECT pg_input_error_message('08:00:2b:01:02:', 'macaddr'); SELECT * FROM pg_input_error_info('08:00:2b:01:02:', 'macaddr');

View File

@ -90,6 +90,6 @@ DROP TABLE macaddr8_data;
-- test non-error-throwing API for some core types -- test non-error-throwing API for some core types
SELECT pg_input_is_valid('08:00:2b:01:02:03:04:ZZ', 'macaddr8'); SELECT pg_input_is_valid('08:00:2b:01:02:03:04:ZZ', 'macaddr8');
SELECT pg_input_error_message('08:00:2b:01:02:03:04:ZZ', 'macaddr8'); SELECT * FROM pg_input_error_info('08:00:2b:01:02:03:04:ZZ', 'macaddr8');
SELECT pg_input_is_valid('08:00:2b:01:02:03:04:', 'macaddr8'); SELECT pg_input_is_valid('08:00:2b:01:02:03:04:', 'macaddr8');
SELECT pg_input_error_message('08:00:2b:01:02:03:04:', 'macaddr8'); SELECT * FROM pg_input_error_info('08:00:2b:01:02:03:04:', 'macaddr8');

View File

@ -90,9 +90,9 @@ SELECT '($123,456.78)'::money;
-- test non-error-throwing API -- test non-error-throwing API
SELECT pg_input_is_valid('\x0001', 'money'); SELECT pg_input_is_valid('\x0001', 'money');
SELECT pg_input_error_message('\x0001', 'money'); SELECT * FROM pg_input_error_info('\x0001', 'money');
SELECT pg_input_is_valid('192233720368547758.07', 'money'); SELECT pg_input_is_valid('192233720368547758.07', 'money');
SELECT pg_input_error_message('192233720368547758.07', 'money'); SELECT * FROM pg_input_error_info('192233720368547758.07', 'money');
-- documented minimums and maximums -- documented minimums and maximums
SELECT '-92233720368547758.08'::money; SELECT '-92233720368547758.08'::money;

View File

@ -61,9 +61,9 @@ select '{(a,a)}'::textmultirange;
-- Also try it with non-error-throwing API -- Also try it with non-error-throwing API
select pg_input_is_valid('{[1,2], [4,5]}', 'int4multirange'); select pg_input_is_valid('{[1,2], [4,5]}', 'int4multirange');
select pg_input_is_valid('{[1,2], [4,5]', 'int4multirange'); select pg_input_is_valid('{[1,2], [4,5]', 'int4multirange');
select pg_input_error_message('{[1,2], [4,5]', 'int4multirange'); select * from pg_input_error_info('{[1,2], [4,5]', 'int4multirange');
select pg_input_is_valid('{[1,2], [4,zed]}', 'int4multirange'); select pg_input_is_valid('{[1,2], [4,zed]}', 'int4multirange');
select pg_input_error_message('{[1,2], [4,zed]}', 'int4multirange'); select * from pg_input_error_info('{[1,2], [4,zed]}', 'int4multirange');
-- --
-- test the constructor -- test the constructor

View File

@ -1086,11 +1086,11 @@ SELECT * FROM num_input_test;
SELECT pg_input_is_valid('34.5', 'numeric'); SELECT pg_input_is_valid('34.5', 'numeric');
SELECT pg_input_is_valid('34xyz', 'numeric'); SELECT pg_input_is_valid('34xyz', 'numeric');
SELECT pg_input_is_valid('1e400000', 'numeric'); SELECT pg_input_is_valid('1e400000', 'numeric');
SELECT pg_input_error_message('1e400000', 'numeric'); SELECT * FROM pg_input_error_info('1e400000', 'numeric');
SELECT pg_input_is_valid('1234.567', 'numeric(8,4)'); SELECT pg_input_is_valid('1234.567', 'numeric(8,4)');
SELECT pg_input_is_valid('1234.567', 'numeric(7,4)'); SELECT pg_input_is_valid('1234.567', 'numeric(7,4)');
SELECT pg_input_error_message('1234.567', 'numeric(7,4)'); SELECT * FROM pg_input_error_info('1234.567', 'numeric(7,4)');
SELECT pg_input_error_message('0x1234.567', 'numeric'); SELECT * FROM pg_input_error_info('0x1234.567', 'numeric');
-- --
-- Test precision and scale typemods -- Test precision and scale typemods

View File

@ -31,16 +31,16 @@ SELECT * FROM OID_TBL;
-- Also try it with non-error-throwing API -- Also try it with non-error-throwing API
SELECT pg_input_is_valid('1234', 'oid'); SELECT pg_input_is_valid('1234', 'oid');
SELECT pg_input_is_valid('01XYZ', 'oid'); SELECT pg_input_is_valid('01XYZ', 'oid');
SELECT pg_input_error_message('01XYZ', 'oid'); SELECT * FROM pg_input_error_info('01XYZ', 'oid');
SELECT pg_input_is_valid('9999999999', 'oid'); SELECT pg_input_is_valid('9999999999', 'oid');
SELECT pg_input_error_message('9999999999', 'oid'); SELECT * FROM pg_input_error_info('9999999999', 'oid');
-- While we're here, check oidvector as well -- While we're here, check oidvector as well
SELECT pg_input_is_valid(' 1 2 4 ', 'oidvector'); SELECT pg_input_is_valid(' 1 2 4 ', 'oidvector');
SELECT pg_input_is_valid('01 01XYZ', 'oidvector'); SELECT pg_input_is_valid('01 01XYZ', 'oidvector');
SELECT pg_input_error_message('01 01XYZ', 'oidvector'); SELECT * FROM pg_input_error_info('01 01XYZ', 'oidvector');
SELECT pg_input_is_valid('01 9999999999', 'oidvector'); SELECT pg_input_is_valid('01 9999999999', 'oidvector');
SELECT pg_input_error_message('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;

View File

@ -45,6 +45,6 @@ SELECT popen(f1) AS open_path FROM PATH_TBL;
-- test non-error-throwing API for some core types -- test non-error-throwing API for some core types
SELECT pg_input_is_valid('[(1,2),(3)]', 'path'); SELECT pg_input_is_valid('[(1,2),(3)]', 'path');
SELECT pg_input_error_message('[(1,2),(3)]', 'path'); SELECT * FROM pg_input_error_info('[(1,2),(3)]', 'path');
SELECT pg_input_is_valid('[(1,2,6),(3,4,6)]', 'path'); SELECT pg_input_is_valid('[(1,2,6),(3,4,6)]', 'path');
SELECT pg_input_error_message('[(1,2,6),(3,4,6)]', 'path'); SELECT * FROM pg_input_error_info('[(1,2,6),(3,4,6)]', 'path');

View File

@ -17,7 +17,7 @@ INSERT INTO PG_LSN_TBL VALUES ('/ABCD');
-- Also try it with non-error-throwing API -- Also try it with non-error-throwing API
SELECT pg_input_is_valid('16AE7F7', 'pg_lsn'); SELECT pg_input_is_valid('16AE7F7', 'pg_lsn');
SELECT pg_input_error_message('16AE7F7', 'pg_lsn'); SELECT * FROM pg_input_error_info('16AE7F7', 'pg_lsn');
-- Min/Max aggregation -- Min/Max aggregation
SELECT MIN(f1), MAX(f1) FROM PG_LSN_TBL; SELECT MIN(f1), MAX(f1) FROM PG_LSN_TBL;

Some files were not shown because too many files have changed in this diff Show More