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

Function sepgsql_proc_setattr

contrib/sepgsql/proc.c:234–307  ·  view source on GitHub ↗

* sepgsql_proc_setattr * * It checks privileges to alter the supplied function. */

Source from the content-addressed store, hash-verified

232 * It checks privileges to alter the supplied function.
233 */
234void
235sepgsql_proc_setattr(Oid functionId)
236{
237 Relation rel;
238 ScanKeyData skey;
239 SysScanDesc sscan;
240 HeapTuple oldtup;
241 HeapTuple newtup;
242 Form_pg_proc oldform;
243 Form_pg_proc newform;
244 uint32 required;
245 ObjectAddress object;
246 char *audit_name;
247
248 /*
249 * Fetch newer catalog
250 */
251 rel = table_open(ProcedureRelationId, AccessShareLock);
252
253 ScanKeyInit(&skey,
254 Anum_pg_proc_oid,
255 BTEqualStrategyNumber, F_OIDEQ,
256 ObjectIdGetDatum(functionId));
257
258 sscan = systable_beginscan(rel, ProcedureOidIndexId, true,
259 SnapshotSelf, 1, &skey);
260 newtup = systable_getnext(sscan);
261 if (!HeapTupleIsValid(newtup))
262 elog(ERROR, "could not find tuple for function %u", functionId);
263 newform = (Form_pg_proc) GETSTRUCT(newtup);
264
265 /*
266 * Fetch older catalog
267 */
268 oldtup = SearchSysCache1(PROCOID, ObjectIdGetDatum(functionId));
269 if (!HeapTupleIsValid(oldtup))
270 elog(ERROR, "cache lookup failed for function %u", functionId);
271 oldform = (Form_pg_proc) GETSTRUCT(oldtup);
272
273 /*
274 * Does this ALTER command takes operation to namespace?
275 */
276 if (newform->pronamespace != oldform->pronamespace)
277 {
278 sepgsql_schema_remove_name(oldform->pronamespace);
279 sepgsql_schema_add_name(oldform->pronamespace);
280 }
281 if (strcmp(NameStr(newform->proname), NameStr(oldform->proname)) != 0)
282 sepgsql_schema_rename(oldform->pronamespace);
283
284 /*
285 * check db_procedure:{setattr (install)} permission
286 */
287 required = SEPG_DB_PROCEDURE__SETATTR;
288 if (!oldform->proleakproof && newform->proleakproof)
289 required |= SEPG_DB_PROCEDURE__INSTALL;
290
291 object.classId = ProcedureRelationId;

Callers 1

sepgsql_object_accessFunction · 0.85

Calls 15

table_openFunction · 0.85
ScanKeyInitFunction · 0.85
ObjectIdGetDatumFunction · 0.85
systable_beginscanFunction · 0.85
systable_getnextFunction · 0.85
SearchSysCache1Function · 0.85
sepgsql_schema_add_nameFunction · 0.85
sepgsql_schema_renameFunction · 0.85
getObjectIdentityFunction · 0.85
sepgsql_avc_check_permsFunction · 0.85
ReleaseSysCacheFunction · 0.85

Tested by

no test coverage detected