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 113AE28284 for ; Thu, 31 May 2018 11:41:28 -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 CNU9l81YSpJb for ; Thu, 31 May 2018 11:41:27 -0400 (EDT) Received: from smtp20.mail.ru (smtp20.mail.ru [94.100.179.251]) (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 BB80828280 for ; Thu, 31 May 2018 11:41:27 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH v1 1/2] sql: remove parser construct, destruct to sql.h References: From: Vladislav Shpilevoy Message-ID: Date: Thu, 31 May 2018 18:41:24 +0300 MIME-Version: 1.0 In-Reply-To: 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: Kirill Shcherbatov , tarantool-patches@freelists.org Thanks for the patch! > sql: remove parser construct, destruct to sql.h What is construct/destruct? It is verbs. How can you remove them? Please, use sql_parser_create/destroy, and do not use 'remove' word here. It means rather delete something than move. On 31/05/2018 18:01, Kirill Shcherbatov wrote: > Moved sql_parser_create and sql_parser_destroy to sql.h to > use them not only in DDL. > Removed SELECTTRACE_ENABLED macro with conditional fields from > struct Parse to prevent different object sizes across the project. > > Part of #3272. > --- > src/box/sql.h | 17 +++++++++++++++++ > src/box/sql/prepare.c | 9 +++++++++ > src/box/sql/sqliteInt.h | 25 ------------------------- > 3 files changed, 26 insertions(+), 25 deletions(-) > > diff --git a/src/box/sql.h b/src/box/sql.h > index 3c26492..ecaf431 100644 > --- a/src/box/sql.h > +++ b/src/box/sql.h > @@ -175,6 +175,23 @@ sql_ephemeral_space_def_new(struct Parse *parser, const char *name); > int > sql_table_def_rebuild(struct sqlite3 *db, struct Table *table); > > +/** > + * Initialize a new parser object. > + * A number of service allocations are performed on the region, > + * which is also cleared in the destroy function. > + * @param parser object to initialize. > + * @param db SQLite object. > + */ > +void > +sql_parser_create(struct Parse *parser, struct sqlite3 *db); > + > +/** > + * Release the parser object resources. > + * @param parser object to release. > + */ > +void > +sql_parser_destroy(struct Parse *parser); > + > #if defined(__cplusplus) > } /* extern "C" { */ > #endif > diff --git a/src/box/sql/prepare.c b/src/box/sql/prepare.c > index 8dc433f..8d94642 100644 > --- a/src/box/sql/prepare.c > +++ b/src/box/sql/prepare.c > @@ -433,6 +433,15 @@ sqlite3_prepare_v2(sqlite3 * db, /* Database handle. */ > } > > void > +sql_parser_create(struct Parse *parser, sqlite3 *db) > +{ > + memset(parser, 0, sizeof(struct Parse)); > + parser->db = db; > + struct region *region = &fiber()->gc; > + parser->region_initial_size = region_used(region); > +} > + > +void > sql_parser_destroy(Parse *parser) > { > assert(parser != NULL); > diff --git a/src/box/sql/sqliteInt.h b/src/box/sql/sqliteInt.h > index 950409d..abf1543 100644 > --- a/src/box/sql/sqliteInt.h > +++ b/src/box/sql/sqliteInt.h > @@ -2903,10 +2903,8 @@ struct Parse { > Token constraintName; /* Name of the constraint currently being parsed */ > int regRoot; /* Register holding root page number for new objects */ > int nMaxArg; /* Max args passed to user function by sub-program */ > -#ifdef SELECTTRACE_ENABLED > int nSelect; /* Number of SELECT statements seen */ > int nSelectIndent; /* How far to indent SELECTTRACE() output */ > -#endif > Parse *pToplevel; /* Parse structure for main program (or NULL) */ > Table *pTriggerTab; /* Table triggers are being coded for */ > u32 nQueryLoop; /* Est number of iterations of a query (10*log2(N)) */ > @@ -4537,27 +4535,4 @@ extern int sqlite3InitDatabase(sqlite3 * db); > enum on_conflict_action > table_column_nullable_action(struct Table *tab, uint32_t column); > > -/** > - * Initialize a new parser object. > - * A number of service allocations are performed on the region, which is also > - * cleared in the destroy function. > - * @param parser object to initialize. > - * @param db SQLite object. > - */ > -static inline void > -sql_parser_create(struct Parse *parser, sqlite3 *db) > -{ > - memset(parser, 0, sizeof(struct Parse)); > - parser->db = db; > - struct region *region = &fiber()->gc; > - parser->region_initial_size = region_used(region); > -} > - > -/** > - * Release the parser object resources. > - * @param parser object to release. > - */ > -void > -sql_parser_destroy(struct Parse *parser); > - > #endif /* SQLITEINT_H */ >