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

Set operation UNION with parentheses to order precedence is not supported in TiDB #29416

Closed
ramanich1 opened this issue Nov 3, 2021 · 3 comments · Fixed by #29656
Closed
Assignees
Labels
severity/moderate sig/execution SIG execution type/bug The issue is confirmed as a bug.

Comments

@ramanich1
Copy link
Collaborator

Bug Report

Please answer these questions before submitting your issue. Thanks!

drop table if exists t1,t2,t3,t4;
create table t1 (a int not null, b char (10) not null);
insert into t1 values(1,‘a’),(2,‘b’),(3,‘c’),(3,‘c’);
select * from (((select * from t1)) union (select * from t1) union (select * from t1)) a;

2. What did you expect to see? (Required)

mysql> drop table if exists t1,t2,t3,t4;
Query OK, 0 rows affected, 2 warnings (0.05 sec)

mysql> create table t1 (a int not null, b char (10) not null);
Query OK, 0 rows affected (0.01 sec)

mysql> insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c');
Query OK, 4 rows affected (0.00 sec)
Records: 4  Duplicates: 0  Warnings: 0

mysql> select * from (((select * from t1)) union (select * from t1) union (select * from t1)) a;
+---+---+
| a | b |
+---+---+
| 1 | a |
| 2 | b |
| 3 | c |
+---+---+
3 rows in set (0.00 sec)

3. What did you see instead (Required)

mysql> drop table if exists t1,t2,t3,t4;
Query OK, 0 rows affected, 2 warnings (0.42 sec)

mysql> create table t1 (a int not null, b char (10) not null);
Query OK, 0 rows affected (0.08 sec)

mysql> insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c');
Query OK, 4 rows affected (0.02 sec)
Records: 4  Duplicates: 0  Warnings: 0

mysql> select * from (((select * from t1)) union (select * from t1) union (select * from t1)) a;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 1 column 41 near "union (select * from t1) union (select * from t1)) a" 

4. What is your TiDB version? (Required)

+-------------------------+--------------------------------------------------------------------------+
| Variable_name           | Value                                                                    |
+-------------------------+--------------------------------------------------------------------------+
| innodb_version          | 5.6.25                                                                   |
| protocol_version        | 10                                                                       |
| tidb_analyze_version    | 2                                                                        |
| tidb_row_format_version | 2                                                                        |
| tls_version             | TLSv1,TLSv1.1,TLSv1.2                                                    |
| version                 | 5.7.25-TiDB-v5.2.1                                                       |
| version_comment         | TiDB Server (Apache License 2.0) Community Edition, MySQL 5.7 compatible |
| version_compile_machine | x86_64                                                                   |
| version_compile_os      | osx10.8                                                                  |
+-------------------------+--------------------------------------------------------------------------+
@ramanich1 ramanich1 added the type/bug The issue is confirmed as a bug. label Nov 3, 2021
@sylzd
Copy link
Contributor

sylzd commented Nov 9, 2021

/assign

@sylzd
Copy link
Contributor

sylzd commented Nov 10, 2021

it is because the parser does not support (( subselect )), I tried to make the bracket recursive, but encounter a conflict of shift/reduce. any help would be appreciated.
image

@github-actions
Copy link

github-actions bot commented Dec 2, 2021

Please check whether the issue should be labeled with 'affects-x.y' or 'fixes-x.y.z', and then remove 'needs-more-info' label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/moderate sig/execution SIG execution type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants