Bug: Changing privileges of functions with enums include the qualified name of the temporal schema
old.sql:
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'app_user') THEN
CREATE ROLE app_user;
END IF;
END $$;
CREATE TYPE entity_kind AS ENUM ('person', 'company', 'organization');
CREATE FUNCTION create_entity(p_name text, p_kind entity_kind)
RETURNS uuid
LANGUAGE sql
AS $$ SELECT gen_random_uuid(); $$;
new.sql:
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'app_user') THEN
CREATE ROLE app_user;
END IF;
END $$;
CREATE TYPE entity_kind AS ENUM ('person', 'company', 'organization');
CREATE FUNCTION create_entity(p_name text, p_kind entity_kind)
RETURNS uuid
LANGUAGE sql
AS $$ SELECT gen_random_uuid(); $$;
REVOKE ALL ON FUNCTION create_entity(text, entity_kind) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION create_entity(text, entity_kind) TO app_user;
current plan.sql:
REVOKE EXECUTE ON FUNCTION create_entity(p_name text, p_kind pgschema_tmp_20260322_225736_e9508683.entity_kind) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION create_entity(p_name text, p_kind pgschema_tmp_20260322_225736_e9508683.entity_kind) TO app_user
Notice the enum is pgschema_tmp_20260322_225736_e9508683.entity_kind
expected plan.sql:
REVOKE EXECUTE ON FUNCTION create_entity(p_name text, p_kind entity_kind) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION create_entity(p_name text, p_kind entity_kind) TO app_user
Same underlying cause as #376, already fixed by #379 (commit cbecb2ae, "strip temp schema prefix from GRANT/REVOKE function signatures").
The root cause is identical: the temporary plan schema (pgschema_tmp_*) leaked into function-argument types in generated GRANT/REVOKE statements. The fix — normalizePrivilegeObjectName in ir/normalize.go — strips the schema qualifier from every argument type and is type-agnostic, so it handles enum args (this issue) exactly the same as the composite/array args in #376.
Verified against current main: reproducing the exact case here now yields the expected output with no temp-schema prefix:
REVOKE EXECUTE ON FUNCTION create_entity(p_name text, p_kind entity_kind) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION create_entity(p_name text, p_kind entity_kind) TO app_user;
Closing as a duplicate of #376. Please upgrade to a release including #379 — happy to reopen if you still see the prefix on the latest build.