From: Kirill Shcherbatov <kshcherbatov@tarantool.org>
To: tarantool-patches@freelists.org
Cc: "v.shpilevoy@tarantool.org" <v.shpilevoy@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH v2 09/11] sql: new _trigger space format with space_id
Date: Thu, 14 Jun 2018 19:12:40 +0300 [thread overview]
Message-ID: <579ec1a5-31f5-4aa5-8eb9-98b3fab4b2b3@tarantool.org> (raw)
In-Reply-To: <36b21e2d-d459-d373-7c56-02537de5fdd9@tarantool.org>
On 13.06.2018 21:53, Vladislav Shpilevoy wrote:
> Thanks for the patch! Almost ok. See 5 minor comments below.
>
> On 09/06/2018 12:32, Kirill Shcherbatov wrote:
>> As we would like to lookup triggers by space_id in future
>> on space deletion to delete assocoated _trigger tuples we
>
> 1. "assocoated" - typo.
fixed
> 2. Unnecessary diff. Either do this: {data, data}, or this { data, data }.
> Not this: {data, data }. Same below.
_index:insert{_trigger.id, 0, 'primary', 'tree', { unique = true },
- {{0, 'string'}} }
+ {{0, 'string'}}}
log.info("create index secondary on _trigger")
_index:insert{_trigger.id, 1, 'space_id', 'tree', { unique = false },
- {{1, 'unsigned'}} }
+ {{1, 'unsigned'}}}
> 3. Out of 80.
- mp_sizeof_str(trigger_stmt_new_len) + mp_sizeof_uint(space_id);
+ mp_sizeof_str(trigger_stmt_new_len) +
+ mp_sizeof_uint(space_id);
> 4. 'is refer to' is incorrect construction. Maybe did you mean 'refers to'?
- /** The ID of space the trigger is refer to. */
+ /** The ID of space the trigger refers to. */
> 5. How about to test space_id is stored in _trigger? I mean test
> box.space._trigger:select{} full result. Not two columns only.
--- a/test/sql/upgrade.test.lua
+++ b/test/sql/upgrade.test.lua
@@ -25,9 +25,16 @@ box.space._index:get({box.space._space.index['name']:get('T1').id, 0})
box.sql.execute("CREATE TABLE t(x INTEGER PRIMARY KEY);")
box.sql.execute("CREATE TABLE t_out(x INTEGER PRIMARY KEY);")
box.sql.execute("CREATE TRIGGER t1t AFTER INSERT ON t BEGIN INSERT INTO t_out VALUES(1); END;")
+box.sql.execute("CREATE TRIGGER t2t AFTER INSERT ON t BEGIN INSERT INTO t_out VALUES(2); END;")
box.space._space.index['name']:get('T')
box.space._space.index['name']:get('T_OUT')
-box.space._trigger:get('T1T')
+t1t = box.space._trigger:get('T1T')
+t2t = box.space._trigger:get('T2T')
+t1t.name
+t1t.opts
+t2t.name
+t2t.opts
+assert(t1t.id == t2t.id)
And some extra changed required by next message review:
+++ b/src/box/schema_def.h
@@ -217,6 +217,12 @@ enum {
BOX_SPACE_SEQUENCE_FIELD_IS_GENERATED = 2,
};
+enum {
+ BOX_TRIGGER_FIELD_NAME = 0,
+ BOX_TRIGGER_FIELD_SPACE_ID = 1,
+ BOX_TRIGGER_FIELD_OPTS = 2,
+};
+
@@ -1320,7 +1320,7 @@ void tarantoolSqlite3LoadSchema(InitData *init)
ptr = mp_decode_str(&field, &len);
name = strndup(ptr, len);
- field = tuple_field(tuple, 2);
+ field = tuple_field(tuple, BOX_TRIGGER_FIELD_OPTS);
@@ -670,10 +670,10 @@ int tarantoolSqlite3RenameTrigger(const char *trig_name,
return SQL_TARANTOOL_ERROR;
assert(tuple != NULL);
assert(tuple_field_count(tuple) == 3);
- const char *field = box_tuple_field(tuple, 1);
+ const char *field = box_tuple_field(tuple, BOX_TRIGGER_FIELD_SPACE_ID);
assert(mp_typeof(*field) == MP_UINT);
uint32_t space_id = mp_decode_uint(&field);
- field = box_tuple_field(tuple, 2);
+ field = box_tuple_field(tuple, BOX_TRIGGER_FIELD_OPTS);
next prev parent reply other threads:[~2018-06-14 16:12 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-09 9:58 [tarantool-patches] [PATCH v2 00/11] sql: remove Triggers to server Kirill Shcherbatov
2018-06-09 9:32 ` [tarantool-patches] [PATCH v2 10/11] sql: move " Kirill Shcherbatov
2018-06-13 18:53 ` [tarantool-patches] " Vladislav Shpilevoy
2018-06-14 16:12 ` Kirill Shcherbatov
2018-06-28 7:18 ` Konstantin Osipov
2018-06-28 7:33 ` Kirill Shcherbatov
2018-06-09 9:32 ` [tarantool-patches] [PATCH v2 11/11] sql: VDBE tests for trigger existence Kirill Shcherbatov
2018-06-13 18:53 ` [tarantool-patches] " Vladislav Shpilevoy
2018-06-14 16:12 ` Kirill Shcherbatov
2018-06-09 9:32 ` [tarantool-patches] [PATCH v2 02/11] box: move db->pShchema init to sql_init Kirill Shcherbatov
2018-06-09 9:32 ` [tarantool-patches] [PATCH v2 04/11] sql: fix sql len in tarantoolSqlite3RenameTrigger Kirill Shcherbatov
2018-06-09 9:32 ` [tarantool-patches] [PATCH v2 06/11] sql: refactor sql_expr_compile to return AST Kirill Shcherbatov
2018-06-13 18:53 ` [tarantool-patches] " Vladislav Shpilevoy
2018-06-14 16:12 ` Kirill Shcherbatov
2018-06-09 9:32 ` [tarantool-patches] [PATCH v2 07/11] sql: move sqlite3DeleteTrigger to sql.h Kirill Shcherbatov
2018-06-13 18:53 ` [tarantool-patches] " Vladislav Shpilevoy
2018-06-14 16:12 ` Kirill Shcherbatov
2018-06-09 9:32 ` [tarantool-patches] [PATCH v2 08/11] box: sort error codes in misc.test Kirill Shcherbatov
2018-06-09 9:32 ` [tarantool-patches] [PATCH v2 09/11] sql: new _trigger space format with space_id Kirill Shcherbatov
2018-06-13 18:53 ` [tarantool-patches] " Vladislav Shpilevoy
2018-06-14 16:12 ` Kirill Shcherbatov [this message]
2018-06-09 9:58 ` [tarantool-patches] [PATCH v2 01/11] box: remove migration from alpha 1.8.2 and 1.8.4 Kirill Shcherbatov
2018-06-09 9:58 ` [tarantool-patches] [PATCH v2 03/11] sql: fix leak on CREATE TABLE and resolve self ref Kirill Shcherbatov
2018-06-13 18:53 ` [tarantool-patches] " Vladislav Shpilevoy
2018-06-14 16:12 ` Kirill Shcherbatov
2018-06-09 9:58 ` [tarantool-patches] [PATCH v2 05/11] box: port schema_find_id to C Kirill Shcherbatov
2018-06-13 18:53 ` [tarantool-patches] " Vladislav Shpilevoy
2018-06-14 16:12 ` Kirill Shcherbatov
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=579ec1a5-31f5-4aa5-8eb9-98b3fab4b2b3@tarantool.org \
--to=kshcherbatov@tarantool.org \
--cc=tarantool-patches@freelists.org \
--cc=v.shpilevoy@tarantool.org \
--subject='[tarantool-patches] Re: [PATCH v2 09/11] sql: new _trigger space format with space_id' \
/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