pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Nathan Bossart <nathan@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Add new OID alias type regdatabase.
Date: Mon, 30 Jun 2025 20:40:38 +0000
Message-ID: <E1uWLIs-0045Zc-1A@gemulon.postgresql.org> (raw)

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@gmail.com>
Reviewed-by: Greg Sabino Mullane <htamfids@gmail.com>
Reviewed-by: Jian He <jian.universality@gmail.com>
Reviewed-by: Fabrízio de Royes Mello <fabriziomello@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.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(-)



Message-ID: <E1uWLIs-0045Zc-1A@gemulon.postgresql.org>
Permalink:  ../E1uWLIs-0045Zc-1A@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1uWLIs-0045Zc-1A@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: nathan@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Add new OID alias type regdatabase.
  In-Reply-To: <E1uWLIs-0045Zc-1A@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox