Bird
0
0

You wrote this policy:

medium📝 Debug Q6 of 15
PostgreSQL - Roles and Security
You wrote this policy:
CREATE POLICY access_policy ON projects FOR SELECT USING (user_id = current_user);

But queries still return all rows to all users. What is the likely mistake?
ARow-level security is not enabled on the projects table.
BThe policy syntax is incorrect and causes an error.
CThe policy should use session_user instead of current_user.
DThe policy needs a TO clause specifying users.
Step-by-Step Solution
Solution:
  1. Step 1: Check if RLS is enabled

    Policies have no effect unless RLS is enabled on the table.
  2. Step 2: Identify why all rows are visible

    If RLS is off, all rows are visible regardless of policies.
  3. Final Answer:

    Row-level security is not enabled on the projects table. -> Option A
  4. Quick Check:

    RLS must be enabled for policies to apply = Row-level security is not enabled on the projects table. [OK]
Quick Trick: Enable RLS before creating policies to enforce row filtering. [OK]
Common Mistakes:
  • Assuming policy syntax error causes no filtering
  • Confusing current_user with session_user
  • Thinking TO clause is mandatory

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes