Tarantool development patches archive
 help / color / mirror / Atom feed
* [tarantool-patches] [PATCH v3 0/3] box: run checks on insertions in LUA spaces
@ 2019-04-16 13:51 Kirill Shcherbatov
  2019-04-16 13:51 ` [tarantool-patches] [PATCH v3 1/3] schema: add new system space for CHECK constraints Kirill Shcherbatov
                   ` (2 more replies)
  0 siblings, 3 replies; 25+ messages in thread
From: Kirill Shcherbatov @ 2019-04-16 13:51 UTC (permalink / raw)
  To: tarantool-patches, korablev; +Cc: Kirill Shcherbatov

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 2:
	- some path parts has been already merged in master
        - dropped commits "box: fix _trigger and _ck_constraint
          access check" and "sql: disallow use of TYPEOF in
          Check" because they are not required and simply wrong
        - code rebased on actual master
        - reworked ck_constrain_def and ck_constraint structures
          and methods to provide a little more consistent API
        - reworked structures are used on SQL parse
        - new user-friendly API
        - use on_replace trigger instead before_replace trigger
          to deal with already-validated tuple
        - many minor review fixes
        - many amazing new test

v2: https://www.freelists.org/post/tarantool-patches/PATCH-v2-09-sql-Checks-on-server-side
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 (3):
  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                      | 267 ++++++++++++++++-
 src/box/alter.h                       |   1 +
 src/box/bootstrap.snap                | Bin 4374 -> 4415 bytes
 src/box/ck_constraint.c               | 271 +++++++++++++++++
 src/box/ck_constraint.h               | 184 ++++++++++++
 src/box/errcode.h                     |   5 +-
 src/box/lua/schema.lua                |  23 ++
 src/box/lua/space.cc                  |   2 +
 src/box/lua/upgrade.lua               |  39 +++
 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                   |  98 +-----
 src/box/space_def.h                   |   2 -
 src/box/sql.c                         |  86 +-----
 src/box/sql.h                         |  36 ---
 src/box/sql/build.c                   | 173 +++++++++--
 src/box/sql/insert.c                  | 125 +++-----
 src/box/sql/parse_def.h               |  22 ++
 src/box/sql/select.c                  |  11 +-
 src/box/sql/sqlInt.h                  |  26 ++
 src/box/sql/tokenize.c                |   1 -
 src/box/sql/vdbeapi.c                 |   8 -
 test/app-tap/tarantoolctl.test.lua    |   6 +-
 test/box-py/bootstrap.result          |   4 +
 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           |  42 +--
 test/sql-tap/fkey2.test.lua           |   4 +-
 test/sql-tap/sql-errors.test.lua      |   2 +-
 test/sql-tap/table.test.lua           |   8 +-
 test/sql/checks.result                | 417 +++++++++++++++++++++++---
 test/sql/checks.test.lua              | 163 ++++++++--
 test/sql/errinj.result                | 140 +++++++++
 test/sql/errinj.test.lua              |  45 +++
 test/sql/gh-2981-check-autoinc.result |  12 +-
 test/sql/upgrade.result               |  19 ++
 test/sql/upgrade.test.lua             |   5 +
 test/wal_off/alter.result             |   2 +-
 45 files changed, 1814 insertions(+), 480 deletions(-)
 create mode 100644 src/box/ck_constraint.c
 create mode 100644 src/box/ck_constraint.h

-- 
2.21.0

^ permalink raw reply	[flat|nested] 25+ messages in thread
* [tarantool-patches] [PATCH v3 0/3] box: run checks on insertions in LUA spaces
@ 2019-05-14 15:02 Kirill Shcherbatov
  2019-05-14 15:02 ` [tarantool-patches] [PATCH v3 1/3] schema: add new system space for CHECK constraints Kirill Shcherbatov
  0 siblings, 1 reply; 25+ messages in thread
From: Kirill Shcherbatov @ 2019-05-14 15:02 UTC (permalink / raw)
  To: tarantool-patches, v.shpilevoy; +Cc: Kirill Shcherbatov

@v.shpilevoy
> Yes, I will. Kirill, please, send it again in a new thread. You can keep
> version 3 and omit change list.

@kostya
> It's better to fetch the bound field upon first access.
> Most paths of the CHECK constraint may not touch most of the
> fields.
I have no idea, how, to fit it in our architecture.
OP_Column has no intersections with binding machinery.

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 2:
	- some path parts has been already merged in master
        - dropped commits "box: fix _trigger and _ck_constraint
          access check" and "sql: disallow use of TYPEOF in
          Check" because they are not required and simply wrong
        - code rebased on actual master
        - reworked ck_constrain_def and ck_constraint structures
          and methods to provide a little more consistent API
        - reworked structures are used on SQL parse
        - new user-friendly API
        - use on_replace trigger instead before_replace trigger
          to deal with already-validated tuple
        - many minor review fixes
        - many amazing new test

v2: https://www.freelists.org/post/tarantool-patches/PATCH-v2-09-sql-Checks-on-server-side
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 (3):
  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                      | 305 +++++++++++++++-
 src/box/alter.h                       |   1 +
 src/box/bootstrap.snap                | Bin 4374 -> 4418 bytes
 src/box/ck_constraint.c               | 267 ++++++++++++++
 src/box/ck_constraint.h               | 169 +++++++++
 src/box/errcode.h                     |   2 +
 src/box/lua/schema.lua                |  38 +-
 src/box/lua/space.cc                  |  65 ++++
 src/box/lua/upgrade.lua               |  43 +++
 src/box/schema.cc                     |   8 +
 src/box/schema_def.h                  |  10 +
 src/box/space.c                       |   2 +
 src/box/space.h                       |   5 +
 src/box/space_def.c                   |  98 +-----
 src/box/space_def.h                   |   2 -
 src/box/sql.c                         |  86 +----
 src/box/sql.h                         |  36 --
 src/box/sql/build.c                   | 208 +++++++++--
 src/box/sql/insert.c                  | 113 ++----
 src/box/sql/parse.y                   |   2 +-
 src/box/sql/parse_def.h               |  24 ++
 src/box/sql/select.c                  |  11 +-
 src/box/sql/sqlInt.h                  |  28 +-
 src/box/sql/tokenize.c                |   1 -
 src/box/sql/vdbeapi.c                 |   8 -
 test/app-tap/tarantoolctl.test.lua    |   4 +-
 test/box-py/bootstrap.result          |   7 +-
 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                 |   6 +-
 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                | 483 +++++++++++++++++++++++---
 test/sql/checks.test.lua              | 182 ++++++++--
 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 +-
 47 files changed, 2033 insertions(+), 483 deletions(-)
 create mode 100644 src/box/ck_constraint.c
 create mode 100644 src/box/ck_constraint.h

-- 
2.21.0

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2019-05-14 16:49 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox