1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-09 17:03:00 +03:00

Convert contrib/ltree's input functions to report errors softly

Reviewed by Tom Lane and Amul Sul

Discussion: https://postgr.es/m/49e598c2-cfe8-0928-b6fb-d0cc51aab626@dunslane.net
This commit is contained in:
Andrew Dunstan
2022-12-28 09:58:04 -05:00
parent 3b76622e04
commit 7a05425d96
4 changed files with 137 additions and 50 deletions

View File

@@ -8084,3 +8084,28 @@ SELECT count(*) FROM _ltreetest WHERE t ? '{23.*.1,23.*.2}' ;
15
(1 row)
-- test non-error-throwing input
SELECT str as "value", typ as "type",
pg_input_is_valid(str,typ) as ok,
pg_input_error_message(str,typ) as errmsg
FROM (VALUES ('.2.3', 'ltree'),
('1.2.', 'ltree'),
('1.2.3','ltree'),
('@.2.3','lquery'),
(' 2.3', 'lquery'),
('1.2.3','lquery'),
('$tree & aWdf@*','ltxtquery'),
('!tree & aWdf@*','ltxtquery'))
AS a(str,typ);
value | type | ok | errmsg
----------------+-----------+----+------------------------------------
.2.3 | ltree | f | ltree syntax error at character 1
1.2. | ltree | f | ltree syntax error
1.2.3 | ltree | t |
@.2.3 | lquery | f | lquery syntax error at character 1
2.3 | lquery | f | lquery syntax error at character 1
1.2.3 | lquery | t |
$tree & aWdf@* | ltxtquery | f | operand syntax error
!tree & aWdf@* | ltxtquery | t |
(8 rows)