Tarantool development patches archive
 help / color / mirror / Atom feed
From: imeevma@tarantool.org
To: korablev@tarantool.org, tarantool-patches@freelists.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	[thread overview]
Message-ID: <27b3be7947c199d2b689c3a2c1401bbb9086756e.1545247320.git.imeevma@gmail.com> (raw)

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

             reply	other threads:[~2018-12-19 19:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-19 19:23 imeevma [this message]
2018-12-20  7:12 ` [tarantool-patches] " n.pettik
2018-12-21  7:40 ` 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=27b3be7947c199d2b689c3a2c1401bbb9086756e.1545247320.git.imeevma@gmail.com \
    --to=imeevma@tarantool.org \
    --cc=korablev@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [tarantool-patches] [PATCH v1 1/1] sql: test to check that FK constraint does not fail' \
    /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