Re: array_in sub function ReadArrayDimensions error message - Mailing list pgsql-hackers

From Tom Lane
Subject Re: array_in sub function ReadArrayDimensions error message
Date
Msg-id 1386373.1720539082@sss.pgh.pa.us
Whole thread Raw
In response to Re: array_in sub function ReadArrayDimensions error message  (jian he <jian.universality@gmail.com>)
Responses Re: array_in sub function ReadArrayDimensions error message
Re: array_in sub function ReadArrayDimensions error message
List pgsql-hackers
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



pgsql-hackers by date:

Previous
From: Junwang Zhao
Date:
Subject: Re: jsonpath: Inconsistency of timestamp_tz() Output
Next
From: Andrew Dunstan
Date:
Subject: Re: tests fail on windows with default git settings