summaryrefslogtreecommitdiff
path: root/contrib/postgres_fdw/deparse.c
diff options
context:
space:
mode:
authorNathan Bossart <nathan@postgresql.org>2025-06-30 15:38:54 -0500
committerNathan Bossart <nathan@postgresql.org>2025-06-30 15:38:54 -0500
commitbd09f024a1bbdd7a7e2ca944595a9d4b6c90fb83 (patch)
treec1dd8158c0ea270884fae796dd61dc3405ac249b /contrib/postgres_fdw/deparse.c
parentf20a347e1a613cfc9053e7bc3d254608ae968386 (diff)
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
Diffstat (limited to 'contrib/postgres_fdw/deparse.c')
-rw-r--r--contrib/postgres_fdw/deparse.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/contrib/postgres_fdw/deparse.c b/contrib/postgres_fdw/deparse.c
index d9970dd6753..9351835b5e4 100644
--- a/contrib/postgres_fdw/deparse.c
+++ b/contrib/postgres_fdw/deparse.c
@@ -39,6 +39,7 @@
#include "catalog/pg_aggregate.h"
#include "catalog/pg_authid.h"
#include "catalog/pg_collation.h"
+#include "catalog/pg_database.h"
#include "catalog/pg_namespace.h"
#include "catalog/pg_operator.h"
#include "catalog/pg_opfamily.h"
@@ -455,6 +456,11 @@ foreign_expr_walker(Node *node,
AuthIdRelationId, fpinfo))
return false;
break;
+ case REGDATABASEOID:
+ if (!is_shippable(DatumGetObjectId(c->constvalue),
+ DatabaseRelationId, fpinfo))
+ return false;
+ break;
}
}