From: "n.pettik" <korablev@tarantool.org> To: tarantool-patches@freelists.org Cc: Kirill Shcherbatov <kshcherbatov@tarantool.org> Subject: [tarantool-patches] Re: [PATCH v2 1/4] sql: get rid off sqlite3NestedParse in clean stats Date: Tue, 10 Jul 2018 20:52:47 +0300 [thread overview] Message-ID: <A3D3CA2F-4BA0-4F52-A903-716BF2B6A5C5@tarantool.org> (raw) In-Reply-To: <3017d0e640eebdc6c3f28b5b4a4cbd2ef5646882.1531242355.git.kshcherbatov@tarantool.org> > On 10 Jul 2018, at 20:08, Kirill Shcherbatov <kshcherbatov@tarantool.org> wrote: > > Now we manually generate AST structures to drop outdated > stats from _sql_stat1 and _sql_stat4 spaces instead of > starting sqlite3NestedParse. This function become totally Typo: becomes. > > --- a/src/box/sql/analyze.c > +++ b/src/box/sql/analyze.c > @@ -116,71 +116,53 @@ > +vdbe_emit_stat_space_open(struct Parse *parse, int stat_cursor, > + const char *index_name, const char *table_name) > { > - const char *aTable[] = { > - "_sql_stat1", > - "_sql_stat4", > - NULL}; > - int i; > - sqlite3 *db = pParse->db; > - Vdbe *v = sqlite3GetVdbe(pParse); > - int aRoot[ArraySize(aTable)]; > - u8 aCreateTbl[ArraySize(aTable)]; > + const char *space_names[] = {"_sql_stat1", "_sql_stat4"}; You already have argument ’table_name’, so it looks confusing. Lets name it like ‘stat_names’. The same for space_ids. > + const uint32_t space_ids[] = {BOX_SQL_STAT1_ID, BOX_SQL_STAT4_ID}; > + struct Vdbe *v = sqlite3GetVdbe(parse); > + assert(v != NULL); > + assert(sqlite3VdbeDb(v) == parse->db); > > - if (v == 0) > - return; > - assert(sqlite3VdbeDb(v) == db); > - > - /* Create new statistic tables if they do not exist, or clear them > - * if they do already exist. > + /* > + * Create new statistic tables if they do not exist, or But comment below says that ’tables already exist since they are system’. > + * clear them if they do already exist. > */ > - for (i = 0; aTable[i]; i++) { > - const char *zTab = aTable[i]; > - Table *pStat; > - /* The table already exists, because it is a system space */ > - pStat = sqlite3HashFind(&db->pSchema->tblHash, zTab); > - assert(pStat != NULL); > - aRoot[i] = pStat->tnum; > - aCreateTbl[i] = 0; > - if (zWhere) { > - sqlite3NestedParse(pParse, > - "DELETE FROM \"%s\" WHERE \"%s\"=%Q", > - zTab, zWhereType, zWhere); > + for (uint i = 0; i < lengthof(space_names); ++i) { > + const char *space_name = space_names[i]; > + /* > + * The table already exists, because it is a > + * system space. > + */ > + assert(sqlite3HashFind(&parse->db->pSchema->tblHash, > + space_name) != NULL); > + if (table_name != NULL || index_name != NULL) { I don’t understand situation when index_name != NULL but table_name == NULL. In our SQL index name is local to table, (i.e. indexes with the same name could exist within different tables). I see that vdbe_emit_stat_space_open() is called twice in analyzeTable() and analyzeTable() in turn always called with pOnlyIdx == NULL. Hence, in vdbe_emit_stat_space_open() index_name is always == NULL. Lets remove this dead code and excess arg. > + vdbe_emit_stat_space_clear(parse, space_name, > + index_name, table_name); > } else { > - /* > - * The sql_stat[134] table already exists. > - * Delete all rows. > - */ > - sqlite3VdbeAddOp2(v, OP_Clear, > - SQLITE_PAGENO_TO_SPACEID(aRoot[i]), 0); > + sqlite3VdbeAddOp2(v, OP_Clear, space_ids[i], 0); OP_Clear uses only first operand, so you can use sqlite3VdbeAddOp1();
next prev parent reply other threads:[~2018-07-10 17:52 UTC|newest] Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-07-10 17:08 [tarantool-patches] [PATCH v2 0/4] sql: get rid off sqlite3NestedParse Kirill Shcherbatov 2018-07-10 17:08 ` [tarantool-patches] [PATCH v2 1/4] sql: get rid off sqlite3NestedParse in clean stats Kirill Shcherbatov 2018-07-10 17:52 ` n.pettik [this message] 2018-07-11 7:22 ` [tarantool-patches] " Kirill Shcherbatov 2018-07-11 12:19 ` n.pettik 2018-07-11 12:23 ` Kirill Shcherbatov 2018-07-11 13:16 ` n.pettik 2018-07-10 17:08 ` [tarantool-patches] [PATCH v2 2/4] sql: remove usless sqlite3NestedParse function Kirill Shcherbatov 2018-07-10 18:22 ` [tarantool-patches] " n.pettik 2018-07-11 7:22 ` Kirill Shcherbatov 2018-07-10 17:08 ` [tarantool-patches] [PATCH v2 3/4] sql: refactor vdbe_emit_open_cursor calls Kirill Shcherbatov 2018-07-10 18:22 ` [tarantool-patches] " n.pettik 2018-07-11 7:22 ` Kirill Shcherbatov 2018-07-10 17:08 ` [tarantool-patches] [PATCH v2 4/4] sql: remove OP_LoadPtr Kirill Shcherbatov 2018-07-10 18:34 ` [tarantool-patches] " n.pettik 2018-07-10 20:23 ` Vladislav Shpilevoy 2018-07-10 20:34 ` n.pettik 2018-07-11 13:45 ` [tarantool-patches] Re: [PATCH v2 0/4] sql: get rid off sqlite3NestedParse Kirill Yukhin
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=A3D3CA2F-4BA0-4F52-A903-716BF2B6A5C5@tarantool.org \ --to=korablev@tarantool.org \ --cc=kshcherbatov@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='[tarantool-patches] Re: [PATCH v2 1/4] sql: get rid off sqlite3NestedParse in clean stats' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox