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 v4 5/6] sql: move Triggers to server
Date: Tue, 26 Jun 2018 17:05:22 +0300	[thread overview]
Message-ID: <AC8F3533-D502-4684-9E44-BCFE1D49651F@tarantool.org> (raw)
In-Reply-To: <5704ba48-ea6b-4995-c405-4ea7c1ade87c@tarantool.org>


> On 25 Jun 2018, at 18:27, Kirill Shcherbatov <kshcherbatov@tarantool.org> wrote:
> 
>> For instance, why do we still have to hold triggers in a separate hash?
>> To invoke triggers on a particular space you can refer to space->triggers.
>> Deletion of trigger occurs at VDBE runtime, so you just need to make sure
>> that _trigger contains record with given name.
> Introduced sql_triggers field in space structure. 
> Changed parser logic to do not insert built triggers, just only
> to do parsing. All triggers insertions and deletions are operated
> via on_replace_dd_trigger now.                    
> Global DB hash has been kept as we still ned to get Trigger AST 
> by name on trigger deletion.    

Now it is possible to delete trigger using only its name, since
in on_replace_dd_trigger() we would have space_id from tuple.
So, we came to agreement to delete global hash of triggers.

> 
>> Could you write more informative comment which would include information
>> concerning each action, i.e. why we delete tuple on insertion etc.
> /**
>  * Trigger invoked on rollback in the _trigger space.
> + * Insert old sql_trigger AST stored in trigger->data,
> + * destruct new object in any.

*Since rollback trigger is invoked after insertion to hash and space,
 we have to delete it from those structures and release memory.
 Vice versa, after deletion of trigger we must return it back to hash and space*.

>> Well, personally I would move these checks (i.e. testing that trigger created on VIEW
>> must be <INSTEAD OF>, and trigger created on table can’t be <INSTEAD OF>’) to
>> on_replace_dd_trigger. Otherwise, you may catch severe errors after creation of such
>> ‘Inconsistent’ triggers from Lua.
> Good idea,
> moved to sql_trigger_replace.

It would be great if you provided diff: right here, at the end of letter or
as a next patch version. Don’t forget next time.

>> 
>>> @@ -566,34 +559,59 @@ sqlite3DropTriggerPtr(Parse * pParse, Trigger * pTrigger)
>> 
>> Lets rename this function and fix comment for it. I suggest to call it vdbe_code_drop_trigger(),
>> vdbe_emit_drop_trigger() or whatever meaningful name you prefer.
> Ok, as a part of next refactoring commit.

Please, sent that patch or attach diff.

> 
>> I would give it a name like sql_trigger_hash_replace().
> I can't agree. This function not only updates the cache, but also insert AST into space trigger list.

Ok, as you wish.

> 
>> Are you sure that in a case of error we must delete all triggers from hash?Hm, can't remember, how I've wrote this code.
> Yes, a non-trivial place. 
> Like this:

Add cautionary (or FIXME) comment which would explain that
in case of RENAME’s fail we are totally fucked up: part of triggers
remain with old space’s name. Thus, after creation of new space with
the name of old one, it appears with triggers which haven’t been created.

> 
> 		if (rc != SQLITE_OK) {
> 			sqlite3CommitInternalChanges();
> 			goto abort_due_to_error;
> 		}
> 
> 
>> I would also delete all mentions of SQLITE_OMIT_TRIGGER (within a separate patch),
>> since triggers are always enabled in our SQL.
> Ok, as a part of next refactoring commit.

Please, sent that patch or attach diff.

  reply	other threads:[~2018-06-26 14:05 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-20 10:46 [tarantool-patches] [PATCH v4 0/6] sql: remove " Kirill Shcherbatov
2018-06-20 10:46 ` [tarantool-patches] [PATCH v4 1/6] sql: refactor sql_expr_compile to return AST Kirill Shcherbatov
2018-06-20 10:46 ` [tarantool-patches] [PATCH v4 2/6] sql: move sqlite3DeleteTrigger to sql.h Kirill Shcherbatov
2018-06-20 10:46 ` [tarantool-patches] [PATCH v4 3/6] box: sort error codes in misc.test Kirill Shcherbatov
2018-06-20 10:46 ` [tarantool-patches] [PATCH v4 4/6] sql: new _trigger space format with space_id Kirill Shcherbatov
2018-06-20 10:46 ` [tarantool-patches] [PATCH v4 5/6] sql: move Triggers to server Kirill Shcherbatov
2018-06-24 15:24   ` [tarantool-patches] " n.pettik
2018-06-24 20:41     ` Vladislav Shpilevoy
2018-06-25 15:27     ` Kirill Shcherbatov
2018-06-26 14:05       ` n.pettik [this message]
2018-06-26 16:13         ` Kirill Shcherbatov
2018-06-20 10:46 ` [tarantool-patches] [PATCH v4 6/6] sql: VDBE tests for trigger existence Kirill Shcherbatov
2018-06-24 15:25   ` [tarantool-patches] " n.pettik
2018-06-25 15:27     ` Kirill Shcherbatov
2018-06-26 14:49       ` 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=AC8F3533-D502-4684-9E44-BCFE1D49651F@tarantool.org \
    --to=korablev@tarantool.org \
    --cc=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH v4 5/6] sql: move Triggers to server' \
    /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