Skip to content

Remove reg* pseudotype columns; add object info functions (reconciles new_features) - #17

Open
jnasbyupgrade wants to merge 19 commits into
masterfrom
reconcile-object-functions
Open

Remove reg* pseudotype columns; add object info functions (reconciles new_features)#17
jnasbyupgrade wants to merge 19 commits into
masterfrom
reconcile-object-functions

Conversation

@jnasbyupgrade

Copy link
Copy Markdown
Contributor

Summary

This is the first PR of a 3-PR stack. It reconciles the real, substantive
feature delta from new_features (#2) onto the current stable-version
baseline (branched fresh from master, which already has #12's real 0.1.0
restore, and merges in #5/#16's pgxn-tools testing + cat_tools 0.3.0 fix +
SQL linter — both still open at the time of this PR, but their content was
needed for this branch to have working CI/lint to validate itself against).

  • Drop the reg* pseudotype columns (regclass/regconfig/regdictionary/
    regnamespace/regoperator/regprocedure/regtype) from
    _object_reference._object_oid in favor of a single plain oid column
    (object_oid), removing the count_nulls-backed null_count trigger that
    used to arbitrate between them and simplifying _object_oid__add's insert
    accordingly. classid is now plain oid too.
  • Drop the now-dead count_nulls dependency entirely (the search_path
    workaround DO block, object_reference.control's requires, the Makefile
    install target, and test setup) — the only thing that needed it was the
    trigger removed above.
  • Add object_reference.object__describe() / object__identity() (thin
    wrappers around pg_describe_object()/pg_identify_object()), and
    object__cleanup() (best-effort delete, ignoring foreign_key_violation),
    wired up to a new AFTER DELETE trigger on object_group__object so
    removing an object from its last group auto-attempts cleanup.
  • object__getsert's core (_object_v__for_update) now refuses to track
    objects living in a pg_temp*/pg_toast_temp* schema.
  • Test updates: object_group.sql's scratch tables switch from TEMP to
    regular tables (temp objects are now rejected) plus new coverage for the
    cleanup trigger; base.sql swaps the now-moot count_nulls-relocation test
    for coverage of object_oid, object__describe(), object__identity(),
    and temp-object rejection.

sql/object_reference--0.1.0.sql (the frozen historical release) and the
META files are untouched — this repo's convention is that frozen versioned
SQL files are never hand-edited after release. default_version stays
'stable'; sql/object_reference--stable.sql is regenerated from
sql/object_reference.sql via make.

This PR supersedes #2 (new_features) — please close that once this
merges. It also obsoletes #3's update/upgrade test infrastructure (built
against the old 0.2.0/reg*-pseudotype model); rebuilding that against this
branch is a separate follow-up, not included here.

Test plan

  • make lint — clean (0 findings) against sql/object_reference.sql
    and test/
  • make test — all 7 regression tests + the dump/restore test pass on
    PostgreSQL 17
  • make test — all 7 regression tests + the dump/restore test pass on
    PostgreSQL 12 (the repo's floor per CI's matrix)
  • test/expected/*.out regenerated via make results (never hand-edited)
  • CI green on this PR (to be confirmed after push)

🤖 Generated with Claude Code

jnasbyupgrade and others added 19 commits August 25, 2025 16:48
e9c24de Fix pg_regress on versions > 12 (#5)
c0af00f Improvements to HISTORY.asc
6e8f2a7 Allow use of sudo when installing an extension
705f1ec Don't run clean as part of make test
370fa8e Create test/sql during setup

git-subtree-dir: pgxntool
git-subtree-split: e9c24de986ddc85bbd1fb3149076888d075ce100
Ditch the old travis setup. Pulls in some pgxntool changes as well.
# Conflicts:
#	.gitignore
#	pgxntool/HISTORY.asc
#	pgxntool/base.mk
#	pgxntool/setup.sh
Vendor Postgres-Extensions/linter as a git submodule at .vendor/linter,
following the same pattern already adopted in cat_tools: a thin
self-initializing lint.mk hand-off (so `make lint` works right after a
plain `git clone`, no --recurse-submodules needed), LINT_TARGETS scoped
to sql/object_reference.sql and test/ (excluding the frozen, never
hand-edited versioned install files under sql/, e.g.
object_reference--0.1.0.sql/--stable.sql), and a CI job that runs
`make lint` directly -- the same entry point a developer uses locally
-- so the self-init logic is actually exercised, not just the rule
checking.

The `include lint.mk` is guarded on .git being present: a tarball build
(PGXN distribution, `git archive` with no .git) has no submodule to
initialize, and Make resolves every `include` before running any
target regardless of which one was requested, so an unguarded rule
would break `make`/`make install` entirely for a tarball build, not
just `make lint`.

Fixes the real pre-existing style findings this first run turned up
(52 total): most were commented-out SQL marked as prose comments
instead of using the linter's `EXCLUDED CODE` disabled-code convention
(missing " * " prefixes flagged as comment-line-prefix/comment-opening
violations); one COPY data block's `secondary` column intentionally
mirrors pg_catalog's own type display name ("integer" for int4) rather
than following prefer-short-type, so it's suppressed via a scoped
disable-block region instead of being "fixed" into incorrect test data.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…able

pgxn install --unstable cat_tools resolves to the newest release actually
published to the PGXN package index, which is still 0.2.1 (2017) -- it fails
standalone on modern PostgreSQL with "column oid specified more than once" at
CREATE EXTENSION. cat_tools 0.3.0 fixes this but hasn't been uploaded to PGXN
yet, only tagged in git, so build it from that tag directly until PGXN has it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
cat_tools 0.3.0 is the first version of cat_tools this extension's test
suite has ever actually run against (pgxn install --unstable previously
resolved to a version that failed CREATE EXTENSION outright, so none of
this was exercised before now):

- cat_tools.function__arg_types_text() is deprecated in 0.3.0 in favor of
  cat_tools.routine__parse_arg_types_text() (same signature, same body,
  just renamed) and now emits a WARNING on every call. Switch to the
  non-deprecated name directly rather than carrying the warning forward.
- cat_tools 0.3.0's object_type enum gained two new members, "partitioned
  table" and "partitioned index". object_reference has no per-object-type
  special-casing (object identity is tracked generically via classid/objid),
  so these are already handled by the existing code the same way "table"
  and "index" are -- they just weren't yet reflected in object_reference's
  own classification of which object types are covered by a test. Add them
  to the untested() set so object_reference.untested_srf() ∪ tested types
  ∪ unsupported() still accounts for every member of the enum; a follow-up
  can add dedicated create/drop test coverage for them.
- Regenerate sql/object_reference--stable.sql (auto-generated from
  sql/object_reference.sql) and test/expected/zzz_build.out (line numbers
  in test/temp_load.not_sql shift by one now that a source comment line
  changed) to match.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…back

# Conflicts:
#	.github/workflows/ci.yml
The linter PR's comment-style edits (block comments -> "EXCLUDED CODE") land
in sql/object_reference.sql, which test/build's raw-load sanity check
(zzz_build) re-parses independently of pg_regress's own SQL loading and
reports line numbers for. Regenerated via `make results` after confirming
zero raw "not ok" TAP assertions anywhere in test/results/*.out (the earlier
copy of this file, committed before the linter-PR merge, was captured while
a leftover extension install from prior manual testing was still on disk in
the sandbox, which produced extra NOTICEs that don't appear in a real clean
run -- this version comes from a fully clean rebuild).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Verified directly: pg_get_object_address('partitioned table', ...) throws
"unrecognized object type" -- PostgreSQL's real object-address API only
knows the base "table"/"index" object types cat_tools's "partitioned table"/
"partitioned index" are derived from. object_reference actively calls
pg_get_object_address() on every object_type it tracks (not just in the
disabled sanity CHECK), so these two types would break identity tracking
outright rather than merely lacking test coverage -- the earlier "untested"
classification undersold the actual constraint.

Matches the classification (and the exact reasoning/wording) already landed
independently on the separate, longer-running new_features branch (PR #2),
which reaches unsupported() via the same cat_tools 0.3.0 enum growth. Update
test/sql/all.sql's own sanity-check of the unsupported set to match.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Reconciles the substantive feature delta from new_features (PR #2) onto the
current 'stable' baseline (post PR #5/#16: pgxn-tools testing, cat_tools
0.3.0, and the linter):

- _object_reference._object_oid: drop the per-catalog regclass/regconfig/
  regdictionary/regnamespace/regoperator/regprocedure/regtype columns and
  their unique indexes plus the count_nulls-backed null_count trigger that
  enforced "exactly one is set". classid is now plain oid and object_oid
  (also NOT NULL) is the sole identifier column, so there's nothing left to
  arbitrate between.
- _object_reference._object_v / _object_v__for_update: drop the reg* columns
  from the column list to match.
- _object_reference._object_oid__add: replace the dynamic, format()-built
  INSERT that picked a reg* column based on cat_tools.object__reg_type()
  with a plain INSERT into object_oid.
- Drop the count_nulls search_path DO block (dead now that the trigger using
  it is gone) and the count_nulls dependency throughout (control, Makefile,
  test setup).
- Add object_reference.object__describe()/object__identity(), thin wrappers
  around pg_describe_object()/pg_identify_object(); and object__cleanup(),
  which best-effort deletes an object record (ignoring foreign_key_violation
  if it's still referenced elsewhere). Wire object__cleanup() up to a new
  AFTER DELETE trigger on object_group__object so removing an object from
  its last group automatically attempts cleanup.
- _object_v__for_update (the getsert core): refuse to track objects living
  in a pg_temp*/pg_toast_temp* schema, since a tracked reference would
  outlive the temporary object it points to.
- test/sql/object_group.sql: switch the two scratch tables from TEMP to
  regular tables (object__getsert now rejects temp objects) and add
  coverage for the new automatic-cleanup trigger.
- test/sql/base.sql: replace the count_nulls-relocation test (relocation
  was already unsupported and the whole extension no longer depends on
  count_nulls) with coverage for object_oid, object__describe(),
  object__identity(), and temp-object rejection.

sql/object_reference--0.1.0.sql (the frozen historical release) and the
META files are untouched. default_version stays 'stable'; sql/object_reference--stable.sql
is regenerated to match sql/object_reference.sql. make lint and make test
(including the dump/restore test) pass on both PostgreSQL 12 and 17.

Supersedes PR #2 (new_features) and, for the update/upgrade test
infrastructure built on top of it, sets up the rebuild of PR #3.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: f8ad85c3-9a5f-49e1-919b-523093d1ac86

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant