From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> To: Kirill Shcherbatov <kshcherbatov@tarantool.org>, tarantool-patches@freelists.org Subject: [tarantool-patches] Re: [PATCH v4 3/4] box: introduce column_mask for ck constraint Date: Sun, 19 May 2019 19:02:10 +0300 [thread overview] Message-ID: <148cfacb-757b-0c4a-7b7d-efaa18c6ffac@tarantool.org> (raw) In-Reply-To: <16fabe763ee57c8cd5c807b24d0fc500ad5a8bae.1558014727.git.kshcherbatov@tarantool.org> Thanks for the patch! See 3 comments below. On 16/05/2019 16:56, Kirill Shcherbatov wrote: > This patch introduces a smart bitmask of fields are mentioned in 1. Remove 'are'. 'mentioned' here works as adjective. The same in other places. Please, find them by yourself. > ck constraint. This allows to do not bind useless fields and > do not parse more fields that is required. > > Needed for #3691 > --- > src/box/ck_constraint.c | 66 ++++++++++++++++++++++++++++++++++------ > src/box/ck_constraint.h | 6 ++++ > src/box/sql.h | 5 ++- > src/box/sql/build.c | 2 +- > src/box/sql/resolve.c | 19 +++++++++--- > src/box/sql/sqlInt.h | 6 ++++ > test/sql/checks.result | 59 +++++++++++++++++++++++++++++++++++ > test/sql/checks.test.lua | 20 ++++++++++++ > 8 files changed, 167 insertions(+), 16 deletions(-) > > diff --git a/src/box/ck_constraint.c b/src/box/ck_constraint.c > index 43798be76..4756f7970 100644 > --- a/src/box/ck_constraint.c > +++ b/src/box/ck_constraint.c > @@ -46,17 +46,21 @@ const char *ck_constraint_language_strs[] = {"SQL"}; > * tree traversal. > * @param ck_constraint Check constraint object to update. > * @param space_def Space definition to use. > + * @param column_mask[out] The "smart" column mask of fields are > + * referenced by AST. > * @retval 0 on success. > * @retval -1 on error. > */ > static int > ck_constraint_resolve_field_names(struct Expr *expr, > - struct space_def *space_def) > + struct space_def *space_def, > + uint64_t *column_mask) > { > struct Parse parser; > sql_parser_create(&parser, sql_get(), default_flags); > parser.parse_only = true; > - sql_resolve_self_reference(&parser, space_def, NC_IsCheck, expr, NULL); > + sql_resolve_self_reference(&parser, space_def, NC_IsCheck, expr, NULL, > + column_mask); 2. Next to last argument 'expr_list' is always NULL. Please, drop it. > int rc = parser.is_aborted ? -1 : 0; > sql_parser_destroy(&parser); > return rc; > @@ -98,10 +105,24 @@ ck_constraint_program_compile(struct ck_constraint_def *ck_constraint_def, > * bind tuple fields there before execution. > */ > uint32_t field_count = space_def->field_count; > + /* > + * Use column mask to prepare binding only for > + * referenced fields. > + */ > int bind_tuple_reg = sqlGetTempRange(&parser, field_count); > - for (uint32_t i = 0; i < field_count; i++) { > + struct bit_iterator it; > + bit_iterator_init(&it, &column_mask, sizeof(uint64_t), true); > + size_t used_fieldno = bit_iterator_next(&it); > + for (; used_fieldno < SIZE_MAX; used_fieldno = bit_iterator_next(&it)) { > sqlVdbeAddOp2(v, OP_Variable, ++parser.nVar, > - bind_tuple_reg + i); > + bind_tuple_reg + used_fieldno); > + } > + if (column_mask_fieldno_is_set(column_mask, 63)) { 3. Please, do not hardcode that value. Add a one-line function to column_mask.h for that. On other places too. > + used_fieldno = 64; > + for (; used_fieldno < (size_t)field_count; used_fieldno++) { > + sqlVdbeAddOp2(v, OP_Variable, ++parser.nVar, > + bind_tuple_reg + used_fieldno); > + } > } > /* Generate ck constraint test code. */ > vdbe_emit_ck_constraint(&parser, expr, ck_constraint_def->name,
next prev parent reply other threads:[~2019-05-19 16:02 UTC|newest] Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-05-16 13:56 [tarantool-patches] [PATCH v4 0/4] box: run checks on insertions in LUA spaces Kirill Shcherbatov 2019-05-16 13:56 ` [tarantool-patches] [PATCH v4 1/4] schema: add new system space for CHECK constraints Kirill Shcherbatov 2019-05-19 16:01 ` [tarantool-patches] " Vladislav Shpilevoy 2019-05-23 10:32 ` Kirill Shcherbatov 2019-05-26 12:03 ` Vladislav Shpilevoy 2019-05-31 13:45 ` Kirill Shcherbatov 2019-05-16 13:56 ` [tarantool-patches] [PATCH v4 2/4] box: run check constraint tests on space alter Kirill Shcherbatov 2019-05-19 16:02 ` [tarantool-patches] " Vladislav Shpilevoy 2019-05-23 10:37 ` Kirill Shcherbatov 2019-05-16 13:56 ` [tarantool-patches] [PATCH v4 3/4] box: introduce column_mask for ck constraint Kirill Shcherbatov 2019-05-19 16:02 ` Vladislav Shpilevoy [this message] 2019-05-23 10:38 ` [tarantool-patches] " Kirill Shcherbatov 2019-05-26 12:03 ` Vladislav Shpilevoy 2019-05-31 13:45 ` Kirill Shcherbatov 2019-05-16 13:56 ` [tarantool-patches] [PATCH v4 4/4] box: user-friendly interface to manage ck constraints Kirill Shcherbatov 2019-05-19 16:02 ` [tarantool-patches] " Vladislav Shpilevoy 2019-05-23 10:41 ` Kirill Shcherbatov 2019-05-26 12:04 ` Vladislav Shpilevoy 2019-05-31 13:45 ` Kirill Shcherbatov 2019-06-03 21:15 ` Vladislav Shpilevoy
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=148cfacb-757b-0c4a-7b7d-efaa18c6ffac@tarantool.org \ --to=v.shpilevoy@tarantool.org \ --cc=kshcherbatov@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='[tarantool-patches] Re: [PATCH v4 3/4] box: introduce column_mask for ck constraint' \ /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