Are OIDs for pg_types constant?

Started by Tyler Brockover 3 years ago3 messages
#1Tyler Brock
tyler.brock@gmail.com

Hi everyone,

I am writing a program that behaves like a Postgres backend and can see
that if I select oid from pg_type that the type old’s could be returned in
the Row Description message for the field’s data type and that seems to
work.

However, I didn’t read anywhere that these are guaranteed to be
constant/stable so I’d like to know if this is the case. For example: is
the old for pg_type bool = 16 on every instance of Postgres?

Also does there exist any documentation decoding what the pg_type fields
all mean?

Please let me know, thanks!

-Tyler

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Tyler Brock (#1)
Re: Are OIDs for pg_types constant?

Tyler Brock <tyler.brock@gmail.com> writes:

I am writing a program that behaves like a Postgres backend and can see
that if I select oid from pg_type that the type old’s could be returned in
the Row Description message for the field’s data type and that seems to
work.
However, I didn’t read anywhere that these are guaranteed to be
constant/stable so I’d like to know if this is the case. For example: is
the old for pg_type bool = 16 on every instance of Postgres?

Hand-assigned OIDs (those below 10000) are stable in released versions.
Those above 10K might vary across installations or PG versions. You
might find it interesting to read

https://www.postgresql.org/docs/current/system-catalog-initial-data.html#SYSTEM-CATALOG-OID-ASSIGNMENT

Also does there exist any documentation decoding what the pg_type fields
all mean?

https://www.postgresql.org/docs/current/catalog-pg-type.html

regards, tom lane

#3Tyler Brock
tyler.brock@gmail.com
In reply to: Tom Lane (#2)
Re: Are OIDs for pg_types constant?

Thank you Tom, this is exactly what I was looking for.

-Tyler

On Apr 20, 2022 at 11:23:59 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Show quoted text

Tyler Brock <tyler.brock@gmail.com> writes:

I am writing a program that behaves like a Postgres backend and can see

that if I select oid from pg_type that the type old’s could be returned in

the Row Description message for the field’s data type and that seems to

work.

However, I didn’t read anywhere that these are guaranteed to be

constant/stable so I’d like to know if this is the case. For example: is

the old for pg_type bool = 16 on every instance of Postgres?

Hand-assigned OIDs (those below 10000) are stable in released versions.
Those above 10K might vary across installations or PG versions. You
might find it interesting to read

https://www.postgresql.org/docs/current/system-catalog-initial-data.html#SYSTEM-CATALOG-OID-ASSIGNMENT

Also does there exist any documentation decoding what the pg_type fields

all mean?

https://www.postgresql.org/docs/current/catalog-pg-type.html

regards, tom lane