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 v3 6/9] sql: rework six syntax errors
Date: Tue, 5 Mar 2019 12:07:06 +0300	[thread overview]
Message-ID: <3C6CDD11-D7C7-42E4-8BAC-77E23DE6C48B@tarantool.org> (raw)
In-Reply-To: <80be508ddcba4ffe5f5f4e99068ccce61e05a764.1551530224.git.imeevma@gmail.com>



> On 2 Mar 2019, at 16:07, imeevma@tarantool.org wrote:
> 
> This patch rewords six more syntax errors.

Are these errors considered to be syntax?
AFAIR we’ve classified them as semantic errors.
And I counted only three new error (and two changed tests)
codes in errcode.h

> Part of #3965
> ---
> src/box/errcode.h             |  3 +++
> src/box/sql/build.c           |  4 +--
> src/box/sql/resolve.c         | 62 +++++++++++++++++++++----------------------
> test/box/misc.result          |  3 +++
> test/sql-tap/check.test.lua   |  2 +-
> test/sql-tap/colname.test.lua |  2 +-
> 6 files changed, 40 insertions(+), 36 deletions(-)
> 
> diff --git a/src/box/errcode.h b/src/box/errcode.h
> index d234d26..057a6d3 100644
> --- a/src/box/errcode.h
> +++ b/src/box/errcode.h
> @@ -239,6 +239,9 @@ struct errcode_record {
> 	/*184 */_(ER_SQL_UNRECOGNIZED_SYNTAX,	"Syntax error near '%.*s'") \
> 	/*185 */_(ER_SQL_UNKNOWN_TOKEN,		"Syntax error: unrecognized token: '%.*s'") \
> 	/*186 */_(ER_SQL_PARSER_GENERIC,	"%s") \
> +	/*187 */_(ER_INDEX_DEF,			"%s prohibited in an index definition") \
> +	/*188 */_(ER_CHECK_CONSTRAINT_DEF,	"%s prohibited in prohibited in a CHECK constraint definition") \

Prohibited in prohibited? I guess this is typo.

> +	/*189 */_(ER_PRIMARY_KEY_DEF,		"Expressions are prohibited in a primary key definition") \

Make errcodes names be more specific:
ER_INDEX_DEF -> ER_INDEX_EXPR_UNSUPPORTED etc.

> diff --git a/src/box/sql/resolve.c b/src/box/sql/resolve.c
> index 3215db3..02eca37 100644
> --- a/src/box/sql/resolve.c
> +++ b/src/box/sql/resolve.c
> @@ -510,30 +510,6 @@ sqlCreateColumnExpr(sql * db, SrcList * pSrc, int iSrc, int iCol)
> }
> 
> -/*
>  * Expression p should encode a floating point value between 1.0 and 0.0.
>  * Return 1024 times this value.  Or return -1 if p is not a floating point
>  * value between 1.0 and 0.0.
> @@ -605,7 +581,10 @@ resolveExprStep(Walker * pWalker, Expr * pExpr)
> 			Expr *pRight;
> 
> 			/* if( pSrcList==0 ) break; */
> -			notValid(pParse, pNC, "the \".\" operator", NC_IdxExpr);
> +			if (pNC->ncFlags & NC_IdxExpr) {
> +				diag_set(ClientError, ER_INDEX_DEF, "'.' operator is");
> +				pParse->is_aborted = true;
> +			}

Is this code reachable? I don’t see any tests connected with it.
Please, figure out whether these errors can be raised or not,
and if they can be raised, add corresponding tests.

> test_run:cmd("setopt delimiter ''");
> ---
> diff --git a/test/sql-tap/check.test.lua b/test/sql-tap/check.test.lua
> index 0d8bf15..e1d2d48 100755
> --- a/test/sql-tap/check.test.lua
> +++ b/test/sql-tap/check.test.lua
> @@ -319,7 +319,7 @@ test:do_catchsql_test(
>         );
>     ]], {
>         -- <check-3.1>
> -        1, "Failed to create space 'T3': subqueries prohibited in CHECK constraints"
> +        1, "Failed to create space 'T3': Subqueries are prohibited in prohibited in a CHECK constraint definition"
>         -- </check-3.1>
>     })
> 
> diff --git a/test/sql-tap/colname.test.lua b/test/sql-tap/colname.test.lua
> index 29fdf13..77c4280 100755
> --- a/test/sql-tap/colname.test.lua
> +++ b/test/sql-tap/colname.test.lua
> @@ -637,7 +637,7 @@ test:do_test(
> test:do_catchsql_test(
>     "colname-11.1",
>     [[ create table t1(a INT, b INT, c INT, primary key('A'))]],
> -    {1, "expressions prohibited in PRIMARY KEY"})
> +    {1, "Expressions are prohibited in a primary key definition”}

Ok, I see three new error codes and two changed tests.

  parent reply	other threads:[~2019-03-05  9:07 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
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 [this message]
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=3C6CDD11-D7C7-42E4-8BAC-77E23DE6C48B@tarantool.org \
    --to=korablev@tarantool.org \
    --cc=imeevma@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH v3 6/9] sql: rework six syntax errors' \
    /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