Skip to content

Commit df92456

Browse files
yjhjstzmy-ship-it
authored andcommitted
Fix: could not pull up equivalence class using projected target list
Ignore RelabelType nodes on top in pullUpExpr_mutator.
1 parent c711df8 commit df92456

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

src/backend/cdb/cdbpullup.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ pullUpExpr_mutator(Node *node, void *context)
124124
foreach(cell, ctx->targetlist)
125125
{
126126
tlistexpr = (Expr *) lfirst(cell);
127-
127+
/* Ignore RelabelType nodes on top */
128+
while (tlistexpr && IsA(tlistexpr, RelabelType))
129+
tlistexpr = ((RelabelType *) tlistexpr)->arg;
128130
/*
129131
* We don't use equal(), because we want to ignore typmod.
130132
* A projection sometimes loses typmod, and that's OK.

src/test/regress/input/appendonly.source

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,3 +879,18 @@ insert into fix_ao_truncate_last_sequence select 1, 1 from generate_series(1, 5)
879879
select count(*) from fix_ao_truncate_last_sequence;
880880
abort;
881881

882+
create table fix_issue_605
883+
(
884+
c1 varchar(8),
885+
c2 varchar(12) collate "C",
886+
c3 varchar(10),
887+
c4 varchar(30)
888+
)
889+
with (appendonly=true,compresstype=zstd,compresslevel=5)
890+
distributed by (c1,c3,c4)
891+
partition by range(c1)
892+
(partition p1990 start('19900101') inclusive,
893+
default partition other
894+
);
895+
896+
select c3::varchar from fix_issue_605 where c1='20190830' order by c2;

src/test/regress/output/appendonly.source

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,3 +1741,21 @@ select count(*) from fix_ao_truncate_last_sequence;
17411741
(1 row)
17421742

17431743
abort;
1744+
create table fix_issue_605
1745+
(
1746+
c1 varchar(8),
1747+
c2 varchar(12) collate "C",
1748+
c3 varchar(10),
1749+
c4 varchar(30)
1750+
)
1751+
with (appendonly=true,compresstype=zstd,compresslevel=5)
1752+
distributed by (c1,c3,c4)
1753+
partition by range(c1)
1754+
(partition p1990 start('19900101') inclusive,
1755+
default partition other
1756+
);
1757+
select c3::varchar from fix_issue_605 where c1='20190830' order by c2;
1758+
c3
1759+
----
1760+
(0 rows)
1761+

0 commit comments

Comments
 (0)