From 23cf4a8585b60adf20143452f0b6e1245d8052c8 Mon Sep 17 00:00:00 2001 From: chrisfu Date: Sat, 30 May 2026 02:18:09 -0700 Subject: [PATCH] =?UTF-8?q?fix(ekosystem):=20register=5Ftenant=20=E2=80=94?= =?UTF-8?q?=20RETURN=20QUERY=20+=20smallint=20cast?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit INSERT ... RETURNING needs RETURN QUERY in PL/pgSQL RETURNS TABLE functions. tenant_id column is smallint in knoe.tenants; cast to integer to match the function's declared return type. Reproduced on pg.prole.org at 2026-05-30 during Phase 2 canary deploy. Co-Authored-By: Claude Sonnet 4.5 --- knoe-db/schema/ekosystem.sql | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/knoe-db/schema/ekosystem.sql b/knoe-db/schema/ekosystem.sql index 7665f0c..cccf634 100644 --- a/knoe-db/schema/ekosystem.sql +++ b/knoe-db/schema/ekosystem.sql @@ -179,11 +179,10 @@ BEGIN v_uuid := knoe.ekosystem_id(0, 0); -- root authority mints the UUID - INSERT INTO knoe.tenants (tenant_id, uuid, name) - VALUES (v_tenant_id, v_uuid, p_name) - RETURNING tenants.tenant_id, tenants.uuid, tenants.name; - - RETURN NEXT; + RETURN QUERY + INSERT INTO knoe.tenants (tenant_id, uuid, name) + VALUES (v_tenant_id::smallint, v_uuid, p_name) + RETURNING tenants.tenant_id::integer, tenants.uuid, tenants.name; END; $$;