From: imeevma@tarantool.org To: korablev@tarantool.org Cc: tarantool-patches@freelists.org Subject: [tarantool-patches] [PATCH v4 1/4] sql: remove unnecessary AUTOINCREMENT ID generation Date: Wed, 17 Jul 2019 12:54:52 +0300 [thread overview] Message-ID: <a82a75782cc536af3e1001674759a1476af7dee7.1563356272.git.imeevma@gmail.com> (raw) In-Reply-To: <cover.1563356272.git.imeevma@gmail.com> 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 <imeevma@gmail.com> 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 *
next prev parent reply other threads:[~2019-07-17 9:54 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-07-17 9:54 [tarantool-patches] [PATCH v4 0/4] sql: do not show IDs generated by trigger imeevma 2019-07-17 9:54 ` imeevma [this message] 2019-07-17 9:54 ` [tarantool-patches] [PATCH v4 2/4] sql: skip autoinc IDs generated inside SQL trigger imeevma 2019-07-17 16:58 ` [tarantool-patches] " n.pettik 2019-07-19 9:33 ` Mergen Imeev 2019-07-17 9:54 ` [tarantool-patches] [PATCH v4 3/4] sql: remove VDBE from TXN imeevma 2019-07-17 9:54 ` [tarantool-patches] [PATCH v4 4/4] sql: do not increase row-count if INSERT or REPLACE failed imeevma 2019-07-17 16:57 ` [tarantool-patches] " n.pettik 2019-07-17 18:08 ` [tarantool-patches] " Мерген Имеев 2019-07-19 9:36 ` Mergen Imeev 2019-07-22 10:48 ` n.pettik 2019-07-22 11:26 ` Mergen Imeev 2019-07-24 13:55 ` [tarantool-patches] Re: [PATCH v4 0/4] sql: do not show IDs generated by trigger 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=a82a75782cc536af3e1001674759a1476af7dee7.1563356272.git.imeevma@gmail.com \ --to=imeevma@tarantool.org \ --cc=korablev@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='Re: [tarantool-patches] [PATCH v4 1/4] sql: remove unnecessary AUTOINCREMENT ID generation' \ /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