From 24153faf5c3ec9cca23d18c3223c6efd6474ccd9 Mon Sep 17 00:00:00 2001 From: David Rowley Date: Wed, 29 Apr 2026 15:50:07 +1200 Subject: [PATCH v1] Remove unused references to HEAP_HASOID_OLD Some code was still under the impression we could see tuples with this flag set in t_infomask. That's not the case as pg_upgrade requires that the tables be modifed to remove the Oids before allowing the upgrade to take place. This removes all usages of HEAP_HASOID_OLD and renames it to HEAP_UNUSED_FLAG. My thoughts are putting that name there makes it more clear that the flag is unused and can be used for something new. Seems easier to see than a gap in the defined hex numbers. Reported-by: Andres Freund Author: David Rowley Discussion: https://postgr.es/m/CAApHDvqB=kapsgwvLiPZRhfyFcJB6nw-Xs2D-jHm6ddRcxP7zA@mail.gmail.com --- contrib/pageinspect/expected/page.out | 3 +-- contrib/pageinspect/heapfuncs.c | 25 +++---------------------- src/include/access/htup_details.h | 4 +--- 3 files changed, 5 insertions(+), 27 deletions(-) diff --git a/contrib/pageinspect/expected/page.out b/contrib/pageinspect/expected/page.out index fcf19c5ca5a..167d3175d31 100644 --- a/contrib/pageinspect/expected/page.out +++ b/contrib/pageinspect/expected/page.out @@ -134,7 +134,6 @@ SELECT unnest(raw_flags) HEAP_COMBOCID HEAP_HASEXTERNAL HEAP_HASNULL - HEAP_HASOID_OLD HEAP_HASVARWIDTH HEAP_HOT_UPDATED HEAP_KEYS_UPDATED @@ -150,7 +149,7 @@ SELECT unnest(raw_flags) HEAP_XMAX_LOCK_ONLY HEAP_XMIN_COMMITTED HEAP_XMIN_INVALID -(19 rows) +(18 rows) SELECT unnest(combined_flags) FROM heap_tuple_infomask_flags(x'FFFF'::int, x'FFFF'::int) ORDER BY 1; diff --git a/contrib/pageinspect/heapfuncs.c b/contrib/pageinspect/heapfuncs.c index 7be4770dc84..3e7a8f172bb 100644 --- a/contrib/pageinspect/heapfuncs.c +++ b/contrib/pageinspect/heapfuncs.c @@ -38,21 +38,6 @@ #include "utils/builtins.h" #include "utils/rel.h" -/* - * It's not supported to create tuples with oids anymore, but when pg_upgrade - * was used to upgrade from an older version, tuples might still have an - * oid. Seems worthwhile to display that. - */ -static inline Oid -HeapTupleHeaderGetOidOld(const HeapTupleHeaderData *tup) -{ - if (tup->t_infomask & HEAP_HASOID_OLD) - return *((const Oid *) ((const char *) (tup) + (tup)->t_hoff - sizeof(Oid))); - else - return InvalidOid; -} - - /* * bits_to_text * @@ -231,7 +216,7 @@ heap_page_items(PG_FUNCTION_ARGS) int tuple_data_len; bytea *tuple_data_bytea; - /* Copy null bitmask and OID, if present */ + /* Copy null bitmask, if present */ if (tuphdr->t_infomask & HEAP_HASNULL) { int bitmaplen; @@ -248,10 +233,8 @@ heap_page_items(PG_FUNCTION_ARGS) else nulls[11] = true; - if (tuphdr->t_infomask & HEAP_HASOID_OLD) - values[12] = ObjectIdGetDatum(HeapTupleHeaderGetOidOld(tuphdr)); - else - nulls[12] = true; + /* Oids are no longer stored in tuples, so set this to NULL */ + nulls[12] = true; /* Copy raw tuple data into bytea attribute */ tuple_data_len = lp_len - tuphdr->t_hoff; @@ -555,8 +538,6 @@ heap_tuple_infomask_flags(PG_FUNCTION_ARGS) flags[cnt++] = CStringGetTextDatum("HEAP_HASVARWIDTH"); if ((t_infomask & HEAP_HASEXTERNAL) != 0) flags[cnt++] = CStringGetTextDatum("HEAP_HASEXTERNAL"); - if ((t_infomask & HEAP_HASOID_OLD) != 0) - flags[cnt++] = CStringGetTextDatum("HEAP_HASOID_OLD"); if ((t_infomask & HEAP_XMAX_KEYSHR_LOCK) != 0) flags[cnt++] = CStringGetTextDatum("HEAP_XMAX_KEYSHR_LOCK"); if ((t_infomask & HEAP_COMBOCID) != 0) diff --git a/src/include/access/htup_details.h b/src/include/access/htup_details.h index 77a6c48fd71..2307a034165 100644 --- a/src/include/access/htup_details.h +++ b/src/include/access/htup_details.h @@ -66,8 +66,6 @@ * fixed fields (HeapTupleHeaderData struct) * nulls bitmap (if HEAP_HASNULL is set in t_infomask) * alignment padding (as needed to make user data MAXALIGN'd) - * object ID (if HEAP_HASOID_OLD is set in t_infomask, not created - * anymore) * user data fields * * We store five "virtual" fields Xmin, Cmin, Xmax, Cmax, and Xvac in three @@ -190,7 +188,7 @@ struct HeapTupleHeaderData #define HEAP_HASNULL 0x0001 /* has null attribute(s) */ #define HEAP_HASVARWIDTH 0x0002 /* has variable-width attribute(s) */ #define HEAP_HASEXTERNAL 0x0004 /* has external stored attribute(s) */ -#define HEAP_HASOID_OLD 0x0008 /* has an object-id field */ +#define HEAP_UNUSED_FLAG 0x0008 /* previously HEAP_HASOID now unused */ #define HEAP_XMAX_KEYSHR_LOCK 0x0010 /* xmax is a key-shared locker */ #define HEAP_COMBOCID 0x0020 /* t_cid is a combo CID */ #define HEAP_XMAX_EXCL_LOCK 0x0040 /* xmax is exclusive locker */ -- 2.53.0