Re: Remove dependence on integer wrapping

Поиск
Список
Период
Сортировка
От Joseph Koshakow
Тема Re: Remove dependence on integer wrapping
Дата
Msg-id CAAvxfHdWseDnK0gLYY51fdw-_pE=5Q2=K=pToVv5jo3YNVfHoQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Remove dependence on integer wrapping  (Nathan Bossart <nathandbossart@gmail.com>)
Ответы Re: Remove dependence on integer wrapping
Список pgsql-hackers


On Mon, Jul 22, 2024 at 11:17 AM Nathan Bossart <nathandbossart@gmail.com> wrote:
> On Fri, Jul 19, 2024 at 07:32:18PM -0400, Joseph Koshakow wrote:
>> On Fri, Jul 19, 2024 at 2:45 PM Nathan Bossart <nathandbossart@gmail.com>
>> wrote:
>>> +            /* dim[i] = 1 + upperIndx[i] - lowerIndx[i]; */
>>> +            if (pg_add_s32_overflow(1, upperIndx[i], &dim[i]))
>>> +                ereport(ERROR,
>>> +                        (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
>>> +                         errmsg("array upper bound is too large: %d",
>>> +                                upperIndx[i])));
>>> +            if (pg_sub_s32_overflow(dim[i], lowerIndx[i], &dim[i]))
>>> +                ereport(ERROR,
>>> +                        (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
>>> +                         errmsg("array size exceeds the maximum allowed
>> (%d)",
>>> +                                (int) MaxArraySize)));
>
> Am I understanding correctly that the main
> behavioral difference between these two approaches is that users will see
> different error messages?

Yes, you are understanding correctly. The approach written above will
have the error message "array upper bound is too large", while the
approach attached in patch
v13-0002-Remove-overflow-from-array_set_slice.patch will have the error
message "array lower bound is too large".

Thanks,
Joseph Koshakow

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

Предыдущее
От: Pavel Luzanov
Дата:
Сообщение: Re: Things I don't like about \du's "Attributes" column
Следующее
От: Andreas Karlsson
Дата:
Сообщение: Re: Special-case executor expression steps for common combinations