Any reason to keep HEAP_HASOID_OLD?

Поиск
Список
Период
Сортировка
Искать

Any reason to keep HEAP_HASOID_OLD?

От:
David Rowley <dgrowleyml@gmail.com>
Дата:
Andres mentioned to me that I might want to look at
HeapTupleHeaderGetOidOld() as there's a comment and some code there
that would lead you to believe we can still have tuples with oids. If
that were true, the code I recently added for getting 'tp' in
slot_selectively_deform_heap_tuple() is wrong.

#define HEAP_HASOID_OLD 0x0008 /* has an object-id field */

On 11.22, I tried:

create extension pageinspect;
create table t1 (a int) with oids;
insert into t1 select generate_Series(1,1000);
select count(*) from heap_page_items(get_raw_page('public.t1',0))
where t_infomask & 8 <> 0;

 count
-------
   185

alter table t1 set without oids;

select count(*) from heap_page_items(get_raw_page('public.t1',0))
where t_infomask & 8 <> 0;
 count
-------
     0

And also, if I try to pg_upgrade before SET WITHOUT OIDS, I get:

$ pg_upgrade -d pgdata11 -D pgdata -b ~/pg11/bin -B ~/pg/bin
Performing Consistency Checks
-----------------------------
Checking cluster versions                                   ok
Checking database user is the install user                  ok
Checking database connection settings                       ok
Checking for prepared transactions                          ok
Checking for system-defined composite types in user tables  ok
Checking for reg* data types in user tables                 ok
Checking for contrib/isn with bigint-passing mismatch       ok
Checking for user-defined encoding conversions              ok
Checking for user-defined postfix operators                 ok
Checking for incompatible polymorphic functions             ok
Checking for tables WITH OIDS                               fatal

So, I'm not following how we could get a tuple with OIDs in versions after 11.

Should we get rid of HEAP_HASOID_OLD and the code that relates to it?

David


Re: Any reason to keep HEAP_HASOID_OLD?

От:
Andres Freund <andres@anarazel.de>
Дата:
Hi,

On 2026-04-28 16:27:59 +1200, David Rowley wrote:
> Andres mentioned to me that I might want to look at
> HeapTupleHeaderGetOidOld() as there's a comment and some code there
> that would lead you to believe we can still have tuples with oids. If
> that were true, the code I recently added for getting 'tp' in
> slot_selectively_deform_heap_tuple() is wrong.
> 
> #define HEAP_HASOID_OLD 0x0008 /* has an object-id field */
> 
> On 11.22, I tried:
> 
> create extension pageinspect;
> create table t1 (a int) with oids;
> insert into t1 select generate_Series(1,1000);
> select count(*) from heap_page_items(get_raw_page('public.t1',0))
> where t_infomask & 8 <> 0;
> 
>  count
> -------
>    185
> 
> alter table t1 set without oids;
> 
> select count(*) from heap_page_items(get_raw_page('public.t1',0))
> where t_infomask & 8 <> 0;
>  count
> -------
>      0

Yea, it seems we've started rewriting tables for SET WITHOUT OIDS a long time
ago:
	/*
	 * If we dropped the OID column, must adjust pg_class.relhasoids and tell
	 * Phase 3 to physically get rid of the column.  We formerly left the
	 * column in place physically, but this caused subtle problems.  See
	 * http://archives.postgresql.org/pgsql-hackers/2009-02/msg00363.php
	 */
	if (attnum == ObjectIdAttributeNumber)


I also verified that we don't allow SET WITHOUT OIDS when it's used as a row
type in another table.



> And also, if I try to pg_upgrade before SET WITHOUT OIDS, I get:
> 
> $ pg_upgrade -d pgdata11 -D pgdata -b ~/pg11/bin -B ~/pg/bin
> Performing Consistency Checks
> -----------------------------
> Checking cluster versions                                   ok
> Checking database user is the install user                  ok
> Checking database connection settings                       ok
> Checking for prepared transactions                          ok
> Checking for system-defined composite types in user tables  ok
> Checking for reg* data types in user tables                 ok
> Checking for contrib/isn with bigint-passing mismatch       ok
> Checking for user-defined encoding conversions              ok
> Checking for user-defined postfix operators                 ok
> Checking for incompatible polymorphic functions             ok
> Checking for tables WITH OIDS                               fatal
> 
> So, I'm not following how we could get a tuple with OIDs in versions after 11.

I don't see it either.  Wonder why I / decided to leave it :/.


> Should we get rid of HEAP_HASOID_OLD and the code that relates to it?

Looks like it.

Greetings,

Andres Freund


Re: Any reason to keep HEAP_HASOID_OLD?

От:
shihao zhong <zhong950419@gmail.com>
Дата:
Вложения:
> > Should we get rid of HEAP_HASOID_OLD and the code that relates to it?
>
> Looks like it.

Patch attached. It removes the define, the doc paragraph about the oid
field, and everything pageinspect did with it.

The bit is kept as a comment so nobody reuses it.

master only.

Thanks,
Shihao


Re: Any reason to keep HEAP_HASOID_OLD?

От:
David Rowley <dgrowleyml@gmail.com>
Дата:
Вложения:
On Wed, 21 Oct 2026 at 14:39, shihao zhong  wrote:
> Patch attached. It removes the define, the doc paragraph about the oid
> field, and everything pageinspect did with it.
>
> The bit is kept as a comment so nobody reuses it.

Thanks for the reminder. I've attached the patch I had pending for
this. I wasn't done and I've not looked at it in a while, but on
comparing to what you've got, you seem to have gone with removing the
pageinspect column. IIRC, I didn't think this was worth breaking any
user code that looks at the column. Instead, I just set it to NULL
always.

I seem to have missed some documentation things, which I'll look at
adjusting soon.

David

Re: Any reason to keep HEAP_HASOID_OLD?

От:
shihao zhong <zhong950419@gmail.com>
Дата:
Hi David,

Thanks. Keeping t_oid as an always NULL column makes sense to me.
Also leave pageinspect behavior today make sense as well.

Let's go with your patch.

I rechecked the related comments and documents, I think we need to

1. For storage.html, the paragraph after the HeapTupleHeaderData table.
Its first sentence lists "an optional object ID field". The sentences
from "The object ID is only present if the HEAP_HASOID_OLD bit is set"
to the end of the paragraph can go.

2. htup_details.h needs some clean work. the comment  still says
"If an OID field is present....."

3. For pageinspect.smgl, it point users to htup_details.h, may add something
like 
"t_oid is always NULL. Tuples no longer store an OID, and the column
is kept for compatibility."

Thanks,
Shihao






FAQ