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: Mon, 27 Aug 2018 14:24:25 -0300	[thread overview]
Message-ID: <a4448924-e7e2-d105-716b-751cf70e201f@tarantool.org> (raw)
In-Reply-To: <63833016-A944-4856-ADDB-DAB672BC887B@tarantool.org>


> @@ -965,7 +965,7 @@ vdbe_emit_constraint_checks(struct Parse *parse_context, struct Table *tab,
>          if (part_count == 1) {
>                  uint32_t fieldno = pk->def->key_def->parts[0].fieldno;
>                  int reg_pk = new_tuple_reg + fieldno;
> -               if (tab->def->fields[fieldno].affinity == AFFINITY_INTEGER) {
> +               if (def->fields[fieldno].affinity == AFFINITY_INTEGER) {
>                          int skip_if_null = sqlite3VdbeMakeLabel(v);
>                          if (autoinc_fieldno != UINT32_MAX) {
>                                  sqlite3VdbeAddOp2(v, OP_IsNull, reg_pk,
> 
> Your initial diff led to assertion fault since def->fields[i].nullable_action and
> tab->def->fields[i].nullable_action had different values - DEFAULT and NONE respectively.
> So I just replaced all usages of tab->def->… to simply def->…
> Why they had different nullable actions? _sql_stat4 is created from Lua and has no specified
> is_nullable property, so nullable action is set to DEFAULT:
> 
> alter.cc (373 lie)
> 
> if (is_action_missing) {
>         field->nullable_action = field->is_nullable ?
>                ON_CONFLICT_ACTION_NONE
>                : ON_CONFLICT_ACTION_DEFAULT;
> }
> 
> For SQL-land tables nullable action is never set to DEFAULT:
> it is either ABORT or NONE.  In fact, DEFAULT makes no sense,
> so it is always substituted with ABORT (field_def_create_for_pk() in build.c).
> Hence, I guess setting default nullable action to DEFAULT in alter.cc seems
> to be messy and should be changed to ABORT. DEFAULT is really helpful
> for statement action (e.g. INSERT OR REPLACE): in this case it allows to
> tell INSERT OR ABORT (ABORT action) from simple INSERT (DEFAULT action).
> Do you agree with me?
> 
> Btw now I see in trunk commit:
> https://github.com/tarantool/tarantool/commit/db37dd2d663e23d55fe2caecbf911e822e9182d4
> 
> IMHO it makes things even worse...

Thanks for the debugging for me! Sure, DEFAULT from Lua is bad idea as we
can see in this particular example. I believe, DEFAULT should never be set
from non-SQL DDL. If a field is set to is_nullable false, it is false always,
not default. So the commit db37dd2d663e23d55fe2caecbf911e822e9182d4 is wrong,
I think. Unfortunately, it was pushed without a review, as I see.

  reply	other threads:[~2018-08-27 17:24 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
2018-08-26 19:44         ` n.pettik
2018-08-27 17:24           ` Vladislav Shpilevoy [this message]
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=a4448924-e7e2-d105-716b-751cf70e201f@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