From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id C2CE96ECC0; Tue, 14 Dec 2021 00:48:47 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C2CE96ECC0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1639432127; bh=v6ZilTbLwuqbEiqDPYTtAG7/qsbu00nK6LRpuQjVx9M=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=qKi5NXhw9wNFjTyZNuKgaNLCi7ixt8C9kZ0BwSktx17ngAJjVamUGtpcel6Pd+5Pk RFm2VB7y8nR9XvklplQglYJEOsDl4gwj6PE+rAjf5LJaV+ZRYZET2i8KfFHGl8SSXf CQ9s0MPnljILUDKZkMOm4a5IZEzzDyFhuO62x9IU= Received: from smtpng3.i.mail.ru (smtpng3.i.mail.ru [94.100.177.149]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id AA7846ECC0 for ; Tue, 14 Dec 2021 00:48:46 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org AA7846ECC0 Received: by smtpng3.m.smailru.net with esmtpa (envelope-from ) id 1mwtBe-0001ca-2p; Tue, 14 Dec 2021 00:48:46 +0300 Message-ID: Date: Mon, 13 Dec 2021 22:48:45 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Content-Language: en-US To: Mergen Imeev Cc: tarantool-patches@dev.tarantool.org References: <4ecfb3439688bef76c96270624410dee8822176f.1637244389.git.imeevma@gmail.com> <662f6b87-f085-ab10-53b8-d087d9598b19@tarantool.org> <20211125085529.GB56448@tarantool.org> <20211202083851.GB8207@tarantool.org> <9b75890d-32e4-aaa9-c377-01854278bc76@tarantool.org> <20211213074239.GB41198@tarantool.org> In-Reply-To: <20211213074239.GB41198@tarantool.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9FFF274446F725B74A0A66A77131E9218A37C9B025F167FE8182A05F538085040BCAE09F4A31E2B9D6F3BD646C1B419F6B075F0139CF29ED5452E5F347D09D5C7 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7AD2F2D6F6013FF7FC2099A533E45F2D0395957E7521B51C2CFCAF695D4D8E9FCEA1F7E6F0F101C6778DA827A17800CE792C68BF9CD4C0E9EEA1F7E6F0F101C6723150C8DA25C47586E58E00D9D99D84E1BDDB23E98D2D38BBCA57AF85F7723F2F60A5C2671B67B4490CA380FD4ED4FFDCC7F00164DA146DAFE8445B8C89999728AA50765F7900637CAEE156C82D3D7D9389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC8D166953D3EA3826BF6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA7E827F84554CEF5019E625A9149C048EE9ECD01F8117BC8BEE2021AF6380DFAD18AA50765F790063735872C767BF85DA227C277FBC8AE2E8B953A8A48A05D51F175ECD9A6C639B01B4E70A05D1297E1BBCB5012B2E24CD356 X-C1DE0DAB: 0D63561A33F958A509EDB19E213E1377DD069D81B22A5B09941A5604FFAE0D8DD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA759D2A03B9C34326B3410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34E229BE567979C940BDA2B4472D107A39B243C394E7C747650F29802C553023AA896034748B7D8AE31D7E09C32AA3244CBFC283333F0A5FAD2EC7A422842EFE0C8894E9C85370243E729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojonEvmBC42e9A3rOtkn6+lw== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5DE1D13296E670F12BC7D071A90ACD07F63841015FED1DE5223CC9A89AB576DD93FB559BB5D741EB963CF37A108A312F5C27E8A8C3839CE0E25FEEDEB644C299C0ED14614B50AE0675 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v1 2/2] sql: introduce syntax for MAP values X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Vladislav Shpilevoy via Tarantool-patches Reply-To: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Thanks for the fixes! >>> diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c >>> index 55e494332..86de3f98a 100644 >>> --- a/src/box/sql/vdbe.c >>> +++ b/src/box/sql/vdbe.c >>> @@ -1438,6 +1438,26 @@ case OP_Array: { >>> break; >>> } >>> >>> +/** >>> + * Opcode: Map P1 P2 P3 * * >>> + * Synopsis: r[P2] = map(P3@P1) >>> + * >>> + * Construct an MAP value from P1 registers starting at reg(P3). >>> + */ >>> +case OP_Map: { >>> + pOut = &aMem[pOp->p2]; >>> + >>> + uint32_t size; >>> + struct region *region = &fiber()->gc; >>> + size_t svp = region_used(region); >>> + char *val = mem_encode_map(&aMem[pOp->p3], pOp->p1, &size, region); >>> + if (val == NULL || mem_copy_map(pOut, val, size) != 0) { >>> + region_truncate(region, svp); >>> + goto abort_due_to_error; >>> + } >> >> You should probably truncate the region regardless of the result. Otherwise >> in case of success you will leak the region inside of the query bit by bit >> while SELECT works: >> >> box.execute('CREATE TABLE test (id INTEGER PRIMARY KEY)') >> box.execute('INSERT INTO test VALUES (1), (2), (3)') >> box.execute('SELECT {id: id} FROM test') >> >> Here you will do OP_Map 3 times, all will leave some region memory leaked >> every time. It is freed in the end of execution probably, but it might do >> some big usage while the request is in progress when the row count is much >> bigger than 3. >> > Thank you! Fixed. > >> Btw, worth adding a multirow test. All current map tests select a single row. > There are several tests where the number of selected rows is more than one, for > example map-3 or map-4, but the number of rows is still quite low. I added > another test that selects 1000 rows with maps. I meant this case when you select not just already stored values, but construct a map from the select values. For instance, not just SELECT col FROM t; where 'col' is map, but rather SELECT {key: value} FROM t; where 'key' and 'value' are columns in T and row count > 0. In your new test you select '*', but I wanted to test what happens when columns are used inside of map syntax + row count > 0. Anyway it works, so the patchset LGTM.