From: Kirill Shcherbatov <kshcherbatov@tarantool.org> To: tarantool-patches@freelists.org, v.shpilevoy@tarantool.org Cc: Kirill Shcherbatov <kshcherbatov@tarantool.org> Subject: [tarantool-patches] [PATCH v1 1/6] box: rename space->opts checks to checks_ast Date: Thu, 29 Nov 2018 16:09:45 +0300 [thread overview] Message-ID: <443f2ecdc091b8e5f6729ecb7d7f81e31fd8f0e7.1543496928.git.kshcherbatov@tarantool.org> (raw) In-Reply-To: <cover.1543496928.git.kshcherbatov@tarantool.org> 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 029da029e..3e9b43a54 100644 --- a/src/box/alter.cc +++ b/src/box/alter.cc @@ -540,8 +540,8 @@ space_def_new_from_tuple(struct tuple *tuple, uint32_t errcode, space_def_new_xc(id, uid, exact_field_count, name, name_len, engine_name, engine_name_len, &opts, fields, field_count); - 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 69b92c5c1..585d29e1d 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; } @@ -283,7 +284,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 0d1e90233..a9a119e6d 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 7b41c9926..2b710fab6 100644 --- a/src/box/sql.c +++ b/src/box/sql.c @@ -1204,7 +1204,7 @@ sql_encode_table_opts(struct region *region, struct Table *table, struct ExprList_item *a; if (table != NULL) { 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 52f0bde15..7d32f3874 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); } @@ -863,15 +863,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 { @@ -947,7 +948,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 @@ -1610,8 +1611,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
next prev parent reply other threads:[~2018-11-29 13:10 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-11-29 13:09 [tarantool-patches] [PATCH v1 0/6] sql: Checks on server side Kirill Shcherbatov 2018-11-29 13:09 ` Kirill Shcherbatov [this message] 2018-11-29 13:09 ` [tarantool-patches] [PATCH v1 2/6] sql: disallow use of TYPEOF in Check Kirill Shcherbatov 2018-11-29 13:09 ` [tarantool-patches] [PATCH v1 3/6] box: exported sql_bind structure and API Kirill Shcherbatov 2018-11-29 13:09 ` [tarantool-patches] [PATCH v1 4/6] sql: release OP_Idx{Insert,Replace} p2 argument Kirill Shcherbatov 2018-11-29 13:09 ` [tarantool-patches] [PATCH v1 5/6] sql: fix incomplete UPDATE on IdxInsert failured Kirill Shcherbatov 2018-11-29 13:09 ` [tarantool-patches] [PATCH v1 6/6] sql: make sql checks on server side Kirill Shcherbatov 2018-11-29 14:09 ` [tarantool-patches] " Kirill Shcherbatov 2018-11-29 18:41 ` Kirill Shcherbatov
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=443f2ecdc091b8e5f6729ecb7d7f81e31fd8f0e7.1543496928.git.kshcherbatov@tarantool.org \ --to=kshcherbatov@tarantool.org \ --cc=tarantool-patches@freelists.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [tarantool-patches] [PATCH v1 1/6] box: rename space->opts checks to checks_ast' \ /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