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 5B29428A13 for ; Mon, 20 Aug 2018 12:49:57 -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 bABlDREApLMJ for ; Mon, 20 Aug 2018 12:49:57 -0400 (EDT) Received: from smtp62.i.mail.ru (smtp62.i.mail.ru [217.69.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 1AD6A26A0D for ; Mon, 20 Aug 2018 12:49:57 -0400 (EDT) From: Kirill Yukhin Subject: [tarantool-patches] [PATCH 2/2] sql: take sql field in index_opts_cmp Date: Mon, 20 Aug 2018 19:49:45 +0300 Message-Id: <2fc838acfd7806a467bbe416ab0edeedf2efd71d.1534783275.git.kyukhin@tarantool.org> In-Reply-To: References: In-Reply-To: References: 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, Kirill Yukhin 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 | 8 ++++++++ test/sql/gh-3613-idx-alter-update-2.result | 28 ++++++++++++++++++++++++++++ test/sql/gh-3613-idx-alter-update-2.test.lua | 16 ++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 test/sql/gh-3613-idx-alter-update-2.result create mode 100644 test/sql/gh-3613-idx-alter-update-2.test.lua 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; + + if ((o1->sql == NULL) != (o2->sql == NULL)) + return 1; + if ((o1->sql != NULL) && (o2->sql != NULL)) { + int rc = strcmp(o1->sql, o2->sql); + if (rc != 0) + return rc; + } 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') -- 2.16.2