From fb84f573adf00de5e606a3b312bec99d24a0f49c Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 11 Oct 2007 18:07:40 +0300 Subject: Moved a lot of old bug fixes and safe cleanups from Maria 5.1 tree to 5.1 - Reserver namespace and place in frm for TABLE_CHECKSUM and PAGE_CHECKSUM create options - Added syncing of directory when creating .frm files - Portability fixes - Added missing cast that could cause bugs - Code cleanups - Made some bit functions inline - Moved things out of myisam.h to my_handler.h to make them more accessable - Renamed some myisam variables and defines to make them more globaly usable (as they are used outside of MyISAM) - Fixed bugs in error conditions - Use compiler time asserts instead of run time - Fixed indentation HA_EXTRA_PREPARE_FOR_DELETE -> HA_EXTRA_PREPARE_FOR_DROP as the old name was wrong (Added a define for old value to ensure we don't break any old code) Added HA_EXTRA_PREPARE_FOR_RENAME as a signal for rename (before we used a DROP signal which is wrong) - Initialize error messages early to get better errors when mysqld or an engine fails to start - Fix windows bug that query_performance_frequency was not initialized if registry code failed - thread_stack -> my_thread_stack_size BitKeeper/etc/ignore: added libmysqld/scheduler.cc libmysqld/sql_connect.cc libmysqld/sql_tablespace.cc include/Makefile.am: Added my_bit.h include/m_string.h: Added bzero_if_purify() to simplify code include/my_base.h: Reserve options for the future Added HA_OPTION_NULL_FIELDS, HA_OPTION_PAGE_CHECKSUM, HA_CREATE_PAGE_CHECKSUM Added new error message HA_ERR_NEW_FILE Added optional new row type BLOCK_RECORD Renamed HA_EXTRA_PREPARE_FOR_DELETE to HA_EXTRA_PREPARE_FOR_DROP Added HA_EXTRA_PREARE_FOR_RENAME to inform handler we will do a rename (Added define to make things compatible until 6.0) Moved invalidator_by_filename form myisam.h include/my_dbug.h: Poirtablity fix include/my_global.h: Added helper macros STATIC_INLINE and MY_ERRPTR Added NEED_EXPLICIT_SYNC_DIR include/my_handler.h: Added missing casts Moved some constants and macros out from myisam.h to make these generally available Renamed mi_compare_text() to ha_compare_text() as this function is not myisam specific Renamed mi_portable_sizeof_char_ptr to portable_sizeof_char_ptr Added registering of handler messages for better error reporting during startup include/my_sys.h: Added my_sync_dir() and my_sync_dir_by_file() More comments Some indentation fixes Moved bit functions to my_bit.h Added prototype for crc32() include/myisam.h: Moved things from here to my_handler.h to make them more accessable libmysql/Makefile.shared: Added my_sync mysys/array.c: Fixed indentation and spelling errors Split set_dynamic() to two functions Added allocate_dynamic() as a new visiable function (no new code, only refactoring) mysys/mf_iocache.c: More DBUG mysys/mf_keycache.c: More explicite ASSERT Removed some casts Fixed indentation mysys/mf_tempfile.c: Fixed bug with possible dangling file descriptor mysys/my_atomic.c: Use compile time asserts instead of run time mysys/my_bit.c: Make most bit functions inline mysys/my_bitmap.c: Added my_bit.h mysys/my_compress.c: Fixed indentation mysys/my_create.c: Added my_sync_by_dir() mysys/my_delete.c: Added my_sync_by_dir() mysys/my_error.c: init_glob_errs() is now done in my_init() mysys/my_handler.c: mi_compare_text() -> ha_compare_text() as this is not MyISAM specific Added functions to initialize handler error messages Fixed indentation More clear usage of include files mysys/my_init.c: Added my_thread_stack_size to be used by other programs Ensure that global error messages are always initialized Fix windows bug that query_performance_frequency was not initialized if registry code failed mysys/my_open.c: More comments Removed duplicate code mysys/my_pread.c: Ensure that my_errno is set even if errno is 0 mysys/my_realloc.c: Added comment mysys/my_rename.c: Added syncing of directories mysys/my_symlink.c: Added my_sync_by_dir() mysys/my_sync.c: Added my_sync_dir() On recent Mac OS X, fcntl(F_FULLFSYNC) is recommended over fsync() (see "man fsync" on Mac OS X 10.3). my_sync_dir(): to sync a directory after a file creation/deletion/ renaming; can be called directly or via MY_SYNC_DIR in my_create/ my_delete/my_rename(). No-op except on Linux (see "man fsync" on Linux). my_sync_dir_from_file(): same as above, just more practical when the caller has a file name but no directory name ready. Should the #warning even be a #error? I mean do we want to release binaries which don't guarantee any durability? mysys/safemalloc.c: Added sf_malloc_report_allocated() (Debugging aid) sql/gen_lex_hash.cc: Remove inline for big function sql/ha_partition.cc: HA_EXTRA_PREPARE_FOR_DELETE -> HA_EXTRA_PREPARE_FOR_DROP prepare_for_delete -> prepare_for_rename() as this is the the time this function is called sql/ha_partition.h: prepare_for_delete -> prepare_for_rename() as this is the the time this function is called sql/handler.cc: ha_init_errors() is now called at startup before plugins This allows us to get better error messages sql/handler.h: Reserve enum value for Maria Add future proof enum for page checksums sql/item_func.cc: Include my_bit.h sql/lex.h: Added future proof CREATE table options sql/log.cc: Added comment sql/mysql_priv.h: thread_stack moved to mysys sql/mysqld.cc: thread_stack moved to mysys thread_stack -> my_thread_stack_size Initialize myisam key caches before plugins starts Initialize error to allow storage engine to give better error messages if init failes. Fixed indentation Group all MyISAM options together Added new status variable 'Opened_table_definitions' to allow one to monitor if table definition cache is too small Clarified some option help messages sql/opt_range.cc: Removed wrong usage of SAFE_MODE (this disabled key usage for UPDATES, which was never the intention) Removed print if total cost in a place where it didn't have any usable value sql/set_var.cc: thread_stack -> my_thread_stack sql/sql_class.cc: Intialize transaction object properly sql/sql_parse.cc: thread_stack -> my_thread_stack sql/sql_select.cc: Include my_bit.h mi_portable_sizeof_char_ptr -> portable_sizeof_char_ptr sql/sql_show.cc: Simplify handling of ha_choice variables Added future safe PAGE_CHECKSUM option Addid missing 'transactional=#' in information schema sql/sql_table.cc: HA_EXTRA_PREPARE_FOR_DELETE -> HA_EXTRA_FORCE_REOPEN when doing reopen HA_EXTRA_PREPARE_FOR_DELETE -> HA_EXTRA_PREPARE_FOR_RENAME when doing rename Removed not needed initialization sql/sql_test.cc: thread_stack -> my_thread_stack sql/sql_yacc.yy: Simplify handling of ha_choice variables Added future proof create table options TABLE_CHECKSUM=# & PAGE_CHECKSUM=# sql/table.cc: Save page_checksum in .frm sql/table.h: Added variable to hold create table option PAGE_CHECKSUM sql/unireg.cc: Added syncing of directories storage/myisam/ft_boolean_search.c: mi_compare_text() -> ha_compare_text() storage/myisam/ft_eval.c: mi_compare_text() -> ha_compare_text() storage/myisam/ft_nlq_search.c: mi_compare_text() -> ha_compare_text() storage/myisam/ft_parser.c: mi_compare_text() -> ha_compare_text() storage/myisam/ft_stopwords.c: mi_compare_text() -> ha_compare_text() storage/myisam/ft_test1.c: mi_portable_sizeof_char_ptr -> portable_sizeof_char_ptr storage/myisam/ft_update.c: mi_compare_text() -> ha_compare_text() storage/myisam/ha_myisam.cc: Include my_bit.h storage/myisam/mi_check.c: MI_MAX_POSSIBLE_KEY_BUFF -> HA_MAX_POSSIBLE_KEY_BUFF mi_compare_text() -> ha_compare_text() Added BLOCK_RECORD to avoid compiler warnings storage/myisam/mi_checksum.c: mi_portable_sizeof_char_ptr -> portable_sizeof_char_ptr storage/myisam/mi_create.c: MI_MAX_POSSIBLE_KEY -> HA_MAX_POSSIBLE_KEY MI_MAX_KEY_BLOCK_SIZE -> HA_MAX_KEY_BLOCK_SIZE mi_portable_sizeof_char_ptr -> portable_sizeof_char_ptr storage/myisam/mi_dynrec.c: mi_portable_sizeof_char_ptr -> portable_sizeof_char_ptr storage/myisam/mi_extra.c: HA_EXTRA_PREPARE_FOR_DELETE -> HA_EXTRA_PREPARE_FOR_DROP storage/myisam/mi_open.c: MI_MAX_POSSIBLE_KEY -> HA_MAX_POSSIBLE_KEY mi_portable_sizeof_char_ptr -> portable_sizeof_char_ptr storage/myisam/mi_packrec.c: mi_portable_sizeof_char_ptr -> portable_sizeof_char_ptr storage/myisam/mi_range.c: mi_compare_text -> ha_compare_text storage/myisam/mi_test1.c: mi_portable_sizeof_char_ptr -> portable_sizeof_char_ptr storage/myisam/mi_test2.c: mi_portable_sizeof_char_ptr -> portable_sizeof_char_ptr storage/myisam/mi_unique.c: mi_compare_text() -> ha_compare_text() storage/myisam/mi_write.c: mi_compare_text() -> ha_compare_text() storage/myisam/myisamchk.c: Include my_bit.h storage/myisam/myisamdef.h: Moved store_key_length_inc to handler.h storage/myisam/myisampack.c: mi_portable_sizeof_char_ptr -> portable_sizeof_char_ptr storage/myisam/sp_test.c: mi_portable_sizeof_char_ptr -> portable_sizeof_char_ptr storage/myisammrg/ha_myisammrg.cc: HA_EXTRA_PREPARE_FOR_DELETE -> HA_EXTRA_PREPARE_FOR_DROP include/my_bit.h: New BitKeeper file ``include/my_bit.h'' --- libmysql/Makefile.shared | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libmysql') diff --git a/libmysql/Makefile.shared b/libmysql/Makefile.shared index 3a2559921f9..a4efd5b184f 100644 --- a/libmysql/Makefile.shared +++ b/libmysql/Makefile.shared @@ -68,7 +68,7 @@ mysysobjects1 = my_init.lo my_static.lo my_malloc.lo my_realloc.lo \ mf_iocache2.lo my_seek.lo my_sleep.lo \ my_pread.lo mf_cache.lo md5.lo sha1.lo \ my_getopt.lo my_gethostbyname.lo my_port.lo \ - my_rename.lo my_chsize.lo my_getsystime.lo + my_rename.lo my_chsize.lo my_sync.lo my_getsystime.lo sqlobjects = net.lo sql_cmn_objects = pack.lo client.lo my_time.lo -- cgit v1.2.1 From 7ee391c4da479cd7fcae64c595afbeca1e8b2d9d Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 16 Oct 2007 17:59:16 +0300 Subject: Fixes to merge between 5.1-main and 5.1-marvel include/my_atomic.h: To avoid compiler problems on some platforms, static inline should be a macro here. include/my_bit.h: To avoid compiler problems on windows and solaris libmysql/CMakeLists.txt: Added missing library on Windows. --- libmysql/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libmysql') diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt index 8471bbbd76c..6094390b2e7 100755 --- a/libmysql/CMakeLists.txt +++ b/libmysql/CMakeLists.txt @@ -98,7 +98,7 @@ SET(CLIENT_SOURCES ../mysys/array.c ../strings/bchange.c ../strings/bmove.c ../strings/strtoll.c ../strings/strtoull.c ../strings/strxmov.c ../strings/strxnmov.c ../mysys/thr_mutex.c ../mysys/typelib.c ../vio/vio.c ../vio/viosocket.c ../vio/viossl.c ../vio/viosslfactories.c ../strings/xml.c - ../mysys/my_getsystime.c ${LIB_SOURCES}) + ../mysys/my_getsystime.c ../mysys/my_sync.c ${LIB_SOURCES}) # Need to set USE_TLS for building the DLL, since __declspec(thread) # approach to thread local storage does not work properly in DLLs. -- cgit v1.2.1 From 205d448b01b93e3aa10507e933337b51e885f9dd Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 19 Feb 2008 18:45:11 +0100 Subject: fixes for build failures due to my yesterday's changeset forbidding bool in C. client/get_password.c: fix for build failure include/thr_alarm.h: fix for build failure libmysql/dll.c: fix for build failure libmysql/get_password.c: fix for build failure mysys/thr_alarm.c: fix for build failure --- libmysql/dll.c | 2 +- libmysql/get_password.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'libmysql') diff --git a/libmysql/dll.c b/libmysql/dll.c index f5db0bb4669..7aa3b5bf96f 100644 --- a/libmysql/dll.c +++ b/libmysql/dll.c @@ -25,7 +25,7 @@ #include #include -static bool libmysql_inited=0; +static my_bool libmysql_inited=0; void libmysql_init(void) { diff --git a/libmysql/get_password.c b/libmysql/get_password.c index 4c251677a66..cbe5fce6949 100644 --- a/libmysql/get_password.c +++ b/libmysql/get_password.c @@ -118,7 +118,7 @@ char *get_tty_password(const char *opt_message) to will not include the eol characters. */ -static void get_password(char *to,uint length,int fd,bool echo) +static void get_password(char *to,uint length,int fd, my_bool echo) { char *pos=to,*end=to+length; -- cgit v1.2.1 From a4b0a2cf67356c0f8f80b5291b3c1f4f8327cb97 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 27 Feb 2008 12:42:43 +0400 Subject: Bug #25097 mysql_server_init fails silently if no errmsg.sys is present. There was no way to return an error from the client library if no MYSQL connections was established. So here i added variables to store that king of errors and made functions like mysql_error(NULL) to return these. client/mysql.cc: Bug #25097 mysql_server_init fails silently if no errmsg.sys is present. Show the error message on std_error include/sql_common.h: Bug #25097 mysql_server_init fails silently if no errmsg.sys is present. cant_connect_sqlstate constant declared libmysql/libmysql.c: Bug #25097 mysql_server_init fails silently if no errmsg.sys is present. mysql_sqlstate(NULL) returns 'unknown_sqlstate' libmysqld/lib_sql.cc: Bug #25097 mysql_server_init fails silently if no errmsg.sys is present. EMBEDDED_SERVER version of the vprint_msg_to_log() implemented sql-common/client.c: Bug #25097 mysql_server_init fails silently if no errmsg.sys is present. mysql_server_last_errno and mysql_server_last_error introduced to store errors not related to particular connections. mysql_error(NULL) and mysql_errno(NULL) now returns these mysql_server_last_error and errno respectively sql/log.cc: Bug #25097 mysql_server_init fails silently if no errmsg.sys is present. EMBEDDED_LIBRARY implementation of the vprint_msg_to_log() moved to lib_sql.cc --- libmysql/libmysql.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libmysql') diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 4afc3ec5925..0320126a522 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -1486,7 +1486,7 @@ my_ulonglong STDCALL mysql_insert_id(MYSQL *mysql) const char *STDCALL mysql_sqlstate(MYSQL *mysql) { - return mysql->net.sqlstate; + return mysql ? mysql->net.sqlstate : cant_connect_sqlstate; } uint STDCALL mysql_warning_count(MYSQL *mysql) -- cgit v1.2.1 From 33a4e7609095388099bb3048778a5b5d164d26fa Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 28 Feb 2008 14:55:46 -0300 Subject: Bug#34655 Compile error Rename client_last_error to last_error and client_last_errno to last_errno to not break connectors which use the internal net structure for error handling. include/mysql_com.h: Rename client_last_error to last_error, client_last_errno to last_errno. include/mysql_h.ic: Rename client_last_error to last_error, client_last_errno to last_errno. libmysql/libmysql.c: Rename client_last_error to last_error, client_last_errno to last_errno. libmysql/manager.c: Rename client_last_error to last_error, client_last_errno to last_errno. libmysqld/lib_sql.cc: Rename client_last_error to last_error, client_last_errno to last_errno. libmysqld/libmysqld.c: Rename client_last_error to last_error, client_last_errno to last_errno. server-tools/instance-manager/mysql_connection.cc: Rename client_last_error to last_error, client_last_errno to last_errno. sql/log_event.cc: Rename client_last_error to last_error, client_last_errno to last_errno. sql-common/client.c: Rename client_last_error to last_error, client_last_errno to last_errno. sql/log_event_old.cc: Rename client_last_error to last_error, client_last_errno to last_errno. sql/net_serv.cc: Rename client_last_error to last_error, client_last_errno to last_errno. sql/repl_failsafe.cc: Rename client_last_error to last_error, client_last_errno to last_errno. --- libmysql/libmysql.c | 36 ++++++++++++++++++------------------ libmysql/manager.c | 2 +- 2 files changed, 19 insertions(+), 19 deletions(-) (limited to 'libmysql') diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 06eae528574..d79910a2ef4 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -440,11 +440,11 @@ static void expand_error(MYSQL* mysql, int error) char tmp[MYSQL_ERRMSG_SIZE]; char *p; uint err_length; - strmake(tmp, mysql->net.client_last_error, MYSQL_ERRMSG_SIZE-1); - p = strmake(mysql->net.client_last_error, ER(error), MYSQL_ERRMSG_SIZE-1); - err_length= (uint) (p - mysql->net.client_last_error); + strmake(tmp, mysql->net.last_error, MYSQL_ERRMSG_SIZE-1); + p = strmake(mysql->net.last_error, ER(error), MYSQL_ERRMSG_SIZE-1); + err_length= (uint) (p - mysql->net.last_error); strmake(p, tmp, MYSQL_ERRMSG_SIZE-1 - err_length); - mysql->net.client_last_errno = error; + mysql->net.last_errno = error; } /* @@ -870,10 +870,10 @@ my_bool handle_local_infile(MYSQL *mysql, const char *net_filename) VOID(my_net_write(net,(const uchar*) "",0)); /* Server needs one packet */ net_flush(net); strmov(net->sqlstate, unknown_sqlstate); - net->client_last_errno= + net->last_errno= (*options->local_infile_error)(li_ptr, - net->client_last_error, - sizeof(net->client_last_error)-1); + net->last_error, + sizeof(net->last_error)-1); goto err; } @@ -900,10 +900,10 @@ my_bool handle_local_infile(MYSQL *mysql, const char *net_filename) if (readcount < 0) { - net->client_last_errno= + net->last_errno= (*options->local_infile_error)(li_ptr, - net->client_last_error, - sizeof(net->client_last_error)-1); + net->last_error, + sizeof(net->last_error)-1); goto err; } @@ -1397,7 +1397,7 @@ const char *cli_read_statistics(MYSQL *mysql) if (!mysql->net.read_pos[0]) { set_mysql_error(mysql, CR_WRONG_HOST_INFO, unknown_sqlstate); - return mysql->net.client_last_error; + return mysql->net.last_error; } return (char*) mysql->net.read_pos; } @@ -1408,7 +1408,7 @@ mysql_stat(MYSQL *mysql) { DBUG_ENTER("mysql_stat"); if (simple_command(mysql,COM_STATISTICS,0,0,0)) - DBUG_RETURN(mysql->net.client_last_error); + DBUG_RETURN(mysql->net.last_error); DBUG_RETURN((*mysql->methods->read_statistics)(mysql)); } @@ -1773,7 +1773,7 @@ static my_bool my_realloc_str(NET *net, ulong length) if (res) { strmov(net->sqlstate, unknown_sqlstate); - strmov(net->client_last_error, ER(net->client_last_errno)); + strmov(net->last_error, ER(net->last_errno)); } net->write_pos= net->buff+ buf_length; } @@ -1825,14 +1825,14 @@ void set_stmt_errmsg(MYSQL_STMT *stmt, NET *net) { DBUG_ENTER("set_stmt_errmsg"); DBUG_PRINT("enter", ("error: %d/%s '%s'", - net->client_last_errno, + net->last_errno, net->sqlstate, - net->client_last_error)); + net->last_error)); DBUG_ASSERT(stmt != 0); - stmt->last_errno= net->client_last_errno; - if (net->client_last_error && net->client_last_error[0]) - strmov(stmt->last_error, net->client_last_error); + stmt->last_errno= net->last_errno; + if (net->last_error && net->last_error[0]) + strmov(stmt->last_error, net->last_error); strmov(stmt->sqlstate, net->sqlstate); DBUG_VOID_RETURN; diff --git a/libmysql/manager.c b/libmysql/manager.c index 27d35758f3e..53ffffa55c0 100644 --- a/libmysql/manager.c +++ b/libmysql/manager.c @@ -160,7 +160,7 @@ MYSQL_MANAGER* STDCALL mysql_manager_connect(MYSQL_MANAGER* con, msg_len=strlen(msg_buf); if (my_net_write(&con->net,(uchar*) msg_buf,msg_len) || net_flush(&con->net)) { - con->last_errno=con->net.client_last_errno; + con->last_errno=con->net.last_errno; strmov(con->last_error,"Write error on socket"); goto err; } -- cgit v1.2.1 From 063b50477296f20b22e5cc5c1f50b8302ef55c19 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 14 Mar 2008 17:40:12 -0300 Subject: Bug#35103 mysql_client_test::test_bug29948 causes sporadic failures The problem was that the COM_STMT_SEND_LONG_DATA was sending a response packet if the prepared statement wasn't found in the server (due to reconnection). The commands COM_STMT_SEND_LONG_DATA and COM_STMT_CLOSE should not send any packets, even error packets should not be sent since they are not expected by the client API. The solution is to clear generated during the execution of the aforementioned commands and to skip resend of prepared statement commands. Another fix is that if the connection breaks during the send of prepared statement command, the command is not sent again since the prepared statement is no longer in the server. libmysql/libmysql.c: The mysql handle might be reset after a reconnection. Pass the now used stmt argument to cli_advanced_command. sql-common/client.c: Don't resend command if the connection broke and it's a prepared statement command. If the session is broken, prepared statements on the server are gone, set the error accordanly. sql/sql_prepare.cc: Clear any error set during the execution of the request command. tests/mysql_client_test.c: Fix memory leak by freeing result associated with statement. Remove test case for Bug 29948 because it's not reliable in 5.0 (fixed in 5.1) due to KILL queries sending two packets for a thread that kills itself. --- libmysql/libmysql.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'libmysql') diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 4afc3ec5925..b4fc40bc78a 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -2456,7 +2456,7 @@ static my_bool execute(MYSQL_STMT *stmt, char *packet, ulong length) int4store(buff+5, 1); /* iteration count */ res= test(cli_advanced_command(mysql, COM_STMT_EXECUTE, buff, sizeof(buff), - packet, length, 1, NULL) || + packet, length, 1, stmt) || (*mysql->methods->read_query_result)(mysql)); stmt->affected_rows= mysql->affected_rows; stmt->server_status= mysql->server_status; @@ -2673,7 +2673,7 @@ stmt_read_row_from_cursor(MYSQL_STMT *stmt, unsigned char **row) int4store(buff + 4, stmt->prefetch_rows); /* number of rows to fetch */ if ((*mysql->methods->advanced_command)(mysql, COM_STMT_FETCH, buff, sizeof(buff), NullS, 0, - 1, NULL)) + 1, stmt)) { set_stmt_errmsg(stmt, net->last_error, net->last_errno, net->sqlstate); return 1; @@ -3340,7 +3340,7 @@ mysql_stmt_send_long_data(MYSQL_STMT *stmt, uint param_number, */ if ((*mysql->methods->advanced_command)(mysql, COM_STMT_SEND_LONG_DATA, buff, sizeof(buff), data, - length, 1, NULL)) + length, 1, stmt)) { set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno, mysql->net.sqlstate); @@ -4737,6 +4737,13 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt) MYSQL_DATA *result= &stmt->result; DBUG_ENTER("mysql_stmt_store_result"); + if (!mysql) + { + /* mysql can be reset in mysql_close called from mysql_reconnect */ + set_stmt_error(stmt, CR_SERVER_LOST, unknown_sqlstate); + DBUG_RETURN(1); + } + mysql= mysql->last_used_con; if (!stmt->field_count) @@ -4762,7 +4769,7 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt) 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), - NullS, 0, 1, NULL)) + NullS, 0, 1, stmt)) { set_stmt_errmsg(stmt, net->last_error, net->last_errno, net->sqlstate); DBUG_RETURN(1); @@ -4949,7 +4956,7 @@ static my_bool reset_stmt_handle(MYSQL_STMT *stmt, uint flags) char buff[MYSQL_STMT_HEADER]; /* packet header: 4 bytes for stmt id */ int4store(buff, stmt->stmt_id); if ((*mysql->methods->advanced_command)(mysql, COM_STMT_RESET, buff, - sizeof(buff), 0, 0, 0, NULL)) + sizeof(buff), 0, 0, 0, stmt)) { set_stmt_errmsg(stmt, mysql->net.last_error, mysql->net.last_errno, mysql->net.sqlstate); -- cgit v1.2.1 From 809522598a9a8946a5e1fa4a981717c38466a379 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 17 Mar 2008 16:39:09 -0300 Subject: Post-merge fixes for Bug 35103 libmysql/libmysql.c: Manual merge sql/sql_class.cc: Don't send anything back to the client if disabled. sql/sql_prepare.cc: Don't send any packet back for statement close. tests/mysql_client_test.c: Manual merge --- libmysql/libmysql.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libmysql') diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 423068a6ba2..99bd393a907 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -4751,7 +4751,7 @@ int STDCALL mysql_stmt_store_result(MYSQL_STMT *stmt) if (!mysql) { /* mysql can be reset in mysql_close called from mysql_reconnect */ - set_stmt_error(stmt, CR_SERVER_LOST, unknown_sqlstate); + set_stmt_error(stmt, CR_SERVER_LOST, unknown_sqlstate, NULL); DBUG_RETURN(1); } -- cgit v1.2.1