summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/Makefile.am2
-rw-r--r--include/my_context.h23
-rw-r--r--include/my_dbug.h4
-rw-r--r--include/mysql.h45
-rw-r--r--include/mysql.h.pp13
-rw-r--r--include/mysql_async.h36
-rw-r--r--include/mysql_com.h9
-rw-r--r--include/sql_common.h3
8 files changed, 86 insertions, 49 deletions
diff --git a/include/Makefile.am b/include/Makefile.am
index e13e7755670..b6013a6b515 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -46,7 +46,7 @@ noinst_HEADERS = config-win.h config-netware.h lf.h my_bit.h \
atomic/rwlock.h atomic/x86-gcc.h \
atomic/generic-msvc.h \
atomic/gcc_builtins.h my_libwrap.h my_stacktrace.h \
- wqueue.h waiting_threads.h my_context.h
+ wqueue.h waiting_threads.h my_context.h mysql_async.h
EXTRA_DIST = mysql.h.pp mysql/plugin_auth.h.pp mysql/client_plugin.h.pp CMakeLists.txt
diff --git a/include/my_context.h b/include/my_context.h
index e19ee89a8be..14974412075 100644
--- a/include/my_context.h
+++ b/include/my_context.h
@@ -1,17 +1,15 @@
/*
- Copyright 2011 Kristian Nielsen
+ Copyright 2011 Kristian Nielsen and Monty Program Ab
- Experiments with non-blocking libmysql.
+ This file is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
- This is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 2 of the License, or
- (at your option) any later version.
-
- This is distributed in the hope that it will be useful,
+ This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
You should have received a copy of the GNU General Public License
along with this. If not, see <http://www.gnu.org/licenses/>.
@@ -164,11 +162,14 @@ struct mysql_async_context {
/*
This is set to the value that should be returned from foo_start() or
foo_cont() when a call is suspended.
+ */
+ unsigned int events_to_wait_for;
+ /*
It is also set to the event(s) that triggered when a suspended call is
resumed, eg. whether we woke up due to connection completed or timeout
in mysql_real_connect_cont().
*/
- unsigned int ret_status;
+ unsigned int events_occured;
/*
This is set to the result of the whole asynchronous operation when it
completes. It uses a union, as different calls have different return
diff --git a/include/my_dbug.h b/include/my_dbug.h
index a58c6588d61..21996614153 100644
--- a/include/my_dbug.h
+++ b/include/my_dbug.h
@@ -134,6 +134,8 @@ extern void dbug_free_code_state(void **code_state_store);
#define DEBUGGER_OFF do { _dbug_on_= 0; } while(0)
#define DEBUGGER_ON do { _dbug_on_= 1; } while(0)
#define IF_DBUG(A) A
+#define DBUG_SWAP_CODE_STATE(arg) dbug_swap_code_state(arg)
+#define DBUG_FREE_CODE_STATE(arg) dbug_free_code_state(arg)
#ifndef __WIN__
#define DBUG_ABORT() (_db_flush_(), abort())
#else
@@ -193,6 +195,8 @@ extern void _db_suicide_();
#define DEBUGGER_OFF do { } while(0)
#define DEBUGGER_ON do { } while(0)
#define IF_DBUG(A)
+#define DBUG_SWAP_CODE_STATE(arg) do { } while(0)
+#define DBUG_FREE_CODE_STATE(arg) do { } while(0)
#define DBUG_ABORT() do { } while(0)
#define DBUG_SUICIDE() do { } while(0)
diff --git a/include/mysql.h b/include/mysql.h
index b1ef4720879..80a0067c914 100644
--- a/include/mysql.h
+++ b/include/mysql.h
@@ -169,7 +169,9 @@ enum mysql_option
MYSQL_OPT_USE_REMOTE_CONNECTION, MYSQL_OPT_USE_EMBEDDED_CONNECTION,
MYSQL_OPT_GUESS_CONNECTION, MYSQL_SET_CLIENT_IP, MYSQL_SECURE_AUTH,
MYSQL_REPORT_DATA_TRUNCATION, MYSQL_OPT_RECONNECT,
- MYSQL_OPT_SSL_VERIFY_SERVER_CERT, MYSQL_PLUGIN_DIR, MYSQL_DEFAULT_AUTH
+ MYSQL_OPT_SSL_VERIFY_SERVER_CERT, MYSQL_PLUGIN_DIR, MYSQL_DEFAULT_AUTH,
+ /* MariaDB options */
+ MYSQL_OPT_NONBLOCK=6000
};
/**
@@ -264,8 +266,6 @@ typedef struct character_set
struct st_mysql_methods;
struct st_mysql_stmt;
-struct st_mysql_extension;
-
typedef struct st_mysql
{
NET net; /* Communication parameters */
@@ -320,7 +320,7 @@ typedef struct st_mysql
my_bool *unbuffered_fetch_owner;
/* needed for embedded server - no net buffer to store the 'info' */
char *info_buffer;
- struct st_mysql_extension *extension;
+ void *extension;
} MYSQL;
@@ -382,14 +382,21 @@ typedef struct st_mysql_parameters
Flag bits, the asynchronous methods return a combination of these ORed
together to let the application know when to resume the suspended operation.
*/
-typedef enum {
- MYSQL_WAIT_READ= 1, /* Wait for data to be available on socket to read */
- /* mysql_get_socket_fd() will return socket descriptor*/
- MYSQL_WAIT_WRITE= 2, /* Wait for socket to be ready to write data */
- MYSQL_WAIT_EXCEPT= 4, /* Wait for select() to mark exception on socket */
- MYSQL_WAIT_TIMEOUT= 8 /* Wait until timeout occurs. Value of timeout can be */
- /* obtained from mysql_get_timeout_value() */
-} MYSQL_ASYNC_STATUS;
+
+/*
+ Wait for data to be available on socket to read.
+ mysql_get_socket_fd() will return socket descriptor.
+*/
+#define MYSQL_WAIT_READ 1
+/* Wait for socket to be ready to write data. */
+#define MYSQL_WAIT_WRITE 2
+/* Wait for select() to mark exception on socket. */
+#define MYSQL_WAIT_EXCEPT 4
+/*
+ Wait until timeout occurs. Value of timeout can be obtained from
+ mysql_get_timeout_value().
+*/
+#define MYSQL_WAIT_TIMEOUT 8
#if !defined(MYSQL_SERVER) && !defined(EMBEDDED_LIBRARY)
#define max_allowed_packet (*mysql_get_parameters()->p_max_allowed_packet)
@@ -943,6 +950,7 @@ my_bool STDCALL mysql_more_results(MYSQL *mysql);
int STDCALL mysql_next_result(MYSQL *mysql);
int STDCALL mysql_next_result_start(int *ret, MYSQL *mysql);
int STDCALL mysql_next_result_cont(int *ret, MYSQL *mysql, int status);
+void STDCALL mysql_close_slow_part(MYSQL *mysql);
void STDCALL mysql_close(MYSQL *sock);
int STDCALL mysql_close_start(MYSQL *sock);
int STDCALL mysql_close_cont(MYSQL *sock, int status);
@@ -958,20 +966,7 @@ unsigned int STDCALL mysql_get_timeout_value(const MYSQL *mysql);
#ifdef USE_OLD_FUNCTIONS
MYSQL * STDCALL mysql_connect(MYSQL *mysql, const char *host,
const char *user, const char *passwd);
-int STDCALL mysql_connect_start(MYSQL **ret, MYSQL *mysql,
- const char *host, const char *user,
- const char *passwd);
-int STDCALL mysql_connect_cont(MYSQL **ret, MYSQL *mysql,
- int status);
int STDCALL mysql_create_db(MYSQL *mysql, const char *DB);
-int STDCALL mysql_create_db_start(int *ret, MYSQL *mysql,
- const char *DB);
-int STDCALL mysql_create_db_cont(int *ret, MYSQL *mysql,
- int status);
-int STDCALL mysql_drop_db(MYSQL *mysql, const char *DB);
-int STDCALL mysql_drop_db_start(int *ret, MYSQL *mysql,
- const char *DB);
-int STDCALL mysql_drop_db_cont(int *ret, MYSQL *mysql, int status);
int STDCALL mysql_drop_db(MYSQL *mysql, const char *DB);
#define mysql_reload(mysql) mysql_refresh((mysql),REFRESH_GRANT)
#endif
diff --git a/include/mysql.h.pp b/include/mysql.h.pp
index f66d92c06a1..ce5790b9346 100644
--- a/include/mysql.h.pp
+++ b/include/mysql.h.pp
@@ -257,7 +257,8 @@ enum mysql_option
MYSQL_OPT_USE_REMOTE_CONNECTION, MYSQL_OPT_USE_EMBEDDED_CONNECTION,
MYSQL_OPT_GUESS_CONNECTION, MYSQL_SET_CLIENT_IP, MYSQL_SECURE_AUTH,
MYSQL_REPORT_DATA_TRUNCATION, MYSQL_OPT_RECONNECT,
- MYSQL_OPT_SSL_VERIFY_SERVER_CERT, MYSQL_PLUGIN_DIR, MYSQL_DEFAULT_AUTH
+ MYSQL_OPT_SSL_VERIFY_SERVER_CERT, MYSQL_PLUGIN_DIR, MYSQL_DEFAULT_AUTH,
+ MYSQL_OPT_NONBLOCK=6000
};
struct st_mysql_options_extention;
struct st_mysql_options {
@@ -318,7 +319,6 @@ typedef struct character_set
} MY_CHARSET_INFO;
struct st_mysql_methods;
struct st_mysql_stmt;
-struct st_mysql_extension;
typedef struct st_mysql
{
NET net;
@@ -354,7 +354,7 @@ typedef struct st_mysql
void *thd;
my_bool *unbuffered_fetch_owner;
char *info_buffer;
- struct st_mysql_extension *extension;
+ void *extension;
} MYSQL;
typedef struct st_mysql_res {
my_ulonglong row_count;
@@ -392,12 +392,6 @@ typedef struct st_mysql_parameters
unsigned long *p_net_buffer_length;
void *extension;
} MYSQL_PARAMETERS;
-typedef enum {
- MYSQL_WAIT_READ= 1,
- MYSQL_WAIT_WRITE= 2,
- MYSQL_WAIT_EXCEPT= 4,
- MYSQL_WAIT_TIMEOUT= 8
-} MYSQL_ASYNC_STATUS;
int mysql_server_init(int argc, char **argv, char **groups);
void mysql_server_end(void);
MYSQL_PARAMETERS * mysql_get_parameters(void);
@@ -776,6 +770,7 @@ my_bool mysql_more_results(MYSQL *mysql);
int mysql_next_result(MYSQL *mysql);
int mysql_next_result_start(int *ret, MYSQL *mysql);
int mysql_next_result_cont(int *ret, MYSQL *mysql, int status);
+void mysql_close_slow_part(MYSQL *mysql);
void mysql_close(MYSQL *sock);
int mysql_close_start(MYSQL *sock);
int mysql_close_cont(MYSQL *sock, int status);
diff --git a/include/mysql_async.h b/include/mysql_async.h
new file mode 100644
index 00000000000..a8a79b541e9
--- /dev/null
+++ b/include/mysql_async.h
@@ -0,0 +1,36 @@
+/* Copyright (C) 2012 MariaDB Services and Kristian Nielsen
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; version 2 of the License.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+/* Common definitions for MariaDB non-blocking client library. */
+
+#ifndef MYSQL_ASYNC_H
+#define MYSQL_ASYNC_H
+
+extern int my_connect_async(struct mysql_async_context *b, my_socket fd,
+ const struct sockaddr *name, uint namelen,
+ uint timeout);
+extern ssize_t my_recv_async(struct mysql_async_context *b, int fd,
+ unsigned char *buf, size_t size, uint timeout);
+extern ssize_t my_send_async(struct mysql_async_context *b, int fd,
+ const unsigned char *buf, size_t size,
+ uint timeout);
+extern my_bool my_poll_read_async(struct mysql_async_context *b,
+ uint timeout);
+extern int my_ssl_read_async(struct mysql_async_context *b, SSL *ssl,
+ void *buf, int size);
+extern int my_ssl_write_async(struct mysql_async_context *b, SSL *ssl,
+ const void *buf, int size);
+
+#endif /* MYSQL_ASYNC_H */
diff --git a/include/mysql_com.h b/include/mysql_com.h
index affd24a4636..da19b445372 100644
--- a/include/mysql_com.h
+++ b/include/mysql_com.h
@@ -159,6 +159,15 @@ enum enum_server_command
#define CLIENT_PLUGIN_AUTH (1UL << 19) /* Client supports plugin authentication */
#define CLIENT_SSL_VERIFY_SERVER_CERT (1UL << 30)
+/*
+ It used to be that if mysql_real_connect() failed, it would delete any
+ options set by the client, unless the CLIENT_REMEMBER_OPTIONS flag was
+ given.
+ That behaviour does not appear very useful, and it seems unlikely that
+ any applications would actually depend on this. So from MariaDB 5.5 we
+ always preserve any options set in case of failed connect, and this
+ option is effectively always set.
+*/
#define CLIENT_REMEMBER_OPTIONS (1UL << 31)
#ifdef HAVE_COMPRESS
diff --git a/include/sql_common.h b/include/sql_common.h
index 8bb33e3779c..2ee4b63adc8 100644
--- a/include/sql_common.h
+++ b/include/sql_common.h
@@ -32,9 +32,6 @@ struct mysql_async_context;
struct st_mysql_options_extention {
char *plugin_dir;
char *default_auth;
-};
-
-struct st_mysql_extension {
struct mysql_async_context *async_context;
};