Pure-reference catalog of row/tenant isolation mechanisms across four database engines: MySQL and MariaDB (no native RLS - views with SQL SECURITY INVOKER plus app-layer enforcement), CockroachDB (native RLS via ALTER TABLE ENABLE ROW LEVEL SECURITY and CREATE POLICY, matching Postgres semantics), Vitess (keyspace sharding + vindexes route tenant writes to dedicated shards without a policy layer), and SQL Server (CREATE SECURITY POLICY with inline table-valued function filter/block predicates). Covers the isolation mechanism, tenant-context pattern, bypass risks, and test patterns for each engine. Use when designing or auditing tenant isolation on MySQL, MariaDB, CockroachDB, Vitess, or SQL Server.
79
99%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
CockroachDB supports native row-level security that closely mirrors Postgres RLS.
ALTER TABLE documents ENABLE ROW LEVEL SECURITY;
-- Force table owners to obey policies too:
ALTER TABLE documents FORCE ROW LEVEL SECURITY;CREATE POLICY policy_name ON table AS [PERMISSIVE | RESTRICTIVE] FOR [SELECT | INSERT | UPDATE | DELETE | ALL] TO role USING (condition) [WITH CHECK (condition)]. Per the CockroachDB RLS docs: USING filters
rows on reads and updates; WITH CHECK validates writes and defaults to
USING when omitted; permissive policies combine with OR, restrictive
with AND; access is denied by default once RLS is enabled and no policy
applies.
CockroachDB has no Postgres-style SET LOCAL + current_setting
transaction variable. The canonical pattern reads the tenant from
application_name, a session variable every client sets at connection
open:
SET application_name = 'tenant:<uuid>';
CREATE POLICY tenant_isolation ON documents
FOR ALL
TO app_role
USING (
tenant_id = split_part(current_setting('application_name'), ':', 2)::uuid
)
WITH CHECK (
tenant_id = split_part(current_setting('application_name'), ':', 2)::uuid
);Per the CockroachDB RLS docs, these paths bypass RLS and need separate controls:
| Bypass | Behaviour |
|---|---|
| Foreign key constraints and cascades | Not subject to RLS |
| Primary / unique key constraints | Not subject to RLS |
TRUNCATE | Not subject to RLS |
| Change Data Capture (CDC) | Queries fail with error when RLS is enabled |
| Backup and restore | Ignore RLS policies |
| Logical and physical cluster replication | Ignore RLS policies |
Source: CockroachDB RLS cockroachlabs.com/docs/stable/row-level-security.html.