[tarantool-patches] Re: [PATCH 05/10] sql: remove affinity string of columns from Index
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Sat Aug 25 00:04:02 MSK 2018
Hi! Thanks for the fixes!
Please, next time attach new diff at the
end of a message. Now I did it below.
See 1 comment and a commit on the branch.
> diff --git a/src/box/sql/insert.c b/src/box/sql/insert.c
> index a8423fe95..f27484344 100644
> --- a/src/box/sql/insert.c
> +++ b/src/box/sql/insert.c
> char *
> -sql_index_affinity_str(struct sqlite3 *db, struct index_def *def)
> +sql_space_index_affinity_str(struct sqlite3 *db, struct space_def *space_def,
> + struct index_def *idx_def)
> {
> - uint32_t column_count = def->key_def->part_count;
> + uint32_t column_count = idx_def->key_def->part_count;
> char *aff = (char *)sqlite3DbMallocRaw(db, column_count + 1);
> if (aff == NULL)
> return NULL;
> - struct space *space = space_by_id(def->space_id);
> - assert(space != NULL);
> -
> - for (uint32_t i = 0; i < column_count; i++) {
> - uint32_t x = def->key_def->parts[i].fieldno;
> - aff[i] = space->def->fields[x].affinity;
> - if (aff[i] == AFFINITY_UNDEFINED)
> - aff[i] = 'A';
> + /*
> + * Table may occasionally come from Lua, so lets
Alternatively it could be IProto instead of SQL. Lets
just write 'non-SQL'.
> + * gentle process this case by setting default
> + * affinity for it.
> + */
> + if (space_def->fields == NULL) {
> + memset(aff, AFFINITY_BLOB, column_count);
> + } else {
> + for (uint32_t i = 0; i < column_count; i++) {
> + uint32_t x = idx_def->key_def->parts[i].fieldno;
> + aff[i] = space_def->fields[x].affinity;
> + if (aff[i] == AFFINITY_UNDEFINED)
> + aff[i] = AFFINITY_BLOB;
> + }
> }
> aff[column_count] = '\0';
> -
> return aff;
> }
>
My diff is below:
diff --git a/src/box/sql/insert.c b/src/box/sql/insert.c
index f27484344..ad9302464 100644
--- a/src/box/sql/insert.c
+++ b/src/box/sql/insert.c
@@ -67,16 +67,16 @@ sql_space_index_affinity_str(struct sqlite3 *db, struct space_def *space_def,
if (aff == NULL)
return NULL;
/*
- * Table may occasionally come from Lua, so lets
- * gentle process this case by setting default
- * affinity for it.
+ * Table may occasionally come from non-SQL API, so lets
+ * gentle process this case by setting default affinity
+ * for it.
*/
if (space_def->fields == NULL) {
memset(aff, AFFINITY_BLOB, column_count);
} else {
for (uint32_t i = 0; i < column_count; i++) {
- uint32_t x = idx_def->key_def->parts[i].fieldno;
- aff[i] = space_def->fields[x].affinity;
+ aff[i] = sql_space_index_part_affinity(space_def,
+ idx_def, i);
if (aff[i] == AFFINITY_UNDEFINED)
aff[i] = AFFINITY_BLOB;
}
More information about the Tarantool-patches
mailing list