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 7522528A46 for ; Thu, 31 May 2018 11:01:23 -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 udhFPMQUwDwh for ; Thu, 31 May 2018 11:01:23 -0400 (EDT) Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (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 B436328A27 for ; Thu, 31 May 2018 11:01:22 -0400 (EDT) From: Kirill Shcherbatov Subject: [tarantool-patches] [PATCH v1 1/2] sql: remove parser construct, destruct to sql.h Date: Thu, 31 May 2018 18:01:17 +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_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 */ -- 2.7.4