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 6A8E325A96 for ; Thu, 7 Jun 2018 08:31:40 -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 94kw64QJ8uN7 for ; Thu, 7 Jun 2018 08:31:40 -0400 (EDT) Received: from smtp57.i.mail.ru (smtp57.i.mail.ru [217.69.128.37]) (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 2858525A92 for ; Thu, 7 Jun 2018 08:31:40 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH] sql: remove unnecessary def rebuild in endTable() References: <20180607112419.37623-1-korablev@tarantool.org> From: Vladislav Shpilevoy Message-ID: <6cd9fb15-8073-9398-57ef-cd9094181ca4@tarantool.org> Date: Thu, 7 Jun 2018 15:31:37 +0300 MIME-Version: 1.0 In-Reply-To: <20180607112419.37623-1-korablev@tarantool.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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, Nikita Pettik Thanks for the patch! LGTM. On 07/06/2018 14:24, Nikita Pettik wrote: > 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. > * >