Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tianmu): Test cases that supplement custom variables (#1703) #1705

Merged
merged 1 commit into from
May 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;