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 3/8] sql: replace rc with is_aborted status in struct Parse
Date: Thu, 14 Mar 2019 22:53:00 +0300	[thread overview]
Message-ID: <FBE3202D-2F86-45AA-8F61-64094AC2E4B3@tarantool.org> (raw)
In-Reply-To: <ad9f22e790f24598fae717ff1de8992b43ef48c9.1552494059.git.imeevma@gmail.com>


>>> diff --git a/test/sql-tap/check.test.lua b/test/sql-tap/check.test.lua
>>> index bab6493..0d8bf15 100755
>>> --- a/test/sql-tap/check.test.lua
>>> +++ b/test/sql-tap/check.test.lua
>>> @@ -516,7 +516,7 @@ test:do_catchsql_test(
>>>        );
>>>    ]], {
>>>        -- <check-5.1>
>>> -        1, "Wrong space options (field 5): invalid expression specified (SQL error: bindings are not allowed in DDL)"
>>> +        1, "Wrong space options (field 5): invalid expression specified (bindings are not allowed in DDL)"
>>>        -- </check-5.1>
>>>    })
>> 
>> Why test results have changed if you provided
>> non-functional refactoring?
> It become this way because now the error in diag instead of being
> only in zErrMsg of struct Parse.

So, then it should be related to the previous patch, I guess.
Otherwise, still don’t understand. Or fix commit message,
since now it implies that only refactoring was provided.
Or, what is better - move functional changes to separate patch.

> index a2937a0..c2e5d6b 100644
> --- a/src/box/sql.c
> +++ b/src/box/sql.c
> @@ -1363,12 +1363,8 @@ sql_checks_resolve_space_def_reference(ExprList *expr_list,
> 
> 	sql_resolve_self_reference(&parser, def, NC_IsCheck, NULL, expr_list);
> 	int rc = 0;
> -	if (parser.rc != SQL_OK) {
> -		/* Tarantool error may be already set with diag. */
> -		if (parser.rc != SQL_TARANTOOL_ERROR)
> -			diag_set(ClientError, ER_SQL, parser.zErrMsg);
> +	if (parser.is_aborted)
> 		rc = -1;
> -	}
> 	sql_parser_destroy(&parser);
> 	return rc;

diff --git a/src/box/sql.c b/src/box/sql.c
index c2e5d6bd1..ea71dd101 100644
--- a/src/box/sql.c
+++ b/src/box/sql.c
@@ -1362,9 +1362,6 @@ sql_checks_resolve_space_def_reference(ExprList *expr_list,
        parser.parse_only = true;
 
        sql_resolve_self_reference(&parser, def, NC_IsCheck, NULL, expr_list);
-       int rc = 0;
-       if (parser.is_aborted)
-               rc = -1;
        sql_parser_destroy(&parser);
-       return rc;
+       return parser.is_aborted ? -1 : 0;
 }

> }
> 
> diff --git a/src/box/sql/prepare.c b/src/box/sql/prepare.c
> index 828a1ae..85385ee 100644
> --- a/src/box/sql/prepare.c
> +++ b/src/box/sql/prepare.c
> @@ -52,7 +52,6 @@ sqlPrepare(sql * db,	/* Database handle. */
> 	       const char **pzTail	/* OUT: End of parsed string */
>     )
> {
> -	char *zErrMsg = 0;	/* Error message */
> 	int rc = SQL_OK;	/* Result code */
> 	Parse sParse;		/* Parsing context */
> 	sql_parser_create(&sParse, db);
> @@ -89,25 +88,24 @@ sqlPrepare(sql * db,	/* Database handle. */
> 		}
> 		zSqlCopy = sqlDbStrNDup(db, zSql, nBytes);
> 		if (zSqlCopy) {
> -			sqlRunParser(&sParse, zSqlCopy, &zErrMsg);
> +			sqlRunParser(&sParse, zSqlCopy);
> 			sParse.zTail = &zSql[sParse.zTail - zSqlCopy];
> 			sqlDbFree(db, zSqlCopy);
> 		} else {
> 			sParse.zTail = &zSql[nBytes];
> 		}
> 	} else {
> -		sqlRunParser(&sParse, zSql, &zErrMsg);
> +		sqlRunParser(&sParse, zSql);
> 	}
> 	assert(0 == sParse.nQueryLoop);
> 
> -	if (sParse.rc == SQL_DONE)
> -		sParse.rc = SQL_OK;
> 	if (db->mallocFailed)
> -		sParse.rc = SQL_TARANTOOL_ERROR;
> +		sParse.is_aborted = true;
> 	if (pzTail) {
> 		*pzTail = sParse.zTail;
> 	}
> -	rc = sParse.rc;
> +	if (sParse.is_aborted)
> +		rc = SQL_TARANTOOL_ERROR;
> 
> 	if (rc == SQL_OK && sParse.pVdbe && sParse.explain) {
> 		static const char *const azColName[] = {
> @@ -168,11 +166,7 @@ sqlPrepare(sql * db,	/* Database handle. */
> 		*ppStmt = (sql_stmt *) sParse.pVdbe;
> 	}
> 
> -	if (zErrMsg) {
> -		sqlErrorWithMsg(db, rc, "%s", zErrMsg);
> -	} else {
> -		sqlError(db, rc);
> -	}
> +	db->errCode = rc;

Is this thing used anywhere?

  reply	other threads:[~2019-03-14 19:53 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   ` n.pettik [this message]
2019-03-18 15:28     ` [tarantool-patches] " 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
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=FBE3202D-2F86-45AA-8F61-64094AC2E4B3@tarantool.org \
    --to=korablev@tarantool.org \
    --cc=imeevma@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH v4 3/8] sql: replace rc with is_aborted status in struct Parse' \
    /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