Skip to content
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
Binary file modified media/sqlgram/BeginTransactionStmt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified media/sqlgram/CompletionTypeWithinTransaction.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion sql-statements/sql-statement-begin.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ Query OK, 0 rows affected (0.01 sec)

## MySQL 兼容性

`BEGIN` 语句与 MySQL 完全兼容。如有任何兼容性差异,请在 GitHub 上[提交 issue](/report-issue.md)
TiDB 在执行 `BEGIN` 语句时,可以带上 `PESSIMISTIC` 或者 `OPTIMISTIC` 选项表明此语句开启事务的类型

## 另请参阅

* [COMMIT](/sql-statements/sql-statement-commit.md)
* [ROLLBACK](/sql-statements/sql-statement-rollback.md)
* [START TRANSACTION](/sql-statements/sql-statement-start-transaction.md)
* [TiDB 乐观事务模型](/optimistic-transaction.md)
* [TiDB 悲观事务模型](/pessimistic-transaction.md)
7 changes: 5 additions & 2 deletions sql-statements/sql-statement-commit.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ aliases: ['/docs-cn/dev/reference/sql/statements/commit/']

![CommitStmt](/media/sqlgram/CommitStmt.png)

**CompletionTypeWithinTransaction:**

![CompletionTypeWithinTransaction](/media/sqlgram/CompletionTypeWithinTransaction.png)

## 示例

{{< copyable "sql" >}}
Expand Down Expand Up @@ -61,8 +65,7 @@ Query OK, 0 rows affected (0.01 sec)

## MySQL 兼容性

* 在 MySQL 中,除了有多个 primary 的群组复制以外,`COMMIT` 语句通常不会导致错误。相比之下,TiDB 使用乐观并发控制,冲突可能导致 `COMMIT` 返回错误。
* 默认情况下,`UNIQUE` 和 `PRIMARY KEY` 约束检查将延迟直至语句提交。可通过设置 `tidb_constraint_check_in_place=TRUE` 来改变该行为。
* 对于 `COMMIT` 语句中的 `CompletionTypeWithinTransaction` 选项,目前只在语法上支持。

## 另请参阅

Expand Down