-
-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tianmu): Test cases that supplement custom variables (#1703)
- Loading branch information
1 parent
b728610
commit c95d263
Showing
3 changed files
with
93 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters