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 CA8ED202F7 for ; Wed, 23 May 2018 10:05:41 -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 246iukf7DFwj for ; Wed, 23 May 2018 10:05:41 -0400 (EDT) Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (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 03AAB201BA for ; Wed, 23 May 2018 10:05:40 -0400 (EDT) From: Kirill Shcherbatov Subject: [tarantool-patches] [PATCH v7 1/7] sql: remove parser construct, destruct to sql.h Date: Wed, 23 May 2018 17:05:28 +0300 Message-Id: In-Reply-To: References: In-Reply-To: References: 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, Kirill Shcherbatov Moved sql_parser_construct and sql_parser_destruct 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..ff8ab6f 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 99c9fea..a7ef80f 100644 --- a/src/box/sql/sqliteInt.h +++ b/src/box/sql/sqliteInt.h @@ -2911,10 +2911,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)) */ @@ -4554,27 +4552,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 */ -- 2.7.4