Re: array_in sub function ReadArrayDimensions error message

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: array_in sub function ReadArrayDimensions error message
Date: 2024-07-09 15:31:22
Message-ID: 1386373.1720539082@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

jian he <jian(dot)universality(at)gmail(dot)com> writes:
> On Mon, Jul 8, 2024 at 10:42 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2024-07-09 15:34:24 Re: tests fail on windows with default git settings
Previous Message Junwang Zhao 2024-07-09 15:08:52 Re: jsonpath: Inconsistency of timestamp_tz() Output