[MDEV-22414] UPDATE or DELETE FOR PORTION OF increments the value of auto-increment column instead of copying the old one Created: 2020-04-29 Updated: 2020-11-20 Resolved: 2020-11-20 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Versioned Tables |
| Affects Version/s: | 10.4, 10.5 |
| Fix Version/s: | 10.4.18, 10.5.9 |
| Type: | Bug | Priority: | Major |
| Reporter: | Elena Stepanova | Assignee: | Nikita Malyavin |
| Resolution: | Not a Bug | Votes: | 1 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||||||
| Description |
|
The behavior is not specified in the documentation or (as far as I can tell) in the standard, but it seems obviously wrong, although understandable from the implementation point of view. |
| Comments |
| Comment by Nayuta Yanagisawa (Inactive) [ 2020-11-19 ] | |||||||||||||||||||||||
|
After a brief investigation, on b2029c0300bf8c311ff5d9fdc4b73a9e48bf6930, I found that the weird update of the auto-increment column is caused by TABLE::update_generated_fields() in sql/table.cc. Removing update_auto_increment() from update_generated_fields() at least fixes the bug, while I'm not yet so sure about the side effect of the remove. | |||||||||||||||||||||||
| Comment by Nayuta Yanagisawa (Inactive) [ 2020-11-19 ] | |||||||||||||||||||||||
|
Just to make sure, the expected result is the below, right?
| |||||||||||||||||||||||
| Comment by Nikita Malyavin [ 2020-11-20 ] | |||||||||||||||||||||||
|
nayuta-yanagisawa I think the expected result should be "update auto_increment counter when we insert a new record". According to standard, "new" should be inserted, and "updated" should be updated/deleted:
As far as I can see, this is the same as the actual result. elenst Please note, how the algorithm works: UPDATE t SET x = 'new' FOR PORTION OF p FROM a TO btransforms to
DELETE FROM t FOR PORTION OF p FROM a TO btransforms to
| |||||||||||||||||||||||
| Comment by Nayuta Yanagisawa (Inactive) [ 2020-11-20 ] | |||||||||||||||||||||||
|
> I think the expected result should be "update auto_increment counter when we insert a new record". This sounds a bit counterintuitive to me but it is reasonable when we interpret insert operations, triggered by UPDATE or DELETE on an application time-period table, as just usual insert operations. | |||||||||||||||||||||||
| Comment by Nikita Malyavin [ 2020-11-20 ] | |||||||||||||||||||||||
|
Maybe that's counterintuitive on the one hand, but on the contrary, the INSERT triggers are called as well. It'd be controversial if the INSERT trigger is called, but no autoincrement update happened. And think about what if `a` would be PRIMARY KEY AUTO_INCREMENT – then updates/deletes would fail with duplicate error |