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 v4 7/8] sql: rework semantic errors
Date: Tue, 26 Mar 2019 17:14:22 +0300	[thread overview]
Message-ID: <08DAB5A5-C5B9-4D0F-B3C3-D3B29505B2D0@tarantool.org> (raw)
In-Reply-To: <20190322124822.GA7890@tarantool.org>

[-- Attachment #1: Type: text/plain, Size: 4453 bytes --]


>>> @@ -1042,27 +1044,34 @@ resolveCompoundOrderBy(Parse * pParse,	/* Parsing context.  Leave error messages
>>> * field) then convert that term into a copy of the corresponding result set
>>> * column.
>>> *
>>> - * If any errors are detected, add an error message to pParse and
>>> - * return non-zero.  Return zero if no errors are seen.
>>> + * @param pParse Parsing context.
>>> + * @param pSelect The SELECT statement containing the clause.
>>> + * @param pOrderBy The ORDER BY or GROUP BY clause to be
>>> + *                 processed.
>>> + * @param is_order_by True if pOrderBy is ORDER BY, false if
>>> + *                    pOrderBy is GROUP BY
>>> + * @retval 0 On success, not 0 elsewhere.
>>> */
>>> int
>>> -sqlResolveOrderGroupBy(Parse * pParse,	/* Parsing context.  Leave error messages here */
>>> -			   Select * pSelect,	/* The SELECT statement containing the clause */
>>> -			   ExprList * pOrderBy,	/* The ORDER BY or GROUP BY clause to be processed */
>>> -			   const char *zType	/* "ORDER" or "GROUP" */
>>> -    )
>>> +sqlResolveOrderGroupBy(Parse *pParse, Select *pSelect, ExprList *pOrderBy,
>>> +		       bool is_order_by)
>> 
>> Why did you decide to fix code style here? Anyway, you didn't finished it
>> (struct prefixes, param naming and so on and so forth)
>> 
> I fixed this because I thought that it is quite unreliable to
> differentiate names of term using first letter of its name. Should
> I remove these changes?

But below you anyway get string representation. So, let’s return
back previous version.

>>> {
>>> 	int i;
>>> 	sql *db = pParse->db;
>>> 	ExprList *pEList;
>>> 	struct ExprList_item *pItem;
>>> +	const char *zType = is_order_by ? "ORDER" : "GROUP";
>>> 
>>> 	if (pOrderBy == 0 || pParse->db->mallocFailed)
>>> 		return 0;
>>> 
>>> @@ -1096,22 +1105,23 @@ sqlResolveOrderGroupBy(Parse * pParse,	/* Parsing context.  Leave error messages
>>> * result-set expression.  Otherwise, the expression is resolved in
>>> * the usual way - using sqlResolveExprNames().
>>> *
>>> - * This routine returns the number of errors.  If errors occur, then
>>> - * an appropriate error message might be left in pParse.  (OOM errors
>>> - * excepted.)
>>> + * @param pNC The name context of the SELECT statement.
>>> + * @param pSelect The SELECT statement containing the clause.
>>> + * @param pOrderBy An ORDER BY or GROUP BY clause to resolve.
>>> + * @param is_order_by True if pOrderBy is ORDER BY, false if
>>> + *                    pOrderBy is GROUP BY
>>> + * @retval 0 On success, not 0 elsewhere.
>>> */
>>> static int
>>> -resolveOrderGroupBy(NameContext * pNC,	/* The name context of the SELECT statement */
>>> -		    Select * pSelect,	/* The SELECT statement holding pOrderBy */
>>> -		    ExprList * pOrderBy,	/* An ORDER BY or GROUP BY clause to resolve */
>>> -		    const char *zType	/* Either "ORDER" or "GROUP", as appropriate */
>>> -    )
>> 
>> The same question.
>> 
> Answer above.
> 
> diff --git a/src/box/sql/build.c b/src/box/sql/build.c
> index 0022254..b6b6c24 100644
> --- a/src/box/sql/build.c
> +++ b/src/box/sql/build.c
> @@ -603,7 +603,7 @@ sqlAddPrimaryKey(Parse * pParse,	/* Parsing context */
> 		goto primary_key_exit;
> 	if (sql_space_primary_key(space) != NULL) {
> 		diag_set(ClientError, ER_CREATE_SPACE, space->def->name,
> -			 "too many primary keys");
> +			 "primary key already exists”);

Sorry, could you fix message to “primary key has been already declared”
or “can’t declare PRIMARY KEY more than once”? This error is related
only to CREATE TABLE processing, so nothing is created at this stage yet.
Hence, error msg may seem a little bit misleading.

> diff --git a/src/box/sql/tokenize.c b/src/box/sql/tokenize.c
> index de0f282..efb895f 100644
> --- a/src/box/sql/tokenize.c
> +++ b/src/box/sql/tokenize.c
> @@ -481,8 +481,8 @@ sqlRunParser(Parse * pParse, const char *zSql)
> 				      &pParse->sLastToken.isReserved);
> 			i += pParse->sLastToken.n;
> 			if (i > mxSqlLen) {
> -				diag_set(ClientError, ER_SQL_PARSER_GENERIC,
> -					 "string or blob too big");
> +				diag_set(ClientError, ER_SQL_PARSER_LIMIT,
> +					 "SQL command length", i, mxSqlLen);
> 				pParse->is_aborted = true;
> 				break;
> 			}
> 
> I will investigate this error a bit later.

Ok, then file it (and the rest of comments which you haven’t fixed).



[-- Attachment #2: Type: text/html, Size: 52560 bytes --]

  reply	other threads:[~2019-03-26 14:14 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-13 17:03 [tarantool-patches] [PATCH v4 0/8] sql: use diag_set() for errors in SQL imeevma
2019-03-13 17:03 ` [tarantool-patches] [PATCH v4 1/8] sql: rework syntax errors imeevma
2019-03-14 18:24   ` [tarantool-patches] " n.pettik
2019-03-14 18:28     ` Imeev Mergen
2019-03-15 14:09   ` Kirill Yukhin
2019-03-13 17:03 ` [tarantool-patches] [PATCH v4 2/8] sql: set SQL parser errors via diag_set() imeevma
2019-03-14 19:26   ` [tarantool-patches] " n.pettik
2019-03-14 19:36     ` n.pettik
2019-03-18 15:06     ` Mergen Imeev
2019-03-19  9:41       ` n.pettik
2019-03-19 11:24   ` Kirill Yukhin
2019-03-13 17:03 ` [tarantool-patches] [PATCH v4 3/8] sql: replace rc with is_aborted status in struct Parse imeevma
2019-03-14 19:53   ` [tarantool-patches] " n.pettik
2019-03-18 15:28     ` Mergen Imeev
2019-03-19  9:54       ` n.pettik
2019-03-19 13:17   ` Kirill Yukhin
2019-03-13 17:03 ` [tarantool-patches] [PATCH v4 4/8] sql: remove field nErr from " imeevma
2019-03-14 19:58   ` [tarantool-patches] " n.pettik
2019-03-19 13:27   ` Kirill Yukhin
2019-03-13 17:03 ` [tarantool-patches] [PATCH v4 5/8] sql: remove field zErrMsg " imeevma
2019-03-14 22:15   ` [tarantool-patches] " n.pettik
2019-03-19 13:20   ` Kirill Yukhin
2019-03-13 17:03 ` [tarantool-patches] [PATCH v4 6/8] sql: rework three errors of "unsupported" type imeevma
2019-03-14 22:15   ` [tarantool-patches] " n.pettik
2019-03-19 13:30   ` Kirill Yukhin
2019-03-13 17:03 ` [tarantool-patches] [PATCH v4 7/8] sql: rework semantic errors imeevma
2019-03-15 15:49   ` [tarantool-patches] " n.pettik
2019-03-22 12:48     ` Mergen Imeev
2019-03-26 14:14       ` n.pettik [this message]
2019-03-26 16:56         ` Mergen Imeev
2019-03-26 18:16           ` n.pettik
2019-03-26 19:20             ` Mergen Imeev
2019-03-26 21:36               ` n.pettik
2019-03-27  6:48   ` Kirill Yukhin
2019-03-13 17:03 ` [tarantool-patches] [PATCH v4 8/8] sql: remove sqlErrorMsg() imeevma
2019-03-15 13:36   ` [tarantool-patches] " n.pettik
2019-03-25 18:47     ` Mergen Imeev
2019-03-26 13:34       ` n.pettik
2019-03-26 17:52         ` Mergen Imeev
2019-03-26 18:28           ` n.pettik
2019-03-26 19:21             ` Mergen Imeev
2019-03-26 21:36               ` n.pettik
2019-03-27  6:49   ` Kirill Yukhin

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=08DAB5A5-C5B9-4D0F-B3C3-D3B29505B2D0@tarantool.org \
    --to=korablev@tarantool.org \
    --cc=imeevma@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH v4 7/8] sql: rework semantic 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