Skip to content

Commit

Permalink
Merge pull request #60886 from ArctypeZach/master
Browse files Browse the repository at this point in the history
Add support for `START TRANSACTION` syntax
  • Loading branch information
alexey-milovidov committed Mar 25, 2024
2 parents 87dea78 + 1c61ef7 commit 1928e7d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/en/sql-reference/transactions.md
Expand Up @@ -127,7 +127,7 @@ See the [deployment](docs/en/deployment-guides/terminology.md) documentation for

#### Verify that experimental transactions are enabled

Issue a `BEGIN TRANSACTION` followed by a `ROLLBACK` to verify that experimental transactions are enabled, and that ClickHouse Keeper is enabled as it is used to track transactions.
Issue a `BEGIN TRANSACTION` or `START TRANSACTION` followed by a `ROLLBACK` to verify that experimental transactions are enabled, and that ClickHouse Keeper is enabled as it is used to track transactions.

```sql
BEGIN TRANSACTION
Expand Down
1 change: 1 addition & 0 deletions src/Parsers/CommonParsers.h
Expand Up @@ -445,6 +445,7 @@ namespace DB
MR_MACROS(SPATIAL, "SPATIAL") \
MR_MACROS(SQL_SECURITY, "SQL SECURITY") \
MR_MACROS(SS, "SS") \
MR_MACROS(START_TRANSACTION, "START TRANSACTION") \
MR_MACROS(STATISTIC, "STATISTIC") \
MR_MACROS(STEP, "STEP") \
MR_MACROS(STORAGE, "STORAGE") \
Expand Down
2 changes: 2 additions & 0 deletions src/Parsers/ParserTransactionControl.cpp
Expand Up @@ -14,6 +14,8 @@ bool ParserTransactionControl::parseImpl(Pos & pos, ASTPtr & node, Expected & ex

if (ParserKeyword(Keyword::BEGIN_TRANSACTION).ignore(pos, expected))
action = ASTTransactionControl::BEGIN;
else if (ParserKeyword(Keyword::START_TRANSACTION).ignore(pos, expected))
action = ASTTransactionControl::BEGIN;
else if (ParserKeyword(Keyword::COMMIT).ignore(pos, expected))
action = ASTTransactionControl::COMMIT;
else if (ParserKeyword(Keyword::ROLLBACK).ignore(pos, expected))
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_transactions/test.py
Expand Up @@ -67,8 +67,8 @@ def test_rollback_unfinished_on_restart1(start_cluster):
tx(1, "insert into mt values (5, 50)")
tx(1, "alter table mt update m = m+n in partition id '1' where 1")

# check that uncommitted insert will be rolled back on restart
tx(3, "begin transaction")
# check that uncommitted insert will be rolled back on restart (using `START TRANSACTION` syntax)
tx(3, "start transaction")
tid5 = tx(3, "select transactionID()").strip()
tx(3, "insert into mt values (6, 70)")

Expand Down

0 comments on commit 1928e7d

Please sign in to comment.