From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp16.mail.ru (smtp16.mail.ru [94.100.176.153]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id E933446970E for ; Tue, 24 Dec 2019 14:40:08 +0300 (MSK) Date: Tue, 24 Dec 2019 14:40:08 +0300 From: Sergey Ostanevich Message-ID: <20191224114008.GD19594@tarantool.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Subject: Re: [Tarantool-patches] [PATCH v3 03/20] sql: move sql_prepare() declaration to box/execute.h List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Nikita Pettik Cc: tarantool-patches@dev.tarantool.org Hi! Thanks for the patch. LGTM. Regards, Sergos On 20 Dec 15:47, Nikita Pettik wrote: > We are going to split sql_prepare_and_execute() into several explicit > and logically separated steps: > > 1. sql_prepare() -- compile VDBE byte-code > 2. sql_bind() -- bind variables (if there are any) > 3. sql_execute() -- query (byte-code) execution in virtual machine > > For instance, for dry-run we are interested only in query preparation. > Contrary, if we had prepared statement cache, we could skip query > preparation and handle only bind and execute steps. > > To avoid inclusion of sql/sqlInt.h header (which gathers almost all SQL > specific functions and constants) let's move sql_prepare() to > box/execute.h header (which already holds sql_prepare_and_execute()). > > Needed for #3292 > --- > src/box/execute.h | 12 ++++++++++++ > src/box/sql/analyze.c | 1 + > src/box/sql/legacy.c | 1 + > src/box/sql/sqlInt.h | 12 ------------ > 4 files changed, 14 insertions(+), 12 deletions(-) > > diff --git a/src/box/execute.h b/src/box/execute.h > index a2fd4d1b7..a6000c08b 100644 > --- a/src/box/execute.h > +++ b/src/box/execute.h > @@ -89,6 +89,18 @@ struct port_sql { > > extern const struct port_vtab port_sql_vtab; > > +/** > + * Prepare (compile into VDBE byte-code) statement. > + * > + * @param sql UTF-8 encoded SQL statement. > + * @param length Length of @param sql in bytes. > + * @param[out] stmt A pointer to the prepared statement. > + * @param[out] sql_tail End of parsed string. > + */ > +int > +sql_prepare(const char *sql, int length, struct sql_stmt **stmt, > + const char **sql_tail); > + > #if defined(__cplusplus) > } /* extern "C" { */ > #endif > diff --git a/src/box/sql/analyze.c b/src/box/sql/analyze.c > index e43011dd0..00ca15413 100644 > --- a/src/box/sql/analyze.c > +++ b/src/box/sql/analyze.c > @@ -106,6 +106,7 @@ > */ > > #include "box/box.h" > +#include "box/execute.h" > #include "box/index.h" > #include "box/key_def.h" > #include "box/schema.h" > diff --git a/src/box/sql/legacy.c b/src/box/sql/legacy.c > index 16507b334..e3a2c77ca 100644 > --- a/src/box/sql/legacy.c > +++ b/src/box/sql/legacy.c > @@ -37,6 +37,7 @@ > */ > > #include "sqlInt.h" > +#include "box/execute.h" > #include "box/session.h" > > /* > diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h > index ac1d8ce42..3ca10778e 100644 > --- a/src/box/sql/sqlInt.h > +++ b/src/box/sql/sqlInt.h > @@ -468,18 +468,6 @@ typedef void (*sql_destructor_type) (void *); > #define SQL_STATIC ((sql_destructor_type)0) > #define SQL_TRANSIENT ((sql_destructor_type)-1) > > -/** > - * Prepare (compile into VDBE byte-code) statement. > - * > - * @param sql UTF-8 encoded SQL statement. > - * @param length Length of @param sql in bytes. > - * @param[out] stmt A pointer to the prepared statement. > - * @param[out] sql_tail End of parsed string. > - */ > -int > -sql_prepare(const char *sql, int length, struct sql_stmt **stmt, > - const char **sql_tail); > - > int > sql_step(sql_stmt *); > > -- > 2.15.1 >