diff --git a/src/backend/executor/execQual.c b/src/backend/executor/execQual.c index 5dae37d5d6..3895b65078 100644 --- a/src/backend/executor/execQual.c +++ b/src/backend/executor/execQual.c @@ -293,7 +293,7 @@ ExecEvalArrayRef(ArrayRefExprState *astate, ereport(ERROR, (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), errmsg("number of array dimensions (%d) exceeds the maximum allowed (%d)", - i, MAXDIM))); + i + 1, MAXDIM))); upper.indx[i++] = DatumGetInt32(ExecEvalExpr(eltstate, econtext, @@ -321,7 +321,7 @@ ExecEvalArrayRef(ArrayRefExprState *astate, ereport(ERROR, (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), errmsg("number of array dimensions (%d) exceeds the maximum allowed (%d)", - i, MAXDIM))); + j + 1, MAXDIM))); lower.indx[j++] = DatumGetInt32(ExecEvalExpr(eltstate, econtext, diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c index f06c4e5657..b36af2c0f0 100644 --- a/src/backend/utils/adt/arrayfuncs.c +++ b/src/backend/utils/adt/arrayfuncs.c @@ -201,7 +201,7 @@ array_in(PG_FUNCTION_ARGS) ereport(ERROR, (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), errmsg("number of array dimensions (%d) exceeds the maximum allowed (%d)", - ndim, MAXDIM))); + ndim + 1, MAXDIM))); for (q = p; isdigit((unsigned char) *q) || (*q == '-') || (*q == '+'); q++); if (q == p) /* no digits? */ @@ -453,7 +453,7 @@ ArrayCount(const char *str, int *dim, char typdelim) ereport(ERROR, (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), errmsg("number of array dimensions (%d) exceeds the maximum allowed (%d)", - nest_level, MAXDIM))); + nest_level + 1, MAXDIM))); temp[nest_level] = 0; nest_level++; if (ndim < nest_level) diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c index 87a9f9de0e..104765be18 100644 --- a/src/pl/plpgsql/src/pl_exec.c +++ b/src/pl/plpgsql/src/pl_exec.c @@ -3750,7 +3750,7 @@ exec_assign_value(PLpgSQL_execstate *estate, ereport(ERROR, (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), errmsg("number of array dimensions (%d) exceeds the maximum allowed (%d)", - nsubscripts, MAXDIM))); + nsubscripts + 1, MAXDIM))); subscripts[nsubscripts++] = arrayelem->subscript; target = estate->datums[arrayelem->arrayparentno]; } while (target->dtype == PLPGSQL_DTYPE_ARRAYELEM);