<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 9 Nov 2018, at 12:25, Vladislav Shpilevoy <<a href="mailto:v.shpilevoy@tarantool.org" class="">v.shpilevoy@tarantool.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Hi! Thanks for the patch! I understand, that Vova said</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">that it should not be pushed, but Kirill asked me, on</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">the contrary, to review it. So I do.</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""></div></blockquote><div><br class=""></div><div><div>Vladimir didn’t suggest better solutions except for complete reworking</div><div>them. Now it is definitely bug which leads to wrong results of</div><div>SELECT queries (which is a terrible thing taking into account the fact that</div><div>SQL is supposed to be used mostly for DQL). So lets take this patch as</div><div>a workaround and rework ephemeral tables when we will have enough time</div><div>and resources (surely if Kirill and Vladimir don’t mind).</div><div><br class=""></div><div>With this bug it seems to be unacceptable to release beta version.</div></div><br class=""><blockquote type="cite" class=""><div class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">On 29/10/2018 22:02, Nikita Pettik wrote:</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">Ephemeral space are extensively used in SQL to store intermediate<br class="">results of query processing. To keep things simple, they feature only<br class="">one unique index (primary) which covers all fields. However, ephemeral<br class="">space can be used to store non-unique entries. In this case, one<br class="">additional field added to the end if stored data:<br class="">[field1, ... fieldn, rowid]<br class="">Note that it can't be added to the beginning of tuple since data in<br class="">ephemeral space may be kept as sorted. Previously, to generate proper<br class="">rowid index_max() was used. However, it is obviously wrong way to do it.<br class="">Hence, lets add simple integer counter to memtx space (ephemeral spaces<br class="">are valid only for memtx engine) and introduce method in vtab to fetch<br class="">next rowid value.<br class="">Needed for #3297<br class="">---<br class=""> src/box/blackhole.c    |  1 +<br class=""> src/box/errcode.h      |  2 ++<br class=""> src/box/memtx_space.c  | 17 +++++++++++++++++<br class=""> src/box/memtx_space.h  |  7 +++++++<br class=""> src/box/space.c        |  9 +++++++++<br class=""> src/box/space.h        |  3 +++<br class=""> src/box/sysview.c      |  1 +<br class=""> src/box/vinyl.c        |  1 +<br class=""> src/errinj.h           |  1 +<br class=""> test/box/errinj.result |  2 ++<br class=""> test/box/misc.result   |  1 +<br class=""> 11 files changed, 45 insertions(+)<br class="">index 04f4f34ee..fab8b6617 100644<br class="">--- a/src/box/errcode.h<br class="">+++ b/src/box/errcode.h<br class="">@@ -223,6 +223,8 @@ struct errcode_record {<br class=""> <span class="Apple-tab-span" style="white-space: pre;">     </span>/*168 */_(ER_DROP_FK_CONSTRAINT,<span class="Apple-tab-span" style="white-space: pre;">  </span>"Failed to drop foreign key constraint '%s': %s") \<br class=""> <span class="Apple-tab-span" style="white-space: pre;">  </span>/*169 */_(ER_NO_SUCH_CONSTRAINT,<span class="Apple-tab-span" style="white-space: pre;">  </span>"Constraint %s does not exist") \<br class=""> <span class="Apple-tab-span" style="white-space: pre;">    </span>/*170 */_(ER_CONSTRAINT_EXISTS,<span class="Apple-tab-span" style="white-space: pre;">   </span><span class="Apple-tab-span" style="white-space: pre;">  </span>"Constraint %s already exists") \<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>/*171 */_(ER_ROWID_OVERFLOW,<span class="Apple-tab-span" style="white-space: pre;">      </span><span class="Apple-tab-span" style="white-space: pre;">  </span>"Rowid is overflowed: too many entries in ephemeral space") \<br class="">+<br class=""></blockquote><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">This error message as well as check on uint64_max are</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">not necessary, IMHO. I can not imagine how many hundreds of</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">years a one should insert into one ephemeral table to</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">reach this limit.</span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""></div></blockquote><div><br class=""></div><div>It is true that 2^64 is likely to be quite huge number of tuples,</div><div>but for instance JOIN uses nested-loop algorithm, so it requires</div><div>n^2 memory for ephemeral table to comprise results.</div><div>In this regard, to reach the limit we need 4-way join where each</div><div>table contains 2^16 entries, which in turn doesn’t seem to be giant.</div><div><br class=""></div><div>*It is only thoughts tho, I haven’t tested it since I suppose very likely</div><div> my pc would simply get stuck.*</div><div><br class=""></div><div>I wanted to create long test as the easiest solution, but Alexander warned</div><div>me that Travis may not survive such test due to lack of memory.</div><br class=""></div><br class=""></body></html>