Tarantool development patches archive
 help / color / mirror / Atom feed
From: Nikita Pettik <korablev@tarantool.org>
To: tarantool-patches@freelists.org
Cc: v.shpilevoy@tarantool.org, Nikita Pettik <korablev@tarantool.org>
Subject: [tarantool-patches] [PATCH] sql: remove unnecessary def rebuild in endTable()
Date: Thu,  7 Jun 2018 14:24:19 +0300	[thread overview]
Message-ID: <20180607112419.37623-1-korablev@tarantool.org> (raw)

sqlite3EndTable() routine is called twice during table creation: firsly
after initial parsing alongside with generating VDBE program; secondly -
as a callback in order to add struct Table to internal table hash.
sqlite3EndTable() contains call of sql_table_def_rebuild() which in
turn copies space_def to malloc. However, it makes no sence to call
rebuild during the first stage, since this sample of struct Table will
be destroyed at the end of initial parsing and will be resurrected at
the second stage from the scratch.
---
Branch: https://github.com/tarantool/tarantool/tree/np/remove-unnecessary-def-rebuild
Issue: no corresponding issue

 src/box/sql/build.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/src/box/sql/build.c b/src/box/sql/build.c
index 28e4d7a4d..62d687b17 100644
--- a/src/box/sql/build.c
+++ b/src/box/sql/build.c
@@ -1869,14 +1869,19 @@ sqlite3EndTable(Parse * pParse,	/* Parse context */
 		return;
 	}
 
-	/*
-	 * As rebuild creates a new ExpList tree and old_def
-	 * is allocated on region release old tree manually.
-	 */
-	struct ExprList *old_checks = p->def->opts.checks;
-	if (sql_table_def_rebuild(db, p) != 0)
-		return;
-	sql_expr_list_delete(db, old_checks);
+	if (db->init.busy) {
+		/*
+		 * As rebuild creates a new ExpList tree and
+		 * old_def is allocated on region release old
+		 * tree manually. This procedure is necessary
+		 * only at second stage of table creation, i.e.
+		 * before adding to table hash.
+		 */
+		struct ExprList *old_checks = p->def->opts.checks;
+		if (sql_table_def_rebuild(db, p) != 0)
+			return;
+		sql_expr_list_delete(db, old_checks);
+	}
 
 	/* If not initializing, then create new Tarantool space.
 	 *
-- 
2.15.1

             reply	other threads:[~2018-06-07 11:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-07 11:24 Nikita Pettik [this message]
2018-06-07 12:31 ` [tarantool-patches] " Vladislav Shpilevoy
2018-06-11  7:56   ` Kirill Yukhin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180607112419.37623-1-korablev@tarantool.org \
    --to=korablev@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [tarantool-patches] [PATCH] sql: remove unnecessary def rebuild in endTable()' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox