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

bug: derived table contains union all statement, return incorrect result set #1882

Open
2 of 3 tasks
davidshiz opened this issue Jun 14, 2023 · 0 comments
Open
2 of 3 tasks
Labels
A-bug Something isn't working

Comments

@davidshiz
Copy link
Collaborator

Have you read the Contributing Guidelines on issues?

Please confirm if bug report does NOT exists already ?

  • I confirm there is no existing issue for this

Describe the problem

mysql> SELECT * FROM (SELECT a FROM t1 UNION ALL SELECT a FROM t2) tu ORDER BY a;
+-------+
| a     |
+-------+
| 65533 |
| 65533 |
|     0 |
|     0 |
|     1 |
|     1 |
+-------+
6 rows in set (0.00 sec)

Expected behavior

mysql> SELECT * FROM (SELECT a FROM t1 UNION ALL SELECT a FROM t2) tu ORDER BY a;
+-------+
| a     |
+-------+
|     0 |
|     0 |
|     1 |
|     1 |
|   253 |
| 65533 |
+-------+
6 rows in set (0.00 sec)

How To Reproduce

CREATE TABLE t1 (a TINYINT UNSIGNED);
INSERT INTO t1 VALUES (0),(1),(0xFF-2);
CREATE TABLE t2 (a SMALLINT UNSIGNED);
INSERT INTO t2 VALUES (0),(1),(0xFFFF-2);
SELECT * FROM (SELECT a FROM t1 UNION ALL SELECT a FROM t2) tu ORDER BY a;

Environment

[root@stonedb-test support-files]# /stonedb57/install/bin/mysqld --version
/stonedb57/install/bin/mysqld  Ver 5.7.36-StoneDB-v1.0.1 for Linux on x86_64 (build-)
build information as follow:
        Repository address: https://github.com/stoneatom/stonedb.git:stonedb-5.7-dev
        Branch name: stonedb-5.7-dev
        Last commit ID: 6b369e5
        Last commit time: Date:   Thu Jun 8 19:16:12 2023 +0800
        Build time: Date: Tue Jun 13 06:00:25 UTC 2023

Are you interested in submitting a PR to solve the problem?

  • Yes, I will!
@davidshiz davidshiz added the A-bug Something isn't working label Jun 14, 2023
@davidshiz davidshiz added this to the StoneDB_5.7_v1.0.4 milestone Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-bug Something isn't working
Projects
Status: No status
Development

No branches or pull requests

1 participant