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 67AB021DB3 for ; Wed, 19 Dec 2018 14:23:21 -0500 (EST) 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 WSIsHYVIKk_j for ; Wed, 19 Dec 2018 14:23:21 -0500 (EST) Received: from smtp63.i.mail.ru (smtp63.i.mail.ru [217.69.128.43]) (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 1E8EA21CFB for ; Wed, 19 Dec 2018 14:23:21 -0500 (EST) From: imeevma@tarantool.org Subject: [tarantool-patches] [PATCH v1 1/1] sql: test to check that FK constraint does not fail Date: Wed, 19 Dec 2018 22:23:19 +0300 Message-Id: <27b3be7947c199d2b689c3a2c1401bbb9086756e.1545247320.git.imeevma@gmail.com> 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, tarantool-patches@freelists.org The issue has been closed by commit 3eb796a. To check that everything is working fine, a test has been added. Closes #3644 --- https://github.com/tarantool/tarantool/issues/3644 https://github.com/tarantool/tarantool/tree/imeevma/gh-3644-foreign-key-update-with-unicode_ci test/sql/collation.result | 64 +++++++++++++++++++++++++++++++++++++++++++++ test/sql/collation.test.lua | 24 +++++++++++++++++ 2 files changed, 88 insertions(+) diff --git a/test/sql/collation.result b/test/sql/collation.result index 148a1a1..c69510f 100644 --- a/test/sql/collation.result +++ b/test/sql/collation.result @@ -261,3 +261,67 @@ box.session.su('admin') box.schema.user.drop('tmp') --- ... +-- gh-3644 Foreign key update fails with "unicode_ci". +-- Check that foreign key update doesn't fail with "unicode_ci". +box.sql.execute('CREATE TABLE t0 (s1 CHAR(5) COLLATE "unicode_ci" PRIMARY KEY);') +--- +... +box.sql.execute('CREATE TABLE t1 (s1 INT PRIMARY KEY, s0 CHAR(5) COLLATE "unicode_ci" REFERENCES t0(s1));') +--- +... +box.sql.execute("INSERT INTO t0 VALUES ('a');") +--- +... +box.sql.execute("INSERT INTO t1 VALUES (1,'a');") +--- +... +-- Should't fail. +box.sql.execute("UPDATE t0 SET s1 = 'A';") +--- +... +box.sql.execute("SELECT * FROM t0;") +--- +- - ['A'] +... +box.sql.execute("SELECT * FROM t1;") +--- +- - [1, 'a'] +... +box.sql.execute("DROP TABLE t1;") +--- +... +box.sql.execute("DROP TABLE t0;") +--- +... +-- Check that foreign key update fails with default collation. +box.sql.execute('CREATE TABLE t0 (s1 CHAR(5) PRIMARY KEY);') +--- +... +box.sql.execute('CREATE TABLE t1 (s1 INT PRIMARY KEY, s0 CHAR(5) REFERENCES t0(s1));') +--- +... +box.sql.execute("INSERT INTO t0 VALUES ('a');") +--- +... +box.sql.execute("INSERT INTO t1 VALUES (1,'a');") +--- +... +-- Should fail. +box.sql.execute("UPDATE t0 SET s1 = 'A';") +--- +- error: FOREIGN KEY constraint failed +... +box.sql.execute("SELECT * FROM t1;") +--- +- - [1, 'a'] +... +box.sql.execute("SELECT * FROM t0;") +--- +- - ['a'] +... +box.sql.execute("DROP TABLE t1;") +--- +... +box.sql.execute("DROP TABLE t0;") +--- +... diff --git a/test/sql/collation.test.lua b/test/sql/collation.test.lua index ade3a69..4ad2d5e 100644 --- a/test/sql/collation.test.lua +++ b/test/sql/collation.test.lua @@ -102,3 +102,27 @@ box.session.su('tmp') box.sql.execute("pragma collation_list") box.session.su('admin') box.schema.user.drop('tmp') + +-- gh-3644 Foreign key update fails with "unicode_ci". +-- Check that foreign key update doesn't fail with "unicode_ci". +box.sql.execute('CREATE TABLE t0 (s1 CHAR(5) COLLATE "unicode_ci" PRIMARY KEY);') +box.sql.execute('CREATE TABLE t1 (s1 INT PRIMARY KEY, s0 CHAR(5) COLLATE "unicode_ci" REFERENCES t0(s1));') +box.sql.execute("INSERT INTO t0 VALUES ('a');") +box.sql.execute("INSERT INTO t1 VALUES (1,'a');") +-- Should't fail. +box.sql.execute("UPDATE t0 SET s1 = 'A';") +box.sql.execute("SELECT * FROM t0;") +box.sql.execute("SELECT * FROM t1;") +box.sql.execute("DROP TABLE t1;") +box.sql.execute("DROP TABLE t0;") +-- Check that foreign key update fails with default collation. +box.sql.execute('CREATE TABLE t0 (s1 CHAR(5) PRIMARY KEY);') +box.sql.execute('CREATE TABLE t1 (s1 INT PRIMARY KEY, s0 CHAR(5) REFERENCES t0(s1));') +box.sql.execute("INSERT INTO t0 VALUES ('a');") +box.sql.execute("INSERT INTO t1 VALUES (1,'a');") +-- Should fail. +box.sql.execute("UPDATE t0 SET s1 = 'A';") +box.sql.execute("SELECT * FROM t1;") +box.sql.execute("SELECT * FROM t0;") +box.sql.execute("DROP TABLE t1;") +box.sql.execute("DROP TABLE t0;") -- 2.7.4