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

Commit29f20db

Browse files
committed
Assign collations in partition bound expressions.
Failure to do this can result in errors during evaluation ofthe bound expression, as illustrated by the new regression test.Back-patch to v12 where the ability for partition bounds to beexpressions was added.Discussion:https://postgr.es/m/CAJV4CdrZ5mKuaEsRSbLf2URQ3h6iMtKD=hik8MaF5WwdmC9uZw@mail.gmail.com
1 parentbda3273 commit29f20db

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

‎src/backend/parser/parse_utilcmd.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4197,7 +4197,10 @@ transformPartitionBoundValue(ParseState *pstate, Node *val,
41974197

41984198
/* Simplify the expression, in case we had a coercion */
41994199
if (!IsA(value,Const))
4200+
{
4201+
assign_expr_collations(pstate,value);
42004202
value= (Node*)expression_planner((Expr*)value);
4203+
}
42014204

42024205
/*
42034206
* transformExpr() should have already rejected column references,

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,13 @@ DETAIL: Failing row contains (1, null).
937937
Partition of: parted_notnull_inh_test FOR VALUES IN (1)
938938

939939
drop table parted_notnull_inh_test;
940+
-- check that collations are assigned in partition bound expressions
941+
create table parted_boolean_col (a bool, b text) partition by list(a);
942+
create table parted_boolean_less partition of parted_boolean_col
943+
for values in ('foo' < 'bar');
944+
create table parted_boolean_greater partition of parted_boolean_col
945+
for values in ('foo' > 'bar');
946+
drop table parted_boolean_col;
940947
-- check for a conflicting COLLATE clause
941948
create table parted_collate_must_match (a text collate "C", b text collate "C")
942949
partition by range (a);

‎src/test/regress/sql/create_table.sql‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,14 @@ insert into parted_notnull_inh_test (b) values (null);
769769
\d parted_notnull_inh_test1
770770
droptable parted_notnull_inh_test;
771771

772+
-- check that collations are assigned in partition bound expressions
773+
createtableparted_boolean_col (a bool, btext) partition by list(a);
774+
createtableparted_boolean_less partition of parted_boolean_col
775+
forvaluesin ('foo'<'bar');
776+
createtableparted_boolean_greater partition of parted_boolean_col
777+
forvaluesin ('foo'>'bar');
778+
droptable parted_boolean_col;
779+
772780
-- check for a conflicting COLLATE clause
773781
createtableparted_collate_must_match (atext collate"C", btext collate"C")
774782
partition by range (a);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp