Improved null check and fixed message [skip ci]

This commit is contained in:
Andrew Kane
2023-07-15 22:51:40 -07:00
parent 21f56374b5
commit 42007b41ea
2 changed files with 6 additions and 6 deletions

View File

@@ -437,6 +437,11 @@ array_to_vector(PG_FUNCTION_ARGS)
(errcode(ERRCODE_DATA_EXCEPTION),
errmsg("array must be 1-D")));
if (ARR_HASNULL(array) && array_contains_nulls(array))
ereport(ERROR,
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
errmsg("array must not contain nulls")));
get_typlenbyvalalign(ARR_ELEMTYPE(array), &typlen, &typbyval, &typalign);
deconstruct_array(array, ARR_ELEMTYPE(array), typlen, typbyval, typalign, &elemsp, &nullsp, &nelemsp);
@@ -446,11 +451,6 @@ array_to_vector(PG_FUNCTION_ARGS)
result = InitVector(nelemsp);
for (int i = 0; i < nelemsp; i++)
{
if (nullsp[i])
ereport(ERROR,
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
errmsg("array must not containing NULLs")));
/* TODO Move outside loop in 0.5.0 */
if (ARR_ELEMTYPE(array) == INT4OID)
result->x[i] = DatumGetInt32(elemsp[i]);

View File

@@ -29,7 +29,7 @@ SELECT ARRAY[1,2,3]::numeric[]::vector;
(1 row)
SELECT '{NULL}'::real[]::vector;
ERROR: array must not containing NULLs
ERROR: array must not contain nulls
SELECT '{NaN}'::real[]::vector;
ERROR: NaN not allowed in vector
SELECT '{Infinity}'::real[]::vector;