* sepgsql_proc_setattr * * It checks privileges to alter the supplied function. */
| 232 | * It checks privileges to alter the supplied function. |
| 233 | */ |
| 234 | void |
| 235 | sepgsql_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; |
no test coverage detected