diff options
Diffstat (limited to 'libmysqld')
-rw-r--r-- | libmysqld/CMakeLists.txt | 84 | ||||
-rw-r--r-- | libmysqld/lib_sql.cc | 15 | ||||
-rw-r--r-- | libmysqld/libmysql.c | 57 | ||||
-rw-r--r-- | libmysqld/libmysqld.c | 11 |
4 files changed, 54 insertions, 113 deletions
diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt index c133e5a4378..efdf7277e5b 100644 --- a/libmysqld/CMakeLists.txt +++ b/libmysqld/CMakeLists.txt @@ -43,7 +43,7 @@ SET(SQL_EMBEDDED_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc libmysql.c ../sql-common/errmsg.c ../sql-common/client.c ../sql-common/my_user.c ../sql-common/pack.c - ../sql-common/client_plugin.c ../sql-common/mysql_async.c + ../sql-common/client_plugin.c ../sql/password.c ../sql/discover.cc ../sql/derror.cc ../sql/field.cc ../sql/field_conv.cc ../sql/field_comp.cc ../sql/filesort_utils.cc ../sql/sql_digest.cc @@ -78,7 +78,8 @@ SET(SQL_EMBEDDED_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc ../sql/sql_binlog.cc ../sql/sql_manager.cc ../sql/sql_parse.cc ../sql/sql_bootstrap.cc ../sql/sql_partition.cc ../sql/sql_plugin.cc - ../sql/debug_sync.cc ../sql/opt_table_elimination.cc + ../sql/debug_sync.cc ../sql/debug.cc + ../sql/opt_table_elimination.cc ../sql/sql_prepare.cc ../sql/sql_rename.cc ../sql/sql_repl.cc ../sql/sql_select.cc ../sql/sql_servers.cc ../sql/group_by_handler.cc ../sql/derived_handler.cc @@ -86,6 +87,7 @@ SET(SQL_EMBEDDED_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc ../sql/sql_show.cc ../sql/sql_state.c ../sql/sql_statistics.cc ../sql/sql_string.cc ../sql/sql_tablespace.cc ../sql/sql_table.cc ../sql/sql_test.cc + ../sql/ddl_log.cc ../sql/sql_trigger.cc ../sql/sql_udf.cc ../sql/sql_union.cc ../sql/sql_update.cc ../sql/sql_view.cc ../sql/sql_profile.cc ../sql/gcalc_tools.cc ../sql/gcalc_slicescan.cc @@ -134,6 +136,7 @@ SET(SQL_EMBEDDED_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc ../sql/item_vers.cc ../sql/opt_trace.cc ../sql/xa.cc + ../sql/json_table.cc ${GEN_SOURCES} ${MYSYS_LIBWRAP_SOURCE} ) @@ -309,82 +312,7 @@ mysql_client_register_plugin mysql_load_plugin mysql_load_plugin_v mysql_plugin_options -# Async API -mysql_get_timeout_value -mysql_get_timeout_value_ms -mysql_get_socket -mysql_autocommit_cont -mysql_autocommit_start -mysql_change_user_cont -mysql_change_user_start -mysql_close_cont -mysql_close_start -mysql_commit_cont -mysql_commit_start -mysql_dump_debug_info_cont -mysql_dump_debug_info_start -mysql_fetch_row_cont -mysql_fetch_row_start -mysql_free_result_cont -mysql_free_result_start -mysql_kill_cont -mysql_kill_start -mysql_list_dbs_cont -mysql_list_dbs_start -mysql_list_fields_cont -mysql_list_fields_start -mysql_list_processes_cont -mysql_list_processes_start -mysql_list_tables_cont -mysql_list_tables_start -mysql_next_result_cont -mysql_next_result_start -mysql_ping_cont -mysql_ping_start -mysql_query_cont -mysql_query_start -mysql_read_query_result_cont -mysql_read_query_result_start -mysql_real_connect_cont -mysql_real_connect_start -mysql_real_query_cont -mysql_real_query_start -mysql_refresh_cont -mysql_refresh_start -mysql_rollback_cont -mysql_rollback_start -mysql_select_db_cont -mysql_select_db_start -mysql_send_query_cont -mysql_send_query_start -mysql_set_character_set_cont -mysql_set_character_set_start -mysql_set_server_option_cont -mysql_set_server_option_start -mysql_shutdown_cont -mysql_shutdown_start -mysql_stat_cont -mysql_stat_start -mysql_stmt_close_cont -mysql_stmt_close_start -mysql_stmt_execute_cont -mysql_stmt_execute_start -mysql_stmt_fetch_cont -mysql_stmt_fetch_start -mysql_stmt_free_result_cont -mysql_stmt_free_result_start -mysql_stmt_next_result_cont -mysql_stmt_next_result_start -mysql_stmt_prepare_cont -mysql_stmt_prepare_start -mysql_stmt_reset_cont -mysql_stmt_reset_start -mysql_stmt_send_long_data_cont -mysql_stmt_send_long_data_start -mysql_stmt_store_result_cont -mysql_stmt_store_result_start -mysql_store_result_cont -mysql_store_result_start + #dynamic columns api dynamic_column_create dynamic_column_create_many diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index c6493773db0..a8f554326cd 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -115,7 +115,7 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command, NET *net= &mysql->net; my_bool stmt_skip= stmt ? stmt->state != MYSQL_STMT_INIT_DONE : FALSE; - if (thd->killed != NOT_KILLED) + if (thd && thd->killed != NOT_KILLED) { if (thd->killed < KILL_CONNECTION) thd->killed= NOT_KILLED; @@ -168,8 +168,7 @@ emb_advanced_command(MYSQL *mysql, enum enum_server_command command, arg_length= header_length; } - result= dispatch_command(command, thd, (char *) arg, arg_length, FALSE, - FALSE); + result= dispatch_command(command, thd, (char *) arg, arg_length); thd->cur_data= 0; thd->mysys_var= NULL; @@ -579,7 +578,7 @@ int init_embedded_server(int argc, char **argv, char **groups) /* Get default temporary directory */ opt_mysql_tmpdir=getenv("TMPDIR"); /* Use this if possible */ -#if defined(__WIN__) +#if defined(_WIN32) if (!opt_mysql_tmpdir) opt_mysql_tmpdir=getenv("TEMP"); if (!opt_mysql_tmpdir) @@ -642,7 +641,11 @@ int init_embedded_server(int argc, char **argv, char **groups) } } - execute_ddl_log_recovery(); + if (ddl_log_execute_recovery() > 0) + { + mysql_server_end(); + return 1; + } mysql_embedded_init= 1; return 0; } @@ -1259,7 +1262,7 @@ bool Protocol_binary::write() bool Protocol::net_send_ok(THD *thd, uint server_status, uint statement_warn_count, ulonglong affected_rows, ulonglong id, const char *message, - bool, bool) + bool) { DBUG_ENTER("emb_net_send_ok"); MYSQL_DATA *data; diff --git a/libmysqld/libmysql.c b/libmysqld/libmysql.c index 9a0858fd067..6c7e0b3b812 100644 --- a/libmysqld/libmysql.c +++ b/libmysqld/libmysql.c @@ -35,7 +35,7 @@ #ifdef HAVE_PWD_H #include <pwd.h> #endif -#if !defined(__WIN__) +#if !defined(_WIN32) #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> @@ -46,7 +46,7 @@ #ifdef HAVE_SYS_SELECT_H #include <sys/select.h> #endif -#endif /* !defined(__WIN__) */ +#endif /* !defined(_WIN32) */ #if defined(HAVE_POLL_H) #include <poll.h> #elif defined(HAVE_SYS_POLL_H) @@ -55,7 +55,7 @@ #ifdef HAVE_SYS_UN_H #include <sys/un.h> #endif -#if !defined(__WIN__) +#if !defined(_WIN32) #include <my_pthread.h> /* because of signal() */ #endif #ifndef INADDR_NONE @@ -78,13 +78,13 @@ ulong max_allowed_packet= 1024L*1024L*1024L; my_bool net_flush(NET *net); #endif -#if defined(__WIN__) +#if defined(_WIN32) /* socket_errno is defined in my_global.h for all platforms */ #define perror(A) #else #include <errno.h> #define SOCKET_ERROR -1 -#endif /* __WIN__ */ +#endif /* _WIN32 */ /* If allowed through some configuration, then this needs to @@ -167,7 +167,7 @@ int STDCALL mysql_server_init(int argc __attribute__((unused)), if (!mysql_unix_port) { char *env; -#ifdef __WIN__ +#ifdef _WIN32 mysql_unix_port = (char*) MYSQL_NAMEDPIPE; #else mysql_unix_port = (char*) MYSQL_UNIX_ADDR; @@ -176,7 +176,7 @@ int STDCALL mysql_server_init(int argc __attribute__((unused)), mysql_unix_port = env; } mysql_debug(NullS); -#if defined(SIGPIPE) && !defined(__WIN__) +#if defined(SIGPIPE) && !defined(_WIN32) (void) signal(SIGPIPE, SIG_IGN); #endif #ifdef EMBEDDED_LIBRARY @@ -421,7 +421,7 @@ struct passwd *getpwuid(uid_t); char* getlogin(void); #endif -#if !defined(__WIN__) +#if !defined(_WIN32) void read_user_name(char *name) { @@ -512,7 +512,7 @@ my_bool handle_local_infile(MYSQL *mysql, const char *net_filename) if (my_net_write(net, (uchar*) buf, readcount)) { DBUG_PRINT("error", - ("Lost connection to MySQL server during LOAD DATA of local file")); + ("Lost connection to server during LOAD DATA of local file")); set_mysql_error(mysql, CR_SERVER_LOST, unknown_sqlstate); goto err; } @@ -1114,15 +1114,15 @@ ulong STDCALL mysql_thread_id(MYSQL *mysql) const char * STDCALL mysql_character_set_name(MYSQL *mysql) { - return mysql->charset->csname; + return mysql->charset->cs_name.str; } void STDCALL mysql_get_character_set_info(MYSQL *mysql, MY_CHARSET_INFO *csinfo) { csinfo->number = mysql->charset->number; csinfo->state = mysql->charset->state; - csinfo->csname = mysql->charset->csname; - csinfo->name = mysql->charset->name; + csinfo->csname = mysql->charset->cs_name.str; + csinfo->name = mysql->charset->coll_name.str; csinfo->comment = mysql->charset->comment; csinfo->mbminlen = mysql->charset->mbminlen; csinfo->mbmaxlen = mysql->charset->mbmaxlen; @@ -1210,16 +1210,21 @@ mysql_hex_string(char *to, const char *from, ulong length) ulong STDCALL mysql_escape_string(char *to,const char *from,ulong length) { - return (uint) escape_string_for_mysql(default_charset_info, to, 0, from, length); + my_bool overflow; + return (uint) escape_string_for_mysql(default_charset_info, to, 0, from, + length, &overflow); } ulong STDCALL mysql_real_escape_string(MYSQL *mysql, char *to,const char *from, ulong length) { + my_bool overflow; if (mysql->server_status & SERVER_STATUS_NO_BACKSLASH_ESCAPES) - return (uint) escape_quotes_for_mysql(mysql->charset, to, 0, from, length); - return (uint) escape_string_for_mysql(mysql->charset, to, 0, from, length); + return (ulong) escape_quotes_for_mysql(mysql->charset, to, 0, from, length, + &overflow); + return (ulong) escape_string_for_mysql(mysql->charset, to, 0, from, length, + &overflow); } void STDCALL @@ -2127,7 +2132,7 @@ static my_bool execute(MYSQL_STMT *stmt, char *packet, ulong length) buff[4]= (char) stmt->flags; int4store(buff+5, 1); /* iteration count */ - res= MY_TEST(cli_advanced_command(mysql, COM_STMT_EXECUTE, buff, sizeof(buff), + res= MY_TEST((*mysql->methods->advanced_command)(mysql, COM_STMT_EXECUTE, buff, sizeof(buff), (uchar*) packet, length, 1, stmt) || (*mysql->methods->read_query_result)(mysql)); stmt->affected_rows= mysql->affected_rows; @@ -2519,9 +2524,16 @@ static void reinit_result_set_metadata(MYSQL_STMT *stmt) } +static int has_cursor(MYSQL_STMT *stmt) +{ + return stmt->server_status & SERVER_STATUS_CURSOR_EXISTS && + stmt->flags & CURSOR_TYPE_READ_ONLY; +} + + static void prepare_to_fetch_result(MYSQL_STMT *stmt) { - if (stmt->server_status & SERVER_STATUS_CURSOR_EXISTS) + if (has_cursor(stmt)) { stmt->mysql->status= MYSQL_STATUS_READY; stmt->read_row_func= stmt_read_row_from_cursor; @@ -4467,8 +4479,7 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt) DBUG_RETURN(1); } - if (mysql->status == MYSQL_STATUS_READY && - stmt->server_status & SERVER_STATUS_CURSOR_EXISTS) + if (mysql->status == MYSQL_STATUS_READY && has_cursor(stmt)) { /* Server side cursor exist, tell server to start sending the rows @@ -4480,7 +4491,7 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt) /* Send row request to the server */ int4store(buff, stmt->stmt_id); int4store(buff + 4, (int)~0); /* number of rows to fetch */ - if (cli_advanced_command(mysql, COM_STMT_FETCH, buff, sizeof(buff), + if ((*mysql->methods->advanced_command)(mysql, COM_STMT_FETCH, buff, sizeof(buff), (uchar*) 0, 0, 1, stmt)) { /* @@ -4927,6 +4938,12 @@ int STDCALL mysql_stmt_next_result(MYSQL_STMT *stmt) alloc_stmt_fields(stmt); prepare_to_fetch_result(stmt); } + else + { + stmt->affected_rows= stmt->mysql->affected_rows; + stmt->server_status= stmt->mysql->server_status; + stmt->insert_id= stmt->mysql->insert_id; + } DBUG_RETURN(0); } diff --git a/libmysqld/libmysqld.c b/libmysqld/libmysqld.c index d29126467e2..774b687f0e2 100644 --- a/libmysqld/libmysqld.c +++ b/libmysqld/libmysqld.c @@ -32,7 +32,7 @@ #ifdef HAVE_PWD_H #include <pwd.h> #endif -#if !defined(__WIN__) +#if !defined(_WIN32) #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> @@ -54,7 +54,7 @@ extern ulong net_buffer_length; extern ulong max_allowed_packet; -#if defined(__WIN__) +#if defined(_WIN32) #define ERRNO WSAGetLastError() #define perror(A) #else @@ -69,13 +69,6 @@ struct passwd *getpwuid(uid_t); char* getlogin(void); #endif -#ifdef __WIN__ -static my_bool is_NT(void) -{ - char *os=getenv("OS"); - return (os && !strcmp(os, "Windows_NT")) ? 1 : 0; -} -#endif int mysql_init_character_set(MYSQL *mysql); |