Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Won't Fix
-
10.1.13
Description
Suppose a table contains data like
MariaDB [c]> select * from t2; |
+-----+ |
| abc |
|
+-----+ |
| 1 |
|
| 3 |
|
| 5 |
|
+-----+ |
Suppose my update command is
MariaDB [c]> update t2 set abc = abc+2; |
It give following error
ERROR 1062 (23000): Duplicate entry '3' for key 'PRIMARY' |
I tried the same with oracle database but it worked fine.It seems to me that mariadb is comparing new row with old data ,which is not updated but is going to be update soon.Is it some kind of bug?
It's a documented deficiency. MariaDB updates one row at a time and does not do deferred constraint checking. So, in your example it updates the first row, tries to update abc from 1 to 3, and that immediately fails the uniqueness constraint. The standard correct behavior would've been to update all rows and only then ensure than uniqueness is not violated, but neither MariaDB nor MySQL ever supported that.