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 6D59E20065 for ; Mon, 23 Jul 2018 12:54:01 -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 rAAk6XxOfI7J for ; Mon, 23 Jul 2018 12:54:01 -0400 (EDT) Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (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 26CFB1FFD1 for ; Mon, 23 Jul 2018 12:54:01 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH v1 1/3] sql: restrict nullable action definitions References: <33314a00ce2e0602e0a0fa7e30257ff03e3eed16.1531932662.git.kshcherbatov@tarantool.org> <51802451-C9AA-4EB8-8926-D08446738FF1@tarantool.org> <972c8144-0f4c-c882-3ab9-4a50cbaf43c6@tarantool.org> <185A42F6-2824-47BE-A521-147C8D22F944@tarantool.org> <3ede21f4-dde1-4853-b08c-f3c7f076021b@tarantool.org> From: Kirill Shcherbatov Message-ID: Date: Mon, 23 Jul 2018 19:53:55 +0300 MIME-Version: 1.0 In-Reply-To: <3ede21f4-dde1-4853-b08c-f3c7f076021b@tarantool.org> Content-Type: text/plain; charset=utf-8 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: tarantool-patches@freelists.org, Nikita Pettik After verbal discussion, I've made small fix and merged "[draft] don't use on_conflict_default_MAX". Don't forget that this patch is now on Kirill's iPkey patch and should be merged to upstream later. On 23.07.2018 11:31, Kirill Shcherbatov wrote: > Hi again! > I've rebased my patch on Kirill's Y. branch kyukhin/gh-3482-remove-ipkey; > I've also have succeed in using ON_CONFLICT_ACTION_DEFAULT instead of on_conflict_action_MAX. > This changes represented as "[draft] don't use on_conflict_default_MAX" commit on my branch. > I've have had to introduce small rule index_onconf that looks very similar with onconf. If I not mistaken, > you are going to get rid of Index on_conflict action; and this rudiment crap would disappear. ============================================= diff --git a/src/box/sql/build.c b/src/box/sql/build.c index ba80d1d..ec0c06b 100644 --- a/src/box/sql/build.c +++ b/src/box/sql/build.c @@ -950,7 +950,7 @@ sqlite3AddPrimaryKey(Parse * pParse, /* Parsing context */ sqlite3ExprAlloc(db, TK_ID, &token, 0)); if (list == NULL) - return; + goto primary_key_exit; sql_create_index(pParse, 0, 0, list, onError, 0, 0, SORT_ORDER_ASC, false, SQL_INDEX_TYPE_CONSTRAINT_PK); @@ -959,21 +959,23 @@ sqlite3AddPrimaryKey(Parse * pParse, /* Parsing context */ } else if (autoInc) { sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an " "INTEGER PRIMARY KEY or INT PRIMARY KEY"); + goto primary_key_exit; } else { sql_create_index(pParse, 0, 0, pList, onError, 0, 0, sortOrder, false, SQL_INDEX_TYPE_CONSTRAINT_PK); pList = 0; + if (pParse->nErr > 0) + goto primary_key_exit; } struct Index *pk = sqlite3PrimaryKeyIndex(pTab); - if (pk != NULL) { - struct key_def *pk_key_def = pk->def->key_def; - for (uint32_t i = 0; i < pk_key_def->part_count; i++) { - uint32_t idx = pk_key_def->parts[i].fieldno; - field_def_create_for_pk(pParse, &pTab->def->fields[idx], - pTab->def->name); - } + assert(pk != NULL); + struct key_def *pk_key_def = pk->def->key_def; + for (uint32_t i = 0; i < pk_key_def->part_count; i++) { + uint32_t idx = pk_key_def->parts[i].fieldno; + field_def_create_for_pk(pParse, &pTab->def->fields[idx], + pTab->def->name); } primary_key_exit: sql_expr_list_delete(pParse->db, pList);