@@ -525,8 +525,7 @@ static ObjectAddress ATExecAddOf(Relation rel, const TypeName *ofTypename, LOCKM
525
525
static void ATExecDropOf(Relation rel, LOCKMODE lockmode);
526
526
static void ATExecReplicaIdentity(Relation rel, ReplicaIdentityStmt *stmt, LOCKMODE lockmode);
527
527
static void ATExecGenericOptions(Relation rel, List *options);
528
- static void ATExecEnableRowSecurity(Relation rel);
529
- static void ATExecDisableRowSecurity(Relation rel);
528
+ static void ATExecSetRowSecurity(Relation rel, bool rls);
530
529
static void ATExecForceNoForceRowSecurity(Relation rel, bool force_rls);
531
530
532
531
static void index_copy_data(Relation rel, RelFileNode newrnode);
@@ -4823,10 +4822,10 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab, Relation rel,
4823
4822
ATExecReplicaIdentity(rel, (ReplicaIdentityStmt *) cmd->def, lockmode);
4824
4823
break;
4825
4824
case AT_EnableRowSecurity:
4826
- ATExecEnableRowSecurity (rel);
4825
+ ATExecSetRowSecurity (rel, true );
4827
4826
break;
4828
4827
case AT_DisableRowSecurity:
4829
- ATExecDisableRowSecurity (rel);
4828
+ ATExecSetRowSecurity (rel, false );
4830
4829
break;
4831
4830
case AT_ForceRowSecurity:
4832
4831
ATExecForceNoForceRowSecurity(rel, true);
@@ -14813,30 +14812,7 @@ ATExecReplicaIdentity(Relation rel, ReplicaIdentityStmt *stmt, LOCKMODE lockmode
14813
14812
* ALTER TABLE ENABLE/DISABLE ROW LEVEL SECURITY
14814
14813
*/
14815
14814
static void
14816
- ATExecEnableRowSecurity(Relation rel)
14817
- {
14818
- Relation pg_class;
14819
- Oid relid;
14820
- HeapTuple tuple;
14821
-
14822
- relid = RelationGetRelid(rel);
14823
-
14824
- pg_class = table_open(RelationRelationId, RowExclusiveLock);
14825
-
14826
- tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relid));
14827
-
14828
- if (!HeapTupleIsValid(tuple))
14829
- elog(ERROR, "cache lookup failed for relation %u", relid);
14830
-
14831
- ((Form_pg_class) GETSTRUCT(tuple))->relrowsecurity = true;
14832
- CatalogTupleUpdate(pg_class, &tuple->t_self, tuple);
14833
-
14834
- table_close(pg_class, RowExclusiveLock);
14835
- heap_freetuple(tuple);
14836
- }
14837
-
14838
- static void
14839
- ATExecDisableRowSecurity(Relation rel)
14815
+ ATExecSetRowSecurity(Relation rel, bool rls)
14840
14816
{
14841
14817
Relation pg_class;
14842
14818
Oid relid;
@@ -14852,7 +14828,7 @@ ATExecDisableRowSecurity(Relation rel)
14852
14828
if (!HeapTupleIsValid(tuple))
14853
14829
elog(ERROR, "cache lookup failed for relation %u", relid);
14854
14830
14855
- ((Form_pg_class) GETSTRUCT(tuple))->relrowsecurity = false ;
14831
+ ((Form_pg_class) GETSTRUCT(tuple))->relrowsecurity = rls ;
14856
14832
CatalogTupleUpdate(pg_class, &tuple->t_self, tuple);
14857
14833
14858
14834
table_close(pg_class, RowExclusiveLock);
0 commit comments