1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

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.
This commit is contained in:
evgen@moonbone.local
2007-03-15 23:21:29 +03:00
parent d0a6231201
commit 92c8558224
4 changed files with 49 additions and 12 deletions

View File

@ -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;