Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit808ea8f

Browse files
committed
Add assign_expr_collations() to CreatePolicy() and AlterPolicy().
As noted by Noah Misch, CreatePolicy() and AlterPolicy() omit to callassign_expr_collations() on the node trees. Fix the omission and addhis test case to the rowsecurity regression test.
1 parentcba045b commit808ea8f

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

‎src/backend/commands/policy.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

‎src/test/regress/expected/rowsecurity.out

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2730,6 +2730,27 @@ ERROR: permission denied for relation copy_t
27302730
RESET SESSION AUTHORIZATION;
27312731
DROP 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
--
27352756
RESET SESSION AUTHORIZATION;

‎src/test/regress/sql/rowsecurity.sql

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,18 @@ COPY copy_t FROM STDIN; --fail - permission denied.
10871087
RESET SESSION AUTHORIZATION;
10881088
DROPTABLE copy_t;
10891089

1090+
--
1091+
-- Collation support
1092+
--
1093+
BEGIN;
1094+
SET row_security= force;
1095+
CREATETABLEcoll_t (c)ASVALUES ('bar'::text);
1096+
CREATE POLICY coll_pON coll_t USING (c< ('foo'::text COLLATE"C"));
1097+
ALTERTABLE coll_t ENABLE ROW LEVEL SECURITY;
1098+
SELECT (string_to_array(polqual,':'))[7]AS inputcollidFROM pg_policyWHERE polrelid='coll_t'::regclass;
1099+
SELECT*FROM coll_t;
1100+
ROLLBACK;
1101+
10901102
--
10911103
-- Clean up objects
10921104
--

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp