summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/update.result12
-rw-r--r--mysql-test/t/update.test17
-rw-r--r--sql/sql_update.cc4
3 files changed, 33 insertions, 0 deletions
diff --git a/mysql-test/r/update.result b/mysql-test/r/update.result
index 86647e845a9..5357e8367e3 100644
--- a/mysql-test/r/update.result
+++ b/mysql-test/r/update.result
@@ -138,3 +138,15 @@ a b
111 100
111 100
drop table t1;
+CREATE TABLE t1 (
+`id_param` smallint(3) unsigned NOT NULL default '0',
+`nom_option` char(40) NOT NULL default '',
+`valid` tinyint(1) NOT NULL default '0',
+KEY `id_param` (`id_param`,`nom_option`)
+) TYPE=MyISAM;
+INSERT INTO t1 (id_param,nom_option,valid) VALUES (185,'600x1200',1);
+UPDATE t1 SET nom_option='test' WHERE id_param=185 AND nom_option='600x1200' AND valid=1 LIMIT 1;
+select * from t1;
+id_param nom_option valid
+185 test 1
+drop table t1;
diff --git a/mysql-test/t/update.test b/mysql-test/t/update.test
index 359ae815197..6ac8543ec93 100644
--- a/mysql-test/t/update.test
+++ b/mysql-test/t/update.test
@@ -91,3 +91,20 @@ update t1 set b=100 where a=1 order by b desc limit 2;
update t1 set a=a+10+b where a=1 order by b;
select * from t1 order by a,b;
drop table t1;
+
+#
+# Test with limit (Bug #393)
+#
+
+CREATE TABLE t1 (
+ `id_param` smallint(3) unsigned NOT NULL default '0',
+ `nom_option` char(40) NOT NULL default '',
+ `valid` tinyint(1) NOT NULL default '0',
+ KEY `id_param` (`id_param`,`nom_option`)
+ ) TYPE=MyISAM;
+
+INSERT INTO t1 (id_param,nom_option,valid) VALUES (185,'600x1200',1);
+
+UPDATE t1 SET nom_option='test' WHERE id_param=185 AND nom_option='600x1200' AND valid=1 LIMIT 1;
+select * from t1;
+drop table t1;
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index de953aa603b..ed4d6fd9b81 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -231,9 +231,13 @@ int mysql_update(THD *thd,
break; /* purecov: inspected */
}
if (!--limit && using_limit)
+ {
+ error= -1;
break;
+ }
}
}
+ limit= tmp_limit;
end_read_record(&info);
/* Change select to use tempfile */
if (select)