Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: tarantool-patches@freelists.org, Nikita Pettik <korablev@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH 1/6] sql: move constraint name to struct contraint_parse
Date: Mon, 14 Jan 2019 17:04:48 +0300	[thread overview]
Message-ID: <834ae33b-dddd-3f51-f6f1-ef5bcc24e240@tarantool.org> (raw)
In-Reply-To: <499ebc6e21ade22cde794f8470bf5900131d42f5.1547035183.git.korablev@tarantool.org>

Hi! Thanks for the patch! See 3 comments below.

On 09/01/2019 15:13, Nikita Pettik wrote:
> Before this patch name of constraint being parsed was held as a separate
> struct Token within parser context. Meanwhile, we also need to store
> name of table which constraint is related to (in order to implement
> ALTER TABLE ADD CONSTRAINT with several options: foreign key, unique,
> primary key, etc). Hence, lets move constraint name to a separate
> structure and save it alongside with the name of table.
> 
> Needed for #3097
> ---
>   src/box/sql/alter.c     |  4 ++--
>   src/box/sql/build.c     | 36 +++++++++++++++++++-----------------
>   src/box/sql/parse.y     | 22 +++++++++++++---------
>   src/box/sql/prepare.c   | 11 +++++++++++
>   src/box/sql/sqliteInt.h | 32 ++++++++++++++++++--------------
>   5 files changed, 63 insertions(+), 42 deletions(-)
> 
> diff --git a/src/box/sql/sqliteInt.h b/src/box/sql/sqliteInt.h
> index 4110a5991..51a5d01b5 100644
> --- a/src/box/sql/sqliteInt.h
> +++ b/src/box/sql/sqliteInt.h
> @@ -2691,6 +2691,17 @@ struct fkey_parse {
>   	struct rlist link;
>   };
>   
> +/**
> + * Used to hold intermediate meta-information during
> + * constraint creation or alteration.
> + */
> +struct constraint_parse {
> +	/** Name of table which constraint belongs to. */
> +	struct SrcList *table_name;

1. I guess, it is not a 'table_name', but a 'table' since it
is struct SrcList, not const char * nor Token.

> +	/** Name of the constraint currently being parsed. */
> +	struct Token name;
> +};

2.1. Also, I see that struct constraint_parse is not able to
describe a foreign key - it has no parent table, referenced
columns - you pass them separately from struct constraint_parse
which looks contr-intuitive. Can you please, elaborate so it,
for example, has struct fkey_parse as a member? Or at least,
have both parent and child table name and cols as Token and
ExprList pointers?

> +
>   /*
>    * An SQL parser context.  A copy of this structure is passed through
>    * the parser and down into all the parser action routine in order to
> @@ -2781,6 +2791,10 @@ struct Parse {
>   	TriggerPrg *pTriggerPrg;	/* Linked list of coded triggers */
>   	With *pWith;		/* Current WITH clause, or NULL */
>   	With *pWithToFree;	/* Free this WITH object at the end of the parse */
> +	/**
> +	 * Constraint currently being parsed.
> +	 */
> +	struct constraint_parse *constraint;

3. Make it an object, not a pointer, please. Anyway you allocate it on
each prepare.

>   	/**
>   	 * Number of FK constraints declared within
>   	 * CREATE TABLE statement.
> @@ -4152,8 +4161,7 @@ fkey_change_defer_mode(struct Parse *parse_context, bool is_deferred);
>    *                algorithms (e.g. CASCADE, RESTRICT etc).
>    */
>   void
> -sql_create_foreign_key(struct Parse *parse_context, struct SrcList *child,
> -		       struct Token *constraint, struct ExprList *child_cols,
> +sql_create_foreign_key(struct Parse *parse_context, struct ExprList *child_cols,
>   		       struct Token *parent, struct ExprList *parent_cols,
>   		       bool is_deferred, int actions);

2.2 This is what I've described in point 2 - child part is partially moved into
struct contraint_parse, whilst parent still is separate.

  reply	other threads:[~2019-01-14 14:05 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-09 12:13 [tarantool-patches] [PATCH 0/6] Introduce ALTER TABLE ADD CONSTRAINT UNIQUE/PK Nikita Pettik
2019-01-09 12:13 ` [tarantool-patches] [PATCH 1/6] sql: move constraint name to struct contraint_parse Nikita Pettik
2019-01-14 14:04   ` Vladislav Shpilevoy [this message]
2019-01-16 20:06     ` [tarantool-patches] " n.pettik
2019-01-16 20:54       ` Vladislav Shpilevoy
2019-01-17 10:56       ` Konstantin Osipov
2019-01-17 17:14         ` n.pettik
2019-01-09 12:13 ` [tarantool-patches] [PATCH 2/6] sql: rework ALTER TABLE grammar Nikita Pettik
2019-01-14 14:05   ` [tarantool-patches] " Vladislav Shpilevoy
2019-01-16 20:06     ` n.pettik
2019-01-16 20:54       ` Vladislav Shpilevoy
2019-01-17 11:51   ` Konstantin Osipov
2019-01-17 17:14     ` n.pettik
2019-01-18  1:42       ` Konstantin Osipov
2019-01-09 12:13 ` [tarantool-patches] [PATCH 3/6] sql: remove start token from sql_create_index args Nikita Pettik
2019-01-09 12:13 ` [tarantool-patches] [PATCH 4/6] sql: refactor getNewIid() function Nikita Pettik
2019-01-14 14:05   ` [tarantool-patches] " Vladislav Shpilevoy
2019-01-09 12:13 ` [tarantool-patches] [PATCH 5/6] sql: fix error message for improperly created index Nikita Pettik
2019-01-14 14:06   ` [tarantool-patches] " Vladislav Shpilevoy
2019-01-16 20:06     ` n.pettik
2019-01-09 12:13 ` [tarantool-patches] [PATCH 6/6] sql: introduce ALTER TABLE ADD CONSTRAINT UNIQUE/PRIMARY KEY Nikita Pettik
2019-01-14 14:06   ` [tarantool-patches] " Vladislav Shpilevoy
2019-01-16 20:06     ` n.pettik
2019-01-16 20:54       ` Vladislav Shpilevoy

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=834ae33b-dddd-3f51-f6f1-ef5bcc24e240@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=korablev@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH 1/6] sql: move constraint name to struct contraint_parse' \
    /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