From b59d2fe4970e689a50e802960ef0812acaf88221 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Sun, 17 Jul 2011 23:23:55 -0400 Subject: [PATCH] Add pg_opfamily_is_visible. We already have similar functions for many other object types, including operator classes, so it seems like we should have this one, too. Extracted from a larger patch by Josh Kupershmidt --- doc/src/sgml/func.sgml | 9 +++++++++ src/backend/catalog/namespace.c | 12 ++++++++++++ src/include/catalog/catversion.h | 2 +- src/include/catalog/pg_proc.h | 2 ++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index e7dcaca3b0..4c163366b2 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -13109,6 +13109,12 @@ SELECT relname FROM pg_class WHERE pg_table_is_visible(oid); boolean is operator visible in search path + + pg_opfamily_is_visible(opclass_oid) + + boolean + is operator family visible in search path + pg_table_is_visible(table_oid) @@ -13164,6 +13170,9 @@ SELECT relname FROM pg_class WHERE pg_table_is_visible(oid); pg_operator_is_visible + + pg_opfamily_is_visible + pg_table_is_visible diff --git a/src/backend/catalog/namespace.c b/src/backend/catalog/namespace.c index 8d426951ba..dec608c907 100644 --- a/src/backend/catalog/namespace.c +++ b/src/backend/catalog/namespace.c @@ -202,6 +202,7 @@ Datum pg_type_is_visible(PG_FUNCTION_ARGS); Datum pg_function_is_visible(PG_FUNCTION_ARGS); Datum pg_operator_is_visible(PG_FUNCTION_ARGS); Datum pg_opclass_is_visible(PG_FUNCTION_ARGS); +Datum pg_opfamily_is_visible(PG_FUNCTION_ARGS); Datum pg_collation_is_visible(PG_FUNCTION_ARGS); Datum pg_conversion_is_visible(PG_FUNCTION_ARGS); Datum pg_ts_parser_is_visible(PG_FUNCTION_ARGS); @@ -3897,6 +3898,17 @@ pg_opclass_is_visible(PG_FUNCTION_ARGS) PG_RETURN_BOOL(OpclassIsVisible(oid)); } +Datum +pg_opfamily_is_visible(PG_FUNCTION_ARGS) +{ + Oid oid = PG_GETARG_OID(0); + + if (!SearchSysCacheExists1(OPFAMILYOID, ObjectIdGetDatum(oid))) + PG_RETURN_NULL(); + + PG_RETURN_BOOL(OpfamilyIsVisible(oid)); +} + Datum pg_collation_is_visible(PG_FUNCTION_ARGS) { diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index 34e30aa1d4..57becb4fe5 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 201107031 +#define CATALOG_VERSION_NO 201107171 #endif diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index 16dc70f6fa..cc436e34ed 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -2829,6 +2829,8 @@ DATA(insert OID = 2082 ( pg_operator_is_visible PGNSP PGUID 12 1 0 0 0 f f f t DESCR("is operator visible in search path?"); DATA(insert OID = 2083 ( pg_opclass_is_visible PGNSP PGUID 12 1 0 0 0 f f f t f s 1 0 16 "26" _null_ _null_ _null_ _null_ pg_opclass_is_visible _null_ _null_ _null_ )); DESCR("is opclass visible in search path?"); +DATA(insert OID = 3829 ( pg_opfamily_is_visible PGNSP PGUID 12 1 0 0 0 f f f t f s 1 0 16 "26" _null_ _null_ _null_ _null_ pg_opfamily_is_visible _null_ _null_ _null_ )); +DESCR("is opfamily visible in search path?"); DATA(insert OID = 2093 ( pg_conversion_is_visible PGNSP PGUID 12 1 0 0 0 f f f t f s 1 0 16 "26" _null_ _null_ _null_ _null_ pg_conversion_is_visible _null_ _null_ _null_ )); DESCR("is conversion visible in search path?"); DATA(insert OID = 3756 ( pg_ts_parser_is_visible PGNSP PGUID 12 1 0 0 0 f f f t f s 1 0 16 "26" _null_ _null_ _null_ _null_ pg_ts_parser_is_visible _null_ _null_ _null_ ));