diff options
author | unknown <Sinisa@sinisa.nasamreza.org> | 2002-12-18 19:00:00 +0200 |
---|---|---|
committer | unknown <Sinisa@sinisa.nasamreza.org> | 2002-12-18 19:00:00 +0200 |
commit | 387e26cf488f5ecdc11554ed726b9bb584aa4d01 (patch) | |
tree | 96d83582e1c00611c11e7e643719729653f3dc5d | |
parent | c44bcf4601eea2211073c815818bcdcc85955e68 (diff) | |
download | mariadb-git-387e26cf488f5ecdc11554ed726b9bb584aa4d01.tar.gz |
Fix for found rows in multi-table updates
-rw-r--r-- | mysql-test/r/multi_update.result | 10 | ||||
-rw-r--r-- | mysql-test/t/multi_update.test | 10 | ||||
-rw-r--r-- | sql/sql_update.cc | 5 |
3 files changed, 22 insertions, 3 deletions
diff --git a/mysql-test/r/multi_update.result b/mysql-test/r/multi_update.result index 8cf035343b1..fe028a4cb95 100644 --- a/mysql-test/r/multi_update.result +++ b/mysql-test/r/multi_update.result @@ -236,3 +236,13 @@ n d 1 30 1 30 drop table t1,t2; +drop table if exists t1,t2,t3; +CREATE TABLE t1 ( broj int(4) unsigned NOT NULL default '0', naziv char(25) NOT NULL default 'NEPOZNAT', PRIMARY KEY (broj)) TYPE=MyISAM; +INSERT INTO t1 VALUES (1,'jedan'),(2,'dva'),(3,'tri'),(4,'xxxxxxxxxx'),(5,'a'),(10,''),(11,''),(12,''),(13,''); +CREATE TABLE t2 ( broj int(4) unsigned NOT NULL default '0', naziv char(25) NOT NULL default 'NEPOZNAT', PRIMARY KEY (broj)) TYPE=MyISAM; +INSERT INTO t2 VALUES (1,'jedan'),(2,'dva'),(3,'tri'),(4,'xxxxxxxxxx'),(5,'a'); +CREATE TABLE t3 ( broj int(4) unsigned NOT NULL default '0', naziv char(25) NOT NULL default 'NEPOZNAT', PRIMARY KEY (broj)) TYPE=MyISAM; +INSERT INTO t3 VALUES (1,'jedan'),(2,'dva'); +update t1,t2 set t1.naziv="aaaa" where t1.broj=t2.broj; +update t1,t2,t3 set t1.naziv="bbbb", t2.naziv="aaaa" where t1.broj=t2.broj and t2.broj=t3.broj; +drop table if exists t1,t2,t3; diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test index ff456b710c1..088b355a17c 100644 --- a/mysql-test/t/multi_update.test +++ b/mysql-test/t/multi_update.test @@ -214,3 +214,13 @@ UPDATE t1,t2 SET t1.d=t2.d,t2.d=30 WHERE t1.n=t2.n; select * from t1; select * from t2; drop table t1,t2; +drop table if exists t1,t2,t3; +CREATE TABLE t1 ( broj int(4) unsigned NOT NULL default '0', naziv char(25) NOT NULL default 'NEPOZNAT', PRIMARY KEY (broj)) TYPE=MyISAM; +INSERT INTO t1 VALUES (1,'jedan'),(2,'dva'),(3,'tri'),(4,'xxxxxxxxxx'),(5,'a'),(10,''),(11,''),(12,''),(13,''); +CREATE TABLE t2 ( broj int(4) unsigned NOT NULL default '0', naziv char(25) NOT NULL default 'NEPOZNAT', PRIMARY KEY (broj)) TYPE=MyISAM; +INSERT INTO t2 VALUES (1,'jedan'),(2,'dva'),(3,'tri'),(4,'xxxxxxxxxx'),(5,'a'); +CREATE TABLE t3 ( broj int(4) unsigned NOT NULL default '0', naziv char(25) NOT NULL default 'NEPOZNAT', PRIMARY KEY (broj)) TYPE=MyISAM; +INSERT INTO t3 VALUES (1,'jedan'),(2,'dva'); +update t1,t2 set t1.naziv="aaaa" where t1.broj=t2.broj; +update t1,t2,t3 set t1.naziv="bbbb", t2.naziv="aaaa" where t1.broj=t2.broj and t2.broj=t3.broj; +drop table if exists t1,t2,t3; diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 8a349671c50..9817dcd2be5 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -614,7 +614,6 @@ bool multi_update::send_data(List<Item> ¬_used_values) TABLE_LIST *cur_table; DBUG_ENTER("multi_update::send_data"); - found++; for (cur_table= update_tables; cur_table ; cur_table= cur_table->next) { TABLE *table= cur_table->table; @@ -630,6 +629,7 @@ bool multi_update::send_data(List<Item> ¬_used_values) store_record(table,1); if (fill_record(*fields_for_table[offset], *values_for_table[offset])) DBUG_RETURN(1); + found++; if (compare_record(table, thd->query_id)) { int error; @@ -656,7 +656,7 @@ bool multi_update::send_data(List<Item> ¬_used_values) int error; TABLE *tmp_table= tmp_tables[offset]; fill_record(tmp_table->field+1, *values_for_table[offset]); - + found++; /* Store pointer to row */ memcpy((char*) tmp_table->field[0]->ptr, (char*) table->file->ref, table->file->ref_length); @@ -754,7 +754,6 @@ int multi_update::do_updates(bool from_send_error) continue; // May happen on dup key goto err; } - found++; if ((local_error= table->file->rnd_pos(table->record[0], ref_pos))) goto err; table->status|= STATUS_UPDATED; |