[tarantool-patches] [PATCH 6/6] Remove SQL string from index opts
Nikita Pettik
korablev at tarantool.org
Mon Dec 10 00:30:26 MSK 2018
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
More information about the Tarantool-patches
mailing list