Skip to content
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

mysql-compatibility: add doc for a UPDATE incompatibility case (#7094) #8596

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions mysql-compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ These differences are documented further in [`ANALYZE TABLE`](/sql-statements/sq

For details, see the [`SELECT`](/sql-statements/sql-statement-select.md) statement reference.

### `UPDATE` statement

See the [`UPDATE`](/sql-statements/sql-statement-update.md) statement reference.

### Views

Views in TiDB are not updatable. They do not support write operations such as `UPDATE`, `INSERT`, and `DELETE`.
Expand Down
12 changes: 11 additions & 1 deletion sql-statements/sql-statement-update.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,17 @@ mysql> SELECT * FROM t1;

## MySQL compatibility

This statement is understood to be fully compatible with MySQL. Any compatibility differences should be [reported via an issue](https://github.com/pingcap/tidb/issues/new/choose) on GitHub.
TiDB always uses the original value of a column when evaluating expressions. For example:

```sql
CREATE TABLE t (a int, b int);
INSERT INTO t VALUES (1,2);
UPDATE t SET a = a+1,b=a;
```

In MySQL, the column `b` is updated to 2 because it is set to the value of `a`, and the value of `a` (which is 1) is updated to `a+1` (which is 2) in the same statement.

TiDB follows the more standard SQL behavior, and updates `b` to 1.

## See also

Expand Down