From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 989AB6EC40; Wed, 18 Aug 2021 17:35:25 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 989AB6EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1629297325; bh=Al9qHNwtvAYIJ8Ejp4LpFWFpXRt4P0uMiHKu9yliLsk=; h=To:Cc:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=n7b9ljn4KKL3UcYhbFEhAXRMUiczy6gDTHOgPwYjSef3qfpynnGaa/CDQHLlKA+1C 2uDqLzePlnAzvQMGn3tcE9+YXpEJj4R11mwbZF7bflD0IyDyFTBRVPJK/nCCHe0TJq Ev3mQ8j0eL3cDwzLZoxzKlW6CszQ2L4MMyJJpVCU= Received: from smtpng1.i.mail.ru (smtpng1.i.mail.ru [94.100.181.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 000E06EC40 for ; Wed, 18 Aug 2021 17:34:54 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 000E06EC40 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1mGMeb-0002sv-T4; Wed, 18 Aug 2021 17:34:54 +0300 To: vdavydov@tarantool.org Cc: tarantool-patches@dev.tarantool.org Date: Wed, 18 Aug 2021 17:34:53 +0300 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD92087353F0EC44DD9F9A2272A1D086A28553D1D5C4B4124EF182A05F538085040AC5FCC1C83BC6C9BA15A6DD6DE7F9CA80441A210FD21B1624FA4805344D0A046 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7387B291F9AC4D188EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006373C710FAF3667BB888638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8B87574C97C414FD37C584ACBD1819D99117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAA867293B0326636D2E47CDBA5A96583BD4B6F7A4D31EC0BC014FD901B82EE079FA2833FD35BB23D27C277FBC8AE2E8BAA867293B0326636D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6B1CFA6D474D4A6A4089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975CF160826E4E1956AEE2E62758746FAD9385DF911F03F057819C2B6934AE262D3EE7EAB7254005DCED7532B743992DF240BDC6A1CF3F042BAD6DF99611D93F60EFCE66FDB1904541E0699F904B3F4130E343918A1A30D5E7FCCB5012B2E24CD356 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D347215713CF3EEE9D1CC59CCEFCF933B6A63B9C31C0598D159A09DA25626FD80668F2E3A51BB01A7B61D7E09C32AA3244CF051F2090FED1E5B9AD6F05D67B63BCA7101BF96129E4011729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojuRQ/H5n28trjxhNL1iLdww== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5D584202B350C71EF5CDB7D28BF714F35D83D72C36FC87018B9F80AB2734326CD2FB559BB5D741EB96352A0ABBE4FDA4210A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: [Tarantool-patches] [PATCH v2 1/5] sql: modify arithmetic aggregate functions X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Mergen Imeev via Tarantool-patches Reply-To: imeevma@tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" This patch modifies arithmetic aggredate functions, so after this patch they will work according to out implicit cast rules. It means that if argument of SUM ar AVG was INTEGER, then the result will also be INTEGER. It the argument was DOUBLE, the result will be DOUBLE. NUMBER values cannot participate in arithmetic operations. Needed for #4415 Part of #6105 --- src/box/sql/func.c | 109 +++++++++++++++----------------- test/sql-tap/e_select1.test.lua | 2 +- test/sql-tap/func.test.lua | 80 ++--------------------- test/sql-tap/minmax4.test.lua | 2 +- test/sql-tap/null.test.lua | 2 +- test/sql-tap/select1.test.lua | 2 +- test/sql-tap/select3.test.lua | 16 ++--- test/sql-tap/select5.test.lua | 2 +- test/sql-tap/select6.test.lua | 21 +++--- test/sql-tap/selectG.test.lua | 2 +- test/sql-tap/subquery.test.lua | 8 +-- test/sql-tap/uuid.test.lua | 6 +- test/sql/boolean.result | 6 +- test/sql/types.result | 8 +-- 14 files changed, 95 insertions(+), 171 deletions(-) diff --git a/src/box/sql/func.c b/src/box/sql/func.c index 1551d3ef2..3267d101e 100644 --- a/src/box/sql/func.c +++ b/src/box/sql/func.c @@ -1664,59 +1664,30 @@ soundexFunc(sql_context * context, int argc, sql_value ** argv) */ typedef struct SumCtx SumCtx; struct SumCtx { - double rSum; /* Floating point sum */ - int64_t iSum; /* Integer sum */ - /** True if iSum < 0. */ - bool is_neg; - i64 cnt; /* Number of elements summed */ - u8 overflow; /* True if integer overflow seen */ - u8 approx; /* True if non-integer value was input to the sum */ + struct Mem mem; + uint32_t count; }; -/* - * Routines used to compute the sum, average, and total. - * - * The SUM() function follows the (broken) SQL standard which means - * that it returns NULL if it sums over no inputs. TOTAL returns - * 0.0 in that case. In addition, TOTAL always returns a float where - * SUM might return an integer if it never encounters a floating point - * value. TOTAL never fails, but SUM might through an exception if - * it overflows an integer. - */ +/** Routines used to compute the sum() and average(). */ static void sum_step(struct sql_context *context, int argc, sql_value **argv) { assert(argc == 1); UNUSED_PARAMETER(argc); struct SumCtx *p = sql_aggregate_context(context, sizeof(*p)); - int type = sql_value_type(argv[0]); - if (type == MP_NIL || p == NULL) + if (p == NULL) { + context->is_aborted = true; return; - if (type != MP_DOUBLE && type != MP_INT && type != MP_UINT) { - if (type != MP_STR || mem_to_number(argv[0]) != 0) { - diag_set(ClientError, ER_SQL_TYPE_MISMATCH, - mem_str(argv[0]), "number"); - context->is_aborted = true; - return; - } - type = sql_value_type(argv[0]); } - p->cnt++; - if (type == MP_INT || type == MP_UINT) { - int64_t v = mem_get_int_unsafe(argv[0]); - if (type == MP_INT) - p->rSum += v; - else - p->rSum += (uint64_t) v; - if ((p->approx | p->overflow) == 0 && - sql_add_int(p->iSum, p->is_neg, v, type == MP_INT, &p->iSum, - &p->is_neg) != 0) { - p->overflow = 1; - } - } else { - p->rSum += mem_get_double_unsafe(argv[0]); - p->approx = 1; + if (p->count == 0) { + mem_create(&p->mem); + mem_set_uint(&p->mem, 0); } + if (argv[0]->type == MEM_TYPE_NULL) + return; + ++p->count; + if (mem_add(&p->mem, argv[0], &p->mem) != 0) + context->is_aborted = true; } static void @@ -1724,17 +1695,10 @@ sumFinalize(sql_context * context) { SumCtx *p; p = sql_aggregate_context(context, 0); - if (p && p->cnt > 0) { - if (p->overflow) { - diag_set(ClientError, ER_SQL_EXECUTE, "integer "\ - "overflow"); - context->is_aborted = true; - } else if (p->approx) { - sql_result_double(context, p->rSum); - } else { - mem_set_int(context->pOut, p->iSum, p->is_neg); - } - } + if (p == NULL || p->count == 0) + mem_set_null(context->pOut); + else + mem_copy_as_ephemeral(context->pOut, &p->mem); } static void @@ -1742,9 +1706,37 @@ avgFinalize(sql_context * context) { SumCtx *p; p = sql_aggregate_context(context, 0); - if (p && p->cnt > 0) { - sql_result_double(context, p->rSum / (double)p->cnt); + if (p == NULL || p->count == 0) { + mem_set_null(context->pOut); + return; } + struct Mem mem; + mem_create(&mem); + mem_set_uint(&mem, p->count); + if (mem_div(&p->mem, &mem, context->pOut) != 0) + context->is_aborted = true; +} + +/** Routines used to compute the total(). */ +static void +total_step(struct sql_context *context, int argc, sql_value **argv) +{ + assert(argc == 1); + UNUSED_PARAMETER(argc); + struct SumCtx *p = sql_aggregate_context(context, sizeof(*p)); + if (p == NULL) { + context->is_aborted = true; + return; + } + if (p->count == 0) { + mem_create(&p->mem); + mem_set_double(&p->mem, 0.0); + } + if (argv[0]->type == MEM_TYPE_NULL) + return; + ++p->count; + if (mem_add(&p->mem, argv[0], &p->mem) != 0) + context->is_aborted = true; } static void @@ -1752,7 +1744,10 @@ totalFinalize(sql_context * context) { SumCtx *p; p = sql_aggregate_context(context, 0); - sql_result_double(context, p ? p->rSum : (double)0); + if (p == NULL || p->count == 0) + mem_set_double(context->pOut, 0.0); + else + mem_copy_as_ephemeral(context->pOut, &p->mem); } /* @@ -2505,7 +2500,7 @@ static struct { .aggregate = FUNC_AGGREGATE_GROUP, .is_deterministic = false, .flags = 0, - .call = sum_step, + .call = total_step, .finalize = totalFinalize, .export_to_sql = true, }, { diff --git a/test/sql-tap/e_select1.test.lua b/test/sql-tap/e_select1.test.lua index 27bd44ac4..da4db5a55 100755 --- a/test/sql-tap/e_select1.test.lua +++ b/test/sql-tap/e_select1.test.lua @@ -1181,7 +1181,7 @@ test:do_select_tests( {"2", "SELECT sum(j), max(j) FROM c2 GROUP BY (i%3)", {54, 36, 27, 21, 39, 28}}, {"3", "SELECT sum(j), max(j) FROM c2 GROUP BY (j%2)", {80, 36, 40, 21}}, {"4", "SELECT 1+sum(j), max(j)+1 FROM c2 GROUP BY (j%2)", {81, 37, 41, 22}}, - {"5", "SELECT count(*), round(avg(i),2) FROM c1, c2 ON (i=down) GROUP BY j%2", {3, 4.33, 1, 2.0}}, + {"5", "SELECT count(*), round(avg(i),2) FROM c1, c2 ON (i=down) GROUP BY j%2", {3, 4, 1, 2.0}}, }) -- EVIDENCE-OF: R-62913-19830 Otherwise, it is evaluated against a single diff --git a/test/sql-tap/func.test.lua b/test/sql-tap/func.test.lua index 4cc722d1e..e7b35c9d9 100755 --- a/test/sql-tap/func.test.lua +++ b/test/sql-tap/func.test.lua @@ -1,6 +1,6 @@ #!/usr/bin/env tarantool local test = require("sqltester") -test:plan(14694) +test:plan(14690) --!./tcltestrunner.lua -- 2001 September 15 @@ -851,7 +851,7 @@ test:do_test( ]]) end, { -- - 68236, 3, 22745.33, 1, 67890, 5 + 68236, 3, 22745, 1, 67890, 5 -- }) @@ -869,76 +869,6 @@ test:do_execsql_test( -- }) --- ifcapable tempdb { --- do_test func-8.3 { --- execsql { --- CREATE TEMP TABLE t3 AS SELECT a FROM t2 ORDER BY a DESC; --- SELECT min('z+'||a||'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP') FROM t3; --- } --- } {z+1abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP} --- } else { --- do_test func-8.3 { --- execsql { --- CREATE TABLE t3 AS SELECT a FROM t2 ORDER BY a DESC; --- SELECT min('z+'||a||'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP') FROM t3; --- } --- } {z+1abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP} --- } --- do_test func-8.4 { --- execsql { --- SELECT max('z+'||a||'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP') FROM t3; --- } --- } {z+67890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP} -test:do_execsql_test( - "func-8.5", - [[ - SELECT sum(x) FROM (SELECT '9223372036' || '854775807' AS x - UNION ALL SELECT -9223372036854775807) - ]], { - -- - 0 - -- - }) - -test:do_execsql_test( - "func-8.6", - [[ - SELECT typeof(sum(x)) FROM (SELECT '9223372036' || '854775807' AS x - UNION ALL SELECT -9223372036854775807) - ]], { - -- - "integer" - -- - }) - -test:do_execsql_test( - "func-8.7", - [[ - SELECT typeof(sum(x)) FROM (SELECT '9223372036' || '854775808' AS x - UNION ALL SELECT -9223372036854775807) - ]], { - -- - "integer" - -- - }) - -test:do_execsql_test( - "func-8.8", - [[ - SELECT sum(x)>0.0 FROM (SELECT '9223372036' || '854775808' AS x - UNION ALL SELECT -9223372036850000000) - ]], { - -- - true - -- - }) - - - - - - - -- How do you test the random() function in a meaningful, deterministic way? -- test:do_execsql_test( @@ -1677,7 +1607,7 @@ test:do_catchsql_test( UNION ALL SELECT 10 AS x); ]], { -- - 1, "Failed to execute SQL statement: integer overflow" + 1, "Failed to execute SQL statement: integer is overflowed" -- }) @@ -1689,7 +1619,7 @@ test:do_catchsql_test( SELECT -10 AS x); ]], { -- - 1, "Failed to execute SQL statement: integer overflow" + 1, "Failed to execute SQL statement: integer is overflowed" -- }) @@ -2961,7 +2891,7 @@ test:do_catchsql_test( SELECT SUM(X'FF') ]], { -- - 1, "Type mismatch: can not convert varbinary(x'FF') to number" + 1, "Type mismatch: can not convert varbinary(x'FF') to integer, unsigned or double" -- }) diff --git a/test/sql-tap/minmax4.test.lua b/test/sql-tap/minmax4.test.lua index 3a71462e0..392e0798d 100755 --- a/test/sql-tap/minmax4.test.lua +++ b/test/sql-tap/minmax4.test.lua @@ -251,7 +251,7 @@ test:do_test( ]] end, { -- - 2, 3, 3.0, 1, 5, 1, 1, 1.5, 2, 4 + 2, 3, 3, 1, 5, 1, 1, 1, 2, 4 -- }) diff --git a/test/sql-tap/null.test.lua b/test/sql-tap/null.test.lua index ca20e3558..d01761a1f 100755 --- a/test/sql-tap/null.test.lua +++ b/test/sql-tap/null.test.lua @@ -157,7 +157,7 @@ test:do_execsql_test( avg(b), avg(c), min(b), max(b) from t1; ]], { -- - 7, 4, 6, 2, 3, 0.5, 0.5, 0, 1 + 7, 4, 6, 2, 3, 0, 0, 0, 1 -- }) diff --git a/test/sql-tap/select1.test.lua b/test/sql-tap/select1.test.lua index dbc6e193d..2bf7fd3a2 100755 --- a/test/sql-tap/select1.test.lua +++ b/test/sql-tap/select1.test.lua @@ -515,7 +515,7 @@ test:do_catchsql_test( SELECT sum(a) FROM t3 ]], { -- - 1, "Type mismatch: can not convert string('abc') to number" + 1, "Type mismatch: can not convert string('abc') to integer, unsigned or double" -- }) diff --git a/test/sql-tap/select3.test.lua b/test/sql-tap/select3.test.lua index ffba58ec2..668042c5a 100755 --- a/test/sql-tap/select3.test.lua +++ b/test/sql-tap/select3.test.lua @@ -61,7 +61,7 @@ test:do_execsql_test("select3-1.2", [[ FROM t1 ]], { -- - 1, 0, 31, 5, 496, 124, 16.0, 4.0 + 1, 0, 31, 5, 496, 124, 16, 4.0 -- }) @@ -69,7 +69,7 @@ test:do_execsql_test("select3-1.3", [[ SELECT max(n)/avg(n), max(log)/avg(log) FROM t1 ]], { -- - 1.9375, 1.25 + 1, 1 -- }) @@ -95,7 +95,7 @@ test:do_execsql_test("select3-2.3.1", [[ SELECT log, avg(n) FROM t1 GROUP BY log ORDER BY log ]], { -- - 0, 1.0, 1, 2.0, 2, 3.5, 3, 6.5, 4, 12.5, 5, 24.0 + 0, 1, 1, 2, 2, 3, 3, 6, 4, 12, 5, 24 -- }) @@ -103,7 +103,7 @@ test:do_execsql_test("select3-2.3.2", [[ SELECT log, avg(n)+1 FROM t1 GROUP BY log ORDER BY log ]], { -- - 0, 2.0, 1, 3.0, 2, 4.5, 3, 7.5, 4, 13.5, 5, 25.0 + 0, 2, 1, 3, 2, 4, 3, 7, 4, 13, 5, 25.0 -- }) @@ -111,7 +111,7 @@ test:do_execsql_test("select3-2.4", [[ SELECT log, avg(n)-min(n) FROM t1 GROUP BY log ORDER BY log ]], { -- - 0, 0.0, 1, 0.0, 2, 0.5, 3, 1.5, 4, 3.5, 5, 7.0 + 0, 0, 1, 0, 2, 0, 3, 1, 4, 3, 5, 7.0 -- }) @@ -119,7 +119,7 @@ test:do_execsql_test("select3-2.5", [[ SELECT log*2+1, avg(n)-min(n) FROM t1 GROUP BY log ORDER BY log ]], { -- - 1, 0.0, 3, 0.0, 5, 0.5, 7, 1.5, 9, 3.5, 11, 7.0 + 1, 0, 3, 0, 5, 0, 7, 1, 9, 3, 11, 7.0 -- }) @@ -264,7 +264,7 @@ test:do_execsql_test("select3-5.1", [[ ORDER BY max(n+log*2)+0, avg(n)+0 ]], { -- - 0, 1, 1.0, 1, 1, 1, 2.0, 4, 2, 2, 3.5, 8, 3, 4, 6.5, 14, 4, 8, 12.5, 24, 5, 15, 24.0, 41 + 0, 1, 1, 1, 1, 1, 2, 4, 2, 2, 3, 8, 3, 4, 6, 14, 4, 8, 12, 24, 5, 15, 24, 41 -- }) @@ -274,7 +274,7 @@ test:do_execsql_test("select3-5.2", [[ ORDER BY max(n+log*2)+0, GREATEST(log,avg(n))+0 ]], { -- - 0, 1, 1.0, 1, 1, 1, 2.0, 4, 2, 2, 3.5, 8, 3, 4, 6.5, 14, 4, 8, 12.5, 24, 5, 15, 24.0, 41 + 0, 1, 1, 1, 1, 1, 2, 4, 2, 2, 3, 8, 3, 4, 6, 14, 4, 8, 12, 24, 5, 15, 24, 41 -- }) diff --git a/test/sql-tap/select5.test.lua b/test/sql-tap/select5.test.lua index b04c9af09..293e1da14 100755 --- a/test/sql-tap/select5.test.lua +++ b/test/sql-tap/select5.test.lua @@ -558,7 +558,7 @@ test:do_catchsql_test( SELECT 1 FROM jj HAVING avg(s2) = 1 AND avg(s2) = 0; ]], { -- - 1, "Type mismatch: can not convert string('A') to number" + 1, "Type mismatch: can not convert string('A') to integer, unsigned or double" -- }) diff --git a/test/sql-tap/select6.test.lua b/test/sql-tap/select6.test.lua index 8ad91390a..031892112 100755 --- a/test/sql-tap/select6.test.lua +++ b/test/sql-tap/select6.test.lua @@ -312,7 +312,7 @@ test:do_execsql_test( SELECT a,b,a+b FROM (SELECT avg(x) as a, avg(y) as b FROM t1) ]], { -- - 10.5, 3.7, 14.2 + 10, 3, 13 -- }) @@ -322,7 +322,7 @@ test:do_execsql_test( SELECT a,b,a+b FROM (SELECT avg(x) as a, avg(y) as b FROM t1 WHERE y=4) ]], { -- - 11.5, 4.0, 15.5 + 11, 4, 15 -- }) @@ -332,7 +332,7 @@ test:do_execsql_test( SELECT x,y,x+y FROM (SELECT avg(a) as x, avg(b) as y FROM t2 WHERE a=4) ]], { -- - 4.0, 3.0, 7.0 + 4, 3, 7 -- }) @@ -343,7 +343,6 @@ test:do_execsql_test( WHERE a>10 ]], { -- - 10.5, 3.7, 14.2 -- }) @@ -365,7 +364,7 @@ test:do_execsql_test( WHERE a>10 ]], { -- - 11.5, 4.0, 15.5 + 11, 4, 15 -- }) @@ -387,7 +386,7 @@ test:do_execsql_test( ORDER BY a ]], { -- - 1.0, 1, 2.0, 2.5, 2, 4.5, 5.5, 3, 8.5, 11.5, 4, 15.5, 18.0, 5, 23.0 + 1, 1, 2, 2, 2, 4, 5, 3, 8, 11, 4, 15, 18, 5, 23 -- }) @@ -399,7 +398,7 @@ test:do_execsql_test( WHERE b<4 ORDER BY a ]], { -- - 1.0, 1, 2.0, 2.5, 2, 4.5, 5.5, 3, 8.5 + 1, 1, 2, 2, 2, 4, 5, 3, 8 -- }) @@ -411,7 +410,7 @@ test:do_execsql_test( WHERE b<4 ORDER BY a ]], { -- - 2.5, 2, 4.5, 5.5, 3, 8.5 + 2, 2, 4, 5, 3, 8 -- }) @@ -423,7 +422,7 @@ test:do_execsql_test( ORDER BY a ]], { -- - 2.5, 2, 4.5, 5.5, 3, 8.5, 11.5, 4, 15.5, 18.0, 5, 23.0 + 2, 2, 4, 5, 3, 8, 11, 4, 15, 18, 5, 23 -- }) @@ -487,7 +486,7 @@ test:do_execsql_test( SELECT avg(y) FROM (SELECT DISTINCT y FROM t1) WHERE y<5 ORDER BY y ]], { -- - 2.5 + 2 -- }) @@ -497,7 +496,7 @@ test:do_execsql_test( SELECT avg(y) FROM (SELECT DISTINCT y FROM t1 WHERE y<5) ORDER BY y ]], { -- - 2.5 + 2 -- }) diff --git a/test/sql-tap/selectG.test.lua b/test/sql-tap/selectG.test.lua index d416381bd..0690b4c86 100755 --- a/test/sql-tap/selectG.test.lua +++ b/test/sql-tap/selectG.test.lua @@ -48,7 +48,7 @@ test:do_test( :format(end_time - start_time, time_quota)) end, { -- <100> - 100000, 5000050000, 50000.5, true + 100000, 5000050000, 50000, true -- }) diff --git a/test/sql-tap/subquery.test.lua b/test/sql-tap/subquery.test.lua index 1c5b3d02e..1030864b0 100755 --- a/test/sql-tap/subquery.test.lua +++ b/test/sql-tap/subquery.test.lua @@ -466,7 +466,7 @@ test:do_execsql_test( HAVING avg(a.y) > avg(b.y)); ]], { -- - 107, 4.0 + 106,4,107,4 -- }) @@ -482,7 +482,7 @@ test:do_execsql_test( HAVING avg1 > avg2); ]], { -- - 107, 4.0 + 106,4,107,4 -- }) @@ -505,7 +505,7 @@ test:do_execsql_test( ORDER BY a.x; ]], { -- - 106, 4.5, false, true, 107, 4.0, true, false + 106, 4, true, false, 107, 4, true, false -- }) @@ -517,7 +517,7 @@ test:do_execsql_test( SELECT max((SELECT avg(y) FROM t35b)) FROM t35a; ]], { -- - 98.5 + 98 -- }) diff --git a/test/sql-tap/uuid.test.lua b/test/sql-tap/uuid.test.lua index 57e638046..ec5caab63 100755 --- a/test/sql-tap/uuid.test.lua +++ b/test/sql-tap/uuid.test.lua @@ -237,7 +237,7 @@ test:do_catchsql_test( [[ SELECT AVG(u) from t2; ]], { - 1, "Type mismatch: can not convert uuid('11111111-1111-1111-1111-111111111111') to number" + 1, "Type mismatch: can not convert uuid('11111111-1111-1111-1111-111111111111') to integer, unsigned or double" }) test:do_execsql_test( @@ -445,7 +445,7 @@ test:do_catchsql_test( [[ SELECT SUM(u) from t2; ]], { - 1, "Type mismatch: can not convert uuid('11111111-1111-1111-1111-111111111111') to number" + 1, "Type mismatch: can not convert uuid('11111111-1111-1111-1111-111111111111') to integer, unsigned or double" }) test:do_catchsql_test( @@ -453,7 +453,7 @@ test:do_catchsql_test( [[ SELECT TOTAL(u) from t2; ]], { - 1, "Type mismatch: can not convert uuid('11111111-1111-1111-1111-111111111111') to number" + 1, "Type mismatch: can not convert uuid('11111111-1111-1111-1111-111111111111') to integer, unsigned or double" }) test:do_execsql_test( diff --git a/test/sql/boolean.result b/test/sql/boolean.result index a9ce37e11..7f005df55 100644 --- a/test/sql/boolean.result +++ b/test/sql/boolean.result @@ -345,7 +345,7 @@ SELECT typeof(a) FROM t0; SELECT AVG(a) FROM t0; | --- | - null - | - 'Type mismatch: can not convert boolean(FALSE) to number' + | - 'Type mismatch: can not convert boolean(FALSE) to integer, unsigned or double' | ... SELECT MIN(a) FROM t0; | --- @@ -366,7 +366,7 @@ SELECT MAX(a) FROM t0; SELECT SUM(a) FROM t0; | --- | - null - | - 'Type mismatch: can not convert boolean(FALSE) to number' + | - 'Type mismatch: can not convert boolean(FALSE) to integer, unsigned or double' | ... SELECT COUNT(a) FROM t0; | --- @@ -379,7 +379,7 @@ SELECT COUNT(a) FROM t0; SELECT TOTAL(a) FROM t0; | --- | - null - | - 'Type mismatch: can not convert boolean(FALSE) to number' + | - 'Type mismatch: can not convert boolean(FALSE) to integer, unsigned or double' | ... SELECT GROUP_CONCAT(a, ' +++ ') FROM t0; | --- diff --git a/test/sql/types.result b/test/sql/types.result index 68bdcd62e..336bef416 100644 --- a/test/sql/types.result +++ b/test/sql/types.result @@ -777,7 +777,7 @@ box.execute("SELECT avg(i) FROM t;") - name: COLUMN_1 type: number rows: - - [6148914691236516864] + - [6148914691236517204] ... box.execute("SELECT total(i) FROM t;") --- @@ -1251,17 +1251,17 @@ box.execute("SELECT * FROM t WHERE v = x'616263'") box.execute("SELECT sum(v) FROM t;") --- - null -- 'Type mismatch: can not convert varbinary(x''616263'') to number' +- 'Type mismatch: can not convert varbinary(x''616263'') to integer, unsigned or double' ... box.execute("SELECT avg(v) FROM t;") --- - null -- 'Type mismatch: can not convert varbinary(x''616263'') to number' +- 'Type mismatch: can not convert varbinary(x''616263'') to integer, unsigned or double' ... box.execute("SELECT total(v) FROM t;") --- - null -- 'Type mismatch: can not convert varbinary(x''616263'') to number' +- 'Type mismatch: can not convert varbinary(x''616263'') to integer, unsigned or double' ... box.execute("SELECT min(v) FROM t;") --- -- 2.25.1