diff options
author | Jeff Davis | 2025-03-25 18:16:06 +0000 |
---|---|---|
committer | Jeff Davis | 2025-03-25 18:16:06 +0000 |
commit | 650ab8aaf1957863ae14c80265e79f5d903b49fd (patch) | |
tree | 6ea530310dc773d82160cc6cc6d66893ab8ec910 /src/backend/statistics/stat_utils.c | |
parent | 2a420f7995e415f4813fccf1c42ab29a3a32182f (diff) |
Stats: use schemaname/relname instead of regclass.
For import and export, use schemaname/relname rather than
regclass.
This is more natural during export, fits with the other arguments
better, and it gives better control over error handling in case we
need to downgrade more errors to warnings.
Also, use text for the argument types for schemaname, relname, and
attname so that casts to "name" are not required.
Author: Corey Huinker <[email protected]>
Discussion: https://postgr.es/m/CADkLM=ceOSsx_=oe73QQ-BxUFR2Cwqum7-UP_fPe22DBY0NerA@mail.gmail.com
Diffstat (limited to 'src/backend/statistics/stat_utils.c')
-rw-r--r-- | src/backend/statistics/stat_utils.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/backend/statistics/stat_utils.c b/src/backend/statistics/stat_utils.c index 9647f5108b3..a9a3224efe6 100644 --- a/src/backend/statistics/stat_utils.c +++ b/src/backend/statistics/stat_utils.c @@ -18,6 +18,7 @@ #include "access/relation.h" #include "catalog/index.h" +#include "catalog/namespace.h" #include "catalog/pg_database.h" #include "funcapi.h" #include "miscadmin.h" @@ -214,6 +215,27 @@ stats_lock_check_privileges(Oid reloid) } /* + * Lookup relation oid from schema and relation name. + */ +Oid +stats_lookup_relid(const char *nspname, const char *relname) +{ + Oid nspoid; + Oid reloid; + + nspoid = LookupExplicitNamespace(nspname, false); + reloid = get_relname_relid(relname, nspoid); + if (!OidIsValid(reloid)) + ereport(ERROR, + (errcode(ERRCODE_UNDEFINED_TABLE), + errmsg("relation \"%s.%s\" does not exist", + nspname, relname))); + + return reloid; +} + + +/* * Find the argument number for the given argument name, returning -1 if not * found. */ |