From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 43381241CF for ; Tue, 5 Mar 2019 04:06:51 -0500 (EST) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qsH9FJQ6kjXW for ; Tue, 5 Mar 2019 04:06:51 -0500 (EST) Received: from smtp59.i.mail.ru (smtp59.i.mail.ru [217.69.128.39]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id F3D2820210 for ; Tue, 5 Mar 2019 04:06:50 -0500 (EST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Subject: [tarantool-patches] Re: [PATCH v3 5/9] sql: remove field zErrMsg of struct Parse From: "n.pettik" In-Reply-To: <29c77ea3f8463994b98bcb23653f901cf46e472a.1551530224.git.imeevma@gmail.com> Date: Tue, 5 Mar 2019 12:06:48 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: References: <29c77ea3f8463994b98bcb23653f901cf46e472a.1551530224.git.imeevma@gmail.com> Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org Cc: Imeev Mergen >>> @@ -146,11 +145,7 @@ sqlPrepare(sql * db, /* Database handle. */ >>> *ppStmt =3D (sql_stmt *) sParse.pVdbe; >>> } >>>=20 >>> - if (zErrMsg) { >>> - sqlErrorWithMsg(db, rc, "%s", zErrMsg); >>> - } else { >>> - sqlError(db, rc); >>> - } >>> + sqlError(db, rc); >>=20 >> sqlError seems to be useless/dead. Please, make a note somewhere >> to remove it as follow-up to error-refactoring patch-set. >>=20 > Ok, made a note. And where is it? Please, paste a link to it. > New version: >=20 > commit 29c77ea3f8463994b98bcb23653f901cf46e472a > Author: Mergen Imeev > Date: Wed Feb 27 09:40:17 2019 +0300 >=20 > sql: remove field zErrMsg of struct Parse >=20 > This field become unused and should be removed. >=20 > Part of #3965 >=20 > 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 =3D 0; /* Error message */ > int rc =3D SQL_OK; /* Result code */ > Parse sParse; /* Parsing context */ > sql_parser_create(&sParse, db); > @@ -89,14 +88,14 @@ sqlPrepare(sql * db, /* Database handle. */ > } > zSqlCopy =3D sqlDbStrNDup(db, zSql, nBytes); > if (zSqlCopy) { > - sqlRunParser(&sParse, zSqlCopy, &zErrMsg); > + sqlRunParser(&sParse, zSqlCopy); > sParse.zTail =3D &zSql[sParse.zTail - zSqlCopy]; > sqlDbFree(db, zSqlCopy); > } else { > sParse.zTail =3D &zSql[nBytes]; > } > } else { > - sqlRunParser(&sParse, zSql, &zErrMsg); > + sqlRunParser(&sParse, zSql); > } > assert(0 =3D=3D sParse.nQueryLoop); >=20 > @@ -169,11 +168,7 @@ sqlPrepare(sql * db, /* Database handle. */ > *ppStmt =3D (sql_stmt *) sParse.pVdbe; > } >=20 > - if (zErrMsg) { > - sqlErrorWithMsg(db, rc, "%s", zErrMsg); > - } else { > - sqlError(db, rc); > - } > + sqlError(db, rc); As we pointed out, you can remove this call. >=20 > /* Delete any TriggerPrg structures allocated while parsing this = statement. */ > while (sParse.pTriggerPrg) { > @@ -318,7 +313,6 @@ sql_parser_destroy(Parse *parser) > db->lookaside.bDisable -=3D parser->disableLookaside; > } > parser->disableLookaside =3D 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=E2=80=99s not true: rc =3D pParse->is_aborted; /* Control jumps to here if an error is encountered above, or = upon * successful coding of the SELECT. */ select_end: pParse->iSelectId =3D iRestoreSelectId; /* Identify column names if results of the SELECT are to be = output. */ if (rc =3D=3D SQL_OK && pDest->eDest =3D=3D 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=E2=80=99t 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) >=20 > /* > * 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 =3D 0; /* Number of errors encountered */ > int i; /* Loop counter */