pgschema icon indicating copy to clipboard operation
pgschema copied to clipboard

ROWS estimate on set-returning functions is not dumped or diffed

Open tianzhou opened this issue 3 weeks ago • 0 comments

Problem

The ROWS n planner estimate on set-returning functions is not inspected, dumped or diffed. A function created with ROWS 1 is replayed with the default estimate of 1000, and plan never reports a change to the estimate.

Reproduction

CREATE FUNCTION one_row(x int) RETURNS TABLE (y int) LANGUAGE sql ROWS 1 AS $$ SELECT x $$;

pgschema dump --schema public emits the function without ROWS 1. After applying the dump elsewhere, pg_proc.prorows is 1000 instead of 1. Changing ROWS in the desired state produces no plan.

Expected behavior

ROWS should be captured in the IR, emitted in CREATE FUNCTION when it differs from the default, and compared by plan, as COST, STRICT, PARALLEL and volatility already are.

Verification and scope

Reproduced on PostgreSQL 18.1 with pgschema 1.14.1 (91623d0b). Found in #597 (public.nc_table ... ROWS 1). Lower severity than a correctness bug since it only affects planner estimates.

tianzhou avatar Nov 08 '26 08:11 tianzhou