File tree 3 files changed +43
-0
lines changed
3 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -538,6 +538,10 @@ CreatePolicy(CreatePolicyStmt *stmt)
538
538
EXPR_KIND_WHERE ,
539
539
"POLICY" );
540
540
541
+ /* Fix up collation information */
542
+ assign_expr_collations (qual_pstate , qual );
543
+ assign_expr_collations (with_check_pstate , with_check_qual );
544
+
541
545
/* Open pg_policy catalog */
542
546
pg_policy_rel = heap_open (PolicyRelationId , RowExclusiveLock );
543
547
@@ -681,6 +685,9 @@ AlterPolicy(AlterPolicyStmt *stmt)
681
685
EXPR_KIND_WHERE ,
682
686
"POLICY" );
683
687
688
+ /* Fix up collation information */
689
+ assign_expr_collations (qual_pstate , qual );
690
+
684
691
qual_parse_rtable = qual_pstate -> p_rtable ;
685
692
free_parsestate (qual_pstate );
686
693
}
@@ -701,6 +708,9 @@ AlterPolicy(AlterPolicyStmt *stmt)
701
708
EXPR_KIND_WHERE ,
702
709
"POLICY" );
703
710
711
+ /* Fix up collation information */
712
+ assign_expr_collations (with_check_pstate , with_check_qual );
713
+
704
714
with_check_parse_rtable = with_check_pstate -> p_rtable ;
705
715
free_parsestate (with_check_pstate );
706
716
}
Original file line number Diff line number Diff line change @@ -2730,6 +2730,27 @@ ERROR: permission denied for relation copy_t
2730
2730
RESET SESSION AUTHORIZATION;
2731
2731
DROP TABLE copy_t;
2732
2732
--
2733
+ -- Collation support
2734
+ --
2735
+ BEGIN;
2736
+ SET row_security = force;
2737
+ CREATE TABLE coll_t (c) AS VALUES ('bar'::text);
2738
+ CREATE POLICY coll_p ON coll_t USING (c < ('foo'::text COLLATE "C"));
2739
+ ALTER TABLE coll_t ENABLE ROW LEVEL SECURITY;
2740
+ SELECT (string_to_array(polqual, ':'))[7] AS inputcollid FROM pg_policy WHERE polrelid = 'coll_t'::regclass;
2741
+ inputcollid
2742
+ ------------------
2743
+ inputcollid 950
2744
+ (1 row)
2745
+
2746
+ SELECT * FROM coll_t;
2747
+ c
2748
+ -----
2749
+ bar
2750
+ (1 row)
2751
+
2752
+ ROLLBACK;
2753
+ --
2733
2754
-- Clean up objects
2734
2755
--
2735
2756
RESET SESSION AUTHORIZATION;
Original file line number Diff line number Diff line change @@ -1087,6 +1087,18 @@ COPY copy_t FROM STDIN; --fail - permission denied.
1087
1087
RESET SESSION AUTHORIZATION;
1088
1088
DROP TABLE copy_t;
1089
1089
1090
+ --
1091
+ -- Collation support
1092
+ --
1093
+ BEGIN ;
1094
+ SET row_security = force;
1095
+ CREATE TABLE coll_t (c) AS VALUES (' bar' ::text );
1096
+ CREATE POLICY coll_p ON coll_t USING (c < (' foo' ::text COLLATE " C" ));
1097
+ ALTER TABLE coll_t ENABLE ROW LEVEL SECURITY;
1098
+ SELECT (string_to_array(polqual, ' :' ))[7 ] AS inputcollid FROM pg_policy WHERE polrelid = ' coll_t' ::regclass;
1099
+ SELECT * FROM coll_t;
1100
+ ROLLBACK ;
1101
+
1090
1102
--
1091
1103
-- Clean up objects
1092
1104
--
You can’t perform that action at this time.
0 commit comments