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 288FF29633 for ; Thu, 7 Mar 2019 08:14:11 -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 vRBQeao4iC77 for ; Thu, 7 Mar 2019 08:14:10 -0500 (EST) Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [94.100.181.251]) (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 964F326B45 for ; Thu, 7 Mar 2019 08:14:10 -0500 (EST) From: Nikita Pettik Subject: [tarantool-patches] [PATCH 2/4] sql: remove support of CHAR type from parser Date: Thu, 7 Mar 2019 16:14:02 +0300 Message-Id: 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: tarantool-patches@freelists.org Cc: v.shpilevoy@tarantool.org, Nikita Pettik Since now no checks connected with length of string are performed, it might be misleading to allow specifying this type. Instead, users must rely on VARCHAR type. Part of #4019 --- src/box/sql/parse.y | 10 +--------- test/sql-tap/autoinc.test.lua | 2 +- test/sql-tap/collation.test.lua | 2 +- test/sql-tap/eqp.test.lua | 4 ++-- test/sql-tap/fkey1.test.lua | 4 ++-- test/sql-tap/resolver01.test.lua | 4 ++-- test/sql-tap/select6.test.lua | 6 +++--- test/sql-tap/table.test.lua | 6 +++--- test/sql-tap/where2.test.lua | 4 ++-- test/sql/collation.result | 10 +++++----- test/sql/collation.test.lua | 10 +++++----- test/sql/row-count.result | 4 ++-- test/sql/row-count.test.lua | 4 ++-- 13 files changed, 31 insertions(+), 39 deletions(-) diff --git a/src/box/sql/parse.y b/src/box/sql/parse.y index fb3639f3f..92788ceb8 100644 --- a/src/box/sql/parse.y +++ b/src/box/sql/parse.y @@ -1487,21 +1487,13 @@ typedef(A) ::= BLOB_KW . { A.type = FIELD_TYPE_SCALAR; } typedef(A) ::= DATETIME . { A.type = FIELD_TYPE_NUMBER; } */ -%type char_len {int} -typedef(A) ::= CHAR . { - A.type = FIELD_TYPE_STRING; -} char_len(A) ::= LP INTEGER(B) RP . { (void) A; (void) B; } -typedef(A) ::= CHAR char_len(B) . { - A.type = FIELD_TYPE_STRING; - (void) B; -} - +%type char_len {int} typedef(A) ::= VARCHAR char_len(B) . { A.type = FIELD_TYPE_STRING; (void) B; diff --git a/test/sql-tap/autoinc.test.lua b/test/sql-tap/autoinc.test.lua index 5ec9fd632..dc2f60e15 100755 --- a/test/sql-tap/autoinc.test.lua +++ b/test/sql-tap/autoinc.test.lua @@ -805,7 +805,7 @@ test:do_test( test:do_catchsql_test( "autoinc-gh-3670", [[ - CREATE TABLE t1 (s1 INT PRIMARY KEY AUTOINCREMENT, s2 CHAR(10)); + CREATE TABLE t1 (s1 INT PRIMARY KEY AUTOINCREMENT, s2 VARCHAR(10)); INSERT INTO t1 VALUES (1, 'a'); INSERT INTO t1 SELECT s2, s2 FROM t1; ]], { diff --git a/test/sql-tap/collation.test.lua b/test/sql-tap/collation.test.lua index 1e55b0092..094d02c42 100755 --- a/test/sql-tap/collation.test.lua +++ b/test/sql-tap/collation.test.lua @@ -209,7 +209,7 @@ local like_testcases = { {"2.0", [[ - CREATE TABLE tx1 (s1 CHAR(5) PRIMARY KEY); + CREATE TABLE tx1 (s1 VARCHAR(5) PRIMARY KEY); CREATE INDEX I1 on tx1(s1 collate "unicode_ci"); INSERT INTO tx1 VALUES('aaa'); INSERT INTO tx1 VALUES('Aab'); diff --git a/test/sql-tap/eqp.test.lua b/test/sql-tap/eqp.test.lua index 5ef9999d8..2aa2d9675 100755 --- a/test/sql-tap/eqp.test.lua +++ b/test/sql-tap/eqp.test.lua @@ -727,8 +727,8 @@ test:drop_all_tables() test:do_execsql_test( 7.0, [[ - CREATE TABLE t1(idt1 INT primary key, a INT, b INT, ex CHAR(100)); - CREATE TABLE t2(idt2 INT primary key, a INT, b INT, ex CHAR(100)); + CREATE TABLE t1(idt1 INT primary key, a INT, b INT, ex VARCHAR(100)); + CREATE TABLE t2(idt2 INT primary key, a INT, b INT, ex VARCHAR(100)); CREATE INDEX i1 ON t2(a); ]]) diff --git a/test/sql-tap/fkey1.test.lua b/test/sql-tap/fkey1.test.lua index 557e557a5..0464f2dcc 100755 --- a/test/sql-tap/fkey1.test.lua +++ b/test/sql-tap/fkey1.test.lua @@ -241,9 +241,9 @@ test:do_select_tests( {"0", [[ CREATE TABLE T12 (A INTEGER PRIMARY KEY, - B CHAR(5) UNIQUE); + B VARCHAR(5) UNIQUE); CREATE TABLE T13 (A INTEGER PRIMARY KEY, - B CHAR(5) UNIQUE, + B VARCHAR(5) UNIQUE, FOREIGN KEY (B) REFERENCES T12 (B) ON UPDATE SET NULL); INSERT INTO T12 VALUES (1,'a'); INSERT INTO T13 VALUES (1,'a'); diff --git a/test/sql-tap/resolver01.test.lua b/test/sql-tap/resolver01.test.lua index d40e49982..aa383b34b 100755 --- a/test/sql-tap/resolver01.test.lua +++ b/test/sql-tap/resolver01.test.lua @@ -229,7 +229,7 @@ test:do_test( "resolver01-4.1", function () test:execsql([[ - CREATE TABLE t4(m CHAR(2) primary key); + CREATE TABLE t4(m VARCHAR(2) primary key); INSERT INTO t4 VALUES('az'); INSERT INTO t4 VALUES('by'); INSERT INTO t4 VALUES('cx'); @@ -257,7 +257,7 @@ test:do_test( test:do_execsql_test( "resolver01-5.1", [[ - CREATE TABLE t5(m CHAR(2) primary key); + CREATE TABLE t5(m VARCHAR(2) primary key); INSERT INTO t5 VALUES('ax'); INSERT INTO t5 VALUES('bx'); INSERT INTO t5 VALUES('cy'); diff --git a/test/sql-tap/select6.test.lua b/test/sql-tap/select6.test.lua index 49652a5a4..7f6cc7939 100755 --- a/test/sql-tap/select6.test.lua +++ b/test/sql-tap/select6.test.lua @@ -1059,8 +1059,8 @@ test:do_execsql_test( [[ DROP TABLE t1; DROP TABLE t2; - CREATE TABLE t1 (s1 INT PRIMARY KEY, u CHAR UNIQUE); - CREATE TABLE t2 (s1 INT PRIMARY KEY, u CHAR); + CREATE TABLE t1 (s1 INT PRIMARY KEY, u VARCHAR(1) UNIQUE); + CREATE TABLE t2 (s1 INT PRIMARY KEY, u VARCHAR(1)); INSERT INTO t1 VALUES (1,''); INSERT INTO t2 VALUES (1,''); SELECT COUNT(*) FROM t1 WHERE u IN @@ -1075,7 +1075,7 @@ test:do_execsql_test( 12.2, [[ DROP TABLE t1; - CREATE TABLE t1 (s1 INT PRIMARY KEY, u CHAR); + CREATE TABLE t1 (s1 INT PRIMARY KEY, u VARCHAR(1)); INSERT INTO t1 VALUES (1,''); SELECT COUNT(*) FROM t1 WHERE u IN (SELECT u FROM t2 WHERE u IN (SELECT u FROM t1)); diff --git a/test/sql-tap/table.test.lua b/test/sql-tap/table.test.lua index b1ea27878..9c4048d4c 100755 --- a/test/sql-tap/table.test.lua +++ b/test/sql-tap/table.test.lua @@ -228,7 +228,7 @@ test:do_test( -- local big_table = [[CREATE TABLE big( f1 varchar(20), - f2 char(10), + f2 varchar(10), f3 varchar(30) primary key, f4 text, f5 text, @@ -893,7 +893,7 @@ test:do_execsql_test( CREATE TABLE t7( a integer primary key, b numeric(5,10), - c char(8), + c VARCHAR(8), d VARCHAR(9), e blob, f BLOB, @@ -1405,7 +1405,7 @@ test:do_execsql_test( [[ CREATE TABLE T23( id INT PRIMARY KEY, - u CHAR + u VARCHAR(1) ); ]], { -- diff --git a/test/sql-tap/where2.test.lua b/test/sql-tap/where2.test.lua index 2dd8b84c4..8eaf4053d 100755 --- a/test/sql-tap/where2.test.lua +++ b/test/sql-tap/where2.test.lua @@ -631,7 +631,7 @@ test:do_test( "where2-6.7", function() test:execsql [[ - CREATE TABLE t2249a(a TEXT PRIMARY KEY, x CHAR(100)); + CREATE TABLE t2249a(a TEXT PRIMARY KEY, x VARCHAR(100)); CREATE TABLE t2249b(b INTEGER PRIMARY KEY); INSERT INTO t2249a(a) VALUES('0123'); INSERT INTO t2249b VALUES(123); @@ -1273,7 +1273,7 @@ test:do_execsql_test( "where2-12.1", function () local data = test:execsql([[ - CREATE TABLE t12(x INTEGER PRIMARY KEY, y INT, z CHAR(100)); + CREATE TABLE t12(x INTEGER PRIMARY KEY, y INT, z VARCHAR(100)); CREATE INDEX t12y ON t12(y); EXPLAIN QUERY PLAN SELECT a.x, b.x diff --git a/test/sql/collation.result b/test/sql/collation.result index daea35543..7e5b60d9a 100644 --- a/test/sql/collation.result +++ b/test/sql/collation.result @@ -34,7 +34,7 @@ box.sql.execute("SELECT 1 LIMIT 1 COLLATE BINARY, 1;") ... -- gh-3052: upper/lower support only default locale -- For tr-TR result depends on collation -box.sql.execute([[CREATE TABLE tu (descriptor CHAR(50) PRIMARY KEY, letter CHAR(50))]]); +box.sql.execute([[CREATE TABLE tu (descriptor VARCHAR(50) PRIMARY KEY, letter VARCHAR(50))]]); --- ... box.internal.collation.create('TURKISH', 'ICU', 'tr-TR', {strength='primary'}); @@ -263,10 +263,10 @@ 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" UNIQUE, id INT PRIMARY KEY AUTOINCREMENT);') +box.sql.execute('CREATE TABLE t0 (s1 VARCHAR(5) COLLATE "unicode_ci" UNIQUE, id INT PRIMARY KEY AUTOINCREMENT);') --- ... -box.sql.execute('CREATE TABLE t1 (s1 INT PRIMARY KEY, s0 CHAR(5) COLLATE "unicode_ci" REFERENCES t0(s1));') +box.sql.execute('CREATE TABLE t1 (s1 INT PRIMARY KEY, s0 VARCHAR(5) COLLATE "unicode_ci" REFERENCES t0(s1));') --- ... box.sql.execute("INSERT INTO t0(s1) VALUES ('a');") @@ -294,10 +294,10 @@ box.sql.execute("DROP TABLE t0;") --- ... -- Check that foreign key update fails with default collation. -box.sql.execute('CREATE TABLE t0 (s1 CHAR(5) UNIQUE, id INT PRIMARY KEY AUTOINCREMENT);') +box.sql.execute('CREATE TABLE t0 (s1 VARCHAR(5) UNIQUE, id INT PRIMARY KEY AUTOINCREMENT);') --- ... -box.sql.execute('CREATE TABLE t1 (s1 INT PRIMARY KEY, s0 CHAR(5) REFERENCES t0(s1));') +box.sql.execute('CREATE TABLE t1 (s1 INT PRIMARY KEY, s0 VARCHAR(5) REFERENCES t0(s1));') --- ... box.sql.execute("INSERT INTO t0(s1) VALUES ('a');") diff --git a/test/sql/collation.test.lua b/test/sql/collation.test.lua index 713a9bd89..2e55de2cb 100644 --- a/test/sql/collation.test.lua +++ b/test/sql/collation.test.lua @@ -14,7 +14,7 @@ box.sql.execute("SELECT 1 LIMIT 1 COLLATE BINARY, 1;") -- gh-3052: upper/lower support only default locale -- For tr-TR result depends on collation -box.sql.execute([[CREATE TABLE tu (descriptor CHAR(50) PRIMARY KEY, letter CHAR(50))]]); +box.sql.execute([[CREATE TABLE tu (descriptor VARCHAR(50) PRIMARY KEY, letter VARCHAR(50))]]); box.internal.collation.create('TURKISH', 'ICU', 'tr-TR', {strength='primary'}); box.sql.execute([[INSERT INTO tu VALUES ('Latin Capital Letter I U+0049','I');]]) box.sql.execute([[INSERT INTO tu VALUES ('Latin Small Letter I U+0069','i');]]) @@ -105,8 +105,8 @@ 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" UNIQUE, id INT PRIMARY KEY AUTOINCREMENT);') -box.sql.execute('CREATE TABLE t1 (s1 INT PRIMARY KEY, s0 CHAR(5) COLLATE "unicode_ci" REFERENCES t0(s1));') +box.sql.execute('CREATE TABLE t0 (s1 VARCHAR(5) COLLATE "unicode_ci" UNIQUE, id INT PRIMARY KEY AUTOINCREMENT);') +box.sql.execute('CREATE TABLE t1 (s1 INT PRIMARY KEY, s0 VARCHAR(5) COLLATE "unicode_ci" REFERENCES t0(s1));') box.sql.execute("INSERT INTO t0(s1) VALUES ('a');") box.sql.execute("INSERT INTO t1 VALUES (1,'a');") -- Should't fail. @@ -116,8 +116,8 @@ 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) UNIQUE, id INT PRIMARY KEY AUTOINCREMENT);') -box.sql.execute('CREATE TABLE t1 (s1 INT PRIMARY KEY, s0 CHAR(5) REFERENCES t0(s1));') +box.sql.execute('CREATE TABLE t0 (s1 VARCHAR(5) UNIQUE, id INT PRIMARY KEY AUTOINCREMENT);') +box.sql.execute('CREATE TABLE t1 (s1 INT PRIMARY KEY, s0 VARCHAR(5) REFERENCES t0(s1));') box.sql.execute("INSERT INTO t0(s1) VALUES ('a');") box.sql.execute("INSERT INTO t1 VALUES (1,'a');") -- Should fail. diff --git a/test/sql/row-count.result b/test/sql/row-count.result index d6248eb0f..b75298f72 100644 --- a/test/sql/row-count.result +++ b/test/sql/row-count.result @@ -9,7 +9,7 @@ box.sql.execute('pragma sql_default_engine=\''..engine..'\'') ... -- Test cases concerning row count calculations. -- -box.sql.execute("CREATE TABLE t1 (s1 CHAR(10) PRIMARY KEY);") +box.sql.execute("CREATE TABLE t1 (s1 VARCHAR(10) PRIMARY KEY);") --- ... box.sql.execute("SELECT ROW_COUNT();") @@ -20,7 +20,7 @@ box.sql.execute("SELECT ROW_COUNT();") --- - - [0] ... -box.sql.execute("CREATE TABLE t2 (s1 CHAR(10) PRIMARY KEY, s2 CHAR(10) REFERENCES t1 ON DELETE CASCADE);") +box.sql.execute("CREATE TABLE t2 (s1 VARCHAR(10) PRIMARY KEY, s2 VARCHAR(10) REFERENCES t1 ON DELETE CASCADE);") --- ... box.sql.execute("SELECT ROW_COUNT();") diff --git a/test/sql/row-count.test.lua b/test/sql/row-count.test.lua index f10807fff..89476c7a9 100644 --- a/test/sql/row-count.test.lua +++ b/test/sql/row-count.test.lua @@ -4,10 +4,10 @@ box.sql.execute('pragma sql_default_engine=\''..engine..'\'') -- Test cases concerning row count calculations. -- -box.sql.execute("CREATE TABLE t1 (s1 CHAR(10) PRIMARY KEY);") +box.sql.execute("CREATE TABLE t1 (s1 VARCHAR(10) PRIMARY KEY);") box.sql.execute("SELECT ROW_COUNT();") box.sql.execute("SELECT ROW_COUNT();") -box.sql.execute("CREATE TABLE t2 (s1 CHAR(10) PRIMARY KEY, s2 CHAR(10) REFERENCES t1 ON DELETE CASCADE);") +box.sql.execute("CREATE TABLE t2 (s1 VARCHAR(10) PRIMARY KEY, s2 VARCHAR(10) REFERENCES t1 ON DELETE CASCADE);") box.sql.execute("SELECT ROW_COUNT();") box.sql.execute("CREATE TABLE t3 (i1 INT UNIQUE, i2 INT, i3 INT PRIMARY KEY);") box.sql.execute("INSERT INTO t3 VALUES (0, 0, 0);") -- 2.15.1