diff options
author | unknown <evgen@moonbone.local> | 2007-03-15 23:21:29 +0300 |
---|---|---|
committer | unknown <evgen@moonbone.local> | 2007-03-15 23:21:29 +0300 |
commit | 542f18a31ab261c0b36ffddf6372e8c1e3de4294 (patch) | |
tree | 7fa5760ca5855723a89f7a63d38ef6f33a6162cf /sql/sql_class.h | |
parent | ed80fe2dfb68b30c6f41b5e0beae1be4394e63cf (diff) | |
download | mariadb-git-542f18a31ab261c0b36ffddf6372e8c1e3de4294.tar.gz |
Bug#27033: 0 as LAST_INSERT_ID() after INSERT .. ON DUPLICATE if rows were
touched but not actually changed.
The LAST_INSERT_ID() is reset to 0 if no rows were inserted or changed.
This is the case when an INSERT ... ON DUPLICATE KEY UPDATE updates a row
with the same values as the row contains.
Now the LAST_INSERT_ID() values is reset to 0 only if there were no rows
successfully inserted or touched.
The new 'touched' field is added to the COPY_INFO structure. It holds the
number of rows that were touched no matter whether they were actually
changed or not.
sql/sql_class.h:
Bug#27033: 0 as LAST_INSERT_ID() after INSERT .. ON DUPLICATE if rows were
touched but not actually changed.
The new 'touched' field is added to the COPY_INFO structure. It holds the
number of rows that were touched no matter whether they were actually
changed or not.
mysql-test/r/insert_update.result:
Added a test case for the bug#27033: 0 as LAST_INSERT_ID() after INSERT .. ON DUPLICATE if rows were
touched but not actually changed.
mysql-test/t/insert_update.test:
Added a test case for the bug#27033: 0 as LAST_INSERT_ID() after INSERT .. ON DUPLICATE if rows were
touched but not actually changed.
sql/sql_insert.cc:
Bug#27033: 0 as LAST_INSERT_ID() after INSERT .. ON DUPLICATE if rows were
touched but not actually changed.
Now the LAST_INSERT_ID() values is reset to 0 only if there were no rows
successfully inserted or touched.
Diffstat (limited to 'sql/sql_class.h')
-rw-r--r-- | sql/sql_class.h | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/sql/sql_class.h b/sql/sql_class.h index 995b5ac0bde..99803802001 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -356,13 +356,25 @@ public: inline uint32 get_open_count() { return open_count; } }; - +/* + The COPY_INFO structure is used by INSERT/REPLACE code. + The schema of the row counting by the INSERT/INSERT ... ON DUPLICATE KEY + UPDATE code: + If a row is inserted then the copied variable is incremented. + If a row is updated by the INSERT ... ON DUPLICATE KEY UPDATE and the + new data differs from the old one then the copied and the updated + variables are incremented. + The touched variable is incremented if a row was touched by the update part + of the INSERT ... ON DUPLICATE KEY UPDATE no matter whether the row + was actually changed or not. +*/ typedef struct st_copy_info { - ha_rows records; - ha_rows deleted; - ha_rows updated; - ha_rows copied; + ha_rows records; /* Number of processed records */ + ha_rows deleted; /* Number of deleted records */ + ha_rows updated; /* Number of updated records */ + ha_rows copied; /* Number of copied records */ ha_rows error_count; + ha_rows touched; /* Number of touched records */ enum enum_duplicates handle_duplicates; int escape_char, last_errno; bool ignore; |