From: Nikita Pettik <korablev@tarantool.org> To: tarantool-patches@freelists.org Cc: v.shpilevoy@tarantool.org, kostja@tarantool.org, alexander.turenko@tarantool.org, Nikita Pettik <korablev@tarantool.org> Subject: [tarantool-patches] [PATCH 5/8] sql: move sql_prepare() declaration to box/execute.h Date: Tue, 27 Aug 2019 16:34:26 +0300 [thread overview] Message-ID: <5cb066a8cede9a29a43be1654a9b32ffe9f05706.1566907520.git.korablev@tarantool.org> (raw) In-Reply-To: <cover.1566907519.git.korablev@tarantool.org> In-Reply-To: <cover.1566907519.git.korablev@tarantool.org> 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 1995c43d5..1b4e14246 100644 --- a/src/box/execute.h +++ b/src/box/execute.h @@ -69,6 +69,18 @@ sql_prepare_and_execute(const char *sql, int len, const struct sql_bind *bind, uint32_t bind_count, struct port *port, struct region *region); +/** + * 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 fa3d364e9..7e3ad270e 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 d2fc76919..7dc0fb8b4 100644 --- a/src/box/sql/sqlInt.h +++ b/src/box/sql/sqlInt.h @@ -447,18 +447,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
next prev parent reply other threads:[~2019-08-27 13:34 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 ` Nikita Pettik [this message] 2019-08-28 9:35 ` [tarantool-patches] Re: [PATCH 5/8] sql: move sql_prepare() declaration to box/execute.h 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 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=5cb066a8cede9a29a43be1654a9b32ffe9f05706.1566907520.git.korablev@tarantool.org \ --to=korablev@tarantool.org \ --cc=alexander.turenko@tarantool.org \ --cc=kostja@tarantool.org \ --cc=tarantool-patches@freelists.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [tarantool-patches] [PATCH 5/8] sql: move sql_prepare() declaration to box/execute.h' \ /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