Tarantool development patches archive
 help / color / mirror / Atom feed
From: Nikita Pettik <korablev@tarantool.org>
To: Leonid Vasiliev <lvasiliev@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org, v.shpilevoy@tarantool.org,
	m.semkin@corp.mail.ru
Subject: Re: [Tarantool-patches] [PATCH v2 2/3] sql: set an error to diag in sql_execute() on failure
Date: Fri, 11 Dec 2020 15:03:36 +0000	[thread overview]
Message-ID: <20201211150336.GG12730@tarantool.org> (raw)
In-Reply-To: <2bcd06c2ee8f5fcfdb8e2d0d640ab822362832f7.1607696813.git.lvasiliev@tarantool.org>

On 11 Dec 17:49, Leonid Vasiliev wrote:
> In SQL, on failure sometimes an error sets to the diag, sometimes not.
> And this can dived to situation as in #5537(SEGFAULT).
> So, let's set an error to the diag if the result of `sql_execute()`
> is a failure and there is no error in the diag.

Personally I am against this patch. In case of error SQL submodule
must always set diagnostic error; if it does no set - something goes
really wrong. In this case crash is better option. Firsly, it provides
coredump which is useful in accident investigation. Secondly, unset
diagnostics may leave SQL in inconsistent state - nobody knows how
severe error happened.
 
> Part of #5537
> ---
> 
> After some discussion with Sergos, I added a common diag_set
> when sql_execute() fails.
> I wanted to add such a common error by `diag_add()` if diag
> is not empty, but such a change would entail additional correction in tests.
> But this patch should be included in the next release, and I want it to
> be as small as possible. This patchset is about fixes a crash, not about
> refactoring and improvements. For this I will create separate tasks.
> 
>  src/box/execute.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/src/box/execute.c b/src/box/execute.c
> index e14da20..87ebb44 100644
> --- a/src/box/execute.c
> +++ b/src/box/execute.c
> @@ -687,8 +687,18 @@ sql_execute(struct sql_stmt *stmt, struct port *port, struct region *region)
>  		rc = sql_step(stmt);
>  		assert(rc != SQL_ROW && rc != 0);
>  	}
> -	if (rc != SQL_DONE)
> +	if (rc != SQL_DONE) {
> +		/*
> +		 * In SQL, on failure sometimes an error sets to the diag,
> +		 * sometimes not. So, let's set an error to the diag if
> +		 * the status is a failure and there is no error in the diag.
> +		 */
> +		if (diag_is_empty(diag_get())) {
> +			diag_set(ClientError, ER_SQL_EXECUTE,
> +				 "something went wrong");
> +		}
>  		return -1;
> +	}
>  	return 0;
>  }
>  
> -- 
> 2.7.4
> 

  reply	other threads:[~2020-12-11 15:03 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-11 14:49 [Tarantool-patches] [PATCH v2 0/3] Fix working with temporary files in VDBE Leonid Vasiliev
2020-12-11 14:49 ` [Tarantool-patches] [PATCH v2 1/3] sql: add missing diag_set on failure when working with files inside SQL module Leonid Vasiliev
2020-12-13 18:30   ` Vladislav Shpilevoy
2020-12-14 15:49     ` Leonid Vasiliev
2020-12-15 20:29       ` Sergey Ostanevich
2020-12-15 22:12   ` Vladislav Shpilevoy
2020-12-16 23:17     ` Leonid Vasiliev
2020-12-11 14:49 ` [Tarantool-patches] [PATCH v2 2/3] sql: set an error to diag in sql_execute() on failure Leonid Vasiliev
2020-12-11 15:03   ` Nikita Pettik [this message]
2020-12-11 15:40     ` Leonid Vasiliev
2020-12-13 18:30   ` Vladislav Shpilevoy
2020-12-14 15:52     ` Leonid Vasiliev
2020-12-15 21:05       ` Sergey Ostanevich
2020-12-11 14:49 ` [Tarantool-patches] [PATCH v2 3/3] sql: update temporary file name format Leonid Vasiliev
2020-12-13 18:30   ` Vladislav Shpilevoy
2020-12-14 15:54     ` Leonid Vasiliev
2020-12-15 21:07       ` Sergey Ostanevich
2020-12-16 14:47       ` Nikita 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=20201211150336.GG12730@tarantool.org \
    --to=korablev@tarantool.org \
    --cc=lvasiliev@tarantool.org \
    --cc=m.semkin@corp.mail.ru \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v2 2/3] sql: set an error to diag in sql_execute() on failure' \
    /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