Skip to content

Commit fc9b7e9

Browse files
committed
Fix sphere() functions to use explicit cast for WHPG compatibility
The sphere() SQL functions were defined as 'SELECT ROW($1, $2)' which returns a generic record type. WHPG (Greenplum/PostgreSQL 12.12) is stricter about type matching in SQL function bodies and requires the return value to match the declared composite type exactly. This caused runtime errors: ERROR: return type mismatch in function declared to return sphere_vector DETAIL: Final statement returns record instead of vector at column 1. Fix by adding explicit casts: 'SELECT ROW($1, $2)::sphere_vector'
1 parent ba61554 commit fc9b7e9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/sql/finalize.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,16 +189,16 @@ CREATE OPERATOR @# (
189189
-- List of functions
190190

191191
CREATE FUNCTION sphere(vector, real) RETURNS sphere_vector
192-
IMMUTABLE PARALLEL SAFE LANGUAGE sql AS 'SELECT ROW($1, $2)';
192+
IMMUTABLE PARALLEL SAFE LANGUAGE sql AS 'SELECT ROW($1, $2)::sphere_vector';
193193

194194
CREATE FUNCTION sphere(halfvec, real) RETURNS sphere_halfvec
195-
IMMUTABLE PARALLEL SAFE LANGUAGE sql AS 'SELECT ROW($1, $2)';
195+
IMMUTABLE PARALLEL SAFE LANGUAGE sql AS 'SELECT ROW($1, $2)::sphere_halfvec';
196196

197197
CREATE FUNCTION sphere(rabitq8, real) RETURNS sphere_rabitq8
198-
IMMUTABLE PARALLEL SAFE LANGUAGE sql AS 'SELECT ROW($1, $2)';
198+
IMMUTABLE PARALLEL SAFE LANGUAGE sql AS 'SELECT ROW($1, $2)::sphere_rabitq8';
199199

200200
CREATE FUNCTION sphere(rabitq4, real) RETURNS sphere_rabitq4
201-
IMMUTABLE PARALLEL SAFE LANGUAGE sql AS 'SELECT ROW($1, $2)';
201+
IMMUTABLE PARALLEL SAFE LANGUAGE sql AS 'SELECT ROW($1, $2)::sphere_rabitq4';
202202

203203
CREATE FUNCTION quantize_to_rabitq8(vector) RETURNS rabitq8
204204
IMMUTABLE STRICT PARALLEL SAFE LANGUAGE c AS 'MODULE_PATHNAME', '_vchord_vector_quantize_to_rabitq8_wrapper';

0 commit comments

Comments
 (0)