mirror of
https://github.com/postgres/postgres.git
synced 2025-07-05 07:21:24 +03:00
Improve error messages for malformed array input strings.
Make the error messages issued by array_in() uniformly follow the style ERROR: malformed array literal: "actual input string" DETAIL: specific complaint here and rewrite many of the specific complaints to be clearer. The immediate motivation for doing this is a complaint from Josh Berkus that json_to_record() produced an unintelligible error message when dealing with an array item, because it tries to feed the JSON-format array value to array_in(). Really it ought to be smart enough to perform JSON-to-Postgres array conversion, but that's a future feature not a bug fix. In the meantime, this change is something we agreed we could back-patch into 9.4, and it should help de-confuse things a bit.
This commit is contained in:
@ -1065,26 +1065,32 @@ select '{{1,{2}},{2,3}}'::text[];
|
||||
ERROR: malformed array literal: "{{1,{2}},{2,3}}"
|
||||
LINE 1: select '{{1,{2}},{2,3}}'::text[];
|
||||
^
|
||||
DETAIL: Unexpected "{" character.
|
||||
select '{{},{}}'::text[];
|
||||
ERROR: malformed array literal: "{{},{}}"
|
||||
LINE 1: select '{{},{}}'::text[];
|
||||
^
|
||||
DETAIL: Unexpected "}" character.
|
||||
select E'{{1,2},\\{2,3}}'::text[];
|
||||
ERROR: malformed array literal: "{{1,2},\{2,3}}"
|
||||
LINE 1: select E'{{1,2},\\{2,3}}'::text[];
|
||||
^
|
||||
DETAIL: Unexpected "\" character.
|
||||
select '{{"1 2" x},{3}}'::text[];
|
||||
ERROR: malformed array literal: "{{"1 2" x},{3}}"
|
||||
LINE 1: select '{{"1 2" x},{3}}'::text[];
|
||||
^
|
||||
DETAIL: Unexpected array element.
|
||||
select '{}}'::text[];
|
||||
ERROR: malformed array literal: "{}}"
|
||||
LINE 1: select '{}}'::text[];
|
||||
^
|
||||
DETAIL: Junk after closing right brace.
|
||||
select '{ }}'::text[];
|
||||
ERROR: malformed array literal: "{ }}"
|
||||
LINE 1: select '{ }}'::text[];
|
||||
^
|
||||
DETAIL: Junk after closing right brace.
|
||||
select array[];
|
||||
ERROR: cannot determine type of empty array
|
||||
LINE 1: select array[];
|
||||
|
Reference in New Issue
Block a user