<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=""><div>In order to avoid send excess mails to patches mailing list,</div><div>I won’t send patch v.2 (since it contains few minor fixes).</div><div>So, just inline changes I have made:</div><div><br class=""></div><div><blockquote type="cite" class=""><div class=""></div><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="">In order to remove colFlag from struct Column, it is necessary to delete<br class="">usages of this field as an indicator of column with specified type, i.e.<br class="">having set COLFLAG_HASTYPE.  This patch adds to struct Column new field<br class=""></blockquote><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="">to struct Column new field -> new field to `struct Column`</span></div></blockquote><div><br class=""></div><div>As you wish. Rephrased.</div><div><br class=""></div><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="">+<span class="Apple-tab-span" style="white-space: pre;">    </span><span class="Apple-tab-span" style="white-space: pre;">  </span>/* TODO: convert string of type into runtime FIELD_TYPE value. */<br class="">+<span class="Apple-tab-span" style="white-space: pre;">   </span><span class="Apple-tab-span" style="white-space: pre;">  </span>if (sqlite3StrNICmp(pType->z, "INTEGER", 7) == 0 ||<br class="">+<span class="Apple-tab-span" style="white-space: pre;">    </span><span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-converted-space"> </span>   sqlite3StrNICmp(pType->z, "INT", 3) == 0) {<br class=""></blockquote><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="">this condition is equivalent to just</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=""><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="">`sqlite3StrNICmp(pType->z, "INT", 3) == 0) `</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=""><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="">Replace `sqlite3StrNICmp` with `sqlite3StrICmp`</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>In fact, you are wrong too, since pType->z contains full string</div><div>of ‘create table’ statement. However, pTyze->n represents length of type substring,</div><div>so to make it comparing correctly, it is enough to add length checking:</div><div><br class=""></div><div><div>+<span class="Apple-tab-span" style="white-space:pre">               </span>if ((sqlite3StrNICmp(pType->z, "INTEGER", 7) == 0 &&</div><div>+<span class="Apple-tab-span" style="white-space:pre">           </span>     pType->n == 7) ||</div><div>+<span class="Apple-tab-span" style="white-space:pre">         </span>    (sqlite3StrNICmp(pType->z, "INT", 3) == 0 &&</div><div>+<span class="Apple-tab-span" style="white-space:pre">             </span>     pType->n == 3)) {</div></div><div><br class=""></div><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="">diff --git a/src/box/sql/pragma.c b/src/box/sql/pragma.c<br class="">index 3eb3248c6..4aa3b2961 100644<br class="">--- a/src/box/sql/pragma.c<br class="">+++ b/src/box/sql/pragma.c<br class="">@@ -368,8 +368,8 @@ sqlite3Pragma(Parse * pParse, Token * pId,<span class="Apple-tab-span" style="white-space: pre;"> </span>/* First part of [schema.]id field */<br class=""> <span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-converted-space"> </span>      || pCol->pDflt->op == TK_SPAN);<br class=""> <span class="Apple-tab-span" style="white-space: pre;">       </span><span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-tab-span" style="white-space: pre;">  </span>sqlite3VdbeMultiLoad(v, 1, "issisi",<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-converted-space"> </span>    i, pCol->zName,<br class="">-<span class="Apple-tab-span" style="white-space: pre;">   </span><span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-converted-space"> </span>    sqlite3ColumnType<br class="">-<span class="Apple-tab-span" style="white-space: pre;">    </span><span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-converted-space"> </span>    (pCol, ""),<br class="">+<span class="Apple-tab-span" style="white-space: pre;">        </span><span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-converted-space"> </span>    field_type_strs[sqlite3ColumnType<br class=""></blockquote><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="">too long line</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=""><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="">replace `if (pTab) {` with `if (!pTab)` above …</span></div></blockquote><div><br class=""></div><div>Why should I do this? I don't get it...</div><div><br class=""></div><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="">-char *<br class="">-sqlite3ColumnType(Column * pCol, char *zDflt)<br class="">+enum field_type<br class="">+sqlite3ColumnType(Column * pCol)<br class=""> {<br class="">-<span class="Apple-tab-span" style="white-space: pre;">  </span>if ((pCol->colFlags & COLFLAG_HASTYPE) == 0)<br class="">-<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;">  </span>return zDflt;<br class="">-<span class="Apple-tab-span" style="white-space: pre;">       </span>return pCol->zName + strlen(pCol->zName) + 1;<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>return pCol->type;<br class=""> }<br class=""></blockquote><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="">Make this function inline or #define</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>Done. (However, I suppose compiler is smart enough to inline this function</div><div>without explicit directives)</div><div><br class=""></div><blockquote type="cite" class=""><div><blockquote type="cite" class="">+/* Return true if given column is part of primary key. */<br class="">+bool<br class="">+table_column_is_primkey(Table *table, uint32_t column)<br class=""></blockquote>I do not like primkey word &&<br class="">The name is a little confusing, because one can suppose that the<br class="">function checks if column is a primary key, while it actually checks<br class="">if pk contains the column.</div></blockquote><div><br class=""></div>As you wish. Renamed to ‘table_column_is_in_pk'.</div><div><br class=""></div><blockquote type="cite" class=""><div><blockquote type="cite" class="">+{<br class="">+<span class="Apple-tab-span" style="white-space: pre;">   </span>uint32_t space_id = SQLITE_PAGENO_TO_SPACEID(table->tnum);<br class="">+<span class="Apple-tab-span" style="white-space: pre;">       </span>struct space *space = space_by_id(space_id);<br class="">+<span class="Apple-tab-span" style="white-space: pre;">        </span>assert(space != NULL);<br class="">+<br class="">+<span class="Apple-tab-span" style="white-space: pre;">        </span>struct index *primary_idx = index_find(space, 0 /* PK */);<br class="">+<span class="Apple-tab-span" style="white-space: pre;">  </span>/* Views don't have any indexes. */<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>if (primary_idx == NULL)<br class="">+<span class="Apple-tab-span" style="white-space: pre;">    </span><span class="Apple-tab-span" style="white-space: pre;">  </span>return false;<br class="">+<span class="Apple-tab-span" style="white-space: pre;">       </span>struct index_def *idx_def = primary_idx->def;<br class="">+<span class="Apple-tab-span" style="white-space: pre;">    </span>uint64_t pk_mask = idx_def->key_def->column_mask;<br class="">+<span class="Apple-tab-span" style="white-space: pre;">     </span>if (column < 63) {<br class=""></blockquote>Are there any constants in Tarantool for this purpose? (63)<br class=""></div></blockquote><div class=""><br class=""></div>Unfortunately, aren’t. It is just (the number of bits in uint64_t) - 1 :)<div class=""><br class=""><div></div><blockquote type="cite" class=""><div><br class=""></div><blockquote type="cite" class="">+<span class="Apple-tab-span" style="white-space: pre;">       </span><span class="Apple-tab-span" style="white-space: pre;">  </span>return pk_mask & (1UL << column);<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>} else if ((pk_mask & (1UL << 1)) != 0) {<br class=""></blockquote>magic</blockquote><br class=""></div><div class="">Added extensive comment to this function explaining this logic:</div><div class=""><br class=""></div><div class=""><div class="">+/*</div><div class="">+ * Return true if given column is part of primary key.</div><div class="">+ * If field number is less than 63, corresponding bit</div><div class="">+ * in column mask is tested. Otherwise, check whether 64-th bit</div><div class="">+ * in mask is set or not. If it is set, then iterate through</div><div class="">+ * key parts of primary index and check field number.</div><div class="">+ * In case it isn't set, there are no key columns among</div><div class="">+ * the rest of fields.</div><div class="">+ */</div></div><div class=""><br class=""></div></body></html>