From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 4413A220A1 for ; Wed, 24 Jul 2019 07:42:52 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bf2JD069_jgQ for ; Wed, 24 Jul 2019 07:42:52 -0400 (EDT) Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [94.100.181.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id CB7CB21CC2 for ; Wed, 24 Jul 2019 07:42:51 -0400 (EDT) From: Nikita Pettik Subject: [tarantool-patches] [PATCH 3/5] sql: use 'varbinary' as a name of type instead of 'blob' Date: Wed, 24 Jul 2019 14:42:45 +0300 Message-Id: In-Reply-To: References: MIME-Version: 1.0 In-Reply-To: References: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org Cc: v.shpilevoy@tarantool.org, Nikita Pettik We are going to introduce new column type 'VARBINARY', which allows to store values with MP_BIN msgpack format. On the other hand, now it is also possible to meet this type: all literals in form of x'...' are supposed to be inserted into SCALAR column type exactly with MP_BIN encoding. Prior to this moment type of such values (encoded as MP_BIN) was called 'blob'. Thus, let's fix all visible to user messages using 'varbinary' name of type instead of 'blob'. --- src/box/lua/lua_sql.c | 2 +- src/box/sql/func.c | 4 ++-- src/box/sql/vdbe.c | 4 ++-- src/box/sql/vdbeapi.c | 4 ++-- test/sql-tap/cast.test.lua | 4 ++-- test/sql-tap/func.test.lua | 2 +- test/sql-tap/lua_sql.test.lua | 4 ++-- test/sql-tap/position.test.lua | 16 ++++++++-------- test/sql/types.result | 24 ++++++++++++------------ 9 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/box/lua/lua_sql.c b/src/box/lua/lua_sql.c index 4d90a53de..c3bddf735 100644 --- a/src/box/lua/lua_sql.c +++ b/src/box/lua/lua_sql.c @@ -165,7 +165,7 @@ lbox_sql_create_function(struct lua_State *L) type = FIELD_TYPE_NUMBER; else if (strcmp(type_arg, "NUM") == 0) type = FIELD_TYPE_NUMBER; - else if (strcmp(type_arg, "BLOB") == 0) + else if (strcmp(type_arg, "VARBINARY") == 0) type = FIELD_TYPE_SCALAR; else if (strcmp(type_arg, "BOOL") == 0 || strcmp(type_arg, "BOOLEAN") == 0) diff --git a/src/box/sql/func.c b/src/box/sql/func.c index 761a3abae..4ec591eee 100644 --- a/src/box/sql/func.c +++ b/src/box/sql/func.c @@ -120,7 +120,7 @@ typeofFunc(sql_context * context, int NotUsed, sql_value ** argv) z = "number"; break; case MP_BIN: - z = "scalar"; + z = "varbinary"; break; case MP_BOOL: z = "boolean"; @@ -249,7 +249,7 @@ position_func(struct sql_context *context, int argc, struct Mem **argv) if (haystack_type != MP_STR && haystack_type != MP_BIN) inconsistent_type_arg = haystack; if (inconsistent_type_arg != NULL) { - diag_set(ClientError, ER_INCONSISTENT_TYPES, "TEXT or BLOB", + diag_set(ClientError, ER_INCONSISTENT_TYPES, "TEXT or VARBINARY", mem_type_to_str(inconsistent_type_arg)); context->is_aborted = true; return; diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c index 9f3879910..826232f99 100644 --- a/src/box/sql/vdbe.c +++ b/src/box/sql/vdbe.c @@ -589,7 +589,7 @@ mem_type_to_str(const struct Mem *p) case MEM_Real: return "REAL"; case MEM_Blob: - return "BLOB"; + return "VARBINARY"; case MEM_Bool: return "BOOLEAN"; default: @@ -1485,7 +1485,7 @@ case OP_Concat: { /* same as TK_CONCAT, in1, in2, out3 */ char *inconsistent_type = str_type_p1 == 0 ? mem_type_to_str(pIn1) : mem_type_to_str(pIn2); - diag_set(ClientError, ER_INCONSISTENT_TYPES, "TEXT or BLOB", + diag_set(ClientError, ER_INCONSISTENT_TYPES, "TEXT or VARBINARY", inconsistent_type); goto abort_due_to_error; } diff --git a/src/box/sql/vdbeapi.c b/src/box/sql/vdbeapi.c index f470ac6b1..3bda7d145 100644 --- a/src/box/sql/vdbeapi.c +++ b/src/box/sql/vdbeapi.c @@ -942,7 +942,7 @@ sql_bind_blob(sql_stmt * pStmt, struct Mem *var = &p->aVar[i - 1]; if (sqlVdbeMemSetStr(var, zData, nData, 0, xDel) != 0) return -1; - return sql_bind_type(p, i, "BLOB"); + return sql_bind_type(p, i, "VARBINARY"); } int @@ -1014,7 +1014,7 @@ sql_bind_ptr(struct sql_stmt *stmt, int i, void *ptr) struct Vdbe *p = (struct Vdbe *) stmt; int rc = vdbeUnbind(p, i); if (rc == 0) { - rc = sql_bind_type(p, i, "BLOB"); + rc = sql_bind_type(p, i, "VARBINARY"); mem_set_ptr(&p->aVar[i - 1], ptr); } return rc; diff --git a/test/sql-tap/cast.test.lua b/test/sql-tap/cast.test.lua index 531c310d2..47784d273 100755 --- a/test/sql-tap/cast.test.lua +++ b/test/sql-tap/cast.test.lua @@ -40,7 +40,7 @@ test:do_execsql_test( SELECT typeof(x'616263') ]], { -- - "scalar" + "varbinary" -- }) @@ -90,7 +90,7 @@ test:do_execsql_test( SELECT typeof(CAST(x'616263' AS SCALAR)) ]], { -- - "scalar" + "varbinary" -- }) diff --git a/test/sql-tap/func.test.lua b/test/sql-tap/func.test.lua index f9044ad01..50a40b777 100755 --- a/test/sql-tap/func.test.lua +++ b/test/sql-tap/func.test.lua @@ -978,7 +978,7 @@ test:do_execsql_test( SELECT typeof(randomblob(32)); ]], { -- - "scalar" + "varbinary" -- }) diff --git a/test/sql-tap/lua_sql.test.lua b/test/sql-tap/lua_sql.test.lua index b0913e7f4..676b105ae 100755 --- a/test/sql-tap/lua_sql.test.lua +++ b/test/sql-tap/lua_sql.test.lua @@ -108,7 +108,7 @@ local from_lua_to_sql = { local function check_from_lua_to_sql(i) return from_lua_to_sql[i][2] end -box.internal.sql_create_function("check_from_lua_to_sql", "BLOB", check_from_lua_to_sql) +box.internal.sql_create_function("check_from_lua_to_sql", "VARBINARY", check_from_lua_to_sql) -- check for different types for i = 1, #from_lua_to_sql, 1 do @@ -125,7 +125,7 @@ local from_lua_to_sql_bad = { local function check_from_lua_to_sql_bad(i) return from_lua_to_sql_bad[i] end -box.internal.sql_create_function("check_from_lua_to_sql_bad", "BLOB", check_from_lua_to_sql_bad) +box.internal.sql_create_function("check_from_lua_to_sql_bad", "VARBINARY", check_from_lua_to_sql_bad) for i = 1, #from_lua_to_sql_bad, 1 do test:do_catchsql_test( diff --git a/test/sql-tap/position.test.lua b/test/sql-tap/position.test.lua index 8c46d7b9e..8ffe3ae2f 100755 --- a/test/sql-tap/position.test.lua +++ b/test/sql-tap/position.test.lua @@ -228,7 +228,7 @@ test:do_test( return test:catchsql "SELECT position(34, 12345);" end, { -- - 1, "Inconsistent types: expected TEXT or BLOB got INTEGER" + 1, "Inconsistent types: expected TEXT or VARBINARY got INTEGER" -- }) @@ -238,7 +238,7 @@ test:do_test( return test:catchsql "SELECT position(34, 123456.78);" end, { -- - 1, "Inconsistent types: expected TEXT or BLOB got REAL" + 1, "Inconsistent types: expected TEXT or VARBINARY got REAL" -- }) @@ -248,7 +248,7 @@ test:do_test( return test:catchsql "SELECT position(x'3334', 123456.78);" end, { -- - 1, "Inconsistent types: expected TEXT or BLOB got REAL" + 1, "Inconsistent types: expected TEXT or VARBINARY got REAL" -- }) @@ -554,7 +554,7 @@ test:do_test( return test:catchsql("SELECT position('x', x'78c3a4e282ac79');") end, { -- - 1, "Inconsistent types: expected TEXT got BLOB" + 1, "Inconsistent types: expected TEXT got VARBINARY" -- }) @@ -564,7 +564,7 @@ test:do_test( return test:catchsql "SELECT position('y', x'78c3a4e282ac79');" end, { -- - 1, "Inconsistent types: expected TEXT got BLOB" + 1, "Inconsistent types: expected TEXT got VARBINARY" -- }) @@ -614,7 +614,7 @@ test:do_test( return test:catchsql "SELECT position(x'79', 'xä€y');" end, { -- - 1, "Inconsistent types: expected BLOB got TEXT" + 1, "Inconsistent types: expected VARBINARY got TEXT" -- }) @@ -624,7 +624,7 @@ test:do_test( return test:catchsql "SELECT position(x'a4', 'xä€y');" end, { -- - 1, "Inconsistent types: expected BLOB got TEXT" + 1, "Inconsistent types: expected VARBINARY got TEXT" -- }) @@ -634,7 +634,7 @@ test:do_test( return test:catchsql "SELECT position('y', x'78c3a4e282ac79');" end, { -- - 1, "Inconsistent types: expected TEXT got BLOB" + 1, "Inconsistent types: expected TEXT got VARBINARY" -- }) diff --git a/test/sql/types.result b/test/sql/types.result index 1db4b980d..332ebd43b 100644 --- a/test/sql/types.result +++ b/test/sql/types.result @@ -152,33 +152,33 @@ sp:drop() -- box.execute("SELECT 'abc' || 1;") --- -- error: 'Inconsistent types: expected TEXT or BLOB got INTEGER' +- error: 'Inconsistent types: expected TEXT or VARBINARY got INTEGER' ... box.execute("SELECT 'abc' || 1.123;") --- -- error: 'Inconsistent types: expected TEXT or BLOB got REAL' +- error: 'Inconsistent types: expected TEXT or VARBINARY got REAL' ... box.execute("SELECT 1 || 'abc';") --- -- error: 'Inconsistent types: expected TEXT or BLOB got INTEGER' +- error: 'Inconsistent types: expected TEXT or VARBINARY got INTEGER' ... box.execute("SELECT 1.123 || 'abc';") --- -- error: 'Inconsistent types: expected TEXT or BLOB got REAL' +- error: 'Inconsistent types: expected TEXT or VARBINARY got REAL' ... box.execute("SELECt 'a' || 'b' || 1;") --- -- error: 'Inconsistent types: expected TEXT or BLOB got INTEGER' +- error: 'Inconsistent types: expected TEXT or VARBINARY got INTEGER' ... -- What is more, they must be of the same type. -- box.execute("SELECT 'abc' || randomblob(5);") --- -- error: 'Inconsistent types: expected TEXT got BLOB' +- error: 'Inconsistent types: expected TEXT got VARBINARY' ... box.execute("SELECT randomblob(5) || 'x';") --- -- error: 'Inconsistent types: expected BLOB got TEXT' +- error: 'Inconsistent types: expected VARBINARY got TEXT' ... -- Result of BLOBs concatenation must be BLOB. -- @@ -188,7 +188,7 @@ box.execute("VALUES (TYPEOF(randomblob(5) || zeroblob(5)));") - name: column1 type: string rows: - - ['scalar'] + - ['varbinary'] ... -- gh-3954: LIKE accepts only arguments of type TEXT and NULLs. -- @@ -202,15 +202,15 @@ box.execute("INSERT INTO t1 VALUES (randomblob(5));") ... box.execute("SELECT * FROM t1 WHERE s LIKE 'blob';") --- -- error: 'Inconsistent types: expected TEXT got BLOB' +- error: 'Inconsistent types: expected TEXT got VARBINARY' ... box.execute("SELECT * FROM t1 WHERE 'blob' LIKE s;") --- -- error: 'Inconsistent types: expected TEXT got BLOB' +- error: 'Inconsistent types: expected TEXT got VARBINARY' ... box.execute("SELECT * FROM t1 WHERE 'blob' LIKE x'0000';") --- -- error: 'Inconsistent types: expected TEXT got BLOB' +- error: 'Inconsistent types: expected TEXT got VARBINARY' ... box.execute("SELECT s LIKE NULL FROM t1;") --- @@ -393,7 +393,7 @@ box.execute("SELECT 1 LIMIT 1 OFFSET true;") ... box.execute("SELECT 'abc' || true;") --- -- error: 'Inconsistent types: expected TEXT or BLOB got BOOLEAN' +- error: 'Inconsistent types: expected TEXT or VARBINARY got BOOLEAN' ... -- Boolean can take part in arithmetic operations. -- -- 2.15.1