Tarantool development patches archive
 help / color / mirror / Atom feed
From: "n.pettik" <korablev@tarantool.org>
To: tarantool-patches@freelists.org
Cc: Imeev Mergen <imeevma@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH v4 8/8] sql: remove sqlErrorMsg()
Date: Tue, 26 Mar 2019 16:34:26 +0300	[thread overview]
Message-ID: <2E9AC693-B13A-4FFD-8F0D-A3FA7AA442A3@tarantool.org> (raw)
In-Reply-To: <20190325184737.GA18346@tarantool.org>


>> @@ -1039,8 +1036,8 @@ resolveCompoundOrderBy(Parse * pParse,    /* Parsing context.  Leave error messages
>>                        const char *err = "Error at ORDER BY in place %d: "\
>>                                          "term does not match any column in "\
>>                                          "the result set";
>> -                       err = tt_sprintf(err, i + 1);
>> -                       diag_set(ClientError, ER_SQL_PARSER_GENERIC, err);
>> +                       diag_set(ClientError, ER_SQL_PARSER_GENERIC,
>> +                                tt_sprintf(err, i + 1));
>> 
>>> @@ -1444,10 +1469,37 @@ resolveSelectStep(Walker * pWalker, Select * p)
>>>    * number of expressions in the select list.
>>>    */
>>>   if (p->pNext && p->pEList->nExpr != p->pNext->pEList->nExpr) {
>>> -     sqlSelectWrongNumTermsError(pParse, p->pNext);
>>> +     if (p->pNext->selFlags & SF_Values) {
>>> +       diag_set(ClientError, ER_SQL_PARSER_GENERIC,
>>> +          "all VALUES must have the same "\
>>> +          "number of terms");
>>> +     } else {
>>> +       const char *err_msg =
>>> +         "SELECTs to the left and right of %s "\
>>> +         "do not have the same number of "\
>>> +         "result columns";
>>> +       switch (p->pNext->op) {
>>> +       case TK_ALL:
>>> +         err_msg = tt_sprintf(err_msg,
>>> +                  "UNION ALL");
>>> +         break;
>> 
>> Why don’t use selectOpName?
>> Like it was in  sqlSelectWrongNumTermsError().
>> 
> Function selectOpName defined in different file and is static.
> I think it isn't worth to share it for one error.

I believe it is worth doing. For instance, you can return
sqlSelectWrongNumTermsError() which was placed in select.c
and called that static func.

> Diff between versions:
> 
> diff --git a/src/box/sql/expr.c b/src/box/sql/expr.c
> index e26596a..1077285 100644
> --- a/src/box/sql/expr.c
> +++ b/src/box/sql/expr.c
> @@ -666,13 +666,7 @@ codeVectorCompare(Parse * pParse,	/* Code generator context */
> 	int regRight = 0;
> 	u8 op = pExpr->op;
> 	int addrDone = sqlVdbeMakeLabel(v);
> -
> -	if (nLeft != sqlExprVectorSize(pRight)) {
> -		diag_set(ClientError, ER_SQL_PARSER_GENERIC,
> -			 "row value misused");
> -		pParse->is_aborted = true;
> -		return;
> -	}

Here the problem is that function is never called in our test suite:
I placed assert(0); and no one test failed. Please, add at least
simple tests like SELECT (1, 2) == (1, 2) to make sure that
codeVectorCompare() can be processed. Tests which you’ve added
fails before this func is called.

Added comment:

diff --git a/src/box/sql/expr.c b/src/box/sql/expr.c
index 107728590..397f8209c 100644
--- a/src/box/sql/expr.c
+++ b/src/box/sql/expr.c
@@ -666,6 +666,11 @@ codeVectorCompare(Parse * pParse,  /* Code generator context */
        int regRight = 0;
        u8 op = pExpr->op;
        int addrDone = sqlVdbeMakeLabel(v);
+       /*
+        * Situation when vectors have different dimensions is
+        * filtred way before - during expr resolution:
+        * see resolveExprStep().
+        */

> +	assert(nLeft == sqlExprVectorSize(pRight));
> 	assert(pExpr->op == TK_EQ || pExpr->op == TK_NE
> 	       || pExpr->op == TK_LT || pExpr->op == TK_GT
> 	       || pExpr->op == TK_LE || pExpr->op == TK_GE);
> 
> 
> @@ -4384,10 +4378,8 @@ sqlWhereBegin(Parse * pParse,	/* The parser context */
> 	 * equal to pTabList->nSrc but might be shortened to 1 if the
> 	 * WHERE_OR_SUBCLAUSE flag is set.
> 	 */
> -	for (ii = 0; ii < pTabList->nSrc; ii++) {
> +	for (ii = 0; ii < pTabList->nSrc; ii++)
> 		createMask(pMaskSet, pTabList->a[ii].iCursor);
> -		sqlWhereTabFuncArgs(pParse, &pTabList->a[ii], &pWInfo->sWC);

Move removal of this func to a separate patch pls alongside with mentions of
table-valued funcs. It is not related to errors.

  reply	other threads:[~2019-03-26 13:34 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-13 17:03 [tarantool-patches] [PATCH v4 0/8] sql: use diag_set() for errors in SQL imeevma
2019-03-13 17:03 ` [tarantool-patches] [PATCH v4 1/8] sql: rework syntax errors imeevma
2019-03-14 18:24   ` [tarantool-patches] " n.pettik
2019-03-14 18:28     ` Imeev Mergen
2019-03-15 14:09   ` Kirill Yukhin
2019-03-13 17:03 ` [tarantool-patches] [PATCH v4 2/8] sql: set SQL parser errors via diag_set() imeevma
2019-03-14 19:26   ` [tarantool-patches] " n.pettik
2019-03-14 19:36     ` n.pettik
2019-03-18 15:06     ` Mergen Imeev
2019-03-19  9:41       ` n.pettik
2019-03-19 11:24   ` Kirill Yukhin
2019-03-13 17:03 ` [tarantool-patches] [PATCH v4 3/8] sql: replace rc with is_aborted status in struct Parse imeevma
2019-03-14 19:53   ` [tarantool-patches] " n.pettik
2019-03-18 15:28     ` Mergen Imeev
2019-03-19  9:54       ` n.pettik
2019-03-19 13:17   ` Kirill Yukhin
2019-03-13 17:03 ` [tarantool-patches] [PATCH v4 4/8] sql: remove field nErr from " imeevma
2019-03-14 19:58   ` [tarantool-patches] " n.pettik
2019-03-19 13:27   ` Kirill Yukhin
2019-03-13 17:03 ` [tarantool-patches] [PATCH v4 5/8] sql: remove field zErrMsg " imeevma
2019-03-14 22:15   ` [tarantool-patches] " n.pettik
2019-03-19 13:20   ` Kirill Yukhin
2019-03-13 17:03 ` [tarantool-patches] [PATCH v4 6/8] sql: rework three errors of "unsupported" type imeevma
2019-03-14 22:15   ` [tarantool-patches] " n.pettik
2019-03-19 13:30   ` Kirill Yukhin
2019-03-13 17:03 ` [tarantool-patches] [PATCH v4 7/8] sql: rework semantic errors imeevma
2019-03-15 15:49   ` [tarantool-patches] " n.pettik
2019-03-22 12:48     ` Mergen Imeev
2019-03-26 14:14       ` n.pettik
2019-03-26 16:56         ` Mergen Imeev
2019-03-26 18:16           ` n.pettik
2019-03-26 19:20             ` Mergen Imeev
2019-03-26 21:36               ` n.pettik
2019-03-27  6:48   ` Kirill Yukhin
2019-03-13 17:03 ` [tarantool-patches] [PATCH v4 8/8] sql: remove sqlErrorMsg() imeevma
2019-03-15 13:36   ` [tarantool-patches] " n.pettik
2019-03-25 18:47     ` Mergen Imeev
2019-03-26 13:34       ` n.pettik [this message]
2019-03-26 17:52         ` Mergen Imeev
2019-03-26 18:28           ` n.pettik
2019-03-26 19:21             ` Mergen Imeev
2019-03-26 21:36               ` n.pettik
2019-03-27  6:49   ` 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=2E9AC693-B13A-4FFD-8F0D-A3FA7AA442A3@tarantool.org \
    --to=korablev@tarantool.org \
    --cc=imeevma@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH v4 8/8] sql: remove sqlErrorMsg()' \
    /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