diff options
author | unknown <monty@mashka.mysql.fi> | 2003-03-16 16:28:30 +0200 |
---|---|---|
committer | unknown <monty@mashka.mysql.fi> | 2003-03-16 16:28:30 +0200 |
commit | 2640e74e39eabef15be0b3161ca5958c14eb7096 (patch) | |
tree | c05688514a8bfc597bdeb7bbae3718151a59fd89 /sql | |
parent | 1ce34eaf6168974d180d954bfe578be2bdf1d5a7 (diff) | |
download | mariadb-git-2640e74e39eabef15be0b3161ca5958c14eb7096.tar.gz |
Write binlog before commit when doing INSERT ... SELECT
mysql-test/r/create.result:
After merge fix
sql/sql_insert.cc:
Write binlog before commit
sql/sql_update.cc:
Added comment
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_insert.cc | 14 | ||||
-rw-r--r-- | sql/sql_update.cc | 13 |
2 files changed, 20 insertions, 7 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 9f1a0e93cb9..ace15771449 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1361,6 +1361,14 @@ bool select_insert::send_eof() if (!(error=table->file->extra(HA_EXTRA_NO_CACHE))) error=table->file->activate_all_index(thd); table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); + + /* Write to binlog before commiting transaction */ + if (mysql_bin_log.is_open()) + { + Query_log_event qinfo(thd, thd->query, thd->query_length, + table->file->has_transactions()); + mysql_bin_log.write(&qinfo); + } if ((error2=ha_autocommit_or_rollback(thd,error)) && ! error) error=error2; if (info.copied || info.deleted) @@ -1386,12 +1394,6 @@ bool select_insert::send_eof() thd->insert_id(last_insert_id); // For update log ::send_ok(&thd->net,info.copied,last_insert_id,buff); mysql_update_log.write(thd,thd->query,thd->query_length); - if (mysql_bin_log.is_open()) - { - Query_log_event qinfo(thd, thd->query, thd->query_length, - table->file->has_transactions()); - mysql_bin_log.write(&qinfo); - } return 0; } } diff --git a/sql/sql_update.cc b/sql/sql_update.cc index adb60adb7d6..d8842855093 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -618,7 +618,18 @@ bool multi_update::send_data(List<Item> ¬_used_values) for (cur_table= update_tables; cur_table ; cur_table= cur_table->next) { TABLE *table= cur_table->table; - /* Check if we are using outer join and we didn't find the row */ + /* + Check if we are using outer join and we didn't find the row + or if we have already updated this row in the previous call to this + function. + + The same row may be presented here several times in a join of type + UPDATE t1 FROM t1,t2 SET t1.a=t2.a + + In this case we will do the update for the first found row combination. + The join algorithm guarantees that we will not find the a row in + t1 several times. + */ if (table->status & (STATUS_NULL_ROW | STATUS_UPDATED)) continue; |