2
Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
4
This program is free software; you can redistribute it and/or
5
modify it under the terms of the GNU General Public License as
6
published by the Free Software Foundation; version 2 of the
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20
#ifndef __NETWORK_MYSQLD_LUA__
21
#define __NETWORK_MYSQLD_LUA__
25
#include "network-backend.h" /* query-status */
26
#include "network-injection.h" /* query-status */
28
#include "network-exports.h"
35
PROXY_IGNORE_RESULT /** for read_query_result */
36
} network_mysqld_lua_stmt_ret;
39
REGISTER_CALLBACK_SUCCESS,
40
REGISTER_CALLBACK_LOAD_FAILED,
41
REGISTER_CALLBACK_EXECUTE_FAILED
42
} network_mysqld_register_callback_ret;
44
NETWORK_API int network_mysqld_con_getmetatable(lua_State *L);
45
NETWORK_API void network_mysqld_lua_init_global_fenv(lua_State *L);
47
NETWORK_API void network_mysqld_lua_setup_global(lua_State *L, chassis_private *g);
50
* Encapsulates injected queries information passed back from the a Lua callback function.
52
* @todo Simplify this structure, it should be folded into network_mysqld_con_lua_t.
54
struct network_mysqld_con_lua_injection {
55
network_injection_queue *queries; /**< An ordered list of queries we want to have executed. */
56
int sent_resultset; /**< Flag to make sure we send only one result back to the client. */
59
* Contains extra connection state used for Lua-based plugins.
62
struct network_mysqld_con_lua_injection injected; /**< A list of queries to send to the backend.*/
64
lua_State *L; /**< The Lua interpreter state of the current connection. */
65
int L_ref; /**< The reference into the lua_scope's registry (a global structure in the Lua interpreter) */
67
network_backend_t *backend;
68
int backend_ndx; /**< [lua] index into the backend-array */
70
gboolean connection_close; /**< [lua] set by the lua code to close a connection */
72
struct timeval interval; /**< The interval to be used for evt_timer, currently unused. */
73
struct event evt_timer; /**< The event structure used to implement the timer callback, currently unused. */
75
gboolean is_reconnecting; /**< if true, critical messages concerning failed connect() calls are suppressed, as they are expected errors */
76
} network_mysqld_con_lua_t;
78
NETWORK_API network_mysqld_con_lua_t *network_mysqld_con_lua_new();
79
NETWORK_API void network_mysqld_con_lua_free(network_mysqld_con_lua_t *st);
81
/** be sure to include network-mysqld.h */
82
NETWORK_API network_mysqld_register_callback_ret network_mysqld_con_lua_register_callback(network_mysqld_con *con, const char *lua_script);
83
NETWORK_API int network_mysqld_con_lua_handle_proxy_response(network_mysqld_con *con, const char *lua_script);