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 A1C342EA29 for ; Sat, 11 May 2019 08:39:14 -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 pLQr-oVIf--7 for ; Sat, 11 May 2019 08:39:14 -0400 (EDT) Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (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 5B91C2E79A for ; Sat, 11 May 2019 08:39:14 -0400 (EDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.8\)) Subject: [tarantool-patches] Re: [PATCH v1 1/1] sql: do not replace the error with a syntax error From: "n.pettik" In-Reply-To: <76ecaa6e2ba8a69f421a73bb25fb857cf5bbe001.1557244912.git.imeevma@gmail.com> Date: Sat, 11 May 2019 15:39:11 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <8D8884F5-961C-477F-B5AD-8723C0BBB674@tarantool.org> References: <76ecaa6e2ba8a69f421a73bb25fb857cf5bbe001.1557244912.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 > On 7 May 2019, at 19:03, imeevma@tarantool.org wrote: >=20 > Currently, it is possible to set a syntax error, even if there has > already been another error before. >=20 > For example: > box.execute("insert into not_exist values(1) a") >=20 > The first error is "Space 'NOT_EXIST' does not exist", but "Syntax > error near 'a'" is displayed. >=20 > After this patch, all syntax errors will be set only if there have > been no errors before. >=20 > Closes #3964 This patch doesn=E2=80=99t resolve issue completely (at least what = issue=E2=80=99s topic says): we just ignore further errors and continue parsing process. > --- > https://github.com/tarantool/tarantool/issues/3964 > = https://github.com/tarantool/tarantool/tree/imeevma/gh-3964-stop-parser-on= -error >=20 > src/box/sql/parse.y | 12 ++++++++++++ > test/sql-tap/e_select1.test.lua | 2 +- > test/sql-tap/misc1.test.lua | 2 +- > test/sql-tap/sql-errors.test.lua | 12 +++++++++++- > test/sql-tap/view.test.lua | 2 +- > 5 files changed, 26 insertions(+), 4 deletions(-) >=20 > diff --git a/src/box/sql/parse.y b/src/box/sql/parse.y > index 3a443a0..ac3cce0 100644 > --- a/src/box/sql/parse.y > +++ b/src/box/sql/parse.y > @@ -32,6 +32,18 @@ > %syntax_error { > UNUSED_PARAMETER(yymajor); /* Silence some compiler warnings */ > assert( TOKEN.z[0] ); /* The tokenizer always gives us a token */ > + /* > + * Do nothing if there was already an error. Before this patch, > + * a syntax error can replace an already set error when the > + * parser rule is violated. > + * For example: > + * INSERT INSERT not_exist VALUES(1) a > + * > + * In this case space NOT_EXIST do not exist, but this error has > + * been replaced by a syntax error. > + */ > + if (pParse->is_aborted) Let=E2=80=99s add assertion: - if (pParse->is_aborted) + if (pParse->is_aborted) { + assert(! diag_is_empty(diag_get())); return; + } > + return; A bit re-phrased your comment: /* * Do nothing if an error has been already set. Since we don't * stop parsing process, syntax error can replace an already * set error when the parser's rule is violated. * For example: * INSERT INSERT not_exist VALUES(1) a; * * In this case space NOT_EXIST doesn't exist, but this error * will be replaced by a error 'near "''a''": syntax error' */ diff --git a/src/box/sql/parse.y b/src/box/sql/parse.y index ac3cce0ce..44d002b4b 100644 --- a/src/box/sql/parse.y +++ b/src/box/sql/parse.y @@ -33,14 +33,14 @@ UNUSED_PARAMETER(yymajor); /* Silence some compiler warnings */ assert( TOKEN.z[0] ); /* The tokenizer always gives us a token */ /* - * Do nothing if there was already an error. Before this patch, - * a syntax error can replace an already set error when the - * parser rule is violated. + * Do nothing if an error has been already set. Since we don't + * stop parsing process, syntax error can replace an already + * set error when the parser's rule is violated. * For example: - * INSERT INSERT not_exist VALUES(1) a + * INSERT INSERT not_exist VALUES(1) a; * - * In this case space NOT_EXIST do not exist, but this error has - * been replaced by a syntax error. + * In this case space NOT_EXIST doesn't exist, but this error + * will be replaced by a error 'near "''a''": syntax error' */ if (pParse->is_aborted)