diff --git a/mysql-test/suite/tianmu/r/issue1696.result b/mysql-test/suite/tianmu/r/issue1696.result new file mode 100644 index 000000000..de929cbb8 --- /dev/null +++ b/mysql-test/suite/tianmu/r/issue1696.result @@ -0,0 +1,87 @@ +# Creating test database test_db_1696 +CREATE DATABASE IF NOT EXISTS test_db_1696; +USE test_db_1696; +CREATE DATABASE IF NOT EXISTS test_database; +USE test_database; +CREATE TABLE IF NOT EXISTS t1 ( +id INT NOT NULL, +value INT NOT NULL +) ENGINE=tianmu; +INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 1), (5, 2), (6, 3); +CREATE TABLE IF NOT EXISTS t2 ( +id INT NOT NULL, +value INT NOT NULL +) ENGINE=tianmu; +INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3), (4, 1), (5, 2), (6, 3); +CREATE TABLE IF NOT EXISTS t3 ( +id INT NOT NULL, +value INT NOT NULL +) ENGINE=tianmu; +INSERT INTO t3 VALUES (1, 1), (2, 2), (3, 3), (4, 1), (5, 2), (6, 3); +SET @counter = 0; +SELECT +*, +IF(@counter != 1, @counter, @counter := @counter + 1) AS counter +FROM +( +SELECT +t1.id AS id1, +t1.value AS value1, +t2.id AS id2, +t2.value AS value2, +t3.id AS id3, +t3.value AS value3 +FROM +t1 +JOIN t2 ON t1.value = t2.value +JOIN t3 ON t2.value = t3.value +) AS derived_table; +id1 value1 id2 value2 id3 value3 counter +1 1 1 1 1 1 0 +4 1 1 1 1 1 0 +1 1 1 1 4 1 0 +4 1 1 1 4 1 0 +2 2 2 2 2 2 0 +5 2 2 2 2 2 0 +2 2 2 2 5 2 0 +5 2 2 2 5 2 0 +3 3 3 3 3 3 0 +6 3 3 3 3 3 0 +3 3 3 3 6 3 0 +6 3 3 3 6 3 0 +1 1 4 1 1 1 0 +4 1 4 1 1 1 0 +1 1 4 1 4 1 0 +4 1 4 1 4 1 0 +2 2 5 2 2 2 0 +5 2 5 2 2 2 0 +2 2 5 2 5 2 0 +5 2 5 2 5 2 0 +3 3 6 3 3 3 0 +6 3 6 3 3 3 0 +3 3 6 3 6 3 0 +6 3 6 3 6 3 0 +DROP TABLE t1, t2, t3; +set @rankno = 1; +create table d(taxis_no int); +insert into d values(1); +insert into d values(1); +insert into d values(1); +SELECT IF(@rankno != d.taxis_no, @rankno := 1, @rankno := @rankno + 1) from d; +IF(@rankno != d.taxis_no, @rankno := 1, @rankno := @rankno + 1) +2 +1 +2 +set @rankno = 1; +drop table d; +create table d(taxis_no int); +insert into d values(1); +insert into d values(2); +insert into d values(3); +SELECT IF(@rankno != d.taxis_no, @rankno := 1, @rankno := @rankno + 1) from d; +IF(@rankno != d.taxis_no, @rankno := 1, @rankno := @rankno + 1) +2 +3 +4 +# Dropping test database test_db_1696 +DROP DATABASE IF EXISTS test_db_1696; diff --git a/mysql-test/suite/tianmu/r/issue1696.test b/mysql-test/suite/tianmu/r/issue1696.test deleted file mode 100644 index 6de3674a7..000000000 --- a/mysql-test/suite/tianmu/r/issue1696.test +++ /dev/null @@ -1,73 +0,0 @@ ---source include/have_tianmu.inc - ---disable_warnings - ---echo # Creating test database test_db_1696 -CREATE DATABASE IF NOT EXISTS test_db_1696; - -USE test_db_1696; - -CREATE DATABASE IF NOT EXISTS test_database; -USE test_database; - -CREATE TABLE IF NOT EXISTS t1 ( - id INT NOT NULL, - value INT NOT NULL -) ENGINE=tianmu; - -INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 1), (5, 2), (6, 3); - -CREATE TABLE IF NOT EXISTS t2 ( - id INT NOT NULL, - value INT NOT NULL -) ENGINE=tianmu; - -INSERT INTO t2 VALUES (1, 1), (2, 2), (3, 3), (4, 1), (5, 2), (6, 3); - -CREATE TABLE IF NOT EXISTS t3 ( - id INT NOT NULL, - value INT NOT NULL -) ENGINE=tianmu; - -INSERT INTO t3 VALUES (1, 1), (2, 2), (3, 3), (4, 1), (5, 2), (6, 3); - -SET @counter = 0; - -SELECT - *, - IF(@counter != 1, @counter, @counter := @counter + 1) AS counter -FROM - ( - SELECT - t1.id AS id1, - t1.value AS value1, - t2.id AS id2, - t2.value AS value2, - t3.id AS id3, - t3.value AS value3 - FROM - t1 - JOIN t2 ON t1.value = t2.value - JOIN t3 ON t2.value = t3.value - ) AS derived_table; -DROP TABLE t1, t2, t3; - -create table d(taxis_no int); - -insert into d values(1); -insert into d values(1); -insert into d values(1); - -SELECT IF(@rowno != d.taxis_no, @rankno := 1, @rankno := @rankno + 1) from d; - -drop table d; -create table d(taxis_no int); - -insert into d values(1); -insert into d values(2); -insert into d values(3); - -SELECT IF(@rowno != d.taxis_no, @rankno := 1, @rankno := @rankno + 1) from d; - ---echo # Dropping test database test_db_1696 -DROP DATABASE IF EXISTS test_db_1696; \ No newline at end of file diff --git a/mysql-test/suite/tianmu/t/issue1696.test b/mysql-test/suite/tianmu/t/issue1696.test index 6de3674a7..cdc0ed5dc 100644 --- a/mysql-test/suite/tianmu/t/issue1696.test +++ b/mysql-test/suite/tianmu/t/issue1696.test @@ -52,13 +52,17 @@ FROM ) AS derived_table; DROP TABLE t1, t2, t3; +set @rankno = 1; + create table d(taxis_no int); insert into d values(1); insert into d values(1); insert into d values(1); -SELECT IF(@rowno != d.taxis_no, @rankno := 1, @rankno := @rankno + 1) from d; +SELECT IF(@rankno != d.taxis_no, @rankno := 1, @rankno := @rankno + 1) from d; + +set @rankno = 1; drop table d; create table d(taxis_no int); @@ -67,7 +71,7 @@ insert into d values(1); insert into d values(2); insert into d values(3); -SELECT IF(@rowno != d.taxis_no, @rankno := 1, @rankno := @rankno + 1) from d; +SELECT IF(@rankno != d.taxis_no, @rankno := 1, @rankno := @rankno + 1) from d; --echo # Dropping test database test_db_1696 DROP DATABASE IF EXISTS test_db_1696; \ No newline at end of file