Details
-
Bug
-
Status: Closed (View Workflow)
-
Blocker
-
Resolution: Fixed
-
10.0(EOL), 10.1(EOL), 10.2(EOL)
Description
This problem was originally reported by Jerome B. on the maria-developers list on 2017-07-21:
This script:
drop table t1; |
create table t1 (c1 integer, c2 integer, c3 integer); |
insert into t1(c1,c2,c3) values (1,1,1); |
update t1 |
set c1 = c1+1, |
c2 = c1+1,
|
c3 = c2+1;
|
select * from t1; |
produces this result:
+------+------+------+
|
| c1 | c2 | c3 |
|
+------+------+------+
|
| 2 | 3 | 4 |
|
+------+------+------+
|
Other databases return 2 for all columns:
PostgreSQL:
c1 | c2 | c3
|
----+----+----
|
2 | 2 | 2
|
Oracle:
C1 C2 C3
|
---------- ---------- ----------
|
2 2 2
|
SQLite3:
2|2|2
|
MariaDB's behavior contradicts the SQL standard, which says in the section <update statement: searched>:
10) The <update source> of each <set clause> contained in SCL is effectively evaluated for each row of T before any row of T is updated.
Attachments
Issue Links
- relates to
-
MDEV-13418 Compatibility: The order of evaluation of SELECT..INTO assignments
-
- Stalled
-
-
MDEV-15122 Simultaneous assignment for LOAD..SET
-
- Open
-
-
MDEV-15123 Make multiple user variable assignment work similar in standalone query and in SP
-
- Open
-
-
MDEV-15124 Simultaneous assignment for INSERT ... SET
-
- Open
-
-
MDEV-19304 Segfault in ALTER TABLE after UPDATE for SIMULTANEOUS_ASSIGNMENT
-
- Closed
-
I also do not like to do prior evaluation of <update source> only in ORACLE mode.
Doing prior evaluation only in TRADITIONAL or ANSI mode also does not look good enough.
ORACLE does not seem to include neither TRADITIONAL nor ANSI.
So Oracle users would have to do something like this:
which looks not so convenient.
I prefer to have a new sql_mode flag, and turn it on by default, to have all users get used with the standard behavior.
However, STANDARD_UPDATE_BEHAVIOR sounds too optimistic, because there might be some other aspects of UPDATE (not related to the order of evaluation of value sources) that expose non-standard behavior
Why not have something like this:
to activate the legacy non-standard behavior?