diff --git a/media/sqlgram/BeginTransactionStmt.png b/media/sqlgram/BeginTransactionStmt.png index 9ccc5f18d022..b7cda69124b2 100644 Binary files a/media/sqlgram/BeginTransactionStmt.png and b/media/sqlgram/BeginTransactionStmt.png differ diff --git a/media/sqlgram/CompletionTypeWithinTransaction.png b/media/sqlgram/CompletionTypeWithinTransaction.png index 1383bd71cb7a..dcb9fea585a2 100644 Binary files a/media/sqlgram/CompletionTypeWithinTransaction.png and b/media/sqlgram/CompletionTypeWithinTransaction.png differ diff --git a/sql-statements/sql-statement-begin.md b/sql-statements/sql-statement-begin.md index b0bff7913eb7..b32dd51a9b58 100644 --- a/sql-statements/sql-statement-begin.md +++ b/sql-statements/sql-statement-begin.md @@ -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) diff --git a/sql-statements/sql-statement-commit.md b/sql-statements/sql-statement-commit.md index f85db1a8d3f9..6192c3862c6d 100644 --- a/sql-statements/sql-statement-commit.md +++ b/sql-statements/sql-statement-commit.md @@ -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" >}} @@ -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` 选项,目前只在语法上支持。 ## 另请参阅