pgsql: Add new OID alias type regdatabase.

From: Nathan Bossart <nathan(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Add new OID alias type regdatabase.
Date: 2025-06-30 20:40:38
Message-ID: E1uWLIs-0045Zc-1A@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Add new OID alias type regdatabase.

This provides a convenient way to look up a database's OID. For
example, the query

SELECT * FROM pg_shdepend
WHERE dbid = (SELECT oid FROM pg_database
WHERE datname = current_database());

can now be simplified to

SELECT * FROM pg_shdepend
WHERE dbid = current_database()::regdatabase;

Like the regrole type, regdatabase has cluster-wide scope, so we
disallow regdatabase constants from appearing in stored
expressions.

Bumps catversion.

Author: Ian Lawrence Barwick <barwick(at)gmail(dot)com>
Reviewed-by: Greg Sabino Mullane <htamfids(at)gmail(dot)com>
Reviewed-by: Jian He <jian(dot)universality(at)gmail(dot)com>
Reviewed-by: Fabrízio de Royes Mello <fabriziomello(at)gmail(dot)com>
Reviewed-by: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Discussion: https://postgr.es/m/aBpjJhyHpM2LYcG0%40nathan

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/bd09f024a1bbdd7a7e2ca944595a9d4b6c90fb83

Modified Files
--------------
contrib/postgres_fdw/deparse.c | 6 ++
doc/src/sgml/datatype.sgml | 15 ++-
doc/src/sgml/func.sgml | 17 +++
doc/src/sgml/ref/pgupgrade.sgml | 3 +-
src/backend/bootstrap/bootstrap.c | 2 +
src/backend/catalog/dependency.c | 11 ++
src/backend/utils/adt/regproc.c | 118 ++++++++++++++++++++
src/backend/utils/adt/selfuncs.c | 2 +
src/backend/utils/cache/catcache.c | 1 +
src/bin/pg_upgrade/check.c | 1 +
src/include/catalog/catversion.h | 2 +-
src/include/catalog/pg_cast.dat | 14 +++
src/include/catalog/pg_proc.dat | 17 +++
src/include/catalog/pg_type.dat | 5 +
src/test/regress/expected/regproc.out | 174 ++++++++++++++++++++++++++++++
src/test/regress/expected/type_sanity.out | 1 +
src/test/regress/sql/regproc.sql | 38 +++++++
src/test/regress/sql/type_sanity.sql | 1 +
18 files changed, 424 insertions(+), 4 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2025-06-30 21:06:46 pgsql: De-reserve keywords EXECUTE and STRICT in PL/pgSQL.
Previous Message Tomas Vondra 2025-06-30 18:56:43 Re: pgsql: Introduce pg_shmem_allocations_numa view