MCPcopy Create free account
hub / github.com/apache/cloudberry / checkMembershipInCurrentExtension

Function checkMembershipInCurrentExtension

src/backend/catalog/pg_depend.c:252–281  ·  view source on GitHub ↗

* If we are executing a CREATE EXTENSION operation, check that the given * object is a member of the extension, and throw an error if it isn't. * Otherwise, do nothing. * * This must be called whenever a CREATE IF NOT EXISTS operation (for an * object type that can be an extension member) has found that an object of * the desired name already exists. It is insecure for an extension to use

Source from the content-addressed store, hash-verified

250 * properties.
251 */
252void
253checkMembershipInCurrentExtension(const ObjectAddress *object)
254{
255 /*
256 * This is actually the same condition tested in
257 * recordDependencyOnCurrentExtension; but we want to issue a
258 * differently-worded error, and anyway it would be pretty confusing to
259 * call recordDependencyOnCurrentExtension in these circumstances.
260 */
261
262 /* Only whole objects can be extension members */
263 Assert(object->objectSubId == 0);
264
265 if (creating_extension)
266 {
267 Oid oldext;
268
269 oldext = getExtensionOfObject(object->classId, object->objectId);
270 /* If already a member of this extension, OK */
271 if (oldext == CurrentExtensionObject)
272 return;
273 /* Else complain */
274 ereport(ERROR,
275 (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
276 errmsg("%s is not a member of extension \"%s\"",
277 getObjectDescription(object, false),
278 get_extension_name(CurrentExtensionObject)),
279 errdetail("An extension may only use CREATE ... IF NOT EXISTS to skip object creation if the conflicting object is one that it already owns.")));
280 }
281}
282
283/*
284 * deleteDependencyRecordsFor -- delete all records with given depender

Callers 6

ExecCreateTableAsFunction · 0.85
CreateForeignServerFunction · 0.85
CreateSchemaCommandFunction · 0.85
DefineSequenceFunction · 0.85
transformCreateStmtFunction · 0.85
CollationCreateFunction · 0.85

Calls 6

getExtensionOfObjectFunction · 0.85
getObjectDescriptionFunction · 0.85
get_extension_nameFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50
errdetailFunction · 0.50

Tested by

no test coverage detected