52 int stmt_location,
int stmt_len)
54 const char *schemaName =
stmt->schemaname;
73 owner_uid = saved_uid;
82 elog(
ERROR,
"cache lookup failed for role %u", owner_uid);
105 (
errcode(ERRCODE_RESERVED_NAME),
106 errmsg(
"unacceptable schema name \"%s\"", schemaName),
107 errdetail(
"The prefix \"pg_\" is reserved for system schemas.")));
116 if (
stmt->if_not_exists)
130 (
errcode(ERRCODE_DUPLICATE_SCHEMA),
131 errmsg(
"schema \"%s\" already exists, skipping",
145 if (saved_uid != owner_uid)
190 foreach(parsetree_item, parsetree_list)
245 (
errcode(ERRCODE_UNDEFINED_SCHEMA),
246 errmsg(
"schema \"%s\" does not exist", oldname)));
249 nspOid = nspform->oid;
254 (
errcode(ERRCODE_DUPLICATE_SCHEMA),
255 errmsg(
"schema \"%s\" already exists", newname)));
270 (
errcode(ERRCODE_RESERVED_NAME),
271 errmsg(
"unacceptable schema name \"%s\"", newname),
272 errdetail(
"The prefix \"pg_\" is reserved for system schemas.")));
298 elog(
ERROR,
"cache lookup failed for schema %u", schemaoid);
325 (
errcode(ERRCODE_UNDEFINED_SCHEMA),
326 errmsg(
"schema \"%s\" does not exist",
name)));
329 nspOid = nspform->oid;
356 if (nspForm->nspowner != newOwnerId)
358 Datum repl_val[Natts_pg_namespace];
359 bool repl_null[Natts_pg_namespace];
360 bool repl_repl[Natts_pg_namespace];
390 memset(repl_null,
false,
sizeof(repl_null));
391 memset(repl_repl,
false,
sizeof(repl_repl));
393 repl_repl[Anum_pg_namespace_nspowner - 1] =
true;
401 Anum_pg_namespace_nspacl,
406 nspForm->nspowner, newOwnerId);
407 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 OidIsValid(objectId)
bool IsReservedName(const char *name)
char * get_database_name(Oid dbid)
elog(ERROR, "%s: %s", p2, msg)
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
HeapTuple heap_modify_tuple(HeapTuple tuple, TupleDesc tupleDesc, Datum *replValues, bool *replIsnull, bool *doReplace)
void heap_freetuple(HeapTuple htup)
#define HeapTupleIsValid(tuple)
void CatalogTupleUpdate(Relation heapRel, ItemPointer otid, HeapTuple tup)
Assert(fmt[strlen(fmt) - 1] !='\n')
List * lcons_oid(Oid datum, List *list)
char * pstrdup(const char *in)
MemoryContext CurrentMemoryContext
#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)
void PushOverrideSearchPath(OverrideSearchPath *newpath)
void PopOverrideSearchPath(void)
Oid get_namespace_oid(const char *nspname, bool missing_ok)
OverrideSearchPath * GetOverrideSearchPath(MemoryContext context)
#define InvokeObjectPostAlterHook(classId, objectId, subId)
const ObjectAddress InvalidObjectAddress
#define ObjectAddressSet(addr, class_id, object_id)
List * transformCreateSchemaStmt(CreateSchemaStmt *stmt)
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)
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 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)