[tarantool-patches] [PATCH v1 1/1] sql: test to check that FK constraint does not fail

imeevma at tarantool.org imeevma at tarantool.org
Wed Dec 19 22:23:19 MSK 2018


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





More information about the Tarantool-patches mailing list