[tarantool-patches] Re: [PATCH] sql: add index_def to struct Index
Kirill Yukhin
kyukhin at tarantool.org
Tue May 22 19:30:19 MSK 2018
On 22 мая 19:03, Ivan Koptelov wrote:
> Currently there is a problem with
> non-deterministic nullability in
> index_def. To see the error just
> uncomment printfs on build.c 2999
> and run any sql-tap test that
> has to do with indexes, e.g
> distinct.test.lua.
> github branch: https://github.com/tarantool/tarantool/tree/sb/gh-3369-use-index-def-in-select-and-where
> ---
> src/box/sql/build.c | 179 +++++++++++++++++++++++++++++++++++++++++++++++-
> src/box/sql/sqliteInt.h | 2 +
> 2 files changed, 179 insertions(+), 2 deletions(-)
>
> diff --git a/src/box/sql/build.c b/src/box/sql/build.c
> index 742f8a572..6bd70fa9f 100644
> --- a/src/box/sql/build.c
> +++ b/src/box/sql/build.c
> @@ -43,6 +43,7 @@
> * COMMIT
> * ROLLBACK
> */
> +#include <ctype.h>
> #include "sqliteInt.h"
> #include "vdbeInt.h"
> #include "tarantoolInt.h"
> @@ -2841,9 +2842,173 @@ index_is_unique(Index *idx)
> return tnt_index->def->opts.is_unique;
> }
>
> +/*
> + * In CREATE INDEX requests user may set binary collation with COLLATE
> + * [BINARY, binary, "binary" and "bInarY"] This function is to handle all
> + * these cases.
> + */
> +bool is_binary_collation(const char *coll_name)
> +{
> + char *upper_case_name =
> + malloc(sizeof(*coll_name) * strlen(coll_name));
> + for (int i = 0; i < (int) strlen(coll_name); i++) {
> + upper_case_name[i] = toupper(coll_name[i]);
> + }
> +
> + bool res = (strcmp(upper_case_name, "BINARY") == 0);
> + free(upper_case_name);
> + return res;
> +}
> +
> +//bool is_index_equal(Index * old, struct index_def *new)
> +//{
> +// assert(strcmp(old->zName, new->name);
> +// return true;
> +//}
Junk.
> +
> +// part_def_tmp[i].is_nullable =
> +// (fieldno < space_def->field_count ?
> +// space_def->fields[fieldno].is_nullable :
> +// false);
Junk.
> @@ -3283,8 +3455,11 @@ sqlite3CreateIndex(Parse * pParse, /* All information about this parse */
>
> /* Clean up before exiting */
> exit_create_index:
> - if (pIndex)
> + if (pIndex) {
> + if (pIndex->def)
!= NULL.
> + index_def_delete(pIndex->def);
> freeIndex(db, pIndex);
> + }
> sql_expr_free(db, pPIWhere, false);
> sqlite3ExprListDelete(db, pList);
> sqlite3SrcListDelete(db, pTblName);
More information about the Tarantool-patches
mailing list