From 287661e66cc1fea6730b357bb56d48c6d065ef43 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 11 Dec 2003 06:24:08 +0200 Subject: Fixed a possible memory leak on MacOSX when using the shared libmysql.so library (Bug #2061) mysql_server_init() now returns error code if something went wrong (Bug #2062) Don't use my_fopen() when reading symlink information as this may cause problems when a lot of files are opened. Free thread keys with pthread_key_delete() instead of relying on automatic free. (Bug #2062) Fixed bug in UNION statement with alias '*'. (Bug #1249) Fixed a bug in DELETE ... ORDER BY ... LIMIT where the rows where not deleted in the proper order. (Bug #1024). FOUND_ROWS() could return incorrect number of rows after a query with an impossible WHERE condition. HOW DATABASES doesn't anymore show .sym files (on windows) that doesn't point to a valid directory. (Bug #1385) include/config-win.h: Ensure that USE_SYMDIR is set for all windows versions (This is set in makefiles, so this is just an extra safety measure) include/my_pthread.h: Fixed a possible memory leak on MacOSX when using the shared libmysql.so library (Bug #2061) include/my_sys.h: my_init() now returns error code if something went wrong include/mysql.h: mysql_once_init() now returns error code if something went wrong include/mysql_com.h: my_init() now returns error code if something went wrong libmysql/libmysql.c: mysql_server_init() and mysql_once_init() now returns error code if something went wrong (Bug #2062) mysql-test/r/limit.result: Update results mysql-test/r/select_found.result: Update results mysql-test/r/union.result: Update results mysql-test/t/limit.test: Added test for DELETE ... ORDER BY ... LIMIT (bug #1024) mysql-test/t/select_found.test: Added test for problem with impossible WHERE (Bug #1468) mysql-test/t/union.test: Added test for problem with alias '*' (Bug #1249) mysys/mf_pack.c: Don't use my_fopen() when reading symlink information as this may cause problems when a lot of files are opened. mysys/my_init.c: my_init() now returns error code if something went wrong mysys/my_lib.c: More debug information mysys/my_thr_init.c: Free thread keys with pthread_key_delete() instead of relying on automatic free. (Bug #2062) sql/sql_base.cc: Fixed bug in UNION statement with alias '*'. (Bug #1249) sql/sql_delete.cc: Fixed a bug in DELETE ... ORDER BY ... LIMIT where the rows where not deleted in the proper order. (Bug #1024). sql/sql_select.cc: FOUND_ROWS() could return incorrect number of rows after a query with an impossible WHERE condition. sql/sql_show.cc: SHOW DATABASES doesn't anymore show .sym files (on windows) that doesn't point to a valid directory. (Bug #1385) sql/sql_yacc.yy: Allow syntax UNION DISTINCT --- sql/sql_delete.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'sql/sql_delete.cc') diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 34a79ecd78d..ee2b720907d 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -78,7 +78,7 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order, DBUG_RETURN(-1); if ((select && select->check_quick(thd, test(thd->options & OPTION_SAFE_UPDATES), - limit)) || + limit)) || !limit) { delete select; @@ -117,13 +117,19 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order, if (setup_order(thd, &tables, fields, all_fields, order) || !(sortorder=make_unireg_sortorder(order, &length)) || (table->found_records = filesort(table, sortorder, length, - (SQL_SELECT *) 0, 0L, HA_POS_ERROR, + select, 0L, HA_POS_ERROR, &examined_rows)) == HA_POS_ERROR) { delete select; - DBUG_RETURN(-1); // This will force out message + DBUG_RETURN(-1); // This will force out message } + /* + Filesort has already found and selected the rows we want to delete, + so we don't need the where clause + */ + delete select; + select= 0; } init_read_record(&info,thd,table,select,1,1); -- cgit v1.2.1 From 9570d010d571d62a9cbdc9674606b1f154b4dead Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 11 Dec 2003 14:55:48 -0800 Subject: Many files: Fixed a bug causing a crash for multi-update/multi-delete with impossible where (bug #1860). sql/sql_class.h: Fixed a bug causing a crash for multi-update/multi-delete with impossible where (bug #1860). sql/sql_delete.cc: Fixed a bug causing a crash for multi-update/multi-delete with impossible where (bug #1860). sql/sql_update.cc: Fixed a bug causing a crash for multi-update/multi-delete with impossible where (bug #1860). mysql-test/t/multi_update.test: Fixed a bug causing a crash for multi-update/multi-delete with impossible where (bug #1860). mysql-test/r/multi_update.result: Fixed a bug causing a crash for multi-update/multi-delete with impossible where (bug #1860). BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted --- sql/sql_delete.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'sql/sql_delete.cc') diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index ee2b720907d..399f237bf2f 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -236,7 +236,8 @@ multi_delete::multi_delete(THD *thd_arg, TABLE_LIST *dt, uint num_of_tables_arg) : delete_tables(dt), thd(thd_arg), deleted(0), num_of_tables(num_of_tables_arg), error(0), - do_delete(0), transactional_tables(0), log_delayed(0), normal_tables(0) + do_delete(0), transactional_tables(0), log_delayed(0), normal_tables(0), + tempfiles_inited(0) { tempfiles = (Unique **) sql_calloc(sizeof(Unique *) * (num_of_tables-1)); } @@ -297,6 +298,7 @@ multi_delete::initialize_tables(JOIN *join) table->file->ref_length, MEM_STRIP_BUF_SIZE); } + tempfiles_inited= 1; init_ftfuncs(thd,1); DBUG_RETURN(thd->fatal_error != 0); } @@ -422,6 +424,8 @@ int multi_delete::do_deletes(bool from_send_error) table_being_deleted = delete_tables; do_delete= 0; + if (!tempfiles_inited) + DBUG_RETURN(0); for (table_being_deleted=table_being_deleted->next; table_being_deleted ; table_being_deleted=table_being_deleted->next, counter++) -- cgit v1.2.1 From 0a79eedb5d6dfb24640b49288b9fdb003c6b00b2 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 12 Dec 2003 13:14:59 -0800 Subject: sql_delete.cc, sql_update.cc, sql_class.h: Simplification of the previous fix for multi-update/delete. sql/sql_class.h: Simplification of the previous fix for multi-update/delete. sql/sql_update.cc: Simplification of the previous fix for multi-update/delete. sql/sql_delete.cc: Simplification of the previous fix for multi-update/delete. --- sql/sql_delete.cc | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'sql/sql_delete.cc') diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 399f237bf2f..bdf2cf85749 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -234,10 +234,9 @@ extern "C" int refposcmp2(void* arg, const void *a,const void *b) multi_delete::multi_delete(THD *thd_arg, TABLE_LIST *dt, uint num_of_tables_arg) - : delete_tables(dt), thd(thd_arg), deleted(0), + : delete_tables(dt), thd(thd_arg), deleted(0), found(0), num_of_tables(num_of_tables_arg), error(0), - do_delete(0), transactional_tables(0), log_delayed(0), normal_tables(0), - tempfiles_inited(0) + do_delete(0), transactional_tables(0), log_delayed(0), normal_tables(0) { tempfiles = (Unique **) sql_calloc(sizeof(Unique *) * (num_of_tables-1)); } @@ -298,7 +297,6 @@ multi_delete::initialize_tables(JOIN *join) table->file->ref_length, MEM_STRIP_BUF_SIZE); } - tempfiles_inited= 1; init_ftfuncs(thd,1); DBUG_RETURN(thd->fatal_error != 0); } @@ -339,6 +337,7 @@ bool multi_delete::send_data(List &values) continue; table->file->position(table->record[0]); + found++; if (secure_counter < 0) { @@ -414,7 +413,7 @@ int multi_delete::do_deletes(bool from_send_error) if (from_send_error) { - /* Found out table number for 'table_being_deleted' */ + /* Found out table number for 'table_being_deleted*/ for (TABLE_LIST *aux=delete_tables; aux != table_being_deleted; aux=aux->next) @@ -424,7 +423,7 @@ int multi_delete::do_deletes(bool from_send_error) table_being_deleted = delete_tables; do_delete= 0; - if (!tempfiles_inited) + if (!found) DBUG_RETURN(0); for (table_being_deleted=table_being_deleted->next; table_being_deleted ; -- cgit v1.2.1 From e97722e495495468ef8a3c5e12d7080738a99841 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 16 Dec 2003 11:10:50 +0100 Subject: Fix for BUG#2083 "EE_ error codes (EE_DELETE, EE_WRITE) end up in the binlog, making slave stop". The problem was that during execution of the command on the master, an error can occur (for example, not space left on device, then mysqld waits and when there is space it completes successfully: so finally it worked but the error EE_WRITE remains in thd->net.last_errno and thd->net.last_error). To know if finally the command succeeded, we test the 'error' variable in every place, and if it shows no failure we reset thd->net.last_err* using the function THD::clear_error() which is backported from 4.1. A new test to see if now only real errors get to the binlog (note: the test uses "rm"). Also a bit of memory free/alloc saving in log_event.cc (do not free the whole mem_root after every query in the slave SQL thread: we can keep the initial block of it; which will be freed when the thread terminates). sql/log_event.cc: In the slave SQL thread, it's a waste to free the initial block of the mem_root after every query. We can instead keep it. It will be freed when the thread terminates (in THD::~THD()). sql/sql_acl.cc: clear the error in thd->net.last_errno as there was no error sql/sql_base.cc: clear the error in thd->net.last_errno as there was no error sql/sql_class.h: Backport of THD::clear_error() from 4.1: clears the error in thd->net.last_errno sql/sql_db.cc: clear the error in thd->net.last_errno as there was no error sql/sql_delete.cc: clear the error in thd->net.last_errno as there was no error sql/sql_insert.cc: clear the error in thd->net.last_errno as there was no error sql/sql_parse.cc: clear the error in thd->net.last_errno as there was no error sql/sql_rename.cc: clear the error in thd->net.last_errno as there was no error sql/sql_table.cc: clear the error in thd->net.last_errno as there was no error sql/sql_update.cc: clear the error in thd->net.last_errno as there was no error --- sql/sql_delete.cc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'sql/sql_delete.cc') diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 34a79ecd78d..ef90cd55730 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -175,6 +175,8 @@ cleanup: mysql_update_log.write(thd,thd->query, thd->query_length); if (mysql_bin_log.is_open()) { + if (error <= 0) + thd->clear_error(); Query_log_event qinfo(thd, thd->query, thd->query_length, log_delayed); if (mysql_bin_log.write(&qinfo) && transactional_table) @@ -479,6 +481,8 @@ bool multi_delete::send_eof() mysql_update_log.write(thd,thd->query,thd->query_length); if (mysql_bin_log.is_open()) { + if (error <= 0) + thd->clear_error(); Query_log_event qinfo(thd, thd->query, thd->query_length, log_delayed); if (mysql_bin_log.write(&qinfo) && !normal_tables) @@ -591,6 +595,7 @@ end: mysql_update_log.write(thd,thd->query,thd->query_length); if (mysql_bin_log.is_open()) { + thd->clear_error(); Query_log_event qinfo(thd, thd->query, thd->query_length, thd->tmp_table); mysql_bin_log.write(&qinfo); -- cgit v1.2.1