diff options
Diffstat (limited to 'sql/sql_insert.cc')
-rw-r--r-- | sql/sql_insert.cc | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 9067df2f014..0ce52779ce1 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -932,20 +932,24 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list, if (values_list.elements == 1 && (!(thd->options & OPTION_WARNINGS) || !thd->cuted_fields)) { - thd->row_count_func= info.copied+info.deleted+info.updated; + thd->row_count_func= info.copied + info.deleted + + ((thd->client_capabilities & CLIENT_FOUND_ROWS) ? + info.touched : info.updated); send_ok(thd, (ulong) thd->row_count_func, id); } else { char buff[160]; + ha_rows updated=((thd->client_capabilities & CLIENT_FOUND_ROWS) ? + info.touched : info.updated); if (ignore) sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records, (lock_type == TL_WRITE_DELAYED) ? (ulong) 0 : (ulong) (info.records - info.copied), (ulong) thd->cuted_fields); else sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records, - (ulong) (info.deleted+info.updated), (ulong) thd->cuted_fields); - thd->row_count_func= info.copied+info.deleted+info.updated; + (ulong) (info.deleted + updated), (ulong) thd->cuted_fields); + thd->row_count_func= info.copied + info.deleted + updated; ::send_ok(thd, (ulong) thd->row_count_func, id, buff); } thd->abort_on_warning= 0; @@ -1415,19 +1419,20 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) goto before_trg_err; table->file->restore_auto_increment(prev_insert_id); - if ((error=table->file->ha_update_row(table->record[1], - table->record[0]))) - { - if (info->ignore && - !table->file->is_fatal_error(error, HA_CHECK_DUP_KEY)) - { - goto ok_or_after_trg_err; - } - goto err; - } if ((table->file->ha_table_flags() & HA_PARTIAL_COLUMN_READ) || - compare_record(table)) + compare_record(table)) { + if ((error=table->file->ha_update_row(table->record[1], + table->record[0]))) + { + if (info->ignore && + !table->file->is_fatal_error(error, HA_CHECK_DUP_KEY)) + { + goto ok_or_after_trg_err; + } + goto err; + } + info->updated++; /* If ON DUP KEY UPDATE updates a row instead of inserting one, it's @@ -1446,6 +1451,11 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) info->copied++; } + if (table->next_number_field) + table->file->adjust_next_insert_id_after_explicit_value( + table->next_number_field->val_int()); + info->touched++; + goto ok_or_after_trg_err; } else /* DUP_REPLACE */ @@ -3136,7 +3146,9 @@ bool select_insert::send_eof() else sprintf(buff, ER(ER_INSERT_INFO), (ulong) info.records, (ulong) (info.deleted+info.updated), (ulong) thd->cuted_fields); - thd->row_count_func= info.copied+info.deleted+info.updated; + thd->row_count_func= info.copied + info.deleted + + ((thd->client_capabilities & CLIENT_FOUND_ROWS) ? + info.touched : info.updated); id= (thd->first_successful_insert_id_in_cur_stmt > 0) ? thd->first_successful_insert_id_in_cur_stmt : |