From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 0463628821 for ; Thu, 29 Aug 2019 16:43:08 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 301lCpcCvSzw for ; Thu, 29 Aug 2019 16:43:07 -0400 (EDT) Received: from smtp31.i.mail.ru (smtp31.i.mail.ru [94.100.177.91]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id B88C9287CF for ; Thu, 29 Aug 2019 16:43:07 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH 8/8] sql: introduce dry-run execution References: <9ebc8e59010c5099ef1f39a5563aa64f5c9746a1.1566907520.git.korablev@tarantool.org> From: Vladislav Shpilevoy Message-ID: <92286aa9-2b33-72a4-760e-241f7f8286ff@tarantool.org> Date: Thu, 29 Aug 2019 22:46:21 +0200 MIME-Version: 1.0 In-Reply-To: <9ebc8e59010c5099ef1f39a5563aa64f5c9746a1.1566907520.git.korablev@tarantool.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: Nikita Pettik , tarantool-patches@freelists.org Cc: kostja@tarantool.org, alexander.turenko@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.