[MDEV-5478] Improper maintenance of TIMESTAMP_AUTO_SET_ON_BOTH interferes with REPLACE optimization Created: 2013-12-20 Updated: 2014-06-06 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | None |
| Affects Version/s: | 5.5.34 |
| Fix Version/s: | 5.5 |
| Type: | Bug | Priority: | Minor |
| Reporter: | Kolbe Kegel (Inactive) | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | upstream | ||
| Description |
|
According to the comments and code in sql_insert.cc:1764(5.5.34), a table with both DEFAULT CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMP should be able to use the "update" optimization for REPLACE (instead of the strict delete/insert behavior).
However, this "doesn't work". It appears that table->timestamp_field_type is never TIMESTAMP_AUTO_SET_ON_BOTH for some reason at this point, even if the table has DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP and timestamp_field_type is correctly set when the table is opened. Running mysqld under gdb confirms that at this point in execution, timestamp_field_type is set to TIMESTAMP_AUTO_SET_ON_UPDATE when it seems that it should be TIMESTAMP_AUTO_SET_ON_BOTH.
This matches upstream behavior, but does not match the intended behavior according to the comments or intent of the code in the 5.5 server. MariaDB 10.0 and MySQL 5.6 do not have this behavior, as they've simply removed the timestamp_field_type check from this if statement... I'm not sure if they check for it in some other way or whether they're just doing something bizarre in this case. |