From: Nikita Pettik <korablev@tarantool.org> To: tarantool-patches@freelists.org Cc: v.shpilevoy@tarantool.org, Nikita Pettik <korablev@tarantool.org> Subject: [tarantool-patches] [PATCH 3/5] sql: use 'varbinary' as a name of type instead of 'blob' Date: Wed, 24 Jul 2019 14:42:45 +0300 [thread overview] Message-ID: <dfb06eacfd92a9f76ab6c638f1549b6beb37d794.1563967510.git.korablev@tarantool.org> (raw) In-Reply-To: <cover.1563967510.git.korablev@tarantool.org> In-Reply-To: <cover.1563967510.git.korablev@tarantool.org> 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') ]], { -- <cast-1.2> - "scalar" + "varbinary" -- </cast-1.2> }) @@ -90,7 +90,7 @@ test:do_execsql_test( SELECT typeof(CAST(x'616263' AS SCALAR)) ]], { -- <cast-1.8> - "scalar" + "varbinary" -- </cast-1.8> }) 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)); ]], { -- <func-9.4> - "scalar" + "varbinary" -- </func-9.4> }) 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, { -- <position-1.23> - 1, "Inconsistent types: expected TEXT or BLOB got INTEGER" + 1, "Inconsistent types: expected TEXT or VARBINARY got INTEGER" -- </position-1.23> }) @@ -238,7 +238,7 @@ test:do_test( return test:catchsql "SELECT position(34, 123456.78);" end, { -- <position-1.24> - 1, "Inconsistent types: expected TEXT or BLOB got REAL" + 1, "Inconsistent types: expected TEXT or VARBINARY got REAL" -- </position-1.24> }) @@ -248,7 +248,7 @@ test:do_test( return test:catchsql "SELECT position(x'3334', 123456.78);" end, { -- <position-1.25> - 1, "Inconsistent types: expected TEXT or BLOB got REAL" + 1, "Inconsistent types: expected TEXT or VARBINARY got REAL" -- </position-1.25> }) @@ -554,7 +554,7 @@ test:do_test( return test:catchsql("SELECT position('x', x'78c3a4e282ac79');") end, { -- <position-1.54> - 1, "Inconsistent types: expected TEXT got BLOB" + 1, "Inconsistent types: expected TEXT got VARBINARY" -- </position-1.54> }) @@ -564,7 +564,7 @@ test:do_test( return test:catchsql "SELECT position('y', x'78c3a4e282ac79');" end, { -- <position-1.55> - 1, "Inconsistent types: expected TEXT got BLOB" + 1, "Inconsistent types: expected TEXT got VARBINARY" -- </position-1.55> }) @@ -614,7 +614,7 @@ test:do_test( return test:catchsql "SELECT position(x'79', 'xä€y');" end, { -- <position-1.57.1> - 1, "Inconsistent types: expected BLOB got TEXT" + 1, "Inconsistent types: expected VARBINARY got TEXT" -- </position-1.57.1> }) @@ -624,7 +624,7 @@ test:do_test( return test:catchsql "SELECT position(x'a4', 'xä€y');" end, { -- <position-1.57.2> - 1, "Inconsistent types: expected BLOB got TEXT" + 1, "Inconsistent types: expected VARBINARY got TEXT" -- </position-1.57.2> }) @@ -634,7 +634,7 @@ test:do_test( return test:catchsql "SELECT position('y', x'78c3a4e282ac79');" end, { -- <position-1.57.3> - 1, "Inconsistent types: expected TEXT got BLOB" + 1, "Inconsistent types: expected TEXT got VARBINARY" -- </position-1.57.3> }) 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
next prev parent reply other threads:[~2019-07-24 11:42 UTC|newest] Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-07-24 11:42 [tarantool-patches] [PATCH 0/5] Introduce VARBINARY in SQL Nikita Pettik 2019-07-24 11:42 ` [tarantool-patches] [PATCH 1/5] sql: always erase numeric flag after stringifying Nikita Pettik 2019-07-24 11:42 ` [tarantool-patches] [PATCH 2/5] sql: fix resulting type calculation for CASE-WHEN stmt Nikita Pettik 2019-07-25 22:12 ` [tarantool-patches] " Vladislav Shpilevoy [not found] ` <a061e845-eeb1-00d1-9141-3b9bb87768f5@tarantool.org> 2019-07-28 23:56 ` n.pettik 2019-07-24 11:42 ` Nikita Pettik [this message] 2019-07-25 22:11 ` [tarantool-patches] Re: [PATCH 3/5] sql: use 'varbinary' as a name of type instead of 'blob' Vladislav Shpilevoy [not found] ` <2e655514-0fec-8baf-20a8-d49e5586b047@tarantool.org> 2019-07-28 23:56 ` n.pettik 2019-07-29 21:03 ` Vladislav Shpilevoy 2019-07-30 13:43 ` n.pettik 2019-07-24 11:42 ` [tarantool-patches] [PATCH 4/5] sql: make built-ins raise errors for varbin args Nikita Pettik 2019-07-25 22:11 ` [tarantool-patches] " Vladislav Shpilevoy [not found] ` <05d15035-2552-1f05-b7ce-facfbbc3a520@tarantool.org> 2019-07-28 23:59 ` n.pettik 2019-07-24 11:42 ` [tarantool-patches] [PATCH 5/5] sql: introduce VARBINARY column type Nikita Pettik 2019-07-25 22:12 ` [tarantool-patches] " Vladislav Shpilevoy [not found] ` <49a188eb-dafe-44e7-a0fd-e9244b68e721@tarantool.org> 2019-07-29 0:03 ` n.pettik 2019-07-29 20:55 ` Vladislav Shpilevoy 2019-07-30 13:44 ` n.pettik 2019-07-30 19:41 ` Vladislav Shpilevoy 2019-07-30 19:52 ` Vladislav Shpilevoy 2019-07-31 14:51 ` n.pettik 2019-08-01 8:42 ` [tarantool-patches] Re: [PATCH 0/5] Introduce VARBINARY in SQL Kirill Yukhin
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=dfb06eacfd92a9f76ab6c638f1549b6beb37d794.1563967510.git.korablev@tarantool.org \ --to=korablev@tarantool.org \ --cc=tarantool-patches@freelists.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [tarantool-patches] [PATCH 3/5] sql: use '\''varbinary'\'' as a name of type instead of '\''blob'\''' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox