Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: Kirill Shcherbatov <kshcherbatov@tarantool.org>,
	tarantool-patches@freelists.org
Subject: [tarantool-patches] Re: [PATCH v2 0/7] sql: store regular identifiers in case-normal form
Date: Mon, 18 Mar 2019 22:33:58 +0300	[thread overview]
Message-ID: <f3b55e03-c46e-16d0-9c81-deb37b3beba9@tarantool.org> (raw)
In-Reply-To: <cover.1551265819.git.kshcherbatov@tarantool.org>

I see, that you've added a new patch, but decided not to
send it. I've done that. Below you can find my 2 comments on
it.

> commit 47f6bd7a079c8a5af73abe88d9abc24e4bf95f75
> Author: Kirill Shcherbatov <kshcherbatov@tarantool.org>
> Date:   Mon Mar 11 14:33:57 2019 +0300
> 
>     sql: rework sqlIdListAppend to set diag
>     
>     Refactored sqlIdListAppend routine as sql_id_list_append and
>     reworked it to use diag_set in case of memory allocation error.
>     This change is necessary because the sql_id_list_append body has
>     a sqlNameFromToken call that will be changed in subsequent
>     patches.
>     
>     This patch refers to a series of preparatory patches that provide
>     the use of Tarantool errors in the call tree that includes
>     sqlNormalizeName, since this call can later return errors.
>     
>     This patch is not self-sufficient, its sqlNameFromToken call
>     remained to be non-Tarantool (for now). It means, that if
>     sqlNameFromToken fails in sql_id_list_append there is no
>     diag message created.
>     
>     Part of #3931
> 
> diff --git a/src/box/sql/parse.y b/src/box/sql/parse.y
> index 122fda2f0..8a8f1b82f 100644
> --- a/src/box/sql/parse.y
> +++ b/src/box/sql/parse.y
> @@ -797,10 +797,17 @@ insert_cmd(A) ::= REPLACE.            {A = ON_CONFLICT_ACTION_REPLACE;}
>  
>  idlist_opt(A) ::= .                       {A = 0;}
>  idlist_opt(A) ::= LP idlist(X) RP.    {A = X;}
> -idlist(A) ::= idlist(A) COMMA nm(Y).
> -    {A = sqlIdListAppend(pParse->db,A,&Y);}
> -idlist(A) ::= nm(Y).
> -    {A = sqlIdListAppend(pParse->db,0,&Y); /*A-overwrites-Y*/}
> +idlist(A) ::= idlist(A) COMMA nm(Y). {
> +  A = sql_id_list_append(pParse->db,A,&Y);
> +  if (A == NULL)
> +    sql_parser_error(pParse);
> +}
> +idlist(A) ::= nm(Y). {
> +  /* A-overwrites-Y. */
> +  A = sql_id_list_append(pParse->db,0,&Y);
> +  if (A == NULL)
> +    sql_parser_error(pParse);

1. Why do not you return after an error?

> +}
>  
>  /////////////////////////// Expression Processing /////////////////////////////
>  //
> diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h
> index 2df1830d6..56ae90a95 100644
> --- a/src/box/sql/sqlInt.h
> +++ b/src/box/sql/sqlInt.h
> @@ -3388,7 +3388,20 @@ sql_drop_table(struct Parse *, struct SrcList *, bool, bool);
>  void sqlInsert(Parse *, SrcList *, Select *, IdList *,
>  	       enum on_conflict_action);
>  void *sqlArrayAllocate(sql *, void *, int, int *, int *);
> -IdList *sqlIdListAppend(sql *, IdList *, Token *);
> +
> +/**
> + * Append a new element to the given IdList. Create a new IdList
> + * if need be.
> + *
> + * @param db The database connection.
> + * @param list The pointer to existent Id list if exists.
> + * @param name_token The token containing name.
> + * @retval Not NULL IdList pointer is returned on success.
> + * @retval NULL otherwise. Diag message is set.
> + */
> +struct IdList *
> +sql_id_list_append(struct sql *db, struct IdList *pList, struct Token *pToken);

2. The arg names are old, and do not match the implementation
and the comment.

> +
>  int sqlIdListIndex(IdList *, const char *);
>  
>  /**

  parent 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] " 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
2019-03-20 11:02         ` Kirill Shcherbatov
2019-03-26 17:08           ` Vladislav Shpilevoy
2019-03-18 19:33 ` Vladislav Shpilevoy [this message]
2019-03-20 11:02   ` [tarantool-patches] Re: [PATCH v2 0/7] " 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=f3b55e03-c46e-16d0-9c81-deb37b3beba9@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH v2 0/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