-
Notifications
You must be signed in to change notification settings - Fork 38
Closed
Copy link
Description
Summary
pgschema dump assigns the wrong LANGUAGE to overloaded functions. When two functions share the same name but have different languages (e.g., one sql and one plpgsql), the dump may emit the plpgsql overload with LANGUAGE sql, making the dump non-replayable.
Environment
- pgschema: 1.7.2
- PostgreSQL: 18.2
Minimal repro
CREATE SCHEMA s;
-- Overload 1: SQL
CREATE FUNCTION s.provide_tx(VARIADIC p_txs text[])
RETURNS void LANGUAGE sql AS $$ SELECT 1; $$;
-- Overload 2: plpgsql
CREATE FUNCTION s.provide_tx(p_id uuid)
RETURNS void LANGUAGE plpgsql AS $$
# variable_conflict use_column
BEGIN
RAISE NOTICE '%', p_id;
END;
$$;pgschema dump --schema s --db <db> --user <user>Expected
Both overloads dumped with their correct LANGUAGE:
provide_tx(VARIADIC text[])→LANGUAGE sqlprovide_tx(uuid)→LANGUAGE plpgsql
Actual
The plpgsql overload is emitted with LANGUAGE sql:
CREATE OR REPLACE FUNCTION provide_tx(
p_id uuid
)
RETURNS void
LANGUAGE sql -- ← wrong, should be plpgsql
VOLATILE
AS $$
# variable_conflict use_column -- ← syntax error in sql context
BEGIN
...This causes a syntax error when replaying the dump (plan or apply):
ERROR: syntax error at or near "#" (SQLSTATE 42601)
Impact
pgschema plancannot produce a valid plan for any schema containing overloaded functions with mixed languagespgschema dumpoutput is not idempotent — cannot be re-applied
Reactions are currently unavailable