1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-08 06:02:22 +03:00

Improve error messages in ltree_in and lquery_in.

Ensure that the type name is mentioned in all cases (bare "syntax error"
isn't that helpful).  Avoid using the term "level", since that's not
used in the documentation.  Phrase error position reports as "at
character N" not "in position N"; the latter seems ambiguous, and it's
certainly not how we say it elsewhere.  For the same reason, make the
character position values be 1-based not 0-based.  Provide a position
in more cases.  (I continued to leave that out of messages complaining
about end-of-input, where it seemed pointless, as well as messages
complaining about overall input complexity, where fingering any one part
of the input would be arbitrary.)

Discussion: https://postgr.es/m/15582.1585529626@sss.pgh.pa.us
This commit is contained in:
Tom Lane
2020-03-31 10:30:59 -04:00
parent 02a5786df2
commit e07e2a40bd
4 changed files with 63 additions and 52 deletions

View File

@@ -464,7 +464,7 @@ SELECT nlevel(('1' || repeat('.1', 65534))::ltree);
(1 row)
SELECT nlevel(('1' || repeat('.1', 65535))::ltree);
ERROR: number of ltree levels (65536) exceeds the maximum allowed (65535)
ERROR: number of ltree labels (65536) exceeds the maximum allowed (65535)
SELECT nlevel(('1' || repeat('.1', 65534))::ltree || '1');
ERROR: number of ltree levels (65536) exceeds the maximum allowed (65535)
SELECT ('1' || repeat('.1', 65534))::lquery IS NULL;
@@ -474,7 +474,7 @@ SELECT ('1' || repeat('.1', 65534))::lquery IS NULL;
(1 row)
SELECT ('1' || repeat('.1', 65535))::lquery IS NULL;
ERROR: number of lquery levels (65536) exceeds the maximum allowed (65535)
ERROR: number of lquery items (65536) exceeds the maximum allowed (65535)
SELECT '*{65535}'::lquery;
lquery
----------
@@ -485,7 +485,7 @@ SELECT '*{65536}'::lquery;
ERROR: lquery syntax error
LINE 1: SELECT '*{65536}'::lquery;
^
DETAIL: Low limit (65536) exceeds the maximum allowed (65535).
DETAIL: Low limit (65536) exceeds the maximum allowed (65535), at character 3.
SELECT '*{,65534}'::lquery;
lquery
-----------
@@ -502,7 +502,12 @@ SELECT '*{,65536}'::lquery;
ERROR: lquery syntax error
LINE 1: SELECT '*{,65536}'::lquery;
^
DETAIL: High limit (65536) exceeds the maximum allowed (65535).
DETAIL: High limit (65536) exceeds the maximum allowed (65535), at character 4.
SELECT '*{4,3}'::lquery;
ERROR: lquery syntax error
LINE 1: SELECT '*{4,3}'::lquery;
^
DETAIL: Low limit (4) is greater than high limit (3), at character 5.
SELECT '1.2'::ltree < '2.2'::ltree;
?column?
----------