From: Kirill Yukhin <kyukhin@tarantool.org>
To: "n.pettik" <korablev@tarantool.org>
Cc: tarantool-patches@freelists.org
Subject: [tarantool-patches] Re: [PATCH 2/2] sql: take sql field in index_opts_cmp
Date: Tue, 21 Aug 2018 15:30:53 +0300 [thread overview]
Message-ID: <20180821123053.h2o4ndurvkzvyuyx@tarantool.org> (raw)
In-Reply-To: <07122CA6-A039-4D71-B535-718AD11B7171@tarantool.org>
Hello Nikita,
Thanks for review! My answers inlined, updated patch in the bottom of
the messaga, branch force-pushed.
On 21 авг 13:26, n.pettik wrote:
> > diff --git a/src/box/index_def.h b/src/box/index_def.h
> > index 48a7820..8960e3d 100644
> > --- a/src/box/index_def.h
> > +++ b/src/box/index_def.h
> > @@ -212,6 +212,14 @@ index_opts_cmp(const struct index_opts *o1, const struct index_opts *o2)
> > return o1->run_size_ratio < o2->run_size_ratio ? -1 : 1;
> > if (o1->bloom_fpr != o2->bloom_fpr)
> > return o1->bloom_fpr < o2->bloom_fpr ? -1 : 1;
> > +
>
> Nitpicking: don’t put extra new line: it breaks whole function look.
Removed.
> > + if ((o1->sql == NULL) != (o2->sql == NULL))
> > + return 1;
> > + if ((o1->sql != NULL) && (o2->sql != NULL)) {
>
> Nitpicking: after previous check o1->sql and o2->sql are both NULL or not.
> So I guess only one check is enough: if (o1->sql != NULL).
Good catch. Fixed.
> > + int rc = strcmp(o1->sql, o2->sql);
> > + if (rc != 0)
> > + return rc;
>
> Why not simply return strcmp()?
Done.
> > + }
> > return 0;
> > }
> >
> > diff --git a/test/sql/gh-3613-idx-alter-update-2.test.lua b/test/sql/gh-3613-idx-alter-update-2.test.lua
> > new file mode 100644
> > index 0000000..e2beb7a
> > --- /dev/null
> > +++ b/test/sql/gh-3613-idx-alter-update-2.test.lua
>
> Can you merge this test file with previous one?
> I strongly dislike the fact that such simple tests are put in
> separate files. Even though we already have sql-tap/alter.test.lua.
No. There's no reason for economy in number of files. There're tons
of pros when each and every regression test lives in separate file, or
even files. I'll update SOP stating that.
--
Regards, Kirill Yukhin
commit a2c7fb02f330819d31591273dbf9ec9e60a5f5df
Author: Kirill Yukhin <kyukhin@tarantool.org>
Date: Mon Aug 20 19:38:06 2018 +0300
sql: take sql field in index_opts_cmp
After gh-3613 is imlemented a hidden bug was uncovered:
during, e.g. recovery opts.sql field didn't take into account
marking corresponding xlog entry useless. Fix that by comparing
mentioned field of new and old entries.
Follow up of #3613
---
src/box/index_def.h | 4 ++++
test/sql/gh-3613-idx-alter-update-2.result | 28 ++++++++++++++++++++++++++++
test/sql/gh-3613-idx-alter-update-2.test.lua | 16 ++++++++++++++++
3 files changed, 48 insertions(+)
diff --git a/src/box/index_def.h b/src/box/index_def.h
index 48a7820..273b8cb 100644
--- a/src/box/index_def.h
+++ b/src/box/index_def.h
@@ -212,6 +212,10 @@ index_opts_cmp(const struct index_opts *o1, const struct index_opts *o2)
return o1->run_size_ratio < o2->run_size_ratio ? -1 : 1;
if (o1->bloom_fpr != o2->bloom_fpr)
return o1->bloom_fpr < o2->bloom_fpr ? -1 : 1;
+ if ((o1->sql == NULL) != (o2->sql == NULL))
+ return 1;
+ if (o1->sql != NULL)
+ return strcmp(o1->sql, o2->sql);
return 0;
}
diff --git a/test/sql/gh-3613-idx-alter-update-2.result b/test/sql/gh-3613-idx-alter-update-2.result
new file mode 100644
index 0000000..234336c
--- /dev/null
+++ b/test/sql/gh-3613-idx-alter-update-2.result
@@ -0,0 +1,28 @@
+test_run = require('test_run').new()
+---
+...
+engine = test_run:get_cfg('engine')
+---
+...
+box.sql.execute('pragma sql_default_engine=\''..engine..'\'')
+---
+...
+box.sql.execute('CREATE TABLE t (s1 INT PRIMARY KEY)')
+---
+...
+box.sql.execute('CREATE INDEX i ON t (s1)')
+---
+...
+box.sql.execute('ALTER TABLE t RENAME TO j3')
+---
+...
+-- After gh-3613 fix, bug in cmp_def was discovered.
+-- Comparison didn't take .opts.sql into account.
+test_run:cmd('restart server default')
+box.sql.execute('DROP INDEX i ON j3')
+---
+...
+-- Cleanup
+box.sql.execute('DROP TABLE j3')
+---
+...
diff --git a/test/sql/gh-3613-idx-alter-update-2.test.lua b/test/sql/gh-3613-idx-alter-update-2.test.lua
new file mode 100644
index 0000000..e2beb7a
--- /dev/null
+++ b/test/sql/gh-3613-idx-alter-update-2.test.lua
@@ -0,0 +1,16 @@
+test_run = require('test_run').new()
+engine = test_run:get_cfg('engine')
+box.sql.execute('pragma sql_default_engine=\''..engine..'\'')
+
+box.sql.execute('CREATE TABLE t (s1 INT PRIMARY KEY)')
+box.sql.execute('CREATE INDEX i ON t (s1)')
+box.sql.execute('ALTER TABLE t RENAME TO j3')
+
+-- After gh-3613 fix, bug in cmp_def was discovered.
+-- Comparison didn't take .opts.sql into account.
+test_run:cmd('restart server default')
+
+box.sql.execute('DROP INDEX i ON j3')
+
+-- Cleanup
+box.sql.execute('DROP TABLE j3')
next prev parent reply other threads:[~2018-08-21 12:30 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-20 16:49 [tarantool-patches] [PATCH 0/2] sql: update inexes after table rename Kirill Yukhin
2018-08-20 16:49 ` [tarantool-patches] [PATCH 1/2] sql: after table rename properly update indexes Kirill Yukhin
2018-08-21 10:26 ` [tarantool-patches] " n.pettik
2018-08-21 12:20 ` Kirill Yukhin
2018-08-21 20:38 ` n.pettik
2018-08-22 6:39 ` Kirill Yukhin
2018-08-20 16:49 ` [tarantool-patches] [PATCH 2/2] sql: take sql field in index_opts_cmp Kirill Yukhin
2018-08-21 10:26 ` [tarantool-patches] " n.pettik
2018-08-21 12:30 ` Kirill Yukhin [this message]
2018-08-21 20:41 ` n.pettik
2018-08-22 6:47 ` [tarantool-patches] Re: [PATCH 0/2] sql: update inexes after table rename 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=20180821123053.h2o4ndurvkzvyuyx@tarantool.org \
--to=kyukhin@tarantool.org \
--cc=korablev@tarantool.org \
--cc=tarantool-patches@freelists.org \
--subject='[tarantool-patches] Re: [PATCH 2/2] sql: take sql field in index_opts_cmp' \
/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