mirror of
https://github.com/postgres/postgres.git
synced 2025-10-28 11:55:03 +03:00
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 <corey.huinker@gmail.com> Discussion: https://postgr.es/m/CADkLM=ceOSsx_=oe73QQ-BxUFR2Cwqum7-UP_fPe22DBY0NerA@mail.gmail.com
This commit is contained in:
@@ -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"
|
||||
@@ -213,6 +214,27 @@ stats_lock_check_privileges(Oid reloid)
|
||||
relation_close(table, NoLock);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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.
|
||||
|
||||
Reference in New Issue
Block a user