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 DE639227B4 for ; Wed, 17 Jul 2019 05:54:54 -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 8edCOFKbKZCO for ; Wed, 17 Jul 2019 05:54:54 -0400 (EDT) Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [94.100.181.251]) (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 9BACA22CE9 for ; Wed, 17 Jul 2019 05:54:54 -0400 (EDT) From: imeevma@tarantool.org Subject: [tarantool-patches] [PATCH v4 1/4] sql: remove unnecessary AUTOINCREMENT ID generation Date: Wed, 17 Jul 2019 12:54:52 +0300 Message-Id: MIME-Version: 1.0 In-Reply-To: References: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit 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: korablev@tarantool.org Cc: tarantool-patches@freelists.org Hi! Thank you for review. My answer and new version below. On 7/15/19 8:50 PM, n.pettik wrote: > >>>> src/box/sql/insert.c | 5 +---- >>>> test/sql/gh-2981-check-autoinc.result | 32 ++++++++++++++++++++++++++++++++ >>>> test/sql/gh-2981-check-autoinc.test.lua | 11 ++++++++++- >>>> 3 files changed, 43 insertions(+), 5 deletions(-) >>>> >>>> diff --git a/src/box/sql/insert.c b/src/box/sql/insert.c >>>> index b353148..d2b4e17 100644 >>>> --- a/src/box/sql/insert.c >>>> +++ b/src/box/sql/insert.c >>>> @@ -628,10 +628,7 @@ sqlInsert(Parse * pParse, /* Parser context */ >>>> if (j < 0 || nColumn == 0 >>>> || (pColumn && j >= pColumn->nId)) { >>>> if (i == (int) autoinc_fieldno) { >>>> - sqlVdbeAddOp2(v, >>>> - OP_NextAutoincValue, >>>> - space->def->id, >>>> - iRegStore); >>> >>> Why didn’t you delete OP_NextAutioncValue? >>> >> I changed it functionality in the next patch. > > You changes affect more than 50% of opcode's content. > Please, to make patches well structured, remove opcode > in current patch and resurrect in the next one. > Removed the opcode. New patch: >From a82a75782cc536af3e1001674759a1476af7dee7 Mon Sep 17 00:00:00 2001 From: Mergen Imeev Date: Wed, 3 Jul 2019 14:05:11 +0300 Subject: [PATCH] sql: remove unnecessary AUTOINCREMENT ID generation Currently, if we perform something like CREATE TABLE t1 ( s1 INTEGER PRIMARY KEY AUTOINCREMENT, s2 INTEGER, CHECK (s1 <> 19) ); INSERT INTO t1 VALUES (18, NULL); INSERT INTO t1 (s2) VALUES (NULL); we generate a new identifier in VDBE, but in any other case we generate it in BOX. That was needed since the CHECK did not work properly. This is not necessary now, because CHECK was moved to BOX due to issue #3691. After this patch all new identifiers will be generated in BOX. Part of #4188 diff --git a/src/box/sql/insert.c b/src/box/sql/insert.c index b353148..d2b4e17 100644 --- a/src/box/sql/insert.c +++ b/src/box/sql/insert.c @@ -628,10 +628,7 @@ sqlInsert(Parse * pParse, /* Parser context */ if (j < 0 || nColumn == 0 || (pColumn && j >= pColumn->nId)) { if (i == (int) autoinc_fieldno) { - sqlVdbeAddOp2(v, - OP_NextAutoincValue, - space->def->id, - iRegStore); + sqlVdbeAddOp2(v, OP_Null, 0, iRegStore); continue; } struct Expr *dflt = NULL; diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c index 9f4ee7a..6bb7bc3 100644 --- a/src/box/sql/vdbe.c +++ b/src/box/sql/vdbe.c @@ -1149,34 +1149,6 @@ case OP_String: { /* out2 */ break; } -/* Opcode: NextAutoincValue P1 P2 * * * - * Synopsis: r[P2] = next value from space sequence, which pageno is r[P1] - * - * Get next value from space sequence, which pageno is written into register - * P1, write this value into register P2. If space doesn't exists (invalid - * space_id or something else), raise an error. If space with - * specified space_id doesn't have attached sequence, also raise an error. - */ -case OP_NextAutoincValue: { - assert(pOp->p1 > 0); - assert(pOp->p2 > 0); - - struct space *space = space_by_id(pOp->p1); - if (space == NULL) - goto abort_due_to_error; - - int64_t value; - struct sequence *sequence = space->sequence; - if (sequence == NULL || sequence_next(sequence, &value) != 0) - goto abort_due_to_error; - - pOut = out2Prerelease(p, pOp); - pOut->flags = MEM_Int; - pOut->u.i = value; - - break; -} - /* Opcode: Null P1 P2 P3 * * * Synopsis: r[P2..P3]=NULL *