Re: Cleaning up array_in()

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема Re: Cleaning up array_in()
Дата
Msg-id 971eebc7-44aa-498d-8f9f-a3c0b3ab7cba@iki.fi
обсуждение исходный текст
Ответ на Re: Cleaning up array_in()  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Cleaning up array_in()  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On 09/11/2023 18:57, Tom Lane wrote:
> After further thought I concluded that this area is worth spending
> a little more code for.  If we have input like '{foo"bar"}' or
> '{"foo"bar}' or '{"foo""bar"}', what it most likely means is that
> the user misunderstood the quoting rules.  A message like "Unexpected
> array element" is pretty completely unhelpful for figuring that out.
> The alternative I was considering, "Unexpected """ character", would
> not be much better.  What we want to say is something like "Incorrectly
> quoted array element", and the attached v12 makes ReadArrayToken do
> that for both quoted and unquoted cases.

+1

> I also fixed the obsolete documentation that Alexander noted, and
> cleaned up a couple other infelicities (notably, I'd blindly written
> ereport(ERROR) in one place where ereturn is now the way).
> 
> Barring objections, I think v12 is committable.

Looks good to me. Just two little things caught my eye:

1.

>     /* Initialize dim, lBound for ReadArrayDimensions, ReadArrayStr */
>     for (int i = 0; i < MAXDIM; i++)
>     {
>         dim[i] = -1;            /* indicates "not yet known" */
>         lBound[i] = 1;            /* default lower bound */
>     }

The function comments in ReadArrayDimensions and ReadArrayStr don't make 
it clear that these arrays need to be initialized like this. 
ReadArrayDimensions() says that they are output variables, and 
ReadArrayStr() doesn't mention anything about having to initialize them.


2. This was the same before this patch, but:

postgres=# select '{{{{{{{{{{1}}}}}}}}}}'::int[];
ERROR:  number of array dimensions (7) exceeds the maximum allowed (6)
LINE 1: select '{{{{{{{{{{1}}}}}}}}}}'::int[];
                ^

The error message isn't great, as the literal contains 10 dimensions, 
not 7 as the error message claims.

-- 
Heikki Linnakangas
Neon (https://neon.tech)




В списке pgsql-hackers по дате отправления:

Предыдущее
От: Thomas Munro
Дата:
Сообщение: Re: ResourceOwner refactoring
Следующее
От: Michael Paquier
Дата:
Сообщение: Re: pg_walfile_name_offset can return inconsistent values