Skip to content

Normalize pg_git SQL object qualification and add search_path regression coverage#47

Merged
seanwevans merged 2 commits into
mainfrom
codex/normalize-sql-object-references
May 20, 2026
Merged

Normalize pg_git SQL object qualification and add search_path regression coverage#47
seanwevans merged 2 commits into
mainfrom
codex/normalize-sql-object-references

Conversation

@seanwevans
Copy link
Copy Markdown
Owner

Motivation

  • Ensure SQL objects owned by the extension are referenced explicitly to avoid accidental dependence on the session search_path and to make FK/DML targets unambiguous.
  • Prevent subtle bugs where unqualified names could resolve to user tables or system objects in non-default search_path environments.
  • Make schema and function SQL safe to call when search_path is changed by callers or tests.

Description

  • Qualified internal extension tables and references by replacing unqualified names with pg_git.<object> across core schema and function SQL, including table creation, FK constraints, DML, and queries.
  • Updated schema files (sql/schema/001-core.sql, sql/schema/pgit-schema.sql) to create pg_git.* tables and to reference pg_git.* in foreign keys and inserts.
  • Updated function files under sql/functions/ to use pg_git.repositories, pg_git.blobs, pg_git.trees, pg_git.commits, pg_git.refs, pg_git.remotes, and pg_git.remote_refs where appropriate, while keeping non-object identifiers (e.g., the refs column alias in get_decorated_log) unchanged.
  • Added a pgtap regression test test/sql/search_path_qualification_test.sql that sets search_path to public and validates init, stage/commit, commit persistence, and HEAD/master alignment still work.

Testing

  • Ran a static audit rg -nP "(?<!pg_git\.)\b(repositories|blobs|trees|commits|refs|remotes|remote_refs)\b" sql/schema sql/functions to verify unqualified object names were removed, which succeeded.
  • Committed the changes (git commit) after staging, which succeeded and shows the SQL and test file were added/updated.
  • Added the regression test file test/sql/search_path_qualification_test.sql to the test suite for automated execution by CI (the test file was created but the SQL test suite was not executed in this patch run).

Codex Task

@seanwevans seanwevans merged commit b1714d5 into main May 20, 2026
@seanwevans seanwevans deleted the codex/normalize-sql-object-references branch May 20, 2026 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant