From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 0E0D125A04 for ; Thu, 7 Jun 2018 07:24:24 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FdvFBIBs7xrE for ; Thu, 7 Jun 2018 07:24:23 -0400 (EDT) Received: from smtp33.i.mail.ru (smtp33.i.mail.ru [94.100.177.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id C3A6325085 for ; Thu, 7 Jun 2018 07:24:23 -0400 (EDT) From: Nikita Pettik Subject: [tarantool-patches] [PATCH] sql: remove unnecessary def rebuild in endTable() Date: Thu, 7 Jun 2018 14:24:19 +0300 Message-Id: <20180607112419.37623-1-korablev@tarantool.org> Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: tarantool-patches@freelists.org Cc: v.shpilevoy@tarantool.org, Nikita Pettik 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