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 648F72AB1B for ; Fri, 24 Aug 2018 17:04:04 -0400 (EDT) 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 5iqS5CxT0OEF for ; Fri, 24 Aug 2018 17:04:04 -0400 (EDT) Received: from smtp32.i.mail.ru (smtp32.i.mail.ru [94.100.177.92]) (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 233682AB05 for ; Fri, 24 Aug 2018 17:04:04 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH 05/10] sql: remove affinity string of columns from Index References: <026cd8e04034ad26529a2b8e76e1ae9aabf9076f.1534001739.git.korablev@tarantool.org> <9ad38333-305b-7c55-a682-6b473d76e4f4@tarantool.org> From: Vladislav Shpilevoy Message-ID: <3612dd6f-bf08-9f2f-b5f4-8c597946cb6c@tarantool.org> Date: Sat, 25 Aug 2018 00:04:02 +0300 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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: "n.pettik" , tarantool-patches@freelists.org 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; }