-
-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(tianmu): fix crashed when the subquery includes a SORT clause (#906
) the reason is The subquery generates a temp table, but the count(*) column of the subquery is not a physical column, so the interface is incompatible. so if the virtual column does not point to the physical column, the check is not performed
- Loading branch information
1 parent
08ac72f
commit 1f86173
Showing
4 changed files
with
244 additions
and
4 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,118 @@ | ||
USE test; | ||
DROP TABLE IF EXISTS shop; | ||
CREATE TABLE shop ( | ||
article INT DEFAULT '0000' NOT NULL, | ||
dealer CHAR(20) DEFAULT '' NOT NULL, | ||
price DECIMAL(16,2) DEFAULT '0.00' NOT NULL | ||
) ENGINE=TIANMU; | ||
INSERT INTO shop | ||
VALUES(1, 'A', 3.45),(1, 'B', 3.99), | ||
(2, 'A', 10.99),(3, 'B', 1.45), | ||
(3, 'C', 1.69),(3, 'D', 1.25), | ||
(4, 'D', 19.95); | ||
SELECT | ||
* | ||
FROM | ||
shop | ||
WHERE | ||
article IN ( | ||
SELECT | ||
COUNT(*) | ||
FROM | ||
shop | ||
GROUP BY | ||
article | ||
); | ||
article dealer price | ||
1 A 3.45 | ||
1 B 3.99 | ||
2 A 10.99 | ||
3 B 1.45 | ||
3 C 1.69 | ||
3 D 1.25 | ||
SELECT | ||
* | ||
FROM | ||
shop | ||
WHERE | ||
article NOT IN ( | ||
SELECT | ||
COUNT(*) | ||
FROM | ||
shop | ||
GROUP BY | ||
article | ||
); | ||
article dealer price | ||
4 D 19.95 | ||
SELECT | ||
* | ||
FROM | ||
shop | ||
WHERE | ||
article IN ( | ||
SELECT | ||
COUNT(*) | ||
FROM | ||
shop | ||
GROUP BY | ||
article | ||
) | ||
UNION | ||
SELECT | ||
* | ||
FROM | ||
shop | ||
WHERE | ||
article NOT IN ( | ||
SELECT | ||
COUNT(*) | ||
FROM | ||
shop | ||
GROUP BY | ||
article | ||
); | ||
article dealer price | ||
1 A 3.45 | ||
1 B 3.99 | ||
2 A 10.99 | ||
3 B 1.45 | ||
3 C 1.69 | ||
3 D 1.25 | ||
4 D 19.95 | ||
SELECT | ||
* | ||
FROM | ||
shop | ||
WHERE | ||
article IN ( | ||
SELECT | ||
COUNT(*) | ||
FROM | ||
shop | ||
GROUP BY | ||
article | ||
) | ||
UNION ALL | ||
SELECT | ||
* | ||
FROM | ||
shop | ||
WHERE | ||
article NOT IN ( | ||
SELECT | ||
COUNT(*) | ||
FROM | ||
shop | ||
GROUP BY | ||
article | ||
); | ||
article dealer price | ||
1 A 3.45 | ||
1 B 3.99 | ||
2 A 10.99 | ||
3 B 1.45 | ||
3 C 1.69 | ||
3 D 1.25 | ||
4 D 19.95 | ||
DROP TABLE shop; |
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,118 @@ | ||
--source include/have_tianmu.inc | ||
|
||
USE test; | ||
|
||
--disable_warnings | ||
|
||
DROP TABLE IF EXISTS shop; | ||
|
||
CREATE TABLE shop ( | ||
article INT DEFAULT '0000' NOT NULL, | ||
dealer CHAR(20) DEFAULT '' NOT NULL, | ||
price DECIMAL(16,2) DEFAULT '0.00' NOT NULL | ||
) ENGINE=TIANMU; | ||
|
||
INSERT INTO shop | ||
VALUES(1, 'A', 3.45),(1, 'B', 3.99), | ||
(2, 'A', 10.99),(3, 'B', 1.45), | ||
(3, 'C', 1.69),(3, 'D', 1.25), | ||
(4, 'D', 19.95); | ||
|
||
## subquery | ||
|
||
### EXPR IN subquery | ||
|
||
SELECT | ||
* | ||
FROM | ||
shop | ||
WHERE | ||
article IN ( | ||
SELECT | ||
COUNT(*) | ||
FROM | ||
shop | ||
GROUP BY | ||
article | ||
); | ||
|
||
### EXPR NOT IN subquery | ||
|
||
SELECT | ||
* | ||
FROM | ||
shop | ||
WHERE | ||
article NOT IN ( | ||
SELECT | ||
COUNT(*) | ||
FROM | ||
shop | ||
GROUP BY | ||
article | ||
); | ||
|
||
## union | ||
|
||
SELECT | ||
* | ||
FROM | ||
shop | ||
WHERE | ||
article IN ( | ||
SELECT | ||
COUNT(*) | ||
FROM | ||
shop | ||
GROUP BY | ||
article | ||
) | ||
UNION | ||
SELECT | ||
* | ||
FROM | ||
shop | ||
WHERE | ||
article NOT IN ( | ||
SELECT | ||
COUNT(*) | ||
FROM | ||
shop | ||
GROUP BY | ||
article | ||
); | ||
|
||
## union all | ||
|
||
SELECT | ||
* | ||
FROM | ||
shop | ||
WHERE | ||
article IN ( | ||
SELECT | ||
COUNT(*) | ||
FROM | ||
shop | ||
GROUP BY | ||
article | ||
) | ||
UNION ALL | ||
SELECT | ||
* | ||
FROM | ||
shop | ||
WHERE | ||
article NOT IN ( | ||
SELECT | ||
COUNT(*) | ||
FROM | ||
shop | ||
GROUP BY | ||
article | ||
); | ||
|
||
## clear test table of this issue | ||
|
||
DROP TABLE shop; | ||
|
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
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