jian he <jian.universality@gmail.com> writes:
> On Mon, Jul 8, 2024 at 10:42 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> One possibility could be
>> ...
>> that is, only say "Missing "]"" if there's no ']' anywhere, and
>> otherwise just say the dimensions are wrong. This could be fooled
>> by a ']' that's part of some string in the data, but even then the
>> errdetail isn't wrong.
>>
>> Or we could just say "Array dimensions have invalid syntax."
>> unconditionally.
> please check attached.
Meh. This just replaces one possibly-off-point error message
with a different one that will be off-point in a different set
of cases. I think we should simply reduce the specificity of
the message.
BTW, I think we have pretty much the same issue with respect
to the check for "=" later on. For instance, if someone
is confused about whether to insert commas:
=# select '[1:1],[1:2]={{3,4}}'::int[];
ERROR: malformed array literal: "[1:1],[1:2]={{3,4}}"
LINE 1: select '[1:1],[1:2]={{3,4}}'::int[];
^
DETAIL: Missing "=" after array dimensions.
Here again, the problem is not a missing "=", it's invalid
syntax somewhere before that.
Another thing we could consider doing here (and similarly
for your original case) is
DETAIL: Expected "=" not "," after array dimensions.
The advantage of this is that it provides a little more
clarity as to exactly where things went wrong.
regards, tom lane