PostgreSQL Source Code git master
Loading...
Searching...
No Matches
alter.h File Reference
Include dependency graph for alter.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

ObjectAddress ExecRenameStmt (RenameStmt *stmt)
 
ObjectAddress ExecAlterObjectDependsStmt (AlterObjectDependsStmt *stmt, ObjectAddress *refAddress)
 
ObjectAddress ExecAlterObjectSchemaStmt (AlterObjectSchemaStmt *stmt, ObjectAddress *oldSchemaAddr)
 
Oid AlterObjectNamespace_oid (Oid classId, Oid objid, Oid nspOid, ObjectAddresses *objsMoved)
 
ObjectAddress ExecAlterOwnerStmt (AlterOwnerStmt *stmt)
 
void AlterObjectOwner_internal (Oid classId, Oid objectId, Oid new_ownerId)
 

Function Documentation

◆ AlterObjectNamespace_oid()

Oid AlterObjectNamespace_oid ( Oid  classId,
Oid  objid,
Oid  nspOid,
ObjectAddresses objsMoved 
)
extern

Definition at line 619 of file alter.c.

621{
623
624 switch (classId)
625 {
627 {
628 Relation rel;
629
632
634
636 break;
637 }
638
639 case TypeRelationId:
641 break;
642
654 {
656
658
660 nspOid);
661
663 }
664 break;
665
666 default:
667 /* ignore object types that don't have schema-qualified names */
669 }
670
671 return oldNspOid;
672}
static Oid AlterObjectNamespace_internal(Relation rel, Oid objid, Oid nspOid)
Definition alter.c:686
#define InvalidAttrNumber
Definition attnum.h:23
#define Assert(condition)
Definition c.h:873
#define NoLock
Definition lockdefs.h:34
#define AccessExclusiveLock
Definition lockdefs.h:43
#define RowExclusiveLock
Definition lockdefs.h:38
AttrNumber get_object_attnum_namespace(Oid class_id)
#define InvalidOid
unsigned int Oid
static int fb(int x)
#define RelationGetNamespace(relation)
Definition rel.h:555
void relation_close(Relation relation, LOCKMODE lockmode)
Definition relation.c:205
Relation relation_open(Oid relationId, LOCKMODE lockmode)
Definition relation.c:47
void table_close(Relation relation, LOCKMODE lockmode)
Definition table.c:126
Relation table_open(Oid relationId, LOCKMODE lockmode)
Definition table.c:40
void AlterTableNamespaceInternal(Relation rel, Oid oldNspOid, Oid nspOid, ObjectAddresses *objsMoved)
Oid AlterTypeNamespace_oid(Oid typeOid, Oid nspOid, bool ignoreDependent, ObjectAddresses *objsMoved)
Definition typecmds.c:4139

References AccessExclusiveLock, AlterObjectNamespace_internal(), AlterTableNamespaceInternal(), AlterTypeNamespace_oid(), Assert, fb(), get_object_attnum_namespace(), InvalidAttrNumber, InvalidOid, NoLock, relation_close(), relation_open(), RelationGetNamespace, RowExclusiveLock, table_close(), and table_open().

Referenced by AlterExtensionNamespace().

◆ AlterObjectOwner_internal()

void AlterObjectOwner_internal ( Oid  classId,
Oid  objectId,
Oid  new_ownerId 
)
extern

Definition at line 920 of file alter.c.

921{
922 /* For large objects, the catalog to modify is pg_largeobject_metadata */
923 Oid catalogId = (classId == LargeObjectRelationId) ? LargeObjectMetadataRelationId : classId;
929 Relation rel;
931 Datum datum;
932 bool isnull;
935
936 rel = table_open(catalogId, RowExclusiveLock);
937
938 /* Search tuple and lock it. */
939 oldtup =
940 get_catalog_object_by_oid_extended(rel, Anum_oid, objectId, true);
941 if (oldtup == NULL)
942 elog(ERROR, "cache lookup failed for object %u of catalog \"%s\"",
943 objectId, RelationGetRelationName(rel));
944
946 RelationGetDescr(rel), &isnull);
947 Assert(!isnull);
949
951 {
953 RelationGetDescr(rel), &isnull);
954 Assert(!isnull);
956 }
957
959 {
960 AttrNumber nattrs;
962 Datum *values;
963 bool *nulls;
964 bool *replaces;
965
966 /* Superusers can bypass permission checks */
967 if (!superuser())
968 {
969 /* must be owner */
971 {
972 char *objname;
973 char namebuf[NAMEDATALEN];
974
976 {
978 RelationGetDescr(rel), &isnull);
979 Assert(!isnull);
980 objname = NameStr(*DatumGetName(datum));
981 }
982 else
983 {
984 snprintf(namebuf, sizeof(namebuf), "%u", objectId);
985 objname = namebuf;
986 }
988 get_object_type(catalogId, objectId),
989 objname);
990 }
991 /* Must be able to become new owner */
993
994 /* New owner must have CREATE privilege on namespace */
996 {
998
1000 ACL_CREATE);
1001 if (aclresult != ACLCHECK_OK)
1004 }
1005 }
1006
1007 /* Build a modified tuple */
1008 nattrs = RelationGetNumberOfAttributes(rel);
1009 values = palloc0(nattrs * sizeof(Datum));
1010 nulls = palloc0(nattrs * sizeof(bool));
1011 replaces = palloc0(nattrs * sizeof(bool));
1013 replaces[Anum_owner - 1] = true;
1014
1015 /*
1016 * Determine the modified ACL for the new owner. This is only
1017 * necessary when the ACL is non-null.
1018 */
1020 {
1021 datum = heap_getattr(oldtup,
1022 Anum_acl, RelationGetDescr(rel), &isnull);
1023 if (!isnull)
1024 {
1025 Acl *newAcl;
1026
1030 replaces[Anum_acl - 1] = true;
1031 }
1032 }
1033
1035 values, nulls, replaces);
1036
1037 /* Perform actual update */
1038 CatalogTupleUpdate(rel, &newtup->t_self, newtup);
1039
1041
1042 /* Update owner dependency reference */
1043 changeDependencyOnOwner(classId, objectId, new_ownerId);
1044
1045 /* Release memory */
1046 pfree(values);
1047 pfree(nulls);
1048 pfree(replaces);
1049 }
1050 else
1052
1053 /* Note the post-alter hook gets classId not catalogId */
1054 InvokeObjectPostAlterHook(classId, objectId, 0);
1055
1057}
bool has_privs_of_role(Oid member, Oid role)
Definition acl.c:5284
Acl * aclnewowner(const Acl *old_acl, Oid oldOwnerId, Oid newOwnerId)
Definition acl.c:1119
void check_can_set_role(Oid member, Oid role)
Definition acl.c:5341
AclResult
Definition acl.h:182
@ ACLCHECK_OK
Definition acl.h:183
@ ACLCHECK_NOT_OWNER
Definition acl.h:185
#define DatumGetAclP(X)
Definition acl.h:120
void aclcheck_error(AclResult aclerr, ObjectType objtype, const char *objectname)
Definition aclchk.c:2654
AclResult object_aclcheck(Oid classid, Oid objectid, Oid roleid, AclMode mode)
Definition aclchk.c:3836
int16 AttrNumber
Definition attnum.h:21
static Datum values[MAXATTR]
Definition bootstrap.c:155
#define NameStr(name)
Definition c.h:765
#define OidIsValid(objectId)
Definition c.h:788
#define ERROR
Definition elog.h:39
#define elog(elevel,...)
Definition elog.h:226
HeapTuple heap_modify_tuple(HeapTuple tuple, TupleDesc tupleDesc, const Datum *replValues, const bool *replIsnull, const bool *doReplace)
Definition heaptuple.c:1210
static Datum heap_getattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
void CatalogTupleUpdate(Relation heapRel, const ItemPointerData *otid, HeapTuple tup)
Definition indexing.c:313
void UnlockTuple(Relation relation, const ItemPointerData *tid, LOCKMODE lockmode)
Definition lmgr.c:601
#define InplaceUpdateTupleLock
Definition lockdefs.h:48
char * get_namespace_name(Oid nspid)
Definition lsyscache.c:3516
void pfree(void *pointer)
Definition mcxt.c:1616
void * palloc0(Size size)
Definition mcxt.c:1417
Oid GetUserId(void)
Definition miscinit.c:469
#define InvokeObjectPostAlterHook(classId, objectId, subId)
AttrNumber get_object_attnum_owner(Oid class_id)
AttrNumber get_object_attnum_oid(Oid class_id)
AttrNumber get_object_attnum_name(Oid class_id)
AttrNumber get_object_attnum_acl(Oid class_id)
ObjectType get_object_type(Oid class_id, Oid object_id)
HeapTuple get_catalog_object_by_oid_extended(Relation catalog, AttrNumber oidcol, Oid objectId, bool locktup)
@ OBJECT_SCHEMA
#define ACL_CREATE
Definition parsenodes.h:85
#define NAMEDATALEN
void changeDependencyOnOwner(Oid classId, Oid objectId, Oid newOwnerId)
#define snprintf
Definition port.h:260
static Datum PointerGetDatum(const void *X)
Definition postgres.h:352
static Name DatumGetName(Datum X)
Definition postgres.h:390
static Oid DatumGetObjectId(Datum X)
Definition postgres.h:252
static Datum ObjectIdGetDatum(Oid X)
Definition postgres.h:262
uint64_t Datum
Definition postgres.h:70
#define RelationGetDescr(relation)
Definition rel.h:540
#define RelationGetNumberOfAttributes(relation)
Definition rel.h:520
#define RelationGetRelationName(relation)
Definition rel.h:548
bool superuser(void)
Definition superuser.c:46

References ACL_CREATE, aclcheck_error(), ACLCHECK_NOT_OWNER, ACLCHECK_OK, aclnewowner(), Assert, CatalogTupleUpdate(), changeDependencyOnOwner(), check_can_set_role(), DatumGetAclP, DatumGetName(), DatumGetObjectId(), elog, ERROR, fb(), get_catalog_object_by_oid_extended(), get_namespace_name(), get_object_attnum_acl(), get_object_attnum_name(), get_object_attnum_namespace(), get_object_attnum_oid(), get_object_attnum_owner(), get_object_type(), GetUserId(), has_privs_of_role(), heap_getattr(), heap_modify_tuple(), InplaceUpdateTupleLock, InvalidAttrNumber, InvalidOid, InvokeObjectPostAlterHook, NAMEDATALEN, NameStr, object_aclcheck(), OBJECT_SCHEMA, ObjectIdGetDatum(), OidIsValid, palloc0(), pfree(), PointerGetDatum(), RelationGetDescr, RelationGetNumberOfAttributes, RelationGetRelationName, RowExclusiveLock, snprintf, superuser(), table_close(), table_open(), UnlockTuple(), and values.

Referenced by ExecAlterOwnerStmt(), and shdepReassignOwned_Owner().

◆ ExecAlterObjectDependsStmt()

ObjectAddress ExecAlterObjectDependsStmt ( AlterObjectDependsStmt stmt,
ObjectAddress refAddress 
)
extern

Definition at line 465 of file alter.c.

466{
467 ObjectAddress address;
469 Relation rel;
470
471 address =
472 get_object_address_rv(stmt->objectType, stmt->relation, (List *) stmt->object,
473 &rel, AccessExclusiveLock, false);
474
475 /*
476 * Verify that the user is entitled to run the command.
477 *
478 * We don't check any privileges on the extension, because that's not
479 * needed. The object owner is stipulating, by running this command, that
480 * the extension owner can drop the object whenever they feel like it,
481 * which is not considered a problem.
482 */
484 stmt->objectType, address, stmt->object, rel);
485
486 /*
487 * If a relation was involved, it would have been opened and locked. We
488 * don't need the relation here, but we'll retain the lock until commit.
489 */
490 if (rel)
491 table_close(rel, NoLock);
492
494 NULL, AccessExclusiveLock, false);
495 if (refAddress)
497
498 if (stmt->remove)
499 {
502 refAddr.classId, refAddr.objectId);
503 }
504 else
505 {
506 List *currexts;
507
508 /* Avoid duplicates */
510 address.objectId);
511 if (!list_member_oid(currexts, refAddr.objectId))
513 }
514
515 return address;
516}
@ DEPENDENCY_AUTO_EXTENSION
Definition dependency.h:39
#define stmt
bool list_member_oid(const List *list, Oid datum)
Definition list.c:722
ObjectAddress get_object_address_rv(ObjectType objtype, RangeVar *rel, List *object, Relation *relp, LOCKMODE lockmode, bool missing_ok)
void check_object_ownership(Oid roleid, ObjectType objtype, ObjectAddress address, Node *object, Relation relation)
ObjectAddress get_object_address(ObjectType objtype, Node *object, Relation *relp, LOCKMODE lockmode, bool missing_ok)
@ OBJECT_EXTENSION
void recordDependencyOn(const ObjectAddress *depender, const ObjectAddress *referenced, DependencyType behavior)
Definition pg_depend.c:45
long deleteDependencyRecordsForSpecific(Oid classId, Oid objectId, char deptype, Oid refclassId, Oid refobjectId)
Definition pg_depend.c:398
List * getAutoExtensionsOfObject(Oid classId, Oid objectId)
Definition pg_depend.c:778
Definition pg_list.h:54
Definition nodes.h:135

References AccessExclusiveLock, check_object_ownership(), ObjectAddress::classId, deleteDependencyRecordsForSpecific(), DEPENDENCY_AUTO_EXTENSION, fb(), get_object_address(), get_object_address_rv(), getAutoExtensionsOfObject(), GetUserId(), list_member_oid(), NoLock, OBJECT_EXTENSION, ObjectAddress::objectId, recordDependencyOn(), stmt, and table_close().

Referenced by ProcessUtilitySlow(), and standard_ProcessUtility().

◆ ExecAlterObjectSchemaStmt()

ObjectAddress ExecAlterObjectSchemaStmt ( AlterObjectSchemaStmt stmt,
ObjectAddress oldSchemaAddr 
)
extern

Definition at line 528 of file alter.c.

530{
531 ObjectAddress address;
533
534 switch (stmt->objectType)
535 {
536 case OBJECT_EXTENSION:
537 address = AlterExtensionNamespace(strVal(stmt->object), stmt->newschema,
539 break;
540
542 case OBJECT_SEQUENCE:
543 case OBJECT_TABLE:
544 case OBJECT_VIEW:
545 case OBJECT_MATVIEW:
546 address = AlterTableNamespace(stmt,
548 break;
549
550 case OBJECT_DOMAIN:
551 case OBJECT_TYPE:
552 address = AlterTypeNamespace(castNode(List, stmt->object), stmt->newschema,
553 stmt->objectType,
555 break;
556
557 /* generic code path */
558 case OBJECT_AGGREGATE:
559 case OBJECT_COLLATION:
561 case OBJECT_FUNCTION:
562 case OBJECT_OPERATOR:
563 case OBJECT_OPCLASS:
564 case OBJECT_OPFAMILY:
565 case OBJECT_PROCEDURE:
566 case OBJECT_ROUTINE:
570 case OBJECT_TSPARSER:
572 {
574 Oid classId;
575 Oid nspOid;
576
577 address = get_object_address(stmt->objectType,
578 stmt->object,
579 NULL,
581 false);
582 classId = address.classId;
584 nspOid = LookupCreationNamespace(stmt->newschema);
585
587 nspOid);
589 }
590 break;
591
592 default:
593 elog(ERROR, "unrecognized AlterObjectSchemaStmt type: %d",
594 (int) stmt->objectType);
595 return InvalidObjectAddress; /* keep compiler happy */
596 }
597
598 if (oldSchemaAddr)
600
601 return address;
602}
ObjectAddress AlterExtensionNamespace(const char *extensionName, const char *newschema, Oid *oldschema)
Definition extension.c:3122
Oid LookupCreationNamespace(const char *nspname)
Definition namespace.c:3498
#define castNode(_type_, nodeptr)
Definition nodes.h:182
const ObjectAddress InvalidObjectAddress
#define ObjectAddressSet(addr, class_id, object_id)
@ OBJECT_TSPARSER
@ OBJECT_COLLATION
@ OBJECT_OPCLASS
@ OBJECT_AGGREGATE
@ OBJECT_MATVIEW
@ OBJECT_OPERATOR
@ OBJECT_FOREIGN_TABLE
@ OBJECT_TSCONFIGURATION
@ OBJECT_OPFAMILY
@ OBJECT_DOMAIN
@ OBJECT_ROUTINE
@ OBJECT_PROCEDURE
@ OBJECT_SEQUENCE
@ OBJECT_TSTEMPLATE
@ OBJECT_TSDICTIONARY
@ OBJECT_CONVERSION
@ OBJECT_TABLE
@ OBJECT_VIEW
@ OBJECT_TYPE
@ OBJECT_FUNCTION
@ OBJECT_STATISTIC_EXT
ObjectAddress AlterTableNamespace(AlterObjectSchemaStmt *stmt, Oid *oldschema)
ObjectAddress AlterTypeNamespace(List *names, const char *newschema, ObjectType objecttype, Oid *oldschema)
Definition typecmds.c:4090
#define strVal(v)
Definition value.h:82

References AccessExclusiveLock, AlterExtensionNamespace(), AlterObjectNamespace_internal(), AlterTableNamespace(), AlterTypeNamespace(), castNode, ObjectAddress::classId, elog, ERROR, fb(), get_object_address(), InvalidObjectAddress, LookupCreationNamespace(), OBJECT_AGGREGATE, OBJECT_COLLATION, OBJECT_CONVERSION, OBJECT_DOMAIN, OBJECT_EXTENSION, OBJECT_FOREIGN_TABLE, OBJECT_FUNCTION, OBJECT_MATVIEW, OBJECT_OPCLASS, OBJECT_OPERATOR, OBJECT_OPFAMILY, OBJECT_PROCEDURE, OBJECT_ROUTINE, OBJECT_SEQUENCE, OBJECT_STATISTIC_EXT, OBJECT_TABLE, OBJECT_TSCONFIGURATION, OBJECT_TSDICTIONARY, OBJECT_TSPARSER, OBJECT_TSTEMPLATE, OBJECT_TYPE, OBJECT_VIEW, ObjectAddressSet, ObjectAddress::objectId, RowExclusiveLock, stmt, strVal, table_close(), and table_open().

Referenced by ProcessUtilitySlow(), and standard_ProcessUtility().

◆ ExecAlterOwnerStmt()

ObjectAddress ExecAlterOwnerStmt ( AlterOwnerStmt stmt)
extern

Definition at line 831 of file alter.c.

832{
833 Oid newowner = get_rolespec_oid(stmt->newowner, false);
834
835 switch (stmt->objectType)
836 {
837 case OBJECT_DATABASE:
838 return AlterDatabaseOwner(strVal(stmt->object), newowner);
839
840 case OBJECT_SCHEMA:
841 return AlterSchemaOwner(strVal(stmt->object), newowner);
842
843 case OBJECT_TYPE:
844 case OBJECT_DOMAIN: /* same as TYPE */
845 return AlterTypeOwner(castNode(List, stmt->object), newowner, stmt->objectType);
846 break;
847
848 case OBJECT_FDW:
850 newowner);
851
853 return AlterForeignServerOwner(strVal(stmt->object),
854 newowner);
855
857 return AlterEventTriggerOwner(strVal(stmt->object),
858 newowner);
859
861 return AlterPublicationOwner(strVal(stmt->object),
862 newowner);
863
865 return AlterSubscriptionOwner(strVal(stmt->object),
866 newowner);
867
868 /* Generic cases */
869 case OBJECT_AGGREGATE:
870 case OBJECT_COLLATION:
872 case OBJECT_FUNCTION:
873 case OBJECT_LANGUAGE:
875 case OBJECT_OPERATOR:
876 case OBJECT_OPCLASS:
877 case OBJECT_OPFAMILY:
878 case OBJECT_PROCEDURE:
879 case OBJECT_ROUTINE:
884 {
885 ObjectAddress address;
886
887 address = get_object_address(stmt->objectType,
888 stmt->object,
889 NULL,
891 false);
892
894 newowner);
895
896 return address;
897 }
898 break;
899
900 default:
901 elog(ERROR, "unrecognized AlterOwnerStmt type: %d",
902 (int) stmt->objectType);
903 return InvalidObjectAddress; /* keep compiler happy */
904 }
905}
Oid get_rolespec_oid(const RoleSpec *role, bool missing_ok)
Definition acl.c:5586
void AlterObjectOwner_internal(Oid classId, Oid objectId, Oid new_ownerId)
Definition alter.c:920
ObjectAddress AlterDatabaseOwner(const char *dbname, Oid newOwnerId)
ObjectAddress AlterEventTriggerOwner(const char *name, Oid newOwnerId)
ObjectAddress AlterForeignServerOwner(const char *name, Oid newOwnerId)
ObjectAddress AlterForeignDataWrapperOwner(const char *name, Oid newOwnerId)
@ OBJECT_EVENT_TRIGGER
@ OBJECT_FDW
@ OBJECT_TABLESPACE
@ OBJECT_LARGEOBJECT
@ OBJECT_DATABASE
@ OBJECT_LANGUAGE
@ OBJECT_FOREIGN_SERVER
@ OBJECT_PUBLICATION
@ OBJECT_SUBSCRIPTION
ObjectAddress AlterPublicationOwner(const char *name, Oid newOwnerId)
ObjectAddress AlterSchemaOwner(const char *name, Oid newOwnerId)
Definition schemacmds.c:331
ObjectAddress AlterSubscriptionOwner(const char *name, Oid newOwnerId)
ObjectAddress AlterTypeOwner(List *names, Oid newOwnerId, ObjectType objecttype)
Definition typecmds.c:3857

References AccessExclusiveLock, AlterDatabaseOwner(), AlterEventTriggerOwner(), AlterForeignDataWrapperOwner(), AlterForeignServerOwner(), AlterObjectOwner_internal(), AlterPublicationOwner(), AlterSchemaOwner(), AlterSubscriptionOwner(), AlterTypeOwner(), castNode, ObjectAddress::classId, elog, ERROR, fb(), get_object_address(), get_rolespec_oid(), InvalidObjectAddress, OBJECT_AGGREGATE, OBJECT_COLLATION, OBJECT_CONVERSION, OBJECT_DATABASE, OBJECT_DOMAIN, OBJECT_EVENT_TRIGGER, OBJECT_FDW, OBJECT_FOREIGN_SERVER, OBJECT_FUNCTION, OBJECT_LANGUAGE, OBJECT_LARGEOBJECT, OBJECT_OPCLASS, OBJECT_OPERATOR, OBJECT_OPFAMILY, OBJECT_PROCEDURE, OBJECT_PUBLICATION, OBJECT_ROUTINE, OBJECT_SCHEMA, OBJECT_STATISTIC_EXT, OBJECT_SUBSCRIPTION, OBJECT_TABLESPACE, OBJECT_TSCONFIGURATION, OBJECT_TSDICTIONARY, OBJECT_TYPE, ObjectAddress::objectId, stmt, and strVal.

Referenced by ProcessUtilitySlow(), and standard_ProcessUtility().

◆ ExecRenameStmt()

ObjectAddress ExecRenameStmt ( RenameStmt stmt)
extern

Definition at line 367 of file alter.c.

368{
369 switch (stmt->renameType)
370 {
373 return RenameConstraint(stmt);
374
375 case OBJECT_DATABASE:
376 return RenameDatabase(stmt->subname, stmt->newname);
377
378 case OBJECT_ROLE:
379 return RenameRole(stmt->subname, stmt->newname);
380
381 case OBJECT_SCHEMA:
382 return RenameSchema(stmt->subname, stmt->newname);
383
385 return RenameTableSpace(stmt->subname, stmt->newname);
386
387 case OBJECT_TABLE:
388 case OBJECT_SEQUENCE:
389 case OBJECT_VIEW:
390 case OBJECT_MATVIEW:
391 case OBJECT_INDEX:
393 return RenameRelation(stmt);
394
395 case OBJECT_COLUMN:
396 case OBJECT_ATTRIBUTE:
397 return renameatt(stmt);
398
399 case OBJECT_RULE:
400 return RenameRewriteRule(stmt->relation, stmt->subname,
401 stmt->newname);
402
403 case OBJECT_TRIGGER:
404 return renametrig(stmt);
405
406 case OBJECT_POLICY:
407 return rename_policy(stmt);
408
409 case OBJECT_DOMAIN:
410 case OBJECT_TYPE:
411 return RenameType(stmt);
412
413 case OBJECT_AGGREGATE:
414 case OBJECT_COLLATION:
417 case OBJECT_FDW:
419 case OBJECT_FUNCTION:
420 case OBJECT_OPCLASS:
421 case OBJECT_OPFAMILY:
422 case OBJECT_LANGUAGE:
423 case OBJECT_PROCEDURE:
424 case OBJECT_ROUTINE:
428 case OBJECT_TSPARSER:
432 {
433 ObjectAddress address;
435
436 address = get_object_address(stmt->renameType,
437 stmt->object,
438 NULL,
439 AccessExclusiveLock, false);
440
443 address.objectId,
444 stmt->newname);
446
447 return address;
448 }
449
450 default:
451 elog(ERROR, "unrecognized rename stmt type: %d",
452 (int) stmt->renameType);
453 return InvalidObjectAddress; /* keep compiler happy */
454 }
455}
static void AlterObjectRename_internal(Relation rel, Oid objectId, const char *new_name)
Definition alter.c:159
ObjectAddress RenameTableSpace(const char *oldname, const char *newname)
Definition tablespace.c:930
ObjectAddress RenameDatabase(const char *oldname, const char *newname)
@ OBJECT_POLICY
@ OBJECT_COLUMN
@ OBJECT_ROLE
@ OBJECT_INDEX
@ OBJECT_ATTRIBUTE
@ OBJECT_RULE
@ OBJECT_TABCONSTRAINT
@ OBJECT_DOMCONSTRAINT
@ OBJECT_TRIGGER
ObjectAddress rename_policy(RenameStmt *stmt)
Definition policy.c:1096
ObjectAddress RenameRewriteRule(RangeVar *relation, const char *oldName, const char *newName)
ObjectAddress RenameSchema(const char *oldname, const char *newname)
Definition schemacmds.c:250
ObjectAddress RenameRelation(RenameStmt *stmt)
Definition tablecmds.c:4204
ObjectAddress renameatt(RenameStmt *stmt)
Definition tablecmds.c:4007
ObjectAddress RenameConstraint(RenameStmt *stmt)
Definition tablecmds.c:4154
ObjectAddress renametrig(RenameStmt *stmt)
Definition trigger.c:1467
ObjectAddress RenameType(RenameStmt *stmt)
Definition typecmds.c:3776
ObjectAddress RenameRole(const char *oldname, const char *newname)
Definition user.c:1335

References AccessExclusiveLock, AlterObjectRename_internal(), ObjectAddress::classId, elog, ERROR, fb(), get_object_address(), InvalidObjectAddress, OBJECT_AGGREGATE, OBJECT_ATTRIBUTE, OBJECT_COLLATION, OBJECT_COLUMN, OBJECT_CONVERSION, OBJECT_DATABASE, OBJECT_DOMAIN, OBJECT_DOMCONSTRAINT, OBJECT_EVENT_TRIGGER, OBJECT_FDW, OBJECT_FOREIGN_SERVER, OBJECT_FOREIGN_TABLE, OBJECT_FUNCTION, OBJECT_INDEX, OBJECT_LANGUAGE, OBJECT_MATVIEW, OBJECT_OPCLASS, OBJECT_OPFAMILY, OBJECT_POLICY, OBJECT_PROCEDURE, OBJECT_PUBLICATION, OBJECT_ROLE, OBJECT_ROUTINE, OBJECT_RULE, OBJECT_SCHEMA, OBJECT_SEQUENCE, OBJECT_STATISTIC_EXT, OBJECT_SUBSCRIPTION, OBJECT_TABCONSTRAINT, OBJECT_TABLE, OBJECT_TABLESPACE, OBJECT_TRIGGER, OBJECT_TSCONFIGURATION, OBJECT_TSDICTIONARY, OBJECT_TSPARSER, OBJECT_TSTEMPLATE, OBJECT_TYPE, OBJECT_VIEW, ObjectAddress::objectId, rename_policy(), renameatt(), RenameConstraint(), RenameDatabase(), RenameRelation(), RenameRewriteRule(), RenameRole(), RenameSchema(), RenameTableSpace(), renametrig(), RenameType(), RowExclusiveLock, stmt, table_close(), and table_open().

Referenced by ProcessUtilitySlow(), and standard_ProcessUtility().