diff options
author | sergefp@mysql.com <> | 2006-01-25 23:25:23 +0300 |
---|---|---|
committer | sergefp@mysql.com <> | 2006-01-25 23:25:23 +0300 |
commit | 5d0e8d81ee13ef4474266b74a12f98d18894a7e1 (patch) | |
tree | 6eb5453574dbbc5b4cca00daf48ba4aa1f574863 | |
parent | 8d0378f542eab51e03a576c5f908f539770631c7 (diff) | |
download | mariadb-git-5d0e8d81ee13ef4474266b74a12f98d18894a7e1.tar.gz |
BUG#15935: In mysql_update, don't use full index scan when we could have used quick select scan.
-rw-r--r-- | mysql-test/r/update.result | 15 | ||||
-rw-r--r-- | mysql-test/t/update.test | 12 | ||||
-rw-r--r-- | sql/sql_update.cc | 3 |
3 files changed, 28 insertions, 2 deletions
diff --git a/mysql-test/r/update.result b/mysql-test/r/update.result index 7854fd773a1..995c76615d3 100644 --- a/mysql-test/r/update.result +++ b/mysql-test/r/update.result @@ -358,3 +358,18 @@ update t2,t1 set f1=3,f2=3 where f1=f2 and f1=1; affected rows: 3 info: Rows matched: 3 Changed: 3 Warnings: 0 drop table t1,t2; +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, filler1 char(200), filler2 char(200), key(a)); +insert into t2 select A.a + 10*B.a, 'filler','filler' from t1 A, t1 B; +flush status; +update t2 set a=3 where a=2; +show status like 'handler_read%'; +Variable_name Value +Handler_read_first 0 +Handler_read_key 1 +Handler_read_next 1 +Handler_read_prev 0 +Handler_read_rnd 1 +Handler_read_rnd_next 0 +drop table t1, t2; diff --git a/mysql-test/t/update.test b/mysql-test/t/update.test index 95adb40962c..55015075db7 100644 --- a/mysql-test/t/update.test +++ b/mysql-test/t/update.test @@ -287,4 +287,16 @@ update t1 set f1=1 where f1=3; update t2,t1 set f1=3,f2=3 where f1=f2 and f1=1; --disable_info drop table t1,t2; + + +# BUG#15935 +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, filler1 char(200), filler2 char(200), key(a)); +insert into t2 select A.a + 10*B.a, 'filler','filler' from t1 A, t1 B; +flush status; +update t2 set a=3 where a=2; +show status like 'handler_read%'; +drop table t1, t2; + # End of 4.1 tests diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 24c7a278e79..edd16bb4bee 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -212,7 +212,6 @@ int mysql_update(THD *thd, SORT_FIELD *sortorder; ha_rows examined_rows; - used_index= MAX_KEY; // For call to init_read_record() table->sort.io_cache = (IO_CACHE *) my_malloc(sizeof(IO_CACHE), MYF(MY_FAE | MY_ZEROFILL)); if (!(sortorder=make_unireg_sortorder(order, &length)) || @@ -244,7 +243,7 @@ int mysql_update(THD *thd, DISK_BUFFER_SIZE, MYF(MY_WME))) goto err; - if (used_index == MAX_KEY) + if (used_index == MAX_KEY || (select && select->quick)) init_read_record(&info,thd,table,select,0,1); else init_read_record_idx(&info, thd, table, 1, used_index); |