[MDEV-10109] Disallow syntactically INSERT .. SELECT .. {ORDER BY ..| LIMIT ..} .. UNION .. Created: 2016-05-24  Updated: 2016-05-24  Resolved: 2016-05-24

Status: Closed
Project: MariaDB Server
Component/s: Parser
Fix Version/s: 10.2.1

Type: Task Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Blocks
blocks MDEV-8909 union parser cleanup Closed

 Description   

These queries:

INSERT INTO t3 SELECT 1 ORDER BY 1 UNION SELECT 2;
INSERT INTO t3 SELECT 1 LIMIT 1 UNION SELECT 2;
CREATE TABLE t1 AS SELECT 1 ORDER BY 1 UNION SELECT 2;
CREATE TABLE t1 AS SELECT 1 LIMIT 1 UNION SELECT 2;

are currently disallowed by this code in add_select_to_union_list():

  if (lex->current_select->order_list.first && !lex->current_select->braces)
  {
    my_error(ER_WRONG_USAGE, MYF(0), "UNION", "ORDER BY");
    return TRUE;
  }
 
  if (lex->current_select->explicit_limit && !lex->current_select->braces)
  {
    my_error(ER_WRONG_USAGE, MYF(0), "UNION", "LIMIT");
    return TRUE;
  }

We'll change the grammar to return syntax errors instead.


Generated at Thu Feb 08 07:39:44 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.