Skip to content

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

@ramanich1

Description

@ramanich1

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                                                                  |
+-------------------------+--------------------------------------------------------------------------+

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions