Reject self-tracked objects; add reusable update-disable mechanism - #41
Reject self-tracked objects; add reusable update-disable mechanism#41jnasbyupgrade wants to merge 1 commit into
Conversation
… objects object__getsert() (via _object_v__for_update()) now refuses to track any object that is itself a member of the object_reference extension, closing a bootstrapping hazard where the extension's own update-time restructuring could trip its own rename-detection/repair machinery. Replace the update script's session_replication_role trick with a real, reusable mechanism: zzz_object_reference__fix_identity and zzz_object_reference_capture self-recognize (and skip) DDL from any extension's own install/update script via in_extension; zzz__object_reference_drop can't self-recognize that way, so internal_update__begin()/__end() explicitly disable/re-enable it (saving and restoring its actual prior state) for future update scripts to reuse. Closes Postgres-Extensions#40.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
|
Claude finished @jnasbyupgrade's task in 2m 54s —— View job Claude's ReviewTodo list
Overall this is a clean, well-explained PR. The One design point worth a second look: Scope of the
|
Two related fixes needed for #38's OID-repair design, but useful independent of it: object__getsert() (via _object_v__for_update()) now refuses to track any object that is a member of the object_reference extension itself, since letting the tracking system observe its own extension-member objects turns the extension's own DDL -- including its own update scripts restructuring itself -- into things the tracking/repair machinery would react to.
The update script's session_replication_role trick is replaced by a real, reusable mechanism. zzz_object_reference__fix_identity and zzz_object_reference_capture now self-recognize DDL from any extension's own install/update script via pg_event_trigger_ddl_commands()'s in_extension column and skip it; zzz__object_reference_drop can't self-recognize that way (pg_event_trigger_dropped_objects() has no equivalent column), so
_object_reference.internal_update__begin()/__end()explicitly disable and re-enable it -- saving and restoring its actual prior enabled state rather than assuming 'origin' -- for this and future update scripts to call.Details
_object_reference._is_own_object(classid, objid)checks extension membership viapg_depend(deptype = 'e',refobjid= object_reference's own extension oid); wired into_object_v__for_update()right after the existing temp-object rejection.internal_update__begin(event_trigger_names name[] DEFAULT '{zzz__object_reference_drop}')/internal_update__end()disable/re-enable the given event triggers, recording each one's priorevtenabledvalue in a temp table soend()restores it exactly.ALTER EVENT TRIGGERis ordinary transactional DDL, so a rolled-back update script undoes any DISABLE automatically -- no separate cleanup-on-error logic needed.sql/object_reference--0.1.0--stable.sqlcreates all three new functions early (0.1.0 has none of them) and callsinternal_update__begin()/__end()around its structural section instead of the oldsession_replication_rolesave/restore. It also now creates_object_reference.exec(), a permanent helper 0.1.0 never got thatobject__dependency__add()/object_group__dependency__add()(both unchanged since 0.1.0) already depended on, closing a pre-existing gap in the update path.test/sql/internal_update.sqlcovers the begin/end round-trip, restoring a non-default prior state, and the nested-call/no-matching-call guards.test/sql/base.sqlgains two rejection tests (tracking_object_reference.objectitself, and one of the event trigger functions).Verified with both
make testandmake test-update(0.1.0 → stable).Closes #40.