Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: Kirill Yukhin <kyukhin@tarantool.org>
Cc: tarantool-patches@freelists.org
Subject: Re: [PATCH v2 3/4] sql: use space_by_name in SQL
Date: Sat, 27 Oct 2018 00:00:59 +0300	[thread overview]
Message-ID: <20181026210059.23np5iasegmmi6z4@esperanza> (raw)
In-Reply-To: <34cf16f3a044a1f0c8b9f091c2f8bd6fbb4834d8.1540388902.git.kyukhin@tarantool.org>

On Thu, Oct 25, 2018 at 11:17:11AM +0300, Kirill Yukhin wrote:
> diff --git a/src/box/sql/alter.c b/src/box/sql/alter.c
> index 3d72e31..7c28437 100644
> --- a/src/box/sql/alter.c
> +++ b/src/box/sql/alter.c
> @@ -47,18 +47,17 @@ sql_alter_table_rename(struct Parse *parse, struct SrcList *src_tab,
>  	if (new_name == NULL)
>  		goto exit_rename_table;
>  	/* Check that new name isn't occupied by another table. */
> -	uint32_t space_id = box_space_id_by_name(new_name, strlen(new_name));
> -	if (space_id != BOX_ID_NIL) {
> +	struct space *space = space_by_name(new_name);
> +	if (space != NULL) {
>  		diag_set(ClientError, ER_SPACE_EXISTS, new_name);
>  		goto tnt_error;
>  	}
>  	const char *tbl_name = src_tab->a[0].zName;
> -	space_id = box_space_id_by_name(tbl_name, strlen(tbl_name));
> -	if (space_id == BOX_ID_NIL) {
> +	space = space_by_name(tbl_name);
> +	if (space == NULL) {
>  		diag_set(ClientError, ER_NO_SUCH_SPACE, tbl_name);
>  		goto tnt_error;
>  	}
> -	struct space *space = space_by_id(space_id);
>  	assert(space != NULL);

Pointless assertion.

>  	if (space->def->opts.is_view) {
>  		diag_set(ClientError, ER_ALTER_SPACE, tbl_name,
> diff --git a/src/box/sql/analyze.c b/src/box/sql/analyze.c
> index 674d53d..ad068a54 100644
> --- a/src/box/sql/analyze.c
> +++ b/src/box/sql/analyze.c
> @@ -1114,16 +1114,15 @@ sqlite3Analyze(Parse * pParse, Token * pName)
>  		/* Form 2:  Analyze table named */
>  		char *z = sqlite3NameFromToken(db, pName);
>  		if (z != NULL) {
> -			uint32_t space_id = box_space_id_by_name(z, strlen(z));
> -			if (space_id != BOX_ID_NIL) {
> -				struct space *sp = space_by_id(space_id);
> -				assert(sp != NULL);
> -				if (sp->def->opts.is_view) {
> +			struct space *space = space_by_name(z);
> +			if (space != NULL) {
> +				assert(space != NULL);

Another one.

> +				if (space->def->opts.is_view) {
>  					sqlite3ErrorMsg(pParse, "VIEW isn't "\
>  							"allowed to be "\
>  							"analyzed");
>  				} else {
> -					vdbe_emit_analyze_table(pParse, sp);
> +					vdbe_emit_analyze_table(pParse, space);
>  				}
>  			} else {
>  				diag_set(ClientError, ER_NO_SUCH_SPACE, z);
> diff --git a/src/box/sql/delete.c b/src/box/sql/delete.c
> index 8f6c76f..72e0575 100644
> --- a/src/box/sql/delete.c
> +++ b/src/box/sql/delete.c
> @@ -36,15 +36,14 @@
>  #include "tarantoolInt.h"
>  
>  struct Table *
> -sql_lookup_table(struct Parse *parse, struct SrcList_item *tbl_name)
> +sql_lookup_table(struct Parse *parse, struct SrcList_item *src_name)
>  {
> -	assert(tbl_name != NULL);
> -	assert(tbl_name->pTab == NULL);
> -	uint32_t space_id = box_space_id_by_name(tbl_name->zName,
> -						 strlen(tbl_name->zName));
> -	struct space *space = space_by_id(space_id);
> -	if (space_id == BOX_ID_NIL || space == NULL) {
> -		sqlite3ErrorMsg(parse, "no such table: %s", tbl_name->zName);
> +	assert(src_name != NULL);
> +	assert(src_name->pTab == NULL);
> +	const char *name = src_name->zName;
> +	struct space *space = space_by_name(name);
> +	if (space == NULL) {
> +		sqlite3ErrorMsg(parse, "no such table: %s", name);

I hate it when one tries to squeeze some unrelated "cleanup", like
this variable renaming, in a patch that doesn't really need it.
This complicates review and clutters the history. I reverted this
part, removed useless assertions, and pushed the patch to 2.1.

>  		return NULL;
>  	}
>  	assert(space != NULL);

  reply	other threads:[~2018-10-26 21:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-25  8:17 [PATCH v2 0/4] Check read access while executing SQL query Kirill Yukhin
2018-10-25  8:17 ` [PATCH v2 1/4] schema: refactor space_cache API Kirill Yukhin
2018-10-25 14:48   ` Vladimir Davydov
2018-10-25 15:31     ` Kirill Yukhin
2018-10-25 16:09       ` Vladimir Davydov
2018-10-25  8:17 ` [PATCH v2 2/4] schema: add space names cache Kirill Yukhin
2018-10-26 20:55   ` Vladimir Davydov
2018-11-01 11:34     ` [tarantool-patches] " Konstantin Osipov
2018-10-25  8:17 ` [PATCH v2 3/4] sql: use space_by_name in SQL Kirill Yukhin
2018-10-26 21:00   ` Vladimir Davydov [this message]
2018-10-25  8:17 ` [PATCH v2 4/4] sql: check read access while executing SQL query Kirill Yukhin
2018-10-26 21:04   ` Vladimir Davydov

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=20181026210059.23np5iasegmmi6z4@esperanza \
    --to=vdavydov.dev@gmail.com \
    --cc=kyukhin@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [PATCH v2 3/4] sql: use space_by_name in SQL' \
    /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