Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: "n.pettik" <korablev@tarantool.org>, tarantool-patches@freelists.org
Subject: [tarantool-patches] Re: [PATCH 05/10] sql: remove affinity string of columns from Index
Date: Sat, 25 Aug 2018 00:04:02 +0300	[thread overview]
Message-ID: <3612dd6f-bf08-9f2f-b5f4-8c597946cb6c@tarantool.org> (raw)
In-Reply-To: <AE32741A-A05A-471A-A177-20D5F1A2BBAC@tarantool.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;
  		}

  reply	other threads:[~2018-08-24 21:04 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-12 14:12 [tarantool-patches] [PATCH 00/10] sql: cleanup in struct Index and struct Table Nikita Pettik
2018-08-12 14:12 ` [tarantool-patches] [PATCH 01/10] sql: remove suport of ALTER TABLE ADD COLUMN Nikita Pettik
2018-08-13 20:24   ` [tarantool-patches] " Vladislav Shpilevoy
2018-08-12 14:12 ` [tarantool-patches] [PATCH 02/10] sql: remove string of fields collation from Table Nikita Pettik
2018-08-13 20:24   ` [tarantool-patches] " Vladislav Shpilevoy
2018-08-12 14:12 ` [tarantool-patches] [PATCH 03/10] sql: remove index hash from struct Table Nikita Pettik
2018-08-13 20:24   ` [tarantool-patches] " Vladislav Shpilevoy
2018-08-12 14:13 ` [tarantool-patches] [PATCH 04/10] sql: remove flags " Nikita Pettik
2018-08-13 20:24   ` [tarantool-patches] " Vladislav Shpilevoy
2018-08-12 14:13 ` [tarantool-patches] [PATCH 05/10] sql: remove affinity string of columns from Index Nikita Pettik
2018-08-13 20:24   ` [tarantool-patches] " Vladislav Shpilevoy
2018-08-21 16:31     ` n.pettik
2018-08-24 21:04       ` Vladislav Shpilevoy [this message]
2018-08-26 19:45         ` n.pettik
2018-08-12 14:13 ` [tarantool-patches] [PATCH 06/10] sql: completely remove support of partial indexes Nikita Pettik
2018-08-13 20:24   ` [tarantool-patches] " Vladislav Shpilevoy
2018-08-21 16:31     ` n.pettik
2018-08-24 21:04       ` Vladislav Shpilevoy
2018-08-26 19:44         ` n.pettik
2018-08-12 14:13 ` [tarantool-patches] [PATCH 07/10] sql: remove index type from struct Index Nikita Pettik
2018-08-13 20:24   ` [tarantool-patches] " Vladislav Shpilevoy
2018-08-21 16:31     ` n.pettik
2018-08-12 14:13 ` [tarantool-patches] [PATCH 08/10] sql: use secondary indexes to process OP_Delete Nikita Pettik
2018-08-13 20:24   ` [tarantool-patches] " Vladislav Shpilevoy
2018-08-12 14:13 ` [tarantool-patches] [PATCH 09/10] sql: disable ON CONFLICT actions for indexes Nikita Pettik
2018-08-13 20:24   ` [tarantool-patches] " Vladislav Shpilevoy
2018-08-21 16:31     ` n.pettik
2018-08-24 21:04       ` Vladislav Shpilevoy
2018-08-26 19:44         ` n.pettik
2018-08-27 17:24           ` Vladislav Shpilevoy
2018-08-12 14:13 ` [tarantool-patches] [PATCH 10/10] sql: move autoincrement field number to server Nikita Pettik
2018-08-13 20:24   ` [tarantool-patches] " Vladislav Shpilevoy
2018-08-21 16:31     ` n.pettik
2018-08-24 21:03       ` Vladislav Shpilevoy
2018-08-26 19:44         ` n.pettik
2018-08-27 17:24           ` Vladislav Shpilevoy
2018-08-27 17:24 ` [tarantool-patches] Re: [PATCH 00/10] sql: cleanup in struct Index and struct Table Vladislav Shpilevoy
2018-08-29 14:11 ` Kirill Yukhin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3612dd6f-bf08-9f2f-b5f4-8c597946cb6c@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=korablev@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH 05/10] sql: remove affinity string of columns from Index' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox