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 10/10] sql: move autoincrement field number to server
Date: Sat, 25 Aug 2018 00:03:57 +0300	[thread overview]
Message-ID: <dd774b4e-5450-d0be-41f7-4678c6837276@tarantool.org> (raw)
In-Reply-To: <685EC40E-4A7E-4A5A-8BAD-A597ADC67E67@tarantool.org>

Thanks for the patch!

On 21/08/2018 19:31, n.pettik wrote:
> 
>> On 13 Aug 2018, at 23:24, Vladislav Shpilevoy <v.shpilevoy@tarantool.org> wrote:
>>
>> Are you sure it is the only way to pass autoinc fieldno? And that it can
>> not be dropped and calculated from other fields without significant problems?
>>
>> Now this flag looks very ugly inside _space tuples.
>>
>> I think, autoinc is rather primary index option than the space, and that it
>> can be detected via checking
>>
>>     pk->part_count == 1 and space->sequence != NULL
>>
>> then pk->parts[0].fieldno is autoinc field. It is not?
> 
> Okay, it seems to be possible. Check this out:
> 
>      sql: remove autoincrement field number from Table
>      
>      During INSERT SQL statement execution we may need to know field which
>      stores INTEGER AUTOINCREMENT PRIMARY KEY. Since we are going to get rid
>      of struct Table, lets remove this member from struct Table. Instead, it
>      can be calculated using struct space: if PK consists from one part and
>      sequence not NULL - table features autoincrement.
>      
>      Part of #3561
> 

I have done some review fixes, but the patch crashes with them,
and I do not understand why. Could you please investigate?

Assertion is 100% repeatable on analyze9.test:
Assertion failed: (0), function vdbe_emit_constraint_checks, file /Users/v.shpilevoy/Work/Repositories/tarantool/src/box/sql/insert.c, line 916.

Right after test case 4.9.

The diff:

===================================================

diff --git a/src/box/sql/insert.c b/src/box/sql/insert.c
index 56ddb10eb..4cc33e830 100644
--- a/src/box/sql/insert.c
+++ b/src/box/sql/insert.c
@@ -858,12 +858,12 @@ vdbe_emit_constraint_checks(struct Parse *parse_context, struct Table *tab,
  	struct sqlite3 *db = parse_context->db;
  	struct Vdbe *v = sqlite3GetVdbe(parse_context);
  	assert(v != NULL);
-	struct space_def *def = tab->def;
-	/* Insertion into VIEW is prohibited. */
-	assert(!def->opts.is_view);
  	bool is_update = upd_cols != NULL;
  	struct space *space = space_by_id(tab->def->id);
  	assert(space != NULL);
+	struct space_def *def = space->def;
+	/* Insertion into VIEW is prohibited. */
+	assert(!def->opts.is_view);
  	uint32_t autoinc_fieldno = sql_space_autoinc_fieldno(space);
  	/* Test all NOT NULL constraints. */
  	for (uint32_t i = 0; i < def->field_count; i++) {
@@ -882,7 +882,7 @@ vdbe_emit_constraint_checks(struct Parse *parse_context, struct Table *tab,
  		/* ABORT is a default error action. */
  		if (on_conflict_nullable == ON_CONFLICT_ACTION_DEFAULT)
  			on_conflict_nullable = ON_CONFLICT_ACTION_ABORT;
-		struct Expr *dflt = space_column_default_expr(tab->def->id, i);
+		struct Expr *dflt = def->fields[i].default_value_expr;
  		if (on_conflict_nullable == ON_CONFLICT_ACTION_REPLACE &&
  		    dflt == NULL)
  			on_conflict_nullable = ON_CONFLICT_ACTION_ABORT;
@@ -923,7 +923,7 @@ vdbe_emit_constraint_checks(struct Parse *parse_context, struct Table *tab,
  	if (on_conflict == ON_CONFLICT_ACTION_DEFAULT)
  		on_conflict = ON_CONFLICT_ACTION_ABORT;
  	/* Test all CHECK constraints. */
-	struct ExprList *checks = space_checks_expr_list(tab->def->id);
+	struct ExprList *checks = def->opts.checks;
  	enum on_conflict_action on_conflict_check = on_conflict;
  	if (on_conflict == ON_CONFLICT_ACTION_REPLACE)
  		on_conflict_check = ON_CONFLICT_ACTION_ABORT;

  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
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 [this message]
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=dd774b4e-5450-d0be-41f7-4678c6837276@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=korablev@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH 10/10] sql: move autoincrement field number to server' \
    /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