[patches] [PATCH V2 9/9] sql: remove OP_Transaction
Bulat Niatshin
niatshin at tarantool.org
Tue Feb 27 16:54:54 MSK 2018
OP_Transaction didn't do any reasonable job except
it was used for proper VDBE flags assigning during
VDBE initialization. In this patch it was merged
with OP_TTransaction into single opcode. OP_TTransaction
now has two additional arguments.
For #3119
---
extra/mkopcodeh.tcl | 2 +-
src/box/sql/build.c | 10 ++---
src/box/sql/fkey.c | 3 +-
src/box/sql/opcodes.c | 93 ++++++++++++++++++++++----------------------
src/box/sql/opcodes.h | 105 +++++++++++++++++++++++++-------------------------
src/box/sql/pragma.c | 2 -
src/box/sql/update.c | 4 +-
src/box/sql/vdbe.c | 80 ++++++++++----------------------------
src/box/sql/vdbeaux.c | 2 +-
9 files changed, 128 insertions(+), 173 deletions(-)
diff --git a/extra/mkopcodeh.tcl b/extra/mkopcodeh.tcl
index bd86ac69a..e8b625910 100644
--- a/extra/mkopcodeh.tcl
+++ b/extra/mkopcodeh.tcl
@@ -128,7 +128,7 @@ foreach name {OP_Noop OP_Explain} {
# The following are the opcodes that are processed by resolveP2Values()
#
set rp2v_ops {
- OP_Transaction
+ OP_TTransaction
OP_AutoCommit
OP_Savepoint
OP_Checkpoint
diff --git a/src/box/sql/build.c b/src/box/sql/build.c
index 593a365da..acae587b6 100644
--- a/src/box/sql/build.c
+++ b/src/box/sql/build.c
@@ -99,12 +99,10 @@ sqlite3FinishCoding(Parse * pParse)
Schema *pSchema;
if (DbMaskTest(pParse->cookieMask, 0) != 0) {
pSchema = db->pSchema;
- sqlite3VdbeAddOp2(v, OP_Transaction, /* Opcode */
- 0, /* P1 */
- DbMaskTest(pParse->writeMask, 0) /* P2 */
- );
- if (pParse->initiateTTrans)
- sqlite3VdbeAddOp0(v, OP_TTransaction);
+
+ sqlite3VdbeAddOp2(v, OP_TTransaction,
+ pParse->initiateTTrans,
+ DbMaskTest(pParse->writeMask, 0));
if (db->init.busy == 0)
sqlite3VdbeChangeP5(v, 1);
diff --git a/src/box/sql/fkey.c b/src/box/sql/fkey.c
index 0a5efd67e..9833e4879 100644
--- a/src/box/sql/fkey.c
+++ b/src/box/sql/fkey.c
@@ -797,7 +797,8 @@ sqlite3FkDropTable(Parse * pParse, SrcList * pName, Table * pTab)
pParse->disableTriggers = 1;
/* Staring new transaction before DELETE FROM <tbl> */
- sqlite3VdbeAddOp0(v, OP_TTransaction);
+ sqlite3VdbeAddOp2(v, OP_TTransaction, 1,
+ DbMaskTest(pParse->writeMask, 0));
sqlite3DeleteFrom(pParse, sqlite3SrcListDup(db, pName, 0), 0);
pParse->disableTriggers = 0;
diff --git a/src/box/sql/opcodes.c b/src/box/sql/opcodes.c
index 2d5dc62ef..4d5a9770f 100644
--- a/src/box/sql/opcodes.c
+++ b/src/box/sql/opcodes.c
@@ -13,7 +13,7 @@ const char *sqlite3OpcodeName(int i){
static const char *const azName[] = {
/* 0 */ "Savepoint" OpHelp(""),
/* 1 */ "AutoCommit" OpHelp(""),
- /* 2 */ "Transaction" OpHelp(""),
+ /* 2 */ "TTransaction" OpHelp(""),
/* 3 */ "SorterNext" OpHelp(""),
/* 4 */ "PrevIfOpen" OpHelp(""),
/* 5 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"),
@@ -103,53 +103,52 @@ const char *sqlite3OpcodeName(int i){
/* 89 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1 at P2])"),
/* 90 */ "Count" OpHelp("r[P2]=count()"),
/* 91 */ "FkCheckCommit" OpHelp(""),
- /* 92 */ "TTransaction" OpHelp(""),
- /* 93 */ "ReadCookie" OpHelp(""),
- /* 94 */ "SetCookie" OpHelp(""),
- /* 95 */ "ReopenIdx" OpHelp("root=P2"),
- /* 96 */ "OpenRead" OpHelp("root=P2"),
- /* 97 */ "OpenWrite" OpHelp("root=P2"),
- /* 98 */ "OpenTEphemeral" OpHelp("nColumn = P2"),
- /* 99 */ "SorterOpen" OpHelp(""),
- /* 100 */ "SequenceTest" OpHelp("if (cursor[P1].ctr++) pc = P2"),
- /* 101 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
- /* 102 */ "Close" OpHelp(""),
- /* 103 */ "ColumnsUsed" OpHelp(""),
- /* 104 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
- /* 105 */ "NextId" OpHelp("r[P3]=get_max(space_index[P1]{Column[P2]})"),
- /* 106 */ "NextIdEphemeral" OpHelp("r[P3]=get_max(space_index[P1]{Column[P2]})"),
- /* 107 */ "FCopy" OpHelp("reg[P2 at cur_frame]= reg[P1 at root_frame(OPFLAG_SAME_FRAME)]"),
- /* 108 */ "Delete" OpHelp(""),
- /* 109 */ "ResetCount" OpHelp(""),
- /* 110 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
- /* 111 */ "SorterData" OpHelp("r[P2]=data"),
- /* 112 */ "RowData" OpHelp("r[P2]=data"),
- /* 113 */ "NullRow" OpHelp(""),
- /* 114 */ "SorterInsert" OpHelp("key=r[P2]"),
+ /* 92 */ "ReadCookie" OpHelp(""),
+ /* 93 */ "SetCookie" OpHelp(""),
+ /* 94 */ "ReopenIdx" OpHelp("root=P2"),
+ /* 95 */ "OpenRead" OpHelp("root=P2"),
+ /* 96 */ "OpenWrite" OpHelp("root=P2"),
+ /* 97 */ "OpenTEphemeral" OpHelp("nColumn = P2"),
+ /* 98 */ "SorterOpen" OpHelp(""),
+ /* 99 */ "SequenceTest" OpHelp("if (cursor[P1].ctr++) pc = P2"),
+ /* 100 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"),
+ /* 101 */ "Close" OpHelp(""),
+ /* 102 */ "ColumnsUsed" OpHelp(""),
+ /* 103 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"),
+ /* 104 */ "NextId" OpHelp("r[P3]=get_max(space_index[P1]{Column[P2]})"),
+ /* 105 */ "NextIdEphemeral" OpHelp("r[P3]=get_max(space_index[P1]{Column[P2]})"),
+ /* 106 */ "FCopy" OpHelp("reg[P2 at cur_frame]= reg[P1 at root_frame(OPFLAG_SAME_FRAME)]"),
+ /* 107 */ "Delete" OpHelp(""),
+ /* 108 */ "ResetCount" OpHelp(""),
+ /* 109 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"),
+ /* 110 */ "SorterData" OpHelp("r[P2]=data"),
+ /* 111 */ "RowData" OpHelp("r[P2]=data"),
+ /* 112 */ "NullRow" OpHelp(""),
+ /* 113 */ "SorterInsert" OpHelp("key=r[P2]"),
+ /* 114 */ "IdxReplace" OpHelp("key=r[P2]"),
/* 115 */ "Real" OpHelp("r[P2]=P4"),
- /* 116 */ "IdxReplace" OpHelp("key=r[P2]"),
- /* 117 */ "IdxInsert" OpHelp("key=r[P2]"),
- /* 118 */ "IdxDelete" OpHelp("key=r[P2 at P3]"),
- /* 119 */ "Destroy" OpHelp(""),
- /* 120 */ "Clear" OpHelp(""),
- /* 121 */ "ResetSorter" OpHelp(""),
- /* 122 */ "ParseSchema2" OpHelp("rows=r[P1 at P2]"),
- /* 123 */ "ParseSchema3" OpHelp("name=r[P1] sql=r[P1+1]"),
- /* 124 */ "RenameTable" OpHelp("P1 = root, P4 = name"),
- /* 125 */ "LoadAnalysis" OpHelp(""),
- /* 126 */ "DropTable" OpHelp(""),
- /* 127 */ "DropIndex" OpHelp(""),
- /* 128 */ "DropTrigger" OpHelp(""),
- /* 129 */ "Param" OpHelp(""),
- /* 130 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
- /* 131 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
- /* 132 */ "AggStep0" OpHelp("accum=r[P3] step(r[P2 at P5])"),
- /* 133 */ "AggStep" OpHelp("accum=r[P3] step(r[P2 at P5])"),
- /* 134 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
- /* 135 */ "Expire" OpHelp(""),
- /* 136 */ "IncMaxid" OpHelp(""),
- /* 137 */ "Noop" OpHelp(""),
- /* 138 */ "Explain" OpHelp(""),
+ /* 116 */ "IdxInsert" OpHelp("key=r[P2]"),
+ /* 117 */ "IdxDelete" OpHelp("key=r[P2 at P3]"),
+ /* 118 */ "Destroy" OpHelp(""),
+ /* 119 */ "Clear" OpHelp(""),
+ /* 120 */ "ResetSorter" OpHelp(""),
+ /* 121 */ "ParseSchema2" OpHelp("rows=r[P1 at P2]"),
+ /* 122 */ "ParseSchema3" OpHelp("name=r[P1] sql=r[P1+1]"),
+ /* 123 */ "RenameTable" OpHelp("P1 = root, P4 = name"),
+ /* 124 */ "LoadAnalysis" OpHelp(""),
+ /* 125 */ "DropTable" OpHelp(""),
+ /* 126 */ "DropIndex" OpHelp(""),
+ /* 127 */ "DropTrigger" OpHelp(""),
+ /* 128 */ "Param" OpHelp(""),
+ /* 129 */ "FkCounter" OpHelp("fkctr[P1]+=P2"),
+ /* 130 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"),
+ /* 131 */ "AggStep0" OpHelp("accum=r[P3] step(r[P2 at P5])"),
+ /* 132 */ "AggStep" OpHelp("accum=r[P3] step(r[P2 at P5])"),
+ /* 133 */ "AggFinal" OpHelp("accum=r[P1] N=P2"),
+ /* 134 */ "Expire" OpHelp(""),
+ /* 135 */ "IncMaxid" OpHelp(""),
+ /* 136 */ "Noop" OpHelp(""),
+ /* 137 */ "Explain" OpHelp(""),
};
return azName[i];
}
diff --git a/src/box/sql/opcodes.h b/src/box/sql/opcodes.h
index 3f60e4066..791f6478d 100644
--- a/src/box/sql/opcodes.h
+++ b/src/box/sql/opcodes.h
@@ -2,7 +2,7 @@
/* See the tool/mkopcodeh.tcl script for details */
#define OP_Savepoint 0
#define OP_AutoCommit 1
-#define OP_Transaction 2
+#define OP_TTransaction 2
#define OP_SorterNext 3
#define OP_PrevIfOpen 4
#define OP_Or 5 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */
@@ -92,53 +92,52 @@
#define OP_MakeRecord 89 /* synopsis: r[P3]=mkrec(r[P1 at P2]) */
#define OP_Count 90 /* synopsis: r[P2]=count() */
#define OP_FkCheckCommit 91
-#define OP_TTransaction 92
-#define OP_ReadCookie 93
-#define OP_SetCookie 94
-#define OP_ReopenIdx 95 /* synopsis: root=P2 */
-#define OP_OpenRead 96 /* synopsis: root=P2 */
-#define OP_OpenWrite 97 /* synopsis: root=P2 */
-#define OP_OpenTEphemeral 98 /* synopsis: nColumn = P2 */
-#define OP_SorterOpen 99
-#define OP_SequenceTest 100 /* synopsis: if (cursor[P1].ctr++) pc = P2 */
-#define OP_OpenPseudo 101 /* synopsis: P3 columns in r[P2] */
-#define OP_Close 102
-#define OP_ColumnsUsed 103
-#define OP_Sequence 104 /* synopsis: r[P2]=cursor[P1].ctr++ */
-#define OP_NextId 105 /* synopsis: r[P3]=get_max(space_index[P1]{Column[P2]}) */
-#define OP_NextIdEphemeral 106 /* synopsis: r[P3]=get_max(space_index[P1]{Column[P2]}) */
-#define OP_FCopy 107 /* synopsis: reg[P2 at cur_frame]= reg[P1 at root_frame(OPFLAG_SAME_FRAME)] */
-#define OP_Delete 108
-#define OP_ResetCount 109
-#define OP_SorterCompare 110 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
-#define OP_SorterData 111 /* synopsis: r[P2]=data */
-#define OP_RowData 112 /* synopsis: r[P2]=data */
-#define OP_NullRow 113
-#define OP_SorterInsert 114 /* synopsis: key=r[P2] */
+#define OP_ReadCookie 92
+#define OP_SetCookie 93
+#define OP_ReopenIdx 94 /* synopsis: root=P2 */
+#define OP_OpenRead 95 /* synopsis: root=P2 */
+#define OP_OpenWrite 96 /* synopsis: root=P2 */
+#define OP_OpenTEphemeral 97 /* synopsis: nColumn = P2 */
+#define OP_SorterOpen 98
+#define OP_SequenceTest 99 /* synopsis: if (cursor[P1].ctr++) pc = P2 */
+#define OP_OpenPseudo 100 /* synopsis: P3 columns in r[P2] */
+#define OP_Close 101
+#define OP_ColumnsUsed 102
+#define OP_Sequence 103 /* synopsis: r[P2]=cursor[P1].ctr++ */
+#define OP_NextId 104 /* synopsis: r[P3]=get_max(space_index[P1]{Column[P2]}) */
+#define OP_NextIdEphemeral 105 /* synopsis: r[P3]=get_max(space_index[P1]{Column[P2]}) */
+#define OP_FCopy 106 /* synopsis: reg[P2 at cur_frame]= reg[P1 at root_frame(OPFLAG_SAME_FRAME)] */
+#define OP_Delete 107
+#define OP_ResetCount 108
+#define OP_SorterCompare 109 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */
+#define OP_SorterData 110 /* synopsis: r[P2]=data */
+#define OP_RowData 111 /* synopsis: r[P2]=data */
+#define OP_NullRow 112
+#define OP_SorterInsert 113 /* synopsis: key=r[P2] */
+#define OP_IdxReplace 114 /* synopsis: key=r[P2] */
#define OP_Real 115 /* same as TK_FLOAT, synopsis: r[P2]=P4 */
-#define OP_IdxReplace 116 /* synopsis: key=r[P2] */
-#define OP_IdxInsert 117 /* synopsis: key=r[P2] */
-#define OP_IdxDelete 118 /* synopsis: key=r[P2 at P3] */
-#define OP_Destroy 119
-#define OP_Clear 120
-#define OP_ResetSorter 121
-#define OP_ParseSchema2 122 /* synopsis: rows=r[P1 at P2] */
-#define OP_ParseSchema3 123 /* synopsis: name=r[P1] sql=r[P1+1] */
-#define OP_RenameTable 124 /* synopsis: P1 = root, P4 = name */
-#define OP_LoadAnalysis 125
-#define OP_DropTable 126
-#define OP_DropIndex 127
-#define OP_DropTrigger 128
-#define OP_Param 129
-#define OP_FkCounter 130 /* synopsis: fkctr[P1]+=P2 */
-#define OP_OffsetLimit 131 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
-#define OP_AggStep0 132 /* synopsis: accum=r[P3] step(r[P2 at P5]) */
-#define OP_AggStep 133 /* synopsis: accum=r[P3] step(r[P2 at P5]) */
-#define OP_AggFinal 134 /* synopsis: accum=r[P1] N=P2 */
-#define OP_Expire 135
-#define OP_IncMaxid 136
-#define OP_Noop 137
-#define OP_Explain 138
+#define OP_IdxInsert 116 /* synopsis: key=r[P2] */
+#define OP_IdxDelete 117 /* synopsis: key=r[P2 at P3] */
+#define OP_Destroy 118
+#define OP_Clear 119
+#define OP_ResetSorter 120
+#define OP_ParseSchema2 121 /* synopsis: rows=r[P1 at P2] */
+#define OP_ParseSchema3 122 /* synopsis: name=r[P1] sql=r[P1+1] */
+#define OP_RenameTable 123 /* synopsis: P1 = root, P4 = name */
+#define OP_LoadAnalysis 124
+#define OP_DropTable 125
+#define OP_DropIndex 126
+#define OP_DropTrigger 127
+#define OP_Param 128
+#define OP_FkCounter 129 /* synopsis: fkctr[P1]+=P2 */
+#define OP_OffsetLimit 130 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */
+#define OP_AggStep0 131 /* synopsis: accum=r[P3] step(r[P2 at P5]) */
+#define OP_AggStep 132 /* synopsis: accum=r[P3] step(r[P2 at P5]) */
+#define OP_AggFinal 133 /* synopsis: accum=r[P1] N=P2 */
+#define OP_Expire 134
+#define OP_IncMaxid 135
+#define OP_Noop 136
+#define OP_Explain 137
/* Properties such as "out2" or "jump" that are specified in
** comments following the "case" for each opcode in the vdbe.c
@@ -162,13 +161,13 @@
/* 64 */ 0x00, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x10,\
/* 72 */ 0x10, 0x00, 0x00, 0x10, 0x10, 0x10, 0x00, 0x00,\
/* 80 */ 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00,\
-/* 88 */ 0x00, 0x00, 0x10, 0x00, 0x00, 0x10, 0x00, 0x00,\
-/* 96 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
-/* 104 */ 0x10, 0x20, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,\
-/* 112 */ 0x00, 0x00, 0x04, 0x10, 0x00, 0x04, 0x00, 0x10,\
+/* 88 */ 0x00, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x00,\
+/* 96 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,\
+/* 104 */ 0x20, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,\
+/* 112 */ 0x00, 0x04, 0x00, 0x10, 0x04, 0x00, 0x10, 0x00,\
/* 120 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
-/* 128 */ 0x00, 0x10, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x00,\
-/* 136 */ 0x00, 0x00, 0x00,}
+/* 128 */ 0x10, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00,\
+/* 136 */ 0x00, 0x00,}
/* The sqlite3P2Values() routine is able to run faster if it knows
** the value of the largest JUMP opcode. The smaller the maximum
diff --git a/src/box/sql/pragma.c b/src/box/sql/pragma.c
index f969c2eea..4ed848b22 100644
--- a/src/box/sql/pragma.c
+++ b/src/box/sql/pragma.c
@@ -831,7 +831,6 @@ sqlite3Pragma(Parse * pParse, Token * pId, /* First part of [schema.]id field */
&& (pPragma->mPragFlg & PragFlg_ReadOnly) == 0) {
/* Write the specified cookie value */
static const VdbeOpList setCookie[] = {
- {OP_Transaction, 0, 1, 0}, /* 0 */
{OP_SetCookie, 0, 0, 0}, /* 1 */
};
VdbeOp *aOp;
@@ -851,7 +850,6 @@ sqlite3Pragma(Parse * pParse, Token * pId, /* First part of [schema.]id field */
} else {
/* Read the specified cookie value */
static const VdbeOpList readCookie[] = {
- {OP_Transaction, 0, 0, 0}, /* 0 */
{OP_ReadCookie, 0, 1, 0}, /* 1 */
{OP_ResultRow, 1, 1, 0}
};
diff --git a/src/box/sql/update.c b/src/box/sql/update.c
index 75baf1f51..9bc5ea233 100644
--- a/src/box/sql/update.c
+++ b/src/box/sql/update.c
@@ -220,9 +220,7 @@ sqlite3Update(Parse * pParse, /* The parser context */
/* Resolve the column names in all the expressions of the
* of the UPDATE statement. Also find the column index
- * for each column to be updated in the pChanges array. For each
- * column to be updated, make sure we have authorization to change
- * that column.
+ * for each column to be updated in the pChanges array.
*/
chngPk = 0;
for (i = 0; i < pChanges->nExpr; i++) {
diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
index ec32c79fe..34a5c2a04 100644
--- a/src/box/sql/vdbe.c
+++ b/src/box/sql/vdbe.c
@@ -3016,69 +3016,31 @@ case OP_AutoCommit: {
break;
}
-/* Opcode: Transaction P1 P2 * * *
- *
- * Begin a transaction on database P1 if a transaction is not already
- * active.
- * If P2 is non-zero, then a write-transaction is started, or if a
- * read-transaction is already active, it is upgraded to a write-transaction.
- * If P2 is zero, then a read-transaction is started.
- *
- * P1 is the index of the database file on which the transaction is
- * started. Index 0 is the main database file and index 1 is the
- * file used for temporary tables. Indices of 2 or more are used for
- * attached databases.
- *
- * If a write-transaction is started and the Vdbe.usesStmtJournal flag is
- * true (this flag is set if the Vdbe may modify more than one row and may
- * throw an ABORT exception), a statement transaction may also be opened.
- * More specifically, a statement transaction is opened if the database
- * connection is currently not in autocommit mode, or if there are other
- * active statements. A statement transaction allows the changes made by this
- * VDBE to be rolled back after an error without having to roll back the
- * entire transaction. If no error is encountered, the statement transaction
- * will automatically commit when the VDBE halts.
- *
- */
-case OP_Transaction: {
- assert(p->bIsReader);
- assert(p->readOnly==0 || pOp->p2==0);
- assert(pOp->p1==0);
- if (pOp->p2 && (user_session->sql_flags & SQLITE_QueryOnly)!=0) {
- rc = SQLITE_READONLY;
- goto abort_due_to_error;
- }
-
- testcase(rc == SQLITE_BUSY_SNAPSHOT);
- testcase(rc == SQLITE_BUSY_RECOVERY);
- if (rc != SQLITE_OK) {
- if ((rc&0xff) == SQLITE_BUSY) {
- p->pc = (int)(pOp - aOp);
- p->rc = rc;
- goto vdbe_return;
- }
- goto abort_due_to_error;
- }
-
- if (rc) goto abort_due_to_error;
- break;
-}
-
-/* Opcode: TTransaction * * * * *
+/* Opcode: TTransaction P1 P2 * * *
+ *
+ * Start Tarantool's transaction if P1 is not zero. If P2 is
+ * non-zero, then write-transaction is started (from VDBE
+ * point of view), if P2 is zero, then a read-transaction
+ * is started (temporarily leave it as it is, VDBE
+ * flags like readOnly and others will be removed later).
*
- * Start Tarantool's transaction.
- * Only do that if auto commit mode is on. This should be no-op
- * if this opcode was emitted inside a transaction.
- * Auto commit mode is disabled by OP_Transaction.
+ * Only start Tarantool transaction if auto commit
+ * mode is on. This should be no-op this opcode was
+ * emitted inside a transaction.
*/
case OP_TTransaction: {
- if (p->autoCommit) {
- rc = box_txn_begin() == 0 ? SQLITE_OK : SQL_TARANTOOL_ERROR;
- }
- if (box_txn()
- && p->autoCommit == 0){
- p->anonymous_savepoint = sql_savepoint(p, NULL);
+ if (pOp->p1) {
+ if (p->autoCommit) {
+ if (box_txn_begin() == 0) {
+ rc = SQLITE_OK;
+ } else {
+ rc = SQL_TARANTOOL_ERROR;
+ }
+ }
+ if (box_txn() && p->autoCommit == 0) {
+ p->anonymous_savepoint = sql_savepoint(p, NULL);
+ }
}
break;
}
diff --git a/src/box/sql/vdbeaux.c b/src/box/sql/vdbeaux.c
index 6622a11a8..845937874 100644
--- a/src/box/sql/vdbeaux.c
+++ b/src/box/sql/vdbeaux.c
@@ -673,7 +673,7 @@ resolveP2Values(Vdbe * p, int *pMaxFuncArgs)
* cases from this switch!
*/
switch (pOp->opcode) {
- case OP_Transaction:{
+ case OP_TTransaction: {
if (pOp->p2 != 0)
p->readOnly = 0;
/* fall thru */
--
2.14.1
More information about the Tarantool-patches
mailing list