Skip to content

Commit 4042330

Browse files
committed
reproduce UNION coercion bug
1 parent 3e8aa8f commit 4042330

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

go/test/endtoend/vtgate/queries/union/schema.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ create table t1_id2_idx(
1313
create table t2(
1414
id3 bigint,
1515
id4 bigint,
16+
e ENUM('a','b','c') DEFAULT 'a',
1617
primary key(id3)
1718
) Engine=InnoDB;
1819

@@ -22,4 +23,4 @@ create table t2_id4_idx(
2223
id3 bigint,
2324
primary key(id),
2425
key idx_id4(id4)
25-
) Engine=InnoDB;
26+
) Engine=InnoDB;

go/test/endtoend/vtgate/queries/union/union_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ func TestUnion(t *testing.T) {
130130
mcmp, closer := start(t)
131131
defer closer()
132132
mcmp.Exec("insert into t1(id1, id2) values(1, 1), (2, 2)")
133+
mcmp.Exec("insert into t2(id3, id4, e) values(1,1,'a'), (2,2,'b'), (3,1,'a'), (4,2,'b')")
133134

134135
mcmp.AssertMatches(`SELECT 1 UNION SELECT 1 UNION SELECT 1`, `[[INT64(1)]]`)
135136
mcmp.AssertMatches(`SELECT 1,'a' UNION SELECT 1,'a' UNION SELECT 1,'a' ORDER BY 1`, `[[INT64(1) VARCHAR("a")]]`)
@@ -140,5 +141,6 @@ func TestUnion(t *testing.T) {
140141
mcmp.AssertMatches(`(SELECT 1,'a' order by 1) union (SELECT 1,'a' ORDER BY 1)`, `[[INT64(1) VARCHAR("a")]]`)
141142
if utils.BinaryIsAtLeastAtVersion(19, "vtgate") {
142143
mcmp.AssertMatches(`(SELECT id2,'a' from t1 where id1 = 1) union (SELECT 'a',id2 from t1 where id1 = 2)`, `[[VARCHAR("1") VARCHAR("a")] [VARCHAR("a") VARCHAR("2")]]`)
144+
mcmp.AssertMatches(`(SELECT id3, e from t2 where e = 'a' and id4 = 1) union (SELECT e, id3 from t2 where e='b' and id4 = 2)`, `[[VARCHAR("1") VARCHAR("a")] [VARCHAR("a") VARCHAR("2")]]`)
143145
}
144146
}

0 commit comments

Comments
 (0)