pgschema icon indicating copy to clipboard operation
pgschema copied to clipboard

pgschema leaks temporary desired-state schema into GRANT/REVOKE ON FUNCTION for user-defined argument types

Open pettijohn opened this issue 8 months ago • 1 comments

Full repro here https://github.com/pettijohn/pgschema-bug - run schema/apply.sh Using v1.8.0

CREATE TYPE my_input AS (
  id uuid
);

CREATE OR REPLACE FUNCTION f_test(p_items my_input[])
RETURNS integer
LANGUAGE sql
AS $$
  SELECT COALESCE(array_length(p_items, 1), 0);
$$;

REVOKE ALL ON FUNCTION f_test(my_input[]) FROM PUBLIC;
GRANT EXECUTE ON FUNCTION f_test(my_input[]) TO appname_apiuser;

Apply fails with ERROR: schema "pgschema_tmp_..." does not exist

Issue: generated output sql leaks temporary schema name in grant/revoke statements

REVOKE EXECUTE ON FUNCTION f_test(p_items pgschema_tmp_20260326_161823_31f3dbda.my_input[]) FROM PUBLIC;

GRANT EXECUTE ON FUNCTION f_test(p_items pgschema_tmp_20260326_161823_31f3dbda.my_input[]) TO appname_apiuser;

pettijohn avatar Mar 26 '26 16:03 pettijohn

Wow! This is the second bug I've filed on this project, and both fixed within 24 hours. Amazing. Thank you so much for this awesome project and your dedication to it.

pettijohn avatar Mar 27 '26 15:03 pettijohn