mirror of
https://github.com/postgres/postgres.git
synced 2025-11-04 20:11:56 +03:00
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
This commit is contained in:
@@ -4619,6 +4619,7 @@ convert_to_scalar(Datum value, Oid valuetypid, Oid collid, double *scaledvalue,
|
||||
case REGDICTIONARYOID:
|
||||
case REGROLEOID:
|
||||
case REGNAMESPACEOID:
|
||||
case REGDATABASEOID:
|
||||
*scaledvalue = convert_numeric_to_scalar(value, valuetypid,
|
||||
&failure);
|
||||
*scaledlobound = convert_numeric_to_scalar(lobound, boundstypid,
|
||||
@@ -4751,6 +4752,7 @@ convert_numeric_to_scalar(Datum value, Oid typid, bool *failure)
|
||||
case REGDICTIONARYOID:
|
||||
case REGROLEOID:
|
||||
case REGNAMESPACEOID:
|
||||
case REGDATABASEOID:
|
||||
/* we can treat OIDs as integers... */
|
||||
return (double) DatumGetObjectId(value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user