PostgreSQL Source Code  git master
schemacmds.c File Reference
#include "postgres.h"
#include "access/htup_details.h"
#include "access/table.h"
#include "access/xact.h"
#include "catalog/catalog.h"
#include "catalog/dependency.h"
#include "catalog/indexing.h"
#include "catalog/namespace.h"
#include "catalog/objectaccess.h"
#include "catalog/pg_authid.h"
#include "catalog/pg_database.h"
#include "catalog/pg_namespace.h"
#include "commands/dbcommands.h"
#include "commands/event_trigger.h"
#include "commands/schemacmds.h"
#include "miscadmin.h"
#include "parser/parse_utilcmd.h"
#include "tcop/utility.h"
#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/rel.h"
#include "utils/syscache.h"
Include dependency graph for schemacmds.c:

Go to the source code of this file.

Functions

static void AlterSchemaOwner_internal (HeapTuple tup, Relation rel, Oid newOwnerId)
 
Oid CreateSchemaCommand (CreateSchemaStmt *stmt, const char *queryString, int stmt_location, int stmt_len)
 
ObjectAddress RenameSchema (const char *oldname, const char *newname)
 
void AlterSchemaOwner_oid (Oid schemaoid, Oid newOwnerId)
 
ObjectAddress AlterSchemaOwner (const char *name, Oid newOwnerId)
 

Function Documentation

◆ AlterSchemaOwner()

ObjectAddress AlterSchemaOwner ( const char *  name,
Oid  newOwnerId 
)

Definition at line 312 of file schemacmds.c.

313 {
314  Oid nspOid;
315  HeapTuple tup;
316  Relation rel;
317  ObjectAddress address;
318  Form_pg_namespace nspform;
319 
320  rel = table_open(NamespaceRelationId, RowExclusiveLock);
321 
323  if (!HeapTupleIsValid(tup))
324  ereport(ERROR,
325  (errcode(ERRCODE_UNDEFINED_SCHEMA),
326  errmsg("schema \"%s\" does not exist", name)));
327 
328  nspform = (Form_pg_namespace) GETSTRUCT(tup);
329  nspOid = nspform->oid;
330 
331  AlterSchemaOwner_internal(tup, rel, newOwnerId);
332 
333  ObjectAddressSet(address, NamespaceRelationId, nspOid);
334 
335  ReleaseSysCache(tup);
336 
338 
339  return address;
340 }
int errcode(int sqlerrcode)
Definition: elog.c:858
int errmsg(const char *fmt,...)
Definition: elog.c:1069
#define ERROR
Definition: elog.h:39
#define ereport(elevel,...)
Definition: elog.h:149
const char * name
Definition: encode.c:571
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define GETSTRUCT(TUP)
Definition: htup_details.h:653
#define RowExclusiveLock
Definition: lockdefs.h:38
#define ObjectAddressSet(addr, class_id, object_id)
Definition: objectaddress.h:40
FormData_pg_namespace * Form_pg_namespace
Definition: pg_namespace.h:52
static Datum CStringGetDatum(const char *X)
Definition: postgres.h:350
unsigned int Oid
Definition: postgres_ext.h:31
static void AlterSchemaOwner_internal(HeapTuple tup, Relation rel, Oid newOwnerId)
Definition: schemacmds.c:343
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:865
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:817
@ NAMESPACENAME
Definition: syscache.h:69
void table_close(Relation relation, LOCKMODE lockmode)
Definition: table.c:126
Relation table_open(Oid relationId, LOCKMODE lockmode)
Definition: table.c:40

References AlterSchemaOwner_internal(), CStringGetDatum(), ereport, errcode(), errmsg(), ERROR, GETSTRUCT, HeapTupleIsValid, name, NAMESPACENAME, ObjectAddressSet, ReleaseSysCache(), RowExclusiveLock, SearchSysCache1(), table_close(), and table_open().

Referenced by ExecAlterOwnerStmt().

◆ AlterSchemaOwner_internal()

static void AlterSchemaOwner_internal ( HeapTuple  tup,
Relation  rel,
Oid  newOwnerId 
)
static

Definition at line 343 of file schemacmds.c.

344 {
345  Form_pg_namespace nspForm;
346 
347  Assert(tup->t_tableOid == NamespaceRelationId);
348  Assert(RelationGetRelid(rel) == NamespaceRelationId);
349 
350  nspForm = (Form_pg_namespace) GETSTRUCT(tup);
351 
352  /*
353  * If the new owner is the same as the existing owner, consider the
354  * command to have succeeded. This is for dump restoration purposes.
355  */
356  if (nspForm->nspowner != newOwnerId)
357  {
358  Datum repl_val[Natts_pg_namespace];
359  bool repl_null[Natts_pg_namespace];
360  bool repl_repl[Natts_pg_namespace];
361  Acl *newAcl;
362  Datum aclDatum;
363  bool isNull;
364  HeapTuple newtuple;
365  AclResult aclresult;
366 
367  /* Otherwise, must be owner of the existing object */
368  if (!object_ownercheck(NamespaceRelationId, nspForm->oid, GetUserId()))
370  NameStr(nspForm->nspname));
371 
372  /* Must be able to become new owner */
373  check_can_set_role(GetUserId(), newOwnerId);
374 
375  /*
376  * must have create-schema rights
377  *
378  * NOTE: This is different from other alter-owner checks in that the
379  * current user is checked for create privileges instead of the
380  * destination owner. This is consistent with the CREATE case for
381  * schemas. Because superusers will always have this right, we need
382  * no special case for them.
383  */
384  aclresult = object_aclcheck(DatabaseRelationId, MyDatabaseId, GetUserId(),
385  ACL_CREATE);
386  if (aclresult != ACLCHECK_OK)
387  aclcheck_error(aclresult, OBJECT_DATABASE,
389 
390  memset(repl_null, false, sizeof(repl_null));
391  memset(repl_repl, false, sizeof(repl_repl));
392 
393  repl_repl[Anum_pg_namespace_nspowner - 1] = true;
394  repl_val[Anum_pg_namespace_nspowner - 1] = ObjectIdGetDatum(newOwnerId);
395 
396  /*
397  * Determine the modified ACL for the new owner. This is only
398  * necessary when the ACL is non-null.
399  */
400  aclDatum = SysCacheGetAttr(NAMESPACENAME, tup,
401  Anum_pg_namespace_nspacl,
402  &isNull);
403  if (!isNull)
404  {
405  newAcl = aclnewowner(DatumGetAclP(aclDatum),
406  nspForm->nspowner, newOwnerId);
407  repl_repl[Anum_pg_namespace_nspacl - 1] = true;
408  repl_val[Anum_pg_namespace_nspacl - 1] = PointerGetDatum(newAcl);
409  }
410 
411  newtuple = heap_modify_tuple(tup, RelationGetDescr(rel), repl_val, repl_null, repl_repl);
412 
413  CatalogTupleUpdate(rel, &newtuple->t_self, newtuple);
414 
415  heap_freetuple(newtuple);
416 
417  /* Update owner dependency reference */
418  changeDependencyOnOwner(NamespaceRelationId, nspForm->oid,
419  newOwnerId);
420  }
421 
422  InvokeObjectPostAlterHook(NamespaceRelationId,
423  nspForm->oid, 0);
424 }
Acl * aclnewowner(const Acl *old_acl, Oid oldOwnerId, Oid newOwnerId)
Definition: acl.c:1090
void check_can_set_role(Oid member, Oid role)
Definition: acl.c:5026
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:2679
AclResult object_aclcheck(Oid classid, Oid objectid, Oid roleid, AclMode mode)
Definition: aclchk.c:3783
bool object_ownercheck(Oid classid, Oid objectid, Oid roleid)
Definition: aclchk.c:3984
#define NameStr(name)
Definition: c.h:730
char * get_database_name(Oid dbid)
Definition: dbcommands.c:3028
Oid MyDatabaseId
Definition: globals.c:89
HeapTuple heap_modify_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *replValues, bool *replIsnull, bool *doReplace)
Definition: heaptuple.c:1113
void heap_freetuple(HeapTuple htup)
Definition: heaptuple.c:1338
void CatalogTupleUpdate(Relation heapRel, ItemPointer otid, HeapTuple tup)
Definition: indexing.c:301
Assert(fmt[strlen(fmt) - 1] !='\n')
Oid GetUserId(void)
Definition: miscinit.c:510
#define InvokeObjectPostAlterHook(classId, objectId, subId)
Definition: objectaccess.h:197
@ OBJECT_SCHEMA
Definition: parsenodes.h:2011
@ OBJECT_DATABASE
Definition: parsenodes.h:1984
#define ACL_CREATE
Definition: parsenodes.h:92
void changeDependencyOnOwner(Oid classId, Oid objectId, Oid newOwnerId)
Definition: pg_shdepend.c:313
static Datum PointerGetDatum(const void *X)
Definition: postgres.h:322
uintptr_t Datum
Definition: postgres.h:64
static Datum ObjectIdGetDatum(Oid X)
Definition: postgres.h:252
#define RelationGetRelid(relation)
Definition: rel.h:501
#define RelationGetDescr(relation)
Definition: rel.h:527
ItemPointerData t_self
Definition: htup.h:65
Oid t_tableOid
Definition: htup.h:66
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:1078

References ACL_CREATE, aclcheck_error(), ACLCHECK_NOT_OWNER, ACLCHECK_OK, aclnewowner(), Assert(), CatalogTupleUpdate(), changeDependencyOnOwner(), check_can_set_role(), DatumGetAclP, get_database_name(), GETSTRUCT, GetUserId(), heap_freetuple(), heap_modify_tuple(), InvokeObjectPostAlterHook, MyDatabaseId, NAMESPACENAME, NameStr, object_aclcheck(), OBJECT_DATABASE, object_ownercheck(), OBJECT_SCHEMA, ObjectIdGetDatum(), PointerGetDatum(), RelationGetDescr, RelationGetRelid, SysCacheGetAttr(), HeapTupleData::t_self, and HeapTupleData::t_tableOid.

Referenced by AlterSchemaOwner(), and AlterSchemaOwner_oid().

◆ AlterSchemaOwner_oid()

void AlterSchemaOwner_oid ( Oid  schemaoid,
Oid  newOwnerId 
)

Definition at line 289 of file schemacmds.c.

290 {
291  HeapTuple tup;
292  Relation rel;
293 
294  rel = table_open(NamespaceRelationId, RowExclusiveLock);
295 
296  tup = SearchSysCache1(NAMESPACEOID, ObjectIdGetDatum(schemaoid));
297  if (!HeapTupleIsValid(tup))
298  elog(ERROR, "cache lookup failed for schema %u", schemaoid);
299 
300  AlterSchemaOwner_internal(tup, rel, newOwnerId);
301 
302  ReleaseSysCache(tup);
303 
305 }
@ NAMESPACEOID
Definition: syscache.h:70

References AlterSchemaOwner_internal(), elog(), ERROR, HeapTupleIsValid, NAMESPACEOID, ObjectIdGetDatum(), ReleaseSysCache(), RowExclusiveLock, SearchSysCache1(), table_close(), and table_open().

Referenced by shdepReassignOwned().

◆ CreateSchemaCommand()

Oid CreateSchemaCommand ( CreateSchemaStmt stmt,
const char *  queryString,
int  stmt_location,
int  stmt_len 
)

Definition at line 51 of file schemacmds.c.

53 {
54  const char *schemaName = stmt->schemaname;
55  Oid namespaceId;
56  OverrideSearchPath *overridePath;
57  List *parsetree_list;
58  ListCell *parsetree_item;
59  Oid owner_uid;
60  Oid saved_uid;
61  int save_sec_context;
62  AclResult aclresult;
63  ObjectAddress address;
64 
65  GetUserIdAndSecContext(&saved_uid, &save_sec_context);
66 
67  /*
68  * Who is supposed to own the new schema?
69  */
70  if (stmt->authrole)
71  owner_uid = get_rolespec_oid(stmt->authrole, false);
72  else
73  owner_uid = saved_uid;
74 
75  /* fill schema name with the user name if not specified */
76  if (!schemaName)
77  {
78  HeapTuple tuple;
79 
80  tuple = SearchSysCache1(AUTHOID, ObjectIdGetDatum(owner_uid));
81  if (!HeapTupleIsValid(tuple))
82  elog(ERROR, "cache lookup failed for role %u", owner_uid);
83  schemaName =
85  ReleaseSysCache(tuple);
86  }
87 
88  /*
89  * To create a schema, must have schema-create privilege on the current
90  * database and must be able to become the target role (this does not
91  * imply that the target role itself must have create-schema privilege).
92  * The latter provision guards against "giveaway" attacks. Note that a
93  * superuser will always have both of these privileges a fortiori.
94  */
95  aclresult = object_aclcheck(DatabaseRelationId, MyDatabaseId, saved_uid, ACL_CREATE);
96  if (aclresult != ACLCHECK_OK)
99 
100  check_can_set_role(saved_uid, owner_uid);
101 
102  /* Additional check to protect reserved schema names */
103  if (!allowSystemTableMods && IsReservedName(schemaName))
104  ereport(ERROR,
105  (errcode(ERRCODE_RESERVED_NAME),
106  errmsg("unacceptable schema name \"%s\"", schemaName),
107  errdetail("The prefix \"pg_\" is reserved for system schemas.")));
108 
109  /*
110  * If if_not_exists was given and the schema already exists, bail out.
111  * (Note: we needn't check this when not if_not_exists, because
112  * NamespaceCreate will complain anyway.) We could do this before making
113  * the permissions checks, but since CREATE TABLE IF NOT EXISTS makes its
114  * creation-permission check first, we do likewise.
115  */
116  if (stmt->if_not_exists)
117  {
118  namespaceId = get_namespace_oid(schemaName, true);
119  if (OidIsValid(namespaceId))
120  {
121  /*
122  * If we are in an extension script, insist that the pre-existing
123  * object be a member of the extension, to avoid security risks.
124  */
125  ObjectAddressSet(address, NamespaceRelationId, namespaceId);
127 
128  /* OK to skip */
129  ereport(NOTICE,
130  (errcode(ERRCODE_DUPLICATE_SCHEMA),
131  errmsg("schema \"%s\" already exists, skipping",
132  schemaName)));
133  return InvalidOid;
134  }
135  }
136 
137  /*
138  * If the requested authorization is different from the current user,
139  * temporarily set the current user so that the object(s) will be created
140  * with the correct ownership.
141  *
142  * (The setting will be restored at the end of this routine, or in case of
143  * error, transaction abort will clean things up.)
144  */
145  if (saved_uid != owner_uid)
146  SetUserIdAndSecContext(owner_uid,
147  save_sec_context | SECURITY_LOCAL_USERID_CHANGE);
148 
149  /* Create the schema's namespace */
150  namespaceId = NamespaceCreate(schemaName, owner_uid, false);
151 
152  /* Advance cmd counter to make the namespace visible */
154 
155  /*
156  * Temporarily make the new namespace be the front of the search path, as
157  * well as the default creation target namespace. This will be undone at
158  * the end of this routine, or upon error.
159  */
161  overridePath->schemas = lcons_oid(namespaceId, overridePath->schemas);
162  /* XXX should we clear overridePath->useTemp? */
163  PushOverrideSearchPath(overridePath);
164 
165  /*
166  * Report the new schema to possibly interested event triggers. Note we
167  * must do this here and not in ProcessUtilitySlow because otherwise the
168  * objects created below are reported before the schema, which would be
169  * wrong.
170  */
171  ObjectAddressSet(address, NamespaceRelationId, namespaceId);
173  (Node *) stmt);
174 
175  /*
176  * Examine the list of commands embedded in the CREATE SCHEMA command, and
177  * reorganize them into a sequentially executable order with no forward
178  * references. Note that the result is still a list of raw parsetrees ---
179  * we cannot, in general, run parse analysis on one statement until we
180  * have actually executed the prior ones.
181  */
182  parsetree_list = transformCreateSchemaStmt(stmt);
183 
184  /*
185  * Execute each command contained in the CREATE SCHEMA. Since the grammar
186  * allows only utility commands in CREATE SCHEMA, there is no need to pass
187  * them through parse_analyze_*() or the rewriter; we can just hand them
188  * straight to ProcessUtility.
189  */
190  foreach(parsetree_item, parsetree_list)
191  {
192  Node *stmt = (Node *) lfirst(parsetree_item);
193  PlannedStmt *wrapper;
194 
195  /* need to make a wrapper PlannedStmt */
196  wrapper = makeNode(PlannedStmt);
197  wrapper->commandType = CMD_UTILITY;
198  wrapper->canSetTag = false;
199  wrapper->utilityStmt = stmt;
200  wrapper->stmt_location = stmt_location;
201  wrapper->stmt_len = stmt_len;
202 
203  /* do this step */
204  ProcessUtility(wrapper,
205  queryString,
206  false,
208  NULL,
209  NULL,
211  NULL);
212 
213  /* make sure later steps can see the object created here */
215  }
216 
217  /* Reset search path to normal state */
219 
220  /* Reset current user and security context */
221  SetUserIdAndSecContext(saved_uid, save_sec_context);
222 
223  return namespaceId;
224 }
Oid get_rolespec_oid(const RoleSpec *role, bool missing_ok)
Definition: acl.c:5289
#define OidIsValid(objectId)
Definition: c.h:759
bool IsReservedName(const char *name)
Definition: catalog.c:219
DestReceiver * None_Receiver
Definition: dest.c:96
int errdetail(const char *fmt,...)
Definition: elog.c:1202
#define NOTICE
Definition: elog.h:35
void EventTriggerCollectSimpleCommand(ObjectAddress address, ObjectAddress secondaryObject, Node *parsetree)
bool allowSystemTableMods
Definition: globals.c:124
#define stmt
Definition: indent_codes.h:59
List * lcons_oid(Oid datum, List *list)
Definition: list.c:530
char * pstrdup(const char *in)
Definition: mcxt.c:1624
MemoryContext CurrentMemoryContext
Definition: mcxt.c:135
#define SECURITY_LOCAL_USERID_CHANGE
Definition: miscadmin.h:304
void GetUserIdAndSecContext(Oid *userid, int *sec_context)
Definition: miscinit.c:631
void SetUserIdAndSecContext(Oid userid, int sec_context)
Definition: miscinit.c:638
void PushOverrideSearchPath(OverrideSearchPath *newpath)
Definition: namespace.c:3533
void PopOverrideSearchPath(void)
Definition: namespace.c:3600
Oid get_namespace_oid(const char *nspname, bool missing_ok)
Definition: namespace.c:3086
OverrideSearchPath * GetOverrideSearchPath(MemoryContext context)
Definition: namespace.c:3403
@ CMD_UTILITY
Definition: nodes.h:281
#define makeNode(_type_)
Definition: nodes.h:176
const ObjectAddress InvalidObjectAddress
List * transformCreateSchemaStmt(CreateSchemaStmt *stmt)
NameData rolname
Definition: pg_authid.h:34
FormData_pg_authid * Form_pg_authid
Definition: pg_authid.h:56
void checkMembershipInCurrentExtension(const ObjectAddress *object)
Definition: pg_depend.c:257
#define lfirst(lc)
Definition: pg_list.h:172
Oid NamespaceCreate(const char *nspName, Oid ownerId, bool isTemp)
Definition: pg_namespace.c:43
#define InvalidOid
Definition: postgres_ext.h:36
Definition: pg_list.h:54
Definition: nodes.h:129
bool canSetTag
Definition: plannodes.h:61
int stmt_location
Definition: plannodes.h:102
int stmt_len
Definition: plannodes.h:103
CmdType commandType
Definition: plannodes.h:53
Node * utilityStmt
Definition: plannodes.h:99
@ AUTHOID
Definition: syscache.h:45
void ProcessUtility(PlannedStmt *pstmt, const char *queryString, bool readOnlyTree, ProcessUtilityContext context, ParamListInfo params, QueryEnvironment *queryEnv, DestReceiver *dest, QueryCompletion *qc)
Definition: utility.c:506
@ PROCESS_UTILITY_SUBCOMMAND
Definition: utility.h:26
void CommandCounterIncrement(void)
Definition: xact.c:1078

References ACL_CREATE, aclcheck_error(), ACLCHECK_OK, allowSystemTableMods, AUTHOID, PlannedStmt::canSetTag, check_can_set_role(), checkMembershipInCurrentExtension(), CMD_UTILITY, CommandCounterIncrement(), PlannedStmt::commandType, CurrentMemoryContext, elog(), ereport, errcode(), errdetail(), errmsg(), ERROR, EventTriggerCollectSimpleCommand(), get_database_name(), get_namespace_oid(), get_rolespec_oid(), GetOverrideSearchPath(), GETSTRUCT, GetUserIdAndSecContext(), HeapTupleIsValid, InvalidObjectAddress, InvalidOid, IsReservedName(), lcons_oid(), lfirst, makeNode, MyDatabaseId, NamespaceCreate(), NameStr, None_Receiver, NOTICE, object_aclcheck(), OBJECT_DATABASE, ObjectAddressSet, ObjectIdGetDatum(), OidIsValid, PopOverrideSearchPath(), PROCESS_UTILITY_SUBCOMMAND, ProcessUtility(), pstrdup(), PushOverrideSearchPath(), ReleaseSysCache(), rolname, OverrideSearchPath::schemas, SearchSysCache1(), SECURITY_LOCAL_USERID_CHANGE, SetUserIdAndSecContext(), stmt, PlannedStmt::stmt_len, PlannedStmt::stmt_location, transformCreateSchemaStmt(), and PlannedStmt::utilityStmt.

Referenced by CreateExtensionInternal(), and ProcessUtilitySlow().

◆ RenameSchema()

ObjectAddress RenameSchema ( const char *  oldname,
const char *  newname 
)

Definition at line 231 of file schemacmds.c.

232 {
233  Oid nspOid;
234  HeapTuple tup;
235  Relation rel;
236  AclResult aclresult;
237  ObjectAddress address;
238  Form_pg_namespace nspform;
239 
240  rel = table_open(NamespaceRelationId, RowExclusiveLock);
241 
243  if (!HeapTupleIsValid(tup))
244  ereport(ERROR,
245  (errcode(ERRCODE_UNDEFINED_SCHEMA),
246  errmsg("schema \"%s\" does not exist", oldname)));
247 
248  nspform = (Form_pg_namespace) GETSTRUCT(tup);
249  nspOid = nspform->oid;
250 
251  /* make sure the new name doesn't exist */
252  if (OidIsValid(get_namespace_oid(newname, true)))
253  ereport(ERROR,
254  (errcode(ERRCODE_DUPLICATE_SCHEMA),
255  errmsg("schema \"%s\" already exists", newname)));
256 
257  /* must be owner */
258  if (!object_ownercheck(NamespaceRelationId, nspOid, GetUserId()))
260  oldname);
261 
262  /* must have CREATE privilege on database */
263  aclresult = object_aclcheck(DatabaseRelationId, MyDatabaseId, GetUserId(), ACL_CREATE);
264  if (aclresult != ACLCHECK_OK)
265  aclcheck_error(aclresult, OBJECT_DATABASE,
267 
268  if (!allowSystemTableMods && IsReservedName(newname))
269  ereport(ERROR,
270  (errcode(ERRCODE_RESERVED_NAME),
271  errmsg("unacceptable schema name \"%s\"", newname),
272  errdetail("The prefix \"pg_\" is reserved for system schemas.")));
273 
274  /* rename */
275  namestrcpy(&nspform->nspname, newname);
276  CatalogTupleUpdate(rel, &tup->t_self, tup);
277 
278  InvokeObjectPostAlterHook(NamespaceRelationId, nspOid, 0);
279 
280  ObjectAddressSet(address, NamespaceRelationId, nspOid);
281 
282  table_close(rel, NoLock);
283  heap_freetuple(tup);
284 
285  return address;
286 }
#define NoLock
Definition: lockdefs.h:34
void namestrcpy(Name name, const char *str)
Definition: name.c:233
#define SearchSysCacheCopy1(cacheId, key1)
Definition: syscache.h:179

References ACL_CREATE, aclcheck_error(), ACLCHECK_NOT_OWNER, ACLCHECK_OK, allowSystemTableMods, CatalogTupleUpdate(), CStringGetDatum(), ereport, errcode(), errdetail(), errmsg(), ERROR, get_database_name(), get_namespace_oid(), GETSTRUCT, GetUserId(), heap_freetuple(), HeapTupleIsValid, InvokeObjectPostAlterHook, IsReservedName(), MyDatabaseId, NAMESPACENAME, namestrcpy(), NoLock, object_aclcheck(), OBJECT_DATABASE, object_ownercheck(), OBJECT_SCHEMA, ObjectAddressSet, OidIsValid, RowExclusiveLock, SearchSysCacheCopy1, HeapTupleData::t_self, table_close(), and table_open().

Referenced by ExecRenameStmt().