Skip to content

Commit

Permalink
feat(tianmu): Test cases that supplement custom variables (#1703)
Browse files Browse the repository at this point in the history
  • Loading branch information
adofsauron authored and mergify[bot] committed May 6, 2023
1 parent b728610 commit c95d263
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 75 deletions.
87 changes: 87 additions & 0 deletions mysql-test/suite/tianmu/r/issue1696.result
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;
73 changes: 0 additions & 73 deletions mysql-test/suite/tianmu/r/issue1696.test

This file was deleted.

8 changes: 6 additions & 2 deletions mysql-test/suite/tianmu/t/issue1696.test
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;

0 comments on commit c95d263

Please sign in to comment.