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 54D1220E97 for ; Sun, 9 Dec 2018 16:30:45 -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 C3aAchl28hpL for ; Sun, 9 Dec 2018 16:30:45 -0500 (EST) Received: from smtp52.i.mail.ru (smtp52.i.mail.ru [94.100.177.112]) (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 11D1F20E90 for ; Sun, 9 Dec 2018 16:30:45 -0500 (EST) From: Nikita Pettik Subject: [tarantool-patches] [PATCH 6/6] Remove SQL string from index opts Date: Mon, 10 Dec 2018 00:30:26 +0300 Message-Id: <2574e71b463f1dcdc836c108a2e7d7e048a5d34b.1544387419.git.korablev@tarantool.org> In-Reply-To: References: In-Reply-To: References: 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 Cc: v.shpilevoy@tarantool.org, Nikita Pettik Closes #2647 --- src/box/alter.cc | 9 --------- src/box/index_def.c | 20 -------------------- src/box/index_def.h | 9 --------- src/box/sql/analyze.c | 3 +-- src/box/sql/where.c | 1 - 5 files changed, 1 insertion(+), 41 deletions(-) diff --git a/src/box/alter.cc b/src/box/alter.cc index 029da029e..c6ee025f2 100644 --- a/src/box/alter.cc +++ b/src/box/alter.cc @@ -187,15 +187,6 @@ index_opts_decode(struct index_opts *opts, const char *map, BOX_INDEX_FIELD_OPTS, "distance must be either "\ "'euclid' or 'manhattan'"); } - if (opts->sql != NULL) { - char *sql = strdup(opts->sql); - if (sql == NULL) { - opts->sql = NULL; - tnt_raise(OutOfMemory, strlen(opts->sql) + 1, "strdup", - "sql"); - } - opts->sql = sql; - } if (opts->range_size <= 0) { tnt_raise(ClientError, ER_WRONG_INDEX_OPTIONS, BOX_INDEX_FIELD_OPTS, diff --git a/src/box/index_def.c b/src/box/index_def.c index 45c74d9ec..2ba57ee9d 100644 --- a/src/box/index_def.c +++ b/src/box/index_def.c @@ -46,7 +46,6 @@ const struct index_opts index_opts_default = { /* .run_size_ratio = */ 3.5, /* .bloom_fpr = */ 0.05, /* .lsn = */ 0, - /* .sql = */ NULL, /* .stat = */ NULL, }; @@ -61,7 +60,6 @@ const struct opt_def index_opts_reg[] = { OPT_DEF("run_size_ratio", OPT_FLOAT, struct index_opts, run_size_ratio), OPT_DEF("bloom_fpr", OPT_FLOAT, struct index_opts, bloom_fpr), OPT_DEF("lsn", OPT_INT64, struct index_opts, lsn), - OPT_DEF("sql", OPT_STRPTR, struct index_opts, sql), OPT_END, }; @@ -109,15 +107,6 @@ index_def_new(uint32_t space_id, uint32_t iid, const char *name, def->space_id = space_id; def->iid = iid; def->opts = *opts; - if (opts->sql != NULL) { - def->opts.sql = strdup(opts->sql); - if (def->opts.sql == NULL) { - diag_set(OutOfMemory, strlen(opts->sql) + 1, "strdup", - "def->opts.sql"); - index_def_delete(def); - return NULL; - } - } /* Statistics are initialized separately. */ assert(opts->stat == NULL); return def; @@ -148,15 +137,6 @@ index_def_dup(const struct index_def *def) } rlist_create(&dup->link); dup->opts = def->opts; - if (def->opts.sql != NULL) { - dup->opts.sql = strdup(def->opts.sql); - if (dup->opts.sql == NULL) { - diag_set(OutOfMemory, strlen(def->opts.sql) + 1, - "strdup", "dup->opts.sql"); - index_def_delete(dup); - return NULL; - } - } if (def->opts.stat != NULL) { dup->opts.stat = index_stat_dup(def->opts.stat); if (dup->opts.stat == NULL) { diff --git a/src/box/index_def.h b/src/box/index_def.h index 273b8cb53..7717ecd64 100644 --- a/src/box/index_def.h +++ b/src/box/index_def.h @@ -157,10 +157,6 @@ struct index_opts { * LSN from the time of index creation. */ int64_t lsn; - /** - * SQL statement that produced this index. - */ - char *sql; /** * SQL specific statistics concerning tuples * distribution for query planer. It is automatically @@ -187,7 +183,6 @@ index_opts_create(struct index_opts *opts) static inline void index_opts_destroy(struct index_opts *opts) { - free(opts->sql); free(opts->stat); TRASH(opts); } @@ -212,10 +207,6 @@ index_opts_cmp(const struct index_opts *o1, const struct index_opts *o2) return o1->run_size_ratio < o2->run_size_ratio ? -1 : 1; if (o1->bloom_fpr != o2->bloom_fpr) return o1->bloom_fpr < o2->bloom_fpr ? -1 : 1; - if ((o1->sql == NULL) != (o2->sql == NULL)) - return 1; - if (o1->sql != NULL) - return strcmp(o1->sql, o2->sql); return 0; } diff --git a/src/box/sql/analyze.c b/src/box/sql/analyze.c index 8f8b6eb5d..51c63fa7a 100644 --- a/src/box/sql/analyze.c +++ b/src/box/sql/analyze.c @@ -1606,8 +1606,7 @@ index_field_tuple_est(const struct index_def *idx_def, uint32_t field) { assert(idx_def != NULL); struct space *space = space_by_id(idx_def->space_id); - if (space == NULL || (idx_def->opts.sql != NULL && - strcmp(idx_def->opts.sql, "fake_autoindex") == 0)) + if (space == NULL || strcmp(idx_def->name, "fake_autoindex") == 0) return idx_def->opts.stat->tuple_log_est[field]; assert(field <= idx_def->key_def->part_count); /* Statistics is held only in real indexes. */ diff --git a/src/box/sql/where.c b/src/box/sql/where.c index 9c3462bc0..571b5af78 100644 --- a/src/box/sql/where.c +++ b/src/box/sql/where.c @@ -2818,7 +2818,6 @@ tnt_error: struct index_opts opts; index_opts_create(&opts); - opts.sql = "fake_autoindex"; fake_index = index_def_new(pTab->def->id, 0,"fake_autoindex", sizeof("fake_autoindex") - 1, TREE, &opts, key_def, NULL); -- 2.15.1