<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 22 Mar 2018, at 17:11, <a href="mailto:v.shpilevoy@tarantool.org" class="">v.shpilevoy@tarantool.org</a> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="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; float: none; display: inline !important;" class="">See below 3 comments.</span><br style="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;" class=""><br style="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;" 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;" class="">21 марта 2018 г., в 2:48, Nikita Pettik <<a href="mailto:korablev@tarantool.org" class="">korablev@tarantool.org</a>> написал(а):<br class=""><br class="">After new DDL SQL implementation has been introduced, OP_OpenWrite,<br class="">OP_OpenRead and OP_ReopenIdx opcodes can be refactored.<br class=""><br class="">Firstly, if schema versions at compile time and runtime don't match,<br class="">finish VDBE execution with appropriate message error. Exception is the<br class="">situation when fifth pointer is set to OPFLAG_FRESH_PTR, which means<br class="">that space pointer has been fetched during runtime right before that.<br class=""><br class="">Secondly, there is no need to fetch number of columns in index from<br class="">KeyInfo: iterator yields the full tuple, so it would always be equal to<br class="">the number of fields in a whole space.<br class=""><br class="">Finally, now we always can pass space pointer to these opcodes<br class="">regardless of DML routine. In case of OP_ReopenIdx opcode space and<br class="">index from given cursor is checked on equality to those given in<br class="">arguments. If they match, this opcode will become no-op.<br class="">---<br class="">src/box/sql/opcodes.c |   6 +-<br class="">src/box/sql/opcodes.h |   6 +-<br class="">src/box/sql/vdbe.c    | 197 +++++++++++++++++---------------------------------<br class="">3 files changed, 71 insertions(+), 138 deletions(-)<br class=""><br class="">-/* Opcode: OpenRead P1 P2 * P4 P5<br class="">- * Synopsis: root=P2<br class="">+/* Opcode: OpenRead P1 P2 PЗ P4 P5<br class=""></blockquote><br style="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;" class=""><span style="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; float: none; display: inline !important;" class="">1. Seems like you wrote here a cyrillic letter 'З' instead of digit three.</span><br style="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;" class=""></div></blockquote><div><br class=""></div><div>Holy sh… How did you manage to notice that? My font displays them almost identical..</div><div>I would call it ’next-level review’. Anyway thanks, fixed.</div><br class=""><blockquote type="cite" class=""><div class=""><br style="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;" 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;" class="">+ * Synopsis: index id = P2, space ptr = P3<br class="">*<br class="">- * Open a read-only cursor for the database table whose root page is<br class="">- * P2 in a database file.<span class="Apple-converted-space"> </span><br class="">- * Give the new cursor an identifier of P1.  The P1<br class="">- * values need not be contiguous but all P1 values should be small integers.<br class="">- * It is an error for P1 to be negative.<br class="">+ * Open a cursor for a space specified by pointer in P3 and index<br class="">+ * id in P2. Give the new cursor an identifier of P1. The P1<br class="">+ * values need not be contiguous but all P1 values should be<br class="">+ * small integers. It is an error for P1 to be negative.<br class="">*<br class="">- * If P5!=0 then use the content of register P2 as the root page, not<br class="">- * the value of P2 itself.<br class="">+ * The P4 value may be a pointer to a KeyInfo structure.<br class="">+ * If it is a pointer to a KeyInfo structure, then said structure<br class="">+ * defines the content and collatining sequence of the index<br class="">+ * being opened. Otherwise, P4 is NULL.<br class="">*<br class="">- * There will be a read lock on the database whenever there is an<br class="">- * open cursor.  If the database was unlocked prior to this instruction<br class="">- * then a read lock is acquired as part of this instruction.  A read<br class="">- * lock allows other processes to read the database but prohibits<br class="">- * any other process from modifying the database.  The read lock is<br class="">- * released when all cursors are closed.  If this instruction attempts<br class="">- * to get a read lock but fails, the script terminates with an<br class="">- * SQLITE_BUSY error code.<br class="">- *<br class="">- * The P4 value may be either an integer (P4_INT32) or a pointer to<br class="">- * a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo<br class="">- * structure, then said structure defines the content and collating<br class="">- * sequence of the index being opened. Otherwise, if P4 is an integer<br class="">- * value, it is set to the number of columns in the table.<br class="">- *<br class="">- * See also: OpenWrite, ReopenIdx<br class="">+ * If schema has changed since compile time, VDBE ends execution<br class="">+ * with appropriate error message. The only exception is<br class="">+ * when P5 is set to OPFLAG_FRESH_PTR, which means that<br class="">+ * space pointer has been fetched in runtime right before<br class="">+ * this opcode.<br class="">*/<br class="">-/* Opcode: ReopenIdx P1 P2 * P4 P5<br class="">- * Synopsis: root=P2<br class="">+/* Opcode: ReopenIdx P1 P2 P3 P4 P5<br class="">+ * Synopsis: index id = P2, space ptr = P3<br class="">*<br class="">- * The ReopenIdx opcode works exactly like ReadOpen except that it first<br class="">- * checks to see if the cursor on P1 is already open with a root page<br class="">- * number of P2 and if it is this opcode becomes a no-op.  In other words,<br class="">- * if the cursor is already open, do not reopen it.<br class="">+ * The ReopenIdx opcode works exactly like ReadOpen except that<br class=""></blockquote><br style="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;" class=""><span style="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; float: none; display: inline !important;" class="">2. I can not find ReadOpen - possibly it is OP_OpenRead?</span><br style="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;" class=""></div></blockquote><div><br class=""></div><div>Fixed.</div><br class=""><blockquote type="cite" class=""><div 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;" class=""><br class="">+<span class="Apple-tab-span" style="white-space: pre;">       </span>/*<br class="">+<span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-converted-space"> </span>* Since Tarantool iterator yields the full tuple,<br class="">+<span class="Apple-tab-span" style="white-space: pre;">    </span><span class="Apple-converted-space"> </span>* we need a number of fields as wide as the table itself.<br class="">+<span class="Apple-tab-span" style="white-space: pre;">    </span><span class="Apple-converted-space"> </span>* Otherwise, not enough slots for row parser cache are<br class="">+<span class="Apple-tab-span" style="white-space: pre;">       </span><span class="Apple-converted-space"> </span>* allocated in VdbeCursor object.<br class=""></blockquote><br style="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;" class=""><span style="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; float: none; display: inline !important;" class="">3. Term 'yields' slightly confused. For the first moments it seems, that an iterator yields a fiber, not fields. Can you please find another word?</span></div></blockquote><br class=""></div><div>Ok, replaced with ‘provides’. BTW, I didn’t come up with this word combination myself,</div><div>just found it somewhere in source code...</div><br class=""></body></html>