[MDEV-33083] "AFTER UPDATE" trigger does not fire when duplicate inserted with "ON DUPLICATE KEY UPDATE" Created: 2023-12-20 Updated: 2024-01-03 |
|
| Status: | Confirmed |
| Project: | MariaDB Server |
| Component/s: | None |
| Affects Version/s: | 10.6.16, 11.0.4 |
| Fix Version/s: | 10.4, 10.5, 10.6, 10.11, 11.0, 11.1, 11.2 |
| Type: | Bug | Priority: | Major |
| Reporter: | Phil Sumner | Assignee: | Vladislav Vaintroub |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
According to https://mariadb.com/kb/en/trigger-overview/ - the following triggers should fire when an ON DUPLICATE KEY insert is used and a duplicate is detected: BEFORE INSERT; We're seeing that the AFTER UPDATE trigger never fires when a duplicate row is inserted. See attached test case and output. Tested on 10.6.16 and 11.0.4 |
| Comments |
| Comment by Alice Sherepa [ 2023-12-20 ] | ||||||||||||||||||
|
This is because you are setting again the same value of Name = 'Test Unique Key' - so update was not actually performed.
| ||||||||||||||||||
| Comment by Phil Sumner [ 2024-01-03 ] | ||||||||||||||||||
|
I haven't checked this work, but the company dev who provided the initial test case has sent the latest attachment (inert on update mariadb confusion.txt) and said the following: ``` However a standard update that does the same, does fire the after update trigger. Am I wrong in thinking that this behaviour is conflicting? This behaviour also doesn't seem to be documented anywhere. | ||||||||||||||||||
| Comment by Sergei Golubchik [ 2024-01-03 ] | ||||||||||||||||||
|
AFTER UPDATE trigger should fire, whether the new value is the same as the old or not. SQL standard describes precisely when a trigger should fire, and it doesn't even have the notion of "oh, the values are the same so it's kind of not an update". So, it's a bug. |