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 F419929D37 for ; Mon, 27 Aug 2018 13:24:39 -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 e54ZlzdLiNGB for ; Mon, 27 Aug 2018 13:24:39 -0400 (EDT) Received: from smtp59.i.mail.ru (smtp59.i.mail.ru [217.69.128.39]) (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 AF1EC29CEE for ; Mon, 27 Aug 2018 13:24:39 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH 09/10] sql: disable ON CONFLICT actions for indexes References: <75ebea5a7bc472e83a844cc98fc6fb88369e4b10.1534001739.git.korablev@tarantool.org> <317b019c-61ad-83f4-5a47-3818e90fa4a8@tarantool.org> <9C5A6A50-CB06-489D-A708-28DC346EA013@tarantool.org> From: Vladislav Shpilevoy Message-ID: <37357d61-cd5a-75ef-02e4-96b47467064e@tarantool.org> Date: Mon, 27 Aug 2018 14:24:35 -0300 MIME-Version: 1.0 In-Reply-To: <9C5A6A50-CB06-489D-A708-28DC346EA013@tarantool.org> Content-Type: text/plain; charset=utf-8; format=flowed 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: "n.pettik" , tarantool-patches@freelists.org On 26/08/2018 16:44, n.pettik wrote: > >>> 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 = regIns = pParse->nMem + 1; >>> - pParse->nMem += def->field_count + 1; >>> + pParse->nMem += def->field_count + 2; >> >> Why +2? My presumption is because nMem was not >> incremented one line above here 'regTupleid = regIns = 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. Thanks for the explanation. I understand the comment. But I do not understand why nMem is changed to +1 in comparison with the previous version. Your comment is actually the same as it was, but nMem is increased. The comment is this in short: "Allocate registers for holding the tupleid, content, assembled record.". Both before and after your patch. But nMem is now +1.