Conversation
…368) The JOIN between information_schema.routines and pg_proc matched only on function name and namespace, causing a cross-join for overloaded functions. This resulted in wrong LANGUAGE (and other attributes) being assigned when overloads had different languages (e.g., sql vs plpgsql). Fix by adding OID matching via specific_name to all 4 affected queries. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Greptile SummaryThis PR fixes a cross-join bug in the Key changes:
The approach is sound: Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[information_schema.routines row\ne.g. provide_tx with specific_name='provide_tx_12345'] --> B{JOIN pg_proc}
subgraph OLD["Before fix (cross-join)"]
B1["ON proname = routine_name\nAND pronamespace = schema_oid"]
B1 --> C1["Matches ALL overloads\nwith same name"]
C1 --> D1["provide_tx_12345 gets LANGUAGE plpgsql\n(from wrong overload)"]
end
subgraph NEW["After fix (OID-pinned)"]
B2["ON proname = routine_name\nAND pronamespace = schema_oid\nAND oid = extract_oid(specific_name)"]
B2 --> C2["Matches EXACTLY ONE pg_proc row\nvia OID from specific_name"]
C2 --> D2["provide_tx_12345 gets LANGUAGE sql ✓\nprovide_tx_67890 gets LANGUAGE plpgsql ✓"]
end
B --> B1
B --> B2
E["specific_name format\n'provide_tx_12345'\n→ regexp_match('_(\d+)$')\n→ OID 12345\n→ cast to ::oid"] --> B2
Reviews (1): Last reviewed commit: "fix: correct LANGUAGE for overloaded fun..." | Re-trigger Greptile |
There was a problem hiding this comment.
Pull request overview
This PR fixes routine introspection so overloaded functions/procedures are joined to the correct pg_proc row, preventing mixed-language overloads from being dumped with an incorrect LANGUAGE (fixing #368) and expanding coverage in the existing overload dump fixture (#191).
Changes:
- Updates the
information_schema.routines↔pg_procjoin to additionally match the routine OID derived fromr.specific_name(applied to 4 queries). - Extends the
issue_191_function_procedure_overloaddump fixture to include a same-name overload pair with different languages (sqlvsplpgsql). - Adds an integration test entry to run the
issue_191_function_procedure_overloadexact-match dump fixture.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
ir/queries/queries.sql |
Fixes routine ↔ pg_proc joining by uniquely matching on OID extracted from specific_name, preventing overload cross-joins. |
ir/queries/queries.sql.go |
Regenerates the sqlc output to reflect the updated SQL joins. |
testdata/dump/issue_191_function_procedure_overload/raw.sql |
Adds mixed-language overload DDL to reproduce/cover #368 in the existing fixture. |
testdata/dump/issue_191_function_procedure_overload/pgschema.sql |
Updates expected pgschema dump output to include both overloads with correct LANGUAGE. |
testdata/dump/issue_191_function_procedure_overload/pgdump.sql |
Updates pg_dump input fixture to include the new overloads. |
testdata/dump/issue_191_function_procedure_overload/manifest.json |
Updates fixture metadata to reflect covering both #191 and #368. |
cmd/dump/dump_integration_test.go |
Adds an integration test function to execute the updated overload fixture. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
information_schema.routines↔pg_procJOIN that caused overloaded functions with different languages to get the wrongLANGUAGEassignedspecific_nameto all 4 affected queries (GetFunctions, GetProcedures, GetFunctionsForSchema, GetProceduresForSchema)issue_191_function_procedure_overloadtest caseFixes #368
Test plan
TestDumpCommand_Issue191FunctionProcedureOverloadwithsqlvsplpgsqloverloadscreate_function/,create_procedure/)🤖 Generated with Claude Code