Commit 30052a49 authored by unknown's avatar unknown

Fixed bug in UPDATE .. ORDER BY


Docs/manual.texi:
  Changelog
mysql-test/r/update.result:
  Test found bug in UPDATE .. ORDER BY
mysql-test/t/update.test:
  Test found bug in UPDATE .. ORDER BY
parent b70dea90
......@@ -46491,6 +46491,8 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}.
@itemize @bullet
@item
Fixed core dump bug in @code{UPDATE ... ORDER BY }.
@item
Changed @code{INSERT INTO .. SELECT} to by default stop on errors.
@item
Ignore @code{DATA DIRECTORY} and @code{INDEX DIRECTORY} directives on windows.
......@@ -102,3 +102,13 @@ select status from t1;
status
1
drop table t1;
create table t1 (a int not null, b int not null);
insert into t1 values (1,1),(1,2),(1,3);
update t1 set b=4 where a=1 order by b asc limit 1;
update t1 set b=4 where a=1 order by b desc limit 1;
select * from t1;
a b
1 4
1 4
1 2
drop table t1;
......@@ -76,3 +76,14 @@ alter table t1 change lfdnr lfdnr int(10) unsigned default 0 not null auto_incre
update t1 set status=1 where type='Open';
select status from t1;
drop table t1;
#
# Test of ORDER BY
#
create table t1 (a int not null, b int not null);
insert into t1 values (1,1),(1,2),(1,3);
update t1 set b=4 where a=1 order by b asc limit 1;
update t1 set b=4 where a=1 order by b desc limit 1;
select * from t1;
drop table t1;
......@@ -148,7 +148,7 @@ int mysql_update(THD *thd,
used_key_is_modified=check_if_key_used(table, used_index, fields);
else
used_key_is_modified=0;
if (used_key_is_modified)
if (used_key_is_modified || order)
{
/*
** We can't update table directly; We must first search after all
......
......@@ -2305,10 +2305,6 @@ values:
update:
UPDATE_SYM opt_low_priority opt_ignore table_name
SET update_list
where_clause
opt_order_clause
delete_limit_clause
{
LEX *lex=Lex;
lex->sql_command = SQLCOM_UPDATE;
......@@ -2316,6 +2312,10 @@ update:
lex->select->order_list.first=0;
lex->select->order_list.next= (byte**) &lex->select->order_list.first;
}
SET update_list
where_clause
opt_order_clause
delete_limit_clause
update_list:
update_list ',' simple_ident equal expr
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment