Add new OID alias type regdatabase.
Nathan Bossart <nathan@postgresql.org>
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
Files
| Path | Change | +/− |
|---|---|---|
| contrib/postgres_fdw/deparse.c | modified | +6 −0 |
| doc/src/sgml/datatype.sgml | modified | +13 −2 |
| doc/src/sgml/func.sgml | modified | +17 −0 |
| doc/src/sgml/ref/pgupgrade.sgml | modified | +2 −1 |
| src/backend/bootstrap/bootstrap.c | modified | +2 −0 |
| src/backend/catalog/dependency.c | modified | +11 −0 |
| src/backend/utils/adt/regproc.c | modified | +118 −0 |
| src/backend/utils/adt/selfuncs.c | modified | +2 −0 |
| src/backend/utils/cache/catcache.c | modified | +1 −0 |
| src/bin/pg_upgrade/check.c | modified | +1 −0 |
| src/include/catalog/catversion.h | modified | +1 −1 |
| src/include/catalog/pg_cast.dat | modified | +14 −0 |
| src/include/catalog/pg_proc.dat | modified | +17 −0 |
| src/include/catalog/pg_type.dat | modified | +5 −0 |
| src/test/regress/expected/regproc.out | modified | +174 −0 |
| src/test/regress/expected/type_sanity.out | modified | +1 −0 |
| src/test/regress/sql/regproc.sql | modified | +38 −0 |
| src/test/regress/sql/type_sanity.sql | modified | +1 −0 |
Discussion
- regdatabase 23 messages · 2025-05-06 → 2025-06-30