* sepgsql_relation_setattr * * It checks privileges to set attribute of the supplied relation */
| 612 | * It checks privileges to set attribute of the supplied relation |
| 613 | */ |
| 614 | void |
| 615 | sepgsql_relation_setattr(Oid relOid) |
| 616 | { |
| 617 | Relation rel; |
| 618 | ScanKeyData skey; |
| 619 | SysScanDesc sscan; |
| 620 | HeapTuple oldtup; |
| 621 | HeapTuple newtup; |
| 622 | Form_pg_class oldform; |
| 623 | Form_pg_class newform; |
| 624 | ObjectAddress object; |
| 625 | char *audit_name; |
| 626 | uint16_t tclass; |
| 627 | |
| 628 | switch (get_rel_relkind(relOid)) |
| 629 | { |
| 630 | case RELKIND_RELATION: |
| 631 | case RELKIND_PARTITIONED_TABLE: |
| 632 | tclass = SEPG_CLASS_DB_TABLE; |
| 633 | break; |
| 634 | case RELKIND_SEQUENCE: |
| 635 | tclass = SEPG_CLASS_DB_SEQUENCE; |
| 636 | break; |
| 637 | case RELKIND_VIEW: |
| 638 | tclass = SEPG_CLASS_DB_VIEW; |
| 639 | break; |
| 640 | case RELKIND_INDEX: |
| 641 | /* deal with indexes specially */ |
| 642 | sepgsql_index_modify(relOid); |
| 643 | return; |
| 644 | default: |
| 645 | /* other relkinds don't need additional work */ |
| 646 | return; |
| 647 | } |
| 648 | |
| 649 | /* |
| 650 | * Fetch newer catalog |
| 651 | */ |
| 652 | rel = table_open(RelationRelationId, AccessShareLock); |
| 653 | |
| 654 | ScanKeyInit(&skey, |
| 655 | Anum_pg_class_oid, |
| 656 | BTEqualStrategyNumber, F_OIDEQ, |
| 657 | ObjectIdGetDatum(relOid)); |
| 658 | |
| 659 | sscan = systable_beginscan(rel, ClassOidIndexId, true, |
| 660 | SnapshotSelf, 1, &skey); |
| 661 | |
| 662 | newtup = systable_getnext(sscan); |
| 663 | if (!HeapTupleIsValid(newtup)) |
| 664 | elog(ERROR, "could not find tuple for relation %u", relOid); |
| 665 | newform = (Form_pg_class) GETSTRUCT(newtup); |
| 666 | |
| 667 | /* |
| 668 | * Fetch older catalog |
| 669 | */ |
| 670 | oldtup = SearchSysCache1(RELOID, ObjectIdGetDatum(relOid)); |
| 671 | if (!HeapTupleIsValid(oldtup)) |
no test coverage detected