diff options
-rw-r--r-- | Docs/manual.texi | 2 | ||||
-rw-r--r-- | mysql-test/r/update.result | 10 | ||||
-rw-r--r-- | mysql-test/t/update.test | 11 | ||||
-rw-r--r-- | sql/sql_update.cc | 2 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 8 |
5 files changed, 28 insertions, 5 deletions
diff --git a/Docs/manual.texi b/Docs/manual.texi index bc62ef00d69..4d68eed64d2 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -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. diff --git a/mysql-test/r/update.result b/mysql-test/r/update.result index 4fa1f3513b2..436f837ab68 100644 --- a/mysql-test/r/update.result +++ b/mysql-test/r/update.result @@ -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; diff --git a/mysql-test/t/update.test b/mysql-test/t/update.test index 6f446a11521..5cbbd2a350e 100644 --- a/mysql-test/t/update.test +++ b/mysql-test/t/update.test @@ -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; diff --git a/sql/sql_update.cc b/sql/sql_update.cc index fbf8239bf69..fec40d61f91 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -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 diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index ee8a0ae930d..076e6d98356 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -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 |