mirror of
https://github.com/postgres/postgres.git
synced 2025-09-03 15:22:11 +03:00
Refactor ownercheck functions
Instead of dozens of mostly-duplicate pg_foo_ownercheck() functions, write one common function object_ownercheck() that can handle almost all of them. We already have all the information we need, such as which system catalog corresponds to which catalog table and which column is the owner column. Reviewed-by: Corey Huinker <corey.huinker@gmail.com> Reviewed-by: Antonin Houska <ah@cybertec.at> Discussion: https://www.postgresql.org/message-id/flat/95c30f96-4060-2f48-98b5-a4392d3b6066@enterprisedb.com
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
#include "catalog/objectaccess.h"
|
||||
#include "catalog/partition.h"
|
||||
#include "catalog/pg_am.h"
|
||||
#include "catalog/pg_database.h"
|
||||
#include "catalog/pg_inherits.h"
|
||||
#include "catalog/toasting.h"
|
||||
#include "commands/cluster.h"
|
||||
@@ -364,7 +365,7 @@ cluster_rel(Oid tableOid, Oid indexOid, ClusterParams *params)
|
||||
if (recheck)
|
||||
{
|
||||
/* Check that the user still owns the relation */
|
||||
if (!pg_class_ownercheck(tableOid, save_userid))
|
||||
if (!object_ownercheck(RelationRelationId, tableOid, save_userid))
|
||||
{
|
||||
relation_close(OldHeap, AccessExclusiveLock);
|
||||
goto out;
|
||||
@@ -1641,7 +1642,7 @@ get_tables_to_cluster(MemoryContext cluster_context)
|
||||
|
||||
index = (Form_pg_index) GETSTRUCT(indexTuple);
|
||||
|
||||
if (!pg_class_ownercheck(index->indrelid, GetUserId()))
|
||||
if (!object_ownercheck(RelationRelationId, index->indrelid, GetUserId()))
|
||||
continue;
|
||||
|
||||
/* Use a permanent memory context for the result list */
|
||||
@@ -1690,8 +1691,8 @@ get_tables_to_cluster_partitioned(MemoryContext cluster_context, Oid indexOid)
|
||||
continue;
|
||||
|
||||
/* Silently skip partitions which the user has no access to. */
|
||||
if (!pg_class_ownercheck(relid, GetUserId()) &&
|
||||
(!pg_database_ownercheck(MyDatabaseId, GetUserId()) ||
|
||||
if (!object_ownercheck(RelationRelationId, relid, GetUserId()) &&
|
||||
(!object_ownercheck(DatabaseRelationId, MyDatabaseId, GetUserId()) ||
|
||||
IsSharedRelation(relid)))
|
||||
continue;
|
||||
|
||||
|
@@ -371,7 +371,7 @@ AlterCollation(AlterCollationStmt *stmt)
|
||||
(errmsg("cannot refresh version of default collation"),
|
||||
errhint("Use ALTER DATABASE ... REFRESH COLLATION VERSION instead.")));
|
||||
|
||||
if (!pg_collation_ownercheck(collOid, GetUserId()))
|
||||
if (!object_ownercheck(CollationRelationId, collOid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_COLLATION,
|
||||
NameListToString(stmt->collname));
|
||||
|
||||
|
@@ -972,7 +972,7 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
|
||||
*/
|
||||
if (!src_istemplate)
|
||||
{
|
||||
if (!pg_database_ownercheck(src_dboid, GetUserId()))
|
||||
if (!object_ownercheck(DatabaseRelationId, src_dboid, GetUserId()))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||
errmsg("permission denied to copy database \"%s\"",
|
||||
@@ -1549,7 +1549,7 @@ dropdb(const char *dbname, bool missing_ok, bool force)
|
||||
/*
|
||||
* Permission checks
|
||||
*/
|
||||
if (!pg_database_ownercheck(db_id, GetUserId()))
|
||||
if (!object_ownercheck(DatabaseRelationId, db_id, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_DATABASE,
|
||||
dbname);
|
||||
|
||||
@@ -1733,7 +1733,7 @@ RenameDatabase(const char *oldname, const char *newname)
|
||||
errmsg("database \"%s\" does not exist", oldname)));
|
||||
|
||||
/* must be owner */
|
||||
if (!pg_database_ownercheck(db_id, GetUserId()))
|
||||
if (!object_ownercheck(DatabaseRelationId, db_id, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_DATABASE,
|
||||
oldname);
|
||||
|
||||
@@ -1854,7 +1854,7 @@ movedb(const char *dbname, const char *tblspcname)
|
||||
/*
|
||||
* Permission checks
|
||||
*/
|
||||
if (!pg_database_ownercheck(db_id, GetUserId()))
|
||||
if (!object_ownercheck(DatabaseRelationId, db_id, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_DATABASE,
|
||||
dbname);
|
||||
|
||||
@@ -2281,7 +2281,7 @@ AlterDatabase(ParseState *pstate, AlterDatabaseStmt *stmt, bool isTopLevel)
|
||||
datform = (Form_pg_database) GETSTRUCT(tuple);
|
||||
dboid = datform->oid;
|
||||
|
||||
if (!pg_database_ownercheck(dboid, GetUserId()))
|
||||
if (!object_ownercheck(DatabaseRelationId, dboid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_DATABASE,
|
||||
stmt->dbname);
|
||||
|
||||
@@ -2364,7 +2364,7 @@ AlterDatabaseRefreshColl(AlterDatabaseRefreshCollStmt *stmt)
|
||||
datForm = (Form_pg_database) GETSTRUCT(tuple);
|
||||
db_id = datForm->oid;
|
||||
|
||||
if (!pg_database_ownercheck(db_id, GetUserId()))
|
||||
if (!object_ownercheck(DatabaseRelationId, db_id, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_DATABASE,
|
||||
stmt->dbname);
|
||||
|
||||
@@ -2427,7 +2427,7 @@ AlterDatabaseSet(AlterDatabaseSetStmt *stmt)
|
||||
*/
|
||||
shdepLockAndCheckObject(DatabaseRelationId, datid);
|
||||
|
||||
if (!pg_database_ownercheck(datid, GetUserId()))
|
||||
if (!object_ownercheck(DatabaseRelationId, datid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_DATABASE,
|
||||
stmt->dbname);
|
||||
|
||||
@@ -2490,7 +2490,7 @@ AlterDatabaseOwner(const char *dbname, Oid newOwnerId)
|
||||
HeapTuple newtuple;
|
||||
|
||||
/* Otherwise, must be owner of the existing object */
|
||||
if (!pg_database_ownercheck(db_id, GetUserId()))
|
||||
if (!object_ownercheck(DatabaseRelationId, db_id, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_DATABASE,
|
||||
dbname);
|
||||
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include "catalog/namespace.h"
|
||||
#include "catalog/objectaddress.h"
|
||||
#include "catalog/pg_class.h"
|
||||
#include "catalog/pg_namespace.h"
|
||||
#include "catalog/pg_proc.h"
|
||||
#include "commands/defrem.h"
|
||||
#include "miscadmin.h"
|
||||
@@ -105,7 +106,7 @@ RemoveObjects(DropStmt *stmt)
|
||||
/* Check permissions. */
|
||||
namespaceId = get_object_namespace(&address);
|
||||
if (!OidIsValid(namespaceId) ||
|
||||
!pg_namespace_ownercheck(namespaceId, GetUserId()))
|
||||
!object_ownercheck(NamespaceRelationId, namespaceId, GetUserId()))
|
||||
check_object_ownership(GetUserId(), stmt->removeType, address,
|
||||
object, relation);
|
||||
|
||||
|
@@ -379,7 +379,7 @@ AlterEventTrigger(AlterEventTrigStmt *stmt)
|
||||
evtForm = (Form_pg_event_trigger) GETSTRUCT(tup);
|
||||
trigoid = evtForm->oid;
|
||||
|
||||
if (!pg_event_trigger_ownercheck(trigoid, GetUserId()))
|
||||
if (!object_ownercheck(EventTriggerRelationId, trigoid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_EVENT_TRIGGER,
|
||||
stmt->trigname);
|
||||
|
||||
@@ -471,7 +471,7 @@ AlterEventTriggerOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
|
||||
if (form->evtowner == newOwnerId)
|
||||
return;
|
||||
|
||||
if (!pg_event_trigger_ownercheck(form->oid, GetUserId()))
|
||||
if (!object_ownercheck(EventTriggerRelationId, form->oid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_EVENT_TRIGGER,
|
||||
NameStr(form->evtname));
|
||||
|
||||
|
@@ -2727,7 +2727,7 @@ AlterExtensionNamespace(const char *extensionName, const char *newschema, Oid *o
|
||||
* Permission check: must own extension. Note that we don't bother to
|
||||
* check ownership of the individual member objects ...
|
||||
*/
|
||||
if (!pg_extension_ownercheck(extensionOid, GetUserId()))
|
||||
if (!object_ownercheck(ExtensionRelationId, extensionOid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_EXTENSION,
|
||||
extensionName);
|
||||
|
||||
@@ -2947,7 +2947,7 @@ ExecAlterExtensionStmt(ParseState *pstate, AlterExtensionStmt *stmt)
|
||||
table_close(extRel, AccessShareLock);
|
||||
|
||||
/* Permission check: must own extension */
|
||||
if (!pg_extension_ownercheck(extensionOid, GetUserId()))
|
||||
if (!object_ownercheck(ExtensionRelationId, extensionOid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_EXTENSION,
|
||||
stmt->extname);
|
||||
|
||||
@@ -3229,7 +3229,7 @@ ExecAlterExtensionContentsStmt(AlterExtensionContentsStmt *stmt,
|
||||
&relation, AccessShareLock, false);
|
||||
|
||||
/* Permission check: must own extension */
|
||||
if (!pg_extension_ownercheck(extension.objectId, GetUserId()))
|
||||
if (!object_ownercheck(ExtensionRelationId, extension.objectId, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_EXTENSION,
|
||||
stmt->extname);
|
||||
|
||||
|
@@ -358,7 +358,7 @@ AlterForeignServerOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
|
||||
srvId = form->oid;
|
||||
|
||||
/* Must be owner */
|
||||
if (!pg_foreign_server_ownercheck(srvId, GetUserId()))
|
||||
if (!object_ownercheck(ForeignServerRelationId, srvId, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_FOREIGN_SERVER,
|
||||
NameStr(form->srvname));
|
||||
|
||||
@@ -998,7 +998,7 @@ AlterForeignServer(AlterForeignServerStmt *stmt)
|
||||
/*
|
||||
* Only owner or a superuser can ALTER a SERVER.
|
||||
*/
|
||||
if (!pg_foreign_server_ownercheck(srvId, GetUserId()))
|
||||
if (!object_ownercheck(ForeignServerRelationId, srvId, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_FOREIGN_SERVER,
|
||||
stmt->servername);
|
||||
|
||||
@@ -1076,7 +1076,7 @@ user_mapping_ddl_aclcheck(Oid umuserid, Oid serverid, const char *servername)
|
||||
{
|
||||
Oid curuserid = GetUserId();
|
||||
|
||||
if (!pg_foreign_server_ownercheck(serverid, curuserid))
|
||||
if (!object_ownercheck(ForeignServerRelationId, serverid, curuserid))
|
||||
{
|
||||
if (umuserid == curuserid)
|
||||
{
|
||||
|
@@ -1377,7 +1377,7 @@ AlterFunction(ParseState *pstate, AlterFunctionStmt *stmt)
|
||||
procForm = (Form_pg_proc) GETSTRUCT(tup);
|
||||
|
||||
/* Permission check: must own function */
|
||||
if (!pg_proc_ownercheck(funcOid, GetUserId()))
|
||||
if (!object_ownercheck(ProcedureRelationId, funcOid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, stmt->objtype,
|
||||
NameListToString(stmt->func->objname));
|
||||
|
||||
@@ -1554,8 +1554,8 @@ CreateCast(CreateCastStmt *stmt)
|
||||
TypeNameToString(stmt->targettype))));
|
||||
|
||||
/* Permission check */
|
||||
if (!pg_type_ownercheck(sourcetypeid, GetUserId())
|
||||
&& !pg_type_ownercheck(targettypeid, GetUserId()))
|
||||
if (!object_ownercheck(TypeRelationId, sourcetypeid, GetUserId())
|
||||
&& !object_ownercheck(TypeRelationId, targettypeid, GetUserId()))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||
errmsg("must be owner of type %s or type %s",
|
||||
@@ -1838,7 +1838,7 @@ CreateTransform(CreateTransformStmt *stmt)
|
||||
errmsg("data type %s is a domain",
|
||||
TypeNameToString(stmt->type_name))));
|
||||
|
||||
if (!pg_type_ownercheck(typeid, GetUserId()))
|
||||
if (!object_ownercheck(TypeRelationId, typeid, GetUserId()))
|
||||
aclcheck_error_type(ACLCHECK_NOT_OWNER, typeid);
|
||||
|
||||
aclresult = pg_type_aclcheck(typeid, GetUserId(), ACL_USAGE);
|
||||
@@ -1861,7 +1861,7 @@ CreateTransform(CreateTransformStmt *stmt)
|
||||
{
|
||||
fromsqlfuncid = LookupFuncWithArgs(OBJECT_FUNCTION, stmt->fromsql, false);
|
||||
|
||||
if (!pg_proc_ownercheck(fromsqlfuncid, GetUserId()))
|
||||
if (!object_ownercheck(ProcedureRelationId, fromsqlfuncid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_FUNCTION, NameListToString(stmt->fromsql->objname));
|
||||
|
||||
aclresult = pg_proc_aclcheck(fromsqlfuncid, GetUserId(), ACL_EXECUTE);
|
||||
@@ -1887,7 +1887,7 @@ CreateTransform(CreateTransformStmt *stmt)
|
||||
{
|
||||
tosqlfuncid = LookupFuncWithArgs(OBJECT_FUNCTION, stmt->tosql, false);
|
||||
|
||||
if (!pg_proc_ownercheck(tosqlfuncid, GetUserId()))
|
||||
if (!object_ownercheck(ProcedureRelationId, tosqlfuncid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_FUNCTION, NameListToString(stmt->tosql->objname));
|
||||
|
||||
aclresult = pg_proc_aclcheck(tosqlfuncid, GetUserId(), ACL_EXECUTE);
|
||||
|
@@ -27,7 +27,9 @@
|
||||
#include "catalog/indexing.h"
|
||||
#include "catalog/pg_am.h"
|
||||
#include "catalog/pg_constraint.h"
|
||||
#include "catalog/pg_database.h"
|
||||
#include "catalog/pg_inherits.h"
|
||||
#include "catalog/pg_namespace.h"
|
||||
#include "catalog/pg_opclass.h"
|
||||
#include "catalog/pg_opfamily.h"
|
||||
#include "catalog/pg_tablespace.h"
|
||||
@@ -2790,7 +2792,7 @@ RangeVarCallbackForReindexIndex(const RangeVar *relation,
|
||||
errmsg("\"%s\" is not an index", relation->relname)));
|
||||
|
||||
/* Check permissions */
|
||||
if (!pg_class_ownercheck(relId, GetUserId()))
|
||||
if (!object_ownercheck(RelationRelationId, relId, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_INDEX, relation->relname);
|
||||
|
||||
/* Lock heap before index to avoid deadlock. */
|
||||
@@ -2914,7 +2916,7 @@ ReindexMultipleTables(const char *objectName, ReindexObjectType objectKind,
|
||||
{
|
||||
objectOid = get_namespace_oid(objectName, false);
|
||||
|
||||
if (!pg_namespace_ownercheck(objectOid, GetUserId()))
|
||||
if (!object_ownercheck(NamespaceRelationId, objectOid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_SCHEMA,
|
||||
objectName);
|
||||
}
|
||||
@@ -2926,7 +2928,7 @@ ReindexMultipleTables(const char *objectName, ReindexObjectType objectKind,
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("can only reindex the currently open database")));
|
||||
if (!pg_database_ownercheck(objectOid, GetUserId()))
|
||||
if (!object_ownercheck(DatabaseRelationId, objectOid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_DATABASE,
|
||||
get_database_name(objectOid));
|
||||
}
|
||||
@@ -3000,13 +3002,13 @@ ReindexMultipleTables(const char *objectName, ReindexObjectType objectKind,
|
||||
/*
|
||||
* The table can be reindexed if the user is superuser, the table
|
||||
* owner, or the database/schema owner (but in the latter case, only
|
||||
* if it's not a shared relation). pg_class_ownercheck includes the
|
||||
* if it's not a shared relation). object_ownercheck includes the
|
||||
* superuser case, and depending on objectKind we already know that
|
||||
* the user has permission to run REINDEX on this database or schema
|
||||
* per the permission checks at the beginning of this routine.
|
||||
*/
|
||||
if (classtuple->relisshared &&
|
||||
!pg_class_ownercheck(relid, GetUserId()))
|
||||
!object_ownercheck(RelationRelationId, relid, GetUserId()))
|
||||
continue;
|
||||
|
||||
/*
|
||||
|
@@ -421,7 +421,7 @@ DefineOpClass(CreateOpClassStmt *stmt)
|
||||
#ifdef NOT_USED
|
||||
/* XXX this is unnecessary given the superuser check above */
|
||||
/* Check we have ownership of the datatype */
|
||||
if (!pg_type_ownercheck(typeoid, GetUserId()))
|
||||
if (!object_ownercheck(TypeRelationId, typeoid, GetUserId()))
|
||||
aclcheck_error_type(ACLCHECK_NOT_OWNER, typeoid);
|
||||
#endif
|
||||
|
||||
@@ -513,11 +513,11 @@ DefineOpClass(CreateOpClassStmt *stmt)
|
||||
#ifdef NOT_USED
|
||||
/* XXX this is unnecessary given the superuser check above */
|
||||
/* Caller must own operator and its underlying function */
|
||||
if (!pg_oper_ownercheck(operOid, GetUserId()))
|
||||
if (!object_ownercheck(OperatorRelationId, operOid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_OPERATOR,
|
||||
get_opname(operOid));
|
||||
funcOid = get_opcode(operOid);
|
||||
if (!pg_proc_ownercheck(funcOid, GetUserId()))
|
||||
if (!object_ownercheck(ProcedureRelationId, funcOid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_FUNCTION,
|
||||
get_func_name(funcOid));
|
||||
#endif
|
||||
@@ -542,7 +542,7 @@ DefineOpClass(CreateOpClassStmt *stmt)
|
||||
#ifdef NOT_USED
|
||||
/* XXX this is unnecessary given the superuser check above */
|
||||
/* Caller must own function */
|
||||
if (!pg_proc_ownercheck(funcOid, GetUserId()))
|
||||
if (!object_ownercheck(ProcedureRelationId, funcOid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_FUNCTION,
|
||||
get_func_name(funcOid));
|
||||
#endif
|
||||
@@ -570,7 +570,7 @@ DefineOpClass(CreateOpClassStmt *stmt)
|
||||
#ifdef NOT_USED
|
||||
/* XXX this is unnecessary given the superuser check above */
|
||||
/* Check we have ownership of the datatype */
|
||||
if (!pg_type_ownercheck(storageoid, GetUserId()))
|
||||
if (!object_ownercheck(TypeRelationId, storageoid, GetUserId()))
|
||||
aclcheck_error_type(ACLCHECK_NOT_OWNER, storageoid);
|
||||
#endif
|
||||
break;
|
||||
@@ -930,11 +930,11 @@ AlterOpFamilyAdd(AlterOpFamilyStmt *stmt, Oid amoid, Oid opfamilyoid,
|
||||
#ifdef NOT_USED
|
||||
/* XXX this is unnecessary given the superuser check above */
|
||||
/* Caller must own operator and its underlying function */
|
||||
if (!pg_oper_ownercheck(operOid, GetUserId()))
|
||||
if (!object_ownercheck(OperatorRelationId, operOid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_OPERATOR,
|
||||
get_opname(operOid));
|
||||
funcOid = get_opcode(operOid);
|
||||
if (!pg_proc_ownercheck(funcOid, GetUserId()))
|
||||
if (!object_ownercheck(ProcedureRelationId, funcOid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_FUNCTION,
|
||||
get_func_name(funcOid));
|
||||
#endif
|
||||
@@ -964,7 +964,7 @@ AlterOpFamilyAdd(AlterOpFamilyStmt *stmt, Oid amoid, Oid opfamilyoid,
|
||||
#ifdef NOT_USED
|
||||
/* XXX this is unnecessary given the superuser check above */
|
||||
/* Caller must own function */
|
||||
if (!pg_proc_ownercheck(funcOid, GetUserId()))
|
||||
if (!object_ownercheck(ProcedureRelationId, funcOid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_FUNCTION,
|
||||
get_func_name(funcOid));
|
||||
#endif
|
||||
|
@@ -481,7 +481,7 @@ AlterOperator(AlterOperatorStmt *stmt)
|
||||
}
|
||||
|
||||
/* Check permissions. Must be owner. */
|
||||
if (!pg_oper_ownercheck(oprId, GetUserId()))
|
||||
if (!object_ownercheck(OperatorRelationId, oprId, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_OPERATOR,
|
||||
NameStr(oprForm->oprname));
|
||||
|
||||
|
@@ -79,7 +79,7 @@ RangeVarCallbackForPolicy(const RangeVar *rv, Oid relid, Oid oldrelid,
|
||||
relkind = classform->relkind;
|
||||
|
||||
/* Must own relation. */
|
||||
if (!pg_class_ownercheck(relid, GetUserId()))
|
||||
if (!object_ownercheck(RelationRelationId, relid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, get_relkind_objtype(get_rel_relkind(relid)), rv->relname);
|
||||
|
||||
/* No system table modifications unless explicitly allowed. */
|
||||
|
@@ -134,7 +134,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
|
||||
|
||||
/* This is currently pointless, since we already checked superuser */
|
||||
#ifdef NOT_USED
|
||||
if (!pg_language_ownercheck(oldform->oid, languageOwner))
|
||||
if (!object_ownercheck(LanguageRelationId, oldform->oid, languageOwner))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_LANGUAGE,
|
||||
languageName);
|
||||
#endif
|
||||
|
@@ -1394,7 +1394,7 @@ AlterPublication(ParseState *pstate, AlterPublicationStmt *stmt)
|
||||
pubform = (Form_pg_publication) GETSTRUCT(tup);
|
||||
|
||||
/* must be owner */
|
||||
if (!pg_publication_ownercheck(pubform->oid, GetUserId()))
|
||||
if (!object_ownercheck(PublicationRelationId, pubform->oid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_PUBLICATION,
|
||||
stmt->pubname);
|
||||
|
||||
@@ -1764,7 +1764,7 @@ PublicationAddTables(Oid pubid, List *rels, bool if_not_exists,
|
||||
ObjectAddress obj;
|
||||
|
||||
/* Must be owner of the table or superuser. */
|
||||
if (!pg_class_ownercheck(RelationGetRelid(rel), GetUserId()))
|
||||
if (!object_ownercheck(RelationRelationId, RelationGetRelid(rel), GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, get_relkind_objtype(rel->rd_rel->relkind),
|
||||
RelationGetRelationName(rel));
|
||||
|
||||
@@ -1905,7 +1905,7 @@ AlterPublicationOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
|
||||
AclResult aclresult;
|
||||
|
||||
/* Must be owner */
|
||||
if (!pg_publication_ownercheck(form->oid, GetUserId()))
|
||||
if (!object_ownercheck(PublicationRelationId, form->oid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_PUBLICATION,
|
||||
NameStr(form->pubname));
|
||||
|
||||
|
@@ -254,7 +254,7 @@ RenameSchema(const char *oldname, const char *newname)
|
||||
errmsg("schema \"%s\" already exists", newname)));
|
||||
|
||||
/* must be owner */
|
||||
if (!pg_namespace_ownercheck(nspOid, GetUserId()))
|
||||
if (!object_ownercheck(NamespaceRelationId, nspOid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_SCHEMA,
|
||||
oldname);
|
||||
|
||||
@@ -364,7 +364,7 @@ AlterSchemaOwner_internal(HeapTuple tup, Relation rel, Oid newOwnerId)
|
||||
AclResult aclresult;
|
||||
|
||||
/* Otherwise, must be owner of the existing object */
|
||||
if (!pg_namespace_ownercheck(nspForm->oid, GetUserId()))
|
||||
if (!object_ownercheck(NamespaceRelationId, nspForm->oid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_SCHEMA,
|
||||
NameStr(nspForm->nspname));
|
||||
|
||||
|
@@ -138,7 +138,7 @@ CreateStatistics(CreateStatsStmt *stmt)
|
||||
errdetail_relkind_not_supported(rel->rd_rel->relkind)));
|
||||
|
||||
/* You must own the relation to create stats on it */
|
||||
if (!pg_class_ownercheck(RelationGetRelid(rel), stxowner))
|
||||
if (!object_ownercheck(RelationRelationId, RelationGetRelid(rel), stxowner))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, get_relkind_objtype(rel->rd_rel->relkind),
|
||||
RelationGetRelationName(rel));
|
||||
|
||||
@@ -665,7 +665,7 @@ AlterStatistics(AlterStatsStmt *stmt)
|
||||
elog(ERROR, "cache lookup failed for extended statistics object %u", stxoid);
|
||||
|
||||
/* Must be owner of the existing statistics object */
|
||||
if (!pg_statistics_object_ownercheck(stxoid, GetUserId()))
|
||||
if (!object_ownercheck(StatisticExtRelationId, stxoid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_STATISTIC_EXT,
|
||||
NameListToString(stmt->defnames));
|
||||
|
||||
|
@@ -1032,7 +1032,7 @@ AlterSubscription(ParseState *pstate, AlterSubscriptionStmt *stmt,
|
||||
subid = form->oid;
|
||||
|
||||
/* must be owner */
|
||||
if (!pg_subscription_ownercheck(subid, GetUserId()))
|
||||
if (!object_ownercheck(SubscriptionRelationId, subid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_SUBSCRIPTION,
|
||||
stmt->subname);
|
||||
|
||||
@@ -1418,7 +1418,7 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel)
|
||||
subid = form->oid;
|
||||
|
||||
/* must be owner */
|
||||
if (!pg_subscription_ownercheck(subid, GetUserId()))
|
||||
if (!object_ownercheck(SubscriptionRelationId, subid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_SUBSCRIPTION,
|
||||
stmt->subname);
|
||||
|
||||
@@ -1709,7 +1709,7 @@ AlterSubscriptionOwner_internal(Relation rel, HeapTuple tup, Oid newOwnerId)
|
||||
if (form->subowner == newOwnerId)
|
||||
return;
|
||||
|
||||
if (!pg_subscription_ownercheck(form->oid, GetUserId()))
|
||||
if (!object_ownercheck(SubscriptionRelationId, form->oid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_SUBSCRIPTION,
|
||||
NameStr(form->subname));
|
||||
|
||||
|
@@ -1572,8 +1572,8 @@ RangeVarCallbackForDropRelation(const RangeVar *rel, Oid relOid, Oid oldRelOid,
|
||||
state->expected_relkind);
|
||||
|
||||
/* Allow DROP to either table owner or schema owner */
|
||||
if (!pg_class_ownercheck(relOid, GetUserId()) &&
|
||||
!pg_namespace_ownercheck(classform->relnamespace, GetUserId()))
|
||||
if (!object_ownercheck(RelationRelationId, relOid, GetUserId()) &&
|
||||
!object_ownercheck(NamespaceRelationId, classform->relnamespace, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER,
|
||||
get_relkind_objtype(classform->relkind),
|
||||
rel->relname);
|
||||
@@ -1877,7 +1877,7 @@ ExecuteTruncateGuts(List *explicit_rels,
|
||||
seq_rel = relation_open(seq_relid, AccessExclusiveLock);
|
||||
|
||||
/* This check must match AlterSequence! */
|
||||
if (!pg_class_ownercheck(seq_relid, GetUserId()))
|
||||
if (!object_ownercheck(RelationRelationId, seq_relid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_SEQUENCE,
|
||||
RelationGetRelationName(seq_rel));
|
||||
|
||||
@@ -2514,7 +2514,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
|
||||
* We should have an UNDER permission flag for this, but for now,
|
||||
* demand that creator of a child table own the parent.
|
||||
*/
|
||||
if (!pg_class_ownercheck(RelationGetRelid(relation), GetUserId()))
|
||||
if (!object_ownercheck(RelationRelationId, RelationGetRelid(relation), GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, get_relkind_objtype(relation->rd_rel->relkind),
|
||||
RelationGetRelationName(relation));
|
||||
|
||||
@@ -3418,7 +3418,7 @@ renameatt_check(Oid myrelid, Form_pg_class classform, bool recursing)
|
||||
/*
|
||||
* permissions checking. only the owner of a class can change its schema.
|
||||
*/
|
||||
if (!pg_class_ownercheck(myrelid, GetUserId()))
|
||||
if (!object_ownercheck(RelationRelationId, myrelid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, get_relkind_objtype(get_rel_relkind(myrelid)),
|
||||
NameStr(classform->relname));
|
||||
if (!allowSystemTableMods && IsSystemClass(myrelid, classform))
|
||||
@@ -6307,7 +6307,7 @@ ATSimplePermissions(AlterTableType cmdtype, Relation rel, int allowed_targets)
|
||||
}
|
||||
|
||||
/* Permissions checks */
|
||||
if (!pg_class_ownercheck(RelationGetRelid(rel), GetUserId()))
|
||||
if (!object_ownercheck(RelationRelationId, RelationGetRelid(rel), GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, get_relkind_objtype(rel->rd_rel->relkind),
|
||||
RelationGetRelationName(rel));
|
||||
|
||||
@@ -13828,7 +13828,7 @@ ATExecChangeOwner(Oid relationOid, Oid newOwnerId, bool recursing, LOCKMODE lock
|
||||
AclResult aclresult;
|
||||
|
||||
/* Otherwise, must be owner of the existing object */
|
||||
if (!pg_class_ownercheck(relationOid, GetUserId()))
|
||||
if (!object_ownercheck(RelationRelationId, relationOid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, get_relkind_objtype(get_rel_relkind(relationOid)),
|
||||
RelationGetRelationName(target_rel));
|
||||
|
||||
@@ -14618,7 +14618,7 @@ AlterTableMoveAll(AlterTableMoveAllStmt *stmt)
|
||||
*
|
||||
* Caller must be considered an owner on the table to move it.
|
||||
*/
|
||||
if (!pg_class_ownercheck(relOid, GetUserId()))
|
||||
if (!object_ownercheck(RelationRelationId, relOid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, get_relkind_objtype(get_rel_relkind(relOid)),
|
||||
NameStr(relForm->relname));
|
||||
|
||||
@@ -16953,7 +16953,7 @@ RangeVarCallbackOwnsTable(const RangeVar *relation,
|
||||
errmsg("\"%s\" is not a table or materialized view", relation->relname)));
|
||||
|
||||
/* Check permissions */
|
||||
if (!pg_class_ownercheck(relId, GetUserId()))
|
||||
if (!object_ownercheck(RelationRelationId, relId, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, get_relkind_objtype(get_rel_relkind(relId)), relation->relname);
|
||||
}
|
||||
|
||||
@@ -16998,7 +16998,7 @@ RangeVarCallbackOwnsRelation(const RangeVar *relation,
|
||||
if (!HeapTupleIsValid(tuple)) /* should not happen */
|
||||
elog(ERROR, "cache lookup failed for relation %u", relId);
|
||||
|
||||
if (!pg_class_ownercheck(relId, GetUserId()))
|
||||
if (!object_ownercheck(RelationRelationId, relId, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, get_relkind_objtype(get_rel_relkind(relId)),
|
||||
relation->relname);
|
||||
|
||||
@@ -17034,7 +17034,7 @@ RangeVarCallbackForAlterRelation(const RangeVar *rv, Oid relid, Oid oldrelid,
|
||||
relkind = classform->relkind;
|
||||
|
||||
/* Must own relation. */
|
||||
if (!pg_class_ownercheck(relid, GetUserId()))
|
||||
if (!object_ownercheck(RelationRelationId, relid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, get_relkind_objtype(get_rel_relkind(relid)), rv->relname);
|
||||
|
||||
/* No system table modifications unless explicitly allowed. */
|
||||
|
@@ -446,7 +446,7 @@ DropTableSpace(DropTableSpaceStmt *stmt)
|
||||
tablespaceoid = spcform->oid;
|
||||
|
||||
/* Must be tablespace owner */
|
||||
if (!pg_tablespace_ownercheck(tablespaceoid, GetUserId()))
|
||||
if (!object_ownercheck(TableSpaceRelationId, tablespaceoid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_TABLESPACE,
|
||||
tablespacename);
|
||||
|
||||
@@ -966,7 +966,7 @@ RenameTableSpace(const char *oldname, const char *newname)
|
||||
table_endscan(scan);
|
||||
|
||||
/* Must be owner */
|
||||
if (!pg_tablespace_ownercheck(tspId, GetUserId()))
|
||||
if (!object_ownercheck(TableSpaceRelationId, tspId, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NO_PRIV, OBJECT_TABLESPACE, oldname);
|
||||
|
||||
/* Validate new name */
|
||||
@@ -1051,7 +1051,7 @@ AlterTableSpaceOptions(AlterTableSpaceOptionsStmt *stmt)
|
||||
tablespaceoid = ((Form_pg_tablespace) GETSTRUCT(tup))->oid;
|
||||
|
||||
/* Must be owner of the existing object */
|
||||
if (!pg_tablespace_ownercheck(tablespaceoid, GetUserId()))
|
||||
if (!object_ownercheck(TableSpaceRelationId, tablespaceoid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_TABLESPACE,
|
||||
stmt->tablespacename);
|
||||
|
||||
|
@@ -1445,7 +1445,7 @@ RangeVarCallbackForRenameTrigger(const RangeVar *rv, Oid relid, Oid oldrelid,
|
||||
errdetail_relkind_not_supported(form->relkind)));
|
||||
|
||||
/* you must own the table to rename one of its triggers */
|
||||
if (!pg_class_ownercheck(relid, GetUserId()))
|
||||
if (!object_ownercheck(RelationRelationId, relid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, get_relkind_objtype(get_rel_relkind(relid)), rv->relname);
|
||||
if (!allowSystemTableMods && IsSystemClass(relid, form))
|
||||
ereport(ERROR,
|
||||
|
@@ -510,7 +510,7 @@ AlterTSDictionary(AlterTSDictionaryStmt *stmt)
|
||||
dictId);
|
||||
|
||||
/* must be owner */
|
||||
if (!pg_ts_dict_ownercheck(dictId, GetUserId()))
|
||||
if (!object_ownercheck(TSDictionaryRelationId, dictId, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_TSDICTIONARY,
|
||||
NameListToString(stmt->dictname));
|
||||
|
||||
@@ -1124,7 +1124,7 @@ AlterTSConfiguration(AlterTSConfigurationStmt *stmt)
|
||||
cfgId = ((Form_pg_ts_config) GETSTRUCT(tup))->oid;
|
||||
|
||||
/* must be owner */
|
||||
if (!pg_ts_config_ownercheck(cfgId, GetUserId()))
|
||||
if (!object_ownercheck(TSConfigRelationId, cfgId, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_TSCONFIGURATION,
|
||||
NameListToString(stmt->cfgname));
|
||||
|
||||
|
@@ -525,28 +525,28 @@ DefineType(ParseState *pstate, List *names, List *parameters)
|
||||
* findTypeInputFunction et al, where they could be shared by AlterType.
|
||||
*/
|
||||
#ifdef NOT_USED
|
||||
if (inputOid && !pg_proc_ownercheck(inputOid, GetUserId()))
|
||||
if (inputOid && !object_ownercheck(ProcedureRelationId, inputOid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_FUNCTION,
|
||||
NameListToString(inputName));
|
||||
if (outputOid && !pg_proc_ownercheck(outputOid, GetUserId()))
|
||||
if (outputOid && !object_ownercheck(ProcedureRelationId, outputOid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_FUNCTION,
|
||||
NameListToString(outputName));
|
||||
if (receiveOid && !pg_proc_ownercheck(receiveOid, GetUserId()))
|
||||
if (receiveOid && !object_ownercheck(ProcedureRelationId, receiveOid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_FUNCTION,
|
||||
NameListToString(receiveName));
|
||||
if (sendOid && !pg_proc_ownercheck(sendOid, GetUserId()))
|
||||
if (sendOid && !object_ownercheck(ProcedureRelationId, sendOid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_FUNCTION,
|
||||
NameListToString(sendName));
|
||||
if (typmodinOid && !pg_proc_ownercheck(typmodinOid, GetUserId()))
|
||||
if (typmodinOid && !object_ownercheck(ProcedureRelationId, typmodinOid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_FUNCTION,
|
||||
NameListToString(typmodinName));
|
||||
if (typmodoutOid && !pg_proc_ownercheck(typmodoutOid, GetUserId()))
|
||||
if (typmodoutOid && !object_ownercheck(ProcedureRelationId, typmodoutOid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_FUNCTION,
|
||||
NameListToString(typmodoutName));
|
||||
if (analyzeOid && !pg_proc_ownercheck(analyzeOid, GetUserId()))
|
||||
if (analyzeOid && !object_ownercheck(ProcedureRelationId, analyzeOid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_FUNCTION,
|
||||
NameListToString(analyzeName));
|
||||
if (subscriptOid && !pg_proc_ownercheck(subscriptOid, GetUserId()))
|
||||
if (subscriptOid && !object_ownercheck(ProcedureRelationId, subscriptOid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_FUNCTION,
|
||||
NameListToString(subscriptName));
|
||||
#endif
|
||||
@@ -1318,7 +1318,7 @@ checkEnumOwner(HeapTuple tup)
|
||||
format_type_be(typTup->oid))));
|
||||
|
||||
/* Permission check: must own type */
|
||||
if (!pg_type_ownercheck(typTup->oid, GetUserId()))
|
||||
if (!object_ownercheck(TypeRelationId, typTup->oid, GetUserId()))
|
||||
aclcheck_error_type(ACLCHECK_NOT_OWNER, typTup->oid);
|
||||
}
|
||||
|
||||
@@ -3430,7 +3430,7 @@ checkDomainOwner(HeapTuple tup)
|
||||
format_type_be(typTup->oid))));
|
||||
|
||||
/* Permission check: must own type */
|
||||
if (!pg_type_ownercheck(typTup->oid, GetUserId()))
|
||||
if (!object_ownercheck(TypeRelationId, typTup->oid, GetUserId()))
|
||||
aclcheck_error_type(ACLCHECK_NOT_OWNER, typTup->oid);
|
||||
}
|
||||
|
||||
@@ -3618,7 +3618,7 @@ RenameType(RenameStmt *stmt)
|
||||
typTup = (Form_pg_type) GETSTRUCT(tup);
|
||||
|
||||
/* check permissions on type */
|
||||
if (!pg_type_ownercheck(typeOid, GetUserId()))
|
||||
if (!object_ownercheck(TypeRelationId, typeOid, GetUserId()))
|
||||
aclcheck_error_type(ACLCHECK_NOT_OWNER, typeOid);
|
||||
|
||||
/* ALTER DOMAIN used on a non-domain? */
|
||||
@@ -3741,7 +3741,7 @@ AlterTypeOwner(List *names, Oid newOwnerId, ObjectType objecttype)
|
||||
if (!superuser())
|
||||
{
|
||||
/* Otherwise, must be owner of the existing object */
|
||||
if (!pg_type_ownercheck(typTup->oid, GetUserId()))
|
||||
if (!object_ownercheck(TypeRelationId, typTup->oid, GetUserId()))
|
||||
aclcheck_error_type(ACLCHECK_NOT_OWNER, typTup->oid);
|
||||
|
||||
/* Must be able to become new owner */
|
||||
@@ -3916,7 +3916,7 @@ AlterTypeNamespace_oid(Oid typeOid, Oid nspOid, ObjectAddresses *objsMoved)
|
||||
Oid elemOid;
|
||||
|
||||
/* check permissions on type */
|
||||
if (!pg_type_ownercheck(typeOid, GetUserId()))
|
||||
if (!object_ownercheck(TypeRelationId, typeOid, GetUserId()))
|
||||
aclcheck_error_type(ACLCHECK_NOT_OWNER, typeOid);
|
||||
|
||||
/* don't allow direct alteration of array types */
|
||||
@@ -4277,7 +4277,7 @@ AlterType(AlterTypeStmt *stmt)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!pg_type_ownercheck(typeOid, GetUserId()))
|
||||
if (!object_ownercheck(TypeRelationId, typeOid, GetUserId()))
|
||||
aclcheck_error_type(ACLCHECK_NOT_OWNER, typeOid);
|
||||
}
|
||||
|
||||
|
@@ -956,7 +956,7 @@ AlterRoleSet(AlterRoleSetStmt *stmt)
|
||||
* If no role is specified, then this is effectively the same as
|
||||
* ALTER DATABASE ... SET, so use the same permission check.
|
||||
*/
|
||||
if (!pg_database_ownercheck(databaseid, GetUserId()))
|
||||
if (!object_ownercheck(DatabaseRelationId, databaseid, GetUserId()))
|
||||
aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_DATABASE,
|
||||
stmt->database);
|
||||
}
|
||||
@@ -1586,7 +1586,7 @@ AddRoleMems(const char *rolename, Oid roleid,
|
||||
* The charter of pg_database_owner is to have exactly one, implicit,
|
||||
* situation-dependent member. There's no technical need for this
|
||||
* restriction. (One could lift it and take the further step of making
|
||||
* pg_database_ownercheck() equivalent to has_privs_of_role(roleid,
|
||||
* object_ownercheck(DatabaseRelationId, ...) equivalent to has_privs_of_role(roleid,
|
||||
* ROLE_PG_DATABASE_OWNER), in which case explicit, situation-independent
|
||||
* members could act as the owner of any database.)
|
||||
*/
|
||||
|
@@ -565,14 +565,14 @@ vacuum_is_relation_owner(Oid relid, Form_pg_class reltuple, bits32 options)
|
||||
*
|
||||
* We allow the user to vacuum or analyze a table if he is superuser, the
|
||||
* table owner, or the database owner (but in the latter case, only if
|
||||
* it's not a shared relation). pg_class_ownercheck includes the
|
||||
* it's not a shared relation). object_ownercheck includes the
|
||||
* superuser case.
|
||||
*
|
||||
* Note we choose to treat permissions failure as a WARNING and keep
|
||||
* trying to vacuum or analyze the rest of the DB --- is this appropriate?
|
||||
*/
|
||||
if (pg_class_ownercheck(relid, GetUserId()) ||
|
||||
(pg_database_ownercheck(MyDatabaseId, GetUserId()) && !reltuple->relisshared))
|
||||
if (object_ownercheck(RelationRelationId, relid, GetUserId()) ||
|
||||
(object_ownercheck(DatabaseRelationId, MyDatabaseId, GetUserId()) && !reltuple->relisshared))
|
||||
return true;
|
||||
|
||||
relname = NameStr(reltuple->relname);
|
||||
|
Reference in New Issue
Block a user