1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

delete.result, delete.test:

Added a test case for bug #8392.
sql_delete.cc:
  Fixed bug #8392.
  The bug caused a crash for a delete statement with ORDER BY
  that explicitly referred to the modified table.
This commit is contained in:
igor@rurik.mysql.com
2005-02-15 18:45:42 -08:00
parent 548f7dbada
commit d4779d3534
3 changed files with 21 additions and 0 deletions

View File

@ -61,3 +61,12 @@ select * from t1;
a b a b
1 apple 1 apple
drop table t1; drop table t1;
CREATE TABLE t1 ( a int PRIMARY KEY );
DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a;
INSERT INTO t1 VALUES (0),(1),(2);
DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a LIMIT 1;
SELECT * FROM t1;
a
0
2
DROP TABLE t1;

View File

@ -71,3 +71,14 @@ select * from t1;
delete t1 from t1, t1 as t2 where t1.b = t2.b and t1.a > t2.a; delete t1 from t1, t1 as t2 where t1.b = t2.b and t1.a > t2.a;
select * from t1; select * from t1;
drop table t1; drop table t1;
#
# Bug #8392: delete with ORDER BY containing a direct reference to the table
#
CREATE TABLE t1 ( a int PRIMARY KEY );
DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a;
INSERT INTO t1 VALUES (0),(1),(2);
DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a LIMIT 1;
SELECT * FROM t1;
DROP TABLE t1;

View File

@ -111,6 +111,7 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order,
bzero((char*) &tables,sizeof(tables)); bzero((char*) &tables,sizeof(tables));
tables.table = table; tables.table = table;
tables.alias = table_list->alias;
table->io_cache = (IO_CACHE *) my_malloc(sizeof(IO_CACHE), table->io_cache = (IO_CACHE *) my_malloc(sizeof(IO_CACHE),
MYF(MY_FAE | MY_ZEROFILL)); MYF(MY_FAE | MY_ZEROFILL));