From c89c969b7c886167c67413454d4962d1cf7a54fd Mon Sep 17 00:00:00 2001 From: "Sinisa@sinisa.nasamreza.org" <> Date: Thu, 6 Feb 2003 18:50:12 +0200 Subject: [PATCH 1/7] A fix for new conditions being defined and upper condition not updated --- mysql-test/r/type_datetime.result | 1 + mysql-test/t/type_datetime.test | 5 +++++ sql/sql_select.cc | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result index dd34bc1cf86..6c461b10930 100644 --- a/mysql-test/r/type_datetime.result +++ b/mysql-test/r/type_datetime.result @@ -40,3 +40,4 @@ date numfacture expedition 0000-00-00 00:00:00 1212 0001-00-00 00:00:00 table type possible_keys key key_len ref rows Extra t1 ref expedition expedition 8 const 1 where used +a b diff --git a/mysql-test/t/type_datetime.test b/mysql-test/t/type_datetime.test index 626dedad547..eed3f831383 100644 --- a/mysql-test/t/type_datetime.test +++ b/mysql-test/t/type_datetime.test @@ -50,3 +50,8 @@ INSERT INTO t1 (numfacture,expedition) VALUES ('1212','0001-00-00 00:00:00'); SELECT * FROM t1 WHERE expedition='0001-00-00 00:00:00'; EXPLAIN SELECT * FROM t1 WHERE expedition='0001-00-00 00:00:00'; drop table t1; +create table t1 (a datetime not null, b datetime not null); +insert into t1 values (now(), now()); +insert into t1 values (now(), now()); +select * from t1 where a is null or b is null; +drop table t1; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 3596fdc0c05..8444a451965 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -3009,6 +3009,7 @@ remove_eq_conds(COND *cond,Item::cond_result *cond_value) == Item_func::COND_AND_FUNC; List_iterator li(*((Item_cond*) cond)->argument_list()); Item::cond_result tmp_cond_value; + bool should_fix_fields=0; *cond_value=Item::COND_UNDEF; Item *item; @@ -3028,6 +3029,7 @@ remove_eq_conds(COND *cond,Item::cond_result *cond_value) delete item; // This may be shared #endif VOID(li.replace(new_item)); + should_fix_fields=1; } if (*cond_value == Item::COND_UNDEF) *cond_value=tmp_cond_value; @@ -3054,6 +3056,9 @@ remove_eq_conds(COND *cond,Item::cond_result *cond_value) break; /* purecov: deadcode */ } } + if (should_fix_fields) + cond->fix_fields(current_thd,0); + if (!((Item_cond*) cond)->argument_list()->elements || *cond_value != Item::COND_OK) return (COND*) 0; From 58f20edf9ccdb3e8986df2010cbdd16ecd811ce1 Mon Sep 17 00:00:00 2001 From: "Sinisa@sinisa.nasamreza.org" <> Date: Mon, 10 Feb 2003 17:50:06 +0200 Subject: [PATCH 2/7] connect timeout bug fix --- libmysql/libmysql.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 179a942828c..af964bb9bfa 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -175,6 +175,9 @@ static int connect2(my_socket s, const struct sockaddr *name, uint namelen, * implementations of select that don't adjust tv upon * failure to reflect the time remaining */ +#ifdef HAVE_POLL + return(0); +#endif start_time = time(NULL); for (;;) { From 5376889e281d3115078ebcabe465b553f80a2f51 Mon Sep 17 00:00:00 2001 From: "Sinisa@sinisa.nasamreza.org" <> Date: Wed, 12 Feb 2003 20:42:46 +0200 Subject: [PATCH 3/7] Fixed YES/NO in Polish messages --- sql/share/polish/errmsg.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/share/polish/errmsg.txt b/sql/share/polish/errmsg.txt index af484b4c850..491068cdcdd 100644 --- a/sql/share/polish/errmsg.txt +++ b/sql/share/polish/errmsg.txt @@ -7,8 +7,8 @@ "hashchk", "isamchk", -"TAK", "NIE", +"TAK", "Nie można stworzyć pliku '%-.64s' (Kod błędu: %d)", "Nie można stworzyć tabeli '%-.64s' (Kod błędu: %d)", "Nie można stworzyć bazy danych '%-.64s'. Bł?d %d", From 8c51eb2c126c1782e2598763d516f92eec29c924 Mon Sep 17 00:00:00 2001 From: "monty@narttu.mysql.fi" <> Date: Mon, 3 Mar 2003 20:42:49 +0200 Subject: [PATCH 4/7] Fixed a deadlock problem when using LOCK TABLE in one thread and DROP TABLE in another --- sql/lock.cc | 76 +++++++++++++++++++++++++++++++++++++++++++++-- sql/mysql_priv.h | 3 ++ sql/sql_rename.cc | 32 +++++++------------- sql/sql_table.cc | 11 ++++--- 4 files changed, 94 insertions(+), 28 deletions(-) diff --git a/sql/lock.cc b/sql/lock.cc index 84d10d61366..e46e2aac7bc 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -416,10 +416,11 @@ int lock_table_name(THD *thd, TABLE_LIST *table_list) { TABLE *table; char key[MAX_DBKEY_LENGTH]; + char *db= table_list->db ? table_list->db : (thd->db ? thd->db : (char*) ""); uint key_length; DBUG_ENTER("lock_table_name"); - key_length=(uint) (strmov(strmov(key,table_list->db)+1,table_list->real_name) + key_length=(uint) (strmov(strmov(key,db)+1,table_list->real_name) -key)+ 1; /* Only insert the table if we haven't insert it already */ @@ -447,7 +448,7 @@ int lock_table_name(THD *thd, TABLE_LIST *table_list) my_free((gptr) table,MYF(0)); DBUG_RETURN(-1); } - if (remove_table_from_cache(thd, table_list->db, table_list->real_name)) + if (remove_table_from_cache(thd, db, table_list->real_name)) DBUG_RETURN(1); // Table is in use DBUG_RETURN(0); } @@ -490,6 +491,77 @@ bool wait_for_locked_table_names(THD *thd, TABLE_LIST *table_list) DBUG_RETURN(result); } + +/* + Lock all tables in list with a name lock + + SYNOPSIS + lock_table_names() + thd Thread handle + table_list Names of tables to lock + + NOTES + One must have a lock on LOCK_open when calling this + + RETURN + 0 ok + 1 Fatal error (end of memory ?) +*/ + +bool lock_table_names(THD *thd, TABLE_LIST *table_list) +{ + bool got_all_locks=1; + TABLE_LIST *lock_table; + + for (lock_table=table_list ; lock_table ; lock_table=lock_table->next) + { + int got_lock; + if ((got_lock=lock_table_name(thd,lock_table)) < 0) + goto end; // Fatal error + if (got_lock) + got_all_locks=0; // Someone is using table + } + + /* If some table was in use, wait until we got the lock */ + if (!got_all_locks && wait_for_locked_table_names(thd, table_list)) + goto end; + return 0; + +end: + unlock_table_names(thd, table_list, lock_table); + return 1; +} + + +/* + Unlock all tables in list with a name lock + + SYNOPSIS + unlock_table_names() + thd Thread handle + table_list Names of tables to unlock + last_table Don't unlock any tables after this one. + (default 0, which will unlock all tables) + + NOTES + One must have a lock on LOCK_open when calling this + This function will send a COND_refresh signal to inform other threads + that the name locks are removed + + RETURN + 0 ok + 1 Fatal error (end of memory ?) +*/ + +void unlock_table_names(THD *thd, TABLE_LIST *table_list, + TABLE_LIST *last_table) +{ + for (TABLE_LIST *table=table_list ; table != last_table ; table=table->next) + unlock_table_name(thd,table); + pthread_cond_broadcast(&COND_refresh); +} + + static void print_lock_error(int error) { int textno; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 49f1713bbc9..237a8a79acd 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -594,6 +594,9 @@ MYSQL_LOCK *mysql_lock_merge(MYSQL_LOCK *a,MYSQL_LOCK *b); int lock_table_name(THD *thd, TABLE_LIST *table_list); void unlock_table_name(THD *thd, TABLE_LIST *table_list); bool wait_for_locked_table_names(THD *thd, TABLE_LIST *table_list); +bool lock_table_names(THD *thd, TABLE_LIST *table_list); +void unlock_table_names(THD *thd, TABLE_LIST *table_list, + TABLE_LIST *last_table= 0); /* old unireg functions */ diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc index a6614f3f3f6..9eee8ccf7ac 100644 --- a/sql/sql_rename.cc +++ b/sql/sql_rename.cc @@ -31,8 +31,8 @@ static TABLE_LIST *rename_tables(THD *thd, TABLE_LIST *table_list, bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list) { - bool error=1,cerror,got_all_locks=1; - TABLE_LIST *lock_table,*ren_table=0; + bool error=1, cerror; + TABLE_LIST *ren_table= 0; DBUG_ENTER("mysql_rename_tables"); /* Avoid problems with a rename on a table that we have locked or @@ -45,23 +45,11 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list) } VOID(pthread_mutex_lock(&LOCK_open)); - for (lock_table=table_list ; lock_table ; lock_table=lock_table->next) - { - int got_lock; - if ((got_lock=lock_table_name(thd,lock_table)) < 0) - goto end; - if (got_lock) - got_all_locks=0; - } - - if (!got_all_locks && wait_for_locked_table_names(thd,table_list)) - goto end; + if (lock_table_names(thd, table_list)) + goto err; - if (!(ren_table=rename_tables(thd,table_list,0))) - error=0; - -end: - if (ren_table) + error= 0; + if ((ren_table=rename_tables(thd,table_list,0))) { /* Rename didn't succeed; rename back the tables in reverse order */ TABLE_LIST *prev=0,*table; @@ -83,7 +71,7 @@ end: table=table->next->next; // Skipp error table /* Revert to old names */ rename_tables(thd, table, 1); - /* Note that lock_table == 0 here, so the unlock loop will work */ + error= 1; } /* Lets hope this doesn't fail as the result will be messy */ @@ -103,9 +91,9 @@ end: send_ok(&thd->net); } - for (TABLE_LIST *table=table_list ; table != lock_table ; table=table->next) - unlock_table_name(thd,table); - pthread_cond_broadcast(&COND_refresh); + unlock_table_names(thd,table_list); + +err: pthread_mutex_unlock(&LOCK_open); DBUG_RETURN(error); } diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 4691c2fd494..2ff7c9c1a75 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -49,7 +49,7 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists) char path[FN_REFLEN]; String wrong_tables; bool some_tables_deleted=0; - uint error; + uint error= 1; db_type table_type; TABLE_LIST *table; DBUG_ENTER("mysql_rm_table"); @@ -66,7 +66,6 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists) { my_error(ER_TABLE_NOT_LOCKED_FOR_WRITE,MYF(0), tables->real_name); - error = 1; goto err; } while (global_read_lock && ! thd->killed) @@ -76,9 +75,12 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists) } + if (lock_table_names(thd, tables)) + goto err; + for (table=tables ; table ; table=table->next) { - char *db=table->db ? table->db : thd->db; + char *db=table->db ? table->db : (thd->db ? thd->db : (char*) ""); if (!close_temporary_table(thd, db, table->real_name)) { some_tables_deleted=1; // Log query @@ -149,9 +151,10 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists) } error = 0; + unlock_table_names(thd, tables); + err: pthread_mutex_unlock(&LOCK_open); - VOID(pthread_cond_broadcast(&COND_refresh)); // Signal to refresh pthread_mutex_lock(&thd->mysys_var->mutex); thd->mysys_var->current_mutex= 0; From 4d83bdef2a357b57d9e5f19ae0f157887b1b3f80 Mon Sep 17 00:00:00 2001 From: "Sinisa@sinisa.nasamreza.org" <> Date: Tue, 4 Mar 2003 18:23:15 +0200 Subject: [PATCH 5/7] Fix for SHOW VARIABLES on 64-bit platforms --- sql/mysqld.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index c188a015ef3..7f7d3225b56 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3162,7 +3162,7 @@ struct show_var_st init_vars[]= { {"record_rnd_buffer", (char*) &record_rnd_cache_size, SHOW_LONG}, {"query_buffer_size", (char*) &query_buff_size, SHOW_LONG}, {"safe_show_database", (char*) &opt_safe_show_db, SHOW_BOOL}, - {"server_id", (char*) &server_id, SHOW_LONG}, + {"server_id", (char*) &server_id, SHOW_INT}, {"slave_net_timeout", (char*) &slave_net_timeout, SHOW_LONG}, {"skip_locking", (char*) &my_disable_locking, SHOW_MY_BOOL}, {"skip_networking", (char*) &opt_disable_networking, SHOW_BOOL}, From 80c34b2aefab3a009b5bc9c5a96318f72fcddf56 Mon Sep 17 00:00:00 2001 From: "serg@serg.mysql.com" <> Date: Tue, 4 Mar 2003 18:02:56 +0100 Subject: [PATCH 6/7] fixed Field::eq() to work with CHAR(0) fields --- .bzrignore | 2 ++ mysql-test/r/delete.result | 4 ++++ mysql-test/t/delete.test | 20 ++++++++++++++++++++ sql/field.h | 2 +- 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 mysql-test/r/delete.result diff --git a/.bzrignore b/.bzrignore index 5b35d1f6611..7929adbf881 100644 --- a/.bzrignore +++ b/.bzrignore @@ -333,3 +333,5 @@ innobase/autom4te.cache/requests innobase/autom4te.cache/traces.0 innobase/stamp-h1 stamp-h1 +configure.lineno +innobase/configure.lineno diff --git a/mysql-test/r/delete.result b/mysql-test/r/delete.result new file mode 100644 index 00000000000..169232b72d8 --- /dev/null +++ b/mysql-test/r/delete.result @@ -0,0 +1,4 @@ +bool not_null misc +NULL c 6 +NULL d 7 +bool not_null misc diff --git a/mysql-test/t/delete.test b/mysql-test/t/delete.test index 953e22cdd55..13fa617b3cf 100644 --- a/mysql-test/t/delete.test +++ b/mysql-test/t/delete.test @@ -35,3 +35,23 @@ create table t1 (a bigint not null, primary key (a,a,a,a,a,a,a,a,a,a)); insert into t1 values (2),(4),(6),(8),(10),(12),(14),(16),(18),(20),(22),(24),(26),(23),(27); delete from t1 where a=27; drop table t1; + +# +# CHAR(0) bug - not actually DELETE bug, but anyway... +# + +CREATE TABLE t1 ( + bool char(0) default NULL, + not_null varchar(20) binary NOT NULL default '', + misc integer not null, + PRIMARY KEY (not_null) +) TYPE=MyISAM; + +INSERT INTO t1 VALUES (NULL,'a',4), (NULL,'b',5), (NULL,'c',6), (NULL,'d',7); + +select * from t1 where misc > 5 and bool is null; +delete from t1 where misc > 5 and bool is null; +select * from t1 where misc > 5 and bool is null; + +drop table t1; + diff --git a/sql/field.h b/sql/field.h index e822f6a71d6..fb3cf2178e2 100644 --- a/sql/field.h +++ b/sql/field.h @@ -64,7 +64,7 @@ public: virtual String *val_str(String*,String *)=0; virtual Item_result result_type () const=0; virtual Item_result cmp_type () const { return result_type(); } - bool eq(Field *field) { return ptr == field->ptr; } + bool eq(Field *field) { return ptr == field->ptr && null_ptr == field->null_ptr; } virtual bool eq_def(Field *field); virtual uint32 pack_length() const { return (uint32) field_length; } virtual void reset(void) { bzero(ptr,pack_length()); } From 9034ed296bca8ed505b547519fbf5ef62dcf8e1e Mon Sep 17 00:00:00 2001 From: "Sinisa@sinisa.nasamreza.org" <> Date: Wed, 5 Mar 2003 15:34:58 +0200 Subject: [PATCH 7/7] A better, but larger fix for server_id bug .. --- client/mysqlbinlog.cc | 2 +- sql/log_event.h | 2 +- sql/mysql_priv.h | 2 +- sql/mysqld.cc | 6 +++--- sql/sql_repl.h | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index e05fd63e344..6d1e711fa98 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -33,7 +33,7 @@ extern "C" #endif char server_version[SERVER_VERSION_LENGTH]; -uint32 server_id = 0; +ulong server_id = 0; // needed by net_serv.c ulong bytes_sent = 0L, bytes_received = 0L; diff --git a/sql/log_event.h b/sql/log_event.h index 7cd84a8c001..39ab1f7c6b4 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -59,7 +59,7 @@ enum Int_event_type { INVALID_INT_EVENT = 0, LAST_INSERT_ID_EVENT = 1, INSERT_ID class String; #endif -extern uint32 server_id; +extern ulong server_id; class Log_event { diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 49f1713bbc9..63f3069ef63 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -506,7 +506,7 @@ void sql_perror(const char *message); void sql_print_error(const char *format,...) __attribute__ ((format (printf, 1, 2))); -extern uint32 server_id; +extern ulong server_id; extern char mysql_data_home[2],server_version[SERVER_VERSION_LENGTH], max_sort_char, mysql_real_data_home[]; extern my_string mysql_unix_port,mysql_tmpdir; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 7f7d3225b56..0ca8659e7f6 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -273,7 +273,7 @@ I_List replicate_do_db, replicate_ignore_db; I_List binlog_do_db, binlog_ignore_db; /* if we guessed server_id , we need to know about it */ -uint32 server_id = 0; +ulong server_id = 0; bool server_id_supplied = 0; uint mysql_port; @@ -3162,7 +3162,7 @@ struct show_var_st init_vars[]= { {"record_rnd_buffer", (char*) &record_rnd_cache_size, SHOW_LONG}, {"query_buffer_size", (char*) &query_buff_size, SHOW_LONG}, {"safe_show_database", (char*) &opt_safe_show_db, SHOW_BOOL}, - {"server_id", (char*) &server_id, SHOW_INT}, + {"server_id", (char*) &server_id, SHOW_LONG}, {"slave_net_timeout", (char*) &slave_net_timeout, SHOW_LONG}, {"skip_locking", (char*) &my_disable_locking, SHOW_MY_BOOL}, {"skip_networking", (char*) &opt_disable_networking, SHOW_BOOL}, @@ -3966,7 +3966,7 @@ static void get_options(int argc,char **argv) break; } case OPT_SERVER_ID: - server_id = atoi(optarg); + server_id = atol(optarg); server_id_supplied = 1; break; case OPT_DELAY_KEY_WRITE: diff --git a/sql/sql_repl.h b/sql/sql_repl.h index aa07d859aec..3b8f161dcd0 100644 --- a/sql/sql_repl.h +++ b/sql/sql_repl.h @@ -5,7 +5,7 @@ extern char* master_host; extern my_string opt_bin_logname, master_info_file; -extern uint32 server_id; +extern ulong server_id; extern bool server_id_supplied; extern I_List binlog_do_db, binlog_ignore_db;