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

feature: The query is not supported if use constant queries after union all. #1860

Closed
haitaoguan opened this issue Jun 7, 2023 · 3 comments · Fixed by #1887
Closed

feature: The query is not supported if use constant queries after union all. #1860

haitaoguan opened this issue Jun 7, 2023 · 3 comments · Fixed by #1887
Assignees
Labels
A-feature feature with good idea prio: high High priority

Comments

@haitaoguan
Copy link
Collaborator

haitaoguan commented Jun 7, 2023

The engine we used here is : Tianmu

mysql> create table tt(id decimal(18,0));
Query OK, 0 rows affected (0.13 sec)

mysql> insert into tt values(1111.0);
Query OK, 1 row affected (0.01 sec)

mysql> select * from tt;
+------+
| id   |
+------+
| 1111 |
+------+
1 row in set (0.00 sec)

mysql> select id from tt union all select 2222 c1 from dual;
ERROR 6 (HY000): The query includes syntax that is not supported by the storage engine. Either restructure the query with supported syntax, or enable the MySQL core::Query Path in config file to execute the query with reduced performance.

Expected behavior
mysql> select id from tt union all select 2222 c1 from dual;
+------+
| id   |
+------+
| 1111 |
| 2222 |
+------+
2 rows in set (0.00 sec)
@haitaoguan haitaoguan added the A-feature feature with good idea label Jun 7, 2023
@haitaoguan
Copy link
Collaborator Author

mysql> create table ttt(name varchar(5));
Query OK, 0 rows affected (0.01 sec)

mysql> insert into ttt values('AAA');
Query OK, 1 row affected (0.00 sec)

mysql> select name from ttt union all select 'BBB' C1 from dual;
ERROR 6 (HY000): The query includes syntax that is not supported by the storage engine. Either restructure the query with supported syntax, or enable the MySQL core::Query Path in config file to execute the query with reduced performance.

@RingsC
Copy link
Contributor

RingsC commented Jun 15, 2023

Ref to #1883

From the exception message indicated that the root cause maybe in the following reasons:
1: The table dual is not recongnized as a tianmu table, therefore, tianmu execution engine dont think that this sql statement can be executed in tianmu layer.

in Query::Compile fuction, it returns kToMySQL at processing the second statement of union. Diving into deeper, we find that it can not handle the join condition via AddJoins.

2: select xxx from dual, as we know that dual is a dummy table, which has not any real sql syntax roles in a statement. It's just only for usage convention. Therefore, in tianmu layer, it cannot deal with this sql pattern properly.

Incorrect query plan:

T:-1 = TABLE_ALIAS(T:0,"t1")
T:-2 = TMP_TABLE(T:4294967295)
VC:-2.0 = CREATE_VC(T:-2,PHYS_COL(T:-1,A:0))
A:-1 = T:-2.ADD_COLUMN(VC:-2.0,LIST,"a","ALL")
T:-2.APPLY_CONDS()
T:-3 = TMP_TABLE(T:4294967295)
VC:-3.0 = CREATE_VC(T:-3,EXPR("123"))
A:-1 = T:-3.ADD_COLUMN(VC:-3.0,LIST,"123","ALL")
MSG: T:-3.APPLY_CONDS()
T:-2 = UNION(T:-2,T:-3,0)
RESULT(T:-2)

@RingsC
Copy link
Contributor

RingsC commented Jun 15, 2023

mysql>  select id from tt union all select 2222 c1 from dual;
+------+
| id   |
+------+
| 1111 |
| 2222 |
+------+

mysql>  select id from tt union all select 2222 ;
+------+
| id   |
+------+
| 1111 |
| 2222 |
+------+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-feature feature with good idea prio: high High priority
Projects
Development

Successfully merging a pull request may close this issue.

3 participants