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
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
5459CREATE SCHEMA __object_reference ;
5560
@@ -205,12 +210,14 @@ DROP VIEW _object_reference._object_v__for_update;
205210DROP 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 */
215222ALTER TABLE _object_reference ._object_oid
216223 DROP CONSTRAINT regclass_classid
@@ -232,16 +239,6 @@ DROP INDEX _object_reference._object_oid__u_regoperator;
232239DROP INDEX _object_reference ._object_oid__u_regprocedure ;
233240DROP 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-
245242ALTER 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
258254CREATE 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