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 4/7] sql: refactor sql_name_from_token to set diag
Date: Mon, 18 Mar 2019 22:33:57 +0300	[thread overview]
Message-ID: <9e87fae4-138e-f727-f9fa-8904687d2acc@tarantool.org> (raw)
In-Reply-To: <4bb2ebb3-dfc7-b95c-cd76-6992baa92128@tarantool.org>

The diff in your email has nothing to do with sql_name_from_token.
You've not sent a new version of that patch, so I did it below
with my 2 comments inlined.

> commit b052b1b0a43159ac79320d5dca43a201fffa6ab9
> Author: Kirill Shcherbatov <kshcherbatov@tarantool.org>
> Date:   Wed Feb 13 15:15:22 2019 +0300
> 
>     sql: rework sqlNameFromToken to set diag
>     
>     Refactored sqlNameFromToken routine as sql_name_from_token and
>     reworked it to use diag_set in case of memory allocation error.
>     This change is necessary because the sql_name_from_token body has
>     a sqlNameFromToken call that will be changed in subsequent
>     patches.

1. Now, reread that paragraph and fix what is wrong. You do not call
sqlNameFromToken from sql_name_from_token.

>     
>     Part of #3931
> 
> diff --git a/src/box/sql/build.c b/src/box/sql/build.c
> index d374acb47..1864bd0ad 100644
> --- a/src/box/sql/build.c
> +++ b/src/box/sql/build.c
> @@ -2981,19 +3001,23 @@ sqlWithAdd(Parse * pParse,	/* Parsing context */
>  {
>  	sql *db = pParse->db;
>  	With *pNew;
> -	char *zName;
>  
> -	/* Check that the CTE name is unique within this WITH clause. If
> -	 * not, store an error in the Parse structure.
> +	/*
> +	 * Check that the CTE name is unique within this WITH
> +	 * clause. If not, store an error in the Parse structure.
>  	 */
> -	zName = sqlNameFromToken(pParse->db, pName);
> -	if (zName && pWith) {
> +	char *name = sql_name_from_token(db, pName);
> +	if (name == NULL) {
> +		sql_parser_error(pParse);
> +		return NULL;

2. Leak. sqlWithAdd should delete some structures in a case of OOM.
Lines 3035 - 3038. Also, that function does not return NULL on an
error - it should return the old value. Otherwise you have a second
leak in parse.y:1494.

> +	}
> +	if (pWith != NULL) {
>  		int i;
>  		for (i = 0; i < pWith->nCte; i++) {
> -			if (strcmp(zName, pWith->a[i].zName) == 0) {
> +			if (strcmp(name, pWith->a[i].zName) == 0) {
>  				sqlErrorMsg(pParse,
> -						"duplicate WITH table name: %s",
> -						zName);
> +					    "duplicate WITH table name: %s",
> +					    name);
>  			}
>  		}
>  	}

  reply	other threads:[~2019-03-18 19:34 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] sql: store regular identifiers in case-normal form 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 [this message]
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
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=9e87fae4-138e-f727-f9fa-8904687d2acc@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH v2 4/7] sql: refactor sql_name_from_token to set diag' \
    /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