Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: tarantool-patches@freelists.org, Nikita Pettik <korablev@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH 3/7] sql: remove struct Table from analyze routine
Date: Tue, 28 Aug 2018 21:58:29 -0300	[thread overview]
Message-ID: <03343a94-b676-3003-6f10-a9fdd81794a7@tarantool.org> (raw)
In-Reply-To: <c7e760b7447d84317ba73fbfc07185c356240cf0.1535064700.git.korablev@tarantool.org>

Thanks for the patch! See 1 comment below.

On 23/08/2018 19:55, Nikita Pettik wrote:
> Instead of using struct Table which is found by lookup in internal hash
> lets use struct space from Tarantool DD.
> 
> Part of #3561
> ---
>   src/box/sql/analyze.c          | 185 +++++++++++++++++++++++------------------
>   test/sql-tap/analyze1.test.lua |   2 +-
>   2 files changed, 107 insertions(+), 80 deletions(-)
> 
> diff --git a/src/box/sql/analyze.c b/src/box/sql/analyze.c
> index abed9d31b..e835a8697 100644
> --- a/src/box/sql/analyze.c
> +++ b/src/box/sql/analyze.c
> @@ -770,61 +764,62 @@ callStatGet(Vdbe * v, int regStat4, int iParam, int regOut)
>   	sqlite3VdbeChangeP5(v, 2);
>   }
>   
> -/*
> +/**
>    * Generate code to do an analysis of all indices associated with
>    * a single table.
> + *
> + * @param pParse Current parsing context.
> + * @param space Space to be analyzed.
> + * @param stat_cursor Cursor pointing to spaces containing
> + *        statistics: _sql_stat1 (stat_cursor) and
> + *        _sql_stat4 (stat_cursor + 1).
>    */
>   static void
> -analyzeOneTable(Parse * pParse,	/* Parser context */
> -		Table * pTab,	/* Table whose indices are to be analyzed */
> -		int iStatCur,	/* Index of VdbeCursor that writes the _sql_stat1 table */
> -		int iMem,	/* Available memory locations begin here */
> -		int iTab	/* Next available cursor */
> -    )
> +vdbe_emit_analyze_space(struct Parse *pParse, struct space *space,
> +			int stat_cursor)

1. Once you started this function formatting, please, finish it.
Use parse instead of pParse. Use reg_stat4 instead of regStat4 etc.

>   {
>   	sqlite3 *db = pParse->db;	/* Database handle */
>   	int iIdxCur;		/* Cursor open on index being analyzed */
>   	int iTabCur;		/* Table cursor */
>   	Vdbe *v;		/* The virtual machine being built up */
>   	int i;			/* Loop counter */
> -	int regStat4 = iMem++;	/* Register to hold Stat4Accum object */
> -	int regChng = iMem++;	/* Index of changed index field */
> -	int regKey = iMem++;	/* Key argument passed to stat_push() */
> -	int regTemp = iMem++;	/* Temporary use register */
> -	int regTabname = iMem++;	/* Register containing table name */
> -	int regIdxname = iMem++;	/* Register containing index name */
> -	int regStat1 = iMem++;	/* Value for the stat column of _sql_stat1 */
> -	int regPrev = iMem;	/* MUST BE LAST (see below) */
> -
> -	pParse->nMem = MAX(pParse->nMem, iMem);
> +	/* Register to hold Stat4Accum object. */
> +	int regStat4 = ++pParse->nMem;
> +	/* Index of changed index field. */
> +	int regChng = ++pParse->nMem;
> +	/* Key argument passed to stat_push(). */
> +	int regKey = ++pParse->nMem;
> +	/* Temporary use register. */
> +	int regTemp = ++pParse->nMem;
> +	/* Register containing table name. */
> +	int regTabname = ++pParse->nMem;
> +	/* Register containing index name. */
> +	int regIdxname = ++pParse->nMem;
> +	/* Value for the stat column of _sql_stat1. */
> +	int regStat1 = ++pParse->nMem;
> +	/* MUST BE LAST (see below). */
> +	int regPrev = ++pParse->nMem;
> +
> @@ -1076,27 +1078,43 @@ loadAnalysis(Parse * pParse)
>   	}
>   }
>   
> -/*
> - * Generate code that will do an analysis of an entire database
> +/**
> + * Wrapper to pass args to space_foreach callback.
> + */
> +struct analyze_data {
> +	struct Parse *parse_context;
> +	/**
> +	 * Cursor numbers pointing to stat spaces:
> +	 * stat_cursor is opened on _sql_stat1 and
> +	 * stat_cursor + 1 - on _sql_stat4.
> +	 */
> +	int stat_cursor;
> +};
> +
> +static int
> +sql_space_foreach_analyze(struct space *space, void *data)
> +{
> +	if (space->def->opts.sql == NULL || space->def->opts.is_view)
> +		return 0;
> +	struct analyze_data *anal_data = (struct analyze_data *) data;

Lol

> +	vdbe_emit_analyze_space(anal_data->parse_context, space,
> +				anal_data->stat_cursor);
> +	return 0;
> +}
> +

  reply	other threads:[~2018-08-29  0:58 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-23 22:55 [tarantool-patches] [PATCH 0/7] Finish SQL DD integration Nikita Pettik
     [not found] ` <cover.1535064700.git.korablev@tarantool.org>
2018-08-23 22:55   ` [tarantool-patches] [PATCH 1/7] sql: remove struct schema from struct Table Nikita Pettik
2018-08-29  0:58     ` [tarantool-patches] " Vladislav Shpilevoy
2018-09-02 23:51       ` n.pettik
2018-09-16 19:32     ` Vladislav Shpilevoy
2018-09-19 10:58       ` n.pettik
2018-08-23 22:55   ` [tarantool-patches] [PATCH 2/7] sql: remove SQLite original struct Index Nikita Pettik
2018-08-29  0:58     ` [tarantool-patches] " Vladislav Shpilevoy
2018-09-02 23:51       ` n.pettik
2018-09-06 19:54         ` Vladislav Shpilevoy
2018-09-16 19:04           ` n.pettik
2018-08-23 22:55   ` [tarantool-patches] [PATCH 3/7] sql: remove struct Table from analyze routine Nikita Pettik
2018-08-29  0:58     ` Vladislav Shpilevoy [this message]
2018-09-02 23:52       ` [tarantool-patches] " n.pettik
2018-08-23 22:55   ` [tarantool-patches] [PATCH 4/7] sql: refactor ALTER RENAME code generation Nikita Pettik
2018-08-29  0:58     ` [tarantool-patches] " Vladislav Shpilevoy
2018-09-02 23:52       ` n.pettik
2018-08-23 22:55   ` [tarantool-patches] [PATCH 5/7] sql: remove lookups in Table hash Nikita Pettik
2018-08-29  0:58     ` [tarantool-patches] " Vladislav Shpilevoy
2018-09-02 23:52       ` n.pettik
2018-08-23 22:55   ` [tarantool-patches] [PATCH 6/7] sql: don't add system spaces to " Nikita Pettik
2018-08-29  0:58     ` [tarantool-patches] " Vladislav Shpilevoy
2018-09-02 23:52       ` n.pettik
2018-09-06 19:54         ` Vladislav Shpilevoy
2018-09-16 19:04           ` n.pettik
2018-08-23 22:55   ` [tarantool-patches] [PATCH 7/7] sql: finish DD integration Nikita Pettik
2018-08-29  0:58     ` [tarantool-patches] " Vladislav Shpilevoy
2018-09-20 14:45       ` 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=03343a94-b676-3003-6f10-a9fdd81794a7@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=korablev@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH 3/7] sql: remove struct Table from analyze routine' \
    /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