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 1D443255B9 for ; Sat, 27 Jul 2019 14:45:41 -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 4KdzNH8JH5pd for ; Sat, 27 Jul 2019 14:45:40 -0400 (EDT) Received: from smtp47.i.mail.ru (smtp47.i.mail.ru [94.100.177.107]) (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 694BC254D7 for ; Sat, 27 Jul 2019 14:45:40 -0400 (EDT) From: Nikita Pettik Subject: [tarantool-patches] [PATCH 2/2] sql: make default type of NULL be boolean Date: Sat, 27 Jul 2019 21:45:36 +0300 Message-Id: In-Reply-To: References: In-Reply-To: References: Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org Cc: v.shpilevoy@tarantool.org, Nikita Pettik It was decided that null value in SQL by default should be of type boolean. Justification of such change is that according to ANSI boolean type in fact has three different values: true, false and unknown. The latter is basically an alias to null value. --- src/box/sql/func.c | 3 ++- test/sql-tap/cast.test.lua | 4 ++-- test/sql-tap/func.test.lua | 12 ++++++------ test/sql-tap/table.test.lua | 2 +- test/sql/types.result | 2 +- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/box/sql/func.c b/src/box/sql/func.c index f50df105d..06904e082 100644 --- a/src/box/sql/func.c +++ b/src/box/sql/func.c @@ -133,10 +133,11 @@ typeofFunc(sql_context * context, int NotUsed, sql_value ** argv) z = "scalar"; break; case MP_BOOL: + case MP_NIL: z = "boolean"; break; default: - z = "null"; + unreachable(); break; } sql_result_text(context, z, -1, SQL_STATIC); diff --git a/test/sql-tap/cast.test.lua b/test/sql-tap/cast.test.lua index f06cc81d6..96162639c 100755 --- a/test/sql-tap/cast.test.lua +++ b/test/sql-tap/cast.test.lua @@ -120,7 +120,7 @@ test:do_execsql_test( SELECT typeof(NULL) ]], { -- - "null" + "boolean" -- }) @@ -180,7 +180,7 @@ test:do_execsql_test( SELECT typeof(CAST(NULL AS SCALAR)) ]], { -- - "null" + "boolean" -- }) diff --git a/test/sql-tap/func.test.lua b/test/sql-tap/func.test.lua index 961fd350a..09407d3fa 100755 --- a/test/sql-tap/func.test.lua +++ b/test/sql-tap/func.test.lua @@ -1802,7 +1802,7 @@ test:do_execsql_test( SELECT typeof(replace('This is the main test string', NULL, 'ALT')); ]], { -- - "null" + "boolean" -- }) @@ -1812,7 +1812,7 @@ test:do_execsql_test( SELECT typeof(replace(NULL, 'main', 'ALT')); ]], { -- - "null" + "boolean" -- }) @@ -1822,7 +1822,7 @@ test:do_execsql_test( SELECT typeof(replace('This is the main test string', 'main', NULL)); ]], { -- - "null" + "boolean" -- }) @@ -2043,7 +2043,7 @@ test:do_execsql_test( SELECT typeof(trim(NULL)); ]], { -- - "null" + "boolean" -- }) @@ -2053,7 +2053,7 @@ test:do_execsql_test( SELECT typeof(TRIM('xyz' FROM NULL)); ]], { -- - "null" + "boolean" -- }) @@ -2063,7 +2063,7 @@ test:do_execsql_test( SELECT typeof(TRIM(NULL FROM 'hello')); ]], { -- - "null" + "boolean" -- }) diff --git a/test/sql-tap/table.test.lua b/test/sql-tap/table.test.lua index 7f4b15e72..18adf70a9 100755 --- a/test/sql-tap/table.test.lua +++ b/test/sql-tap/table.test.lua @@ -906,7 +906,7 @@ test:do_execsql_test( FROM t7 LIMIT 1; ]], { -- - "integer", "number", "string", "string", "null", "null", "string", "string" + "integer", "number", "string", "string", "boolean", "boolean", "string", "string" -- }) diff --git a/test/sql/types.result b/test/sql/types.result index 6e7fffa42..3750ed2a3 100644 --- a/test/sql/types.result +++ b/test/sql/types.result @@ -1771,7 +1771,7 @@ box.execute("SELECT typeof(a), typeof(s) FROM t;") type: string rows: - ['integer', 'integer'] - - ['integer', 'null'] + - ['integer', 'boolean'] ... box.execute("SELECT typeof(CAST(0 AS UNSIGNED));") --- -- 2.15.1