From 82281dff1a6008f0d89e5d60e240e2c8fbf037f9 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 6 Feb 2003 18:50:12 +0200 Subject: [PATCH 1/9] A fix for new conditions being defined and upper condition not updated mysql-test/r/type_datetime.result: result for datetime fix mysql-test/t/type_datetime.test: test for datetime fix sql/sql_select.cc: Fix for a bug caused implicitely by MySQL having to comply with ODBC standard on datetime comparisons. This failed to update used_tables() for OR condition, which is why query returned all rows on query as in .test above, while none of types contains NULL nor 0 datetime (last one from ODBC) --- 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 f67fe80eade847584bc0eae79d51b3b9345d7a57 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 10 Feb 2003 17:50:06 +0200 Subject: [PATCH 2/9] connect timeout bug fix libmysql/libmysql.c: This is a fix for a bug in connect_timeout. This bug manifested itself on operating systems that do support poll() system call, which resulted in a timeout twice the value specified. That is because timeout executed on both select() and poll(). --- 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 614bc5a186894916a879a4cdfe7e0fb04a7e963f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 12 Feb 2003 20:42:46 +0200 Subject: [PATCH 3/9] 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 374ea106f5098e4a6ee79f217bf799d181d20a25 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 3 Mar 2003 20:42:49 +0200 Subject: [PATCH 4/9] Fixed a deadlock problem when using LOCK TABLE in one thread and DROP TABLE in another sql/lock.cc: Added functions to handle list of table name locks sql/mysql_priv.h: Added functions to handle list of named locks sql/sql_rename.cc: Use new general table name lock functions sql/sql_table.cc: Require table name locks when doing drop table. This 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 5247c5bf515d5c1ef55b3d56ef87bc2d73628fe2 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 4 Mar 2003 18:23:15 +0200 Subject: [PATCH 5/9] 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 8529b744b7dbddb0be58c7c2a62ab1131a35ccad Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 4 Mar 2003 18:02:56 +0100 Subject: [PATCH 6/9] fixed Field::eq() to work with CHAR(0) fields BitKeeper/etc/ignore: Added configure.lineno innobase/configure.lineno to the ignore list --- .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 a300406b4f599d1ab676d6fb1cbca93be466926e Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 5 Mar 2003 15:34:58 +0200 Subject: [PATCH 7/9] 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; From 7ae420a4a17fab1b45ee56dc5cac2f8d9063baa5 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 7 Mar 2003 01:00:58 +0200 Subject: [PATCH 8/9] Portability fix for IBM compiler on AIX configure.in: Remove duplicated configure line sql-bench/crash-me.sh: Fix for connect test --- configure.in | 1 - mysys/my_tempnam.c | 10 ++++++++-- sql-bench/crash-me.sh | 37 ++++++++++++++++++++++++++++++------- 3 files changed, 38 insertions(+), 10 deletions(-) diff --git a/configure.in b/configure.in index 2e28b1d7db4..0854bb67725 100644 --- a/configure.in +++ b/configure.in @@ -14,7 +14,6 @@ SHARED_LIB_VERSION=12:0:0 # Set all version vars based on $VERSION. How do we do this more elegant ? # Remember that regexps needs to quote [ and ] since this is run through m4 -MYSQL_NO_DASH_VERSION=`echo $VERSION | sed -e "s|-.*$||"` MYSQL_NO_DASH_VERSION=`echo $VERSION | sed -e "s|[[a-z]]*-.*$||"` MYSQL_BASE_VERSION=`echo $MYSQL_NO_DASH_VERSION | sed -e "s|\.[[^.]]*$||"` F_PART=`echo $MYSQL_BASE_VERSION | sed -e "s|\.||g"| sed -e "s|[a-zA-Z]\+||"|sed -e "s|^\(..\)$|\\10|"` diff --git a/mysys/my_tempnam.c b/mysys/my_tempnam.c index a652fae3574..d079b9f66a5 100644 --- a/mysys/my_tempnam.c +++ b/mysys/my_tempnam.c @@ -115,13 +115,19 @@ my_string my_tempnam(const char *dir, const char *pfx, old_env=(char**)environ; if (dir) { /* Don't use TMPDIR if dir is given */ - ((char**) environ)=(char**) temp_env; + /* + The following strange cast is required because the IBM compiler on AIX + doesn't allow us to cast the value of environ. + The cast of environ is needed as some systems doesn't allow us to + update environ with a char ** pointer. (const mismatch) + */ + (*(char***) &environ)=(char**) temp_env; temp_env[0]=0; } #endif res=tempnam((char*) dir,(my_string) pfx); /* Use stand. dir with prefix */ #if !defined(OS2) && !defined(__NETWARE__) - ((char**) environ)=(char**) old_env; + (*(char***) &environ)=(char**) old_env; #endif if (!res) DBUG_PRINT("error",("Got error: %d from tempnam",errno)); diff --git a/sql-bench/crash-me.sh b/sql-bench/crash-me.sh index 1ae2550d69d..aeca7aa311b 100644 --- a/sql-bench/crash-me.sh +++ b/sql-bench/crash-me.sh @@ -39,7 +39,7 @@ # as such, and clarify ones such as "mediumint" with comments such as # "3-byte int" or "same as xxx". -$version="1.60"; +$version="1.61"; use DBI; use Getopt::Long; @@ -74,7 +74,7 @@ usage() if ($opt_help || $opt_Information); version() && exit(0) if ($opt_version); $opt_suffix = '-'.$opt_suffix if (length($opt_suffix) != 0); -$opt_config_file = "$pwd/$opt_dir/$opt_server$opt_suffix.cfg" +$opt_config_file = "$pwd/$opt_dir/$opt_server$opt_suffix.cfg" if (length($opt_config_file) == 0); $log_prefix=' ###'; # prefix for log lines in result file $safe_query_log=''; @@ -540,7 +540,7 @@ else " Please start it and try again\n"; exit 1; } - $dbh=safe_connect(); + $dbh=retry_connect(); } @@ -2880,9 +2880,10 @@ As all used queries are legal according to some SQL standard. any reasonable SQL server should be able to run this test without any problems. -All questions is cached in $opt_dir/'server_name'.cfg that future runs will use -limits found in previous runs. Remove this file if you want to find the -current limits for your version of the database server. +All questions is cached in $opt_dir/'server_name'[-suffix].cfg that +future runs will use limits found in previous runs. Remove this file +if you want to find the current limits for your version of the +database server. This program uses some table names while testing things. If you have any tables with the name of 'crash_me' or 'crash_qxxxx' where 'x' is a number, @@ -3152,7 +3153,29 @@ sub safe_connect } # -# Check if the server is upp and running. If not, ask the user to restart it +# Test connecting a couple of times before giving an error +# This is needed to get the server time to free old connections +# after the connect test +# + +sub retry_connect +{ + my ($dbh, $i); + for (i=0 ; $i < 10 ; $i++) + { + if (($dbh=DBI->connect($server->{'data_source'},$opt_user,$opt_password, + { PrintError => 0, AutoCommit => 1}))) + { + $dbh->{LongReadLen}= 16000000; # Set max retrieval buffer + return $dbh; + } + sleep(1); + } + return safe_connect(); +} + +# +# Check if the server is up and running. If not, ask the user to restart it # sub check_connect From efadca644132c76beb4b06b5db4b6f3533a95e29 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 7 Mar 2003 12:36:52 +0200 Subject: [PATCH 9/9] Fixed AUTO_INCREMENT handling in MyISAM (last auto_increment patch broke things) Some after merge fixes mysql-test/r/ctype_latin1_de.result: Changed test to have more relevant results mysql-test/r/delete.result: Updated results after merge mysql-test/r/select.result: Remove explicit database usage mysql-test/r/type_datetime.result: Updated results after merge mysql-test/t/ctype_latin1_de.test: Changed test to have more relevant results mysql-test/t/select.test: Remove explicit database usage sql/ha_myisam.cc: Fixed AUTO_INCREMENT handling in MyISAM (last auto_increment patch broke things) --- mysql-test/r/ctype_latin1_de.result | 210 ++++++++++++++-------------- mysql-test/r/delete.result | 15 ++ mysql-test/r/select.result | 1 - mysql-test/r/type_datetime.result | 15 -- mysql-test/t/ctype_latin1_de.test | 4 +- mysql-test/t/select.test | 2 - sql/ha_myisam.cc | 14 +- 7 files changed, 131 insertions(+), 130 deletions(-) diff --git a/mysql-test/r/ctype_latin1_de.result b/mysql-test/r/ctype_latin1_de.result index e5ae6f249ee..b79bc67138c 100644 --- a/mysql-test/r/ctype_latin1_de.result +++ b/mysql-test/r/ctype_latin1_de.result @@ -1,93 +1,95 @@ drop table if exists t1; -create table t1 (a char (20) not null, b int not null auto_increment, index (a,b),index(b)); +create table t1 (a char (20) not null, b int not null auto_increment, index (a,b)); insert into t1 (a) values ('ä'),('ac'),('ae'),('ad'),('Äc'),('aeb'); insert into t1 (a) values ('üc'),('uc'),('ue'),('ud'),('Ü'),('ueb'),('uf'); insert into t1 (a) values ('ö'),('oc'),('Öa'),('oe'),('od'),('Öc'),('oeb'); insert into t1 (a) values ('s'),('ss'),('ß'),('ßb'),('ssa'),('ssc'),('ßa'); insert into t1 (a) values ('eä'),('uü'),('öo'),('ää'),('ääa'),('aeae'); -insert into t1 (a) values ('q'),('a'),('u'),('o'),('é'),('É'); +insert into t1 (a) values ('q'),('a'),('u'),('o'),('é'),('É'),('a'); select a,b from t1 order by a,b; a b -a 35 -ac 2 -ad 4 +a 1 +a 2 +ac 1 +ad 1 ä 1 -ae 3 -ää 31 -aeae 33 -ääa 32 -aeb 6 -Äc 5 -é 38 -É 39 -eä 28 -o 37 -oc 15 -od 18 -ö 14 -oe 17 -Öa 16 -oeb 20 -Öc 19 -öo 30 -q 34 -s 21 -ss 22 -ß 23 -ssa 25 -ßa 27 -ßb 24 -ssc 26 -u 36 -uc 8 -ud 10 -ue 9 -Ü 11 -ueb 12 -üc 7 -uf 13 -uü 29 +ae 2 +ää 1 +aeae 2 +ääa 1 +aeb 1 +Äc 1 +é 1 +É 2 +eä 1 +o 1 +oc 1 +od 1 +ö 1 +oe 2 +Öa 1 +oeb 1 +Öc 1 +öo 1 +q 1 +s 1 +ss 1 +ß 2 +ssa 1 +ßa 2 +ßb 1 +ssc 1 +u 1 +uc 1 +ud 1 +ue 1 +Ü 2 +ueb 1 +üc 1 +uf 1 +uü 1 select a,b from t1 order by upper(a),b; a b -a 35 -ac 2 -ad 4 +a 1 +a 2 +ac 1 +ad 1 ä 1 -ae 3 -ää 31 -aeae 33 -ääa 32 -aeb 6 -Äc 5 -é 38 -É 39 -eä 28 -o 37 -oc 15 -od 18 -ö 14 -oe 17 -Öa 16 -oeb 20 -Öc 19 -öo 30 -q 34 -s 21 -ss 22 -ß 23 -ssa 25 -ßa 27 -ßb 24 -ssc 26 -u 36 -uc 8 -ud 10 -ue 9 -Ü 11 -ueb 12 -üc 7 -uf 13 -uü 29 +ae 2 +ää 1 +aeae 2 +ääa 1 +aeb 1 +Äc 1 +é 1 +É 2 +eä 1 +o 1 +oc 1 +od 1 +ö 1 +oe 2 +Öa 1 +oeb 1 +Öc 1 +öo 1 +q 1 +s 1 +ss 1 +ß 2 +ssa 1 +ßa 2 +ßb 1 +ssc 1 +u 1 +uc 1 +ud 1 +ue 1 +Ü 2 +ueb 1 +üc 1 +uf 1 +uü 1 select a from t1 order by a desc; a uü @@ -129,44 +131,46 @@ ae ad ac a +a check table t1; Table Op Msg_type Msg_text test.t1 check status OK select * from t1 where a like "ö%"; a b -ö 14 -Öa 16 -Öc 19 -öo 30 +ö 1 +Öa 1 +Öc 1 +öo 1 select * from t1 where a like binary "%É%"; a b -É 39 +É 2 select * from t1 where a like "%Á%"; a b -a 35 -ac 2 -ad 4 -ae 3 -aeae 33 -ääa 32 -aeb 6 -Öa 16 -ssa 25 -ßa 27 +a 1 +a 2 +ac 1 +ad 1 +ae 2 +aeae 2 +ääa 1 +aeb 1 +Öa 1 +ssa 1 +ßa 2 select * from t1 where a like "%U%"; a b -u 36 -uc 8 -ud 10 -ue 9 -ueb 12 -uf 13 -uü 29 +u 1 +uc 1 +ud 1 +ue 1 +ueb 1 +uf 1 +uü 1 select * from t1 where a like "%ss%"; a b -ss 22 -ssa 25 -ssc 26 +ss 1 +ssa 1 +ssc 1 drop table t1; select strcmp('ä','ae'),strcmp('ae','ä'),strcmp('aeq','äq'),strcmp('äq','aeq'); strcmp('ä','ae') strcmp('ae','ä') strcmp('aeq','äq') strcmp('äq','aeq') diff --git a/mysql-test/r/delete.result b/mysql-test/r/delete.result index c2230722aa6..582ab894233 100644 --- a/mysql-test/r/delete.result +++ b/mysql-test/r/delete.result @@ -24,3 +24,18 @@ 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; +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; +bool not_null misc +NULL c 6 +NULL d 7 +delete from t1 where misc > 5 and bool is null; +select * from t1 where misc > 5 and bool is null; +bool not_null misc +drop table t1; diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index a921d75f20a..b71c6ada03f 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -1,4 +1,3 @@ -use test; drop table if exists t1,t2,t3,t4; CREATE TABLE t1 ( Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL, diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result index b71884f8563..4785f790069 100644 --- a/mysql-test/r/type_datetime.result +++ b/mysql-test/r/type_datetime.result @@ -78,21 +78,6 @@ EXPLAIN SELECT * FROM t1 WHERE expedition='0001-00-00 00:00:00'; table type possible_keys key key_len ref rows Extra t1 ref expedition expedition 8 const 1 Using where drop table t1; -CREATE TABLE `t1` ( - `date` datetime NOT NULL default '0000-00-00 00:00:00', - `numfacture` int(6) unsigned NOT NULL default '0', - `expedition` datetime NOT NULL default '0000-00-00 00:00:00', - PRIMARY KEY (`numfacture`), - KEY `date` (`date`), - KEY `expedition` (`expedition`) -) TYPE=MyISAM; - -INSERT INTO t1 (expedition) VALUES ('0001-00-00 00:00:00'); -SELECT * FROM t1 WHERE expedition='0001-00-00 00:00:00'; -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()); diff --git a/mysql-test/t/ctype_latin1_de.test b/mysql-test/t/ctype_latin1_de.test index e829005a229..4b96f5f5867 100644 --- a/mysql-test/t/ctype_latin1_de.test +++ b/mysql-test/t/ctype_latin1_de.test @@ -2,13 +2,13 @@ # Test latin_de character set # drop table if exists t1; -create table t1 (a char (20) not null, b int not null auto_increment, index (a,b),index(b)); +create table t1 (a char (20) not null, b int not null auto_increment, index (a,b)); insert into t1 (a) values ('ä'),('ac'),('ae'),('ad'),('Äc'),('aeb'); insert into t1 (a) values ('üc'),('uc'),('ue'),('ud'),('Ü'),('ueb'),('uf'); insert into t1 (a) values ('ö'),('oc'),('Öa'),('oe'),('od'),('Öc'),('oeb'); insert into t1 (a) values ('s'),('ss'),('ß'),('ßb'),('ssa'),('ssc'),('ßa'); insert into t1 (a) values ('eä'),('uü'),('öo'),('ää'),('ääa'),('aeae'); -insert into t1 (a) values ('q'),('a'),('u'),('o'),('é'),('É'); +insert into t1 (a) values ('q'),('a'),('u'),('o'),('é'),('É'),('a'); select a,b from t1 order by a,b; select a,b from t1 order by upper(a),b; select a from t1 order by a desc; diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index d9b75fca362..89cc2a57b30 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -6,8 +6,6 @@ # Simple select test # -use test; - drop table if exists t1,t2,t3,t4; CREATE TABLE t1 ( diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index 6e055f57c83..749a3eba5e4 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -1021,7 +1021,7 @@ int ha_myisam::create(const char *name, register TABLE *table_arg, { int error; uint i,j,recpos,minpos,fieldpos,temp_length,length; - bool found_auto_increment=0, found_real_auto_increment=0; + bool found_real_auto_increment=0; enum ha_base_keytype type; char buff[FN_REFLEN]; KEY *pos; @@ -1091,12 +1091,6 @@ int ha_myisam::create(const char *name, register TABLE *table_arg, keydef[i].seg[j].null_bit=0; keydef[i].seg[j].null_pos=0; } - if (field->flags & AUTO_INCREMENT_FLAG && !found_auto_increment) - { - keydef[i].flag|=HA_AUTO_KEY; - found_auto_increment=1; - found_real_auto_increment=(j==0); - } if (field->type() == FIELD_TYPE_BLOB) { keydef[i].seg[j].flag|=HA_BLOB_PART; @@ -1108,6 +1102,12 @@ int ha_myisam::create(const char *name, register TABLE *table_arg, keyseg+=pos->key_parts; } + if (table_arg->found_next_number_field) + { + keydef[table_arg->next_number_index].flag|= HA_AUTO_KEY; + found_real_auto_increment= table_arg->next_number_key_offset == 0; + } + recpos=0; recinfo_pos=recinfo; while (recpos < (uint) table_arg->reclength) {