Skip to content

Commit 8d5573b

Browse files
committedNov 17, 2023
Don't specify number of dimensions in cases where we don't know it.
A few places in array_in() and plperl would report a misleading value (always MAXDIM+1) for the number of dimensions in the input, because we'd error out as soon as that was clearly too large rather than scanning the entire input. There doesn't seem to be much value in offering the true number, at least not enough to justify the extra complication involved in trying to get it. So just remove that parenthetical remark. We already have other places that do it like that, anyway. Per suggestions from Alexander Lakhin and Heikki Linnakangas. Discussion: https://postgr.es/m/[email protected]
1 parent 284cbae commit 8d5573b

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed
 

‎src/backend/utils/adt/arrayfuncs.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,8 @@ ReadArrayDimensions(char **srcptr, int *ndim_p, int *dim, int *lBound,
429429
if (ndim >= MAXDIM)
430430
ereturn(escontext, false,
431431
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
432-
errmsg("number of array dimensions (%d) exceeds the maximum allowed (%d)",
433-
ndim + 1, MAXDIM)));
432+
errmsg("number of array dimensions exceeds the maximum allowed (%d)",
433+
MAXDIM)));
434434

435435
q = p;
436436
if (!ReadDimensionInt(&p, &i, origStr, escontext))
@@ -641,8 +641,8 @@ ReadArrayStr(char **srcptr,
641641
if (nest_level >= MAXDIM)
642642
ereturn(escontext, false,
643643
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
644-
errmsg("number of array dimensions (%d) exceeds the maximum allowed (%d)",
645-
nest_level + 1, MAXDIM)));
644+
errmsg("number of array dimensions exceeds the maximum allowed (%d)",
645+
MAXDIM)));
646646

647647
nelems[nest_level] = 0;
648648
nest_level++;

‎src/pl/plperl/expected/plperl_array.out

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ select plperl_sum_array('{{{{{{{1,2},{3,4}},{{5,6},{7,8}}},{{{9,10},{11,12}},
6161
{{{{{1,2},{3,4}},{{5,6},{7,8}}},{{{9,10},{11,12}},{{13,14},{15,16}}}},
6262
{{{{17,18},{19,20}},{{21,22},{23,24}}},{{{25,26},{27,28}},{{29,30},{31,32}}}}}}}'
6363
);
64-
ERROR: number of array dimensions (7) exceeds the maximum allowed (6)
64+
ERROR: number of array dimensions exceeds the maximum allowed (6)
6565
LINE 1: select plperl_sum_array('{{{{{{{1,2},{3,4}},{{5,6},{7,8}}},{...
6666
^
6767
select plperl_sum_array('{{{1,2,3}, {4,5,6,7}}, {{7,8,9}, {10, 11, 12}}}');

‎src/pl/plperl/plperl.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1201,8 +1201,8 @@ array_to_datum_internal(AV *av, ArrayBuildState **astatep,
12011201
if (cur_depth + 1 > MAXDIM)
12021202
ereport(ERROR,
12031203
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
1204-
errmsg("number of array dimensions (%d) exceeds the maximum allowed (%d)",
1205-
cur_depth + 1, MAXDIM)));
1204+
errmsg("number of array dimensions exceeds the maximum allowed (%d)",
1205+
MAXDIM)));
12061206
/* OK, add a dimension */
12071207
dims[*ndims] = av_len(nav) + 1;
12081208
(*ndims)++;

0 commit comments

Comments
 (0)
Please sign in to comment.