• Davi Arnaut's avatar
    Backport of Bug#27525 to mysql-next-mr · e26de1ca
    Davi Arnaut authored
    ------------------------------------------------------------
    revno: 2572.2.1
    revision-id: sp1r-davi@mysql.com/endora.local-20080227225948-16317
    parent: sp1r-anozdrin/alik@quad.-20080226165712-10409
    committer: davi@mysql.com/endora.local
    timestamp: Wed 2008-02-27 19:59:48 -0300
    message:
      Bug#27525 table not found when using multi-table-deletes with aliases over several databas
      Bug#30234 Unexpected behavior using DELETE with AS and USING
    
      The multi-delete statement has a documented limitation that
      cross-database multiple-table deletes using aliases are not
      supported because it fails to find the tables by alias if it
      belongs to a different database. The problem is that when
      building the list of tables to delete from, if a database
      name is not specified (maybe an alias) it defaults to the
      name of the current selected database, making impossible to
      to properly resolve tables by alias later. Another problem
      is a inconsistency of the multiple table delete syntax that
      permits ambiguities in a delete statement (aliases that refer
      to multiple different tables or vice-versa).
    
      The first step for a solution and proper implementation of
      the cross-databse multiple table delete is to get rid of any
      ambiguities in a multiple table statement. Currently, the parser
      is accepting multiple table delete statements that have no obvious
      meaning, such as:
    
      DELETE a1 FROM db1.t1 AS a1, db2.t2 AS a1;
      DELETE a1 AS a1 FROM db1.t1 AS a1, db2.t2 AS a1;
    
      The solution is to resolve the left part of a delete statement
      using the right part, if the a table on right has an alias,
      it must be referenced in the left using the given alias. Also,
      each table on the left side must match unambiguously only one
      table in the right side.
    
    mysql-test/r/delete.result:
      Add test case result for Bug#27525 and Bug#21148
    mysql-test/r/derived.result:
      Update error.
    mysql-test/suite/rpl/r/rpl_multi_delete2.result:
      Update syntax.
    mysql-test/suite/rpl/t/rpl_multi_delete2.test:
      Update syntax.
    mysql-test/t/delete.test:
      Add test case for Bug#27525 and Bug#21148
    mysql-test/t/derived.test:
      Update statement error, alias is properly resolved now.
    sql/sql_parse.cc:
      Implement new algorithm for the resolution of alias in
      a multiple table delete statement.
    sql/sql_yacc.yy:
      Rework multi-delete parser rules to not accept table alias
      for the table source list.
    sql/table.h:
      Add flag to signal that the table has a alias set or
      that fully qualified table name was given.
    e26de1ca
sql_parse.cc 242 KB