[MDEV-29366] Inserting now() into auto_increment field caused value to jump to max Created: 2022-08-23 Updated: 2022-08-24 Resolved: 2022-08-24 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data Manipulation - Insert |
| Affects Version/s: | 10.5.8 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Minor |
| Reporter: | Roger | Assignee: | Sergei Golubchik |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | auto_increment, now | ||
| Environment: |
openSUSE Leap 15.3 |
||
| Description |
|
When inserting into a table with an AUTO_INCREMENT column and inserting the function name now() it fails and causes the auto_increment value for the table to jump to the maximum for the data type. No further records can be inserted until the rouge rows are deleted and the auto_increment is reset. (Not a common mistake to make in scripting, but can happen if inserted fields are in the incorrect order.)
Does the same for LOCALTIMESTAMP() & LOCALTIME()
does not give the error. |
| Comments |
| Comment by Sergei Golubchik [ 2022-08-24 ] |
|
this is all very much expected. now() in a numeric context becomes something like 20220824192234 (this is the same value as 2022-08-24 19:22:34 without separators) and it overflows INT. If you store it in a variable it is interpreted as a string '2022-08-24 19:22:34' and in a numeric context it becomes 2022, that does not overflow INT. |