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 v2 4/5] sql: remove file zErrMsg of struct Parse
Date: Tue, 26 Feb 2019 17:47:46 +0300	[thread overview]
Message-ID: <B55A9284-A9D3-4463-9F11-F371F00AAFAC@tarantool.org> (raw)
In-Reply-To: <33421784356c1d83b8f38d1ff4c90982f3ad884b.1551114402.git.imeevma@gmail.com>


> diff --git a/src/box/sql.c b/src/box/sql.c
> index 580f3fa..116e3e8 100644
> --- a/src/box/sql.c
> +++ b/src/box/sql.c
> @@ -1362,13 +1362,8 @@ sql_checks_resolve_space_def_reference(ExprList *expr_list,
> 	parser.parse_only = true;
> 
> 	sql_resolve_self_reference(&parser, def, NC_IsCheck, NULL, expr_list);
> -	int rc = 0;
> -	if (parser.rc != SQL_OK) {
> -		/* Tarantool error may be already set with diag. */
> -		if (parser.rc != SQL_TARANTOOL_ERROR)
> -			diag_set(ClientError, ER_SQL, parser.zErrMsg);
> -		rc = -1;
> -	}
> +	if (parser.rc != SQL_OK)
> +		return -1;

Since now we have only one possible RC, lets remove
its name and simply check (parser.rc != 0).
Or, as suggested Konstantin, better replace rc with bool is_aborted flag.

> 	sql_parser_destroy(&parser);
> -	return rc;
> +	return 0;
> }
> diff --git a/src/box/sql/build.c b/src/box/sql/build.c
> index deb5b89..6afca4a 100644
> --- a/src/box/sql/build.c
> +++ b/src/box/sql/build.c
> @@ -493,16 +493,10 @@ sql_column_add_nullable_action(struct Parse *parser,
> 	struct field_def *field = &def->fields[def->field_count - 1];
> 	if (field->nullable_action != ON_CONFLICT_ACTION_DEFAULT &&
> 	    nullable_action != field->nullable_action) {
> -		/* Prevent defining nullable_action many times. */
> -		const char *err_msg =
> -			tt_sprintf("NULL declaration for column '%s' of table "
> -				   "'%s' has been already set to '%s'",
> -				   field->name, def->name,
> -				   on_conflict_action_strs[field->
> -							   nullable_action]);
> -		diag_set(ClientError, ER_SQL, err_msg);
> -		parser->rc = SQL_TARANTOOL_ERROR;
> -		parser->nErr++;
> +		sqlErrorMsg(parser, "NULL declaration for column '%s' of "\
> +			    "table '%s' has been already set to '%s'",
> +			    field->name, def->name,
> +			    on_conflict_action_strs[field-> nullable_action]);

This looks like step back in our attempt at using diag_set.
We do you need to incapsulate diag into sqlErrorMsg?

> 		return;
> 	}
> 	field->nullable_action = nullable_action;
> diff --git a/src/box/sql/delete.c b/src/box/sql/delete.c
> index 5170c7f..a7bf3b3 100644
> --- a/src/box/sql/delete.c
> +++ b/src/box/sql/delete.c
> @@ -94,31 +94,22 @@ sql_table_truncate(struct Parse *parse, struct SrcList *tab_list)
> 	struct space *space = space_by_name(tab_name);
> 	if (space == NULL) {
> 		diag_set(ClientError, ER_NO_SUCH_SPACE, tab_name);
> -		goto tarantool_error;
> +		sql_parser_error(parse);

Look, anyway you remove this function in next commit.
Next time please consider order of refactoring.

> 	}
> 	if (! rlist_empty(&space->parent_fk_constraint)) {
> -		const char *err_msg =
> -			tt_sprintf("can not truncate space '%s' because other "
> -				   "objects depend on it", space->def->name);
> -		diag_set(ClientError, ER_SQL, err_msg);
> -		goto tarantool_error;
> +		sqlErrorMsg(parse, "can not truncate space '%s' because other "
> +			    "objects depend on it", space->def->name);

Replace invocation of sqlErrorMsg with diag_set + parser->rc.
The same in other places.

> @@ -146,11 +145,7 @@ sqlPrepare(sql * db,	/* Database handle. */
> 		*ppStmt = (sql_stmt *) sParse.pVdbe;
> 	}
> 
> -	if (zErrMsg) {
> -		sqlErrorWithMsg(db, rc, "%s", zErrMsg);
> -	} else {
> -		sqlError(db, rc);
> -	}
> +	sqlError(db, rc);

sqlError seems to be useless/dead. Please, make a note somewhere
to remove it as follow-up to error-refactoring patch-set.

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

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-25 17:14 [tarantool-patches] [PATCH v2 0/5] sql: use diag_set() for errors in SQL imeevma
2019-02-25 17:14 ` [tarantool-patches] [PATCH v2 1/5] sql: remove "syntax error after column name" error imeevma
2019-02-25 19:34   ` [tarantool-patches] " n.pettik
2019-02-27 11:32   ` Kirill Yukhin
2019-02-25 17:14 ` [tarantool-patches] [PATCH v2 2/5] sql: rework syntax errors imeevma
2019-02-25 20:02   ` [tarantool-patches] " n.pettik
2019-02-26  8:24     ` Konstantin Osipov
2019-02-26 12:59       ` n.pettik
2019-02-26 13:12         ` Konstantin Osipov
2019-02-26 15:59       ` Imeev Mergen
2019-02-25 17:14 ` [tarantool-patches] [PATCH v2 3/5] sql: save SQL parser errors in diag_set() imeevma
2019-02-25 23:01   ` [tarantool-patches] " n.pettik
2019-02-26  8:25     ` Konstantin Osipov
2019-02-26 15:29     ` Imeev Mergen
2019-02-25 17:14 ` [tarantool-patches] [PATCH v2 4/5] sql: remove file zErrMsg of struct Parse imeevma
2019-02-26 14:47   ` n.pettik [this message]
2019-02-26 15:36     ` [tarantool-patches] " Imeev Mergen
2019-02-26 18:17       ` n.pettik
2019-02-25 17:14 ` [tarantool-patches] [PATCH v2 5/5] sql: remove field nErr " imeevma
2019-02-26  8:27   ` [tarantool-patches] " Konstantin Osipov
2019-02-26 14:48   ` n.pettik

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=B55A9284-A9D3-4463-9F11-F371F00AAFAC@tarantool.org \
    --to=korablev@tarantool.org \
    --cc=imeevma@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH v2 4/5] sql: remove file zErrMsg of struct Parse' \
    /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