@@ -188,14 +188,14 @@ query TTTTTT colnames,rowsort
188
188
SHOW POLICIES FOR multi_pol_tab1
189
189
----
190
190
name cmd type roles using_expr with_check_expr
191
- policy8 ALL permissive {papa_roach,public} · ·
192
191
policy1 ALL permissive {public} · ·
193
192
policy2 ALL restrictive {public} · ·
194
193
policy3 ALL permissive {public} · ·
195
194
policy4 INSERT permissive {public} · ·
196
195
policy5 UPDATE permissive {public} · ·
197
196
policy6 DELETE permissive {public} · ·
198
197
policy7 SELECT permissive {public} · ·
198
+ policy8 ALL permissive {public,papa_roach} · ·
199
199
200
200
statement ok
201
201
CREATE TABLE multi_pol_tab2 (c1 INT NOT NULL PRIMARY KEY)
@@ -1367,15 +1367,14 @@ alter_policy_table CREATE TABLE public.alter_policy_table (
1367
1367
CREATE POLICY p_ins ON public.alter_policy_table AS PERMISSIVE FOR INSERT TO public WITH CHECK (nextval('public.seq1'::REGCLASS) < 10000:::INT8);
1368
1368
CREATE POLICY p_sel ON public.alter_policy_table AS PERMISSIVE FOR SELECT TO aux1, alter_policy_role, aux2 USING (c1 != 1:::INT8)
1369
1369
1370
- # TODO(143358): Include roles in the SHOW POLICIES output.
1371
- query TTTTT colnames
1372
- SELECT name,cmd,type,using_expr,with_check_expr
1370
+ query TTTTTT colnames
1371
+ SELECT name,cmd,type,roles,using_expr,with_check_expr
1373
1372
FROM [SHOW POLICIES FOR alter_policy_table]
1374
1373
ORDER BY name DESC;
1375
1374
----
1376
- name cmd type using_expr with_check_expr
1377
- p_sel SELECT permissive c1 != 1:::INT8 ·
1378
- p_ins INSERT permissive · nextval('public.seq1'::REGCLASS) < 10000:::INT8
1375
+ name cmd type roles using_expr with_check_expr
1376
+ p_sel SELECT permissive {alter_policy_role,aux1,aux2} c1 != 1:::INT8 ·
1377
+ p_ins INSERT permissive {public} · nextval('public.seq1'::REGCLASS) < 10000:::INT8
1379
1378
1380
1379
statement ok
1381
1380
SET ROLE root;
@@ -2573,7 +2572,7 @@ CREATE POLICY p1 ON rls_disabled USING (true);
2573
2572
statement ok
2574
2573
ALTER TABLE rls_disabled DISABLE ROW LEVEL SECURITY;
2575
2574
2576
- query TTTTTT colnames,rowsort
2575
+ query TTTTTT colnames
2577
2576
SHOW POLICIES FOR rls_disabled;
2578
2577
----
2579
2578
name cmd type roles using_expr with_check_expr
@@ -2586,10 +2585,9 @@ CREATE TABLE no_policies (id INT PRIMARY KEY);
2586
2585
statement ok
2587
2586
ALTER TABLE no_policies ENABLE ROW LEVEL SECURITY;
2588
2587
2589
- query TTTTTT colnames,rowsort
2588
+ query TTTTTT
2590
2589
SHOW POLICIES FOR no_policies;
2591
2590
----
2592
- name cmd type roles using_expr with_check_expr
2593
2591
2594
2592
# This is another test for multiple policies. But the focus here is how multiple
2595
2593
# policies are applied when they apply for other commands. For example, having
@@ -2873,4 +2871,66 @@ DROP TABLE cnt;
2873
2871
statement ok
2874
2872
DROP USER r1_user;
2875
2873
2874
+ subtest show_policies_roles_and_users
2875
+
2876
+ statement ok
2877
+ CREATE ROLE test_role1;
2878
+
2879
+ statement ok
2880
+ CREATE ROLE test_role2;
2881
+
2882
+ statement ok
2883
+ CREATE USER test_user1;
2884
+
2885
+ statement ok
2886
+ CREATE USER test_user2;
2887
+
2888
+ statement ok
2889
+ CREATE TABLE policy_roles_test (id INT PRIMARY KEY, val TEXT);
2890
+
2891
+ statement ok
2892
+ CREATE POLICY mixed_policy ON policy_roles_test TO test_role1, test_user1, test_role2, test_user2;
2893
+
2894
+ query TTTTTT colnames
2895
+ SHOW POLICIES FOR policy_roles_test
2896
+ ----
2897
+ name cmd type roles using_expr with_check_expr
2898
+ mixed_policy ALL permissive {test_role1,test_role2,test_user1,test_user2} · ·
2899
+
2900
+ statement ok
2901
+ CREATE POLICY users_only_policy ON policy_roles_test TO test_user1, test_user2;
2902
+
2903
+ query TTTTTT colnames,rowsort
2904
+ SHOW POLICIES FOR policy_roles_test
2905
+ ----
2906
+ name cmd type roles using_expr with_check_expr
2907
+ mixed_policy ALL permissive {test_role1,test_role2,test_user1,test_user2} · ·
2908
+ users_only_policy ALL permissive {test_user1,test_user2} · ·
2909
+
2910
+ statement ok
2911
+ CREATE POLICY roles_only_policy ON policy_roles_test TO test_role1, test_role2;
2912
+
2913
+ query TTTTTT colnames,rowsort
2914
+ SHOW POLICIES FOR policy_roles_test
2915
+ ----
2916
+ name cmd type roles using_expr with_check_expr
2917
+ mixed_policy ALL permissive {test_role1,test_role2,test_user1,test_user2} · ·
2918
+ roles_only_policy ALL permissive {test_role1,test_role2} · ·
2919
+ users_only_policy ALL permissive {test_user1,test_user2} · ·
2920
+
2921
+ statement ok
2922
+ DROP TABLE policy_roles_test;
2923
+
2924
+ statement ok
2925
+ DROP USER test_user1;
2926
+
2927
+ statement ok
2928
+ DROP USER test_user2;
2929
+
2930
+ statement ok
2931
+ DROP ROLE test_role1;
2932
+
2933
+ statement ok
2934
+ DROP ROLE test_role2;
2935
+
2876
2936
subtest end
0 commit comments