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

Commit61a78c7

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 parentf787390 commit61a78c7

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
@@ -4239,7 +4239,10 @@ transformPartitionBoundValue(ParseState *pstate, Node *val,
42394239

42404240
/* Simplify the expression, in case we had a coercion */
42414241
if (!IsA(value,Const))
4242+
{
4243+
assign_expr_collations(pstate,value);
42424244
value= (Node*)expression_planner((Expr*)value);
4245+
}
42434246

42444247
/*
42454248
* 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
@@ -986,6 +986,13 @@ DETAIL: Failing row contains (1, null).
986986
Partition of: parted_notnull_inh_test FOR VALUES IN (1)
987987

988988
drop table parted_notnull_inh_test;
989+
-- check that collations are assigned in partition bound expressions
990+
create table parted_boolean_col (a bool, b text) partition by list(a);
991+
create table parted_boolean_less partition of parted_boolean_col
992+
for values in ('foo' < 'bar');
993+
create table parted_boolean_greater partition of parted_boolean_col
994+
for values in ('foo' > 'bar');
995+
drop table parted_boolean_col;
989996
-- check for a conflicting COLLATE clause
990997
create table parted_collate_must_match (a text collate "C", b text collate "C")
991998
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
@@ -802,6 +802,14 @@ insert into parted_notnull_inh_test (b) values (null);
802802
\d parted_notnull_inh_test1
803803
droptable parted_notnull_inh_test;
804804

805+
-- check that collations are assigned in partition bound expressions
806+
createtableparted_boolean_col (a bool, btext) partition by list(a);
807+
createtableparted_boolean_less partition of parted_boolean_col
808+
forvaluesin ('foo'<'bar');
809+
createtableparted_boolean_greater partition of parted_boolean_col
810+
forvaluesin ('foo'>'bar');
811+
droptable parted_boolean_col;
812+
805813
-- check for a conflicting COLLATE clause
806814
createtableparted_collate_must_match (atext collate"C", btext collate"C")
807815
partition by range (a);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp