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 A7D36261DF for ; Wed, 30 Jan 2019 03:59:20 -0500 (EST) 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 kpbDsTm37wOH for ; Wed, 30 Jan 2019 03:59:20 -0500 (EST) Received: from smtp54.i.mail.ru (smtp54.i.mail.ru [217.69.128.34]) (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 D841A261BA for ; Wed, 30 Jan 2019 03:59:19 -0500 (EST) From: Kirill Shcherbatov Subject: [tarantool-patches] [PATCH v2 0/9] sql: Checks on server side Date: Wed, 30 Jan 2019 11:59:07 +0300 Message-Id: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: tarantool-patches@freelists.org, korablev@tarantool.org Cc: Kirill Shcherbatov Fire check constraints for LUA space for insert and update operations 1. Reworked check constraints in Tarantool - refactored code: -- new _ck_constraint space to persist check constraints -- new ck_constrain_def and ck_constraint classes to work with ck constraints -- checks based on TYPEOF operator are forbidden 2. Fixed few bugs in core (out of Checks epic) -- access check for _treigger and _ck_constraint space -- fixed 2.1.1 migration -- fixed possible segfault and _trigger space alter Changes in version 2: -- Totally changed approach to store check constraints in server -- Independent VDBE on server for each check constraint: (pay attantion that we must recompile VDBE on space alter operation as space_def may be changed) -- routines is split by modules in a better way v1: https://www.freelists.org/post/tarantool-patches/PATCH-v1-04-sql-Checks-on-server-side Branch: http://github.com/tarantool/tarantool/tree/kshch/gh-3691-checks-on-server-side Issue: https://github.com/tarantool/tarantool/issues/3691 Kirill Shcherbatov (9): box: fix upgrade script for _fk_constraint space box: fix _trigger and _ck_constraint access check box: fix Tarantool upgrade from 2.1.0 to 2.1.1 box: fix on_replace_trigger_rollback routine schema: add new system space for CHECK constraints sql: disallow use of TYPEOF in Check sql: refactor sqlite3_reset routine box: exported sql_bind structure and API sql: run check constraint tests on space alter src/box/CMakeLists.txt | 2 + src/box/alter.cc | 256 +++++++++++++- src/box/alter.h | 1 + src/box/bind.c | 239 +++++++++++++ src/box/bind.h | 138 ++++++++ src/box/bootstrap.snap | Bin 1911 -> 1955 bytes src/box/ck_constraint.c | 318 ++++++++++++++++++ src/box/ck_constraint.h | 187 ++++++++++ src/box/errcode.h | 4 +- src/box/execute.c | 270 +-------------- src/box/execute.h | 18 +- src/box/index_def.c | 1 + src/box/iproto.cc | 1 + src/box/lua/schema.lua | 4 + src/box/lua/space.cc | 2 + src/box/lua/upgrade.lua | 64 +++- src/box/opt_def.c | 3 + src/box/opt_def.h | 12 +- src/box/schema.cc | 8 + src/box/schema_def.h | 9 + src/box/space.c | 2 + src/box/space.h | 5 + src/box/space_def.c | 97 +----- src/box/space_def.h | 2 - src/box/sql.c | 99 +----- src/box/sql.h | 44 --- src/box/sql/build.c | 160 +++++++-- src/box/sql/insert.c | 111 ++---- src/box/sql/parse.y | 4 +- src/box/sql/prepare.c | 1 + src/box/sql/resolve.c | 3 + src/box/sql/select.c | 3 +- src/box/sql/sqliteInt.h | 42 ++- src/box/sql/vdbe.c | 8 +- src/box/sql/vdbeapi.c | 58 +--- test/app-tap/tarantoolctl.test.lua | 4 +- test/box-py/bootstrap.result | 6 +- test/box/access.result | 3 + test/box/access.test.lua | 1 + test/box/access_misc.result | 2 + test/box/access_sysview.result | 6 +- test/box/alter.result | 6 +- test/box/misc.result | 2 + test/sql-tap/check.test.lua | 94 ++---- test/sql-tap/fkey2.test.lua | 4 +- test/sql-tap/in1.test.lua | 2 +- test/sql-tap/subquery.test.lua | 2 +- test/sql-tap/table.test.lua | 8 +- test/sql/checks.result | 112 +++--- test/sql/checks.test.lua | 60 ++-- test/sql/errinj.result | 76 +++++ test/sql/errinj.test.lua | 26 ++ test/sql/gh-2981-check-autoinc.result | 8 +- test/sql/upgrade.result | 51 +++ test/sql/upgrade.test.lua | 17 + .../upgrade/2.1.0/00000000000000000003.snap | Bin 0 -> 2124 bytes test/wal_off/alter.result | 2 +- 57 files changed, 1792 insertions(+), 876 deletions(-) create mode 100644 src/box/bind.c create mode 100644 src/box/bind.h create mode 100644 src/box/ck_constraint.c create mode 100644 src/box/ck_constraint.h create mode 100644 test/sql/upgrade/2.1.0/00000000000000000003.snap -- 2.19.2