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 174602925D for ; Tue, 27 Aug 2019 09:34:35 -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 qtUuCcYcIazf for ; Tue, 27 Aug 2019 09:34:35 -0400 (EDT) Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (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 C200C289CE for ; Tue, 27 Aug 2019 09:34:34 -0400 (EDT) From: Nikita Pettik Subject: [tarantool-patches] [PATCH 2/8] port: move struct port_sql to box/port.h Date: Tue, 27 Aug 2019 16:34:23 +0300 Message-Id: <31f265719574074dbabca4ced925ed1008bb49eb.1566907520.git.korablev@tarantool.org> In-Reply-To: References: In-Reply-To: References: 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: tarantool-patches@freelists.org Cc: v.shpilevoy@tarantool.org, kostja@tarantool.org, alexander.turenko@tarantool.org, Nikita Pettik We are going to use port_sql_create() in box/lua/execute.c so to be able to call it let's make port_sql_create() non-static and move its declaration to box/port.h alongside with struct port_sql (since box/port.h already contains struct port_tuple and struct port_lua). No functional changes are provided. Needed for #3292 --- src/box/execute.c | 2 +- src/box/execute.h | 20 -------------------- src/box/port.h | 24 ++++++++++++++++++++++++ src/lib/core/port.h | 1 + 4 files changed, 26 insertions(+), 21 deletions(-) diff --git a/src/box/execute.c b/src/box/execute.c index 68e94e442..a6454d5bb 100644 --- a/src/box/execute.c +++ b/src/box/execute.c @@ -112,7 +112,7 @@ const struct port_vtab port_sql_vtab = { /* .destroy = */ port_sql_destroy, }; -static void +void port_sql_create(struct port *port, struct sql_stmt *stmt) { port_tuple_create(port); diff --git a/src/box/execute.h b/src/box/execute.h index a2fd4d1b7..1995c43d5 100644 --- a/src/box/execute.h +++ b/src/box/execute.h @@ -69,26 +69,6 @@ sql_prepare_and_execute(const char *sql, int len, const struct sql_bind *bind, uint32_t bind_count, struct port *port, struct region *region); -/** - * Port implementation that is used to store SQL responses and - * output them to obuf or Lua. This port implementation is - * inherited from the port_tuple structure. This allows us to use - * this structure in the port_tuple methods instead of port_tuple - * itself. - * - * The methods of port_tuple are called via explicit access to - * port_tuple_vtab just like C++ does with BaseClass::method, when - * it is called in a child method. - */ -struct port_sql { - /* port_tuple to inherit from. */ - struct port_tuple port_tuple; - /* Prepared SQL statement. */ - struct sql_stmt *stmt; -}; - -extern const struct port_vtab port_sql_vtab; - #if defined(__cplusplus) } /* extern "C" { */ #endif diff --git a/src/box/port.h b/src/box/port.h index a7f5d81bd..0d2cc7e84 100644 --- a/src/box/port.h +++ b/src/box/port.h @@ -119,6 +119,30 @@ port_init(void); void port_free(void); +/** + * Port implementation that is used to store SQL responses and + * output them to obuf or Lua. This port implementation is + * inherited from the port_tuple structure. This allows us to use + * this structure in the port_tuple methods instead of port_tuple + * itself. + * + * The methods of port_tuple are called via explicit access to + * port_tuple_vtab just like C++ does with BaseClass::method, when + * it is called in a child method. + */ +struct port_sql { + /* port_tuple to inherit from. */ + struct port_tuple port_tuple; + /* Prepared SQL statement. */ + struct sql_stmt *stmt; +}; + +extern const struct port_vtab port_sql_vtab; + +/** Create instance of SQL port using given attributes. */ +void +port_sql_create(struct port *port, struct sql_stmt *stmt); + #if defined(__cplusplus) } /* extern "C" */ #endif /* defined __cplusplus */ diff --git a/src/lib/core/port.h b/src/lib/core/port.h index abe21aa53..2b1ccaae3 100644 --- a/src/lib/core/port.h +++ b/src/lib/core/port.h @@ -39,6 +39,7 @@ extern "C" { struct obuf; struct lua_State; +struct sql_stmt; struct port; /** -- 2.15.1