@@ -525,8 +525,7 @@ static ObjectAddress ATExecAddOf(Relation rel, const TypeName *ofTypename, LOCKM
525525static void ATExecDropOf(Relation rel, LOCKMODE lockmode);
526526static void ATExecReplicaIdentity(Relation rel, ReplicaIdentityStmt *stmt, LOCKMODE lockmode);
527527static 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);
530529static void ATExecForceNoForceRowSecurity(Relation rel, bool force_rls);
531530
532531static void index_copy_data(Relation rel, RelFileNode newrnode);
@@ -4823,10 +4822,10 @@ ATExecCmd(List **wqueue, AlteredTableInfo *tab, Relation rel,
48234822 ATExecReplicaIdentity(rel, (ReplicaIdentityStmt *) cmd->def, lockmode);
48244823 break;
48254824 case AT_EnableRowSecurity:
4826- ATExecEnableRowSecurity (rel);
4825+ ATExecSetRowSecurity (rel, true );
48274826 break;
48284827 case AT_DisableRowSecurity:
4829- ATExecDisableRowSecurity (rel);
4828+ ATExecSetRowSecurity (rel, false );
48304829 break;
48314830 case AT_ForceRowSecurity:
48324831 ATExecForceNoForceRowSecurity(rel, true);
@@ -14813,30 +14812,7 @@ ATExecReplicaIdentity(Relation rel, ReplicaIdentityStmt *stmt, LOCKMODE lockmode
1481314812 * ALTER TABLE ENABLE/DISABLE ROW LEVEL SECURITY
1481414813 */
1481514814static 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)
1484014816{
1484114817 Relation pg_class;
1484214818 Oid relid;
@@ -14852,7 +14828,7 @@ ATExecDisableRowSecurity(Relation rel)
1485214828 if (!HeapTupleIsValid(tuple))
1485314829 elog(ERROR, "cache lookup failed for relation %u", relid);
1485414830
14855- ((Form_pg_class) GETSTRUCT(tuple))->relrowsecurity = false ;
14831+ ((Form_pg_class) GETSTRUCT(tuple))->relrowsecurity = rls ;
1485614832 CatalogTupleUpdate(pg_class, &tuple->t_self, tuple);
1485714833
1485814834 table_close(pg_class, RowExclusiveLock);
0 commit comments