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 5ED1D29B27 for ; Sun, 26 Aug 2018 15:44:44 -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 s1OReH5QgRU9 for ; Sun, 26 Aug 2018 15:44:44 -0400 (EDT) Received: from smtp17.mail.ru (smtp17.mail.ru [94.100.176.154]) (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 1D9DB29AEF for ; Sun, 26 Aug 2018 15:44:44 -0400 (EDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: [tarantool-patches] Re: [PATCH 09/10] sql: disable ON CONFLICT actions for indexes From: "n.pettik" In-Reply-To: Date: Sun, 26 Aug 2018 22:44:42 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <9C5A6A50-CB06-489D-A708-28DC346EA013@tarantool.org> References: <75ebea5a7bc472e83a844cc98fc6fb88369e4b10.1534001739.git.korablev@tarantool.org> <317b019c-61ad-83f4-5a47-3818e90fa4a8@tarantool.org> 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 Cc: Vladislav Shpilevoy >> diff --git a/src/box/sql/insert.c b/src/box/sql/insert.c >> index 33d243414..9da971415 100644 >> --- a/src/box/sql/insert.c >> +++ b/src/box/sql/insert.c >> @@ -354,11 +351,14 @@ sqlite3Insert(Parse * pParse, /* Parser = context */ >> } >> #endif /* SQLITE_OMIT_XFER_OPT */ >> - /* Allocate registers for holding the tupleid of the new row, >> - * the content of the new row, and the assembled row record. >> + /* >> + * Allocate registers for holding the tupleid of the new >> + * row (if it isn't required first register will contain >> + * NULL), the content of the new row, and the assembled >> + * row record. >> */ >> regTupleid =3D regIns =3D pParse->nMem + 1; >> - pParse->nMem +=3D def->field_count + 1; >> + pParse->nMem +=3D def->field_count + 2; >=20 > Why +2? My presumption is because nMem was not > incremented one line above here 'regTupleid =3D regIns =3D = pParse->nMem + 1;', > am I right? Why did it work before? As comments says: field_count for raw data to be encoded into tuple, one memory cell for encoded tuple, and the last one for rowid (or = tupleid): it is used for ephemeral spaces to distinguish entries. If it is not = required, then mem will contain NULL. Tuple id (regTupleId) comes first, then raw tuple and in the end - encoded msgpack. >=20 > Then could you do it slightly more clear, like this? >=20 > regTupleid =3D regIns =3D ++pParse->nMem; > pParse->nMem +=3D def->field_count + 1; As you wish. Simply applied your code: +++ b/src/box/sql/insert.c @@ -357,8 +357,8 @@ sqlite3Insert(Parse * pParse, /* Parser = context */ * NULL), the content of the new row, and the assembled * row record. */ - regTupleid =3D regIns =3D pParse->nMem + 1; - pParse->nMem +=3D def->field_count + 2; + regTupleid =3D regIns =3D ++pParse->nMem; + pParse->nMem +=3D def->field_count + 1=