summaryrefslogtreecommitdiff
path: root/sql/sql_insert.cc
diff options
context:
space:
mode:
authorunknown <hf@deer.(none)>2003-06-17 21:53:13 +0500
committerunknown <hf@deer.(none)>2003-06-17 21:53:13 +0500
commit46cb15ccd477007c8ba2abaa90f86960a8adc7bd (patch)
tree8bec4511106588d39e833346b08272d3d00f72ee /sql/sql_insert.cc
parentef726bbff367ab6c5aa735655d8ff6c3fdccdb7d (diff)
parenta4792eefad19e4f70471952afedef2221fbfbd64 (diff)
downloadmariadb-git-46cb15ccd477007c8ba2abaa90f86960a8adc7bd.tar.gz
SCRUM
merged conflicts about my previous commit it seems there are some errors left - gonna check... BitKeeper/etc/logging_ok: auto-union client/mysqltest.c: Auto merged include/mysql_com.h: Auto merged include/sql_common.h: Auto merged include/mysql.h: conflicts merged libmysql/client_settings.h: conflicts merged libmysql/libmysql.c: conflicts merged sql-common/client.c: conflicts merged sql/client_settings.h: conflicts merged sql/protocol.cc: conflict merged
Diffstat (limited to 'sql/sql_insert.cc')
-rw-r--r--sql/sql_insert.cc15
1 files changed, 13 insertions, 2 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index f65ef4b968a..091de9d406f 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -308,6 +308,11 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
}
thd->row_count++;
}
+
+ /*
+ Now all rows are inserted. Time to update logs and sends response to
+ user
+ */
if (lock_type == TL_WRITE_DELAYED)
{
if (!error)
@@ -341,7 +346,7 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
}
if (id && values_list.elements != 1)
thd->insert_id(id); // For update log
- else if (table->next_number_field)
+ else if (table->next_number_field && info.copied)
id=table->next_number_field->val_int(); // Return auto_increment value
/*
@@ -383,9 +388,15 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list,
thd->next_insert_id=0; // Reset this if wrongly used
if (duplic != DUP_ERROR)
table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY);
+
+ /* Reset value of LAST_INSERT_ID if no rows where inserted */
+ if (!info.copied && thd->insert_id_used)
+ {
+ thd->insert_id(0);
+ id=0;
+ }
if (error)
goto abort;
-
if (values_list.elements == 1 && (!(thd->options & OPTION_WARNINGS) ||
!thd->cuted_fields))
send_ok(thd,info.copied+info.deleted,id);