File tree Expand file tree Collapse file tree 3 files changed +43
-0
lines changed Expand file tree Collapse file tree 3 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -538,6 +538,10 @@ CreatePolicy(CreatePolicyStmt *stmt)
538538 EXPR_KIND_WHERE ,
539539 "POLICY" );
540540
541+ /* Fix up collation information */
542+ assign_expr_collations (qual_pstate , qual );
543+ assign_expr_collations (with_check_pstate , with_check_qual );
544+
541545 /* Open pg_policy catalog */
542546 pg_policy_rel = heap_open (PolicyRelationId , RowExclusiveLock );
543547
@@ -681,6 +685,9 @@ AlterPolicy(AlterPolicyStmt *stmt)
681685 EXPR_KIND_WHERE ,
682686 "POLICY" );
683687
688+ /* Fix up collation information */
689+ assign_expr_collations (qual_pstate , qual );
690+
684691 qual_parse_rtable = qual_pstate -> p_rtable ;
685692 free_parsestate (qual_pstate );
686693 }
@@ -701,6 +708,9 @@ AlterPolicy(AlterPolicyStmt *stmt)
701708 EXPR_KIND_WHERE ,
702709 "POLICY" );
703710
711+ /* Fix up collation information */
712+ assign_expr_collations (with_check_pstate , with_check_qual );
713+
704714 with_check_parse_rtable = with_check_pstate -> p_rtable ;
705715 free_parsestate (with_check_pstate );
706716 }
Original file line number Diff line number Diff line change @@ -2730,6 +2730,27 @@ ERROR: permission denied for relation copy_t
27302730RESET SESSION AUTHORIZATION;
27312731DROP TABLE copy_t;
27322732--
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+ --
27332754-- Clean up objects
27342755--
27352756RESET SESSION AUTHORIZATION;
Original file line number Diff line number Diff line change @@ -1087,6 +1087,18 @@ COPY copy_t FROM STDIN; --fail - permission denied.
10871087RESET SESSION AUTHORIZATION;
10881088DROP TABLE copy_t;
10891089
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+
10901102--
10911103-- Clean up objects
10921104--
You can’t perform that action at this time.
0 commit comments