26#include "catalog/pg_database_d.h"
82 case EventTriggerRelationId:
83 msgfmt =
gettext_noop(
"event trigger \"%s\" already exists");
85 case ForeignDataWrapperRelationId:
86 msgfmt =
gettext_noop(
"foreign-data wrapper \"%s\" already exists");
88 case ForeignServerRelationId:
91 case LanguageRelationId:
94 case PublicationRelationId:
95 msgfmt =
gettext_noop(
"publication \"%s\" already exists");
97 case SubscriptionRelationId:
98 msgfmt =
gettext_noop(
"subscription \"%s\" already exists");
101 elog(
ERROR,
"unsupported object class: %u", classId);
119 case ConversionRelationId:
121 msgfmt =
gettext_noop(
"conversion \"%s\" already exists in schema \"%s\"");
123 case StatisticExtRelationId:
125 msgfmt =
gettext_noop(
"statistics object \"%s\" already exists in schema \"%s\"");
127 case TSParserRelationId:
129 msgfmt =
gettext_noop(
"text search parser \"%s\" already exists in schema \"%s\"");
131 case TSDictionaryRelationId:
133 msgfmt =
gettext_noop(
"text search dictionary \"%s\" already exists in schema \"%s\"");
135 case TSTemplateRelationId:
137 msgfmt =
gettext_noop(
"text search template \"%s\" already exists in schema \"%s\"");
139 case TSConfigRelationId:
141 msgfmt =
gettext_noop(
"text search configuration \"%s\" already exists in schema \"%s\"");
144 elog(
ERROR,
"unsupported object class: %u", classId);
188 elog(
ERROR,
"cache lookup failed for object %u of catalog \"%s\"",
197 if (Anum_namespace > 0)
213 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
214 errmsg(
"must be superuser to rename %s",
237 if (classId == SubscriptionRelationId)
253 if (!form->subpasswordrequired && !
superuser())
255 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
256 errmsg(
"password_required=false is superuser-only"),
257 errhint(
"Subscriptions with the password_required option set to false may only be created or modified by the superuser.")));
266 if (classId == ProcedureRelationId)
271 &proc->proargtypes, proc->pronamespace);
273 else if (classId == CollationRelationId)
279 else if (classId == OperatorClassRelationId)
286 else if (classId == OperatorFamilyRelationId)
293 else if (classId == SubscriptionRelationId)
301#ifdef ENFORCE_REGRESSION_TEST_NAME_RESTRICTIONS
302 if (strncmp(new_name,
"regress_", 8) != 0)
303 elog(
WARNING,
"subscriptions created by regression test cases should have names starting with \"regress_\"");
309 else if (nameCacheId >= 0)
332 replaces[Anum_name - 1] =
true;
342 if (classId == PublicationRelationId)
375 switch (
stmt->renameType)
457 elog(
ERROR,
"unrecognized rename stmt type: %d",
458 (
int)
stmt->renameType);
490 stmt->objectType, address,
stmt->object, rel);
502 *refAddress = refAddr;
540 switch (
stmt->objectType)
544 oldSchemaAddr ? &oldNspOid : NULL);
553 oldSchemaAddr ? &oldNspOid : NULL);
560 oldSchemaAddr ? &oldNspOid : NULL);
599 elog(
ERROR,
"unrecognized AlterObjectSchemaStmt type: %d",
600 (
int)
stmt->objectType);
632 case RelationRelationId:
649 case ProcedureRelationId:
650 case CollationRelationId:
651 case ConversionRelationId:
652 case OperatorRelationId:
653 case OperatorClassRelationId:
654 case OperatorFamilyRelationId:
655 case StatisticExtRelationId:
656 case TSParserRelationId:
657 case TSDictionaryRelationId:
658 case TSTemplateRelationId:
659 case TSConfigRelationId:
712 elog(
ERROR,
"cache lookup failed for object %u of catalog \"%s\"",
726 if (oldNspOid == nspOid)
745 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
746 errmsg(
"must be superuser to set schema of %s",
770 if (classId == ProcedureRelationId)
775 &proc->proargtypes, nspOid);
777 else if (classId == CollationRelationId)
783 else if (classId == OperatorClassRelationId)
788 opc->opcmethod, nspOid);
790 else if (classId == OperatorFamilyRelationId)
795 opf->opfmethod, nspOid);
797 else if (nameCacheId >= 0 &&
809 replaces[Anum_namespace - 1] =
true;
823 NamespaceRelationId, oldNspOid, nspOid) != 1)
824 elog(
ERROR,
"could not change schema dependency for object %u",
841 switch (
stmt->objectType)
907 elog(
ERROR,
"unrecognized AlterOwnerStmt type: %d",
908 (
int)
stmt->objectType);
929 Oid catalogId = (classId == LargeObjectRelationId) ? LargeObjectMetadataRelationId : classId;
948 elog(
ERROR,
"cache lookup failed for object %u of catalog \"%s\"",
964 if (old_ownerId != new_ownerId)
990 snprintf(namebuf,
sizeof(namebuf),
"%u", objectId);
1005 aclresult =
object_aclcheck(NamespaceRelationId, namespaceId, new_ownerId,
1016 nulls =
palloc0(nattrs *
sizeof(
bool));
1017 replaces =
palloc0(nattrs *
sizeof(
bool));
1019 replaces[Anum_owner - 1] =
true;
1034 old_ownerId, new_ownerId);
1036 replaces[Anum_acl - 1] =
true;
1041 values, nulls, replaces);
bool has_privs_of_role(Oid member, Oid role)
Acl * aclnewowner(const Acl *old_acl, Oid oldOwnerId, Oid newOwnerId)
void check_can_set_role(Oid member, Oid role)
Oid get_rolespec_oid(const RoleSpec *role, bool missing_ok)
void aclcheck_error(AclResult aclerr, ObjectType objtype, const char *objectname)
AclResult object_aclcheck(Oid classid, Oid objectid, Oid roleid, AclMode mode)
static Oid AlterObjectNamespace_internal(Relation rel, Oid objid, Oid nspOid)
static void report_name_conflict(Oid classId, const char *name)
ObjectAddress ExecAlterOwnerStmt(AlterOwnerStmt *stmt)
static void report_namespace_conflict(Oid classId, const char *name, Oid nspOid)
ObjectAddress ExecAlterObjectDependsStmt(AlterObjectDependsStmt *stmt, ObjectAddress *refAddress)
static void AlterObjectRename_internal(Relation rel, Oid objectId, const char *new_name)
ObjectAddress ExecRenameStmt(RenameStmt *stmt)
void AlterObjectOwner_internal(Oid classId, Oid objectId, Oid new_ownerId)
ObjectAddress ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt, ObjectAddress *oldSchemaAddr)
Oid AlterObjectNamespace_oid(Oid classId, Oid objid, Oid nspOid, ObjectAddresses *objsMoved)
#define InvalidAttrNumber
ObjectAddress RenameTableSpace(const char *oldname, const char *newname)
void LogicalRepWorkersWakeupAtCommit(Oid subid)
static Datum values[MAXATTR]
#define OidIsValid(objectId)
void IsThereCollationInNamespace(const char *collname, Oid nspOid)
ObjectAddress RenameDatabase(const char *oldname, const char *newname)
char * get_database_name(Oid dbid)
ObjectAddress AlterDatabaseOwner(const char *dbname, Oid newOwnerId)
@ DEPENDENCY_AUTO_EXTENSION
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
ObjectAddress AlterEventTriggerOwner(const char *name, Oid newOwnerId)
ObjectAddress AlterExtensionNamespace(const char *extensionName, const char *newschema, Oid *oldschema)
ObjectAddress AlterForeignServerOwner(const char *name, Oid newOwnerId)
ObjectAddress AlterForeignDataWrapperOwner(const char *name, Oid newOwnerId)
void IsThereFunctionInNamespace(const char *proname, int pronargs, oidvector *proargtypes, Oid nspOid)
Assert(PointerIsAligned(start, uint64))
HeapTuple heap_modify_tuple(HeapTuple tuple, TupleDesc tupleDesc, const Datum *replValues, const bool *replIsnull, const bool *doReplace)
void heap_freetuple(HeapTuple htup)
#define HeapTupleIsValid(tuple)
static Datum heap_getattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
static void * GETSTRUCT(const HeapTupleData *tuple)
void CatalogTupleUpdate(Relation heapRel, ItemPointer otid, HeapTuple tup)
bool list_member_oid(const List *list, Oid datum)
void UnlockTuple(Relation relation, ItemPointer tid, LOCKMODE lockmode)
#define AccessExclusiveLock
#define InplaceUpdateTupleLock
char * get_namespace_name(Oid nspid)
void pfree(void *pointer)
void * palloc0(Size size)
void namestrcpy(Name name, const char *str)
Oid LookupCreationNamespace(const char *nspname)
void CheckSetNamespace(Oid oldNspOid, Oid nspOid)
#define castNode(_type_, nodeptr)
#define InvokeObjectPostAlterHook(classId, objectId, subId)
int get_object_catcache_name(Oid class_id)
ObjectAddress get_object_address_rv(ObjectType objtype, RangeVar *rel, List *object, Relation *relp, LOCKMODE lockmode, bool missing_ok)
AttrNumber get_object_attnum_owner(Oid class_id)
AttrNumber get_object_attnum_oid(Oid class_id)
AttrNumber get_object_attnum_namespace(Oid class_id)
void check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address, Node *object, Relation relation)
char * getObjectDescriptionOids(Oid classid, Oid objid)
AttrNumber get_object_attnum_name(Oid class_id)
AttrNumber get_object_attnum_acl(Oid class_id)
int get_object_catcache_oid(Oid class_id)
const ObjectAddress InvalidObjectAddress
ObjectType get_object_type(Oid class_id, Oid object_id)
ObjectAddress get_object_address(ObjectType objtype, Node *object, Relation *relp, LOCKMODE lockmode, bool missing_ok)
HeapTuple get_catalog_object_by_oid_extended(Relation catalog, AttrNumber oidcol, Oid objectId, bool locktup)
#define ObjectAddressSet(addr, class_id, object_id)
void IsThereOpFamilyInNamespace(const char *opfname, Oid opfmethod, Oid opfnamespace)
void IsThereOpClassInNamespace(const char *opcname, Oid opcmethod, Oid opcnamespace)
FormData_pg_collation * Form_pg_collation
void recordDependencyOn(const ObjectAddress *depender, const ObjectAddress *referenced, DependencyType behavior)
long changeDependencyFor(Oid classId, Oid objectId, Oid refClassId, Oid oldRefObjectId, Oid newRefObjectId)
long deleteDependencyRecordsForSpecific(Oid classId, Oid objectId, char deptype, Oid refclassId, Oid refobjectId)
List * getAutoExtensionsOfObject(Oid classId, Oid objectId)
FormData_pg_opclass * Form_pg_opclass
FormData_pg_opfamily * Form_pg_opfamily
FormData_pg_proc * Form_pg_proc
FormData_pg_publication * Form_pg_publication
void changeDependencyOnOwner(Oid classId, Oid objectId, Oid newOwnerId)
FormData_pg_subscription * Form_pg_subscription
ObjectAddress rename_policy(RenameStmt *stmt)
static Datum PointerGetDatum(const void *X)
static Name DatumGetName(Datum X)
static Oid DatumGetObjectId(Datum X)
static Datum ObjectIdGetDatum(Oid X)
static Datum NameGetDatum(const NameData *X)
static Datum CStringGetDatum(const char *X)
void InvalidatePubRelSyncCache(Oid pubid, bool puballtables)
ObjectAddress AlterPublicationOwner(const char *name, Oid newOwnerId)
#define RelationGetRelid(relation)
#define RelationGetDescr(relation)
#define RelationGetNumberOfAttributes(relation)
#define RelationGetRelationName(relation)
#define RelationGetNamespace(relation)
ObjectAddress RenameRewriteRule(RangeVar *relation, const char *oldName, const char *newName)
ObjectAddress AlterSchemaOwner(const char *name, Oid newOwnerId)
ObjectAddress RenameSchema(const char *oldname, const char *newname)
void relation_close(Relation relation, LOCKMODE lockmode)
Relation relation_open(Oid relationId, LOCKMODE lockmode)
#define ERRCODE_DUPLICATE_OBJECT
ObjectAddress AlterSubscriptionOwner(const char *name, Oid newOwnerId)
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
#define SearchSysCacheCopy1(cacheId, key1)
#define SearchSysCacheExists2(cacheId, key1, key2)
#define SearchSysCacheExists1(cacheId, key1)
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
ObjectAddress RenameRelation(RenameStmt *stmt)
ObjectAddress renameatt(RenameStmt *stmt)
void AlterTableNamespaceInternal(Relation rel, Oid oldNspOid, Oid nspOid, ObjectAddresses *objsMoved)
ObjectAddress AlterTableNamespace(AlterObjectSchemaStmt *stmt, Oid *oldschema)
ObjectAddress RenameConstraint(RenameStmt *stmt)
ObjectAddress renametrig(RenameStmt *stmt)
Oid AlterTypeNamespace_oid(Oid typeOid, Oid nspOid, bool ignoreDependent, ObjectAddresses *objsMoved)
ObjectAddress AlterTypeOwner(List *names, Oid newOwnerId, ObjectType objecttype)
ObjectAddress RenameType(RenameStmt *stmt)
ObjectAddress AlterTypeNamespace(List *names, const char *newschema, ObjectType objecttype, Oid *oldschema)
ObjectAddress RenameRole(const char *oldname, const char *newname)