Tarantool development patches archive
 help / color / mirror / Atom feed
* [tarantool-patches] [PATCH 0/4] SQL types changes
@ 2019-03-07 13:14 Nikita Pettik
  2019-03-07 13:14 ` [tarantool-patches] [PATCH 1/4] sql: remove support of DATE/TIME from parser Nikita Pettik
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Nikita Pettik @ 2019-03-07 13:14 UTC (permalink / raw)
  To: tarantool-patches; +Cc: v.shpilevoy, Nikita Pettik

Branch: https://github.com/tarantool/tarantool/tree/np/gh-4019-types-cleanup
Issue:
https://github.com/tarantool/tarantool/issues/4019
https://github.com/tarantool/tarantool/issues/4023

This patch-set polishes current situation with SQL types. Several type
aliases (CHAR/DECIMAL/NUMERIC) were removed; TIME-like types were
completely removed. BLOB was replaced with SCALAR to avoid any
confusions in using that type. For more details, see content of patches
and document request in the last patch.

Nikita Pettik (4):
  sql: remove support of DATE/TIME from parser
  sql: remove support of CHAR type from parser
  sql: remove support of NUMERIC type from parser
  sql: replace BLOB as column type with SCALAR

 extra/mkkeywordhash.c                        | 18 +++----
 src/box/sql/date.c                           |  9 ++--
 src/box/sql/parse.y                          | 79 +++++++++++++++-------------
 src/box/sql/vdbe.c                           |  2 -
 src/box/sql/vdbemem.c                        | 14 +----
 test/sql-tap/analyze9.test.lua               |  2 +-
 test/sql-tap/autoinc.test.lua                |  2 +-
 test/sql-tap/blob.test.lua                   |  4 +-
 test/sql-tap/boundary1.test.lua              |  2 +-
 test/sql-tap/boundary3.test.lua              |  2 +-
 test/sql-tap/cast.test.lua                   | 60 ++++++++++-----------
 test/sql-tap/collation.test.lua              |  2 +-
 test/sql-tap/date.test.lua                   |  9 ++--
 test/sql-tap/default.test.lua                |  4 +-
 test/sql-tap/delete4.test.lua                |  2 +-
 test/sql-tap/distinct.test.lua               | 11 ++--
 test/sql-tap/e_expr.test.lua                 | 14 +++--
 test/sql-tap/eqp.test.lua                    |  4 +-
 test/sql-tap/fkey1.test.lua                  |  4 +-
 test/sql-tap/in1.test.lua                    |  2 +-
 test/sql-tap/in3.test.lua                    |  9 ++--
 test/sql-tap/in4.test.lua                    |  2 +-
 test/sql-tap/index1.test.lua                 |  2 +-
 test/sql-tap/index4.test.lua                 |  4 +-
 test/sql-tap/resolver01.test.lua             |  4 +-
 test/sql-tap/select6.test.lua                |  6 +--
 test/sql-tap/substr.test.lua                 |  2 +-
 test/sql-tap/suite.ini                       |  4 ++
 test/sql-tap/table.test.lua                  | 30 ++++++-----
 test/sql-tap/tkt-7bbfb7d442.test.lua         |  4 +-
 test/sql-tap/tkt-bd484a090c.test.lua         |  9 +++-
 test/sql-tap/tkt1443.test.lua                |  2 +-
 test/sql-tap/tkt1444.test.lua                |  2 +-
 test/sql-tap/tkt1449.test.lua                | 14 ++---
 test/sql-tap/tkt2192.test.lua                |  8 ++-
 test/sql-tap/tkt3791.test.lua                | 10 ++--
 test/sql-tap/types2.test.lua                 |  8 +--
 test/sql-tap/where2.test.lua                 |  4 +-
 test/sql-tap/whereB.test.lua                 | 22 ++++----
 test/sql/collation.result                    | 10 ++--
 test/sql/collation.test.lua                  | 10 ++--
 test/sql/drop-index.result                   |  2 +-
 test/sql/drop-index.test.lua                 |  2 +-
 test/sql/errinj.result                       |  2 +-
 test/sql/errinj.test.lua                     |  2 +-
 test/sql/gh-2929-primary-key.result          |  6 +--
 test/sql/gh-2929-primary-key.test.lua        |  6 +--
 test/sql/gh-3888-values-blob-assert.result   |  8 +--
 test/sql/gh-3888-values-blob-assert.test.lua |  4 +-
 test/sql/gh2251-multiple-update.result       |  2 +-
 test/sql/gh2251-multiple-update.test.lua     |  2 +-
 test/sql/persistency.result                  |  2 +-
 test/sql/persistency.test.lua                |  2 +-
 test/sql/row-count.result                    |  4 +-
 test/sql/row-count.test.lua                  |  4 +-
 test/sql/transition.result                   |  4 +-
 test/sql/transition.test.lua                 |  4 +-
 test/sql/triggers.result                     |  4 +-
 test/sql/triggers.test.lua                   |  4 +-
 test/sql/types.result                        | 10 ++--
 test/sql/types.test.lua                      |  7 ++-
 61 files changed, 249 insertions(+), 244 deletions(-)

-- 
2.15.1

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [tarantool-patches] [PATCH 1/4] sql: remove support of DATE/TIME from parser
  2019-03-07 13:14 [tarantool-patches] [PATCH 0/4] SQL types changes Nikita Pettik
@ 2019-03-07 13:14 ` Nikita Pettik
  2019-03-07 13:34   ` [tarantool-patches] " Konstantin Osipov
  2019-03-07 13:14 ` [tarantool-patches] [PATCH 2/4] sql: remove support of CHAR type " Nikita Pettik
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Nikita Pettik @ 2019-03-07 13:14 UTC (permalink / raw)
  To: tarantool-patches; +Cc: v.shpilevoy, Nikita Pettik

Currently, there is no native (in Tarantool terms) types to represent
time-like types. So, until we add implementation of those types, it
makes no sense to allow to specify those types in table definition.
Note that previously they were mapped to NUMBER type. For the same
reason all built-in functions connected with DATE/TIME are disabled as
well.

Part of #4019
---
 extra/mkkeywordhash.c                | 10 +++++-----
 src/box/sql/date.c                   |  9 ++++++---
 src/box/sql/parse.y                  | 27 ++++++++++++++++++---------
 test/sql-tap/date.test.lua           |  9 ++++++---
 test/sql-tap/suite.ini               |  4 ++++
 test/sql-tap/table.test.lua          |  6 +++++-
 test/sql-tap/tkt-7bbfb7d442.test.lua |  4 ++--
 test/sql-tap/tkt-bd484a090c.test.lua |  9 +++++++--
 test/sql-tap/tkt2192.test.lua        |  8 ++++++--
 test/sql-tap/tkt3791.test.lua        | 10 ++++++----
 test/sql/triggers.result             |  4 ++--
 test/sql/triggers.test.lua           |  4 ++--
 12 files changed, 69 insertions(+), 35 deletions(-)

diff --git a/extra/mkkeywordhash.c b/extra/mkkeywordhash.c
index edc2ee3b7..491b81ddd 100644
--- a/extra/mkkeywordhash.c
+++ b/extra/mkkeywordhash.c
@@ -126,9 +126,6 @@ static Keyword aKeywordTable[] = {
   { "CONSTRAINT",             "TK_CONSTRAINT",  ALWAYS,           true  },
   { "CREATE",                 "TK_CREATE",      ALWAYS,           true  },
   { "CROSS",                  "TK_JOIN_KW",     ALWAYS,           true  },
-  { "CURRENT_DATE",           "TK_CTIME_KW",    ALWAYS,           true  },
-  { "CURRENT_TIME",           "TK_CTIME_KW",    ALWAYS,           true  },
-  { "CURRENT_TIMESTAMP",      "TK_CTIME_KW",    ALWAYS,           true  },
   { "DEFAULT",                "TK_DEFAULT",     ALWAYS,           true  },
   { "DEFERRED",               "TK_DEFERRED",    ALWAYS,           false },
   { "DEFERRABLE",             "TK_DEFERRABLE",  FKEY,             false },
@@ -225,8 +222,11 @@ static Keyword aKeywordTable[] = {
   { "CURRENT",                "TK_STANDARD",    RESERVED,         true  },
   { "CURRENT_USER",           "TK_STANDARD",    RESERVED,         true  },
   { "CURSOR",                 "TK_STANDARD",    RESERVED,         true  },
-  { "DATE",                   "TK_DATE",        RESERVED,         true  },
-  { "DATETIME",               "TK_DATETIME",    RESERVED,         true  },
+  { "CURRENT_DATE",           "TK_STANDARD",    RESERVED,         true  },
+  { "CURRENT_TIME",           "TK_STANDARD",    RESERVED,         true  },
+  { "CURRENT_TIMESTAMP",      "TK_STANDARD",    RESERVED,         true  },
+  { "DATE",                   "TK_STANDARD",    RESERVED,         true  },
+  { "DATETIME",               "TK_STANDARD",    RESERVED,         true  },
   { "DECIMAL",                "TK_DECIMAL",     RESERVED,         true  },
   { "DECLARE",                "TK_STANDARD",    RESERVED,         true  },
   { "DENSE_RANK",             "TK_STANDARD",    RESERVED,         true  },
diff --git a/src/box/sql/date.c b/src/box/sql/date.c
index f3b5b484c..5f5272ea3 100644
--- a/src/box/sql/date.c
+++ b/src/box/sql/date.c
@@ -69,7 +69,11 @@
 #include <assert.h>
 #include <time.h>
 
-#ifndef SQL_OMIT_DATETIME_FUNCS
+/*
+ * Till time-like types are implemented as native Tarantool
+ * types, built-in functions below make no sense.
+ */
+#if 0
 
 /*
  * A structure for holding a single date and time.
@@ -1305,7 +1309,7 @@ void
 sqlRegisterDateTimeFunctions(void)
 {
 	static FuncDef aDateTimeFuncs[] = {
-#ifndef SQL_OMIT_DATETIME_FUNCS
+#if 0
 		DFUNCTION(julianday, -1, 0, 0, juliandayFunc, FIELD_TYPE_NUMBER),
 		DFUNCTION(date, -1, 0, 0, dateFunc, FIELD_TYPE_STRING),
 		DFUNCTION(time, -1, 0, 0, timeFunc, FIELD_TYPE_STRING),
@@ -1315,7 +1319,6 @@ sqlRegisterDateTimeFunctions(void)
 		DFUNCTION(current_timestamp, 0, 0, 0, ctimestampFunc,
 			  FIELD_TYPE_STRING),
 		DFUNCTION(current_date, 0, 0, 0, cdateFunc, FIELD_TYPE_STRING),
-#else
 		STR_FUNCTION(current_time, 0, "%H:%M:%S", 0, currentTimeFunc),
 		STR_FUNCTION(current_date, 0, "%Y-%m-%d", 0, currentTimeFunc),
 		STR_FUNCTION(current_timestamp, 0, "%Y-%m-%d %H:%M:%S", 0,
diff --git a/src/box/sql/parse.y b/src/box/sql/parse.y
index e2504c4f1..fb3639f3f 100644
--- a/src/box/sql/parse.y
+++ b/src/box/sql/parse.y
@@ -931,8 +931,10 @@ expr(A) ::= id(X) LP distinct(D) exprlist(Y) RP(E). {
   }
 }
 
-type_func(A) ::= DATE(A) .
-type_func(A) ::= DATETIME(A) .
+/*
+ * type_func(A) ::= DATE(A) .
+ * type_func(A) ::= DATETIME(A) .
+ */
 type_func(A) ::= CHAR(A) .
 expr(A) ::= type_func(X) LP distinct(D) exprlist(Y) RP(E). {
   if( Y && Y->nExpr>pParse->db->aLimit[SQL_LIMIT_FUNCTION_ARG] ){
@@ -949,10 +951,12 @@ expr(A) ::= id(X) LP STAR RP(E). {
   A.pExpr = sqlExprFunction(pParse, 0, &X);
   spanSet(&A,&X,&E);
 }
-term(A) ::= CTIME_KW(OP). {
-  A.pExpr = sqlExprFunction(pParse, 0, &OP);
-  spanSet(&A, &OP, &OP);
-}
+/*
+ * term(A) ::= CTIME_KW(OP). {
+ *   A.pExpr = sqlExprFunction(pParse, 0, &OP);
+ *   spanSet(&A, &OP, &OP);
+ * }
+ */
 
 %include {
   /* This routine constructs a binary expression node out of two ExprSpan
@@ -1474,9 +1478,14 @@ wqlist(A) ::= wqlist(A) COMMA nm(X) eidlist_opt(Y) AS LP select(Z) RP. {
 %type typedef {struct type_def}
 typedef(A) ::= TEXT . { A.type = FIELD_TYPE_STRING; }
 typedef(A) ::= BLOB_KW . { A.type = FIELD_TYPE_SCALAR; }
-typedef(A) ::= DATE . { A.type = FIELD_TYPE_NUMBER; }
-typedef(A) ::= TIME . { A.type = FIELD_TYPE_NUMBER; }
-typedef(A) ::= DATETIME . { A.type = FIELD_TYPE_NUMBER; }
+/**
+ * Time-like types are temporary disabled, until they are
+ * implemented as a native Tarantool types (gh-3694).
+ *
+ typedef(A) ::= DATE . { A.type = FIELD_TYPE_NUMBER; }
+ typedef(A) ::= TIME . { A.type = FIELD_TYPE_NUMBER; }
+ typedef(A) ::= DATETIME . { A.type = FIELD_TYPE_NUMBER; }
+*/
 
 %type char_len {int}
 typedef(A) ::= CHAR . {
diff --git a/test/sql-tap/date.test.lua b/test/sql-tap/date.test.lua
index f66a4f02c..87fc80db0 100755
--- a/test/sql-tap/date.test.lua
+++ b/test/sql-tap/date.test.lua
@@ -1,6 +1,7 @@
 #!/usr/bin/env tarantool
 test = require("sqltester")
-test:plan(1279)
+-- test:plan(1279)
+test:plan(0)
 
 --!./tcltestrunner.lua
 -- 2003 October 31
@@ -26,7 +27,9 @@ test:plan(1279)
 -- at compile-time
 --
 
-
+-- Disabled until #3694 is resolved.
+--
+if false then
 local function datetest(tnum, expr, result)
     test:do_test(
         "date-"..tnum,
@@ -478,7 +481,7 @@ test:do_test(
         1
         -- </date-15.2>
     })
-
+end -- if false
 
 
 test:finish_test()
diff --git a/test/sql-tap/suite.ini b/test/sql-tap/suite.ini
index faa56a999..bb492895e 100644
--- a/test/sql-tap/suite.ini
+++ b/test/sql-tap/suite.ini
@@ -5,6 +5,10 @@ disabled = selectA.test.lua ;
            like2.test.lua ;
            types2.test.lua ;
            e_expr.test.lua ;
+           date.test.lua ;
+           tkt-bd484a090c.test.lua ;
+           tkt3791.test.lua ;
+
 lua_libs = lua/sqltester.lua ../sql/lua/sql_tokenizer.lua ../box/lua/identifier.lua
 is_parallel = True
 release_disabled = debug_mode_only.test.lua
diff --git a/test/sql-tap/table.test.lua b/test/sql-tap/table.test.lua
index 2bcc5aa48..b1ea27878 100755
--- a/test/sql-tap/table.test.lua
+++ b/test/sql-tap/table.test.lua
@@ -1,6 +1,6 @@
 #!/usr/bin/env tarantool
 test = require("sqltester")
-test:plan(78)
+test:plan(77)
 
 --!./tcltestrunner.lua
 -- 2001 September 15
@@ -945,6 +945,9 @@ test:do_execsql_test(
 -- Test the ability to have default values of CURRENT_TIME, CURRENT_DATE
 -- and CURRENT_TIMESTAMP.
 --
+--  Disabled until #3694 is resolved.
+--
+if false then
 test:do_execsql_test(
     "table-13.1",
     [[
@@ -960,6 +963,7 @@ test:do_execsql_test(
         
         -- </table-13.1>
     })
+end
 
 ----------------------------------------------------------------------
 -- Test cases table-14.*
diff --git a/test/sql-tap/tkt-7bbfb7d442.test.lua b/test/sql-tap/tkt-7bbfb7d442.test.lua
index 15478a77d..9469025cd 100755
--- a/test/sql-tap/tkt-7bbfb7d442.test.lua
+++ b/test/sql-tap/tkt-7bbfb7d442.test.lua
@@ -91,7 +91,7 @@ if (1 > 0)
               InventoryControlId INTEGER,
               SKU INTEGER NOT NULL PRIMARY KEY,
               Variant INTEGER NOT NULL DEFAULT 0,
-              ControlDate DATE NOT NULL,
+              ControlDate TEXT NOT NULL,
               ControlState INTEGER NOT NULL DEFAULT -1,
               DeliveredQty TEXT
             );
@@ -161,7 +161,7 @@ if (1 > 0)
 
 
             INSERT INTO InventoryControl(SKU, Variant, ControlDate) SELECT 
-                II.SKU AS SKU, II.Variant AS Variant, julianday('2011-08-30') AS ControlDate
+                II.SKU AS SKU, II.Variant AS Variant, '2011-08-30' AS ControlDate
                 FROM InventoryItem II;
         ]])
 
diff --git a/test/sql-tap/tkt-bd484a090c.test.lua b/test/sql-tap/tkt-bd484a090c.test.lua
index 974e22169..0347fd426 100755
--- a/test/sql-tap/tkt-bd484a090c.test.lua
+++ b/test/sql-tap/tkt-bd484a090c.test.lua
@@ -1,6 +1,7 @@
 #!/usr/bin/env tarantool
 test = require("sqltester")
-test:plan(2)
+--test:plan(2)
+test:plan(0)
 
 --!./tcltestrunner.lua
 -- 2011 June 21
@@ -18,6 +19,10 @@ test:plan(2)
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
 testprefix = "tkt-bd484a090c"
+
+-- Disabled until #3694 is resolved.
+--
+if false then
 test:do_test(
     1.1,
     function()
@@ -29,7 +34,7 @@ test:do_test(
     function()
         return test:catchsql(" SELECT datetime('now', 'utc') ")[1]
     end, 0)
-
+end -- if false
 -- TBI to be implemented feature
 --sql_test_control("sql_TESTCTRL_LOCALTIME_FAULT", 1)
 --test:do_catchsql_test(
diff --git a/test/sql-tap/tkt2192.test.lua b/test/sql-tap/tkt2192.test.lua
index b118d6310..17b5d46d1 100755
--- a/test/sql-tap/tkt2192.test.lua
+++ b/test/sql-tap/tkt2192.test.lua
@@ -1,6 +1,7 @@
 #!/usr/bin/env tarantool
 test = require("sqltester")
-test:plan(6)
+-- test:plan(6)
+test:plan(4)
 
 --!./tcltestrunner.lua
 -- 2007 January 26
@@ -23,7 +24,9 @@ test:plan(6)
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
 
-
+--  Disabled until #3694 is resolved.
+--
+if false then
 test:do_execsql_test(
     "tkt2192-1.1",
     [[
@@ -105,6 +108,7 @@ test:do_test(
 
         -- </tkt2192-1.2>
     })
+end -- if false
 
 test:do_execsql_test(
     "tkt2192-2.1",
diff --git a/test/sql-tap/tkt3791.test.lua b/test/sql-tap/tkt3791.test.lua
index 388670a4b..d39b6a2d5 100755
--- a/test/sql-tap/tkt3791.test.lua
+++ b/test/sql-tap/tkt3791.test.lua
@@ -1,6 +1,7 @@
 #!/usr/bin/env tarantool
 test = require("sqltester")
-test:plan(1)
+--test:plan(1)
+test:plan(0)
 
 --!./tcltestrunner.lua
 -- 2009 April 2
@@ -21,9 +22,9 @@ test:plan(1)
 -- ["set","testdir",[["file","dirname",["argv0"]]]]
 -- ["source",[["testdir"],"\/tester.tcl"]]
 -- MUST_WORK_TEST
-if (0 > 0)
- then
-end
+-- Disabled until #3694 is resolved.
+--
+if (0 > 0) then
 test:do_test(
     "tkt3791-1.1",
     function()
@@ -37,6 +38,7 @@ test:do_test(
         1, 19
         -- </tkt3791-1.1>
     })
+end
 
 test:finish_test()
 
diff --git a/test/sql/triggers.result b/test/sql/triggers.result
index bbfff3302..2f5b14803 100644
--- a/test/sql/triggers.result
+++ b/test/sql/triggers.result
@@ -256,7 +256,7 @@ box.sql.execute("PRAGMA sql_default_engine ('vinyl');")
 box.sql.execute("CREATE TABLE m (s0 INT PRIMARY KEY, s1 TEXT UNIQUE);")
 ---
 ...
-box.sql.execute("CREATE TRIGGER m1 BEFORE UPDATE ON m FOR EACH ROW BEGIN UPDATE n SET s2 = DATETIME('now'); END;")
+box.sql.execute("CREATE TRIGGER m1 BEFORE UPDATE ON m FOR EACH ROW BEGIN UPDATE n SET s2 = 'now'; END;")
 ---
 ...
 box.sql.execute("PRAGMA sql_default_engine('memtx');")
@@ -292,7 +292,7 @@ box.sql.execute("PRAGMA sql_default_engine ('memtx');")
 box.sql.execute("CREATE TABLE m (s0 INT PRIMARY KEY, s1 TEXT UNIQUE);")
 ---
 ...
-box.sql.execute("CREATE TRIGGER m1 BEFORE UPDATE ON m FOR EACH ROW BEGIN UPDATE n SET s2 = DATETIME('now'); END;")
+box.sql.execute("CREATE TRIGGER m1 BEFORE UPDATE ON m FOR EACH ROW BEGIN UPDATE n SET s2 = 'now'; END;")
 ---
 ...
 box.sql.execute("PRAGMA sql_default_engine('vinyl');")
diff --git a/test/sql/triggers.test.lua b/test/sql/triggers.test.lua
index eb3f41ef5..b22b4f9ff 100644
--- a/test/sql/triggers.test.lua
+++ b/test/sql/triggers.test.lua
@@ -102,7 +102,7 @@ box.sql.execute("DROP TABLE T1;")
 -- Case 1: Src 'vinyl' table; Dst 'memtx' table
 box.sql.execute("PRAGMA sql_default_engine ('vinyl');")
 box.sql.execute("CREATE TABLE m (s0 INT PRIMARY KEY, s1 TEXT UNIQUE);")
-box.sql.execute("CREATE TRIGGER m1 BEFORE UPDATE ON m FOR EACH ROW BEGIN UPDATE n SET s2 = DATETIME('now'); END;")
+box.sql.execute("CREATE TRIGGER m1 BEFORE UPDATE ON m FOR EACH ROW BEGIN UPDATE n SET s2 = 'now'; END;")
 box.sql.execute("PRAGMA sql_default_engine('memtx');")
 box.sql.execute("CREATE TABLE n (s0 INT PRIMARY KEY, s1 TEXT UNIQUE, s2 REAL);")
 box.sql.execute("INSERT INTO m VALUES (0, '0');")
@@ -118,7 +118,7 @@ box.sql.execute("DROP TABLE n;")
 -- Case 2: Src 'memtx' table; Dst 'vinyl' table
 box.sql.execute("PRAGMA sql_default_engine ('memtx');")
 box.sql.execute("CREATE TABLE m (s0 INT PRIMARY KEY, s1 TEXT UNIQUE);")
-box.sql.execute("CREATE TRIGGER m1 BEFORE UPDATE ON m FOR EACH ROW BEGIN UPDATE n SET s2 = DATETIME('now'); END;")
+box.sql.execute("CREATE TRIGGER m1 BEFORE UPDATE ON m FOR EACH ROW BEGIN UPDATE n SET s2 = 'now'; END;")
 box.sql.execute("PRAGMA sql_default_engine('vinyl');")
 box.sql.execute("CREATE TABLE n (s0 INT PRIMARY KEY, s1 TEXT UNIQUE, s2 REAL);")
 box.sql.execute("INSERT INTO m VALUES (0, '0');")
-- 
2.15.1

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [tarantool-patches] [PATCH 2/4] sql: remove support of CHAR type from parser
  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:14 ` Nikita Pettik
  2019-03-07 13:35   ` [tarantool-patches] " Konstantin Osipov
  2019-03-07 13:14 ` [tarantool-patches] [PATCH 3/4] sql: remove support of NUMERIC " Nikita Pettik
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Nikita Pettik @ 2019-03-07 13:14 UTC (permalink / raw)
  To: tarantool-patches; +Cc: v.shpilevoy, 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)
         );
     ]], {
         -- <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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [tarantool-patches] [PATCH 3/4] sql: remove support of NUMERIC type from parser
  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:14 ` [tarantool-patches] [PATCH 2/4] sql: remove support of CHAR type " Nikita Pettik
@ 2019-03-07 13:14 ` 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 14:14 ` [tarantool-patches] Re: [PATCH 0/4] SQL types changes Kirill Yukhin
  4 siblings, 1 reply; 11+ messages in thread
From: Nikita Pettik @ 2019-03-07 13:14 UTC (permalink / raw)
  To: tarantool-patches; +Cc: v.shpilevoy, Nikita Pettik

NMERIC and DECIMAL were allowed to be specified as column types. But in
fact, they were just synonyms for FLOAT type and mapped to NUMERIC
Tarantool NoSQL type. So, we've decided to remove this type from parser
and return back when NUMERIC will be implemented as a native type.

Part of #4019
---
 extra/mkkeywordhash.c                    |  6 ++---
 src/box/sql/parse.y                      | 40 ++++++++++++++++++--------------
 test/sql-tap/cast.test.lua               | 30 ++++++++++++------------
 test/sql-tap/default.test.lua            |  2 +-
 test/sql-tap/in1.test.lua                |  2 +-
 test/sql-tap/in3.test.lua                |  4 ++--
 test/sql-tap/in4.test.lua                |  2 +-
 test/sql-tap/index1.test.lua             |  2 +-
 test/sql-tap/table.test.lua              |  2 +-
 test/sql-tap/tkt1444.test.lua            |  2 +-
 test/sql-tap/whereB.test.lua             |  4 ++--
 test/sql/drop-index.result               |  2 +-
 test/sql/drop-index.test.lua             |  2 +-
 test/sql/errinj.result                   |  2 +-
 test/sql/errinj.test.lua                 |  2 +-
 test/sql/gh-2929-primary-key.result      |  6 ++---
 test/sql/gh-2929-primary-key.test.lua    |  6 ++---
 test/sql/gh2251-multiple-update.result   |  2 +-
 test/sql/gh2251-multiple-update.test.lua |  2 +-
 test/sql/persistency.result              |  2 +-
 test/sql/persistency.test.lua            |  2 +-
 test/sql/transition.result               |  2 +-
 test/sql/transition.test.lua             |  2 +-
 23 files changed, 67 insertions(+), 61 deletions(-)

diff --git a/extra/mkkeywordhash.c b/extra/mkkeywordhash.c
index 491b81ddd..298c19c47 100644
--- a/extra/mkkeywordhash.c
+++ b/extra/mkkeywordhash.c
@@ -227,7 +227,7 @@ static Keyword aKeywordTable[] = {
   { "CURRENT_TIMESTAMP",      "TK_STANDARD",    RESERVED,         true  },
   { "DATE",                   "TK_STANDARD",    RESERVED,         true  },
   { "DATETIME",               "TK_STANDARD",    RESERVED,         true  },
-  { "DECIMAL",                "TK_DECIMAL",     RESERVED,         true  },
+  { "DECIMAL",                "TK_STANDARD",    RESERVED,         true  },
   { "DECLARE",                "TK_STANDARD",    RESERVED,         true  },
   { "DENSE_RANK",             "TK_STANDARD",    RESERVED,         true  },
   { "DESCRIBE",               "TK_STANDARD",    RESERVED,         true  },
@@ -248,8 +248,8 @@ static Keyword aKeywordTable[] = {
   { "LOCALTIME",              "TK_STANDARD",    RESERVED,         true  },
   { "LOCALTIMESTAMP",         "TK_STANDARD",    RESERVED,         true  },
   { "LOOP",                   "TK_STANDARD",    RESERVED,         true  },
-  { "NUM",                    "TK_NUM",         RESERVED,         true  },
-  { "NUMERIC",                "TK_NUMERIC",     RESERVED,         true  },
+  { "NUM",                    "TK_STANDARD",    RESERVED,         true  },
+  { "NUMERIC",                "TK_STANDARD",    RESERVED,         true  },
   { "OUT",                    "TK_STANDARD",    RESERVED,         true  },
   { "OVER",                   "TK_STANDARD",    RESERVED,         true  },
   { "PARTITION",              "TK_STANDARD",    RESERVED,         true  },
diff --git a/src/box/sql/parse.y b/src/box/sql/parse.y
index 92788ceb8..8b45eceaf 100644
--- a/src/box/sql/parse.y
+++ b/src/box/sql/parse.y
@@ -1504,20 +1504,26 @@ typedef(A) ::= number_typedef(A) .
 number_typedef(A) ::= FLOAT_KW|REAL|DOUBLE . { A.type = FIELD_TYPE_NUMBER; }
 number_typedef(A) ::= INT|INTEGER_KW . { A.type = FIELD_TYPE_INTEGER; }
 
-%type number_len_typedef {struct type_def}
-number_typedef(A) ::= DECIMAL|NUMERIC|NUM number_len_typedef(B) . {
-  A.type = FIELD_TYPE_NUMBER;
-  (void) B;
-}
-
-number_len_typedef(A) ::= . { (void) A; }
-number_len_typedef(A) ::= LP INTEGER(B) RP . {
-  (void) A;
-  (void) B;
-}
-
-number_len_typedef(A) ::= LP INTEGER(B) COMMA INTEGER(C) RP . {
-  (void) A;
-  (void) B;
-  (void) C;
-}
+/**
+ * NUMERIC type is temporary disabled. To be enabled when
+ * it will be implemented as native Tarantool type.
+ *
+ * %type number_len_typedef {struct type_def}
+ * number_typedef(A) ::= DECIMAL|NUMERIC|NUM number_len_typedef(B) . {
+ *   A.type = FIELD_TYPE_NUMBER;
+ *   (void) B;
+ * }
+ *
+ *
+ * number_len_typedef(A) ::= . { (void) A; }
+ * number_len_typedef(A) ::= LP INTEGER(B) RP . {
+ *   (void) A;
+ *   (void) B;
+ * }
+ *
+ * number_len_typedef(A) ::= LP INTEGER(B) COMMA INTEGER(C) RP . {
+ *   (void) A;
+ *   (void) B;
+ *   (void) C;
+ *}
+ */
diff --git a/test/sql-tap/cast.test.lua b/test/sql-tap/cast.test.lua
index f861e4e76..05fa872b5 100755
--- a/test/sql-tap/cast.test.lua
+++ b/test/sql-tap/cast.test.lua
@@ -67,7 +67,7 @@ test:do_execsql_test(
 test:do_catchsql_test(
     "cast-1.5",
     [[
-        SELECT CAST(x'616263' AS numeric)
+        SELECT CAST(x'616263' AS FLOAT)
     ]], {
         -- <cast-1.5>
         1, 'Type mismatch: can not convert abc to number'
@@ -147,7 +147,7 @@ test:do_execsql_test(
 test:do_execsql_test(
     "cast-1.15",
     [[
-        SELECT CAST(NULL AS numeric)
+        SELECT CAST(NULL AS FLOAT)
     ]], {
         -- <cast-1.15>
         ""
@@ -157,7 +157,7 @@ test:do_execsql_test(
 test:do_execsql_test(
     "cast-1.16",
     [[
-        SELECT typeof(CAST(NULL AS numeric))
+        SELECT typeof(CAST(NULL AS FLOAT))
     ]], {
         -- <cast-1.16>
         "null"
@@ -247,7 +247,7 @@ test:do_execsql_test(
 test:do_execsql_test(
     "cast-1.25",
     [[
-        SELECT CAST(123 AS numeric)
+        SELECT CAST(123 AS FLOAT)
     ]], {
         -- <cast-1.25>
         123
@@ -257,7 +257,7 @@ test:do_execsql_test(
 test:do_execsql_test(
     "cast-1.26",
     [[
-        SELECT typeof(CAST(123 AS numeric))
+        SELECT typeof(CAST(123 AS FLOAT))
     ]], {
         -- <cast-1.26>
         "real"
@@ -347,7 +347,7 @@ test:do_execsql_test(
 test:do_execsql_test(
     "cast-1.35",
     [[
-        SELECT CAST(123.456 AS numeric)
+        SELECT CAST(123.456 AS FLOAT)
     ]], {
         -- <cast-1.35>
         123.456
@@ -357,7 +357,7 @@ test:do_execsql_test(
 test:do_execsql_test(
     "cast-1.36",
     [[
-        SELECT typeof(CAST(123.456 AS numeric))
+        SELECT typeof(CAST(123.456 AS FLOAT))
     ]], {
         -- <cast-1.36>
         "real"
@@ -447,7 +447,7 @@ test:do_execsql_test(
 test:do_catchsql_test(
     "cast-1.45",
     [[
-        SELECT CAST('123abc' AS numeric)
+        SELECT CAST('123abc' AS FLOAT)
     ]], {
         -- <cast-1.45>
         1, 'Type mismatch: can not convert 123abc to number'
@@ -477,7 +477,7 @@ test:do_catchsql_test(
 test:do_catchsql_test(
     "cast-1.51",
     [[
-        SELECT CAST('123.5abc' AS numeric)
+        SELECT CAST('123.5abc' AS FLOAT)
     ]], {
         -- <cast-1.51>
         1, 'Type mismatch: can not convert 123.5abc to number'
@@ -625,7 +625,7 @@ test:do_execsql_test(
 test:do_execsql_test(
     "cast-3.2",
     [[
-        SELECT CAST(9223372036854774800 AS numeric)
+        SELECT CAST(9223372036854774800 AS FLOAT)
     ]], {
         -- <cast-3.2>
         9223372036854774784
@@ -660,7 +660,7 @@ test:do_execsql_test(
 test:do_execsql_test(
     "cast-3.6",
     [[
-        SELECT CAST(-9223372036854774800 AS numeric)
+        SELECT CAST(-9223372036854774800 AS float)
     ]], {
         -- <cast-3.6>
         -9223372036854774784
@@ -695,7 +695,7 @@ test:do_execsql_test(
 test:do_execsql_test(
     "cast-3.12",
     [[
-        SELECT CAST('9223372036854774800' AS numeric)
+        SELECT CAST('9223372036854774800' AS FLOAT)
     ]], {
         -- <cast-3.12>
         9223372036854774784
@@ -732,7 +732,7 @@ test:do_execsql_test(
 test:do_execsql_test(
     "cast-3.16",
     [[
-        SELECT CAST('-9223372036854774800' AS numeric)
+        SELECT CAST('-9223372036854774800' AS FLOAT)
     ]], {
         -- <cast-3.16>
         -9223372036854774784
@@ -770,7 +770,7 @@ if true then --test:execsql("PRAGMA encoding")[1][1]=="UTF-8" then
     test:do_execsql_test(
         "cast-3.22",
         [[
-            SELECT CAST(x'39323233333732303336383534373734383030' AS numeric)
+            SELECT CAST(x'39323233333732303336383534373734383030' AS FLOAT)
         ]], {
             -- <cast-3.22>
             9223372036854774784
@@ -796,7 +796,7 @@ end
 test:do_execsql_test(
     "case-3.31",
     [[
-        SELECT CAST(NULL AS numeric)
+        SELECT CAST(NULL AS FLOAT)
     ]], {
         -- <case-3.31>
         ""
diff --git a/test/sql-tap/default.test.lua b/test/sql-tap/default.test.lua
index e0dbb9145..349bcdf6c 100755
--- a/test/sql-tap/default.test.lua
+++ b/test/sql-tap/default.test.lua
@@ -105,7 +105,7 @@ test:do_execsql_test(
 	b INT DEFAULT 12345 UNIQUE NOT NULL CHECK( b>=0 AND b<99999 ),
 	c VARCHAR(123) DEFAULT 'hello' NOT NULL,
 	d REAL,
-	e NUMERIC(5,10) DEFAULT 4.36,
+	e FLOAT DEFAULT 4.36,
 	f VARCHAR(15), --COLLATE RTRIM,
 	g INTEGER DEFAULT( 3600*12 )
 	);
diff --git a/test/sql-tap/in1.test.lua b/test/sql-tap/in1.test.lua
index 41c0e0dae..835c10dd5 100755
--- a/test/sql-tap/in1.test.lua
+++ b/test/sql-tap/in1.test.lua
@@ -623,7 +623,7 @@ test:do_catchsql_test(
 test:do_execsql_test(
     "in-11.1",
     [[
-        CREATE TABLE t6(a  INT PRIMARY KEY,b NUMERIC);
+        CREATE TABLE t6(a  INT PRIMARY KEY,b FLOAT);
         INSERT INTO t6 VALUES(1,2);
         INSERT INTO t6 VALUES(2,3);
         SELECT * FROM t6 WHERE b IN (2);
diff --git a/test/sql-tap/in3.test.lua b/test/sql-tap/in3.test.lua
index 41f08c8a0..18f57fa47 100755
--- a/test/sql-tap/in3.test.lua
+++ b/test/sql-tap/in3.test.lua
@@ -271,12 +271,12 @@ test:do_test(
             DROP TABLE IF EXISTS t1;
             DROP TABLE IF EXISTS t1;
 
-            CREATE TABLE t1(id  INT primary key, a BLOB, b NUMERIC ,c TEXT);
+            CREATE TABLE t1(id  INT primary key, a BLOB, b FLOAT ,c TEXT);
             CREATE UNIQUE INDEX t1_i1 ON t1(a);        /* no affinity */
             CREATE UNIQUE INDEX t1_i2 ON t1(b);        /* numeric affinity */
             CREATE UNIQUE INDEX t1_i3 ON t1(c);        /* text affinity */
 
-            CREATE TABLE t2(id  INT primary key, x BLOB, y NUMERIC, z TEXT);
+            CREATE TABLE t2(id  INT primary key, x BLOB, y FLOAT, z TEXT);
             CREATE UNIQUE INDEX t2_i1 ON t2(x);        /* no affinity */
             CREATE UNIQUE INDEX t2_i2 ON t2(y);        /* numeric affinity */
             CREATE UNIQUE INDEX t2_i3 ON t2(z);        /* text affinity */
diff --git a/test/sql-tap/in4.test.lua b/test/sql-tap/in4.test.lua
index c488cde45..9d488745d 100755
--- a/test/sql-tap/in4.test.lua
+++ b/test/sql-tap/in4.test.lua
@@ -588,7 +588,7 @@ test:do_execsql_test(
 test:do_execsql_test(
     "in4-4.11",
     [[
-        CREATE TABLE t4b(a TEXT, b NUMERIC, c  INT PRIMARY KEY);
+        CREATE TABLE t4b(a TEXT, b FLOAT, c  INT PRIMARY KEY);
         INSERT INTO t4b VALUES('1.0',1,4);
         SELECT c FROM t4b WHERE a=b;
     ]], {
diff --git a/test/sql-tap/index1.test.lua b/test/sql-tap/index1.test.lua
index 2ed1451ac..fa97018d7 100755
--- a/test/sql-tap/index1.test.lua
+++ b/test/sql-tap/index1.test.lua
@@ -605,7 +605,7 @@ end
 test:do_execsql_test(
     "index-12.1",
     [[
-        CREATE TABLE t4(id  INT primary key, a NUM,b INT );
+        CREATE TABLE t4(id  INT primary key, a FLOAT,b INT );
         INSERT INTO t4 VALUES(1, '0.0',1);
         INSERT INTO t4 VALUES(2, '0.00',2);
         INSERT INTO t4 VALUES(4, '-1.0',4);
diff --git a/test/sql-tap/table.test.lua b/test/sql-tap/table.test.lua
index 9c4048d4c..1583890da 100755
--- a/test/sql-tap/table.test.lua
+++ b/test/sql-tap/table.test.lua
@@ -892,7 +892,7 @@ test:do_execsql_test(
     [[
         CREATE TABLE t7(
            a integer primary key,
-           b numeric(5,10),
+           b FLOAT,
            c VARCHAR(8),
            d VARCHAR(9),
            e blob,
diff --git a/test/sql-tap/tkt1444.test.lua b/test/sql-tap/tkt1444.test.lua
index 8def87e86..563bf3c07 100755
--- a/test/sql-tap/tkt1444.test.lua
+++ b/test/sql-tap/tkt1444.test.lua
@@ -28,7 +28,7 @@ test:plan(4)
 test:do_execsql_test(
     "tkt1444-1.1",
     [[
-        CREATE TABLE DemoTable (id  INT primary key, x INTEGER, TextKey TEXT, DKey NUM);
+        CREATE TABLE DemoTable (id  INT primary key, x INTEGER, TextKey TEXT, DKey FLOAT);
         CREATE INDEX DemoTableIdx ON DemoTable (TextKey);
         INSERT INTO DemoTable VALUES(1, 9,8,7);
         INSERT INTO DemoTable VALUES(2, 1,2,3);
diff --git a/test/sql-tap/whereB.test.lua b/test/sql-tap/whereB.test.lua
index 84c9cd990..6ecc3cc5d 100755
--- a/test/sql-tap/whereB.test.lua
+++ b/test/sql-tap/whereB.test.lua
@@ -321,7 +321,7 @@ test:do_execsql_test(
         CREATE TABLE t1(x  INT primary key, y BLOB);    -- affinity of t1.y is NONE
         INSERT INTO t1 VALUES(1,'99');
 
-        CREATE TABLE t2(a  INT primary key, b NUMERIC);  -- affinity of t2.b is NUMERIC
+        CREATE TABLE t2(a  INT primary key, b FLOAT);  -- affinity of t2.b is NUMERIC
         CREATE INDEX t2b ON t2(b);
         INSERT INTO t2 VALUES(2,99);
 
@@ -618,7 +618,7 @@ test:do_execsql_test(
         DROP TABLE t1;
         DROP TABLE t2;
 
-        CREATE TABLE t1(x  INT primary key, y NUMERIC);  -- affinity of t1.y is NUMERIC
+        CREATE TABLE t1(x  INT primary key, y FLOAT);  -- affinity of t1.y is NUMERIC
         INSERT INTO t1 VALUES(1,99);
 
         CREATE TABLE t2(a  INT primary key, b BLOB);  -- affinity of t2.b is NONE
diff --git a/test/sql/drop-index.result b/test/sql/drop-index.result
index 8cd667bec..2590b74cb 100644
--- a/test/sql/drop-index.result
+++ b/test/sql/drop-index.result
@@ -9,7 +9,7 @@ box.sql.execute('pragma sql_default_engine=\''..engine..'\'')
 ...
 -- box.cfg()
 -- create space
-box.sql.execute("CREATE TABLE zzoobar (c1 NUM, c2 INT PRIMARY KEY, c3 TEXT, c4 NUM)")
+box.sql.execute("CREATE TABLE zzoobar (c1 FLOAT, c2 INT PRIMARY KEY, c3 TEXT, c4 FLOAT)")
 ---
 ...
 box.sql.execute("CREATE UNIQUE INDEX zoobar2 ON zzoobar(c1, c4)")
diff --git a/test/sql/drop-index.test.lua b/test/sql/drop-index.test.lua
index 4fa7b9867..2493299b0 100644
--- a/test/sql/drop-index.test.lua
+++ b/test/sql/drop-index.test.lua
@@ -5,7 +5,7 @@ box.sql.execute('pragma sql_default_engine=\''..engine..'\'')
 -- box.cfg()
 
 -- create space
-box.sql.execute("CREATE TABLE zzoobar (c1 NUM, c2 INT PRIMARY KEY, c3 TEXT, c4 NUM)")
+box.sql.execute("CREATE TABLE zzoobar (c1 FLOAT, c2 INT PRIMARY KEY, c3 TEXT, c4 FLOAT)")
 
 box.sql.execute("CREATE UNIQUE INDEX zoobar2 ON zzoobar(c1, c4)")
 box.sql.execute("CREATE        INDEX zoobar3 ON zzoobar(c3)")
diff --git a/test/sql/errinj.result b/test/sql/errinj.result
index c423c8bc6..0f6075b13 100644
--- a/test/sql/errinj.result
+++ b/test/sql/errinj.result
@@ -239,7 +239,7 @@ box.sql.execute("DROP TABLE t2;")
 -- Tests which are aimed at verifying work of commit/rollback
 -- triggers on _fk_constraint space.
 --
-box.sql.execute("CREATE TABLE t3 (id NUMERIC PRIMARY KEY, a INT REFERENCES t3, b INT UNIQUE);")
+box.sql.execute("CREATE TABLE t3 (id FLOAT PRIMARY KEY, a INT REFERENCES t3, b INT UNIQUE);")
 ---
 ...
 t = box.space._fk_constraint:select{}[1]:totable()
diff --git a/test/sql/errinj.test.lua b/test/sql/errinj.test.lua
index 8378c255c..6c9311b5a 100644
--- a/test/sql/errinj.test.lua
+++ b/test/sql/errinj.test.lua
@@ -88,7 +88,7 @@ box.sql.execute("DROP TABLE t2;")
 -- Tests which are aimed at verifying work of commit/rollback
 -- triggers on _fk_constraint space.
 --
-box.sql.execute("CREATE TABLE t3 (id NUMERIC PRIMARY KEY, a INT REFERENCES t3, b INT UNIQUE);")
+box.sql.execute("CREATE TABLE t3 (id FLOAT PRIMARY KEY, a INT REFERENCES t3, b INT UNIQUE);")
 t = box.space._fk_constraint:select{}[1]:totable()
 errinj = box.error.injection
 errinj.set("ERRINJ_WAL_IO", true)
diff --git a/test/sql/gh-2929-primary-key.result b/test/sql/gh-2929-primary-key.result
index 280e90002..405266583 100644
--- a/test/sql/gh-2929-primary-key.result
+++ b/test/sql/gh-2929-primary-key.result
@@ -20,15 +20,15 @@ box.sql.execute("CREATE TABLE t2(a INT UNIQUE, b INT)")
 ---
 - error: PRIMARY KEY missing on table T2
 ...
-box.sql.execute("CREATE TABLE t3(a NUM)")
+box.sql.execute("CREATE TABLE t3(a FLOAT)")
 ---
 - error: PRIMARY KEY missing on table T3
 ...
-box.sql.execute("CREATE TABLE t4(a DECIMAL, b TEXT)")
+box.sql.execute("CREATE TABLE t4(a FLOAT, b TEXT)")
 ---
 - error: PRIMARY KEY missing on table T4
 ...
-box.sql.execute("CREATE TABLE t5(a DECIMAL, b NUM UNIQUE)")
+box.sql.execute("CREATE TABLE t5(a FLOAT, b FLOAT UNIQUE)")
 ---
 - error: PRIMARY KEY missing on table T5
 ...
diff --git a/test/sql/gh-2929-primary-key.test.lua b/test/sql/gh-2929-primary-key.test.lua
index a1446b2e5..6c2f0eb10 100644
--- a/test/sql/gh-2929-primary-key.test.lua
+++ b/test/sql/gh-2929-primary-key.test.lua
@@ -11,9 +11,9 @@ box.cfg{}
 box.sql.execute("CREATE TABLE t1(a INT PRIMARY KEY, b INT UNIQUE)")
 box.sql.execute("CREATE TABLE t2(a INT UNIQUE, b INT)")
 
-box.sql.execute("CREATE TABLE t3(a NUM)")
-box.sql.execute("CREATE TABLE t4(a DECIMAL, b TEXT)")
-box.sql.execute("CREATE TABLE t5(a DECIMAL, b NUM UNIQUE)")
+box.sql.execute("CREATE TABLE t3(a FLOAT)")
+box.sql.execute("CREATE TABLE t4(a FLOAT, b TEXT)")
+box.sql.execute("CREATE TABLE t5(a FLOAT, b FLOAT UNIQUE)")
 
 box.sql.execute("DROP TABLE t1")
 
diff --git a/test/sql/gh2251-multiple-update.result b/test/sql/gh2251-multiple-update.result
index 7066ca99f..e6380a0ee 100644
--- a/test/sql/gh2251-multiple-update.result
+++ b/test/sql/gh2251-multiple-update.result
@@ -26,7 +26,7 @@ box.sql.execute("SELECT e FROM t1")
 - - [7]
   - [8]
 ...
-box.sql.execute("CREATE TABLE t2(a integer primary key, b INT UNIQUE, c NUM, d NUM, e INT,  UNIQUE(c,d));")
+box.sql.execute("CREATE TABLE t2(a integer primary key, b INT UNIQUE, c FLOAT, d FLOAT, e INT,  UNIQUE(c,d));")
 ---
 ...
 box.sql.execute("INSERT INTO t2 VALUES(1,2,3,4,5);")
diff --git a/test/sql/gh2251-multiple-update.test.lua b/test/sql/gh2251-multiple-update.test.lua
index 6107125d7..656ed72e4 100644
--- a/test/sql/gh2251-multiple-update.test.lua
+++ b/test/sql/gh2251-multiple-update.test.lua
@@ -13,7 +13,7 @@ box.sql.execute("UPDATE t1 SET e=e+1 WHERE b IN (SELECT b FROM t1);")
 
 box.sql.execute("SELECT e FROM t1")
 
-box.sql.execute("CREATE TABLE t2(a integer primary key, b INT UNIQUE, c NUM, d NUM, e INT,  UNIQUE(c,d));")
+box.sql.execute("CREATE TABLE t2(a integer primary key, b INT UNIQUE, c FLOAT, d FLOAT, e INT,  UNIQUE(c,d));")
 box.sql.execute("INSERT INTO t2 VALUES(1,2,3,4,5);")
 box.sql.execute("INSERT INTO t2 VALUES(2,3,4,4,6);")
 
diff --git a/test/sql/persistency.result b/test/sql/persistency.result
index 09f8eab29..31c844f88 100644
--- a/test/sql/persistency.result
+++ b/test/sql/persistency.result
@@ -125,7 +125,7 @@ box.sql.execute("SELECT COUNT(*) FROM foobar WHERE bar='cacodaemon'")
 ...
 -- multi-index
 -- create space
-box.sql.execute("CREATE TABLE barfoo (bar TEXT, foo NUM PRIMARY KEY)")
+box.sql.execute("CREATE TABLE barfoo (bar TEXT, foo FLOAT PRIMARY KEY)")
 ---
 ...
 box.sql.execute("CREATE UNIQUE INDEX barfoo2 ON barfoo(bar)")
diff --git a/test/sql/persistency.test.lua b/test/sql/persistency.test.lua
index e7b137b44..67659e881 100644
--- a/test/sql/persistency.test.lua
+++ b/test/sql/persistency.test.lua
@@ -41,7 +41,7 @@ box.sql.execute("SELECT COUNT(*) FROM foobar WHERE bar='cacodaemon'")
 -- multi-index
 
 -- create space
-box.sql.execute("CREATE TABLE barfoo (bar TEXT, foo NUM PRIMARY KEY)")
+box.sql.execute("CREATE TABLE barfoo (bar TEXT, foo FLOAT PRIMARY KEY)")
 box.sql.execute("CREATE UNIQUE INDEX barfoo2 ON barfoo(bar)")
 
 -- prepare data
diff --git a/test/sql/transition.result b/test/sql/transition.result
index 04721596a..e7613c344 100644
--- a/test/sql/transition.result
+++ b/test/sql/transition.result
@@ -122,7 +122,7 @@ box.sql.execute("SELECT COUNT(*) FROM foobar WHERE bar='cacodaemon'")
 ...
 -- multi-index
 -- create space
-box.sql.execute("CREATE TABLE barfoo (bar TEXT, foo NUM PRIMARY KEY)")
+box.sql.execute("CREATE TABLE barfoo (bar TEXT, foo FLOAT PRIMARY KEY)")
 ---
 ...
 box.sql.execute("CREATE UNIQUE INDEX barfoo2 ON barfoo(bar)")
diff --git a/test/sql/transition.test.lua b/test/sql/transition.test.lua
index 5a7010d93..276ff7174 100644
--- a/test/sql/transition.test.lua
+++ b/test/sql/transition.test.lua
@@ -40,7 +40,7 @@ box.sql.execute("SELECT COUNT(*) FROM foobar WHERE bar='cacodaemon'")
 -- multi-index
 
 -- create space
-box.sql.execute("CREATE TABLE barfoo (bar TEXT, foo NUM PRIMARY KEY)")
+box.sql.execute("CREATE TABLE barfoo (bar TEXT, foo FLOAT PRIMARY KEY)")
 box.sql.execute("CREATE UNIQUE INDEX barfoo2 ON barfoo(bar)")
 
 -- prepare data
-- 
2.15.1

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [tarantool-patches] [PATCH 4/4] sql: replace BLOB as column type with SCALAR
  2019-03-07 13:14 [tarantool-patches] [PATCH 0/4] SQL types changes Nikita Pettik
                   ` (2 preceding siblings ...)
  2019-03-07 13:14 ` [tarantool-patches] [PATCH 3/4] sql: remove support of NUMERIC " Nikita Pettik
@ 2019-03-07 13:14 ` Nikita Pettik
  2019-03-07 13:40   ` [tarantool-patches] " Konstantin Osipov
  2019-03-07 14:14 ` [tarantool-patches] Re: [PATCH 0/4] SQL types changes Kirill Yukhin
  4 siblings, 1 reply; 11+ messages in thread
From: Nikita Pettik @ 2019-03-07 13:14 UTC (permalink / raw)
  To: tarantool-patches; +Cc: v.shpilevoy, Nikita Pettik

BLOB column type is represented by SCALAR field type in terms of NoSQL.
We attempted at emulating BLOB behaviour, but such efforts turn out to
be not decent enough. For this reason, we've decided to abandon these
attempts and fairly replace it with SCALAR column type.  SCALAR column
type acts in the same way as it does in NoSQL: it is aggregator-type for
INTEGER, NUMBER and STRING types. So, column declared with this type can
contain values of these three (available in SQL) types. It is worth
mentioning that CAST operator in this case does nothing.

Still, we consider BLOB values as entries encoded in msgpack with MP_BIN
format. To make this happen, values to be operated should be represented
in BLOB form x'...' (e.g. x'000000'). What is more, there are two
built-in functions returning BLOBs: randomblob() and zeroblob().  On the
other hand, columns with STRING NoSQL type don't accept BLOB values.

Closes #4019
Closes #4023

@TarantoolBot document
Title: SQL types changes
There are couple of recently introduced changes connected with SQL
types.

Firstly, we've removed support of DATE/TIME types from parser due to
confusing behaviour of these types: they were mapped to NUMBER NoSQL
type and have nothing in common with generally accepted DATE/TIME types
(like in other DBs). In addition, all built-in functions related to
these types (julianday(), date(), time(), datetime(), current_time(),
current_date() etc) are disabled until we reimplement TIME-like types as
a native NoSQL ones (see #3694 issue).

Secondly, we've removed CHAR type (i.e. alias to VARCHAR and TEXT). The
reason is that according to ANSI SQL CHAR(len) must accept only strings
featuring length exactly equal to given in type definition. Obviously,
now we don't provide such checks. Types VARCHAR and TEXT are still
legal.

For the same reason, we've removed NUMERIC and DECIMAL types, which were
aliases to NUMBER NoSQL type. REAL, FLOAT and DOUBLE are still exist as
aliases.

Finally, we've renamed BLOB column type to SCALAR. We've decided that
all our attempts to emulate BLOB behaviour using SCALAR NoSQL type don't
seem decent enough, i.e. without native NoSQL type BLOB there always
will be inconsistency, especially taking into account possible NoSQL-SQL
interactions. In SQL SCALAR type works exactly in the same way as in
NoSQL: it can store values of INTEGER, FLOAT and TEXT SQL types at the
same time. Also, with this change behaviour of CAST operator has been
slightly corrected: now cast to SCALAR doesn't affect type of value at
all. Couple of examples:

CREATE TABLE t1 (a SCALAR PRIMARY KEY);
INSERT INTO t1 VALUES ('1');
SELECT * FROM t1 WHERE a = 1;
-- []
Result is empty set since column "a" contains string literal value '1',
not integer value 1.

CAST(123 AS SCALAR); -- Returns 123 (integer)
CAST('abc' AS SCALAR); -- Returns 'abc' (string)

Note that in NoSQL values of BLOB type defined as ones decoded in
msgpack with MP_BIN format. In SQL there are still a few ways to force
this format: declaring literal in "BLOB" format (x'...') or using one of
two built-in functions (randomblob() and zeroblob()). TEXT and VARCHAR
SQL types don't accept BLOB values:

CREATE TABLE t (a TEXT PRIMARAY KEY);
INSERT INTO t VALUES (randomblob(5));
---
- error: 'Tuple field 1 type does not match one required: expected string'
...

BLOB itself is going to be reimplemented in scope of #3650.
---
 extra/mkkeywordhash.c                        |  2 +-
 src/box/sql/parse.y                          |  2 +-
 src/box/sql/vdbe.c                           |  2 --
 src/box/sql/vdbemem.c                        | 14 +------------
 test/sql-tap/analyze9.test.lua               |  2 +-
 test/sql-tap/blob.test.lua                   |  4 ++--
 test/sql-tap/boundary1.test.lua              |  2 +-
 test/sql-tap/boundary3.test.lua              |  2 +-
 test/sql-tap/cast.test.lua                   | 30 ++++++++++++++--------------
 test/sql-tap/default.test.lua                |  2 +-
 test/sql-tap/delete4.test.lua                |  2 +-
 test/sql-tap/distinct.test.lua               | 11 +++-------
 test/sql-tap/e_expr.test.lua                 | 14 ++++++-------
 test/sql-tap/in3.test.lua                    |  9 ++++-----
 test/sql-tap/index4.test.lua                 |  4 ++--
 test/sql-tap/substr.test.lua                 |  2 +-
 test/sql-tap/table.test.lua                  | 16 +++++++--------
 test/sql-tap/tkt1443.test.lua                |  2 +-
 test/sql-tap/tkt1449.test.lua                | 14 ++++++-------
 test/sql-tap/types2.test.lua                 |  8 ++++----
 test/sql-tap/whereB.test.lua                 | 18 ++++++++---------
 test/sql/gh-3888-values-blob-assert.result   |  8 ++++----
 test/sql/gh-3888-values-blob-assert.test.lua |  4 ++--
 test/sql/transition.result                   |  2 +-
 test/sql/transition.test.lua                 |  2 +-
 test/sql/types.result                        | 10 +++-------
 test/sql/types.test.lua                      |  7 +++----
 27 files changed, 84 insertions(+), 111 deletions(-)

diff --git a/extra/mkkeywordhash.c b/extra/mkkeywordhash.c
index 298c19c47..0a874c8e6 100644
--- a/extra/mkkeywordhash.c
+++ b/extra/mkkeywordhash.c
@@ -109,7 +109,6 @@ static Keyword aKeywordTable[] = {
   { "BEFORE",                 "TK_BEFORE",      TRIGGER,          false },
   { "BEGIN",                  "TK_BEGIN",       TRIGGER,          true  },
   { "BETWEEN",                "TK_BETWEEN",     ALWAYS,           true  },
-  { "BLOB",                   "TK_BLOB_KW",     RESERVED,         true  },
   { "BY",                     "TK_BY",          ALWAYS,           true  },
   { "CASCADE",                "TK_CASCADE",     FKEY,             false },
   { "CASE",                   "TK_CASE",        ALWAYS,           true  },
@@ -193,6 +192,7 @@ static Keyword aKeywordTable[] = {
   { "ROLLBACK",               "TK_ROLLBACK",    ALWAYS,           true  },
   { "ROW",                    "TK_ROW",         TRIGGER,          true  },
   { "SAVEPOINT",              "TK_SAVEPOINT",   ALWAYS,           true  },
+  { "SCALAR",                 "TK_SCALAR",      ALWAYS,           true  },
   { "SELECT",                 "TK_SELECT",      ALWAYS,           true  },
   { "SET",                    "TK_SET",         ALWAYS,           true  },
   { "SIMPLE",                 "TK_SIMPLE",      ALWAYS,           true  },
diff --git a/src/box/sql/parse.y b/src/box/sql/parse.y
index 8b45eceaf..996f55d37 100644
--- a/src/box/sql/parse.y
+++ b/src/box/sql/parse.y
@@ -1477,7 +1477,7 @@ wqlist(A) ::= wqlist(A) COMMA nm(X) eidlist_opt(Y) AS LP select(Z) RP. {
 ////////////////////////////// TYPE DECLARATION ///////////////////////////////
 %type typedef {struct type_def}
 typedef(A) ::= TEXT . { A.type = FIELD_TYPE_STRING; }
-typedef(A) ::= BLOB_KW . { A.type = FIELD_TYPE_SCALAR; }
+typedef(A) ::= SCALAR . { A.type = FIELD_TYPE_SCALAR; }
 /**
  * Time-like types are temporary disabled, until they are
  * implemented as a native Tarantool types (gh-3694).
diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
index d2d8e9182..c1da9a4aa 100644
--- a/src/box/sql/vdbe.c
+++ b/src/box/sql/vdbe.c
@@ -364,8 +364,6 @@ mem_apply_type(struct Mem *record, enum field_type type)
 		record->flags &= ~(MEM_Real | MEM_Int);
 		return 0;
 	case FIELD_TYPE_SCALAR:
-		if (record->flags & (MEM_Str | MEM_Blob))
-			record->flags |= MEM_Blob;
 		return 0;
 	default:
 		return -1;
diff --git a/src/box/sql/vdbemem.c b/src/box/sql/vdbemem.c
index f67c32e1d..074ff8c96 100644
--- a/src/box/sql/vdbemem.c
+++ b/src/box/sql/vdbemem.c
@@ -617,19 +617,7 @@ sqlVdbeMemCast(Mem * pMem, enum field_type type)
 	}
 	switch (type) {
 	case FIELD_TYPE_SCALAR:
-		if (pMem->flags & MEM_Blob)
-			return SQL_OK;
-		if (pMem->flags & MEM_Str) {
-			MemSetTypeFlag(pMem, MEM_Blob);
-			return SQL_OK;
-		}
-		if (pMem->flags & MEM_Int || pMem->flags & MEM_Real) {
-			if (sqlVdbeMemStringify(pMem, 1) != 0)
-				return -1;
-			MemSetTypeFlag(pMem, MEM_Blob);
-			return 0;
-		}
-		return SQL_ERROR;
+		return 0;
 	case FIELD_TYPE_INTEGER:
 		if ((pMem->flags & MEM_Blob) != 0) {
 			if (sql_atoi64(pMem->z, (int64_t *) &pMem->u.i,
diff --git a/test/sql-tap/analyze9.test.lua b/test/sql-tap/analyze9.test.lua
index b7033234f..3969c45af 100755
--- a/test/sql-tap/analyze9.test.lua
+++ b/test/sql-tap/analyze9.test.lua
@@ -391,7 +391,7 @@ test:do_execsql_test(
         INSERT INTO t1 VALUES(null, 4, 4);
         INSERT INTO t1 VALUES(null, 5, 5);
         ANALYZE;
-        CREATE TABLE x1(tbl TEXT, idx TEXT , neq TEXT, nlt TEXT, ndlt TEXT, sample BLOB, PRIMARY KEY(tbl, idx, sample));
+        CREATE TABLE x1(tbl TEXT, idx TEXT , neq TEXT, nlt TEXT, ndlt TEXT, sample SCALAR, PRIMARY KEY(tbl, idx, sample));
         INSERT INTO x1 SELECT * FROM "_sql_stat4";
         DELETE FROM "_sql_stat4";
         INSERT INTO "_sql_stat4" SELECT * FROM x1;
diff --git a/test/sql-tap/blob.test.lua b/test/sql-tap/blob.test.lua
index c7b328a9f..376d5b183 100755
--- a/test/sql-tap/blob.test.lua
+++ b/test/sql-tap/blob.test.lua
@@ -170,7 +170,7 @@ test:do_test(
     "blob-2.0",
     function()
         test:execsql [[
-            CREATE TABLE t1(a BLOB primary key, b BLOB);
+            CREATE TABLE t1(a SCALAR primary key, b SCALAR);
             INSERT INTO t1 VALUES(X'123456', x'7890ab');
             INSERT INTO t1 VALUES(X'CDEF12', x'345678');
         ]]
@@ -186,7 +186,7 @@ test:do_test(
         -- </blob-2.0>
     })
 
--- An index on a blob column
+-- An index on a SCALAR column
 test:do_test(
     "blob-2.1",
     function()
diff --git a/test/sql-tap/boundary1.test.lua b/test/sql-tap/boundary1.test.lua
index e266cf750..ffd667c15 100755
--- a/test/sql-tap/boundary1.test.lua
+++ b/test/sql-tap/boundary1.test.lua
@@ -26,7 +26,7 @@ test:do_test(
     "boundary1-1.1",
     function()
         return test:execsql([[
-            CREATE TABLE t1(rowid  INT primary key, a INT ,x BLOB);
+            CREATE TABLE t1(rowid  INT primary key, a INT ,x SCALAR);
             INSERT INTO t1(rowid,a,x) VALUES(-8388609,1,'ffffffffff7fffff');
             INSERT INTO t1(rowid,a,x) VALUES(-36028797018963969,2,'ff7fffffffffffff');
             INSERT INTO t1(rowid,a,x) VALUES(9223372036854775807,3,'7fffffffffffffff');
diff --git a/test/sql-tap/boundary3.test.lua b/test/sql-tap/boundary3.test.lua
index 56130935c..fef15c93e 100755
--- a/test/sql-tap/boundary3.test.lua
+++ b/test/sql-tap/boundary3.test.lua
@@ -26,7 +26,7 @@ test:do_test(
     "boundary3-1.1",
     function()
         return test:execsql([[
-            CREATE TABLE t1(rowid  INT primary key, a FLOAT ,x BLOB);
+            CREATE TABLE t1(rowid  INT primary key, a FLOAT ,x SCALAR);
             INSERT INTO t1(rowid,a,x) VALUES(-8388609,1,'ffffffffff7fffff');
             INSERT INTO t1(rowid,a,x) VALUES(-36028797018963969,2,'ff7fffffffffffff');
             INSERT INTO t1(rowid,a,x) VALUES(9223372036854775806,3,'7fffffffffffffff');
diff --git a/test/sql-tap/cast.test.lua b/test/sql-tap/cast.test.lua
index 05fa872b5..e848991ba 100755
--- a/test/sql-tap/cast.test.lua
+++ b/test/sql-tap/cast.test.lua
@@ -22,7 +22,7 @@ test:plan(82)
 -- Only run these tests if the build includes the CAST operator
 
 
--- Tests for the CAST( AS blob), CAST( AS text) and CAST( AS numeric) built-ins
+-- Tests for the CAST( AS SCALAR), CAST( AS text) and CAST( AS numeric) built-ins
 --
 test:do_execsql_test(
     "cast-1.1",
@@ -77,7 +77,7 @@ test:do_catchsql_test(
 test:do_execsql_test(
     "cast-1.7",
     [[
-        SELECT CAST(x'616263' AS blob)
+        SELECT CAST(x'616263' AS SCALAR)
     ]], {
         -- <cast-1.7>
         "abc"
@@ -87,7 +87,7 @@ test:do_execsql_test(
 test:do_execsql_test(
     "cast-1.8",
     [[
-        SELECT typeof(CAST(x'616263' AS blob))
+        SELECT typeof(CAST(x'616263' AS SCALAR))
     ]], {
         -- <cast-1.8>
         "blob"
@@ -167,7 +167,7 @@ test:do_execsql_test(
 test:do_execsql_test(
     "cast-1.17",
     [[
-        SELECT CAST(NULL AS blob)
+        SELECT CAST(NULL AS SCALAR)
     ]], {
         -- <cast-1.17>
         ""
@@ -177,7 +177,7 @@ test:do_execsql_test(
 test:do_execsql_test(
     "cast-1.18",
     [[
-        SELECT typeof(CAST(NULL AS blob))
+        SELECT typeof(CAST(NULL AS SCALAR))
     ]], {
         -- <cast-1.18>
         "null"
@@ -267,20 +267,20 @@ test:do_execsql_test(
 test:do_execsql_test(
     "cast-1.27",
     [[
-        SELECT CAST(123 AS blob)
+        SELECT CAST(123 AS SCALAR)
     ]], {
         -- <cast-1.27>
-        "123"
+        123
         -- </cast-1.27>
     })
 
 test:do_execsql_test(
     "cast-1.28",
     [[
-        SELECT typeof(CAST(123 AS blob))
+        SELECT typeof(CAST(123 AS SCALAR))
     ]], {
         -- <cast-1.28>
-        "blob"
+        "integer"
         -- </cast-1.28>
     })
 
@@ -367,20 +367,20 @@ test:do_execsql_test(
 test:do_execsql_test(
     "cast-1.37",
     [[
-        SELECT CAST(123.456 AS blob)
+        SELECT CAST(123.456 AS SCALAR)
     ]], {
         -- <cast-1.37>
-        "123.456"
+        123.456
         -- </cast-1.37>
     })
 
 test:do_execsql_test(
     "cast-1.38",
     [[
-        SELECT typeof(CAST(123.456 AS blob))
+        SELECT typeof(CAST(123.456 AS SCALAR))
     ]], {
         -- <cast-1.38>
-        "blob"
+        "real"
         -- </cast-1.38>
     })
 
@@ -457,10 +457,10 @@ test:do_catchsql_test(
 test:do_execsql_test(
     "cast-1.48",
     [[
-        SELECT typeof(CAST('123abc' AS blob))
+        SELECT typeof(CAST('123abc' AS SCALAR))
     ]], {
         -- <cast-1.48>
-        "blob"
+        "text"
         -- </cast-1.48>
     })
 
diff --git a/test/sql-tap/default.test.lua b/test/sql-tap/default.test.lua
index 349bcdf6c..267ce884d 100755
--- a/test/sql-tap/default.test.lua
+++ b/test/sql-tap/default.test.lua
@@ -28,7 +28,7 @@ test:do_execsql_test(
 		CREATE TABLE t1(
 		rowid INTEGER PRIMARY KEY AUTOINCREMENT, 
 		a INTEGER,
-		b BLOB DEFAULT x'6869'
+		b SCALAR DEFAULT x'6869'
 		);
 		INSERT INTO t1(a) VALUES(1);
 		SELECT a, b from t1;
diff --git a/test/sql-tap/delete4.test.lua b/test/sql-tap/delete4.test.lua
index 55c99a163..7c0eec15e 100755
--- a/test/sql-tap/delete4.test.lua
+++ b/test/sql-tap/delete4.test.lua
@@ -56,7 +56,7 @@ test:do_execsql_test(
     2.1,
     [[
         DROP TABLE IF EXISTS t1;
-        CREATE TABLE t1(x INTEGER PRIMARY KEY, y INT , z BLOB);
+        CREATE TABLE t1(x INTEGER PRIMARY KEY, y INT , z SCALAR);
         INSERT INTO t1 VALUES(1, 0, randomblob(200));
         INSERT INTO t1 VALUES(2, 1, randomblob(200));
         INSERT INTO t1 VALUES(3, 0, randomblob(200));
diff --git a/test/sql-tap/distinct.test.lua b/test/sql-tap/distinct.test.lua
index e2041ba3a..c66375184 100755
--- a/test/sql-tap/distinct.test.lua
+++ b/test/sql-tap/distinct.test.lua
@@ -222,7 +222,7 @@ if (1 > 0) then
     ---------------------------------------------------------------------------
     -- Ticket  [fccbde530a6583bf2748400919f1603d5425995c] (2014-01-08)
     -- The logic that computes DISTINCT sometimes thinks that a zeroblob()
-    -- and a blob of all zeros are different when they should be the same. 
+    -- and a blob of all zeros are different when they should be the same.
     --
     test:do_execsql_test(
         4.1,
@@ -236,13 +236,8 @@ if (1 > 0) then
             INSERT INTO t1 VALUES(4,2);
             INSERT INTO t1 VALUES(5,3);
             INSERT INTO t1 VALUES(6,1);
-            CREATE TABLE t2(x BLOB primary key);
-            INSERT INTO t2
-              SELECT DISTINCT
-                CASE a WHEN 1 THEN x'0000000000'
-                       WHEN 2 THEN zeroblob(5)
-                       ELSE 'xyzzy' END
-                FROM t1;
+            CREATE TABLE t2(x SCALAR primary key);
+            INSERT INTO t2 SELECT DISTINCT CASE a WHEN 1 THEN x'0000000000' WHEN 2 THEN zeroblob(5) ELSE 'xyzzy' END FROM t1;
             SELECT quote(x) FROM t2 ORDER BY 1;
         ]], {
             -- <4.1>
diff --git a/test/sql-tap/e_expr.test.lua b/test/sql-tap/e_expr.test.lua
index 24f522978..7b80651a8 100755
--- a/test/sql-tap/e_expr.test.lua
+++ b/test/sql-tap/e_expr.test.lua
@@ -3034,15 +3034,13 @@ test:do_execsql_test(
 --
 do_expr_test("e_expr-27.2.1", " CAST(NULL AS integer) ", "null", "")
 do_expr_test("e_expr-27.2.2", " CAST(NULL AS text) ", "null", "")
-do_expr_test("e_expr-27.2.3", " CAST(NULL AS blob) ", "null", "")
+do_expr_test("e_expr-27.2.3", " CAST(NULL AS SCALAR) ", "null", "")
 do_expr_test("e_expr-27.2.4", " CAST(NULL AS numeric) ", "null", "")
--- EVIDENCE-OF: R-22956-37754 Casting to a BLOB consists of first casting
--- the value to TEXT in the encoding of the database connection, then
--- interpreting the resulting byte sequence as a BLOB instead of as TEXT.
+-- Casting to a SCALAR doesn't affect original value.
 --
-do_qexpr_test("e_expr-27.4.1", " CAST('ghi' AS blob) ", "X'676869'")
-do_qexpr_test("e_expr-27.4.2", " CAST(456 AS blob) ", "X'343536'")
-do_qexpr_test("e_expr-27.4.3", " CAST(1.78 AS blob) ", "X'312E3738'")
+do_qexpr_test("e_expr-27.4.1", " CAST('ghi' AS SCALAR) ", "X'676869'")
+do_qexpr_test("e_expr-27.4.2", " CAST(456 AS SCALAR) ", "X'343536'")
+do_qexpr_test("e_expr-27.4.3", " CAST(1.78 AS SCALAR) ", "X'312E3738'")
 
 -- EVIDENCE-OF: R-22235-47006 Casting an INTEGER or REAL value into TEXT
 -- renders the value as if via sql_snprintf() except that the
@@ -3170,7 +3168,7 @@ do_expr_test("e_expr-32.2.4", [[
   CAST(9223372036854775807 AS NUMERIC)
 ]], "real", 9223372036854775807)
 -- EVIDENCE-OF: R-64550-29191 Note that the result from casting any
--- non-BLOB value into a BLOB and the result from casting any BLOB value
+-- non-BLOB value into a SCALAR and the result from casting any SCALAR value
 -- into a non-BLOB value may be different depending on whether the
 -- database encoding is UTF-8
 --
diff --git a/test/sql-tap/in3.test.lua b/test/sql-tap/in3.test.lua
index 18f57fa47..988a9b2a7 100755
--- a/test/sql-tap/in3.test.lua
+++ b/test/sql-tap/in3.test.lua
@@ -271,12 +271,12 @@ test:do_test(
             DROP TABLE IF EXISTS t1;
             DROP TABLE IF EXISTS t1;
 
-            CREATE TABLE t1(id  INT primary key, a BLOB, b FLOAT ,c TEXT);
+            CREATE TABLE t1(id  INT primary key, a SCALAR, b FLOAT ,c TEXT);
             CREATE UNIQUE INDEX t1_i1 ON t1(a);        /* no affinity */
             CREATE UNIQUE INDEX t1_i2 ON t1(b);        /* numeric affinity */
             CREATE UNIQUE INDEX t1_i3 ON t1(c);        /* text affinity */
 
-            CREATE TABLE t2(id  INT primary key, x BLOB, y FLOAT, z TEXT);
+            CREATE TABLE t2(id  INT primary key, x SCALAR, y FLOAT, z TEXT);
             CREATE UNIQUE INDEX t2_i1 ON t2(x);        /* no affinity */
             CREATE UNIQUE INDEX t2_i2 ON t2(y);        /* numeric affinity */
             CREATE UNIQUE INDEX t2_i3 ON t2(z);        /* text affinity */
@@ -318,9 +318,8 @@ test:do_test(
 test:do_test(
     "in3-3.4",
     function()
-        -- BLOB is compatible with TEXT, however index can't
-        -- be used since under the hood BLOB is SCALAR (which
-        -- can contain not only STRING values) and TEXT is STRING.
+        -- SCALAR is compatible with TEXT, however index can't
+        -- be used since SCALAR can accept not only string values.
         return exec_neph(" SELECT x IN (SELECT c FROM t1) FROM t2 ")
     end, {
         -- <in3-3.4>
diff --git a/test/sql-tap/index4.test.lua b/test/sql-tap/index4.test.lua
index 3745dab90..d8c6babad 100755
--- a/test/sql-tap/index4.test.lua
+++ b/test/sql-tap/index4.test.lua
@@ -22,7 +22,7 @@ testprefix = "index4"
 test:do_execsql_test(
     1.1,
     [[
-        CREATE TABLE t1(x BLOB primary key);
+        CREATE TABLE t1(x SCALAR primary key);
         START TRANSACTION;
           INSERT INTO t1 VALUES(randomblob(102));
           INSERT INTO t1 SELECT randomblob(102) FROM t1;     --     2
@@ -78,7 +78,7 @@ test:do_execsql_test(
     1.6,
     [[
           DROP TABLE t1;
-          CREATE TABLE t1(x BLOB primary key);
+          CREATE TABLE t1(x SCALAR primary key);
         START TRANSACTION;
           INSERT INTO t1 VALUES('a');
           INSERT INTO t1 VALUES('b');
diff --git a/test/sql-tap/substr.test.lua b/test/sql-tap/substr.test.lua
index fbb97ff1c..a9e656e6d 100755
--- a/test/sql-tap/substr.test.lua
+++ b/test/sql-tap/substr.test.lua
@@ -25,7 +25,7 @@ test:plan(93)
 --
 test:execsql [[
     CREATE TABLE t1(id integer primary key --autoincrement
-    , t text, b blob)
+    , t text, b SCALAR)
 ]]
 
 local function substr_test(id, string, i1, i2, result)
diff --git a/test/sql-tap/table.test.lua b/test/sql-tap/table.test.lua
index 1583890da..aa3eea813 100755
--- a/test/sql-tap/table.test.lua
+++ b/test/sql-tap/table.test.lua
@@ -495,8 +495,8 @@ test:do_catchsql_test(
           key int,
           "14_vac" int,
           fuzzy_dog_12 varchar(10),
-          beginn blob,
-          endd blob
+          beginn SCALAR,
+          endd SCALAR
         )
     ]=], {
         -- <table-7.1>
@@ -551,8 +551,8 @@ test:do_execsql2_test(
           key int,
           "14_vac" int,
           fuzzy_dog_12 varchar(10),
-          beginn blob,
-          endd blob
+          beginn SCALAR,
+          endd SCALAR
         );
         INSERT INTO t2 SELECT * from weird;
         SELECT * FROM t2;
@@ -704,7 +704,7 @@ test:do_catchsql_test(
 test:do_catchsql_test(
     "table-9.2",
     [[
-        CREATE TABLE t6(a varchar(100) primary key, b blob, a integer);
+        CREATE TABLE t6(a varchar(100) primary key, b SCALAR, a integer);
     ]], {
         -- <table-9.2>
         1, "Space field 'A' is duplicate"
@@ -895,8 +895,8 @@ test:do_execsql_test(
            b FLOAT,
            c VARCHAR(8),
            d VARCHAR(9),
-           e blob,
-           f BLOB,
+           e SCALAR,
+           f SCALAR,
            g Text,
            h text
         );
@@ -1142,7 +1142,7 @@ test:do_test(
 --   DROP TABLE IF EXISTS t1;
 --   BEGIN;
 --   CREATE TABLE t1 AS SELECT zeroblob(2e20);
--- } {1 {string or blob too big}}
+-- } {1 {string or SCALAR too big}}
 -- do_execsql_test table-18.2 {
 --   COMMIT;
 --   PRAGMA integrity_check;
diff --git a/test/sql-tap/tkt1443.test.lua b/test/sql-tap/tkt1443.test.lua
index e42ef9900..35f9f3226 100755
--- a/test/sql-tap/tkt1443.test.lua
+++ b/test/sql-tap/tkt1443.test.lua
@@ -85,7 +85,7 @@ test:do_test(
             CREATE TABLE Users (
                 userId INTEGER PRIMARY KEY,
                 "user" TEXT UNIQUE,
-                salt  BLOB,
+                salt  SCALAR,
                 password  TEXT
             );
             INSERT INTO Users VALUES(1, 'test', 'Šæ%s',
diff --git a/test/sql-tap/tkt1449.test.lua b/test/sql-tap/tkt1449.test.lua
index 54c58452b..87403000f 100755
--- a/test/sql-tap/tkt1449.test.lua
+++ b/test/sql-tap/tkt1449.test.lua
@@ -37,28 +37,28 @@ test:do_execsql_test(
         CREATE TABLE ACLS(ISSUEID varchar(50) not null, OBJECTID varchar(50) not null, PARTICIPANTID varchar(50) not null, PERMISSIONBITS int not null, constraint PK_ACLS primary key (ISSUEID, OBJECTID, PARTICIPANTID));
         CREATE TABLE ACTIONITEMSTATUSES(CLASSID int null, SEQNO int not null, LASTMODONNODEID varchar(50) not null, PREVMODONNODEID varchar(50) null, ISSUEID varchar(50) not null, OBJECTID varchar(50) not null, REVISIONNUM int not null, CONTAINERID varchar(50) not null, AUTHORID varchar(50) not null, CREATIONDATE varchar(25) null, LASTMODIFIEDDATE varchar(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD varchar(300) null, LASTMODIFIEDBYID varchar(50) null, FRIENDLYNAME varchar(100) not null, REVISION int not null, SHORTNAME varchar(30) not null, LONGNAME varchar(200) not null, ATTACHMENTHANDLING int not null, RESULT int not null, NOTIFYCREATOR varchar(1) null, NOTIFYASSIGNEE varchar(1) null, NOTIFYFYI varchar(1) null, NOTIFYCLOSURETEAM varchar(1) null, NOTIFYCOORDINATORS varchar(1) null, COMMENTREQUIRED varchar(1) not null, constraint PK_ACTIONITEMSTATUSES primary key (ISSUEID, OBJECTID));
         CREATE TABLE ACTIONITEMTYPES(CLASSID int null, SEQNO int not null, LASTMODONNODEID varchar(50) not null, PREVMODONNODEID varchar(50) null, ISSUEID varchar(50) not null, OBJECTID varchar(50) not null, REVISIONNUM int not null, CONTAINERID varchar(50) not null, AUTHORID varchar(50) not null, CREATIONDATE varchar(25) null, LASTMODIFIEDDATE varchar(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD varchar(300) null, LASTMODIFIEDBYID varchar(50) null, REVISION int not null, LABEL varchar(200) not null, INSTRUCTIONS text not null, EMAILINSTRUCTIONS text null, ALLOWEDSTATUSES text not null, INITIALSTATUS varchar(100) not null, COMMENTREQUIRED varchar(1) not null, ATTACHMENTHANDLING int not null, constraint PK_ACTIONITEMTYPES primary key (ISSUEID, OBJECTID));
-        CREATE TABLE ATTACHMENTS(TQUNID varchar(36) not null, OBJECTID varchar(50) null, ISSUEID varchar(50) null, DATASTREAM blob not null, CONTENTENCODING varchar(50) null, CONTENTCHARSET varchar(50) null, CONTENTTYPE varchar(100) null, CONTENTID varchar(100) null, CONTENTLOCATION varchar(100) null, CONTENTNAME varchar(100) not null, constraint PK_ATTACHMENTS primary key (TQUNID));
+        CREATE TABLE ATTACHMENTS(TQUNID varchar(36) not null, OBJECTID varchar(50) null, ISSUEID varchar(50) null, DATASTREAM SCALAR not null, CONTENTENCODING varchar(50) null, CONTENTCHARSET varchar(50) null, CONTENTTYPE varchar(100) null, CONTENTID varchar(100) null, CONTENTLOCATION varchar(100) null, CONTENTNAME varchar(100) not null, constraint PK_ATTACHMENTS primary key (TQUNID));
         CREATE TABLE COMPLIANCEPOLICIES(CLASSID int null, SEQNO int not null, LASTMODONNODEID varchar(50) not null, PREVMODONNODEID varchar(50) null, ISSUEID varchar(50) not null, OBJECTID varchar(50) not null, REVISIONNUM int not null, CONTAINERID varchar(50) not null, AUTHORID varchar(50) not null, CREATIONDATE varchar(25) null, LASTMODIFIEDDATE varchar(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD varchar(300) null, LASTMODIFIEDBYID varchar(50) null, BODY text null, constraint PK_COMPLIANCEPOLICIES primary key (ISSUEID, OBJECTID));
         CREATE TABLE DBHISTORY(id INT primary key, "DATETIME" varchar(25) not null, OPERATION varchar(20) not null, KUBIVERSION varchar(100) not null, FROMVERSION int null, TOVERSION int null);
         CREATE TABLE DBINFO(id INT primary key, FINGERPRINT varchar(32) not null, VERSION int not null);
         CREATE TABLE DETACHEDATTACHMENTS (TQUNID varchar(36) not null, ISSUEID varchar(50) not null, OBJECTID varchar(50) not null, PATH varchar(300) not null, DETACHEDFILELASTMODTIMESTAMP varchar(25) null, CONTENTID varchar(100) not null, constraint PK_DETACHEDATTACHMENTS primary key (TQUNID));
         CREATE TABLE DOCREFERENCES(CLASSID int null, SEQNO int not null, LASTMODONNODEID varchar(50) not null, PREVMODONNODEID varchar(50) null, ISSUEID varchar(50) not null, OBJECTID varchar(50) not null, REVISIONNUM int not null, CONTAINERID varchar(50) not null, AUTHORID varchar(50) not null, CREATIONDATE varchar(25) null, LASTMODIFIEDDATE varchar(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD varchar(300) null, LASTMODIFIEDBYID varchar(50) null, REFERENCEDOCUMENTID varchar(50) null, constraint PK_DOCREFERENCES primary key (ISSUEID, OBJECTID));
-        CREATE TABLE DQ (TQUNID varchar(36) not null, ISSUEID varchar(50) not null, DEPENDSID varchar(50) null, DEPENDSTYPE int null, DEPENDSCOMMANDSTREAM blob null, DEPENDSNODEIDSEQNOKEY varchar(100) null, DEPENDSACLVERSION int null, constraint PK_DQ primary key (TQUNID));
-        CREATE TABLE EMAILQ(id INT primary key, TIMEQUEUED int not null, NODEID varchar(50) not null, MIME blob not null, TQUNID varchar(36) not null);
+        CREATE TABLE DQ (TQUNID varchar(36) not null, ISSUEID varchar(50) not null, DEPENDSID varchar(50) null, DEPENDSTYPE int null, DEPENDSCOMMANDSTREAM SCALAR null, DEPENDSNODEIDSEQNOKEY varchar(100) null, DEPENDSACLVERSION int null, constraint PK_DQ primary key (TQUNID));
+        CREATE TABLE EMAILQ(id INT primary key, TIMEQUEUED int not null, NODEID varchar(50) not null, MIME SCALAR not null, TQUNID varchar(36) not null);
         CREATE TABLE ENTERPRISEDATA(CLASSID int null, SEQNO int not null, LASTMODONNODEID varchar(50) not null, PREVMODONNODEID varchar(50) null, ISSUEID varchar(50) not null, OBJECTID varchar(50) not null, REVISIONNUM int not null, CONTAINERID varchar(50) not null, AUTHORID varchar(50) not null, CREATIONDATE varchar(25) null, LASTMODIFIEDDATE varchar(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD varchar(300) null, LASTMODIFIEDBYID varchar(50) null, DATE1 varchar(25) null, DATE2 varchar(25) null, DATE3 varchar(25) null, DATE4 varchar(25) null, DATE5 varchar(25) null, DATE6 varchar(25) null, DATE7 varchar(25) null, DATE8 varchar(25) null, DATE9 varchar(25) null, DATE10 varchar(25) null, VALUE1 int null, VALUE2 int null, VALUE3 int null, VALUE4 int null, VALUE5 int null, VALUE6 int null, VALUE7 int null, VALUE8 int null, VALUE9 int null, VALUE10 int null, VALUE11 int null, VALUE12 int null, VALUE13 int null, V
 ALUE14 int null, VALUE15 int null, VALUE16 int null, VALUE17 int null, VALUE18 int null, VALUE19 int null, VALUE20 int null, STRING1 varchar(300) null, STRING2 varchar(300) null, STRING3 varchar(300) null, STRING4 varchar(300) null, STRING5 varchar(300) null, STRING6 varchar(300) null, STRING7 varchar(300) null, STRING8 varchar(300) null, STRING9 varchar(300) null, STRING10 varchar(300) null, LONGSTRING1 text null, LONGSTRING2 text null, LONGSTRING3 text null, LONGSTRING4 text null, LONGSTRING5 text null, LONGSTRING6 text null, LONGSTRING7 text null, LONGSTRING8 text null, LONGSTRING9 text null, LONGSTRING10 text null, constraint PK_ENTERPRISEDATA primary key (ISSUEID, OBJECTID));
         CREATE TABLE FILEMORGUE(TQUNID varchar(36) not null, PATH varchar(300) not null, DELETEFOLDERWHENEMPTY varchar(1) null, constraint PK_FILEMORGUE primary key (TQUNID));
         CREATE TABLE FILES(CLASSID int null, SEQNO int not null, LASTMODONNODEID varchar(50) not null, PREVMODONNODEID varchar(50) null, ISSUEID varchar(50) not null, OBJECTID varchar(50) not null, REVISIONNUM int not null, CONTAINERID varchar(50) not null, AUTHORID varchar(50) not null, CREATIONDATE varchar(25) null, LASTMODIFIEDDATE varchar(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD varchar(300) null, LASTMODIFIEDBYID varchar(50) null, PARENTENTITYID varchar(50) null, BODY text null, BODYCONTENTTYPE varchar(100) null, ISOBSOLETE varchar(1) null, FILENAME varchar(300) not null, VISIBLENAME varchar(300) not null, VERSIONSTRING varchar(300) not null, DOCUMENTHASH varchar(40) not null, ISFINAL varchar(1) null, DOCREFERENCEID varchar(50) not null, constraint PK_FILES primary key (ISSUEID, OBJECTID));
         CREATE TABLE FOLDERS(CLASSID int null, SEQNO int not null, LASTMODONNODEID varchar(50) not null, PREVMODONNODEID varchar(50) null, ISSUEID varchar(50) not null, OBJECTID varchar(50) not null, REVISIONNUM int not null, CONTAINERID varchar(50) not null, AUTHORID varchar(50) not null, CREATIONDATE varchar(25) null, LASTMODIFIEDDATE varchar(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD varchar(300) null, LASTMODIFIEDBYID varchar(50) null, CONTAINERNAME varchar(300) null, CONTAINERACLSETTINGS text null, constraint PK_FOLDERS primary key (ISSUEID, OBJECTID));
         CREATE TABLE GLOBALSETTINGS(CLASSID int null, SEQNO int not null, LASTMODONNODEID varchar(50) not null, PREVMODONNODEID varchar(50) null, ISSUEID varchar(50) not null, OBJECTID varchar(50) not null, REVISIONNUM int not null, CONTAINERID varchar(50) not null, AUTHORID varchar(50) not null, CREATIONDATE varchar(25) null, LASTMODIFIEDDATE varchar(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD varchar(300) null, LASTMODIFIEDBYID varchar(50) null, SINGULARPROJECTLABEL varchar(30) not null, PLURALPROJECTLABEL varchar(30) not null, PROJECTREQUIRED varchar(1) not null, CUSTOMPROJECTSALLOWED varchar(1) not null, ACTIONITEMSPECXML text null, PROJECTLISTXML text null, ENTERPRISEDATALABELS text null, ENTERPRISEDATATABXSL text null, constraint PK_GLOBALSETTINGS primary key (ISSUEID, OBJECTID));
         CREATE TABLE GLOBALSTRINGPROPERTIES(ID int not null, VALUE varchar(300) not null, constraint PK_GLOBALSTRINGPROPERTIES primary key (ID));
-        CREATE TABLE IMQ(TQUNID varchar(36) not null, DATETIMEQUEUED varchar(25) not null, ISSUEID varchar(50) not null, KUBIBUILD varchar(30) not null, FAILCOUNT int not null, LASTRUN varchar(25) null, ENVELOPESTREAM blob not null, PAYLOADSTREAM blob not null, constraint PK_IMQ primary key (TQUNID));
+        CREATE TABLE IMQ(TQUNID varchar(36) not null, DATETIMEQUEUED varchar(25) not null, ISSUEID varchar(50) not null, KUBIBUILD varchar(30) not null, FAILCOUNT int not null, LASTRUN varchar(25) null, ENVELOPESTREAM SCALAR not null, PAYLOADSTREAM SCALAR not null, constraint PK_IMQ primary key (TQUNID));
         CREATE TABLE INVITATIONNODES(INVITATIONID varchar(50) not null, RECIPIENTNODEID varchar(50) not null, DATECREATED varchar(25) not null, constraint PK_INVITATIONNODES primary key (INVITATIONID, RECIPIENTNODEID));
-        CREATE TABLE INVITATIONS (id INT primary key, INVITATIONID varchar(50) not null, SENDERNODEID varchar(50) not null, RECIPIENTEMAILADDR varchar(200) not null, RECIPIENTUSERID varchar(50) null, RECIPIENTNODES text null, ISSUEID varchar(50) not null, ENVELOPE text not null, MESSAGEBLOB blob not null, INVITATIONSTATE int not null, TQUNID varchar(36) not null, DATECREATED varchar(25) not null);
+        CREATE TABLE INVITATIONS (id INT primary key, INVITATIONID varchar(50) not null, SENDERNODEID varchar(50) not null, RECIPIENTEMAILADDR varchar(200) not null, RECIPIENTUSERID varchar(50) null, RECIPIENTNODES text null, ISSUEID varchar(50) not null, ENVELOPE text not null, MESSAGEBLOB SCALAR not null, INVITATIONSTATE int not null, TQUNID varchar(36) not null, DATECREATED varchar(25) not null);
         CREATE TABLE ISSUES (CLASSID int null, SEQNO int not null, LASTMODONNODEID varchar(50) not null, PREVMODONNODEID varchar(50) null, ISSUEID varchar(50) not null, OBJECTID varchar(50) not null, REVISIONNUM int not null, CONTAINERID varchar(50) not null, AUTHORID varchar(50) not null, CREATIONDATE varchar(25) null, LASTMODIFIEDDATE varchar(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD varchar(300) null, LASTMODIFIEDBYID varchar(50) null, CONTAINERNAME varchar(300) null, CONTAINERACLSETTINGS text null, ISINITIALIZED varchar(1) null, BLINDINVITES text null, ISSYSTEMISSUE varchar(1) not null, ISSUETYPE int not null, ACTIVITYTYPEID varchar(50) null, ISINCOMPLETE varchar(1) not null, constraint PK_ISSUES primary key (ISSUEID, OBJECTID));
         CREATE TABLE ISSUESETTINGS (CLASSID int null, SEQNO int not null, LASTMODONNODEID varchar(50) not null, PREVMODONNODEID varchar(50) null, ISSUEID varchar(50) not null, OBJECTID varchar(50) not null, REVISIONNUM int not null, CONTAINERID varchar(50) not null, AUTHORID varchar(50) not null, CREATIONDATE varchar(25) null, LASTMODIFIEDDATE varchar(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD varchar(300) null, LASTMODIFIEDBYID varchar(50) null, ISSUENAME varchar(300) not null, ISSUEACLSETTINGS text not null, ISSUEDUEDATE varchar(25) null, ISSUEPRIORITY int null, ISSUESTATUS int null, DESCRIPTION text null, PROJECTID varchar(100) null, PROJECTNAME text null, PROJECTNAMEISCUSTOM varchar(1) null, ISSYSTEMISSUE varchar(1) not null, ACTIONITEMREVNUM int not null, constraint PK_ISSUESETTINGS primary key (ISSUEID, OBJECTID));
-        CREATE TABLE KMTPMSG (MSGID integer not null, SENDERID varchar(50) null, RECIPIENTIDLIST text not null, ISSUEID varchar(50) null, MESSAGETYPE int not null, ENVELOPE text null, MESSAGEBLOB blob not null, RECEIVEDDATE varchar(25) not null, constraint PK_KMTPMSG primary key (MSGID));
+        CREATE TABLE KMTPMSG (MSGID integer not null, SENDERID varchar(50) null, RECIPIENTIDLIST text not null, ISSUEID varchar(50) null, MESSAGETYPE int not null, ENVELOPE text null, MESSAGEBLOB SCALAR not null, RECEIVEDDATE varchar(25) not null, constraint PK_KMTPMSG primary key (MSGID));
         CREATE TABLE KMTPNODEQ(id INT primary key, NODEID varchar(50) not null, MSGID int not null, RECEIVEDDATE varchar(25) not null, SENDCOUNT int not null);
-        CREATE TABLE KMTPQ(MSGID integer not null, SENDERID varchar(50) null, RECIPIENTIDLIST text not null, ISSUEID varchar(50) null, MESSAGETYPE int not null, ENVELOPE text null, MESSAGEBLOB blob not null, constraint PK_KMTPQ primary key (MSGID));
+        CREATE TABLE KMTPQ(MSGID integer not null, SENDERID varchar(50) null, RECIPIENTIDLIST text not null, ISSUEID varchar(50) null, MESSAGETYPE int not null, ENVELOPE text null, MESSAGEBLOB SCALAR not null, constraint PK_KMTPQ primary key (MSGID));
         CREATE TABLE LOGENTRIES(CLASSID int null, SEQNO int not null, LASTMODONNODEID varchar(50) not null, PREVMODONNODEID varchar(50) null, ISSUEID varchar(50) not null, OBJECTID varchar(50) not null, REVISIONNUM int not null, CONTAINERID varchar(50) not null, AUTHORID varchar(50) not null, CREATIONDATE varchar(25) null, LASTMODIFIEDDATE varchar(25) null, UPDATENUMBER int null, PREVREVISIONNUM int null, LASTCMD int null, LASTCMDACLVERSION int null, USERDEFINEDFIELD varchar(300) null, LASTMODIFIEDBYID varchar(50) null, PARENTENTITYID varchar(50) null, BODY text null, BODYCONTENTTYPE varchar(100) null, ISOBSOLETE varchar(1) null, ACTIONTYPE int not null, ASSOCIATEDOBJECTIDS text null, OLDENTITIES text null, NEWENTITIES text null, OTHERENTITIES text null, constraint PK_LOGENTRIES primary key (ISSUEID, OBJECTID));
         CREATE TABLE LSBI(TQUNID varchar(36) not null, ISSUEID varchar(50) not null, TABLEITEMID varchar(50) null, TABLENODEID varchar(50) null, TABLECMD int null, TABLECONTAINERID varchar(50) null, TABLESEQNO int null, DIRTYCONTENT text null, STUBBED varchar(1) null, ENTITYSTUBDATA text null, UPDATENUMBER int not null, constraint PK_LSBI primary key (TQUNID));
         CREATE TABLE LSBN(TQUNID varchar(36) not null, ISSUEID varchar(50) not null, NODEID varchar(50) not null, STORESEQNO int not null, SYNCSEQNO int not null, LASTMSGDATE varchar(25) null, constraint PK_LSBN primary key (TQUNID));
diff --git a/test/sql-tap/types2.test.lua b/test/sql-tap/types2.test.lua
index bce42e796..0640c8048 100755
--- a/test/sql-tap/types2.test.lua
+++ b/test/sql-tap/types2.test.lua
@@ -43,7 +43,7 @@ test:execsql [[
       n2 NUMERIC,
       t1 TEXT,
       t2 TEXT,
-      o1 BLOB,
+      o1 SCALAR,
       o2 BLOB
     );
     INSERT INTO t1 VALUES(1, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
@@ -112,7 +112,7 @@ test_bool("types2-1.28", "o1='500'", "'500.0' = o1", 0)
 local vals = { 10, "10.0", "'10'", "'10.0'", 20, "20.0", "'20'", "'20.0'", 30, "30.0", "'30'", "'30.0'" }
 --             1    2      3         4      5  6       7        8      9    10       11   12
 test:execsql [[
-    CREATE TABLE t2(id  INT primary key, i INTEGER, n NUMERIC, t TEXT, o BLOB);
+    CREATE TABLE t2(id  INT primary key, i INTEGER, n NUMERIC, t TEXT, o SCALAR);
     CREATE INDEX t2i1 ON t2(i);
     CREATE INDEX t2i2 ON t2(n);
     CREATE INDEX t2i3 ON t2(t);
@@ -274,7 +274,7 @@ test_boolset("types2-6.9", "id IN (1, 6, 10)", {1, 6, 10})
 -- Tests types2-7.* concentrate on expressions of the form 
 -- "x IN (SELECT...)" with no index.
 test:execsql [[
-    CREATE TABLE t3(id  INT primary key, i INTEGER, n NUMERIC, t TEXT, o BLOB);
+    CREATE TABLE t3(id  INT primary key, i INTEGER, n NUMERIC, t TEXT, o SCALAR);
     INSERT INTO t3 VALUES(1, 1, 1, 1, 1);
     INSERT INTO t3 VALUES(2, 2, 2, 2, 2);
     INSERT INTO t3 VALUES(3, 3, 3, 3, 3);
@@ -306,7 +306,7 @@ test_bool("types2-7.15", "o1='2'", "o1 IN (SELECT o||'' FROM t3)", 1)
 -- set vals [list 10 10.0 '10' '10.0' 20 20.0 '20' '20.0' 30 30.0 '30' '30.0']
 --                1  2    3    4      5  6    7    8      9  10   11   12
 test:execsql [[
-    CREATE TABLE t4(id  INT primary key, i INTEGER, n NUMERIC, t VARCHAR(20), o BLOB);
+    CREATE TABLE t4(id  INT primary key, i INTEGER, n NUMERIC, t VARCHAR(20), o SCALAR);
     INSERT INTO t4 VALUES(1, 10, 20, 20, 30);
 ]]
 test_boolset("types2-8.1", "i IN (SELECT i FROM t4)", {1, 2, 3, 4})
diff --git a/test/sql-tap/whereB.test.lua b/test/sql-tap/whereB.test.lua
index 6ecc3cc5d..e04e37dc4 100755
--- a/test/sql-tap/whereB.test.lua
+++ b/test/sql-tap/whereB.test.lua
@@ -129,7 +129,7 @@ test:do_execsql_test(
         CREATE TABLE t1(x  INT primary key, y TEXT);    -- affinity of t1.y is TEXT
         INSERT INTO t1 VALUES(1,99);
 
-        CREATE TABLE t2(a  INT primary key, b BLOB);  -- affinity of t2.b is NONE
+        CREATE TABLE t2(a  INT primary key, b SCALAR);  -- affinity of t2.b is NONE
         CREATE INDEX t2b ON t2(b);
         INSERT INTO t2 VALUES(2, 99);
 
@@ -222,10 +222,10 @@ test:do_execsql_test(
         DROP TABLE t1;
         DROP TABLE t2;
 
-        CREATE TABLE t1(x  INT primary key, y BLOB);    -- affinity of t1.y is NONE
+        CREATE TABLE t1(x  INT primary key, y SCALAR);    -- affinity of t1.y is NONE
         INSERT INTO t1 VALUES(1,99);
 
-        CREATE TABLE t2(a  INT primary key, b BLOB);  -- affinity of t2.b is NONE
+        CREATE TABLE t2(a  INT primary key, b SCALAR);  -- affinity of t2.b is NONE
         CREATE INDEX t2b ON t2(b);
         INSERT INTO t2 VALUES(2,'99');
 
@@ -318,7 +318,7 @@ test:do_execsql_test(
         DROP TABLE IF EXISTS t1;
         DROP TABLE IF EXISTS t2;
 
-        CREATE TABLE t1(x  INT primary key, y BLOB);    -- affinity of t1.y is NONE
+        CREATE TABLE t1(x  INT primary key, y SCALAR);    -- affinity of t1.y is NONE
         INSERT INTO t1 VALUES(1,'99');
 
         CREATE TABLE t2(a  INT primary key, b FLOAT);  -- affinity of t2.b is NUMERIC
@@ -418,7 +418,7 @@ test:do_execsql_test(
         DROP TABLE t1;
         DROP TABLE t2;
 
-        CREATE TABLE t1(x  INT primary key, y BLOB);    -- affinity of t1.y is NONE
+        CREATE TABLE t1(x  INT primary key, y SCALAR);    -- affinity of t1.y is NONE
         INSERT INTO t1 VALUES(1,'99');
 
         CREATE TABLE t2(a  INT primary key, b INT);  -- affinity of t2.b is INTEGER
@@ -518,7 +518,7 @@ test:do_execsql_test(
         DROP TABLE t1;
         DROP TABLE t2;
 
-        CREATE TABLE t1(x  INT primary key, y BLOB);    -- affinity of t1.y is NONE
+        CREATE TABLE t1(x  INT primary key, y SCALAR);    -- affinity of t1.y is NONE
         INSERT INTO t1 VALUES(1,'99');
 
         CREATE TABLE t2(a  INT primary key, b FLOAT);  -- affinity of t2.b is REAL
@@ -621,7 +621,7 @@ test:do_execsql_test(
         CREATE TABLE t1(x  INT primary key, y FLOAT);  -- affinity of t1.y is NUMERIC
         INSERT INTO t1 VALUES(1,99);
 
-        CREATE TABLE t2(a  INT primary key, b BLOB);  -- affinity of t2.b is NONE
+        CREATE TABLE t2(a  INT primary key, b SCALAR);  -- affinity of t2.b is NONE
         CREATE INDEX t2b ON t2(b);
         INSERT INTO t2 VALUES(2,'99');
 
@@ -721,7 +721,7 @@ test:do_execsql_test(
         CREATE TABLE t1(x  INT primary key, y INT);  -- affinity of t1.y is INTEGER
         INSERT INTO t1 VALUES(1,99);
 
-        CREATE TABLE t2(a  INT primary key, b BLOB);  -- affinity of t2.b is NONE
+        CREATE TABLE t2(a  INT primary key, b SCALAR);  -- affinity of t2.b is NONE
         CREATE INDEX t2b ON t2(b);
         INSERT INTO t2 VALUES(2,'99');
 
@@ -821,7 +821,7 @@ test:do_execsql_test(
         CREATE TABLE t1(x  INT primary key, y FLOAT);  -- affinity of t1.y is REAL
         INSERT INTO t1 VALUES(1,99.0);
 
-        CREATE TABLE t2(a  INT primary key, b BLOB);  -- affinity of t2.b is NONE
+        CREATE TABLE t2(a  INT primary key, b SCALAR);  -- affinity of t2.b is NONE
         CREATE INDEX t2b ON t2(b);
         INSERT INTO t2 VALUES(2,'99');
 
diff --git a/test/sql/gh-3888-values-blob-assert.result b/test/sql/gh-3888-values-blob-assert.result
index 67948cd3f..8deded7d0 100644
--- a/test/sql/gh-3888-values-blob-assert.result
+++ b/test/sql/gh-3888-values-blob-assert.result
@@ -14,18 +14,18 @@ box.sql.execute('pragma sql_default_engine=\''..engine..'\'')
 ---
 ...
 -- check 'VALUES' against typedef keywords (should fail)
-box.sql.execute('VALUES(blob)')
+box.sql.execute('VALUES(scalar)')
 ---
-- error: 'near "blob": syntax error'
+- error: 'near "scalar": syntax error'
 ...
 box.sql.execute('VALUES(float)')
 ---
 - error: 'near "float": syntax error'
 ...
 -- check 'SELECT' against typedef keywords (should fail)
-box.sql.execute('SELECT blob')
+box.sql.execute('SELECT scalar')
 ---
-- error: 'near "blob": syntax error'
+- error: 'near "scalar": syntax error'
 ...
 box.sql.execute('SELECT float')
 ---
diff --git a/test/sql/gh-3888-values-blob-assert.test.lua b/test/sql/gh-3888-values-blob-assert.test.lua
index 9adab488c..6e916c258 100644
--- a/test/sql/gh-3888-values-blob-assert.test.lua
+++ b/test/sql/gh-3888-values-blob-assert.test.lua
@@ -9,11 +9,11 @@ engine = test_run:get_cfg('engine')
 box.sql.execute('pragma sql_default_engine=\''..engine..'\'')
 
 -- check 'VALUES' against typedef keywords (should fail)
-box.sql.execute('VALUES(blob)')
+box.sql.execute('VALUES(scalar)')
 box.sql.execute('VALUES(float)')
 
 -- check 'SELECT' against typedef keywords (should fail)
-box.sql.execute('SELECT blob')
+box.sql.execute('SELECT scalar')
 box.sql.execute('SELECT float')
 
 -- check 'VALUES' against ID (should fail)
diff --git a/test/sql/transition.result b/test/sql/transition.result
index e7613c344..ea110c03c 100644
--- a/test/sql/transition.result
+++ b/test/sql/transition.result
@@ -178,7 +178,7 @@ box.sql.execute("DROP TABLE barfoo")
 ---
 ...
 -- attempt to create a table lacking PRIMARY KEY
-box.sql.execute("CREATE TABLE without_rowid_lacking_primary_key(x BLOB)")
+box.sql.execute("CREATE TABLE without_rowid_lacking_primary_key(x SCALAR)")
 ---
 - error: PRIMARY KEY missing on table WITHOUT_ROWID_LACKING_PRIMARY_KEY
 ...
diff --git a/test/sql/transition.test.lua b/test/sql/transition.test.lua
index 276ff7174..2fbee6255 100644
--- a/test/sql/transition.test.lua
+++ b/test/sql/transition.test.lua
@@ -63,7 +63,7 @@ box.sql.execute("DROP TABLE foobar")
 box.sql.execute("DROP TABLE barfoo")
 
 -- attempt to create a table lacking PRIMARY KEY
-box.sql.execute("CREATE TABLE without_rowid_lacking_primary_key(x BLOB)")
+box.sql.execute("CREATE TABLE without_rowid_lacking_primary_key(x SCALAR)")
 
 -- create a table with implicit indices (used to SEGFAULT)
 box.sql.execute("CREATE TABLE implicit_indices(a INT PRIMARY KEY,b INT,c INT,d TEXT UNIQUE)")
diff --git a/test/sql/types.result b/test/sql/types.result
index a0159d661..11b045c05 100644
--- a/test/sql/types.result
+++ b/test/sql/types.result
@@ -28,7 +28,7 @@ box.sql.execute("CREATE TABLE t1 (id INT PRIMARY KEY, a INT, b UNIQUE);")
 ...
 -- gh-3104: real type is stored in space format.
 --
-box.sql.execute("CREATE TABLE t1 (id TEXT PRIMARY KEY, a REAL, b INT, c TEXT, d BLOB);")
+box.sql.execute("CREATE TABLE t1 (id TEXT PRIMARY KEY, a REAL, b INT, c TEXT, d SCALAR);")
 ---
 ...
 box.space.T1:format()
@@ -155,20 +155,16 @@ box.sql.execute("SELECt 'a' || 'b' || 1;")
 ...
 -- What is more, they must be of the same type.
 --
-box.sql.execute("SELECT 'abc' || CAST('x' AS BLOB);")
+box.sql.execute("SELECT 'abc' || randomblob(5);")
 ---
 - error: 'Inconsistent types: expected TEXT got BLOB'
 ...
-box.sql.execute("SELECT CAST('abc' AS BLOB) || 'x';")
+box.sql.execute("SELECT randomblob(5) || 'x';")
 ---
 - error: 'Inconsistent types: expected BLOB got TEXT'
 ...
 -- Result of BLOBs concatenation must be BLOB.
 --
-box.sql.execute("SELECT TYPEOF(CAST('abc' AS BLOB) || CAST('cda' AS BLOB))")
----
-- - ['blob']
-...
 box.sql.execute("VALUES (TYPEOF(randomblob(5) || zeroblob(5)));")
 ---
 - - ['blob']
diff --git a/test/sql/types.test.lua b/test/sql/types.test.lua
index b944b081b..799e9aed3 100644
--- a/test/sql/types.test.lua
+++ b/test/sql/types.test.lua
@@ -11,7 +11,7 @@ box.sql.execute("CREATE TABLE t1 (id INT PRIMARY KEY, a INT, b UNIQUE);")
 
 -- gh-3104: real type is stored in space format.
 --
-box.sql.execute("CREATE TABLE t1 (id TEXT PRIMARY KEY, a REAL, b INT, c TEXT, d BLOB);")
+box.sql.execute("CREATE TABLE t1 (id TEXT PRIMARY KEY, a REAL, b INT, c TEXT, d SCALAR);")
 box.space.T1:format()
 box.sql.execute("CREATE VIEW v1 AS SELECT b + a, b - a FROM t1;")
 box.space.V1:format()
@@ -50,9 +50,8 @@ box.sql.execute("SELECT 1.123 || 'abc';")
 box.sql.execute("SELECt 'a' || 'b' || 1;")
 -- What is more, they must be of the same type.
 --
-box.sql.execute("SELECT 'abc' || CAST('x' AS BLOB);")
-box.sql.execute("SELECT CAST('abc' AS BLOB) || 'x';")
+box.sql.execute("SELECT 'abc' || randomblob(5);")
+box.sql.execute("SELECT randomblob(5) || 'x';")
 -- Result of BLOBs concatenation must be BLOB.
 --
-box.sql.execute("SELECT TYPEOF(CAST('abc' AS BLOB) || CAST('cda' AS BLOB))")
 box.sql.execute("VALUES (TYPEOF(randomblob(5) || zeroblob(5)));")
-- 
2.15.1

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [tarantool-patches] Re: [PATCH 1/4] sql: remove support of DATE/TIME from parser
  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   ` Konstantin Osipov
  0 siblings, 0 replies; 11+ messages in thread
From: Konstantin Osipov @ 2019-03-07 13:34 UTC (permalink / raw)
  To: tarantool-patches; +Cc: v.shpilevoy, Nikita Pettik

* Nikita Pettik <korablev@tarantool.org> [19/03/07 16:18]:
> Currently, there is no native (in Tarantool terms) types to represent
> time-like types. So, until we add implementation of those types, it
> makes no sense to allow to specify those types in table definition.
> Note that previously they were mapped to NUMBER type. For the same
> reason all built-in functions connected with DATE/TIME are disabled as
> well.
> 
> Part of #4019
> ---

It's amazing how small this patch is. LGTM.


-- 
Konstantin Osipov, Moscow, Russia, +7 903 626 22 32
http://tarantool.io - www.twitter.com/kostja_osipov

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [tarantool-patches] Re: [PATCH 2/4] sql: remove support of CHAR type from parser
  2019-03-07 13:14 ` [tarantool-patches] [PATCH 2/4] sql: remove support of CHAR type " Nikita Pettik
@ 2019-03-07 13:35   ` Konstantin Osipov
  0 siblings, 0 replies; 11+ messages in thread
From: Konstantin Osipov @ 2019-03-07 13:35 UTC (permalink / raw)
  To: tarantool-patches; +Cc: v.shpilevoy, Nikita Pettik

* Nikita Pettik <korablev@tarantool.org> [19/03/07 16:18]:
> 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.

LGTM.


-- 
Konstantin Osipov, Moscow, Russia, +7 903 626 22 32
http://tarantool.io - www.twitter.com/kostja_osipov

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [tarantool-patches] Re: [PATCH 3/4] sql: remove support of NUMERIC type from parser
  2019-03-07 13:14 ` [tarantool-patches] [PATCH 3/4] sql: remove support of NUMERIC " Nikita Pettik
@ 2019-03-07 13:36   ` Konstantin Osipov
  0 siblings, 0 replies; 11+ messages in thread
From: Konstantin Osipov @ 2019-03-07 13:36 UTC (permalink / raw)
  To: tarantool-patches; +Cc: v.shpilevoy, Nikita Pettik

* Nikita Pettik <korablev@tarantool.org> [19/03/07 16:18]:
> NMERIC and DECIMAL were allowed to be specified as column types. But in
> fact, they were just synonyms for FLOAT type and mapped to NUMERIC
> Tarantool NoSQL type. So, we've decided to remove this type from parser
> and return back when NUMERIC will be implemented as a native type.

OK to push.

-- 
Konstantin Osipov, Moscow, Russia, +7 903 626 22 32
http://tarantool.io - www.twitter.com/kostja_osipov

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [tarantool-patches] Re: [PATCH 4/4] sql: replace BLOB as column type with SCALAR
  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   ` Konstantin Osipov
  2019-03-07 14:00     ` n.pettik
  0 siblings, 1 reply; 11+ messages in thread
From: Konstantin Osipov @ 2019-03-07 13:40 UTC (permalink / raw)
  To: tarantool-patches; +Cc: v.shpilevoy, Nikita Pettik

* Nikita Pettik <korablev@tarantool.org> [19/03/07 16:18]:
> BLOB column type is represented by SCALAR field type in terms of NoSQL.
> We attempted at emulating BLOB behaviour, but such efforts turn out to
> be not decent enough. For this reason, we've decided to abandon these
> attempts and fairly replace it with SCALAR column type.  SCALAR column
> type acts in the same way as it does in NoSQL: it is aggregator-type for
> INTEGER, NUMBER and STRING types. So, column declared with this type can
> contain values of these three (available in SQL) types. It is worth
> mentioning that CAST operator in this case does nothing.
> 

Shouldn't we keep the BLOB keyword in the list of reserved words?

The same applies to DATE/TIME and other words which are reserved
in SQL standard.

The patch itself LGTM.


-- 
Konstantin Osipov, Moscow, Russia, +7 903 626 22 32
http://tarantool.io - www.twitter.com/kostja_osipov

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [tarantool-patches] Re: [PATCH 4/4] sql: replace BLOB as column type with SCALAR
  2019-03-07 13:40   ` [tarantool-patches] " Konstantin Osipov
@ 2019-03-07 14:00     ` n.pettik
  0 siblings, 0 replies; 11+ messages in thread
From: n.pettik @ 2019-03-07 14:00 UTC (permalink / raw)
  To: tarantool-patches; +Cc: Konstantin Osipov, Kirill Yukhin



> On 7 Mar 2019, at 16:40, Konstantin Osipov <kostja@tarantool.org> wrote:
> 
> * Nikita Pettik <korablev@tarantool.org> [19/03/07 16:18]:
>> BLOB column type is represented by SCALAR field type in terms of NoSQL.
>> We attempted at emulating BLOB behaviour, but such efforts turn out to
>> be not decent enough. For this reason, we've decided to abandon these
>> attempts and fairly replace it with SCALAR column type.  SCALAR column
>> type acts in the same way as it does in NoSQL: it is aggregator-type for
>> INTEGER, NUMBER and STRING types. So, column declared with this type can
>> contain values of these three (available in SQL) types. It is worth
>> mentioning that CAST operator in this case does nothing.
>> 
> 
> Shouldn't we keep the BLOB keyword in the list of reserved words?

Yep, surely we should. Fixed:

diff --git a/extra/mkkeywordhash.c b/extra/mkkeywordhash.c
index 0a874c8e6..fbd56fa00 100644
--- a/extra/mkkeywordhash.c
+++ b/extra/mkkeywordhash.c
@@ -213,6 +213,7 @@ static Keyword aKeywordTable[] = {
   { "WHERE",                  "TK_WHERE",       ALWAYS,           true  },
   { "ANY",                    "TK_STANDARD",    RESERVED,         true  },
   { "ASENSITIVE",             "TK_STANDARD",    RESERVED,         true  },
+  { "BLOB",                   "TK_STANDARD",    RESERVED,         true  },
   { "BINARY",                 "TK_ID",          RESERVED,         true  },
   { "CALL",                   "TK_STANDARD",    RESERVED,         true  },
   { "CHAR",                   "TK_CHAR",        RESERVED,         true  },
diff --git a/test/sql-tap/keyword1.test.lua b/test/sql-tap/keyword1.test.lua
index 6895dc16e..44fa1cfb5 100755
--- a/test/sql-tap/keyword1.test.lua
+++ b/test/sql-tap/keyword1.test.lua
@@ -1,6 +1,6 @@
 #!/usr/bin/env tarantool
 test = require("sqltester")
-test:plan(175)
+test:plan(176)
 
 --!./tcltestrunner.lua
 -- 2009 January 29
@@ -54,6 +54,7 @@ local bannedkws = {
        "asc",
        "begin",
        "between",
+       "blob",
        "by",
        "case",
        "check",

> 
> The same applies to DATE/TIME and other words which are reserved
> in SQL standard.

These words are already reserved.

> The patch itself LGTM.

Also, I’ve rebased patch (after rebase on fresh 2.1 some new tests
failed due to usage of CHAR instead of VARCHAR).

> -- 
> Konstantin Osipov, Moscow, Russia, +7 903 626 22 32
> http://tarantool.io - www.twitter.com/kostja_osipov

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [tarantool-patches] Re: [PATCH 0/4] SQL types changes
  2019-03-07 13:14 [tarantool-patches] [PATCH 0/4] SQL types changes Nikita Pettik
                   ` (3 preceding siblings ...)
  2019-03-07 13:14 ` [tarantool-patches] [PATCH 4/4] sql: replace BLOB as column type with SCALAR Nikita Pettik
@ 2019-03-07 14:14 ` Kirill Yukhin
  4 siblings, 0 replies; 11+ messages in thread
From: Kirill Yukhin @ 2019-03-07 14:14 UTC (permalink / raw)
  To: tarantool-patches; +Cc: v.shpilevoy, Nikita Pettik

Hello,

On 07 Mar 16:14, Nikita Pettik wrote:
> Branch: https://github.com/tarantool/tarantool/tree/np/gh-4019-types-cleanup
> Issue:
> https://github.com/tarantool/tarantool/issues/4019
> https://github.com/tarantool/tarantool/issues/4023
> 
> This patch-set polishes current situation with SQL types. Several type
> aliases (CHAR/DECIMAL/NUMERIC) were removed; TIME-like types were
> completely removed. BLOB was replaced with SCALAR to avoid any
> confusions in using that type. For more details, see content of patches
> and document request in the last patch.
> 
> Nikita Pettik (4):
>   sql: remove support of DATE/TIME from parser
>   sql: remove support of CHAR type from parser
>   sql: remove support of NUMERIC type from parser
>   sql: replace BLOB as column type with SCALAR

I've checked your patchset into 2.1 branch.

--
Regards, Kirill Yukhin

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2019-03-07 14:14 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [tarantool-patches] [PATCH 2/4] sql: remove support of CHAR type " Nikita Pettik
2019-03-07 13:35   ` [tarantool-patches] " 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox