Commit 53239a71 authored by unknown's avatar unknown

Fix for found rows in multi-table updates

parent 172d5acb
...@@ -236,3 +236,13 @@ n d ...@@ -236,3 +236,13 @@ n d
1 30 1 30
1 30 1 30
drop table t1,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;
...@@ -214,3 +214,13 @@ UPDATE t1,t2 SET t1.d=t2.d,t2.d=30 WHERE t1.n=t2.n; ...@@ -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 t1;
select * from t2; select * from t2;
drop table t1,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;
...@@ -614,7 +614,6 @@ bool multi_update::send_data(List<Item> &not_used_values) ...@@ -614,7 +614,6 @@ bool multi_update::send_data(List<Item> &not_used_values)
TABLE_LIST *cur_table; TABLE_LIST *cur_table;
DBUG_ENTER("multi_update::send_data"); DBUG_ENTER("multi_update::send_data");
found++;
for (cur_table= update_tables; cur_table ; cur_table= cur_table->next) for (cur_table= update_tables; cur_table ; cur_table= cur_table->next)
{ {
TABLE *table= cur_table->table; TABLE *table= cur_table->table;
...@@ -630,6 +629,7 @@ bool multi_update::send_data(List<Item> &not_used_values) ...@@ -630,6 +629,7 @@ bool multi_update::send_data(List<Item> &not_used_values)
store_record(table,1); store_record(table,1);
if (fill_record(*fields_for_table[offset], *values_for_table[offset])) if (fill_record(*fields_for_table[offset], *values_for_table[offset]))
DBUG_RETURN(1); DBUG_RETURN(1);
found++;
if (compare_record(table, thd->query_id)) if (compare_record(table, thd->query_id))
{ {
int error; int error;
...@@ -656,7 +656,7 @@ bool multi_update::send_data(List<Item> &not_used_values) ...@@ -656,7 +656,7 @@ bool multi_update::send_data(List<Item> &not_used_values)
int error; int error;
TABLE *tmp_table= tmp_tables[offset]; TABLE *tmp_table= tmp_tables[offset];
fill_record(tmp_table->field+1, *values_for_table[offset]); fill_record(tmp_table->field+1, *values_for_table[offset]);
found++;
/* Store pointer to row */ /* Store pointer to row */
memcpy((char*) tmp_table->field[0]->ptr, memcpy((char*) tmp_table->field[0]->ptr,
(char*) table->file->ref, table->file->ref_length); (char*) table->file->ref, table->file->ref_length);
...@@ -754,7 +754,6 @@ int multi_update::do_updates(bool from_send_error) ...@@ -754,7 +754,6 @@ int multi_update::do_updates(bool from_send_error)
continue; // May happen on dup key continue; // May happen on dup key
goto err; goto err;
} }
found++;
if ((local_error= table->file->rnd_pos(table->record[0], ref_pos))) if ((local_error= table->file->rnd_pos(table->record[0], ref_pos)))
goto err; goto err;
table->status|= STATUS_UPDATED; table->status|= STATUS_UPDATED;
......
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