<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 3 Apr 2018, at 21:27, 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="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 6 comments below.</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=""><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="">03.04.2018 19:14, Nikita Pettik пишет:</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=""><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="">As a part of SQL data dictionary integration, 'DROP INDEX' and<br class="">'DROP TABLE' statements proccessing has been refactored in order<br class="">to avoid using SQL specific internal structures.<br class="">However, triggers still aren't transfered to server, so to drop them<br class="">it is required to lookup SQL table and emit apporpriate opcodes.<br class="">Also, added comments and fixed codestyle for functions processing<br class="">'DROP' routine.<br class=""><br class="">Part of #3222.<br class="">---<br class=""> src/box/sql/build.c     | 241 ++++++++++++++++++++++++++----------------------<br class=""> src/box/sql/parse.c     |   6 +-<br class=""> src/box/sql/parse.y     |   6 +-<br class=""> src/box/sql/sqliteInt.h |   6 +-<br class=""> 4 files changed, 140 insertions(+), 119 deletions(-)<br class=""><br class="">diff --git a/src/box/sql/build.c b/src/box/sql/build.c<br class="">index 61194e06b..219cc974b 100644<br class="">--- a/src/box/sql/build.c<br class="">+++ b/src/box/sql/build.c<br class="">@@ -46,6 +46,7 @@<br class=""> #include "sqliteInt.h"<br class=""> #include "vdbeInt.h"<br class=""> #include "tarantoolInt.h"<br class="">+#include "box/box.h"<br class=""> #include "box/sequence.h"<br class=""> #include "box/session.h"<br class=""> #include "box/identifier.h"<br class="">@@ -2152,48 +2153,50 @@ sql_clear_stat_spaces(Parse * pParse, const char *zType, const char *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-converted-space"> </span>  zType, zName);<br class=""> }<br class=""> -/*<br class="">+/**<br class="">  * Generate code to drop a table.<br class="">+ * This routine includes dropping triggers, sequences,<br class="">+ * all indexes and entry from _space space.<br class="">+ *<br class="">+ * @param parse_context Current parsing context.<br class="">+ * @param space Space to be dropped.<br class="">+ * @param is_view True, if space is<br class="">  */<br class=""> static void<br class="">-sqlite3CodeDropTable(Parse * pParse, Table * pTab, int isView)<br class="">+sql_code_drop_table(struct Parse *parse_context, struct space *space,<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>   bool is_view)<br class=""> {<br class="">-<span class="Apple-tab-span" style="white-space: pre;">  </span>Vdbe *v;<br class="">-<span class="Apple-tab-span" style="white-space: pre;">    </span>sqlite3 *db = pParse->db;<br class="">-<span class="Apple-tab-span" style="white-space: pre;">        </span>Trigger *pTrigger;<br class="">-<br class="">-<span class="Apple-tab-span" style="white-space: pre;">    </span>v = sqlite3GetVdbe(pParse);<br class=""><br class="">+<span class="Apple-tab-span" style="white-space: pre;">    </span>struct sqlite3 *db = parse_context->db;<br class="">+<span class="Apple-tab-span" style="white-space: pre;">  </span>struct Vdbe *v = sqlite3GetVdbe(parse_context);<br class=""> <span class="Apple-tab-span" style="white-space: pre;">        </span>assert(v != 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="">1. Lets in all new code use explicit ==/!= NULL.</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>Fixed:</div><div>-       assert(v != 0);<br class=""><div>+       assert(v != NULL);</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=""> <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>* Drop all triggers associated with the table being<br class=""> <span class="Apple-tab-span" style="white-space: pre;">     </span><span class="Apple-converted-space"> </span>* dropped. Code is generated to remove entries from<br class=""> <span class="Apple-tab-span" style="white-space: pre;">     </span><span class="Apple-converted-space"> </span>* _trigger. OP_DropTrigger will remove it from internal<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-converted-space"> </span>* SQL structures.<br class="">-<span class="Apple-tab-span" style="white-space: pre;">    </span><span class="Apple-converted-space"> </span>*/<br class="">-<span class="Apple-tab-span" style="white-space: pre;">   </span>pTrigger = pTab->pTrigger;<br class="">-<span class="Apple-tab-span" style="white-space: pre;">       </span>/* Do not account triggers deletion - they will be accounted<br class="">+<span class="Apple-tab-span" style="white-space: pre;">        </span><span class="Apple-converted-space"> </span>*<br class="">+<span class="Apple-tab-span" style="white-space: pre;">    </span><span class="Apple-converted-space"> </span>* Do not account triggers deletion - they will be accounted<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="">2. Out of 66.</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><div><div>-        * Do not account triggers deletion - they will be accounted</div><div>-        * in DELETE from _space below.</div><div>+        * Do not account triggers deletion - they will be</div><div>+        * accounted in DELETE from _space below.</div></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="">@@ -2214,7 +2216,7 @@ sqlite3CodeDropTable(Parse * pParse, Table * pTab, int isView)<br class=""> <span class="Apple-tab-span" style="white-space: pre;">     </span><span class="Apple-converted-space"> </span>* Drop all _space and _index entries that refer to the<br class=""> <span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-converted-space"> </span>* table.<br class=""> <span class="Apple-tab-span" style="white-space: pre;">        </span><span class="Apple-converted-space"> </span>*/<br class="">-<span class="Apple-tab-span" style="white-space: pre;">   </span>if (!isView) {<br class="">+<span class="Apple-tab-span" style="white-space: pre;">      </span>if (!is_view) {<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="">3. I looked at the indexes deletion more carefully and noticed, that you can avoid any allocations</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="">here. Why can not you just walk through space->index array and generate OP_SDelete opcodes for</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="">each index, starting from 1 (to skip primary)? AFAIK the entire index array is not changed until you</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="">reach VdbeExec, so you can do not save index identifiers on region to generate opcodes.</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>IDK why I didn’t do it in this way (probably due to my ‘paranoia’).</div><div>Reworked:</div><div><br class=""></div><div><div>-                       uint32_t *iids =</div><div>-                               (uint32_t *) region_alloc(&fiber()->gc,</div><div>-                                                         sizeof(uint32_t) *</div><div>-                                                         (index_count - 1));</div><div>-                       /* Save index ids to be deleted except for PK. */</div><div>                        for (uint32_t i = 1; i < index_count; ++i) {</div><div>-                               iids[i - 1] = space->index[i]->def->iid;</div><div>-                       }</div><div>-                       for (uint32_t i = 0; i < index_count - 1; ++i) {</div><div>-                               sqlite3VdbeAddOp2(v, OP_Integer, iids[i],</div><div>+                               sqlite3VdbeAddOp2(v, OP_Integer,</div><div>+                                                 space->index[i]->def->iid,</div><div>                                                  space_id_reg + 1);</div><div>                                sqlite3VdbeAddOp3(v, OP_MakeRecord,</div><div>                                                  space_id_reg, 2, idx_rec_reg);</div><div>@@ -2233,7 +2226,7 @@ sql_code_drop_table(struct Parse *parse_context, struct space *space,</div><div>                                                  idx_rec_reg);</div><div>                                VdbeComment((v,</div><div>                                             "Remove secondary index iid = %u",</div><div>-                                            iids[i]));</div><div>+                                            space->index[i]->def->iid));</div></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=""> <span class="Apple-tab-span" style="white-space: pre;">        </span><span class="Apple-tab-span" style="white-space: pre;">  </span>uint32_t index_count = space->index_count;<br class=""> <span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-tab-span" style="white-space: pre;">  </span>if (index_count > 1) {<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>/*<br class="">@@ -2257,71 +2259,78 @@ sqlite3CodeDropTable(Parse * pParse, Table * pTab, int isView)<br class=""> <span class="Apple-tab-span" style="white-space: pre;">  </span>sqlite3VdbeAddOp2(v, OP_SDelete, BOX_SPACE_ID, idx_rec_reg);<br class=""> <span class="Apple-tab-span" style="white-space: pre;">   </span>sqlite3VdbeChangeP5(v, OPFLAG_NCHANGE);<br class=""> <span class="Apple-tab-span" style="white-space: pre;">        </span>VdbeComment((v, "Delete entry from _space"));<br class="">-<span class="Apple-tab-span" style="white-space: pre;">     </span>/* Remove the table entry from SQLite's internal schema and modify<br class="">-<span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-converted-space"> </span>* the schema cookie.<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>* Remove the table entry from SQLite's internal schema<br class="">+<span class="Apple-tab-span" style="white-space: pre;">       </span><span class="Apple-converted-space"> </span>* and modify the schema cookie.<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-converted-space"> </span>*/<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="">4. But you have deleted cookie updates in the previous commit. Source code of OP_DropTable and all</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="">called there functions does not contain cookie changes.</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>Removed obsolete comment:</div><div><br class=""></div><div><div>-       /*</div><div>-        * Remove the table entry from SQLite's internal schema</div><div>-        * and modify the schema cookie.</div><div>-        */</div><div>+       /* Remove the table entry from SQLite's internal schema. */</div></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="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>sqlite3VdbeAddOp4(v, OP_DropTable, 0, 0, 0, space->def->name, 0);<br class=""> -<span class="Apple-tab-span" style="white-space: pre;">       </span>sqlite3VdbeAddOp4(v, OP_DropTable, 0, 0, 0, pTab->zName, 0);<br class="">-<br class="">-<span class="Apple-tab-span" style="white-space: pre;">       </span>/* FIXME: DDL is impossible inside a transaction so far.<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>* Replace to _space/_index will fail if active<br class=""> <span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-converted-space"> </span>* transaction. So, don't pretend, that we are able to<br class=""> <span class="Apple-tab-span" style="white-space: pre;">   </span><span class="Apple-converted-space"> </span>* anything back. To be fixed when transactions<br class=""> <span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-converted-space"> </span>* DDL are enabled.<br class=""> <span class="Apple-tab-span" style="white-space: pre;">      </span><span class="Apple-converted-space"> </span>*/<br class="">-<span class="Apple-tab-span" style="white-space: pre;">   </span>/* sqlite3ChangeCookie(pParse); */<br class=""> <span class="Apple-tab-span" style="white-space: pre;">     </span>sqliteViewResetAll(db);<br class=""> }<br class=""> -/*<br class="">+/**<br class="">  * This routine is called to do the work of a DROP TABLE statement.<br class="">- * pName is the name of the table to be dropped.<br class="">+ *<br class="">+ * @param parse_context Current parsing context.<br class="">+ * @param table_name_list List containing table name.<br class="">+ * @param is_view True, if statement is really 'DROP VIEW'.<br class="">+ * @param if_exists True, if statement contains 'IF EXISTS' clause.<br class="">  */<br class=""> void<br class="">-sqlite3DropTable(Parse * pParse, SrcList * pName, int isView, int noErr)<br class="">+sql_drop_table(struct Parse *parse_context, struct SrcList *table_name_list,<br class="">+<span class="Apple-tab-span" style="white-space: pre;">    </span><span class="Apple-converted-space"> </span>      bool is_view, bool if_exists)<br class=""> {<br class="">-<span class="Apple-tab-span" style="white-space: pre;">        </span>Table *pTab;<br class="">-<span class="Apple-tab-span" style="white-space: pre;">        </span>Vdbe *v = sqlite3GetVdbe(pParse);<br class="">-<span class="Apple-tab-span" style="white-space: pre;">   </span>sqlite3 *db = pParse->db;<br class="">-<br class="">+<span class="Apple-tab-span" style="white-space: pre;">  </span>struct Vdbe *v = sqlite3GetVdbe(parse_context);<br class="">+<span class="Apple-tab-span" style="white-space: pre;">     </span>struct sqlite3 *db = parse_context->db;<br class=""> <span class="Apple-tab-span" style="white-space: pre;">     </span>if (v == NULL || db->mallocFailed) {<br class=""> <span class="Apple-tab-span" style="white-space: pre;">        </span><span class="Apple-tab-span" style="white-space: pre;">  </span>goto exit_drop_table;<br class=""> <span class="Apple-tab-span" style="white-space: pre;">  </span>}<br class="">-<span class="Apple-tab-span" style="white-space: pre;">   </span>/* Activate changes counting here to account<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>* Activate changes counting here to account<br class=""> <span class="Apple-tab-span" style="white-space: pre;">     </span><span class="Apple-converted-space"> </span>* DROP TABLE IF NOT EXISTS, if the table really does not<br class=""> <span class="Apple-tab-span" style="white-space: pre;">        </span><span class="Apple-converted-space"> </span>* exist.<br class=""> <span class="Apple-tab-span" style="white-space: pre;">        </span><span class="Apple-converted-space"> </span>*/<br class="">-<span class="Apple-tab-span" style="white-space: pre;">   </span>if (!pParse->nested)<br class="">+<span class="Apple-tab-span" style="white-space: pre;">     </span>if (!parse_context->nested)<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="">5. Please, use explicit != 0. Why you use !int, the variable seems to be boolean. It slightly confuses.</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>This this not != check, but vice versa == 0 check.</div><div>! In this case would better fit, wouldn’t it?</div><div>(Since any number except for 0 would be converted to false)</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=""> <span class="Apple-tab-span" style="white-space: pre;">     </span><span class="Apple-tab-span" style="white-space: pre;">  </span>sqlite3VdbeCountChanges(v);<br class="">-<span class="Apple-tab-span" style="white-space: pre;"> </span>assert(pParse->nErr == 0);<br class="">-<span class="Apple-tab-span" style="white-space: pre;">       </span>assert(pName->nSrc == 1);<br class="">-<span class="Apple-tab-span" style="white-space: pre;">        </span>assert(db->pSchema != NULL);<br class="">-<span class="Apple-tab-span" style="white-space: pre;">     </span>if (noErr)<br class="">-<span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-tab-span" style="white-space: pre;">  </span>db->suppressErr++;<br class="">-<span class="Apple-tab-span" style="white-space: pre;">       </span>assert(isView == 0 || isView == LOCATE_VIEW);<br class="">-<span class="Apple-tab-span" style="white-space: pre;">       </span>pTab = sqlite3LocateTable(pParse, isView, pName->a[0].zName);<br class="">-<span class="Apple-tab-span" style="white-space: pre;">    </span>if (noErr)<br class="">-<span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-tab-span" style="white-space: pre;">  </span>db->suppressErr--;<br class="">-<br class="">-<span class="Apple-tab-span" style="white-space: pre;"> </span>if (pTab == 0)<br class="">+<span class="Apple-tab-span" style="white-space: pre;">      </span>assert(parse_context->nErr == 0);<br class="">+<span class="Apple-tab-span" style="white-space: pre;">        </span>assert(table_name_list->nSrc == 1);<br class="">+<span class="Apple-tab-span" style="white-space: pre;">      </span>assert(is_view == 0 || is_view == LOCATE_VIEW);<br class="">+<span class="Apple-tab-span" style="white-space: pre;">     </span>const char *space_name = table_name_list->a[0].zName;<br class="">+<span class="Apple-tab-span" style="white-space: pre;">    </span>uint32_t space_id = box_space_id_by_name(space_name,<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-converted-space"> </span>strlen(space_name));<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>if (space_id == BOX_ID_NIL) {<br class="">+<span class="Apple-tab-span" style="white-space: pre;">       </span><span class="Apple-tab-span" style="white-space: pre;">  </span>if (!is_view && !if_exists)<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>sqlite3ErrorMsg(parse_context, "no such table: %s",<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>space_name);<br class="">+<span class="Apple-tab-span" style="white-space: pre;">        </span><span class="Apple-tab-span" style="white-space: pre;">  </span>if (is_view && !if_exists)<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>sqlite3ErrorMsg(parse_context, "no such view: %s",<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>space_name);<br class=""> <span class="Apple-tab-span" style="white-space: pre;">   </span><span class="Apple-tab-span" style="white-space: pre;">  </span>goto exit_drop_table;<br class="">-#ifndef SQLITE_OMIT_VIEW<br class="">-<span class="Apple-tab-span" style="white-space: pre;"> </span>/* Ensure DROP TABLE is not used on a view, and DROP VIEW is not used<br class="">-<span class="Apple-tab-span" style="white-space: pre;">       </span><span class="Apple-converted-space"> </span>* on a table.<br class="">+<span class="Apple-tab-span" style="white-space: pre;">        </span>}<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="">+<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>* Ensure DROP TABLE is not used on a view,<br class="">+<span class="Apple-tab-span" style="white-space: pre;">   </span><span class="Apple-converted-space"> </span>* and DROP VIEW is not used on a table.<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-converted-space"> </span>*/<br class="">-<span class="Apple-tab-span" style="white-space: pre;">   </span>if (isView && !space_is_view(pTab)) {<br class="">-<span class="Apple-tab-span" style="white-space: pre;">       </span><span class="Apple-tab-span" style="white-space: pre;">  </span>sqlite3ErrorMsg(pParse, "use DROP TABLE to delete table %s",<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>pTab->zName);<br class="">+<span class="Apple-tab-span" style="white-space: pre;">    </span>if (is_view && !space->def->opts.is_view) {<br class="">+<span class="Apple-tab-span" style="white-space: pre;">   </span><span class="Apple-tab-span" style="white-space: pre;">  </span>sqlite3ErrorMsg(parse_context, "use DROP TABLE to delete table %s",<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>space_name);<br class=""> <span class="Apple-tab-span" style="white-space: pre;">   </span><span class="Apple-tab-span" style="white-space: pre;">  </span>goto exit_drop_table;<br class=""> <span class="Apple-tab-span" style="white-space: pre;">  </span>}<br class="">-<span class="Apple-tab-span" style="white-space: pre;">   </span>if (!isView && space_is_view(pTab)) {<br class="">-<span class="Apple-tab-span" style="white-space: pre;">       </span><span class="Apple-tab-span" style="white-space: pre;">  </span>sqlite3ErrorMsg(pParse, "use DROP VIEW to delete view %s",<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>pTab->zName);<br class="">+<span class="Apple-tab-span" style="white-space: pre;">    </span>if (!is_view && space->def->opts.is_view) {<br class="">+<span class="Apple-tab-span" style="white-space: pre;">   </span><span class="Apple-tab-span" style="white-space: pre;">  </span>sqlite3ErrorMsg(parse_context, "use DROP VIEW to delete view %s",<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>space_name);<br class=""> <span class="Apple-tab-span" style="white-space: pre;">   </span><span class="Apple-tab-span" style="white-space: pre;">  </span>goto exit_drop_table;<br class=""> <span class="Apple-tab-span" style="white-space: pre;">  </span>}<br class="">-#endif<br class="">-<br class="">-<span class="Apple-tab-span" style="white-space: pre;"> </span>/* Generate code to remove the table from Tarantool and internal SQL<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>* Generate code to remove the table from Tarantool and internal SQL<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="">6. Out of 66.</span></div></blockquote><br class=""></div><div>Fixed whole comment (to fit into 66 chars):</div><div><br class=""></div><div><div>-        * Generate code to remove the table from Tarantool and internal SQL</div><div>-        * tables. Basically, it consists from 3 stages:</div><div>-        * 1. Delete statistics from _stat1 and _stat4 tables (if any exist)</div><div>-        * 2. In case of presence of FK constraints, i.e. current table is child</div><div>-        *    or parent, then start new transaction and erase from table</div><div>-        *    all data row by row. On each deletion check whether any FK</div><div>-        *    violations have occurred. If ones take place, then rollback</div><div>-        *    transaction and halt VDBE. Otherwise, commit transaction.</div><div>-        * 3. Drop table by truncating (if step 2 was skipped), removing</div><div>-        *    indexes from _index table and eventually tuple with corresponding</div><div>-        *    space_id from _space.</div><div>+        * Generate code to remove the table from Tarantool</div><div>+        * and internal SQL tables. Basically, it consists</div><div>+        * from 3 stages:</div><div>+        * 1. Delete statistics from _stat1 and _stat4 tables.</div><div>+        * 2. In case of presence of FK constraints, i.e. current</div><div>+        *    table is child or parent, then start new transaction</div><div>+        *    and erase from table all data row by row. On each</div><div>+        *    deletion check whether any FK violations have</div><div>+        *    occurred. If ones take place, then rollback</div><div>+        *    transaction and halt VDBE.</div><div>+        * 3. Drop table by truncating (if step 2 was skipped),</div><div>+        *    removing indexes from _index space and eventually</div><div>+        *    tuple with corresponding space_id from _space.</div><div>         */</div><div class=""><br class=""></div></div><br class=""></body></html>