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 5/7] sql: refactor sql_trigger_step_allocate to set diag
Date: Mon, 18 Mar 2019 22:33:56 +0300	[thread overview]
Message-ID: <6fc95943-2a4b-19f3-6b66-408e6d03bd7a@tarantool.org> (raw)
In-Reply-To: <e1bc0e82-df24-e34e-ce4d-4f93007f1f40@tarantool.org>

Thanks for the fixes. See 6 comments below.

> 
> Part of #3931
> ---
>   src/box/sql/parse.y   |  30 +++++--
>   src/box/sql/sqlInt.h  |  77 +++++++++++++++--
>   src/box/sql/trigger.c | 187 +++++++++++++++++-------------------------
>   3 files changed, 167 insertions(+), 127 deletions(-)
> 
> diff --git a/src/box/sql/parse.y b/src/box/sql/parse.y
> index 8a8f1b82f..f0388b481 100644
> --- a/src/box/sql/parse.y
> +++ b/src/box/sql/parse.y
> @@ -1415,20 +1415,34 @@ tridxby ::= NOT INDEXED. {
>   %destructor trigger_cmd {sqlDeleteTriggerStep(pParse->db, $$);}
>   // UPDATE
>   trigger_cmd(A) ::=
> -   UPDATE orconf(R) trnm(X) tridxby SET setlist(Y) where_opt(Z).
> -   {A = sqlTriggerUpdateStep(pParse->db, &X, Y, Z, R);}
> +   UPDATE orconf(R) trnm(X) tridxby SET setlist(Y) where_opt(Z). {
> +     A = sql_trigger_update_step(pParse->db, &X, Y, Z, R);
> +     if (A == NULL)
> +        sql_parser_error(pParse);

1. Why do not you return after an error here and in other places?

> diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h
> index b49229b26..4e6c5717b 100644
> --- a/src/box/sql/sqlInt.h
> +++ b/src/box/sql/sqlInt.h
> @@ -4087,12 +4087,77 @@ vdbe_code_row_trigger_direct(struct Parse *parser, struct sql_trigger *trigger,
>   			     int ignore_jump);
>   
>   void sqlDeleteTriggerStep(sql *, TriggerStep *);
> -TriggerStep *sqlTriggerSelectStep(sql *, Select *);
> -TriggerStep *sqlTriggerInsertStep(sql *, Token *, IdList *,
> -				      Select *, u8);
> -TriggerStep *sqlTriggerUpdateStep(sql *, Token *, ExprList *, Expr *,
> -				      u8);
> -TriggerStep *sqlTriggerDeleteStep(sql *, Token *, Expr *);
> +
> +/**
> + * Turn a SELECT statement (that the pSelect parameter points to)

2. Again old names.

> + * into a trigger step. Return a pointer to a TriggerStep
> + * structure.

3. In that case a type of return value is strictly determined
thanks to C language. Not sure if that sentence makes a sense.
The same about other places.

> + * The parser calls this routine when it finds a SELECT statement
> + * in body of a TRIGGER.
> + *
> + * @param db The database connection.
> + * @param select The SELECT statement to process.
> + * @retval Not NULL TriggerStep object on success.
> + * @retval NULL Otherwise. The diag message is set.
> + */
> +struct TriggerStep *
> +sql_trigger_select_step(struct sql *db, struct Select *select);
> +
> +/**
> + * Build a trigger step out of an INSERT statement. Return a
> + * pointer to the new trigger step.
> + * The parser calls this routine when it sees an INSERT inside the
> + * body of a trigger.
> + *
> + * @param db The database connection.
> + * @param table_name Name of the table into which we insert.
> + * @param column_list List of columns in table to insert into.
> + * @param select The SELECT statement that supplies values.
> + * @param orconf The conflict algorithm
> + *               (ON_CONFLICT_ACTION_ABORT, _REPLACE, etc.).
> + * @retval Not NULL TriggerStep object on success.
> + * @retval NULL Otherwise. The diag message is set.
> + */
> +struct TriggerStep *
> +sql_trigger_insert_step(struct sql *db, struct Token *table_name,
> +			struct IdList *column_list, struct Select *select,
> +			u8 orconf);

4. If you decided to completely refactor these functions,
then use enum on_conflict_action, please.

> +
> +/**
> + * Construct a trigger step that implements an UPDATE statement
> + * and return a pointer to that trigger step. The parser calls
> + * this routine when it sees an UPDATE statement inside the body
> + * of a CREATE TRIGGER.
> + *
> + * @param db The database connection.
> + * @param table_name Name of the table to be updated.
> + * @param new_list The SET clause: list of column and new values.
> + * @param where The WHERE clause.
> + * @param orconf The conflict algorithm
> + *               (ON_CONFLICT_ACTION_ABORT, _REPLACE, etc.).
> + * @retval Not NULL TriggerStep object on success.
> + * @retval NULL Otherwise.

5. In other places you wrote 'The diag message is set.'. Is it
set here? I know, that it is, but the comment differs from the others.
We should either never say about diag explicitly, or say it everywhere.
And I think that now, while some SQL functions do not set diag, we
should say about diag explicitly.

> + */
> +struct TriggerStep *
> +sql_trigger_update_step(struct sql *db, struct Token *table_name,

6. On the branch I see a whitespace after '*' before 'table_name'.
Please, remove.

> +		        struct ExprList *new_list, struct Expr *where,
> +			u8 orconf);
> +

  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] 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
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 [this message]
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=6fc95943-2a4b-19f3-6b66-408e6d03bd7a@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH v2 5/7] sql: refactor sql_trigger_step_allocate 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