Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: tarantool-patches@freelists.org, Kirill Yukhin <kyukhin@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH] sql: refactor SQL delete to allow Lua spaces
Date: Sat, 19 May 2018 00:07:18 +0300	[thread overview]
Message-ID: <946fafd7-9e8a-0263-ecaa-02df83c82223@tarantool.org> (raw)
In-Reply-To: <87358913270ee98c98bc276209289d6b7ac496b6.1526650490.git.kyukhin@tarantool.org>

Hello. Thanks for the patch! See 1 comment below.

On 18/05/2018 16:36, Kirill Yukhin wrote:
> Branch: https://github.com/tarantool/tarantool/tree/kyukhin/gh-3235-sql-truncate-on-lua-spaces
> Issue: https://github.com/tarantool/tarantool/issues/3235
> 
> This is a first step toward fully-featured deletion
> of spaces created in Lua by means of SQL language.
> This change to handle most simple case:
> DELETE * FROM <space_name> and will be improved in
> nearest future.
> 
> Part of #3235
> ---
>   src/box/sql/analyze.c         |  3 +-
>   src/box/sql/build.c           |  3 +-
>   src/box/sql/delete.c          | 69 ++++++++++++++++++++++++++-----------------
>   src/box/sql/vdbe.c            |  2 +-
>   test/sql-tap/delete1.test.lua | 23 ++++++++++++++-
>   5 files changed, 69 insertions(+), 31 deletions(-)
> 
> diff --git a/src/box/sql/delete.c b/src/box/sql/delete.c
> index f4d248e..dfc91cb 100644
> --- a/src/box/sql/delete.c
> +++ b/src/box/sql/delete.c
> @@ -29,6 +29,7 @@
>    * SUCH DAMAGE.
>    */
>   
> +#include "box/box.h"
>   #include "box/session.h"
>   #include "box/schema.h"
>   #include "sqliteInt.h"
> @@ -86,35 +87,50 @@ sql_table_delete_from(struct Parse *parse, struct SrcList *tab_list,
> +	bool is_complex = false;
> +	const char *tab_name = tab_list->a->zName;
> +	if (sqlite3LocateTable(parse, LOCATE_NOERR, tab_name) == NULL) {
> +		space_id = box_space_id_by_name(tab_name,
> +						strlen(tab_name));
> +		if (space_id == BOX_ID_NIL)
> +			goto delete_from_cleanup;
> +	} else {
> +		table = sql_list_lookup_table(parse, tab_list);
> +		if (table == NULL)
> +			goto delete_from_cleanup;
> +		space_id = SQLITE_PAGENO_TO_SPACEID(table->tnum);
> +		trigger_list =sqlite3TriggersExist(table, TK_DELETE,
> +						   NULL, NULL);
> +		is_complex = trigger_list != NULL ||
> +			     sqlite3FkRequired(table, NULL);
> +	}
> +	space = space_by_id(space_id);
> +	assert(space != NULL);
> +
> +	bool is_view = space->def->opts.is_view;
>   
>   	/* If table is really a view, make sure it has been
>   	 * initialized.
>   	 */
> -	if (sqlite3ViewGetColumnNames(parse, table))
> -		goto delete_from_cleanup;
> +	if (is_view) {

1. sqlite3ViewGetColumnNames makes the check too. Lets turn it into assertion
inside sqlite3ViewGetColumnNames, and add the 'if (is_view)' in other places,
where it is called and the check is necessary. For example, in selectExpander
it is checked twice too.

> +		if (sqlite3ViewGetColumnNames(parse, table))
> +			goto delete_from_cleanup;
>   
>   
>   	/* Assign cursor numbers to the table and all its indices.

  reply	other threads:[~2018-05-18 21:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-18 13:36 [tarantool-patches] " Kirill Yukhin
2018-05-18 21:07 ` Vladislav Shpilevoy [this message]
2018-05-21  8:20   ` [tarantool-patches] " Kirill Yukhin
2018-05-21  9:47     ` Vladislav Shpilevoy
2018-05-21 10:25       ` Kirill Yukhin
2018-05-21 10:49         ` Vladislav Shpilevoy
2018-05-21 11:24           ` Kirill Yukhin
2018-05-21 11:39             ` Vladislav Shpilevoy

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=946fafd7-9e8a-0263-ecaa-02df83c82223@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=kyukhin@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH] sql: refactor SQL delete to allow Lua spaces' \
    /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