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