[Tarantool-patches] [PATCH v2 1/5] sql: modify arithmetic aggregate functions

imeevma at tarantool.org imeevma at tarantool.org
Wed Aug 18 17:34:53 MSK 2021


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, {
         -- <func-8.1>
-        68236, 3, 22745.33, 1, 67890, 5
+        68236, 3, 22745, 1, 67890, 5
         -- </func-8.1>
     })
 
@@ -869,76 +869,6 @@ test:do_execsql_test(
         -- </func-8.2>
     })
 
--- 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)
-    ]], {
-        -- <func-8.5>
-        0
-        -- </func-8.5>
-    })
-
-test:do_execsql_test(
-    "func-8.6",
-    [[
-        SELECT typeof(sum(x)) FROM (SELECT '9223372036' || '854775807' AS x
-                            UNION ALL SELECT -9223372036854775807)
-    ]], {
-        -- <func-8.6>
-        "integer"
-        -- </func-8.6>
-    })
-
-test:do_execsql_test(
-    "func-8.7",
-    [[
-        SELECT typeof(sum(x)) FROM (SELECT '9223372036' || '854775808' AS x
-                            UNION ALL SELECT -9223372036854775807)
-    ]], {
-        -- <func-8.7>
-        "integer"
-        -- </func-8.7>
-    })
-
-test:do_execsql_test(
-    "func-8.8",
-    [[
-        SELECT sum(x)>0.0 FROM (SELECT '9223372036' || '854775808' AS x
-                            UNION ALL SELECT -9223372036850000000)
-    ]], {
-        -- <func-8.8>
-        true
-        -- </func-8.8>
-    })
-
-
-
-
-
-
-
 -- 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);
     ]], {
     -- <func-18.15.2>
-    1, "Failed to execute SQL statement: integer overflow"
+    1, "Failed to execute SQL statement: integer is overflowed"
     -- </func-18.15.2>
 })
 
@@ -1689,7 +1619,7 @@ test:do_catchsql_test(
             SELECT -10 AS x);
     ]], {
         -- <func-18.18>
-        1, "Failed to execute SQL statement: integer overflow"
+        1, "Failed to execute SQL statement: integer is overflowed"
         -- </func-18.18>
     })
 
@@ -2961,7 +2891,7 @@ test:do_catchsql_test(
         SELECT SUM(X'FF')
     ]], {
         -- <func-76.4>
-        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"
         -- </func-76.4>
     })
 
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, {
         -- <minmax4-2.3>
-        2, 3, 3.0, 1, 5, 1, 1, 1.5, 2, 4
+        2, 3, 3, 1, 5, 1, 1, 1, 2, 4
         -- </minmax4-2.3>
     })
 
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;
     ]], {
         -- <null-3.1>
-        7, 4, 6, 2, 3, 0.5, 0.5, 0, 1
+        7, 4, 6, 2, 3, 0, 0, 0, 1
         -- </null-3.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
     ]], {
         -- <select1-2.17.1>
-        1, "Type mismatch: can not convert string('abc') to number"
+        1, "Type mismatch: can not convert string('abc') to integer, unsigned or double"
         -- </select1-2.17.1>
     })
 
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
 ]], {
   -- <select3-1.2>
-  1, 0, 31, 5, 496, 124, 16.0, 4.0
+  1, 0, 31, 5, 496, 124, 16, 4.0
   -- </select3-1.2>
 })
 
@@ -69,7 +69,7 @@ test:do_execsql_test("select3-1.3", [[
   SELECT max(n)/avg(n), max(log)/avg(log) FROM t1
 ]], {
   -- <select3-1.3>
-  1.9375, 1.25
+  1, 1
   -- </select3-1.3>
 })
 
@@ -95,7 +95,7 @@ test:do_execsql_test("select3-2.3.1", [[
   SELECT log, avg(n) FROM t1 GROUP BY log ORDER BY log
 ]], {
   -- <select3-2.3.1>
-  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
   -- </select3-2.3.1>
 })
 
@@ -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
 ]], {
   -- <select3-2.3.2>
-  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
   -- </select3-2.3.2>
 })
 
@@ -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
 ]], {
   -- <select3-2.4>
-  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
   -- </select3-2.4>
 })
 
@@ -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
 ]], {
   -- <select3-2.5>
-  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
   -- </select3-2.5>
 })
 
@@ -264,7 +264,7 @@ test:do_execsql_test("select3-5.1", [[
   ORDER BY max(n+log*2)+0, avg(n)+0
 ]], {
   -- <select3-5.1>
-  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
   -- </select3-5.1>
 })
 
@@ -274,7 +274,7 @@ test:do_execsql_test("select3-5.2", [[
   ORDER BY max(n+log*2)+0, GREATEST(log,avg(n))+0
 ]], {
   -- <select3-5.2>
-  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
   -- </select3-5.2>
 })
 
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;
     ]], {
     -- <select5-9.13.2>
-    1, "Type mismatch: can not convert string('A') to number"
+    1, "Type mismatch: can not convert string('A') to integer, unsigned or double"
     -- </select5-9.13.2>
 })
 
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)
     ]], {
         -- <select6-3.3>
-        10.5, 3.7, 14.2
+        10, 3, 13
         -- </select6-3.3>
     })
 
@@ -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)
     ]], {
         -- <select6-3.4>
-        11.5, 4.0, 15.5
+        11, 4, 15
         -- </select6-3.4>
     })
 
@@ -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)
     ]], {
         -- <select6-3.5>
-        4.0, 3.0, 7.0
+        4, 3, 7
         -- </select6-3.5>
     })
 
@@ -343,7 +343,6 @@ test:do_execsql_test(
         WHERE a>10
     ]], {
         -- <select6-3.6>
-        10.5, 3.7, 14.2
         -- </select6-3.6>
     })
 
@@ -365,7 +364,7 @@ test:do_execsql_test(
         WHERE a>10
     ]], {
         -- <select6-3.8>
-        11.5, 4.0, 15.5
+        11, 4, 15
         -- </select6-3.8>
     })
 
@@ -387,7 +386,7 @@ test:do_execsql_test(
         ORDER BY a
     ]], {
         -- <select6-3.10>
-        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
         -- </select6-3.10>
     })
 
@@ -399,7 +398,7 @@ test:do_execsql_test(
         WHERE b<4 ORDER BY a
     ]], {
         -- <select6-3.11>
-        1.0, 1, 2.0, 2.5, 2, 4.5, 5.5, 3, 8.5
+        1, 1, 2, 2, 2, 4, 5, 3, 8
         -- </select6-3.11>
     })
 
@@ -411,7 +410,7 @@ test:do_execsql_test(
         WHERE b<4 ORDER BY a
     ]], {
         -- <select6-3.12>
-        2.5, 2, 4.5, 5.5, 3, 8.5
+        2, 2, 4, 5, 3, 8
         -- </select6-3.12>
     })
 
@@ -423,7 +422,7 @@ test:do_execsql_test(
         ORDER BY a
     ]], {
         -- <select6-3.13>
-        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
         -- </select6-3.13>
     })
 
@@ -487,7 +486,7 @@ test:do_execsql_test(
         SELECT avg(y) FROM (SELECT DISTINCT y FROM t1) WHERE y<5 ORDER BY y
     ]], {
         -- <select6-4.4>
-        2.5
+        2
         -- </select6-4.4>
     })
 
@@ -497,7 +496,7 @@ test:do_execsql_test(
         SELECT avg(y) FROM (SELECT DISTINCT y FROM t1 WHERE y<5) ORDER BY y
     ]], {
         -- <select6-4.5>
-        2.5
+        2
         -- </select6-4.5>
     })
 
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
         -- </100>
     })
 
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));
     ]], {
         -- <subquery-3.4.1>
-        107, 4.0
+        106,4,107,4
         -- </subquery-3.4.1>
     })
 
@@ -482,7 +482,7 @@ test:do_execsql_test(
                              HAVING avg1 > avg2);
     ]], {
         -- <subquery-3.4.2>
-        107, 4.0
+        106,4,107,4
         -- </subquery-3.4.2>
     })
 
@@ -505,7 +505,7 @@ test:do_execsql_test(
          ORDER BY a.x;
     ]], {
         -- <subquery-3.4.3>
-        106, 4.5, false, true, 107, 4.0, true, false
+        106, 4, true, false, 107, 4, true, false
         -- </subquery-3.4.3>
     })
 
@@ -517,7 +517,7 @@ test:do_execsql_test(
         SELECT max((SELECT avg(y) FROM t35b)) FROM t35a;
     ]], {
         -- <subquery-3.5.1>
-        98.5
+        98
         -- </subquery-3.5.1>
     })
 
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



More information about the Tarantool-patches mailing list