Re: MySQL/PostgreSQL discrepancy
От | Tom Lane |
---|---|
Тема | Re: MySQL/PostgreSQL discrepancy |
Дата | |
Msg-id | 6747.972707993@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | MySQL/PostgreSQL discrepancy (Ken Smith <ken@turbolinux.co.jp>) |
Список | pgsql-bugs |
Ken Smith <ken@turbolinux.co.jp> writes: > create table test (name char, a int, b int); > insert into test values ('x', 1, 2); > update test set a=3,b=a where name='x'; > select * from test; > name | a | b > ------+---+--- > x | 3 | 1 This is correct ... > I am used to MySQL so I expected the following from the select > statement. > name | a | b > ------+---+--- > x | 3 | 3 > Which behavior is the correct? MySQL is evidently evaluating the assignments left-to-right, and using the updated values of prior columns in subsequent expressions. Unfortunately for MySQL, that is unquestionably a violation of the SQL spec. I refer you to SQL92 section 3.10 <update statement: searched>, General Rule 6: 6) The <value expression>s are effectively evaluated for each row of T before updating any row of T. There is no other way to read that except that the expressions are all to be evaluated using the *old* values of the row. regards, tom lane
В списке pgsql-bugs по дате отправления: