mirror of
https://github.com/pgvector/pgvector.git
synced 2026-06-06 05:51:21 +08:00
Improved null check and fixed message [skip ci]
This commit is contained in:
10
src/vector.c
10
src/vector.c
@@ -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]);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user