Tarantool development patches archive
 help / color / mirror / Atom feed
From: "n.pettik" <korablev@tarantool.org>
To: tarantool-patches@freelists.org
Cc: Kirill Shcherbatov <kshcherbatov@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH v3 1/3] schema: add new system space for CHECK constraints
Date: Sun, 12 May 2019 16:45:30 +0300	[thread overview]
Message-ID: <D100010B-42DE-4D3A-933F-661E46764BFB@tarantool.org> (raw)
In-Reply-To: <0cd8bbf7-adfa-f59e-b726-313700aa2b39@tarantool.org>


>> Nit: ck_constraint_def_sizeof() return uint32_t
>> 
>> Also why do we not use vdbe_emit_halt_with_presence_test()
>> during creation of check constraints?
>> 
>> tarantool> create table t2(id int primary key, constraint ck1 check(id > 0), constraint ck1 check(id < 0))
>> ---
>> - error: Duplicate key exists in unique index 'primary' in space '_ck_constraint'
>> ...
>> tarantool> create table t2(id int primary key, constraint fk1 foreign key(id) references t2, constraint fk1 foreign key(id) references t2)
>> ---
>> - error: Constraint FK1 already exists
>> ...
>> 
> 
> And this is a bug in FK
> https://github.com/tarantool/tarantool/issues/4183

Still, we have an option to fix it: display proper error message and
process clean-up. Please, add a mention that in scope of issue we
should also use vdbe_emit_halt_with_presence_test for CK constraints

>>> +	if (rlist_next(dst_ck_link) != &dest->ck_constraint)
>>> +		return 0;
>> 
>> After next patch this check could be removed: VDBE program for checking
>> consistency of check constraints would be generated automatically.
>> In SQLite xFer allows to avoid generation of this program. On the other hand,
>> if you added way to temporarily disable check constraints, we would able
>> to leave this check and re-enable them after query is executed. So, consider
>> way of disabling/enabling check constraints - it might be useful for other
>> cases as well.
> 
> At first, there is no way to control this state as you propose.

Ok, then we should come up with machinery which will allow us
to disable CK constraints, but not other NoSQL triggers.

> Next, disabling/enabling triggers is required for upgrade() functionality
> and is not a part of public API.

From user’s point of view checks are constraints. AFAIR Konstantin
asked for a handle to disable check and foreign key constraints.

> As in further patches ck constraint are rely
> on trigger machinery, we don't need a separate controller.

We shouldn’t disable all NoSQL triggers, only check constraints.

> So, I've reject xfer optimization when source or destination space has
> ck constraints.

This optimisation doesn’t seem to be vital. On the other hand, if we can
use it, why not to do so?

> This patch introduces a new system space to persist check
> constraints. Format of the space:
> 
> _ck_constraint (space id = 357)
> [<constraint name> STR, <space id> UINT, <expression string>STR]

Nit: you forgot about is_deferred field.

> Because space alter, index alter and space truncate operations
> cause space recreation, introduced RebuildCkConstrains object
> that compile

-> compiles

> new ck constraint objects, replace and remove

-> replaces and removes

> existent instances atomically(when some compilation fails,
> nothing changed).

-> is changed

> In fact, in scope of this patch we don't
> really need to recreate ck_constraint object in such situations
> (patch space_def pointer in AST like we did it before is enough
> now, but we would

-> are going to

> The main motivation for these changes is the ability to support
> ADD CHECK CONSTRAINT operation in the future. CK constraints are
> are easier to manage as self-sustained objects: we mustn’t

What to do?

> the tuple describing target space to do it(unlike the current
> architecture).

Can’t parse this sentence. Re-phrase it please.

> Disabled xfer optimization when some space have ck constraints
> because in the following patches this xfer optimisation becomes
> impossible. No reason to rewrite this code.
> 
> Needed for #3691
> —

Please, don’t send the whole patch again, I expect only diff
between versions. It takes a while to review such huge patch again.

  reply	other threads:[~2019-05-12 13:45 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-16 13:51 [tarantool-patches] [PATCH v3 0/3] box: run checks on insertions in LUA spaces Kirill Shcherbatov
2019-04-16 13:51 ` [tarantool-patches] [PATCH v3 1/3] schema: add new system space for CHECK constraints Kirill Shcherbatov
2019-04-25 20:38   ` [tarantool-patches] " n.pettik
2019-05-07  9:53     ` Kirill Shcherbatov
2019-05-12 13:45       ` n.pettik [this message]
2019-05-12 15:52         ` Kirill Shcherbatov
2019-05-12 23:04           ` n.pettik
2019-05-13  7:11             ` Kirill Shcherbatov
2019-05-13 12:29               ` n.pettik
2019-05-13 13:13                 ` Vladislav Shpilevoy
2019-04-16 13:51 ` [tarantool-patches] [PATCH v3 2/3] box: run check constraint tests on space alter Kirill Shcherbatov
2019-04-25 20:38   ` [tarantool-patches] " n.pettik
2019-05-07  9:53     ` Kirill Shcherbatov
2019-05-07 16:39       ` Konstantin Osipov
2019-05-07 17:47         ` [tarantool-patches] " Kirill Shcherbatov
2019-05-07 20:28           ` Konstantin Osipov
2019-05-11 12:15           ` n.pettik
2019-05-12 21:12             ` Konstantin Osipov
2019-05-13  7:09               ` Kirill Shcherbatov
2019-05-13  7:49                 ` Konstantin Osipov
2019-05-14 16:49       ` n.pettik
2019-04-16 13:51 ` [tarantool-patches] [PATCH v3 3/3] box: user-friendly interface to manage ck constraints Kirill Shcherbatov
2019-04-25 20:38   ` [tarantool-patches] " n.pettik
2019-05-07  9:53     ` Kirill Shcherbatov
2019-05-14 15:02 [tarantool-patches] [PATCH v3 0/3] box: run checks on insertions in LUA spaces Kirill Shcherbatov
2019-05-14 15:02 ` [tarantool-patches] [PATCH v3 1/3] schema: add new system space for CHECK constraints Kirill Shcherbatov
2019-05-14 18:29   ` [tarantool-patches] " Konstantin Osipov

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=D100010B-42DE-4D3A-933F-661E46764BFB@tarantool.org \
    --to=korablev@tarantool.org \
    --cc=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH v3 1/3] schema: add new system space for CHECK constraints' \
    /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