-
Notifications
You must be signed in to change notification settings - Fork 5.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
executor: fix value swapping and multi-updates in UPDATE statement #20493
Conversation
PTAL @SunRunAway |
@@ -1802,15 +1802,15 @@ func (s *testSuiteP1) TestMultiUpdate(c *C) { | |||
// Test UPDATE ... set_lists. | |||
tk.MustExec(`UPDATE test_mu SET b = 0, c = b WHERE a = 4`) | |||
result = tk.MustQuery(`SELECT * FROM test_mu ORDER BY a`) | |||
result.Check(testkit.Rows(`1 7 2`, `4 0 0`, `7 8 9`)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the result consistent with MySQL?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. It could be more consistent with PG and SQLite as discussed in #19137.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/cc @lysu |
/bench |
It seems not to be a |
LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
/run-all-tests |
/run-common-test tidb-test=pr/1111 |
/run-unit-test |
LGTM |
/merge |
Your auto merge job has been accepted, waiting for:
|
/run-all-tests |
What problem does this PR solve?
Issue Number: close #11911, close #19137, amendment to #20603 (#20594)
Problem Summary: In
UPDATE
statement:update ... set ...
on same table #11911)What is changed and how it works?
If we have a table:
For #19137 (changes in
UpdateExec.composeNewRow
):For #11911 :
updateRowKeys
to allow the same row be updated once for each table alias (instead of once for each table).mergedRowData
to merge modifications to a row from each table alias.UpdateExec.updateRows
:UpdateExec.prepare
)composeFunc
)UpdateExec.merge
)composeGeneratedColumns
)UpdateExec.merge
)UpdateExec.exec
)For #20603 :
checkUpdateLists
). For example:Related changes
Check List
Tests
Side effects
Release note
update t set a=b, b=a
.update t set b=a, c=b
, as the assignments will use values from the original row instead of the newly evaluated row.update t m, t n set m.a=1, n.b=2
.m.a
orn.b
) can be written to storage.