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 5FAC3246E7 for ; Thu, 10 Jan 2019 08:54:55 -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 Psp5IAgttRqq for ; Thu, 10 Jan 2019 08:54:55 -0500 (EST) Received: from smtp55.i.mail.ru (smtp55.i.mail.ru [217.69.128.35]) (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 93CBF24588 for ; Thu, 10 Jan 2019 08:54:54 -0500 (EST) From: Kirill Shcherbatov Subject: [tarantool-patches] [PATCH v1 1/4] box: rename space->opts checks to checks_ast Date: Thu, 10 Jan 2019 16:54:47 +0300 Message-Id: <347e0f9e4c81bf76520c167a00f7af661b76aa64.1547128310.git.kshcherbatov@tarantool.org> In-Reply-To: References: 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 The checks field of space_opts object renamed to checks_ast to avoid a confusion due to introduction of a new object sql_check, representing precompiled VDBE program to execute. Need for #3691 --- src/box/alter.cc | 4 ++-- src/box/space_def.c | 15 ++++++++------- src/box/space_def.h | 4 ++-- src/box/sql.c | 2 +- src/box/sql/build.c | 17 +++++++++-------- 5 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/box/alter.cc b/src/box/alter.cc index 0589c9678..dcbb1ca66 100644 --- a/src/box/alter.cc +++ b/src/box/alter.cc @@ -532,8 +532,8 @@ space_def_new_from_tuple(struct tuple *tuple, uint32_t errcode, engine_name, engine_name_len, &opts, fields, field_count); auto def_guard = make_scoped_guard([=] { space_def_delete(def); }); - if (def->opts.checks != NULL && - sql_checks_resolve_space_def_reference(def->opts.checks, + if (def->opts.checks_ast != NULL && + sql_checks_resolve_space_def_reference(def->opts.checks_ast, def) != 0) { box_error_t *err = box_error_last(); if (box_error_code(err) != ENOMEM) { diff --git a/src/box/space_def.c b/src/box/space_def.c index 3516bdd8d..1ed9d4280 100644 --- a/src/box/space_def.c +++ b/src/box/space_def.c @@ -55,7 +55,7 @@ const struct space_opts space_opts_default = { /* .is_temporary = */ false, /* .view = */ false, /* .sql = */ NULL, - /* .checks = */ NULL, + /* .checks_ast = */ NULL, }; const struct opt_def space_opts_reg[] = { @@ -63,7 +63,7 @@ const struct opt_def space_opts_reg[] = { OPT_DEF("temporary", OPT_BOOL, struct space_opts, is_temporary), OPT_DEF("view", OPT_BOOL, struct space_opts, is_view), OPT_DEF("sql", OPT_STRPTR, struct space_opts, sql), - OPT_DEF_ARRAY("checks", struct space_opts, checks, + OPT_DEF_ARRAY("checks", struct space_opts, checks_ast, checks_array_decode), OPT_END, }; @@ -112,15 +112,16 @@ space_def_dup_opts(struct space_def *def, const struct space_opts *opts) return -1; } } - if (opts->checks != NULL) { - def->opts.checks = sql_expr_list_dup(sql_get(), opts->checks, 0); - if (def->opts.checks == NULL) { + if (opts->checks_ast != NULL) { + def->opts.checks_ast = + sql_expr_list_dup(sql_get(), opts->checks_ast, 0); + if (def->opts.checks_ast == NULL) { free(def->opts.sql); diag_set(OutOfMemory, 0, "sql_expr_list_dup", "def->opts.checks"); return -1; } - sql_checks_update_space_def_reference(def->opts.checks, def); + sql_checks_update_space_def_reference(def->opts.checks_ast, def); } return 0; } @@ -284,7 +285,7 @@ void space_opts_destroy(struct space_opts *opts) { free(opts->sql); - sql_expr_list_delete(sql_get(), opts->checks); + sql_expr_list_delete(sql_get(), opts->checks_ast); TRASH(opts); } diff --git a/src/box/space_def.h b/src/box/space_def.h index 8044f88fd..c23c578ff 100644 --- a/src/box/space_def.h +++ b/src/box/space_def.h @@ -66,8 +66,8 @@ struct space_opts { bool is_view; /** SQL statement that produced this space. */ char *sql; - /** SQL Checks expressions list. */ - struct ExprList *checks; + /** Checks AST expressions list. */ + struct ExprList *checks_ast; }; extern const struct space_opts space_opts_default; diff --git a/src/box/sql.c b/src/box/sql.c index 081a038f1..26b84c5db 100644 --- a/src/box/sql.c +++ b/src/box/sql.c @@ -1048,7 +1048,7 @@ sql_encode_table_opts(struct region *region, struct Table *table, int checks_cnt = 0; struct ExprList_item *a; bool is_view = table->def->opts.is_view; - struct ExprList *checks = table->def->opts.checks; + struct ExprList *checks = table->def->opts.checks_ast; if (checks != NULL) { checks_cnt = checks->nExpr; a = checks->a; diff --git a/src/box/sql/build.c b/src/box/sql/build.c index 49b90b5d0..7e5bcc518 100644 --- a/src/box/sql/build.c +++ b/src/box/sql/build.c @@ -276,7 +276,7 @@ table_delete(struct sqlite3 *db, struct Table *tab) for (uint32_t i = 0; i < tab->space->index_count; ++i) index_def_delete(tab->space->index[i]->def); /* Do not delete table->def allocated on region. */ - sql_expr_list_delete(db, tab->def->opts.checks); + sql_expr_list_delete(db, tab->def->opts.checks_ast); } else if (tab->def->id == 0) { space_def_delete(tab->def); } @@ -767,15 +767,16 @@ sql_add_check_constraint(struct Parse *parser, struct ExprSpan *span) (int)(span->zEnd - span->zStart)); if (expr->u.zToken == NULL) goto release_expr; - table->def->opts.checks = + table->def->opts.checks_ast = sql_expr_list_append(parser->db, - table->def->opts.checks, expr); - if (table->def->opts.checks == NULL) { + table->def->opts.checks_ast, expr); + if (table->def->opts.checks_ast == NULL) { sqlite3DbFree(parser->db, expr->u.zToken); goto release_expr; } if (parser->constraintName.n) { - sqlite3ExprListSetName(parser, table->def->opts.checks, + sqlite3ExprListSetName(parser, + table->def->opts.checks_ast, &parser->constraintName, 1); } } else { @@ -852,7 +853,7 @@ space_checks_expr_list(uint32_t space_id) space = space_by_id(space_id); assert(space != NULL); assert(space->def != NULL); - return space->def->opts.checks; + return space->def->opts.checks_ast; } int @@ -1375,8 +1376,8 @@ sqlite3EndTable(Parse * pParse, /* Parse context */ vdbe_emit_fkey_create(pParse, fk); } cleanup: - sql_expr_list_delete(db, p->def->opts.checks); - p->def->opts.checks = NULL; + sql_expr_list_delete(db, p->def->opts.checks_ast); + p->def->opts.checks_ast = NULL; } void -- 2.19.2