From: "n.pettik" <korablev@tarantool.org>
To: tarantool-patches@freelists.org
Cc: Imeev Mergen <imeevma@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH v3 5/9] sql: remove field zErrMsg of struct Parse
Date: Tue, 5 Mar 2019 12:06:48 +0300 [thread overview]
Message-ID: <F8E2BB02-016F-490C-8BDC-330CA44955C5@tarantool.org> (raw)
In-Reply-To: <29c77ea3f8463994b98bcb23653f901cf46e472a.1551530224.git.imeevma@gmail.com>
>>> @@ -146,11 +145,7 @@ sqlPrepare(sql * db, /* Database handle. */
>>> *ppStmt = (sql_stmt *) sParse.pVdbe;
>>> }
>>>
>>> - if (zErrMsg) {
>>> - sqlErrorWithMsg(db, rc, "%s", zErrMsg);
>>> - } else {
>>> - sqlError(db, rc);
>>> - }
>>> + sqlError(db, rc);
>>
>> sqlError seems to be useless/dead. Please, make a note somewhere
>> to remove it as follow-up to error-refactoring patch-set.
>>
> Ok, made a note.
And where is it? Please, paste a link to it.
> New version:
>
> commit 29c77ea3f8463994b98bcb23653f901cf46e472a
> Author: Mergen Imeev <imeevma@gmail.com>
> Date: Wed Feb 27 09:40:17 2019 +0300
>
> sql: remove field zErrMsg of struct Parse
>
> This field become unused and should be removed.
>
> Part of #3965
>
> diff --git a/src/box/sql/prepare.c b/src/box/sql/prepare.c
> index 42737ff..4359fa7 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,14 +88,14 @@ 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);
>
> @@ -169,11 +168,7 @@ sqlPrepare(sql * db, /* Database handle. */
> *ppStmt = (sql_stmt *) sParse.pVdbe;
> }
>
> - if (zErrMsg) {
> - sqlErrorWithMsg(db, rc, "%s", zErrMsg);
> - } else {
> - sqlError(db, rc);
> - }
> + sqlError(db, rc);
As we pointed out, you can remove this call.
>
> /* Delete any TriggerPrg structures allocated while parsing this statement. */
> while (sParse.pTriggerPrg) {
> @@ -318,7 +313,6 @@ sql_parser_destroy(Parse *parser)
> db->lookaside.bDisable -= parser->disableLookaside;
> }
> parser->disableLookaside = 0;
> - sqlDbFree(db, parser->zErrMsg);
> switch (parser->parsed_ast_type) {
> case AST_TYPE_SELECT:
> sql_select_delete(db, parser->parsed_ast.select);
> diff --git a/src/box/sql/select.c b/src/box/sql/select.c
> index cfac553..66cbc73 100644
> --- a/src/box/sql/select.c
> +++ b/src/box/sql/select.c
> @@ -5431,9 +5431,7 @@ vdbe_code_raise_on_multiple_rows(struct Parse *parser, int limit_reg, int end_ma
> * The results are returned according to the SelectDest structure.
> * See comments in sqlInt.h for further information.
> *
> - * This routine returns the number of errors. If any errors are
> - * encountered, then an appropriate error message is left in
> - * pParse->zErrMsg.
> + * This routine returns the number of errors.
That’s not true:
rc = pParse->is_aborted;
/* Control jumps to here if an error is encountered above, or upon
* successful coding of the SELECT.
*/
select_end:
pParse->iSelectId = iRestoreSelectId;
/* Identify column names if results of the SELECT are to be output.
*/
if (rc == SQL_OK && pDest->eDest == SRT_Output) {
generateColumnNames(pParse, pTabList, pEList);
}
sqlDbFree(db, sAggInfo.aCol);
sqlDbFree(db, sAggInfo.aFunc);
#ifdef SQL_DEBUG
SELECTTRACE(1, pParse, p, ("end processing\n"));
pParse->nSelectIndent--;
#endif
return rc;
So it doesn’t return count of occurred errors.
> diff --git a/src/box/sql/tokenize.c b/src/box/sql/tokenize.c
> index 4ca3c2e..1a7248e 100644
> --- a/src/box/sql/tokenize.c
> +++ b/src/box/sql/tokenize.c
> @@ -439,13 +439,10 @@ parser_space_delete(struct sql *db, struct space *space)
>
> /*
> * Run the parser on the given SQL string. The parser structure is
> - * passed in. An SQL_ status code is returned. If an error occurs
> - * then an and attempt is made to write an error message into
> - * memory obtained from sql_malloc() and to make *pzErrMsg point to that
> - * error message.
> + * passed in. An SQL_ status code is returned.
On the other hand:
return nErr;
So what is the truth?
> */
> int
> -sqlRunParser(Parse * pParse, const char *zSql, char **pzErrMsg)
> +sqlRunParser(Parse * pParse, const char *zSql)
> {
> int nErr = 0; /* Number of errors encountered */
> int i; /* Loop counter */
next prev parent reply other threads:[~2019-03-05 9:06 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-02 13:07 [tarantool-patches] [PATCH v3 0/9] sql: use diag_set() for errors in SQL imeevma
2019-03-02 13:07 ` [tarantool-patches] [PATCH v3 1/9] sql: rework syntax errors imeevma
2019-03-04 17:47 ` [tarantool-patches] " n.pettik
2019-03-05 8:31 ` Konstantin Osipov
2019-03-02 13:07 ` [tarantool-patches] [PATCH v3 2/9] sql: save SQL parser errors in diag_set() imeevma
2019-03-05 8:40 ` [tarantool-patches] " Konstantin Osipov
2019-03-05 9:06 ` n.pettik
2019-03-02 13:07 ` [tarantool-patches] [PATCH v3 3/9] sql: remove field nErr of struct Parse imeevma
2019-03-05 8:41 ` [tarantool-patches] " Konstantin Osipov
2019-03-05 9:06 ` n.pettik
2019-03-02 13:07 ` [tarantool-patches] [PATCH v3 4/9] sql: remove field rc " imeevma
2019-03-05 8:42 ` [tarantool-patches] " Konstantin Osipov
2019-03-05 9:06 ` n.pettik
2019-03-02 13:07 ` [tarantool-patches] [PATCH v3 5/9] sql: remove field zErrMsg " imeevma
2019-03-05 8:43 ` [tarantool-patches] " Konstantin Osipov
2019-03-05 9:06 ` n.pettik [this message]
2019-03-02 13:07 ` [tarantool-patches] [PATCH v3 6/9] sql: rework six syntax errors imeevma
2019-03-05 8:45 ` [tarantool-patches] " Konstantin Osipov
2019-03-05 9:07 ` n.pettik
2019-03-02 13:08 ` [tarantool-patches] [PATCH v3 7/9] sql: rework four semantic errors imeevma
2019-03-05 8:46 ` [tarantool-patches] " Konstantin Osipov
2019-03-05 9:16 ` n.pettik
2019-03-02 13:08 ` [tarantool-patches] [PATCH v3 8/9] sql: rework three errors of "unsupported" type imeevma
2019-03-05 8:47 ` [tarantool-patches] " Konstantin Osipov
2019-03-05 9:34 ` n.pettik
2019-03-05 9:43 ` Konstantin Osipov
2019-03-02 13:08 ` [tarantool-patches] [PATCH v3 9/9] sql: remove sqlErrorMsg() imeevma
2019-03-05 8:48 ` [tarantool-patches] " Konstantin Osipov
2019-03-05 12:16 ` n.pettik
2019-03-05 15:44 ` Konstantin Osipov
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=F8E2BB02-016F-490C-8BDC-330CA44955C5@tarantool.org \
--to=korablev@tarantool.org \
--cc=imeevma@tarantool.org \
--cc=tarantool-patches@freelists.org \
--subject='[tarantool-patches] Re: [PATCH v3 5/9] sql: remove field zErrMsg of 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