Details
-
Bug
-
Status: Closed (View Workflow)
-
Minor
-
Resolution: Won't Fix
-
2.3.20
-
None
-
MXS-SPRINT-190
Description
The following SQL statements fail to parse due to the fact that the SELECT statements are surrounded by an extra set of parentheses.
./compare -v 3 -0 qc_sqlite -s "SELECT * FROM ((SELECT @@last_insert_id) UNION (SELECT @@last_insert_id)) t"
|
(0): SELECT * FROM ((SELECT @@last_insert_id) UNION (SELECT @@last_insert_id)) t
|
qc_parse : Ok : QC_QUERY_TOKENIZED
|
qc_get_type_mask : Ok : QUERY_TYPE_READ
|
qc_get_operation : Ok : QUERY_OP_SELECT
|
qc_get_created_table_name: Ok : NULL
|
qc_is_drop_table_query : Ok : 0
|
qc_get_table_names : Ok :
|
qc_get_table_names(full) : Ok :
|
qc_query_has_clause : Ok : 0
|
qc_get_database_names : Ok :
|
qc_get_prepare_name : Ok : NULL
|
qc_get_field_info : Ok :
|
qc_get_function_info : Ok :
|
Moving the UNION out from the subselect or removing the parentheses around it solves the problem:
./compare -v 3 -0 qc_sqlite -s "SELECT * FROM (SELECT @@last_insert_id UNION SELECT @@last_insert_id) t"
|
(0): SELECT * FROM (SELECT @@last_insert_id UNION SELECT @@last_insert_id) t
|
qc_parse : Ok : QC_QUERY_PARSED
|
qc_get_type_mask : Ok : QUERY_TYPE_READ|QUERY_TYPE_MASTER_READ
|
qc_get_operation : Ok : QUERY_OP_SELECT
|
qc_get_created_table_name: Ok : NULL
|
qc_is_drop_table_query : Ok : 0
|
qc_get_table_names : Ok :
|
qc_get_table_names(full) : Ok :
|
qc_query_has_clause : Ok : 0
|
qc_get_database_names : Ok :
|
qc_get_prepare_name : Ok : NULL
|
qc_get_field_info : Ok : *
|
qc_get_function_info : Ok :
|
|
./compare -v 3 -0 qc_sqlite -s "(SELECT @@last_insert_id) UNION (SELECT @@last_insert_id)"
|
(0): (SELECT @@last_insert_id) UNION (SELECT @@last_insert_id)
|
qc_parse : Ok : QC_QUERY_PARTIALLY_PARSED
|
qc_get_type_mask : Ok : QUERY_TYPE_READ|QUERY_TYPE_MASTER_READ
|
qc_get_operation : Ok : QUERY_OP_SELECT
|
qc_get_created_table_name: Ok : NULL
|
qc_is_drop_table_query : Ok : 0
|
qc_get_table_names : Ok :
|
qc_get_table_names(full) : Ok :
|
qc_query_has_clause : Ok : 0
|
qc_get_database_names : Ok :
|
qc_get_prepare_name : Ok : NULL
|
qc_get_field_info : Ok :
|
qc_get_function_info : Ok :
|
Original description:
first one is:
select * from (SELECT s.hrdocid FROM scheduleteacher s where s.orgid = @OrgId UNION SELECT u.hrdocId FROM `user` u WHERE u.orgid = @OrgId) t; |
|
second one is:
select * from ((SELECT s.hrdocid FROM scheduleteacher s where s.orgid = @OrgId) UNION (SELECT u.hrdocId FROM `user` u WHERE u.orgid = @OrgId)) t |
for 2.2:
user variable in the first one can be parsed, but not the second one.
for 2.3:
it seems that both SQLs are not parsed correctly.