From: Nikita Pettik <korablev@tarantool.org> To: tarantool-patches@freelists.org Cc: v.shpilevoy@tarantool.org, Nikita Pettik <korablev@tarantool.org> Subject: [tarantool-patches] [PATCH 2/4] sql: remove support of CHAR type from parser Date: Thu, 7 Mar 2019 16:14:02 +0300 [thread overview] Message-ID: <f9ff68e0f8318f8949df0d44a823b4d1325be539.1551964360.git.korablev@tarantool.org> (raw) In-Reply-To: <cover.1551964360.git.korablev@tarantool.org> In-Reply-To: <cover.1551964360.git.korablev@tarantool.org> 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) ); ]], { -- <table-23.2> 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
next prev parent reply other threads:[~2019-03-07 13:14 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-03-07 13:14 [tarantool-patches] [PATCH 0/4] SQL types changes Nikita Pettik 2019-03-07 13:14 ` [tarantool-patches] [PATCH 1/4] sql: remove support of DATE/TIME from parser Nikita Pettik 2019-03-07 13:34 ` [tarantool-patches] " Konstantin Osipov 2019-03-07 13:14 ` Nikita Pettik [this message] 2019-03-07 13:35 ` [tarantool-patches] Re: [PATCH 2/4] sql: remove support of CHAR type " Konstantin Osipov 2019-03-07 13:14 ` [tarantool-patches] [PATCH 3/4] sql: remove support of NUMERIC " Nikita Pettik 2019-03-07 13:36 ` [tarantool-patches] " Konstantin Osipov 2019-03-07 13:14 ` [tarantool-patches] [PATCH 4/4] sql: replace BLOB as column type with SCALAR Nikita Pettik 2019-03-07 13:40 ` [tarantool-patches] " Konstantin Osipov 2019-03-07 14:00 ` n.pettik 2019-03-07 14:14 ` [tarantool-patches] Re: [PATCH 0/4] SQL types changes 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=f9ff68e0f8318f8949df0d44a823b4d1325be539.1551964360.git.korablev@tarantool.org \ --to=korablev@tarantool.org \ --cc=tarantool-patches@freelists.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [tarantool-patches] [PATCH 2/4] sql: remove support of CHAR type from parser' \ /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