Details
-
Task
-
Status: Closed (View Workflow)
-
Blocker
-
Resolution: Fixed
-
None
Description
Subqueries are not allowed in a number of clauses, e.g.:
- EXECUTE IMMEDIATE expr
- EXECUTE .. USING expr
- PREPARE stmt FROM expr
- SELECT .. PROCEDURE ANALYSE(expr, expr)
- PURGE BINARY LOGS BEFORE expr
- HANDLER t1 READ a=expr
If a subquery appears in a disallowed context, a syntax error is reported:
EXECUTE IMMEDIATE (SELECT 'SELECT 1'); |
ERROR 42000: You have an error in your SQL syntax ... near 'SELECT 'SELECT 1')' at line 1
|
The grammar uses remember_tok_start to remember the start position of a subquery, to use this position for error reporting:
subselect:
|
remember_tok_start
|
query_expression
|
{
|
if (!($$= Lex->parsed_subselect($2, $1))) |
YYABORT;
|
}
|
;
|
Under terms of MDEV-19956 the grammar will be changed significantly. The remember_tok_start has to be removed to avoid shift/reduce and reduce/reduce conflicts.
Let's change the error message from ER_SYNTAX_ERROR to ER_SUBQUERIES_NOT_SUPPORTED.
So it will look as follows:
EXECUTE IMMEDIATE (SELECT 'SELECT 1'); |
ERROR 42000: EXECUTE IMMEDIATE does not support subqueries or stored functions
|
Rationale:
- Preserving the old messages is challenging
- The proposed error message is more informative
Attachments
Issue Links
- blocks
-
MDEV-19956 Queries with subqueries containing UNION are not parsed
- Closed