Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: Kirill Shcherbatov <kshcherbatov@tarantool.org>,
	tarantool-patches@freelists.org
Subject: [tarantool-patches] Re: [PATCH v1 1/2] sql: remove parser construct, destruct to sql.h
Date: Thu, 31 May 2018 18:41:24 +0300	[thread overview]
Message-ID: <c2fd3172-87d2-292a-8ee5-e140dbb7cdca@tarantool.org> (raw)
In-Reply-To: <e3a0e34e0c35f4e67423738bfecf8be86fbf5bc1.1527778868.git.kshcherbatov@tarantool.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 */
> 

  reply	other threads:[~2018-05-31 15:41 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-31 15:01 [tarantool-patches] [PATCH v1 0/2] sql: Create special region for parser Kirill Shcherbatov
2018-05-31 15:01 ` [tarantool-patches] [PATCH v1 1/2] sql: remove parser construct, destruct to sql.h Kirill Shcherbatov
2018-05-31 15:41   ` Vladislav Shpilevoy [this message]
2018-05-31 15:49     ` [tarantool-patches] " Kirill Shcherbatov
2018-05-31 15:01 ` [tarantool-patches] [PATCH v1 2/2] sql: use own region in Parser Kirill Shcherbatov
2018-05-31 15:41   ` [tarantool-patches] " Vladislav Shpilevoy
2018-05-31 15:49     ` Kirill Shcherbatov
2018-05-31 15:41 ` [tarantool-patches] Re: [PATCH v1 0/2] sql: Create special region for parser Vladislav Shpilevoy
2018-05-31 15:50 ` Kirill Shcherbatov
2018-05-31 15:55   ` Vladislav Shpilevoy
2018-05-31 17:43     ` Kirill Yukhin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c2fd3172-87d2-292a-8ee5-e140dbb7cdca@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH v1 1/2] sql: remove parser construct, destruct to sql.h' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox