From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 569DB2C326 for ; Sun, 15 Apr 2018 02:35:36 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id c8QDmwPxqmz5 for ; Sun, 15 Apr 2018 02:35:36 -0400 (EDT) Received: from mail-lf0-f44.google.com (mail-lf0-f44.google.com [209.85.215.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id A986D2C2A5 for ; Sun, 15 Apr 2018 02:35:35 -0400 (EDT) Received: by mail-lf0-f44.google.com with SMTP id j68-v6so17675752lfg.13 for ; Sat, 14 Apr 2018 23:35:35 -0700 (PDT) MIME-Version: 1.0 References: <1522791436-8221-1-git-send-email-hollow653@gmail.com> <926E041C-FCCB-46B0-B49B-21292CB70813@tarantool.org> <4E93854E-25F3-45F7-8590-5CD96991E365@tarantool.org> <51BFB6B0-C9CE-4380-8758-7F991512A752@tarantool.org> <55BEE14D-0F45-4DBD-95BB-D5EC23F02F18@tarantool.org> In-Reply-To: From: Hollow111 Date: Sun, 15 Apr 2018 06:35:22 +0000 Message-ID: Subject: [tarantool-patches] Re: [PATCH 2/2] sql: statistics removal after dropping an index Content-Type: multipart/alternative; boundary="000000000000f5afdd0569dd4f76" Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: korablev@tarantool.org Cc: tarantool-patches@freelists.org --000000000000f5afdd0569dd4f76 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I'm sorry have just noticed few mistakes. Changed it: diff --git a/src/box/sql/build.c b/src/box/sql/build.c index 92f3cb6..c6185e4 100644 --- a/src/box/sql/build.c +++ b/src/box/sql/build.c @@ -2129,18 +2129,36 @@ sqliteViewResetAll(sqlite3 * db) * Remove entries from the _sql_stat1 and _sql_stat4 * system spaces after a DROP INDEX or DROP TABLE command. * - * @param pParse Parsing context. - * @param zType Type of entry to be deleted: - * 'idx' or 'tbl' string literal. - * @param zName Name of index or table. + * @param parse The parsing context. + * @param table_name The table to be dropped or + * the table that contains index to be dropped. + * @param idx_name Index to be dropped. */ static void -sql_clear_stat_spaces(Parse * pParse, const char *zType, const char *zName= ) +sql_clear_stat_spaces(Parse *parse, const char *table_name, + const char *idx_name) { - sqlite3NestedParse(pParse, "DELETE FROM \"_sql_stat1\" WHERE \"%s\"=3D%Q"= , - zType, zName); - sqlite3NestedParse(pParse, "DELETE FROM \"_sql_stat4\" WHERE \"%s\"=3D%Q"= , - zType, zName); + if (idx_name !=3D NULL) { + sqlite3NestedParse(parse, + "DELETE FROM \"_sql_stat1\" " + "WHERE (\"idx\"=3D%Q AND " + "\"tbl\"=3D%Q)", + idx_name, table_name); + sqlite3NestedParse(parse, + "DELETE FROM \"_sql_stat4\" " + "WHERE (\"idx\"=3D%Q AND " + "\"tbl\"=3D%Q)", + idx_name, table_name); + } else { + sqlite3NestedParse(parse, + "DELETE FROM \"_sql_stat1\" " + "WHERE \"tbl\"=3D%Q", + table_name); + sqlite3NestedParse(parse, + "DELETE FROM \"_sql_stat4\" " + "WHERE \"tbl\"=3D%Q", + table_name); + } } =D0=B2=D1=81, 15 =D0=B0=D0=BF=D1=80. 2018 =D0=B3. =D0=B2 9:09, Hollow111 : > Hello. Changes have been made. > Diff: > > diff --git a/src/box/sql/build.c b/src/box/sql/build.c > index 92f3cb6..ce5878c 100644 > --- a/src/box/sql/build.c > +++ b/src/box/sql/build.c > @@ -2129,18 +2129,32 @@ sqliteViewResetAll(sqlite3 * db) > * Remove entries from the _sql_stat1 and _sql_stat4 > * system spaces after a DROP INDEX or DROP TABLE command. > * > - * @param pParse Parsing context. > - * @param zType Type of entry to be deleted: > - * 'idx' or 'tbl' string literal. > - * @param zName Name of index or table. > + * @param parse The parsing context. > + * @param table_name The table to be dropped or > + * the table that contains index to be dropped. > + * @param idx_name Index to be dropped. > */ > static void > -sql_clear_stat_spaces(Parse * pParse, const char *zType, const char > *zName) > +sql_clear_stat_spaces(Parse *parse, const char *table_name, > + const char *idx_name) > { > - sqlite3NestedParse(pParse, "DELETE FROM \"_sql_stat1\" WHERE \"%s\"=3D%= Q", > - zType, zName); > - sqlite3NestedParse(pParse, "DELETE FROM \"_sql_stat4\" WHERE \"%s\"=3D%= Q", > - zType, zName); > + if (idx_name !=3D NULL) { > + sqlite3NestedParse(parse, > + "DELETE FROM \"_sql_stat1\" WHERE (\"idx\"=3D%Q AND " > + "\"tbl\"=3D%Q)", > + idx_name, table_name); > + sqlite3NestedParse(parse, > + "DELETE FROM \"_sql_stat4\" WHERE (\"idx\"=3D%Q AND " > + "\"tbl\"=3D%Q)", > + idx_name, table_name); > + } else { > + sqlite3NestedParse(parse, > + "DELETE FROM \"_sql_stat1\" WHERE \"tbl\"=3D%Q", > + table_name); > + sqlite3NestedParse(parse, > + "DELETE FROM \"_sql_stat4\" WHERE \"tbl\"=3D%Q", > + table_name); > + } > } > > /** > @@ -2325,7 +2339,7 @@ sql_drop_table(struct Parse *parse_context, struct > SrcList *table_name_list, > * tuple with corresponding space_id from _space. > */ > > - sql_clear_stat_spaces(parse_context, "tbl", space_name); > + sql_clear_stat_spaces(parse_context, space_name, NULL); > struct Table *tab =3D sqlite3HashFind(&db->pSchema->tblHash, space_name= ); > sqlite3FkDropTable(parse_context, table_name_list, tab); > sql_code_drop_table(parse_context, space, is_view); > @@ -3328,7 +3342,7 @@ sql_drop_index(struct Parse *parse_context, struct > SrcList *index_name_list, > * But firstly, delete statistics since schema > * changes after DDL. > */ > - sql_clear_stat_spaces(parse_context, "idx", index->def->name); > + sql_clear_stat_spaces(parse_context, table_name, index->def->name); > int record_reg =3D ++parse_context->nMem; > int space_id_reg =3D ++parse_context->nMem; > sqlite3VdbeAddOp2(v, OP_Integer, space_id, space_id_reg); > > > =D1=81=D0=B1, 14 =D0=B0=D0=BF=D1=80. 2018 =D0=B3. =D0=B2 11:13, n.pettik = : > >> >> On 14 Apr 2018, at 07:29, Hollow111 wrote: >> >> Hello. I'd like to ask about 'one kind of corrections=E2=80=9D. >> >> >> >>> Arguments which you carry to the next line, should start right below >>> previous: >>> >>> void f(x int, =E2=80=A6. >>> y char, =E2=80=A6. >>> z double =E2=80=A6); >>> >> >> I couldnt find this in "C style guide" ( >> https://tarantool.io/en/doc/2.0/dev_guide/c_style_guide.html) >> Moreover according to this guide: >> "Outside of comments, documentation and except in Kconfig, spaces are >> never used for indentation...". >> Which means we're supposed to violate this rule >> >> >> In fact, they are used. Probably, we should update and clarify this poin= t >> in docs. >> You use tabs as much as possible. To precisely align argument lists, you >> have >> to use spaces: >> >> return_value very_long_function_name_bla_bla_bla(int first_argument, >> int second_argument) >> >> To make =E2=80=99second_argument=E2=80=99 be under first, you should use= 8 tabs + 1 space. >> Overall, you can inspect other source files from box/ to understand how >> source files should be formatted. Also, I advise you to make spaces and >> tabs visible. >> For instance, see how it was done in box/space.c 106 : space_create() >> >> in case first argument is positioned not on the same range >> from left corner of screen as any amount of 8-character tabs. >> Maybe I'm wrong at smth but I'd like to have an explanation. >> >> >> --000000000000f5afdd0569dd4f76 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I'm sorry have just noticed few mistakes.
Changed = it:


diff --git a/src/box/sql/b= uild.c b/src/box/sql/build.c
index 92f3cb6..c6185e4 100644
<= div>--- a/src/box/sql/build.c
+++ b/src/box/sql/build.c
@@ -2129,18 +2129,36 @@ sqliteViewResetAll(sqlite3 * db)
=C2=A0 = * Remove entries from the _sql_stat1 and _sql_stat4
=C2=A0 * syst= em spaces after a DROP INDEX or DROP TABLE command.
=C2=A0 *
- * @param pParse Parsing context.
- * @param zType Type of= entry to be deleted:
- * 'idx' or 'tbl' string literal.
- * @param zName= Name of index or table.
+ * @param parse=C2=A0 =C2=A0 =C2=A0 The= parsing context.
+ * @param table_name The table to be dropped o= r
+ *=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0the table that contains index to be dropped.
+ * @param= idx_name=C2=A0 =C2=A0Index to be dropped.
=C2=A0 */
= =C2=A0static void
-sql_clear_stat_spaces(Parse * pParse, const ch= ar *zType, const char *zName)
+sql_clear_stat_spaces(Parse *parse= , const char *table_name,
+ =C2=A0 =C2=A0 =C2=A0 const char *idx_name)
=C2=A0{
-= sqlite3NestedParse(pParse, "DE= LETE FROM \"_sql_stat1\" WHERE \"%s\"=3D%Q",
=
- =C2=A0 =C2=A0zType, zName);=
- sqlite3NestedParse(pPar= se, "DELETE FROM \"_sql_stat4\" WHERE \"%s\"=3D%Q&= quot;,
- =C2=A0 =C2=A0zT= ype, zName);
+ if (idx_nam= e !=3D NULL) {
+ sqlite3N= estedParse(parse,
+ =C2= =A0 =C2=A0"DELETE FROM \"_sql_stat1\" "
+ =C2=A0 =C2=A0"WHERE (\"idx= \"=3D%Q AND "
+ =C2=A0 =C2=A0"\"tbl\"=3D%Q)",
+ =C2=A0 =C2=A0idx_name, table_name);
+ sqlite3NestedParse(parse,
+ =C2=A0 =C2=A0"DELETE= FROM \"_sql_stat4\" "
+ =C2=A0 =C2=A0"WHERE (\"idx\"=3D%Q AND "= ;
+ =C2=A0 =C2=A0"= \"tbl\"=3D%Q)",
+ = =C2=A0 =C2=A0idx_name, table_name);
+ } else {
+ = sqlite3NestedParse(parse,
+ =C2=A0 =C2=A0"DELETE FROM \"_sql_stat1\" "=
+ =C2=A0 =C2=A0"W= HERE \"tbl\"=3D%Q",
+ =C2=A0 =C2=A0table_name);
+ sqlite3NestedParse(parse,
+ =C2=A0 =C2=A0"DELETE FROM \"_sql_stat4\&quo= t; "
+ =C2=A0 =C2= =A0"WHERE \"tbl\"=3D%Q",
+ =C2=A0 =C2=A0table_name);
+ }
=C2=A0}

=D0=B2=D1=81, 15 =D0=B0=D0=BF=D1=80. 20= 18 =D0=B3. =D0=B2 9:09, Hollow111 <hollow653@gmail.com>:
Hello. Changes have been made.=C2=A0
Diff:

<= /div>
diff --git a/src/box/sql/build.c b/src/box/sql/build.c
=
index 92f3cb6..ce5878c 100644
--- a/src/box/sql/build.c
+++ b/src/box/sql/build.c
@@ -2129,18 +2129,32 @@ sqliteVie= wResetAll(sqlite3 * db)
=C2=A0 * Remove entries from the _sql_sta= t1 and _sql_stat4
=C2=A0 * system spaces after a DROP INDEX or DR= OP TABLE command.
=C2=A0 *
- * @param pParse Parsing co= ntext.
- * @param zType Type of entry to be deleted:
- = * 'idx' or 'tbl&#= 39; string literal.
- * @param zName Name of index or table.
+ * @param parse=C2=A0 =C2=A0 =C2=A0 The parsing context.
+= * @param table_name The table to be dropped or
+ *=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0the table that conta= ins index to be dropped.
+ * @param idx_name=C2=A0 =C2=A0Index to= be dropped.
=C2=A0 */
=C2=A0static void
-sql= _clear_stat_spaces(Parse * pParse, const char *zType, const char *zName)
+sql_clear_stat_spaces(Parse *parse, const char *table_name,
<= div>+ =C2=A0 =C2=A0 =C2=A0 con= st char *idx_name)
=C2=A0{
- sqlite3NestedParse(pParse, "DELETE FROM \"_sql_= stat1\" WHERE \"%s\"=3D%Q",
- =C2=A0 =C2=A0zType, zName);
- sqlite3NestedParse(pParse, "DE= LETE FROM \"_sql_stat4\" WHERE \"%s\"=3D%Q",
=
- =C2=A0 =C2=A0zType, zN= ame);
+ if (idx_name = !=3D NULL) {
+ sqlit= e3NestedParse(parse,
+ =C2=A0 =C2=A0"DELETE FROM \"_sql_stat1\" WHERE (\"= idx\"=3D%Q AND "
+= =C2=A0 =C2=A0"\"tbl\"=3D%Q)",
+ =C2=A0 =C2=A0idx_name, table_n= ame);
+ sqlite3Neste= dParse(parse,
+ = =C2=A0 =C2=A0"DELETE FROM \"_sql_stat4\" WHERE (\"idx\&= quot;=3D%Q AND "
+ <= /span>=C2=A0 =C2=A0"\"tbl\"=3D%Q)",
+ =C2=A0 =C2=A0idx_name, table_name);=
+ } else {
+ sqlite3NestedParse(parse,
+ =C2=A0 =C2=A0&quo= t;DELETE FROM \"_sql_stat1\" WHERE \"tbl\"=3D%Q",<= /div>
+ =C2=A0 =C2=A0tab= le_name);
+ sqlite3N= estedParse(parse,
+ =C2=A0 =C2=A0"DELETE FROM \"_sql_stat4\" WHERE \"tbl\= "=3D%Q",
+ =C2=A0 =C2=A0table_name);
+ }
=C2=A0}
=C2=A0
=C2=A0/**
@@ -2325,7 +2339,7 @@ sql_drop_table(struct Parse *parse_context, struct = SrcList *table_name_list,
=C2=A0 *=C2=A0 =C2=A0 tuple with corresponding space_id from _space.<= /div>
=C2=A0 */
= =C2=A0
- sql_clear_st= at_spaces(parse_context, "tbl", space_name);
+ sql_clear_stat_spaces(parse_context, sp= ace_name, NULL);
=C2=A0 struct Table *tab =3D sqlite3HashFind(&db->pSchema->tblHash, s= pace_name);
=C2=A0 sq= lite3FkDropTable(parse_context, table_name_list, tab);
=C2=A0 sql_code_drop_table(parse_context,= space, is_view);
@@ -3328,7 +3342,7 @@ sql_drop_index(struct Par= se *parse_context, struct SrcList *index_name_list,
=C2=A0 * But firstly, delete statistics sin= ce schema
=C2=A0 * c= hanges after DDL.
=C2=A0 */
- sql_clear_s= tat_spaces(parse_context, "idx", index->def->name);
+ sql_clear_stat_spaces(pars= e_context, table_name, index->def->name);
=C2=A0 int record_reg =3D ++parse_context->nM= em;
=C2=A0 int space_= id_reg =3D ++parse_context->nMem;
=C2=A0 sqlite3VdbeAddOp2(v, OP_Integer, space_id, space_id_= reg);


=D1=81=D0=B1, 14 =D0=B0=D0=BF=D1=80. 2018 =D0=B3. =D0=B2 11:13, = n.pettik <ko= rablev@tarantool.org>:

On 1= 4 Apr 2018, at 07:29, Hollow111 <hollow653@gmail.com> wrote:

Hello. I'd like to ask about 'one kind of corrections=E2= =80=9D.


Arguments which yo= u carry to the next line, should start right below previous:

void f(= x int, =E2=80=A6.
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0= y char, =E2=80=A6.
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0z double =E2=80=A6);

I couldnt find th= is in=C2=A0=C2=A0&quo= t;C style guide" (https://tarantool.io/en/doc/2.0/dev_= guide/c_style_guide.html)
Moreover according to this g= uide:
"Outside of comments, documentation and except in Kcon= fig, spaces are never used for indentation...".
Which means = we're supposed to violate this rule

In fact, they are used. Probably, we should upda= te and clarify this point in docs.
You use tabs as much as possib= le. To precisely align argument lists, you have
to use spaces:

return_value very_long_function_name_bla_bla_bl= a(int first_argument,
int second_argument)

To make =E2=80=99second_arg= ument=E2=80=99 be under first, you should use 8 tabs + 1 space.
O= verall, you can inspect other source files from box/ to understand how
source files should be formatted. Also, I advise you to make spaces a= nd tabs visible.
For instance, see how it was done in box/space.c= 106 : space_create()

in case first argument is positio= ned not on the same range=C2=A0
from left corner of screen as any= amount of 8-character tabs.=C2=A0
Maybe I'm wrong at smth bu= t I'd like to have an explanation.

--000000000000f5afdd0569dd4f76--