Tarantool development patches archive
 help / color / mirror / Atom feed
From: "n.pettik" <korablev@tarantool.org>
To: tarantool-patches@freelists.org
Cc: Kirill Yukhin <kyukhin@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH] sql: prohibit duplication of FK action clause
Date: Wed, 13 Feb 2019 22:43:26 +0300	[thread overview]
Message-ID: <50B90E82-7ECC-4C12-B7EF-132E77EDDDEC@tarantool.org> (raw)
In-Reply-To: <68664d5ad6be9959c4364a288ccc2feed84cd8b4.1550037810.git.kyukhin@tarantool.org>



> On 13 Feb 2019, at 09:08, Kirill Yukhin <kyukhin@tarantool.org> wrote:
> 
> The patch prohibits duplication of action clause for foreign
> key constraints. It is now syntax error to specify, say,
> ON UPDATE clause for the same FK twice.
> The patch also remove ON INSERT caluse at all, since it
> ultimately is no-op and leads to nothing but confusion.
> 
> Closes #3475
> ---
> https://github.com/tarantool/tarantool/issues/3475
> https://github.com/tarantool/tarantool/commits/kyukhin/gh-3475-fk-duplicate-action-clause

Travis status is completely negative. Please, make sure it is green
before sending patch.

> src/box/sql/parse.y                           | 10 +++++++--
> test/sql/gh-3475-fk-duplicate-clause.result   | 32 +++++++++++++++++++++++++++
> test/sql/gh-3475-fk-duplicate-clause.test.lua | 13 +++++++++++
> 3 files changed, 53 insertions(+), 2 deletions(-)
> create mode 100644 test/sql/gh-3475-fk-duplicate-clause.result
> create mode 100644 test/sql/gh-3475-fk-duplicate-clause.test.lua
> 
> diff --git a/src/box/sql/parse.y b/src/box/sql/parse.y
> index 32ef685..7938afd 100644
> --- a/src/box/sql/parse.y
> +++ b/src/box/sql/parse.y
> @@ -283,10 +283,16 @@ autoinc(X) ::= AUTOINCR.  {X = 1;}
> //
> %type refargs {int}
> refargs(A) ::= .                  { A = FKEY_NO_ACTION; }
> -refargs(A) ::= refargs(A) refarg(Y). { A = (A & ~Y.mask) | Y.value; }
> +refargs(A) ::= refargs(A) refarg(Y). { if ((A & Y.mask) == 0) {
> +                                           A = (A & ~Y.mask) | Y.value;
> +                                       } else {
> +                                           sqlite3ErrorMsg(pParse,
> +                                                           "near \"%T\": duplicate FK action clause.",
> +                                                           &pParse->sLastToken);
> +                                       }
> +                                     }

Please, fix indentation, it looks extremely awful.
Lets use 2 spaces as a default indent (as almost
everywhere in parse.y).

> diff --git a/test/sql/gh-3475-fk-duplicate-clause.test.lua b/test/sql/gh-3475-fk-duplicate-clause.test.lua
> new file mode 100644
> index 0000000..447c104
> --- /dev/null
> +++ b/test/sql/gh-3475-fk-duplicate-clause.test.lua
> @@ -0,0 +1,13 @@
> +test_run = require('test_run').new()
> +engine = test_run:get_cfg('engine')
> +box.sql.execute('pragma sql_default_engine=\''..engine..'\’')

Should this test be engine-dependent?

> +
> +box.cfg{}
> +
> +box.sql.execute("CREATE TABLE t1(a INT PRIMARY KEY, b INT UNIQUE)")
> +box.sql.execute("CREATE TABLE t2(a INT PRIMARY KEY, b INT REFERENCES t1(b) ON UPDATE CASCADE ON UPDATE CASCADE)")
> +box.sql.execute("CREATE TABLE t2(a INT PRIMARY KEY, b INT REFERENCES t1(b) ON DELETE CASCADE ON DELETE CASCADE)")
> +box.sql.execute("CREATE TABLE t2(a INT PRIMARY KEY, b INT REFERENCES t1(b) ON DELETE CASCADE ON UPDATE CASCADE)”)

What about next cases:

box.sql.execute("CREATE TABLE t2(a INT PRIMARY KEY, b INT REFERENCES t1(b) ON DELETE CASCADE ON DELETE RESTRICT)”)
box.sql.execute("CREATE TABLE t2(a INT PRIMARY KEY, b INT REFERENCES t1(b) ON DELETE CASCADE ON UPDATE CASCADE ON DELETE RESTRICT )”)

Sorry, can’t check myself since can’t build your branch.

  reply	other threads:[~2019-02-13 19:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-13  6:08 [tarantool-patches] " Kirill Yukhin
2019-02-13 19:43 ` n.pettik [this message]
2019-02-14  8:56   ` [tarantool-patches] " Kirill Yukhin
2019-02-14 13:44     ` n.pettik

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=50B90E82-7ECC-4C12-B7EF-132E77EDDDEC@tarantool.org \
    --to=korablev@tarantool.org \
    --cc=kyukhin@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH] sql: prohibit duplication of FK action clause' \
    /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