Files
aevolution/migrations/0024_primitive_life_owner_lookup.sql
dingo 636740bc55
Foundation / checks (deploy) (push) Successful in 6s
Foundation / checks (checks) (push) Failing after 40s
Foundation / checks (ecs) (push) Successful in 1m55s
Foundation / checks (postgres) (push) Failing after 53s
Foundation / checks (tsan) (push) Failing after 33s
Foundation / checks (network) (push) Failing after 3m1s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (client) (push) Canceled after 3m53s
Add durable primitive life owner lookup
2026-10-11 01:28:24 -04:00

24 lines
1.3 KiB
PL/PgSQL

-- M11.2d-7a, ADR-0116. Resolve the durable world/account owner before a
-- region claims account control during login. The lease fences the caller;
-- runtime receives no direct access to life_reservations.
CREATE FUNCTION evolution.primitive_life_owner(p_world evolution.u64,
p_region evolution.u64, p_holder uuid, p_epoch evolution.u64, p_account uuid)
RETURNS TABLE (owner_region evolution.u64)
LANGUAGE plpgsql SECURITY DEFINER SET search_path = pg_catalog, pg_temp AS $$
BEGIN
IF p_world IS NULL OR p_world = 0 OR p_region IS NULL OR p_region = 0
OR p_holder IS NULL OR p_epoch IS NULL OR p_epoch = 0
OR p_account IS NULL OR p_account = '00000000-0000-0000-0000-000000000000' THEN
RAISE EXCEPTION 'invalid life owner lookup' USING ERRCODE = '22023';
END IF;
PERFORM evolution.check_region_lease(p_world, p_region, p_holder, p_epoch);
RETURN QUERY SELECT r.region_id FROM evolution.life_reservations r
WHERE r.world_id = p_world AND r.account_id = p_account AND r.rejection = 0;
END $$;
REVOKE ALL ON FUNCTION evolution.primitive_life_owner(
evolution.u64,evolution.u64,uuid,evolution.u64,uuid) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION evolution.primitive_life_owner(
evolution.u64,evolution.u64,uuid,evolution.u64,uuid) TO :"runtime_role";
INSERT INTO evolution.schema_migrations(version,sha256) VALUES (24, :'migration_sha_24');