static void ATExecDropOf(Relation rel, LOCKMODE lockmode);
static void ATExecReplicaIdentity(Relation rel, ReplicaIdentityStmt *stmt, LOCKMODE lockmode);
static void ATExecGenericOptions(Relation rel, List *options);
-static void ATExecEnableRowSecurity(Relation rel);
-static void ATExecDisableRowSecurity(Relation rel);
+static void ATExecSetRowSecurity(Relation rel, bool rls);
static void ATExecForceNoForceRowSecurity(Relation rel, bool force_rls);
static void index_copy_data(Relation rel, RelFileNode newrnode);
ATExecReplicaIdentity(rel, (ReplicaIdentityStmt *) cmd->def, lockmode);
break;
case AT_EnableRowSecurity:
- ATExecEnableRowSecurity(rel);
+ ATExecSetRowSecurity(rel, true);
break;
case AT_DisableRowSecurity:
- ATExecDisableRowSecurity(rel);
+ ATExecSetRowSecurity(rel, false);
break;
case AT_ForceRowSecurity:
ATExecForceNoForceRowSecurity(rel, true);
* ALTER TABLE ENABLE/DISABLE ROW LEVEL SECURITY
*/
static void
-ATExecEnableRowSecurity(Relation rel)
-{
- Relation pg_class;
- Oid relid;
- HeapTuple tuple;
-
- relid = RelationGetRelid(rel);
-
- pg_class = table_open(RelationRelationId, RowExclusiveLock);
-
- tuple = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relid));
-
- if (!HeapTupleIsValid(tuple))
- elog(ERROR, "cache lookup failed for relation %u", relid);
-
- ((Form_pg_class) GETSTRUCT(tuple))->relrowsecurity = true;
- CatalogTupleUpdate(pg_class, &tuple->t_self, tuple);
-
- table_close(pg_class, RowExclusiveLock);
- heap_freetuple(tuple);
-}
-
-static void
-ATExecDisableRowSecurity(Relation rel)
+ATExecSetRowSecurity(Relation rel, bool rls)
{
Relation pg_class;
Oid relid;
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for relation %u", relid);
- ((Form_pg_class) GETSTRUCT(tuple))->relrowsecurity = false;
+ ((Form_pg_class) GETSTRUCT(tuple))->relrowsecurity = rls;
CatalogTupleUpdate(pg_class, &tuple->t_self, tuple);
table_close(pg_class, RowExclusiveLock);