pgschema icon indicating copy to clipboard operation
pgschema copied to clipboard

Plan step fails on functions with table row-type composite parameters

Open kallanb opened this issue 7 months ago • 1 comments

My pgschema plan fails when a function takes a table's row type as a parameter (PostgreSQL composite type). The temp-schema validation step cannot resolve the composite type because the referenced table doesn't exist in the temp schema at function parse time.

Reproduce

CREATE TABLE shared.example_table (
    id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
    name varchar NOT NULL
);

CREATE FUNCTION shared.example_helper(p_row shared.example_table)
RETURNS jsonb LANGUAGE sql STABLE AS $$
    SELECT jsonb_build_object('id', p_row.id, 'name', p_row.name);
$$;

Running pgschema plan --file schema/main.sql --db mydb --schema shared fails during validation with an error referencing the composite type.

pgschema should resolve composite row types from the target schema before validating function definitions in the temp schema.

kallanb avatar Apr 15 '26 19:04 kallanb

Resolved in v1.9.0

kallanb avatar Apr 15 '26 21:04 kallanb