Tarantool development patches archive
 help / color / mirror / Atom feed
From: Kirill Shcherbatov <kshcherbatov@tarantool.org>
To: tarantool-patches@freelists.org, korablev@tarantool.org
Cc: Kirill Shcherbatov <kshcherbatov@tarantool.org>
Subject: [tarantool-patches] [PATCH v1 1/4] box: rename space->opts checks to checks_ast
Date: Thu, 10 Jan 2019 16:54:47 +0300	[thread overview]
Message-ID: <347e0f9e4c81bf76520c167a00f7af661b76aa64.1547128310.git.kshcherbatov@tarantool.org> (raw)
In-Reply-To: <cover.1547128310.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 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

  reply	other threads:[~2019-01-10 13:54 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-10 13:54 [tarantool-patches] [PATCH v1 0/4] sql: Checks on server side Kirill Shcherbatov
2019-01-10 13:54 ` Kirill Shcherbatov [this message]
2019-01-11 14:05   ` [tarantool-patches] Re: [PATCH v1 1/4] box: rename space->opts checks to checks_ast Konstantin Osipov
2019-01-18 18:00   ` Konstantin Osipov
2019-01-10 13:54 ` [tarantool-patches] [PATCH v1 2/4] sql: disallow use of TYPEOF in Check Kirill Shcherbatov
2019-01-11 14:06   ` [tarantool-patches] " Konstantin Osipov
2019-01-11 14:07   ` Konstantin Osipov
2019-01-18 18:04   ` Konstantin Osipov
2019-01-10 13:54 ` [tarantool-patches] [PATCH v1 3/4] box: exported sql_bind structure and API Kirill Shcherbatov
2019-01-10 13:54 ` [tarantool-patches] [PATCH v1 4/4] sql: make sql checks on server side Kirill Shcherbatov
2019-01-11 14:12   ` [tarantool-patches] " Konstantin Osipov
2019-01-11 14:14   ` Konstantin Osipov
2019-01-18 18:11   ` Konstantin Osipov
2019-01-21 14:47   ` n.pettik

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=347e0f9e4c81bf76520c167a00f7af661b76aa64.1547128310.git.kshcherbatov@tarantool.org \
    --to=kshcherbatov@tarantool.org \
    --cc=korablev@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [tarantool-patches] [PATCH v1 1/4] 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