[tarantool-patches] Re: [PATCH v2 3/4] sql: refactor vdbe_emit_open_cursor calls

  • From: "n.pettik" <korablev@xxxxxxxxxxxxx>
  • To: tarantool-patches@xxxxxxxxxxxxx
  • Date: Tue, 10 Jul 2018 21:22:17 +0300


diff --git a/src/box/sql/insert.c b/src/box/sql/insert.c
index 58e159c..62b85d5 100644
--- a/src/box/sql/insert.c
+++ b/src/box/sql/insert.c
@@ -179,41 +179,51 @@ sqlite3TableAffinity(Vdbe * v, Table * pTab, int iReg)
-static int
-readsTable(Parse * p, Table * pTab)
+static bool
+vdbe_has_table_read(struct Parse *parser, const struct Table *table)
{
+             if (op->opcode == OP_OpenRead || op->opcode == OP_OpenWrite) {
+                     assert(i > 1);
+                     struct VdbeOp *space_var_op =
+                             sqlite3VdbeGetOp(v, i - 1);
+                     assert(space_var_op != NULL);
+                     assert(space_var_op->opcode == OP_LoadPtr);
+                     struct space *space = space_var_op->p4.space;
+
+                     if (space->def->id == table->def->id)
+                             return true;
+
+                     int idx_id = op->p2;
+                     for (struct Index *pIndex = table->pIndex;
+                             pIndex != NULL; pIndex = pIndex->pNext) {
+                             if (idx_id ==
+                                 SQLITE_PAGENO_TO_INDEXID(pIndex->tnum))
+                                     return true;

Why do you need these index iterations? If spaces don’t match, what is the
point to check index ids? Btw, I deleted this code and all tests seem to pass.

The rest is OK in this patch.


Other related posts: