From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 210E52E023 for ; Mon, 3 Jun 2019 17:15:32 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id i_ndJvksqQRE for ; Mon, 3 Jun 2019 17:15:32 -0400 (EDT) Received: from smtp45.i.mail.ru (smtp45.i.mail.ru [94.100.177.105]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id D5B5B2DF7A for ; Mon, 3 Jun 2019 17:15:31 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH v5 0/6] box: run checks on insertions in LUA spaces References: From: Vladislav Shpilevoy Message-ID: <18232b7e-6985-1349-706c-47d07fb33e45@tarantool.org> Date: Mon, 3 Jun 2019 23:15:28 +0200 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: Kirill Shcherbatov , tarantool-patches@freelists.org Please, proceed with next patches. We need to make a single Vdbe for all checks in a separate commit. There is also a new proposal for benchmark. Lets compare SQL CHECKs with tuple validation in Lua before insertion, and see what is faster. Please, write down somewhere all our planned benchmarks so as no to forget something. Totally: 1) bench CHECKs before your patch via pure SQL 2) bench before your patch via checks done in Lua before insertion 3) bench after patch via pure SQL 4) bench via Lua DML After single Vdbe is implemented, bench 3 and 4 again. On 23/05/2019 13:19, Kirill Shcherbatov wrote: > Fire CK constraints for LUA spaces. > To achieve this goal, we reworked data dictionary, to store ck > constraints in separate space _ck_constraints and updated data > migration script to migrate existent data there. This also would > be useful in future to implement ALTER SPACE ADD CONSTRAINT > operation. Now we do not support CK constraint creation on > non-empty space. > Each CK has own precompiled VDBE machine that performs this > check with tuple fields mapped to it's memory with sql_bind() api. > In case of ck constraint conflict detected by this VM we abort > the transaction and return error to user. > Finally, we introduced a LUA-wrapper that provide a user-friendly > way to manage space ck constraints. > > Changes in version 5: > - a new tuple_fetcher class to access tuple fields fast > - refactored _ck_constraint space format and indexes > - one on_replace trigger for all ck constraints > - trim_space_snprintf fixes: do not trim substring in ' or " > - do not wrap ck_constraint methods > - many minor fixes > > v4: https://www.freelists.org/post/tarantool-patches/PATCH-v4-04-box-run-checks-on-insertions-in-LUA-spaces > > Branch: http://github.com/tarantool/tarantool/tree/kshch/gh-3691-checks-on-server-side > Issue: https://github.com/tarantool/tarantool/issues/3691 > > Kirill Shcherbatov (6): > sql: introduce a new method to bind a pointer > sql: refactor OP_Column vdbe instruction > sql: introduce tuple_fetcher class > schema: add new system space for CHECK constraints > box: run check constraint tests on space alter > box: user-friendly interface to manage ck constraints > > src/box/CMakeLists.txt | 1 + > src/box/alter.cc | 342 +++++++++++++- > src/box/alter.h | 1 + > src/box/bootstrap.snap | Bin 4379 -> 4430 bytes > src/box/ck_constraint.c | 238 ++++++++++ > src/box/ck_constraint.h | 196 ++++++++ > src/box/errcode.h | 4 +- > src/box/lua/schema.lua | 35 +- > src/box/lua/space.cc | 65 +++ > src/box/lua/upgrade.lua | 40 ++ > src/box/schema.cc | 8 + > src/box/schema_def.h | 11 + > src/box/space.c | 6 + > src/box/space.h | 8 + > src/box/space_def.c | 98 +--- > src/box/space_def.h | 4 - > src/box/sql.c | 103 +---- > src/box/sql.h | 82 ++-- > src/box/sql/build.c | 220 +++++++-- > src/box/sql/expr.c | 25 +- > src/box/sql/insert.c | 115 ++--- > src/box/sql/parse.y | 2 +- > src/box/sql/parse_def.h | 24 + > src/box/sql/select.c | 11 +- > src/box/sql/sqlInt.h | 50 ++- > src/box/sql/tarantoolInt.h | 5 +- > src/box/sql/tokenize.c | 1 - > src/box/sql/vdbe.c | 308 +++++++------ > src/box/sql/vdbe.h | 1 - > src/box/sql/vdbeInt.h | 20 +- > src/box/sql/vdbeapi.c | 20 +- > src/box/sql/vdbemem.c | 8 + > test/app-tap/tarantoolctl.test.lua | 4 +- > test/box-py/bootstrap.result | 4 + > test/box/access.result | 3 + > test/box/access.test.lua | 1 + > test/box/access_misc.result | 3 + > test/box/access_sysview.result | 6 +- > test/box/alter.result | 5 +- > test/box/misc.result | 2 + > test/sql-tap/check.test.lua | 42 +- > test/sql-tap/fkey2.test.lua | 4 +- > test/sql-tap/sql-errors.test.lua | 2 +- > test/sql-tap/table.test.lua | 12 +- > test/sql/checks.result | 620 ++++++++++++++++++++++++-- > test/sql/checks.test.lua | 228 ++++++++-- > test/sql/errinj.result | 140 ++++++ > test/sql/errinj.test.lua | 45 ++ > test/sql/gh-2981-check-autoinc.result | 12 +- > test/sql/types.result | 3 +- > test/sql/upgrade.result | 19 + > test/sql/upgrade.test.lua | 5 + > test/wal_off/alter.result | 2 +- > 53 files changed, 2561 insertions(+), 653 deletions(-) > create mode 100644 src/box/ck_constraint.c > create mode 100644 src/box/ck_constraint.h >