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 A7A2C2749A for ; Thu, 14 Mar 2019 15:53:02 -0400 (EDT) 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 dHZaTR1RSOa9 for ; Thu, 14 Mar 2019 15:53:02 -0400 (EDT) Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (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 5CCC626995 for ; Thu, 14 Mar 2019 15:53:02 -0400 (EDT) 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 v4 3/8] sql: replace rc with is_aborted status in struct Parse From: "n.pettik" In-Reply-To: Date: Thu, 14 Mar 2019 22:53:00 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: References: 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 >>> 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( >>> ); >>> ]], { >>> -- >>> - 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)" >>> -- >>> }) >>=20 >> 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=E2=80=99t 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, >=20 > sql_resolve_self_reference(&parser, def, NC_IsCheck, NULL, = expr_list); > int rc =3D 0; > - if (parser.rc !=3D SQL_OK) { > - /* Tarantool error may be already set with diag. */ > - if (parser.rc !=3D SQL_TARANTOOL_ERROR) > - diag_set(ClientError, ER_SQL, parser.zErrMsg); > + if (parser.is_aborted) > rc =3D -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 =3D true; =20 sql_resolve_self_reference(&parser, def, NC_IsCheck, NULL, = expr_list); - int rc =3D 0; - if (parser.is_aborted) - rc =3D -1; sql_parser_destroy(&parser); - return rc; + return parser.is_aborted ? -1 : 0; } > } >=20 > 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 =3D 0; /* Error message */ > int rc =3D SQL_OK; /* Result code */ > Parse sParse; /* Parsing context */ > sql_parser_create(&sParse, db); > @@ -89,25 +88,24 @@ 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 > - if (sParse.rc =3D=3D SQL_DONE) > - sParse.rc =3D SQL_OK; > if (db->mallocFailed) > - sParse.rc =3D SQL_TARANTOOL_ERROR; > + sParse.is_aborted =3D true; > if (pzTail) { > *pzTail =3D sParse.zTail; > } > - rc =3D sParse.rc; > + if (sParse.is_aborted) > + rc =3D SQL_TARANTOOL_ERROR; >=20 > if (rc =3D=3D SQL_OK && sParse.pVdbe && sParse.explain) { > static const char *const azColName[] =3D { > @@ -168,11 +166,7 @@ sqlPrepare(sql * db, /* Database handle. */ > *ppStmt =3D (sql_stmt *) sParse.pVdbe; > } >=20 > - if (zErrMsg) { > - sqlErrorWithMsg(db, rc, "%s", zErrMsg); > - } else { > - sqlError(db, rc); > - } > + db->errCode =3D rc; Is this thing used anywhere?