Tarantool development patches archive
 help / color / mirror / Atom feed
From: Kirill Shcherbatov <kshcherbatov@tarantool.org>
To: tarantool-patches@freelists.org, "n.pettik" <korablev@tarantool.org>
Subject: [tarantool-patches] [PATCH v4 3/5] sql: remove name overloading for SQL builtins
Date: Fri, 23 Aug 2019 18:02:12 +0300	[thread overview]
Message-ID: <6c04c60a-8ae6-d1bf-0d67-943f39bd3b81@tarantool.org> (raw)
In-Reply-To: <17C6E71F-24DF-476D-B5FA-430AF34DC84D@tarantool.org>

Now all SQL builtins are unique, i.e. each function has the only
hash table entry. This technique requires to remove static argc
checks for some builtins(substr, round, like, trim, count,
group_concat). Now they raise a runtime error in case of invalid
usage.

Updated error messages correspondingly, to provide more
informative messages in such cases. Taking into account upcoming
changes, all built-in functions names are uppercased.

Needed for #2200, #4113, #2233
---
 src/box/errcode.h               |   1 +
 src/box/sql/expr.c              |  18 ++++-
 src/box/sql/func.c              | 126 ++++++++++++++++++--------------
 src/box/sql/resolve.c           |  24 +++---
 test/box/misc.result            |   1 +
 test/sql-tap/func.test.lua      |  22 +++---
 test/sql-tap/func2.test.lua     |  18 ++---
 test/sql-tap/limit.test.lua     |   4 +-
 test/sql-tap/select1.test.lua   |  12 +--
 test/sql-tap/where2.test.lua    |   4 +-
 test/sql/icu-upper-lower.result |   4 +-
 11 files changed, 130 insertions(+), 104 deletions(-)

diff --git a/src/box/errcode.h b/src/box/errcode.h
index 46b0b365a..18574c5aa 100644
--- a/src/box/errcode.h
+++ b/src/box/errcode.h
@@ -253,6 +253,7 @@ struct errcode_record {
 	/*198 */_(ER_FUNC_INDEX_FUNC,		"Failed to build a key for functional index '%s' of space '%s': %s") \
 	/*199 */_(ER_FUNC_INDEX_FORMAT,		"Key format doesn't match one defined in functional index '%s' of space '%s': %s") \
 	/*200 */_(ER_FUNC_INDEX_PARTS,		"Wrong functional index definition: %s") \
+	/*201 */_(ER_FUNC_WRONG_ARG_COUNT,	"Wrong number of arguments is passed to %s(): expected %s, got %d") \
 
 /*
  * !IMPORTANT! Please follow instructions at start of the file
diff --git a/src/box/sql/expr.c b/src/box/sql/expr.c
index 1f9d91705..1837817d6 100644
--- a/src/box/sql/expr.c
+++ b/src/box/sql/expr.c
@@ -4004,7 +4004,14 @@ sqlExprCodeTarget(Parse * pParse, Expr * pExpr, int target)
 			 */
 			if (pDef->funcFlags & SQL_FUNC_COALESCE) {
 				int endCoalesce = sqlVdbeMakeLabel(v);
-				assert(nFarg >= 2);
+				if (nFarg < 2) {
+					diag_set(ClientError,
+						 ER_FUNC_WRONG_ARG_COUNT,
+						 pDef->zName, "at least two",
+						 nFarg);
+					pParse->is_aborted = true;
+					break;
+				}
 				sqlExprCode(pParse, pFarg->a[0].pExpr,
 						target);
 				for (i = 1; i < nFarg; i++) {
@@ -4027,7 +4034,14 @@ sqlExprCodeTarget(Parse * pParse, Expr * pExpr, int target)
 			 * of the first argument.
 			 */
 			if (pDef->funcFlags & SQL_FUNC_UNLIKELY) {
-				assert(nFarg >= 1);
+				if (nFarg < 1) {
+					diag_set(ClientError,
+						ER_FUNC_WRONG_ARG_COUNT,
+						pDef->zName, "at least one",
+						nFarg);
+					pParse->is_aborted = true;
+					break;
+				}
 				return sqlExprCodeTarget(pParse,
 							     pFarg->a[0].pExpr,
 							     target);
diff --git a/src/box/sql/func.c b/src/box/sql/func.c
index a46df60ed..9ce645698 100644
--- a/src/box/sql/func.c
+++ b/src/box/sql/func.c
@@ -410,7 +410,12 @@ substrFunc(sql_context * context, int argc, sql_value ** argv)
 	i64 p1, p2;
 	int negP2 = 0;
 
-	assert(argc == 3 || argc == 2);
+	if (argc != 2 && argc != 3) {
+		diag_set(ClientError, ER_FUNC_WRONG_ARG_COUNT, "SUBSTR",
+			 "1 or 2", argc);
+		context->is_aborted = true;
+		return;
+	}
 	if (sql_value_is_null(argv[1])
 	    || (argc == 3 && sql_value_is_null(argv[2]))
 	    ) {
@@ -506,7 +511,12 @@ roundFunc(sql_context * context, int argc, sql_value ** argv)
 {
 	int n = 0;
 	double r;
-	assert(argc == 1 || argc == 2);
+	if (argc != 1 && argc != 2) {
+		diag_set(ClientError, ER_FUNC_WRONG_ARG_COUNT, "ROUND",
+			 "1 or 2", argc);
+		context->is_aborted = true;
+		return;
+	}
 	if (argc == 2) {
 		if (sql_value_is_null(argv[1]))
 			return;
@@ -898,6 +908,12 @@ likeFunc(sql_context *context, int argc, sql_value **argv)
 {
 	u32 escape = SQL_END_OF_STRING;
 	int nPat;
+	if (argc != 2 && argc != 3) {
+		diag_set(ClientError, ER_FUNC_WRONG_ARG_COUNT,
+			 "LIKE", "2 or 3", argc);
+		context->is_aborted = true;
+		return;
+	}
 	sql *db = sql_context_db_handle(context);
 	int rhs_type = sql_value_type(argv[0]);
 	int lhs_type = sql_value_type(argv[1]);
@@ -1510,7 +1526,9 @@ trim_func(struct sql_context *context, int argc, sql_value **argv)
 		trim_func_three_args(context, argv[0], argv[1], argv[2]);
 		break;
 	default:
-		unreachable();
+		diag_set(ClientError, ER_FUNC_WRONG_ARG_COUNT, "TRIM",
+			 "1 or 2 or 3", argc);
+		context->is_aborted = true;
 	}
 }
 
@@ -1689,6 +1707,12 @@ static void
 countStep(sql_context * context, int argc, sql_value ** argv)
 {
 	CountCtx *p;
+	if (argc != 0 && argc != 1) {
+		diag_set(ClientError, ER_FUNC_WRONG_ARG_COUNT,
+			 "COUNT", "0 or 1", argc);
+		context->is_aborted = true;
+		return;
+	}
 	p = sql_aggregate_context(context, sizeof(*p));
 	if ((argc == 0 || ! sql_value_is_null(argv[0])) && p) {
 		p->n++;
@@ -1765,7 +1789,12 @@ groupConcatStep(sql_context * context, int argc, sql_value ** argv)
 	StrAccum *pAccum;
 	const char *zSep;
 	int nVal, nSep;
-	assert(argc == 1 || argc == 2);
+	if (argc != 1 && argc != 2) {
+		diag_set(ClientError, ER_FUNC_WRONG_ARG_COUNT,
+			 "GROUP_CONCAT", "1 or 2", argc);
+		context->is_aborted = true;
+		return;
+	}
 	if (sql_value_is_null(argv[0]))
 		return;
 	pAccum =
@@ -1848,75 +1877,62 @@ sqlRegisterBuiltinFunctions(void)
 	 * For peak efficiency, put the most frequently used function last.
 	 */
 	static FuncDef aBuiltinFunc[] = {
-		FUNCTION(soundex, 1, 0, 0, soundexFunc, FIELD_TYPE_STRING),
-		FUNCTION2(unlikely, 1, 0, 0, noopFunc, SQL_FUNC_UNLIKELY,
+		FUNCTION(SOUNDEX, 1, 0, 0, soundexFunc, FIELD_TYPE_STRING),
+		FUNCTION2(UNLIKELY, 1, 0, 0, noopFunc, SQL_FUNC_UNLIKELY,
 			  FIELD_TYPE_BOOLEAN),
-		FUNCTION2(likelihood, 2, 0, 0, noopFunc, SQL_FUNC_UNLIKELY,
+		FUNCTION2(LIKELIHOOD, 2, 0, 0, noopFunc, SQL_FUNC_UNLIKELY,
 			  FIELD_TYPE_BOOLEAN),
-		FUNCTION2(likely, 1, 0, 0, noopFunc, SQL_FUNC_UNLIKELY,
+		FUNCTION2(LIKELY, 1, 0, 0, noopFunc, SQL_FUNC_UNLIKELY,
 			  FIELD_TYPE_BOOLEAN),
-		FUNCTION_COLL(trim, 1, 3, 0, trim_func),
-		FUNCTION_COLL(trim, 2, 3, 0, trim_func),
-		FUNCTION_COLL(trim, 3, 3, 0, trim_func),
-		FUNCTION2(least, -1, 0, 1, minmaxFunc, SQL_FUNC_MIN,
+		FUNCTION_COLL(TRIM, -1, 3, 0, trim_func),
+		FUNCTION2(LEAST, -1, 0, 1, minmaxFunc, SQL_FUNC_MIN,
 			  FIELD_TYPE_SCALAR),
-		AGGREGATE2(min, 1, 0, 1, minmaxStep, minMaxFinalize,
+		AGGREGATE2(MIN, 1, 0, 1, minmaxStep, minMaxFinalize,
 			   SQL_FUNC_MIN, FIELD_TYPE_SCALAR),
 		FUNCTION2(greatest, -1, 1, 1, minmaxFunc, SQL_FUNC_MAX,
 			  FIELD_TYPE_SCALAR),
-		AGGREGATE2(max, 1, 1, 1, minmaxStep, minMaxFinalize,
+		AGGREGATE2(MAX, 1, 1, 1, minmaxStep, minMaxFinalize,
 			   SQL_FUNC_MAX, FIELD_TYPE_SCALAR),
-		FUNCTION2(typeof, 1, 0, 0, typeofFunc, SQL_FUNC_TYPEOF,
+		FUNCTION2(TYPEOF, 1, 0, 0, typeofFunc, SQL_FUNC_TYPEOF,
 			  FIELD_TYPE_STRING),
-		FUNCTION2(length, 1, 0, 0, lengthFunc, SQL_FUNC_LENGTH,
+		FUNCTION2(LENGTH, 1, 0, 0, lengthFunc, SQL_FUNC_LENGTH,
 			  FIELD_TYPE_INTEGER),
-		FUNCTION(char_length, 1, 0, 0, lengthFunc, FIELD_TYPE_INTEGER),
-		FUNCTION(character_length, 1, 0, 0, lengthFunc,
+		FUNCTION(CHAR_LENGTH, 1, 0, 0, lengthFunc, FIELD_TYPE_INTEGER),
+		FUNCTION(CHARACTER_LENGTH, 1, 0, 0, lengthFunc,
 			 FIELD_TYPE_INTEGER),
-		FUNCTION(position, 2, 0, 1, position_func, FIELD_TYPE_INTEGER),
-		FUNCTION(printf, -1, 0, 0, printfFunc, FIELD_TYPE_STRING),
-		FUNCTION(unicode, 1, 0, 0, unicodeFunc, FIELD_TYPE_STRING),
-		FUNCTION(char, -1, 0, 0, charFunc, FIELD_TYPE_STRING),
-		FUNCTION(abs, 1, 0, 0, absFunc, FIELD_TYPE_NUMBER),
-		FUNCTION(round, 1, 0, 0, roundFunc, FIELD_TYPE_INTEGER),
-		FUNCTION(round, 2, 0, 0, roundFunc, FIELD_TYPE_INTEGER),
-		FUNCTION_COLL(upper, 1, 0, 1, UpperICUFunc),
-		FUNCTION_COLL(lower, 1, 0, 1, LowerICUFunc),
-		FUNCTION(hex, 1, 0, 0, hexFunc, FIELD_TYPE_STRING),
-		FUNCTION2(ifnull, 2, 0, 0, noopFunc, SQL_FUNC_COALESCE,
+		FUNCTION(POSITION, 2, 0, 1, position_func, FIELD_TYPE_INTEGER),
+		FUNCTION(PRINTF, -1, 0, 0, printfFunc, FIELD_TYPE_STRING),
+		FUNCTION(UNICODE, 1, 0, 0, unicodeFunc, FIELD_TYPE_STRING),
+		FUNCTION(CHAR, -1, 0, 0, charFunc, FIELD_TYPE_STRING),
+		FUNCTION(ABS, 1, 0, 0, absFunc, FIELD_TYPE_NUMBER),
+		FUNCTION(ROUND, -1, 0, 0, roundFunc, FIELD_TYPE_INTEGER),
+		FUNCTION_COLL(UPPER, 1, 0, 1, UpperICUFunc),
+		FUNCTION_COLL(LOWER, 1, 0, 1, LowerICUFunc),
+		FUNCTION(HEX, 1, 0, 0, hexFunc, FIELD_TYPE_STRING),
+		FUNCTION2(IFNULL, 2, 0, 0, noopFunc, SQL_FUNC_COALESCE,
 			  FIELD_TYPE_INTEGER),
-		VFUNCTION(random, 0, 0, 0, randomFunc, FIELD_TYPE_INTEGER),
-		VFUNCTION(randomblob, 1, 0, 0, randomBlob, FIELD_TYPE_VARBINARY),
-		FUNCTION(nullif, 2, 0, 1, nullifFunc, FIELD_TYPE_SCALAR),
-		FUNCTION(version, 0, 0, 0, sql_func_version, FIELD_TYPE_STRING),
-		FUNCTION(quote, 1, 0, 0, quoteFunc, FIELD_TYPE_STRING),
-		VFUNCTION(row_count, 0, 0, 0, sql_row_count, FIELD_TYPE_INTEGER),
-		FUNCTION_COLL(replace, 3, 0, 0, replaceFunc),
-		FUNCTION(zeroblob, 1, 0, 0, zeroblobFunc, FIELD_TYPE_VARBINARY),
-		FUNCTION_COLL(substr, 2, 0, 0, substrFunc),
-		FUNCTION_COLL(substr, 3, 0, 0, substrFunc),
-		AGGREGATE(sum, 1, 0, 0, sum_step, sumFinalize,
+		VFUNCTION(RANDOM, 0, 0, 0, randomFunc, FIELD_TYPE_INTEGER),
+		VFUNCTION(RANDOMBLOB, 1, 0, 0, randomBlob, FIELD_TYPE_VARBINARY),
+		FUNCTION(NULLIF, 2, 0, 1, nullifFunc, FIELD_TYPE_SCALAR),
+		FUNCTION(VERSION, 0, 0, 0, sql_func_version, FIELD_TYPE_STRING),
+		FUNCTION(QUOTE, 1, 0, 0, quoteFunc, FIELD_TYPE_STRING),
+		VFUNCTION(ROW_COUNT, 0, 0, 0, sql_row_count, FIELD_TYPE_INTEGER),
+		FUNCTION_COLL(REPLACE, 3, 0, 0, replaceFunc),
+		FUNCTION(ZEROBLOB, 1, 0, 0, zeroblobFunc, FIELD_TYPE_VARBINARY),
+		FUNCTION_COLL(SUBSTR, -1, 0, 0, substrFunc),
+		AGGREGATE(SUM, 1, 0, 0, sum_step, sumFinalize,
 			  FIELD_TYPE_NUMBER),
-		AGGREGATE(total, 1, 0, 0, sum_step, totalFinalize,
+		AGGREGATE(TOTAL, 1, 0, 0, sum_step, totalFinalize,
 			  FIELD_TYPE_NUMBER),
-		AGGREGATE(avg, 1, 0, 0, sum_step, avgFinalize,
+		AGGREGATE(AVG, 1, 0, 0, sum_step, avgFinalize,
 			  FIELD_TYPE_NUMBER),
-		AGGREGATE2(count, 0, 0, 0, countStep, countFinalize,
+		AGGREGATE2(COUNT, -1, 0, 0, countStep, countFinalize,
 			  SQL_FUNC_COUNT, FIELD_TYPE_INTEGER),
-		AGGREGATE2(count, 1, 0, 0, countStep, countFinalize,
-			   SQL_FUNC_COUNT, FIELD_TYPE_INTEGER),
-		AGGREGATE(group_concat, 1, 0, 0, groupConcatStep,
+		AGGREGATE(GROUP_CONCAT, -1, 0, 0, groupConcatStep,
 			  groupConcatFinalize, FIELD_TYPE_STRING),
-		AGGREGATE(group_concat, 2, 0, 0, groupConcatStep,
-			  groupConcatFinalize, FIELD_TYPE_STRING),
-
-		LIKEFUNC(like, 2, 1, SQL_FUNC_LIKE,
-			 FIELD_TYPE_INTEGER),
-		LIKEFUNC(like, 3, 1, SQL_FUNC_LIKE,
+		LIKEFUNC(LIKE, -1, 1, SQL_FUNC_LIKE,
 			 FIELD_TYPE_INTEGER),
-		FUNCTION(coalesce, 1, 0, 0, 0, FIELD_TYPE_SCALAR),
-		FUNCTION(coalesce, 0, 0, 0, 0, FIELD_TYPE_SCALAR),
-		FUNCTION2(coalesce, -1, 0, 0, noopFunc, SQL_FUNC_COALESCE,
+		FUNCTION2(COALESCE, -1, 0, 0, noopFunc, SQL_FUNC_COALESCE,
 			  FIELD_TYPE_SCALAR),
 	};
 	sql_register_analyze_builtins();
diff --git a/src/box/sql/resolve.c b/src/box/sql/resolve.c
index 83dff47b6..853d42b58 100644
--- a/src/box/sql/resolve.c
+++ b/src/box/sql/resolve.c
@@ -591,8 +591,6 @@ resolveExprStep(Walker * pWalker, Expr * pExpr)
 	case TK_FUNCTION:{
 			ExprList *pList = pExpr->x.pList;	/* The argument list */
 			int n = pList ? pList->nExpr : 0;	/* Number of arguments */
-			int no_such_func = 0;	/* True if no such function exists */
-			int wrong_num_args = 0;	/* True if wrong number of arguments */
 			int is_agg = 0;	/* True if is an aggregate function */
 			int nId;	/* Number of characters in function name */
 			const char *zId;	/* The function name. */
@@ -606,10 +604,17 @@ resolveExprStep(Walker * pWalker, Expr * pExpr)
 				pDef =
 				    sqlFindFunction(pParse->db, zId, -2,0);
 				if (pDef == 0) {
-					no_such_func = 1;
+					diag_set(ClientError,
+						 ER_NO_SUCH_FUNCTION, zId);
 				} else {
-					wrong_num_args = 1;
+					uint32_t argc = pDef->nArg;
+					const char *err = tt_sprintf("%d", argc);
+					diag_set(ClientError,
+						 ER_FUNC_WRONG_ARG_COUNT,
+						 pDef->zName, err, n);
 				}
+				pParse->is_aborted = true;
+				pNC->nErr++;
 			} else {
 				is_agg = pDef->xFinalize != 0;
 				pExpr->type = pDef->ret_type;
@@ -671,17 +676,6 @@ resolveExprStep(Walker * pWalker, Expr * pExpr)
 				pParse->is_aborted = true;
 				pNC->nErr++;
 				is_agg = 0;
-			} else if (no_such_func && pParse->db->init.busy == 0) {
-				diag_set(ClientError, ER_NO_SUCH_FUNCTION, zId);
-				pParse->is_aborted = true;
-				pNC->nErr++;
-			} else if (wrong_num_args) {
-				const char *err = "wrong number of arguments "\
-						  "to function %.*s()";
-				diag_set(ClientError, ER_SQL_PARSER_GENERIC,
-					 tt_sprintf(err, nId, zId));
-				pParse->is_aborted = true;
-				pNC->nErr++;
 			}
 			if (is_agg)
 				pNC->ncFlags &= ~NC_AllowAgg;
diff --git a/test/box/misc.result b/test/box/misc.result
index 287d84e5b..e4de2e9b3 100644
--- a/test/box/misc.result
+++ b/test/box/misc.result
@@ -530,6 +530,7 @@ t;
   198: box.error.FUNC_INDEX_FUNC
   199: box.error.FUNC_INDEX_FORMAT
   200: box.error.FUNC_INDEX_PARTS
+  201: box.error.FUNC_WRONG_ARG_COUNT
 ...
 test_run:cmd("setopt delimiter ''");
 ---
diff --git a/test/sql-tap/func.test.lua b/test/sql-tap/func.test.lua
index ec06c903d..a96fc611e 100755
--- a/test/sql-tap/func.test.lua
+++ b/test/sql-tap/func.test.lua
@@ -69,7 +69,7 @@ test:do_catchsql_test(
         SELECT length(*) FROM tbl1 ORDER BY t1
     ]], {
         -- <func-1.1>
-        1, "wrong number of arguments to function LENGTH()"
+        1, "Wrong number of arguments is passed to LENGTH(): expected 1, got 0"
         -- </func-1.1>
     })
 
@@ -79,7 +79,7 @@ test:do_catchsql_test(
         SELECT length(t1,5) FROM tbl1 ORDER BY t1
     ]], {
         -- <func-1.2>
-        1, "wrong number of arguments to function LENGTH()"
+        1, "Wrong number of arguments is passed to LENGTH(): expected 1, got 2"
         -- </func-1.2>
     })
 
@@ -365,7 +365,7 @@ test:do_test(
         return test:catchsql("SELECT abs(a,b) FROM t1")
     end, {
         -- <func-4.1>
-        1, "wrong number of arguments to function ABS()"
+        1, "Wrong number of arguments is passed to ABS(): expected 1, got 2"
         -- </func-4.1>
     })
 
@@ -377,7 +377,7 @@ test:do_catchsql_test(
         SELECT abs() FROM t1
     ]], {
         -- <func-4.2>
-        1, "wrong number of arguments to function ABS()"
+        1, "Wrong number of arguments is passed to ABS(): expected 1, got 0"
         -- </func-4.2>
     })
 
@@ -428,7 +428,7 @@ test:do_catchsql_test(
         SELECT round(a,b,c) FROM t1
     ]], {
         -- <func-4.5>
-        1, "wrong number of arguments to function ROUND()"
+        1, "Wrong number of arguments is passed to ROUND(): expected 1 or 2, got 3"
         -- </func-4.5>
     })
 
@@ -488,7 +488,7 @@ test:do_catchsql_test(
         SELECT round() FROM t1 ORDER BY a
     ]], {
         -- <func-4.11>
-        1, "wrong number of arguments to function ROUND()"
+        1, "Wrong number of arguments is passed to ROUND(): expected 1 or 2, got 0"
         -- </func-4.11>
     })
 
@@ -778,7 +778,7 @@ test:do_catchsql_test(
         SELECT upper(*) FROM t2
     ]], {
         -- <func-5.5>
-        1, "wrong number of arguments to function UPPER()"
+        1, "Wrong number of arguments is passed to UPPER(): expected 1, got 0"
         -- </func-5.5>
     })
 
@@ -1782,7 +1782,7 @@ test:do_catchsql_test(
         SELECT replace(1,2);
     ]], {
         -- <func-21.1>
-        1, "wrong number of arguments to function REPLACE()"
+        1, "Wrong number of arguments is passed to REPLACE(): expected 3, got 2"
         -- </func-21.1>
     })
 
@@ -1792,7 +1792,7 @@ test:do_catchsql_test(
         SELECT replace(1,2,3,4);
     ]], {
         -- <func-21.2>
-        1, "wrong number of arguments to function REPLACE()"
+        1, "Wrong number of arguments is passed to REPLACE(): expected 3, got 4"
         -- </func-21.2>
     })
 
@@ -2540,7 +2540,7 @@ test:do_catchsql_test(
         SELECT coalesce()
     ]], {
         -- <func-27.1>
-        1, "wrong number of arguments to function COALESCE()"
+        1, "Wrong number of arguments is passed to COALESCE(): expected at least two, got 0"
         -- </func-27.1>
     })
 
@@ -2550,7 +2550,7 @@ test:do_catchsql_test(
         SELECT coalesce(1)
     ]], {
         -- <func-27.2>
-        1, "wrong number of arguments to function COALESCE()"
+        1, "Wrong number of arguments is passed to COALESCE(): expected at least two, got 1"
         -- </func-27.2>
     })
 
diff --git a/test/sql-tap/func2.test.lua b/test/sql-tap/func2.test.lua
index b70197d09..c9bd3665f 100755
--- a/test/sql-tap/func2.test.lua
+++ b/test/sql-tap/func2.test.lua
@@ -50,7 +50,7 @@ test:do_catchsql_test(
         SELECT SUBSTR()
     ]], {
         -- <func2-1.2.1>
-        1, "wrong number of arguments to function SUBSTR()"
+        1, "Wrong number of arguments is passed to SUBSTR(): expected 1 or 2, got 0"
         -- </func2-1.2.1>
     })
 
@@ -60,7 +60,7 @@ test:do_catchsql_test(
         SELECT SUBSTR('Supercalifragilisticexpialidocious')
     ]], {
         -- <func2-1.2.2>
-        1, "wrong number of arguments to function SUBSTR()"
+        1, "Wrong number of arguments is passed to SUBSTR(): expected 1 or 2, got 1"
         -- </func2-1.2.2>
     })
 
@@ -70,7 +70,7 @@ test:do_catchsql_test(
         SELECT SUBSTR('Supercalifragilisticexpialidocious', 1,1,1)
     ]], {
         -- <func2-1.2.3>
-        1, "wrong number of arguments to function SUBSTR()"
+        1, "Wrong number of arguments is passed to SUBSTR(): expected 1 or 2, got 4"
         -- </func2-1.2.3>
     })
 
@@ -673,7 +673,7 @@ if ("ሴ" ~= "u1234")
             SELECT SUBSTR()
         ]], {
             -- <func2-2.1.2>
-            1, "wrong number of arguments to function SUBSTR()"
+            1, "Wrong number of arguments is passed to SUBSTR(): expected 1 or 2, got 0"
             -- </func2-2.1.2>
         })
 
@@ -683,7 +683,7 @@ if ("ሴ" ~= "u1234")
             SELECT SUBSTR('hiሴho')
         ]], {
             -- <func2-2.1.3>
-            1, "wrong number of arguments to function SUBSTR()"
+            1, "Wrong number of arguments is passed to SUBSTR(): expected 1 or 2, got 1"
             -- </func2-2.1.3>
         })
 
@@ -693,7 +693,7 @@ if ("ሴ" ~= "u1234")
             SELECT SUBSTR('hiሴho', 1,1,1)
         ]], {
             -- <func2-2.1.4>
-            1, "wrong number of arguments to function SUBSTR()"
+            1, "Wrong number of arguments is passed to SUBSTR(): expected 1 or 2, got 4"
             -- </func2-2.1.4>
         })
 
@@ -1038,7 +1038,7 @@ test:do_catchsql_test(
         SELECT SUBSTR()
     ]], {
         -- <func2-3.1.2>
-        1, "wrong number of arguments to function SUBSTR()"
+        1, "Wrong number of arguments is passed to SUBSTR(): expected 1 or 2, got 0"
         -- </func2-3.1.2>
     })
 
@@ -1048,7 +1048,7 @@ test:do_catchsql_test(
         SELECT SUBSTR(x'1234')
     ]], {
         -- <func2-3.1.3>
-        1, "wrong number of arguments to function SUBSTR()"
+        1, "Wrong number of arguments is passed to SUBSTR(): expected 1 or 2, got 1"
         -- </func2-3.1.3>
     })
 
@@ -1058,7 +1058,7 @@ test:do_catchsql_test(
         SELECT SUBSTR(x'1234', 1,1,1)
     ]], {
         -- <func2-3.1.4>
-        1, "wrong number of arguments to function SUBSTR()"
+        1, "Wrong number of arguments is passed to SUBSTR(): expected 1 or 2, got 4"
         -- </func2-3.1.4>
     })
 
diff --git a/test/sql-tap/limit.test.lua b/test/sql-tap/limit.test.lua
index 8445ab18e..870233942 100755
--- a/test/sql-tap/limit.test.lua
+++ b/test/sql-tap/limit.test.lua
@@ -771,7 +771,7 @@ test:do_catchsql_test(
         SELECT * FROM t1 LIMIT replace(1)
     ]], {
         -- <limit-12.1>
-        1, "wrong number of arguments to function REPLACE()"
+        1, "Wrong number of arguments is passed to REPLACE(): expected 3, got 1"
         -- </limit-12.1>
     })
 
@@ -781,7 +781,7 @@ test:do_catchsql_test(
         SELECT * FROM t1 LIMIT 5 OFFSET replace(1)
     ]], {
         -- <limit-12.2>
-        1, 'wrong number of arguments to function REPLACE()'
+        1, 'Wrong number of arguments is passed to REPLACE(): expected 3, got 1'
         -- </limit-12.2>
     })
 
diff --git a/test/sql-tap/select1.test.lua b/test/sql-tap/select1.test.lua
index 924c0ccb1..4bbfbd67b 100755
--- a/test/sql-tap/select1.test.lua
+++ b/test/sql-tap/select1.test.lua
@@ -244,7 +244,7 @@ test:do_catchsql_test(
         SELECT count(f1,f2) FROM test1
     ]], {
         -- <select1-2.1>
-        1, "wrong number of arguments to function COUNT()"
+        1, "Wrong number of arguments is passed to COUNT(): expected 0 or 1, got 2"
         -- </select1-2.1>
     })
 
@@ -324,7 +324,7 @@ test:do_catchsql_test(
         SELECT min(*) FROM test1
     ]], {
         -- <select1-2.6>
-        1, "wrong number of arguments to function MIN()"
+        1, "Wrong number of arguments is passed to MIN(): expected 1, got 0"
         -- </select1-2.6>
     })
 
@@ -389,7 +389,7 @@ test:do_catchsql_test(
         SELECT MAX(*) FROM test1
     ]], {
         -- <select1-2.9>
-        1, "wrong number of arguments to function MAX()"
+        1, "Wrong number of arguments is passed to MAX(): expected 1, got 0"
         -- </select1-2.9>
     })
 
@@ -469,7 +469,7 @@ test:do_catchsql_test(
         SELECT SUM(*) FROM test1
     ]], {
         -- <select1-2.14>
-        1, "wrong number of arguments to function SUM()"
+        1, "Wrong number of arguments is passed to SUM(): expected 1, got 0"
         -- </select1-2.14>
     })
 
@@ -489,7 +489,7 @@ test:do_catchsql_test(
         SELECT sum(f1,f2) FROM test1
     ]], {
         -- <select1-2.16>
-        1, "wrong number of arguments to function SUM()"
+        1, "Wrong number of arguments is passed to SUM(): expected 1, got 2"
         -- </select1-2.16>
     })
 
@@ -691,7 +691,7 @@ test:do_catchsql_test(
         SELECT f1 FROM test1 WHERE count(f1,f2)!=11
     ]], {
         -- <select1-3.9>
-        1, "wrong number of arguments to function COUNT()"
+        1, "misuse of aggregate function COUNT()"
         -- </select1-3.9>
     })
 
diff --git a/test/sql-tap/where2.test.lua b/test/sql-tap/where2.test.lua
index 4116ca913..f267be8e6 100755
--- a/test/sql-tap/where2.test.lua
+++ b/test/sql-tap/where2.test.lua
@@ -231,7 +231,7 @@ test:do_execsql_test(
         EXPLAIN SELECT * FROM x1, x2 WHERE x=1 ORDER BY random();
     ]], {
         -- <where2-2.5>
-        "/random/"
+        "/RANDOM/"
         -- </where2-2.5>
     })
 
@@ -254,7 +254,7 @@ test:do_execsql_test(
         EXPLAIN SELECT * FROM x1, x2 WHERE x=1 ORDER BY abs(5);
     ]], {
         -- <where2-2.6>
-        "~/abs/"
+        "~/ABS/"
         -- </where2-2.6>
     })
 
diff --git a/test/sql/icu-upper-lower.result b/test/sql/icu-upper-lower.result
index 88266c8c5..8ff7528f3 100644
--- a/test/sql/icu-upper-lower.result
+++ b/test/sql/icu-upper-lower.result
@@ -277,7 +277,7 @@ test_run:cmd("setopt delimiter ''");
 box.execute("select upper('1', 2)")
 ---
 - null
-- wrong number of arguments to function UPPER()
+- 'Wrong number of arguments is passed to UPPER(): expected 1, got 2'
 ...
 box.execute("select upper(\"1\")")
 ---
@@ -287,5 +287,5 @@ box.execute("select upper(\"1\")")
 box.execute("select upper()")
 ---
 - null
-- wrong number of arguments to function UPPER()
+- 'Wrong number of arguments is passed to UPPER(): expected 1, got 0'
 ...
-- 
2.22.1

  parent reply	other threads:[~2019-08-23 15:02 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-21 15:28 [tarantool-patches] [PATCH v4 0/4] sql: uniform SQL and Lua functions subsystem Kirill Shcherbatov
2019-08-21 15:28 ` [tarantool-patches] [PATCH v4 1/4] sql: rename sql_vdbe_mem_alloc_region helper Kirill Shcherbatov
2019-08-22 13:04   ` [tarantool-patches] " n.pettik
2019-08-23 15:02     ` Kirill Shcherbatov
2019-08-21 15:28 ` [tarantool-patches] [PATCH v4 2/4] sql: replace flag MINMAX with flags MIN and MAX Kirill Shcherbatov
2019-08-22 13:30   ` [tarantool-patches] " n.pettik
2019-08-21 15:28 ` [tarantool-patches] [PATCH v4 3/4] sql: get rid of FuncDef function hash Kirill Shcherbatov
2019-08-22 14:37   ` [tarantool-patches] " n.pettik
2019-08-23 15:02     ` [tarantool-patches] [PATCH v4 4/5] " Kirill Shcherbatov
2019-08-23 15:02     ` Kirill Shcherbatov [this message]
2019-08-28 15:05       ` [tarantool-patches] Re: [PATCH v4 3/5] sql: remove name overloading for SQL builtins Nikita Pettik
2019-08-23 15:02     ` [tarantool-patches] Re: [PATCH v4 3/4] sql: get rid of FuncDef function hash Kirill Shcherbatov
2019-08-21 15:28 ` [tarantool-patches] [PATCH v4 4/4] sql: support user-defined functions in SQL Kirill Shcherbatov
2019-08-22 15:23   ` [tarantool-patches] " n.pettik
2019-08-23 15:02     ` Kirill Shcherbatov
2019-08-29 15:09 ` [tarantool-patches] Re: [PATCH v4 0/4] sql: uniform SQL and Lua functions subsystem Nikita Pettik
2019-08-29 17:12 ` 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=6c04c60a-8ae6-d1bf-0d67-943f39bd3b81@tarantool.org \
    --to=kshcherbatov@tarantool.org \
    --cc=korablev@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [tarantool-patches] [PATCH v4 3/5] sql: remove name overloading for SQL builtins' \
    /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