diff --git a/src/common/backend/utils/adt/vector.cpp b/src/common/backend/utils/adt/vector.cpp index db2365eb9..7cd2ce324 100644 --- a/src/common/backend/utils/adt/vector.cpp +++ b/src/common/backend/utils/adt/vector.cpp @@ -1099,6 +1099,14 @@ Datum subvector(PG_FUNCTION_ARGS) ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION), errmsg("vector must have at least 1 dimension"))); } + /* Indexing starts at 1, like substring */ + if (start < 1) { + ereport(WARNING, (errmsg("when the start position is less than 1, it will begin with the first dimension"))); + start = 1; + } else if (start > a->dim) { + ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION), errmsg("vector must have at least 1 dimension"))); + } + /* * Check if (start + count > a->dim), avoiding integer overflow. a->dim * and count are both positive, so a->dim - count won't overflow. @@ -1109,13 +1117,6 @@ Datum subvector(PG_FUNCTION_ARGS) end = start + count; } - /* Indexing starts at 1, like substring */ - if (start < 1) { - start = 1; - } else if (start > a->dim) { - ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION), errmsg("vector must have at least 1 dimension"))); - } - dim = end - start; CheckDim(dim); result = InitVector(dim);