Skip to content

Commit 204b288

Browse files
jnasbyupgradeclaude
andcommitted
Update script: drop object_oid, use SET LOCAL for client_min_messages
Mirrors reconcile-object-functions' fresh-install changes in this hand-authored 0.1.0->stable update script: - object_oid is dropped (not backfilled+kept) alongside the reg* columns it used to collapse -- with no reg* columns left after this update, it's pure redundant storage of objid. objid_must_match and the two view recreations' object_oid passthrough go with it. - SET LOCAL client_min_messages, not plain SET -- this script runs inside ALTER EXTENSION UPDATE's implicit transaction, so LOCAL reverts automatically once it commits. Verified structurally clean and functionally correct: make test TEST_LOAD_SOURCE=update (the real 0.1.0 -> stable update path) passes all 8 tests. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 777c777 commit 204b288

1 file changed

Lines changed: 19 additions & 25 deletions

File tree

sql/object_reference--0.1.0--stable.sql

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
* which called count_nulls' not_null_count_trigger(), is removed.
1414
* - The reg* pseudotype columns on _object_reference._object_oid
1515
* (regclass/regconfig/regdictionary/regnamespace/regoperator/
16-
* regprocedure/regtype) are removed in favor of a single plain `oid`
17-
* column (object_oid), and classid changes from regclass to oid.
16+
* regprocedure/regtype), plus the now-redundant object_oid column they
17+
* used to collapse into (it always equaled objid once there was only
18+
* one oid source left), are all dropped; classid changes from regclass
19+
* to oid.
1820
* - _object_reference._object_v / _object_v__for_update (views) drop the
1921
* now-gone reg* columns. CREATE OR REPLACE VIEW cannot drop columns, so
2022
* both are DROP+CREATE'd, along with the two functions whose RETURNS
@@ -49,7 +51,10 @@
4951
* comparison of every recreated function/view against a fresh install of the
5052
* current version backs this file -- see the containing PR's description).
5153
*/
52-
SET client_min_messages = WARNING;
54+
-- SET LOCAL, not SET: this script runs inside ALTER EXTENSION UPDATE's
55+
-- implicit transaction, so LOCAL reverts automatically once it commits --
56+
-- see sql/object_reference.sql's own identical comment on this same point.
57+
SET LOCAL client_min_messages = WARNING;
5358

5459
CREATE SCHEMA __object_reference;
5560

@@ -205,12 +210,14 @@ DROP VIEW _object_reference._object_v__for_update;
205210
DROP VIEW _object_reference._object_v;
206211

207212
/*
208-
* _object_reference._object_oid: drop the reg* pseudotype columns and the
209-
* count_nulls-backed trigger that enforced "exactly one is set", in favor of
210-
* a single NOT NULL object_oid column. Order below is fully explicit
211-
* (constraints/indexes/trigger dropped by name, not left to an implicit
212-
* CASCADE) so nothing is silently dropped alongside a `DROP COLUMN` we did
213-
* not ask for.
213+
* _object_reference._object_oid: drop the reg* pseudotype columns, the
214+
* count_nulls-backed trigger that enforced "exactly one is set", and
215+
* object_oid itself (it only ever existed to collapse whichever reg* column
216+
* applied into a single plain-oid value -- with no reg* columns left, it's
217+
* pure redundant storage of objid and buys nothing). Order below is fully
218+
* explicit (constraints/indexes/trigger dropped by name, not left to an
219+
* implicit CASCADE) so nothing is silently dropped alongside a `DROP COLUMN`
220+
* we did not ask for.
214221
*/
215222
ALTER TABLE _object_reference._object_oid
216223
DROP CONSTRAINT regclass_classid
@@ -232,16 +239,6 @@ DROP INDEX _object_reference._object_oid__u_regoperator;
232239
DROP INDEX _object_reference._object_oid__u_regprocedure;
233240
DROP INDEX _object_reference._object_oid__u_regtype;
234241

235-
/*
236-
* Backfill: 0.1.0 only ever populated ONE of {regclass, ..., regtype,
237-
* object_oid} per row (whichever reg* type applied; object_oid itself only
238-
* when none did). objid was always kept equal to that same value (that's
239-
* exactly what the old objid_must_match CHECK enforced), so copying objid
240-
* into object_oid for every row is correct regardless of which reg* column
241-
* used to carry it, and is a no-op where object_oid already matched.
242-
*/
243-
UPDATE _object_reference._object_oid SET object_oid = objid WHERE object_oid IS NULL;
244-
245242
ALTER TABLE _object_reference._object_oid
246243
DROP COLUMN regclass
247244
, DROP COLUMN regconfig
@@ -250,9 +247,8 @@ ALTER TABLE _object_reference._object_oid
250247
, DROP COLUMN regoperator
251248
, DROP COLUMN regprocedure
252249
, DROP COLUMN regtype
250+
, DROP COLUMN object_oid
253251
, ALTER COLUMN classid TYPE oid USING classid::oid
254-
, ALTER COLUMN object_oid SET NOT NULL
255-
, ADD CONSTRAINT objid_must_match CHECK ( objid IS NOT DISTINCT FROM object_oid ) -- _object_reference._sanity() depends on this!
256252
;
257253

258254
CREATE VIEW _object_reference._object_v AS
@@ -264,7 +260,6 @@ CREATE VIEW _object_reference._object_v AS
264260
, i.classid
265261
, i.objid
266262
, i.objsubid
267-
, i.object_oid
268263
, s.*
269264
FROM _object_reference.object o
270265
LEFT JOIN _object_reference._object_oid i USING(object_id)
@@ -279,7 +274,6 @@ CREATE VIEW _object_reference._object_v__for_update AS
279274
, i.classid
280275
, i.objid
281276
, i.objsubid
282-
, i.object_oid
283277
, s.*
284278
FROM _object_reference.object o
285279
LEFT JOIN _object_reference._object_oid i USING(object_id)
@@ -440,8 +434,8 @@ BEGIN
440434
;
441435
END IF;
442436
BEGIN
443-
INSERT INTO _object_reference._object_oid(object_id, classid, objid, objsubid, object_oid)
444-
VALUES (object_id, classid, objid, objsubid, objid);
437+
INSERT INTO _object_reference._object_oid(object_id, classid, objid, objsubid)
438+
VALUES (object_id, classid, objid, objsubid);
445439

446440
SELECT INTO STRICT r_object_v -- Record better exist!
447441
*

0 commit comments

Comments
 (0)