53 int stmt_location,
int stmt_len)
55 const char *schemaName =
stmt->schemaname;
76 owner_uid = saved_uid;
85 elog(
ERROR,
"cache lookup failed for role %u", owner_uid);
108 (
errcode(ERRCODE_RESERVED_NAME),
109 errmsg(
"unacceptable schema name \"%s\"", schemaName),
110 errdetail(
"The prefix \"pg_\" is reserved for system schemas.")));
119 if (
stmt->if_not_exists)
133 (
errcode(ERRCODE_DUPLICATE_SCHEMA),
134 errmsg(
"schema \"%s\" already exists, skipping",
148 if (saved_uid != owner_uid)
206 foreach(parsetree_item, parsetree_list)
263 (
errcode(ERRCODE_UNDEFINED_SCHEMA),
264 errmsg(
"schema \"%s\" does not exist", oldname)));
267 nspOid = nspform->oid;
272 (
errcode(ERRCODE_DUPLICATE_SCHEMA),
273 errmsg(
"schema \"%s\" already exists", newname)));
288 (
errcode(ERRCODE_RESERVED_NAME),
289 errmsg(
"unacceptable schema name \"%s\"", newname),
290 errdetail(
"The prefix \"pg_\" is reserved for system schemas.")));
316 elog(
ERROR,
"cache lookup failed for schema %u", schemaoid);
343 (
errcode(ERRCODE_UNDEFINED_SCHEMA),
344 errmsg(
"schema \"%s\" does not exist",
name)));
347 nspOid = nspform->oid;
374 if (nspForm->nspowner != newOwnerId)
376 Datum repl_val[Natts_pg_namespace];
377 bool repl_null[Natts_pg_namespace];
378 bool repl_repl[Natts_pg_namespace];
408 memset(repl_null,
false,
sizeof(repl_null));
409 memset(repl_repl,
false,
sizeof(repl_repl));
411 repl_repl[Anum_pg_namespace_nspowner - 1] =
true;
419 Anum_pg_namespace_nspacl,
424 nspForm->nspowner, newOwnerId);
425 repl_repl[Anum_pg_namespace_nspacl - 1] =
true;
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)
bool object_ownercheck(Oid classid, Oid objectid, Oid roleid)
#define Assert(condition)
#define OidIsValid(objectId)
bool IsReservedName(const char *name)
char * get_database_name(Oid dbid)
DestReceiver * None_Receiver
int errdetail(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
void EventTriggerCollectSimpleCommand(ObjectAddress address, ObjectAddress secondaryObject, Node *parsetree)
bool allowSystemTableMods
int NewGUCNestLevel(void)
void AtEOXact_GUC(bool isCommit, int nestLevel)
int set_config_option(const char *name, const char *value, GucContext context, GucSource source, GucAction action, bool changeVal, int elevel, bool is_reload)
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)
void CatalogTupleUpdate(Relation heapRel, ItemPointer otid, HeapTuple tup)
char * pstrdup(const char *in)
#define SECURITY_LOCAL_USERID_CHANGE
void GetUserIdAndSecContext(Oid *userid, int *sec_context)
void SetUserIdAndSecContext(Oid userid, int sec_context)
void namestrcpy(Name name, const char *str)
Oid get_namespace_oid(const char *nspname, bool missing_ok)
char * namespace_search_path
#define InvokeObjectPostAlterHook(classId, objectId, subId)
const ObjectAddress InvalidObjectAddress
#define ObjectAddressSet(addr, class_id, object_id)
List * transformCreateSchemaStmtElements(List *schemaElts, const char *schemaName)
FormData_pg_authid * Form_pg_authid
void checkMembershipInCurrentExtension(const ObjectAddress *object)
Oid NamespaceCreate(const char *nspName, Oid ownerId, bool isTemp)
FormData_pg_namespace * Form_pg_namespace
void changeDependencyOnOwner(Oid classId, Oid objectId, Oid newOwnerId)
static Datum PointerGetDatum(const void *X)
static Datum ObjectIdGetDatum(Oid X)
static Datum CStringGetDatum(const char *X)
#define RelationGetRelid(relation)
#define RelationGetDescr(relation)
const char * quote_identifier(const char *ident)
bool scanner_isspace(char ch)
Oid CreateSchemaCommand(CreateSchemaStmt *stmt, const char *queryString, int stmt_location, int stmt_len)
void AlterSchemaOwner_oid(Oid schemaoid, Oid newOwnerId)
ObjectAddress AlterSchemaOwner(const char *name, Oid newOwnerId)
ObjectAddress RenameSchema(const char *oldname, const char *newname)
static void AlterSchemaOwner_internal(HeapTuple tup, Relation rel, Oid newOwnerId)
void appendStringInfo(StringInfo str, const char *fmt,...)
void appendStringInfoString(StringInfo str, const char *s)
void initStringInfo(StringInfo str)
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
#define SearchSysCacheCopy1(cacheId, key1)
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
void ProcessUtility(PlannedStmt *pstmt, const char *queryString, bool readOnlyTree, ProcessUtilityContext context, ParamListInfo params, QueryEnvironment *queryEnv, DestReceiver *dest, QueryCompletion *qc)
@ PROCESS_UTILITY_SUBCOMMAND
void CommandCounterIncrement(void)