Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: Nikita Pettik <korablev@tarantool.org>, tarantool-patches@freelists.org
Cc: kostja@tarantool.org, alexander.turenko@tarantool.org
Subject: [tarantool-patches] Re: [PATCH 8/8] sql: introduce dry-run execution
Date: Thu, 29 Aug 2019 22:46:21 +0200	[thread overview]
Message-ID: <92286aa9-2b33-72a4-760e-241f7f8286ff@tarantool.org> (raw)
In-Reply-To: <9ebc8e59010c5099ef1f39a5563aa64f5c9746a1.1566907520.git.korablev@tarantool.org>

Thanks for the patch!

See 2 comments below.

On 27/08/2019 15:34, Nikita Pettik wrote:
> To get result of dry-run execution locally, one can use
> box.dry_run("sql_string") method, which returns query's
> meta-information. Note this method does not support binding values
> substitution.
> 
> To get result of dry-run execution using net.box facilities, one can
> pass map containing dry_run options to :execute() method (leaving array
> of bindings empty):
> 
> cn:execute("SELECT 1;", {}, {{dry_run = true}})
> 
> Or simply set options considering their order:
> 
> cn:execute("SELECT 1;", {}, {true})
> 
> Note that there's no binding substitution even if array of values to be
> bound is not empty. Also, dry-run execution for DML and DDL request
> doesn't make any sense - zero row_count is always returned.
> 
> Under the hood we add 'meta_only' flag to struct port_sql, which
> regulates whether response contains only metadata or metadata and
> tuples forming the result set of query.
> 
> Closes #3292

1. JFR, we will need a docbot request. About box, netbox, and the binary
protocol.

> diff --git a/src/box/iproto.cc b/src/box/iproto.cc
> index a92e66ace..22019efaa 100644
> --- a/src/box/iproto.cc
> +++ b/src/box/iproto.cc
> @@ -1671,14 +1671,16 @@ tx_process_sql(struct cmsg *m)
>  	if (sql_prepare(sql, len, &stmt, NULL) != 0)
>  		goto error;
>  	assert(stmt != NULL);
> -	port_sql_create(&port, stmt);
> -	if (sql_bind(stmt, bind, bind_count) != 0) {
> -		port_destroy(&port);
> -		goto error;
> -	}
> -	if (sql_execute(stmt, &port, &fiber()->gc) != 0) {
> -		port_destroy(&port);
> -		goto error;
> +	port_sql_create(&port, stmt, opts.dry_run);
> +	if (!opts.dry_run) {
> +		if (sql_bind(stmt, bind, bind_count) != 0) {
> +			port_destroy(&port);
> +			goto error;
> +		}
> +		if (sql_execute(stmt, &port, &fiber()->gc) != 0) {
> +			port_destroy(&port);
> +			goto error;
> +		}
>  	}

2. This should be done inside sql_prepare_and_execute(), which
will take sql_opts parameter. It will allow you to 1) keep
sql_port encapsulated, 2) don't duplicate this code for Lua and
iproto versions.

  parent reply	other threads:[~2019-08-29 20:43 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-27 13:34 [tarantool-patches] [PATCH 0/8] rfc: introduce dry-run execution of SQL queries Nikita Pettik
2019-08-27 13:34 ` [tarantool-patches] [PATCH 1/8] port: increase padding of struct port Nikita Pettik
2019-08-28  9:33   ` [tarantool-patches] " Konstantin Osipov
2019-08-29 20:46   ` Vladislav Shpilevoy
2019-08-27 13:34 ` [tarantool-patches] [PATCH 2/8] port: move struct port_sql to box/port.h Nikita Pettik
2019-08-28  9:33   ` [tarantool-patches] " Konstantin Osipov
2019-08-29 20:46   ` Vladislav Shpilevoy
2019-08-27 13:34 ` [tarantool-patches] [PATCH 3/8] sql: remove sql_prepare_v2() Nikita Pettik
2019-08-28  9:33   ` [tarantool-patches] " Konstantin Osipov
2019-08-29 20:46   ` Vladislav Shpilevoy
2019-08-27 13:34 ` [tarantool-patches] [PATCH 4/8] sql: refactor sql_prepare() and sqlPrepare() Nikita Pettik
2019-08-28  9:35   ` [tarantool-patches] " Konstantin Osipov
2019-08-29 20:46   ` Vladislav Shpilevoy
2019-08-27 13:34 ` [tarantool-patches] [PATCH 5/8] sql: move sql_prepare() declaration to box/execute.h Nikita Pettik
2019-08-28  9:35   ` [tarantool-patches] " Konstantin Osipov
2019-08-27 13:34 ` [tarantool-patches] [PATCH 6/8] refactoring: use sql_prepare() and sql_execute() in tx_process_sql() Nikita Pettik
2019-08-28  9:37   ` [tarantool-patches] " Konstantin Osipov
2019-08-29 20:46   ` Vladislav Shpilevoy
2019-08-27 13:34 ` [tarantool-patches] [PATCH 7/8] netbox: allow passing options to :execute() Nikita Pettik
2019-08-28  9:38   ` [tarantool-patches] " Konstantin Osipov
2019-08-29 20:46   ` Vladislav Shpilevoy
2019-08-27 13:34 ` [tarantool-patches] [PATCH 8/8] sql: introduce dry-run execution Nikita Pettik
2019-08-28  9:39   ` [tarantool-patches] " Konstantin Osipov
2019-08-29 20:46   ` Vladislav Shpilevoy [this message]
2019-08-28  9:31 ` [tarantool-patches] Re: [PATCH 0/8] rfc: introduce dry-run execution of SQL queries Konstantin Osipov
2019-08-29 20:46 ` Vladislav Shpilevoy

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=92286aa9-2b33-72a4-760e-241f7f8286ff@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=alexander.turenko@tarantool.org \
    --cc=korablev@tarantool.org \
    --cc=kostja@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH 8/8] sql: introduce dry-run execution' \
    /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