Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: tarantool-patches@freelists.org,
	Kirill Shcherbatov <kshcherbatov@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH v2 7/7] sql: store regular identifiers in case-normal form
Date: Mon, 18 Mar 2019 22:33:54 +0300	[thread overview]
Message-ID: <a11299d1-0eaa-d62b-6ee3-21d25d7f55d8@tarantool.org> (raw)
In-Reply-To: <152eb589-a416-01d4-e75c-8876c9538c9d@tarantool.org>

Thanks for the fixes! See 3 comments below.

On 11/03/2019 18:04, Kirill Shcherbatov wrote:
>> First of all, I do not see a test on failed normalization.
>> Please, add.
> I've implemented a new errinj test.
> 
>> 1. You have sql_parser_error, and you used it already in
>> some other places. Fix it, please, in all touched places.
> 
> Ok, done.
> 
>> 2. Why?
> 
> Because I've added a new test that have created a new additional table.

1. As I asked multiple times - please, do not put my comments
out of the context. I see my question 'Why?', but I do not see
what does it refer to.

> diff --git a/src/box/sql/util.c b/src/box/sql/util.c
> index c89e2e8ab..60133758a 100644
> --- a/src/box/sql/util.c
> +++ b/src/box/sql/util.c
> @@ -292,23 +294,37 @@ sqlDequote(char *z)
>   	z[j] = 0;
>   }
>   
> -
> -void
> -sqlNormalizeName(char *z)
> +int
> +sql_normalize_name(char *dst, int dst_size, const char *src, int src_len)
>   {
> -	char quote;
> -	int i=0;
> -	if (z == 0)
> -		return;
> -	quote = z[0];
> -	if (sqlIsquote(quote)){
> -		sqlDequote(z);
> -		return;
> -	}
> -	while(z[i]!=0){
> -		z[i] = (char)sqlToupper(z[i]);
> -		i++;
> +	assert(src != NULL);
> +	if (sqlIsquote(src[0])){
> +		if (dst_size == 0)
> +			return src_len;
> +		memcpy(dst, src, src_len);
> +		dst[src_len] = '\0';
> +		sqlDequote(dst);
> +		return src_len;

2. In the comment you said that sql_normalize_name returns a length
of result string, but here it is false. sqlDequote can trim some
symbols and the result length is less. The code works only thanks to
the fact, that the result of sql_normalize_name is never used as a
length, but rather as a buffer size. Please, either fix the return value,
returning a real string length, or change the comment, saying what
that function returns + its usage places, where you store its result
into 'name_len' variables (they should be renamed to bsize or something).

> diff --git a/test/box/errinj.test.lua b/test/box/errinj.test.lua
> index c876f9afb..9e8095295 100644
> --- a/test/box/errinj.test.lua
> +++ b/test/box/errinj.test.lua
> @@ -587,3 +587,11 @@ fio = require('fio')
>   #fio.glob(fio.pathjoin(box.cfg.vinyl_dir, box.space.test.id, 0, '*.index.inprogress')) == 0
>   
>   box.space.test:drop()
> +
> +--
> +-- gh-3931: Store regular identifiers in case-normal form
> +--
> +errinj = box.error.injection
> +errinj.set("ERRINJ_SQL_NAME_NORMALIZATION", true)
> +box.sql.execute("CREATE TABLE hello (id INT primary key,x INT,y INT);")
> +errinj.set("ERRINJ_SQL_NAME_NORMALIZATION", false)

3. We have sql/errinj.test.lua for that.


Below you can find a couple of general comments, which I discovered on the
top commit, but probably some of them were introduced in the previous
ones:

1) delete.c:72: 'where' leaks. It was duplicated on line 68, and you do
    not free it before return;

2) fk_constraint.c:641: why not to return? Here OOM has happened, obviously,
    and there is nothing to cleanup;

  reply	other threads:[~2019-03-18 19:33 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-27 11:13 [tarantool-patches] [PATCH v2 0/7] " Kirill Shcherbatov
2019-02-27 11:13 ` [tarantool-patches] [PATCH v2 1/7] sql: refactor sql_alloc_src_list to set diag Kirill Shcherbatov
2019-03-07 17:34   ` [tarantool-patches] " Vladislav Shpilevoy
2019-03-11 15:04     ` Kirill Shcherbatov
2019-02-27 11:13 ` [tarantool-patches] [PATCH v2 2/7] sql: rework sql_src_list_enlarge " Kirill Shcherbatov
2019-03-07 17:34   ` [tarantool-patches] " Vladislav Shpilevoy
2019-03-11 15:04     ` Kirill Shcherbatov
2019-02-27 11:13 ` [tarantool-patches] [PATCH v2 3/7] sql: refactor sql_src_list_append " Kirill Shcherbatov
2019-03-07 17:34   ` [tarantool-patches] " Vladislav Shpilevoy
2019-03-11 15:04     ` Kirill Shcherbatov
2019-03-18 19:33       ` Vladislav Shpilevoy
2019-03-20 11:02         ` Kirill Shcherbatov
2019-03-26 17:08           ` Vladislav Shpilevoy
2019-03-26 18:07             ` Vladislav Shpilevoy
2019-02-27 11:13 ` [tarantool-patches] [PATCH v2 4/7] sql: refactor sql_name_from_token " Kirill Shcherbatov
2019-03-07 17:34   ` [tarantool-patches] " Vladislav Shpilevoy
2019-03-11 15:04     ` Kirill Shcherbatov
2019-03-18 19:33       ` Vladislav Shpilevoy
2019-03-20 11:02         ` Kirill Shcherbatov
2019-02-27 11:13 ` [tarantool-patches] [PATCH v2 5/7] sql: refactor sql_trigger_step_allocate " Kirill Shcherbatov
2019-03-07 17:34   ` [tarantool-patches] " Vladislav Shpilevoy
2019-03-11 15:04     ` Kirill Shcherbatov
2019-03-18 19:33       ` Vladislav Shpilevoy
2019-03-20 11:02         ` Kirill Shcherbatov
2019-03-26 17:08           ` Vladislav Shpilevoy
2019-02-27 11:13 ` [tarantool-patches] [PATCH v2 6/7] sql: refactor sql_expr_create " Kirill Shcherbatov
2019-03-07 17:34   ` [tarantool-patches] " Vladislav Shpilevoy
2019-03-11 15:04     ` Kirill Shcherbatov
2019-03-18 19:33       ` Vladislav Shpilevoy
2019-03-20 11:02         ` Kirill Shcherbatov
2019-03-26 17:08           ` Vladislav Shpilevoy
2019-02-27 11:13 ` [tarantool-patches] [PATCH v2 7/7] sql: store regular identifiers in case-normal form Kirill Shcherbatov
2019-03-07 17:34   ` [tarantool-patches] " Vladislav Shpilevoy
2019-03-11 15:04     ` Kirill Shcherbatov
2019-03-18 19:33       ` Vladislav Shpilevoy [this message]
2019-03-20 11:02         ` Kirill Shcherbatov
2019-03-26 17:08           ` Vladislav Shpilevoy
2019-03-18 19:33 ` [tarantool-patches] Re: [PATCH v2 0/7] " Vladislav Shpilevoy
2019-03-20 11:02   ` Kirill Shcherbatov
2019-03-26 17:09     ` Vladislav Shpilevoy
2019-03-27 14:06 ` 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=a11299d1-0eaa-d62b-6ee3-21d25d7f55d8@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH v2 7/7] sql: store regular identifiers in case-normal form' \
    /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