From e6298f379e642a8e3867c7cb185ae5fa1615b497 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 5 Nov 2003 02:23:13 +0500 Subject: [PATCH 01/47] compile-pentium-gcov: Stop the line wrapping for warnings. it needs for warnings statistic in code coverage BUILD/compile-pentium-gcov: Stop the line wrapping for warnings. it needs for warnings statistic in code coverage --- BUILD/compile-pentium-gcov | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUILD/compile-pentium-gcov b/BUILD/compile-pentium-gcov index 873d1d0d8e8..0bc7eb2a8fa 100755 --- a/BUILD/compile-pentium-gcov +++ b/BUILD/compile-pentium-gcov @@ -3,7 +3,7 @@ path=`dirname $0` . "$path/SETUP.sh" -extra_flags="$pentium_cflags -O2 -fprofile-arcs -ftest-coverage" +extra_flags="$pentium_cflags -O2 -fprofile-arcs -ftest-coverage -fmessage-length=0 " extra_configs="$pentium_configs $debug_configs --disable-shared $static_link" . "$path/FINISH.sh" From 20da41c5d6c57fc0c951d9187bd17eb074b8386e Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 8 Nov 2003 15:39:10 +0100 Subject: [PATCH 02/47] fulltext.test, fulltext.result: one simple trunc* test mysql-test/r/fulltext.result: one simple trunc* test mysql-test/t/fulltext.test: one simple trunc* test --- mysql-test/r/fulltext.result | 14 ++++++++++++++ mysql-test/t/fulltext.test | 10 ++++++++++ 2 files changed, 24 insertions(+) diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result index 737390865f1..8f1f90e9f76 100644 --- a/mysql-test/r/fulltext.result +++ b/mysql-test/r/fulltext.result @@ -134,6 +134,20 @@ Only MyISAM tables support collections Function MATCH ... AGAINST() is used to do a search some test foobar implements vector space model drop table t1; +create table t1 (a varchar(200) not null, fulltext (a)); +insert t1 values ("aaa10 bbb20"), ("aaa20 bbb15"), ("aaa30 bbb10"); +select * from t1 where match a against ("+aaa* +bbb*" in boolean mode); +a +aaa10 bbb20 +aaa20 bbb15 +aaa30 bbb10 +select * from t1 where match a against ("+aaa* +bbb1*" in boolean mode); +a +aaa20 bbb15 +aaa30 bbb10 +select * from t1 where match a against ("+aaa* +ccc*" in boolean mode); +a +drop table t1; CREATE TABLE t1 ( id int(11), ticket int(11), diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test index 387a36f1f52..e2293094258 100644 --- a/mysql-test/t/fulltext.test +++ b/mysql-test/t/fulltext.test @@ -70,6 +70,16 @@ delete from t1 where MATCH(a,b) AGAINST ("indexes"); select * from t1; drop table t1; +# +# why to scan strings for trunc* +# +create table t1 (a varchar(200) not null, fulltext (a)); +insert t1 values ("aaa10 bbb20"), ("aaa20 bbb15"), ("aaa30 bbb10"); +select * from t1 where match a against ("+aaa* +bbb*" in boolean mode); +select * from t1 where match a against ("+aaa* +bbb1*" in boolean mode); +select * from t1 where match a against ("+aaa* +ccc*" in boolean mode); +drop table t1; + # # Check bug reported by Matthias Urlichs # From 75392a0d2e4c7f95fa1490fed8203c9f2ffbee48 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 12 Nov 2003 22:33:28 +0100 Subject: [PATCH 03/47] make error message more detailed --- sql/sql_handler.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index a19fcdc2d73..dd8dfb31163 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -232,8 +232,8 @@ int mysql_ha_read(THD *thd, TABLE_LIST *tables, { if (err != HA_ERR_KEY_NOT_FOUND && err != HA_ERR_END_OF_FILE) { - sql_print_error("mysql_ha_read: Got error %d when reading table", - err); + sql_print_error("mysql_ha_read: Got error %d when reading table '%s'", + err, tables->real_name); table->file->print_error(err,MYF(0)); goto err; } From a35ba0ea0ce87b54c65d451a50d7821ac0f92d4a Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 14 Nov 2003 22:08:45 +0100 Subject: [PATCH 04/47] obligatory update checksum on repair, if it is obligatory verified on check. --- myisam/mi_check.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/myisam/mi_check.c b/myisam/mi_check.c index a4ae7b25dbb..466defe8fbc 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -1153,6 +1153,9 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info, } param->testflag|=T_REP; /* for easy checking */ + if (info->s->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD)) + param->testflag|=T_CALC_CHECKSUM; + if (!param->using_global_keycache) VOID(init_key_cache(param->use_buffers)); @@ -1820,6 +1823,9 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, } param->testflag|=T_REP; /* for easy checking */ + if (info->s->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD)) + param->testflag|=T_CALC_CHECKSUM; + bzero((char*)&sort_info,sizeof(sort_info)); bzero((char *)&sort_param, sizeof(sort_param)); if (!(sort_info.key_block= @@ -2189,6 +2195,9 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, } param->testflag|=T_REP; /* for easy checking */ + if (info->s->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD)) + param->testflag|=T_CALC_CHECKSUM; + bzero((char*)&sort_info,sizeof(sort_info)); if (!(sort_info.key_block= alloc_key_blocks(param, From 194dbe1a9a53cd1b3f3614a8764f8c35587f70e0 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 15 Nov 2003 19:37:54 -0400 Subject: [PATCH 05/47] fixed bug #1650 "mysql_config --libmysqd-libs misses libwrap" scripts/Makefile.am: added processing of @WRAPLIBS@ in scripts scripts/mysql_config.sh: added @WRAPLIBS@ to embedded_libs option line --- scripts/Makefile.am | 1 + scripts/mysql_config.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/Makefile.am b/scripts/Makefile.am index e846976eceb..d14d7f38deb 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -114,6 +114,7 @@ SUFFIXES = .sh -e 's!@''LDFLAGS''@!@SAVE_LDFLAGS@!'\ -e 's!@''CLIENT_LIBS''@!@CLIENT_LIBS@!' \ -e 's!@''LIBS''@!@LIBS@!' \ + -e 's!@''WRAPLIBS''@!@WRAPLIBS@!' \ -e 's!@''innodb_system_libs''@!@innodb_system_libs@!' \ -e 's!@''openssl_libs''@!@openssl_libs@!' \ -e 's!@''VERSION''@!@VERSION@!' \ diff --git a/scripts/mysql_config.sh b/scripts/mysql_config.sh index 6b543bf4a07..051f3fa9c14 100644 --- a/scripts/mysql_config.sh +++ b/scripts/mysql_config.sh @@ -92,7 +92,7 @@ libs_r="$ldflags -L$pkglibdir -lmysqlclient_r @LIBS@ @openssl_libs@" libs_r=`echo "$libs_r" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'` cflags="-I$pkgincludedir @CFLAGS@" include="-I$pkgincludedir" -embedded_libs="$ldflags -L$pkglibdir -lmysqld @LIBS@ @innodb_system_libs@" +embedded_libs="$ldflags -L$pkglibdir -lmysqld @LIBS@ @WRAPLIBS@ @innodb_system_libs@" embedded_libs=`echo "$embedded_libs" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'` # Remove some options that a client doesn't have to care about From 069ec78c803516363e91c550624032d1b622dec9 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 16 Nov 2003 17:37:15 +0100 Subject: [PATCH 06/47] Item_uint::save_in_field() added to take into account bigint->decimal case BitKeeper/etc/ignore: Added sql/udf_example.so to the ignore list --- .bzrignore | 1 + mysql-test/r/bigint.result | 8 ++++++++ mysql-test/t/bigint.test | 12 ++++++++++++ sql/item.cc | 13 +++++++++++++ sql/item.h | 3 ++- 5 files changed, 36 insertions(+), 1 deletion(-) diff --git a/.bzrignore b/.bzrignore index 3dcf46841d9..12cdf99cbc9 100644 --- a/.bzrignore +++ b/.bzrignore @@ -540,3 +540,4 @@ libmysql/vio_priv.h libmysql_r/vio_priv.h hardcopy.0 scripts/make_sharedlib_distribution +sql/udf_example.so diff --git a/mysql-test/r/bigint.result b/mysql-test/r/bigint.result index d7d811dc5f3..2b595c2b83d 100644 --- a/mysql-test/r/bigint.result +++ b/mysql-test/r/bigint.result @@ -67,3 +67,11 @@ select * from t1 limit 9999999999; id a 9999999999 1 drop table t1; +CREATE TABLE t1 ( quantity decimal(60,0)); +insert into t1 values (10000000000000000000); +insert into t1 values ('10000000000000000000'); +select * from t1; +quantity +10000000000000000000 +10000000000000000000 +drop table t1; diff --git a/mysql-test/t/bigint.test b/mysql-test/t/bigint.test index c5691a760c7..a7cc068ec46 100644 --- a/mysql-test/t/bigint.test +++ b/mysql-test/t/bigint.test @@ -46,3 +46,15 @@ insert into t1 values (null,1); select * from t1; select * from t1 limit 9999999999; drop table t1; + +# +# Item_uint::save_to_field() +# BUG#1845 +# + +CREATE TABLE t1 ( quantity decimal(60,0)); +insert into t1 values (10000000000000000000); +insert into t1 values ('10000000000000000000'); +select * from t1; +drop table t1; + diff --git a/sql/item.cc b/sql/item.cc index 0e9085180cd..65eb7f1befd 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -548,6 +548,19 @@ bool Item_string::save_in_field(Field *field, bool no_conversions) return 0; } +bool Item_uint::save_in_field(Field *field, bool no_conversions) +{ + longlong nr=val_int(); + if (null_value) + return set_field_to_null(field); + field->set_notnull(); + if (nr < 0) + field->store(ulonglong2double(nr)); + else + field->store(nr); + return 0; +} + bool Item_int::save_in_field(Field *field, bool no_conversions) { longlong nr=val_int(); diff --git a/sql/item.h b/sql/item.h index 25650e85434..d23a061eedb 100644 --- a/sql/item.h +++ b/sql/item.h @@ -232,13 +232,14 @@ public: String *val_str(String*); void make_field(Send_field *field); Item *new_item() { return new Item_uint(name,max_length); } + bool save_in_field(Field *field, bool no_conversions); bool fix_fields(THD *thd,struct st_table_list *table_list) { unsigned_flag= 1; return 0; } void print(String *str); - unsigned int size_of() { return sizeof(*this);} + unsigned int size_of() { return sizeof(*this);} }; From b57a1dd22731b436c52bddd2fe4f368429ebb59c Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 17 Nov 2003 12:59:07 +0200 Subject: [PATCH 07/47] Safety fix for alarms on windows. mysys/thr_alarm.c: Safety fix for alarms on windows sql/mini_client.cc: Added comments --- mysys/thr_alarm.c | 3 ++- sql/mini_client.cc | 17 +++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c index f51f27b7f51..564d46aca3a 100644 --- a/mysys/thr_alarm.c +++ b/mysys/thr_alarm.c @@ -638,7 +638,8 @@ bool thr_got_alarm(thr_alarm_t *alrm_ptr) void thr_end_alarm(thr_alarm_t *alrm_ptr) { thr_alarm_t alrm= *alrm_ptr; - if (alrm->crono) + /* alrm may be zero if thr_alarm aborted with an error */ + if (alrm && alrm->crono) { KillTimer(NULL, alrm->crono); alrm->crono = 0; diff --git a/sql/mini_client.cc b/sql/mini_client.cc index c7beeea37b8..cd56081e6a8 100644 --- a/sql/mini_client.cc +++ b/sql/mini_client.cc @@ -15,13 +15,14 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* - mini MySQL client to be included into the server to do server to server - commincation by Sasha Pachev + mini MySQL client to be included into the server to do server to server + commincation by Sasha Pachev - Note: all file-global symbols must begin with mc_ , even the static ones, just - in case we decide to make them external at some point - */ + Note: all file-global symbols must begin with mc_ , even the static + ones, just in case we decide to make them external at some point +*/ +#include #define DONT_USE_RAID #if defined(__WIN__) #include @@ -40,7 +41,6 @@ inline int local_thr_alarm(my_bool *A,int B __attribute__((unused)),ALARM *C __a #define thr_got_alarm(A) 0 #endif -#include #include #include #include @@ -597,6 +597,11 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user, sprintf(host_info=buff,ER(CR_TCP_CONNECTION),host); DBUG_PRINT("info",("Server name: '%s'. TCP sock: %d", host,port)); thr_alarm_init(&alarmed); + /* + We don't have to check status for thr_alarm as it's not fatal if + we didn't manage to set an alarm. (In this case the socket call + will just block for a while). + */ thr_alarm(&alarmed, net_read_timeout, &alarm_buff); sock = (my_socket) socket(AF_INET,SOCK_STREAM,0); thr_end_alarm(&alarmed); From 348416e930dd37137fc74f17c67d84d3e7274ce9 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 17 Nov 2003 13:06:32 +0200 Subject: [PATCH 08/47] Fix for service names on windows; Now we always put the service name last when we create a service myisam/mi_test2.c: Moved test so that resize_key_cache() is always tested mysys/mf_keycache.c: Fixed comment --- myisam/mi_test2.c | 4 ++-- mysys/mf_keycache.c | 2 +- sql/mysqld.cc | 14 ++++++++------ 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/myisam/mi_test2.c b/myisam/mi_test2.c index 2a658ca2054..11253f1fdee 100644 --- a/myisam/mi_test2.c +++ b/myisam/mi_test2.c @@ -267,9 +267,9 @@ int main(int argc, char *argv[]) puts("got error from mi_extra(HA_EXTRA_NO_CACHE)"); goto end; } - if (key_cacheing) - resize_key_cache(key_cache_size*2); } + if (key_cacheing) + resize_key_cache(key_cache_size*2); if (!silent) printf("- Delete\n"); diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c index 4cb3681b8b8..977ca6b11a7 100644 --- a/mysys/mf_keycache.c +++ b/mysys/mf_keycache.c @@ -669,7 +669,7 @@ static int flush_key_blocks_int(File file, enum flush_type type) Flush all blocks for a specific file to disk SYNOPSIS - flush_all_key_blocks() + flush_key_blocks() file File descriptor type Type of flush operation diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 811984e50b4..5073f8e1c40 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1958,7 +1958,7 @@ extern "C" pthread_handler_decl(handle_shutdown,arg) #endif -const char *load_default_groups[]= { "mysqld","server",MYSQL_BASE_VERSION,0 }; +const char *load_default_groups[]= { "mysqld","server",MYSQL_BASE_VERSION,0,0}; bool open_log(MYSQL_LOG *log, const char *hostname, const char *opt_name, const char *extension, @@ -2561,7 +2561,7 @@ default_service_handling(char **argv, const char *extra_opt) { char path_and_service[FN_REFLEN+FN_REFLEN+32], *pos, *end; - end= path_and_service + sizeof(path_and_service)-1; + end= path_and_service + sizeof(path_and_service)-3; /* We have to quote filename if it contains spaces */ pos= add_quoted_string(path_and_service, file_path, end); @@ -2571,7 +2571,9 @@ default_service_handling(char **argv, *pos++= ' '; pos= add_quoted_string(pos, extra_opt, end); } - *pos= 0; // Ensure end null + /* We must have servicename last */ + *pos++= ' '; + strmake(pos, servicename, (uint) (end+2 - pos)); if (Service.got_service_option(argv, "install")) { @@ -2616,7 +2618,7 @@ int main(int argc, char **argv) if (Service.IsService(argv[1])) { /* start an optional service */ - load_default_groups[0]= argv[1]; + load_default_groups[3]= argv[1]; start_mode= 1; Service.Init(argv[1], mysql_service); return 0; @@ -2624,8 +2626,7 @@ int main(int argc, char **argv) } else if (argc == 3) /* install or remove any optional service */ { - if (!default_service_handling(argv, argv[2], argv[2], file_path, - argv[2])) + if (!default_service_handling(argv, argv[2], argv[2], file_path, "")) return 0; if (Service.IsService(argv[2])) { @@ -2637,6 +2638,7 @@ int main(int argc, char **argv) opt_argc= 2; // Skip service-name opt_argv=argv; start_mode= 1; + load_default_groups[3]= argv[2]; Service.Init(argv[2], mysql_service); return 0; } From 80649ee8746aab02a198285248668cb49ce70f33 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 18 Nov 2003 17:31:17 +0100 Subject: [PATCH 09/47] Fix for BUG#1870 "CHANGE MASTER makes SQL thread restart from coordinates of I/O thread". So, in CHANGE MASTER: when it seems reasonable that the user did not want to discontinue its replication (i.e. when he is not specifying host or port or master_log_file or master_log_pos; this will be documented), set the coordinates of the I/O thread to those of the SQL thread. This way, the SQL thread will see no discontinuity in the relay log (i.e. will skip no events), because the I/O thread will fill the brand new relay log with the events which are just after the position where the SQL thread had stopped (before CHANGE MASTER was issued). And a new test for this bug. mysql-test/r/rpl_loaddata.result: Now, after CHANGE MASTER the coordinates of the I/O thread are the last ones of the SQL thread, so result update. sql/sql_repl.cc: Fix for BUG#1870 "CHANGE MASTER makes SQL thread restart from coordinates of I/O thread". So, in CHANGE MASTER: when it seems reasonable that the user did not want to discontinue its replication (i.e. when he is not specifying host or port or master_log_file or master_log_pos; this will be documented), set the coordinates of the I/O thread to those of the SQL thread. This way, the SQL thread will see no discontinuity in the relay log (i.e. will skip no events), because the I/O thread will fill the brand new relay log with the events which are just after the position where the SQL thread had stopped (before CHANGE MASTER was issued). --- mysql-test/r/rpl_change_master.result | 32 +++++++++++++++++ mysql-test/r/rpl_loaddata.result | 2 +- mysql-test/t/rpl_change_master.test | 26 ++++++++++++++ sql/sql_repl.cc | 49 ++++++++++++++++++++++++--- 4 files changed, 104 insertions(+), 5 deletions(-) create mode 100644 mysql-test/r/rpl_change_master.result create mode 100644 mysql-test/t/rpl_change_master.test diff --git a/mysql-test/r/rpl_change_master.result b/mysql-test/r/rpl_change_master.result new file mode 100644 index 00000000000..be2aec616b0 --- /dev/null +++ b/mysql-test/r/rpl_change_master.result @@ -0,0 +1,32 @@ +slave stop; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +slave start; +select get_lock("a",5); +get_lock("a",5) +1 +create table t1(n int); +insert into t1 values(1+get_lock("a",10)*0); +insert into t1 values(2); +stop slave; +select * from t1; +n +1 +show slave status; +Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space +127.0.0.1 root 9306 1 master-bin.001 273 slave-relay-bin.002 255 master-bin.001 No No 0 0 214 314 +change master to master_user='root'; +show slave status; +Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space +127.0.0.1 root 9306 1 master-bin.001 214 slave-relay-bin.001 4 master-bin.001 No No 0 0 214 4 +select release_lock("a"); +release_lock("a") +1 +start slave; +select * from t1; +n +1 +2 +drop table t1; diff --git a/mysql-test/r/rpl_loaddata.result b/mysql-test/r/rpl_loaddata.result index 8b910d0d183..268e383ce69 100644 --- a/mysql-test/r/rpl_loaddata.result +++ b/mysql-test/r/rpl_loaddata.result @@ -43,7 +43,7 @@ change master to master_user='test'; change master to master_user='root'; show slave status; Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space -127.0.0.1 root MASTER_PORT 1 master-bin.001 1442 slave-relay-bin.001 4 master-bin.001 No No 0 0 1442 4 +127.0.0.1 root MASTER_PORT 1 master-bin.001 1419 slave-relay-bin.001 4 master-bin.001 No No 0 0 1419 4 set global sql_slave_skip_counter=1; start slave; set sql_log_bin=0; diff --git a/mysql-test/t/rpl_change_master.test b/mysql-test/t/rpl_change_master.test new file mode 100644 index 00000000000..61de22fe57b --- /dev/null +++ b/mysql-test/t/rpl_change_master.test @@ -0,0 +1,26 @@ +source include/master-slave.inc; + +connection slave; +select get_lock("a",5); +connection master; +create table t1(n int); +insert into t1 values(1+get_lock("a",10)*0); +insert into t1 values(2); +save_master_pos; +connection slave; +sleep 3; # can't sync_with_master as we should be blocked +stop slave; +select * from t1; +show slave status; +change master to master_user='root'; +show slave status; +# Will restart from after the values(2), which is bug +select release_lock("a"); +start slave; +sync_with_master; +select * from t1; +connection master; +drop table t1; +save_master_pos; +connection slave; +sync_with_master; diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 10581431c72..c95cdc1b04e 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -853,8 +853,8 @@ void kill_zombie_dump_threads(uint32 slave_server_id) int change_master(THD* thd, MASTER_INFO* mi) { int thread_mask; - const char* errmsg=0; - bool need_relay_log_purge=1; + const char* errmsg= 0; + bool need_relay_log_purge= 1; DBUG_ENTER("change_master"); lock_slave_threads(mi); @@ -928,6 +928,36 @@ int change_master(THD* thd, MASTER_INFO* mi) mi->rli.relay_log_pos=lex_mi->relay_log_pos; } + /* + If user did specify neither host nor port nor any log name nor any log + pos, i.e. he specified only user/password/master_connect_retry, he probably + wants replication to resume from where it had left, i.e. from the + coordinates of the **SQL** thread (imagine the case where the I/O is ahead + of the SQL; restarting from the coordinates of the I/O would lose some + events which is probably unwanted when you are just doing minor changes + like changing master_connect_retry). + A side-effect is that if only the I/O thread was started, this thread may + restart from ''/4 after the CHANGE MASTER. That's a minor problem (it is a + much more unlikely situation than the one we are fixing here). + Note: coordinates of the SQL thread must be read here, before the + 'if (need_relay_log_purge)' block which resets them. + */ + if (!lex_mi->host && !lex_mi->port && + !lex_mi->log_file_name && !lex_mi->pos && + need_relay_log_purge) + { + /* + Sometimes mi->rli.master_log_pos == 0 (it happens when the SQL thread is + not initialized), so we use a max(). + What happens to mi->rli.master_log_pos during the initialization stages + of replication is not 100% clear, so we guard against problems using + max(). + */ + mi->master_log_pos = max(BIN_LOG_HEADER_SIZE, mi->rli.master_log_pos); + strmake(mi->master_log_name,mi->rli.master_log_name, + sizeof(mi->master_log_name)-1); + } + flush_master_info(mi); if (need_relay_log_purge) { @@ -959,10 +989,21 @@ int change_master(THD* thd, MASTER_INFO* mi) } } DBUG_PRINT("info", ("master_log_pos: %d", (ulong) mi->master_log_pos)); - /* If changing RELAY_LOG_FILE or RELAY_LOG_POS, this will be nonsense: */ + + /* + Coordinates in rli were spoilt by the 'if (need_relay_log_purge)' block, + so restore them to good values. If we left them to ''/0, that would work; + but that would fail in the case of 2 successive CHANGE MASTER (without a + START SLAVE in between): because first one would set the coords in mi to + the good values of those in rli, the set those in rli to ''/0, then + second CHANGE MASTER would set the coords in mi to those of rli, i.e. to + ''/0: we have lost all copies of the original good coordinates. + That's why we always save good coords in rli. + */ mi->rli.master_log_pos = mi->master_log_pos; strmake(mi->rli.master_log_name,mi->master_log_name, - sizeof(mi->rli.master_log_name)-1); + sizeof(mi->rli.master_log_name)-1); + if (!mi->rli.master_log_name[0]) // uninitialized case mi->rli.master_log_pos=0; From a36145a8f2ba164bffe513c887697548b38955df Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 18 Nov 2003 22:06:47 +0100 Subject: [PATCH 10/47] Bug#1826, HANDLER+ALTER TABLE=crash (unfortunately, it cannot be tested in mysql-test suite) more user variable tests mysql-test/r/user_var.result: more user variable tests (just to have this behaviour written down somewhere) mysql-test/t/user_var.test: more user variable tests (just to have this behaviour written down somewhere) sql/sql_handler.cc: Bug#1826, HANDLER+ALTER TABLE=crash (unfortunately, it cannot be tested in mysql-test suite) --- mysql-test/r/user_var.result | 19 +++++++++++++++++++ mysql-test/t/user_var.test | 11 +++++++++++ sql/sql_handler.cc | 13 +++++++++++++ 3 files changed, 43 insertions(+) diff --git a/mysql-test/r/user_var.result b/mysql-test/r/user_var.result index d7c41d5dbc4..3e83438b273 100644 --- a/mysql-test/r/user_var.result +++ b/mysql-test/r/user_var.result @@ -97,3 +97,22 @@ drop table t1; select @a:=10, @b:=2, @a>@b, @a:="10", @b:="2", @a>@b, @a:=10, @b:=2, @a>@b, @a:="10", @b:="2", @a>@b; @a:=10 @b:=2 @a>@b @a:="10" @b:="2" @a>@b @a:=10 @b:=2 @a>@b @a:="10" @b:="2" @a>@b 10 2 1 10 2 1 10 2 1 10 2 1 +create table t1 (i int not null); +insert t1 values (1),(2),(2),(3),(3),(3); +select @a:=0; +@a:=0 +0 +select @a, @a:=@a+count(*), count(*), @a from t1 group by i; +@a @a:=@a+count(*) count(*) @a +0 1 1 0 +0 2 2 0 +0 3 3 0 +select @a:=0; +@a:=0 +0 +select @a+0, @a:=@a+0+count(*), count(*), @a+0 from t1 group by i; +@a+0 @a:=@a+0+count(*) count(*) @a+0 +0 1 1 0 +1 3 2 0 +3 6 3 0 +drop table t1; diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test index 56528405a2a..9cb5d5e1eb0 100644 --- a/mysql-test/t/user_var.test +++ b/mysql-test/t/user_var.test @@ -53,3 +53,14 @@ drop table t1; # just for fun :) select @a:=10, @b:=2, @a>@b, @a:="10", @b:="2", @a>@b, @a:=10, @b:=2, @a>@b, @a:="10", @b:="2", @a>@b; + +# +# bug#1739 +# Item_func_set_user_var sets update_query_id, Item_func_get_user_var checks it +# +create table t1 (i int not null); +insert t1 values (1),(2),(2),(3),(3),(3); +select @a:=0; select @a, @a:=@a+count(*), count(*), @a from t1 group by i; +select @a:=0; select @a+0, @a:=@a+0+count(*), count(*), @a+0 from t1 group by i; +drop table t1; + diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index dd8dfb31163..208545a435b 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -285,7 +285,20 @@ static TABLE **find_table_ptr_by_name(THD *thd, const char *db, { if (!memcmp(table->table_cache_key, db, dblen) && !my_strcasecmp((is_alias ? table->table_name : table->real_name),table_name)) + { + if (table->version != refresh_version) + { + VOID(pthread_mutex_lock(&LOCK_open)); + if (close_thread_table(thd, ptr)) + { + /* Tell threads waiting for refresh that something has happened */ + VOID(pthread_cond_broadcast(&COND_refresh)); + } + VOID(pthread_mutex_unlock(&LOCK_open)); + continue; + } break; + } ptr=&(table->next); } return ptr; From c9b59bccb3da2ac065c3aaa883b8d6c0792f7a17 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 19 Nov 2003 16:38:01 +0100 Subject: [PATCH 11/47] - removed some undefined non-weak symbols in libmysqlclient_r by setting LIBS to include @openss_libs@ (BUG#1652) --- libmysql_r/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmysql_r/Makefile.am b/libmysql_r/Makefile.am index e01fc7634a1..ae091d86a88 100644 --- a/libmysql_r/Makefile.am +++ b/libmysql_r/Makefile.am @@ -19,7 +19,7 @@ target = libmysqlclient_r.la target_defs = -DDONT_USE_RAID @LIB_EXTRA_CCFLAGS@ -## LIBS = @LIBS@ +LIBS = @LIBS@ @openssl_libs@ INCLUDES = @MT_INCLUDES@ -I$(srcdir)/../include -I../include \ -I$(srcdir)/.. -I$(top_srcdir) -I.. $(openssl_includes) From 8fcd7311790f548cff66d40ef24b5bc02d61a6e8 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 19 Nov 2003 23:07:31 +0100 Subject: [PATCH 12/47] minor fixups: more verbose on "no memory" errors - report requested size, avoid flushing rec buffer to a file that is closed and deleted already (on got_error=1) --- myisam/mi_check.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/myisam/mi_check.c b/myisam/mi_check.c index 466defe8fbc..7108fdcba9e 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -1368,6 +1368,7 @@ err: VOID(my_close(new_file,MYF(0))); VOID(my_raid_delete(param->temp_filename,info->s->base.raid_chunks, MYF(MY_WME))); + info->rec_cache.file=-1; /* don't flush data to new_file, it's closed */ } mi_mark_crashed_on_repair(info); } @@ -2852,8 +2853,8 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) if (!(to=mi_alloc_rec_buff(info,block_info.rec_len, &(sort_param->rec_buff)))) { - mi_check_print_error(param,"Not enough memory for blob at %s", - llstr(sort_param->start_recpos,llbuff)); + mi_check_print_error(param,"Not enough memory for blob at %s (need %lu)", + llstr(sort_param->start_recpos,llbuff), block_info.rec_len); DBUG_RETURN(1); } } From cd878c2c8a4a639b2a7147ecf00ce791e15faa42 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 20 Nov 2003 21:21:56 +0300 Subject: [PATCH 13/47] added comments to simple_order, simple_group, no_order, skip_sort_order --- sql/sql_select.cc | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 740b0470fdc..7f8dfd219d0 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -208,8 +208,21 @@ mysql_select(THD *thd,TABLE_LIST *tables,List &fields,COND *conds, { TABLE *tmp_table; int error, tmp_error; - bool need_tmp,hidden_group_fields; - bool simple_order,simple_group,no_order, skip_sort_order; + bool need_tmp; + bool hidden_group_fields; + /* + simple_xxxxx is set if ORDER/GROUP BY doesn't include any references + to other tables than the first non-constant table in the JOIN. + It's also set if ORDER/GROUP BY is empty. + */ + bool simple_order, simple_group; + /* + Is set only in case if we have a GROUP BY clause + and no ORDER BY after constant elimination of 'order'. + */ + bool no_order; + /* Is set if we have a GROUP BY and we have ORDER BY on a constant. */ + bool skip_sort_order; ha_rows select_limit; Item::cond_result cond_value; SQL_SELECT *select; From 3f355523ba3e9eb814bbd37c0092755330fd2db9 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 21 Nov 2003 00:03:04 +0300 Subject: [PATCH 14/47] fix for bug #1790: "BIT_AND() result in GROUP BY different when SQL_BIG_RESULT used" return value of BIT_AND changed to BIGINT SIGNED Also the patch fixes another bug: when temporary table is in use and one of values in group is NULL, BIT_AND always returns zero. Fixed it to always skip null values. mysql-test/r/func_group.result: bug #1790: test results fixed sql/item_sum.cc: fix for bug #1790: update_field() rewritten to use add() and thus was moved to Item_sum_bit::update_field() Item_sum_bit::reset_field() was rewritten to take into account reset_bits. sql/item_sum.h: fix for bug #1790: Item_sum::update_field() and Item_sum::reset_field() commented Item_sum_and changed to return BIGINT SIGNED Item_sum_and::update_field() and Item_sum_or::update_field) were replaced with generic Item_sum_bit::update_field() --- mysql-test/r/func_group.result | 14 ++++++------- sql/item_sum.cc | 36 ++++++++++++---------------------- sql/item_sum.h | 22 ++++++++++++++++----- 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index 80ccb6c7bb8..a1563271917 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -47,7 +47,7 @@ sum(all a) count(all a) avg(all a) std(all a) bit_or(all a) bit_and(all a) min(a 21 6 3.5000 1.7078 7 0 1 6 E select grp, sum(a),count(a),avg(a),std(a),bit_or(a),bit_and(a),min(a),max(a),min(c),max(c) from t1 group by grp; grp sum(a) count(a) avg(a) std(a) bit_or(a) bit_and(a) min(a) max(a) min(c) max(c) -NULL NULL 0 NULL NULL 0 0 NULL NULL +NULL NULL 0 NULL NULL 0 -1 NULL NULL 1 1 1 1.0000 0.0000 1 1 1 1 a a 2 5 2 2.5000 0.5000 3 2 2 3 b c 3 15 3 5.0000 0.8165 7 4 4 6 C E @@ -218,8 +218,8 @@ insert into t1 values (1,null); insert into t1 values (2,null); select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a; a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) -1 0 NULL NULL NULL NULL NULL 0 0 -2 0 NULL NULL NULL NULL NULL 0 0 +1 0 NULL NULL NULL NULL NULL -1 0 +2 0 NULL NULL NULL NULL NULL -1 0 select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a; a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) 1 0 NULL NULL NULL NULL NULL -1 0 @@ -227,8 +227,8 @@ a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) insert into t1 values (2,1); select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a; a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) -1 0 NULL NULL NULL NULL NULL 0 0 -2 1 1 1.0000 0.0000 1 1 0 1 +1 0 NULL NULL NULL NULL NULL -1 0 +2 1 1 1.0000 0.0000 1 1 1 1 select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a; a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) 1 0 NULL NULL NULL NULL NULL -1 0 @@ -236,8 +236,8 @@ a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) insert into t1 values (3,1); select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a; a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) -1 0 NULL NULL NULL NULL NULL 0 0 -2 1 1 1.0000 0.0000 1 1 0 1 +1 0 NULL NULL NULL NULL NULL -1 0 +2 1 1 1.0000 0.0000 1 1 1 1 3 1 1 1.0000 0.0000 1 1 1 1 select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a; a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 835278ae262..36a3c6b009b 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -614,10 +614,19 @@ void Item_sum_avg::reset_field() } void Item_sum_bit::reset_field() +{ + char *res= result_field->ptr; + bits= reset_bits; + add(); + int8store(res, bits); +} + +void Item_sum_bit::update_field() { char *res=result_field->ptr; - ulonglong nr=(ulonglong) args[0]->val_int(); - int8store(res,nr); + bits= uint8korr(res); + add(); + int8store(res, bits); } /* @@ -756,28 +765,6 @@ Item_sum_hybrid::min_max_update_int_field() } -void Item_sum_or::update_field() -{ - ulonglong nr; - char *res=result_field->ptr; - - nr=uint8korr(res); - nr|= (ulonglong) args[0]->val_int(); - int8store(res,nr); -} - - -void Item_sum_and::update_field() -{ - ulonglong nr; - char *res=result_field->ptr; - - nr=uint8korr(res); - nr&= (ulonglong) args[0]->val_int(); - int8store(res,nr); -} - - Item_avg_field::Item_avg_field(Item_sum_avg *item) { name=item->name; @@ -787,6 +774,7 @@ Item_avg_field::Item_avg_field(Item_sum_avg *item) maybe_null=1; } + double Item_avg_field::val() { double nr; diff --git a/sql/item_sum.h b/sql/item_sum.h index 5189566fdfb..c91abbded28 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -55,7 +55,18 @@ public: virtual enum Sumfunctype sum_func () const=0; virtual void reset()=0; virtual bool add()=0; + /* + Called when new group is started and results are being saved in + a temporary table. Similar to reset(), but must also store value in + result_field. Like reset() it is supposed to reset start value to + default. + */ virtual void reset_field()=0; + /* + Called for each new value in the group, when temporary table is in use. + Similar to add(), but uses temporary table field to obtain current value, + Updated value is then saved in the field. + */ virtual void update_field()=0; virtual bool keep_field_type(void) const { return 0; } virtual void fix_length_and_dec() { maybe_null=1; null_value=1; } @@ -360,20 +371,20 @@ class Item_sum_bit :public Item_sum_int void reset(); longlong val_int(); void reset_field(); + void update_field(); unsigned int size_of() { return sizeof(*this);} - void fix_length_and_dec() - { decimals=0; max_length=21; unsigned_flag=1; maybe_null=null_value=0; } }; class Item_sum_or :public Item_sum_bit { - public: +public: Item_sum_or(Item *item_par) :Item_sum_bit(item_par,LL(0)) {} bool add(); - void update_field(); const char *func_name() const { return "bit_or"; } unsigned int size_of() { return sizeof(*this);} + void fix_length_and_dec() + { decimals=0; max_length=21; unsigned_flag=1; maybe_null=null_value=0; } }; @@ -382,9 +393,10 @@ class Item_sum_and :public Item_sum_bit public: Item_sum_and(Item *item_par) :Item_sum_bit(item_par, ~(ulonglong) LL(0)) {} bool add(); - void update_field(); const char *func_name() const { return "bit_and"; } unsigned int size_of() { return sizeof(*this);} + void fix_length_and_dec() + { decimals=0; max_length=21; unsigned_flag=0; maybe_null=null_value=0; } }; /* From b6bbbf0832513e96ae8c476066bf7fd6e1e593a7 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 20 Nov 2003 22:20:54 +0100 Subject: [PATCH 15/47] more left join tests --- mysql-test/r/fulltext_left_join.result | 8 ++++++++ mysql-test/t/fulltext_left_join.test | 2 ++ 2 files changed, 10 insertions(+) diff --git a/mysql-test/r/fulltext_left_join.result b/mysql-test/r/fulltext_left_join.result index 6875a517718..d215ea0cea8 100644 --- a/mysql-test/r/fulltext_left_join.result +++ b/mysql-test/r/fulltext_left_join.result @@ -41,4 +41,12 @@ venue_id venue_text dt name entity_id select * from t1 left join t2 on venue_id = entity_id where match(name) against('aberdeen') and dt = '2003-05-23 19:30:00'; venue_id venue_text dt name entity_id 1 a1 2003-05-23 19:30:00 aberdeen town hall 1 +select * from t1 left join t2 on (venue_id = entity_id and match(name) against('aberdeen' in boolean mode)) where dt = '2003-05-23 19:30:00'; +venue_id venue_text dt name entity_id +1 a1 2003-05-23 19:30:00 aberdeen town hall 1 +NULL a2 2003-05-23 19:30:00 NULL NULL +select * from t1 left join t2 on (venue_id = entity_id and match(name) against('aberdeen')) where dt = '2003-05-23 19:30:00'; +venue_id venue_text dt name entity_id +1 a1 2003-05-23 19:30:00 aberdeen town hall 1 +NULL a2 2003-05-23 19:30:00 NULL NULL drop table t1,t2; diff --git a/mysql-test/t/fulltext_left_join.test b/mysql-test/t/fulltext_left_join.test index da4df13bc0c..a785cc6a61c 100644 --- a/mysql-test/t/fulltext_left_join.test +++ b/mysql-test/t/fulltext_left_join.test @@ -38,5 +38,7 @@ create table t2 (name varchar(255) not null default '', entity_id int(11) not nu insert into t2 (name, entity_id) values ('aberdeen town hall', 1), ('glasgow royal concert hall', 2), ('queen\'s hall, edinburgh', 3); select * from t1 left join t2 on venue_id = entity_id where match(name) against('aberdeen' in boolean mode) and dt = '2003-05-23 19:30:00'; select * from t1 left join t2 on venue_id = entity_id where match(name) against('aberdeen') and dt = '2003-05-23 19:30:00'; +select * from t1 left join t2 on (venue_id = entity_id and match(name) against('aberdeen' in boolean mode)) where dt = '2003-05-23 19:30:00'; +select * from t1 left join t2 on (venue_id = entity_id and match(name) against('aberdeen')) where dt = '2003-05-23 19:30:00'; drop table t1,t2; From 7c6ed734438fe7f473c045f89ae8d2b1dce8c4b6 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 21 Nov 2003 00:11:50 +0200 Subject: [PATCH 16/47] Revert patch for bigint handling in double context as it broke normal bigint handling The right way to fix this is to change the Field::store(longlong) method to be Field::store(longlong, bool unsigned_flag), but this is better to do in 4.1 than in 4.0 mysql-test/r/bigint.result: New tests to show how the last bigint patch broke MySQL mysql-test/t/bigint.test: New tests to show how the last bigint patch broke MySQL sql/item.cc: Revert patch for bigint handling in double context as it broke normal bigint handling sql/item.h: Revert patch for bigint handling in double context as it broke normal bigint handling --- mysql-test/r/bigint.result | 8 +++++++- mysql-test/t/bigint.test | 4 +++- sql/item.cc | 12 ------------ sql/item.h | 1 - 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/mysql-test/r/bigint.result b/mysql-test/r/bigint.result index 2b595c2b83d..308adc881f2 100644 --- a/mysql-test/r/bigint.result +++ b/mysql-test/r/bigint.result @@ -15,9 +15,11 @@ select 9223372036854775808+1; 9223372036854775809 drop table if exists t1; create table t1 (a bigint unsigned not null, primary key(a)); -insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE); +insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE), (18446744073709551613), (18446744073709551612); select * from t1; a +18446744073709551612 +18446744073709551613 18446744073709551614 18446744073709551615 select * from t1 where a=18446744073709551615; @@ -26,6 +28,8 @@ a delete from t1 where a=18446744073709551615; select * from t1; a +18446744073709551612 +18446744073709551613 18446744073709551614 drop table t1; create table t1 ( a int not null default 1, big bigint ); @@ -69,9 +73,11 @@ id a drop table t1; CREATE TABLE t1 ( quantity decimal(60,0)); insert into t1 values (10000000000000000000); +insert into t1 values (10000000000000000000.0); insert into t1 values ('10000000000000000000'); select * from t1; quantity +-8446744073709551616 10000000000000000000 10000000000000000000 drop table t1; diff --git a/mysql-test/t/bigint.test b/mysql-test/t/bigint.test index a7cc068ec46..f21f821e45c 100644 --- a/mysql-test/t/bigint.test +++ b/mysql-test/t/bigint.test @@ -14,7 +14,7 @@ select 9223372036854775808+1; drop table if exists t1; create table t1 (a bigint unsigned not null, primary key(a)); -insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE); +insert into t1 values (18446744073709551615), (0xFFFFFFFFFFFFFFFE), (18446744073709551613), (18446744073709551612); select * from t1; select * from t1 where a=18446744073709551615; # select * from t1 where a='18446744073709551615'; @@ -50,10 +50,12 @@ drop table t1; # # Item_uint::save_to_field() # BUG#1845 +# This can't be fixed in MySQL 4.0 without loosing precisions for bigints # CREATE TABLE t1 ( quantity decimal(60,0)); insert into t1 values (10000000000000000000); +insert into t1 values (10000000000000000000.0); insert into t1 values ('10000000000000000000'); select * from t1; drop table t1; diff --git a/sql/item.cc b/sql/item.cc index 65eb7f1befd..fc6256d4fed 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -548,18 +548,6 @@ bool Item_string::save_in_field(Field *field, bool no_conversions) return 0; } -bool Item_uint::save_in_field(Field *field, bool no_conversions) -{ - longlong nr=val_int(); - if (null_value) - return set_field_to_null(field); - field->set_notnull(); - if (nr < 0) - field->store(ulonglong2double(nr)); - else - field->store(nr); - return 0; -} bool Item_int::save_in_field(Field *field, bool no_conversions) { diff --git a/sql/item.h b/sql/item.h index d23a061eedb..e8a6313b6a0 100644 --- a/sql/item.h +++ b/sql/item.h @@ -232,7 +232,6 @@ public: String *val_str(String*); void make_field(Send_field *field); Item *new_item() { return new Item_uint(name,max_length); } - bool save_in_field(Field *field, bool no_conversions); bool fix_fields(THD *thd,struct st_table_list *table_list) { unsigned_flag= 1; From 722a4cc5d6d61d25d8c0d24ad237e414b1ac76b1 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 20 Nov 2003 23:15:07 +0100 Subject: [PATCH 17/47] yet another trunc* bug --- myisam/ft_boolean_search.c | 53 ++++++++++++++++++++++-------------- mysql-test/r/fulltext.result | 3 ++ mysql-test/t/fulltext.test | 1 + 3 files changed, 37 insertions(+), 20 deletions(-) diff --git a/myisam/ft_boolean_search.c b/myisam/ft_boolean_search.c index 72c54bd0c5b..30b52a20060 100644 --- a/myisam/ft_boolean_search.c +++ b/myisam/ft_boolean_search.c @@ -62,11 +62,12 @@ typedef struct st_ftb_expr FTB_EXPR; struct st_ftb_expr { FTB_EXPR *up; - byte *quot, *qend; float weight; uint flags; - my_off_t docid[2]; /* for index search and for scan */ + my_off_t docid[2]; +/* ^^^^^^^^^^^^^^^^^^ FTB_{EXPR,WORD} common section */ float cur_weight; + byte *quot, *qend; int yesses; /* number of "yes" words matched */ int nos; /* number of "no" words matched */ int ythresh; /* number of "yes" words in expr */ @@ -78,7 +79,8 @@ typedef struct st_ftb_word FTB_EXPR *up; float weight; uint flags; - my_off_t docid[2]; /* for index search and for scan */ + my_off_t docid[2]; +/* ^^^^^^^^^^^^^^^^^^ FTB_{EXPR,WORD} common section */ uint ndepth; int len; /* ... docid cache can be added here. SerG */ @@ -217,13 +219,15 @@ static void _ftb_init_index_search(FT_INFO *ftb) if (ftbw->flags & FTB_FLAG_TRUNC) { /* - special treatment for truncation operator :(( - 1. +trunc* and there're other (not +trunc*) words + special treatment for truncation operator + 1. there are some (besides this) +words | no need to search in the index, it can never ADD new rows | to the result, and to remove half-matched rows we do scan anyway 2. -trunc* | same as 1. - 3. trunc* + 3. in 1 and 2, +/- need not be on the same expr. level, + but can be on any upper level, as in +word +(trunc1* trunc2*) + 4. otherwise | We have to index-search for this prefix. | It may cause duplicates, as in the index (sorted by ) | @@ -231,22 +235,31 @@ static void _ftb_init_index_search(FT_INFO *ftb) | | Searching for "aa*" will find row1 twice... */ - if ( test(ftbw->flags&FTB_FLAG_NO) || /* 2 */ - (test(ftbw->flags&FTB_FLAG_YES) && /* 1 */ - ftbw->up->ythresh - ftbw->up->yweaks >1)) /* 1 */ + FTB_EXPR *ftbe; + for (ftbe=(FTB_EXPR*)ftbw; + ftbe->up && !(ftbe->up->flags & FTB_FLAG_TRUNC); + ftbe->up->flags|= FTB_FLAG_TRUNC, ftbe=ftbe->up) { - ftbw->docid[0]=HA_POS_ERROR; - ftbw->up->yweaks++; + if (ftbe->flags & FTB_FLAG_NO || /* 2 */ + ftbe->up->ythresh - ftbe->up->yweaks >1) /* 1 */ + { + FTB_EXPR *top_ftbe=ftbe->up->up; + ftbw->docid[0]=HA_POS_ERROR; + for (ftbe=ftbw->up; ftbe != top_ftbe; ftbe=ftbe->up) + if (ftbe->flags & FTB_FLAG_YES) + ftbe->yweaks++; + ftbe=0; + break; + } + } + if (!ftbe) continue; - } - else /* 3 */ - { - if (!is_tree_inited(& ftb->no_dupes)) - init_tree(& ftb->no_dupes,0,0,sizeof(my_off_t), - _ftb_no_dupes_cmp,0,0,0); - else - reset_tree(& ftb->no_dupes); - } + /* 3 */ + if (!is_tree_inited(& ftb->no_dupes)) + init_tree(& ftb->no_dupes,0,0,sizeof(my_off_t), + _ftb_no_dupes_cmp,0,0,0); + else + reset_tree(& ftb->no_dupes); } r=_mi_search(info, keyinfo, (uchar*) ftbw->word, ftbw->len, SEARCH_FIND | SEARCH_BIGGER, keyroot); diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result index bd5d7c2a6ac..e8ae9d3063f 100644 --- a/mysql-test/r/fulltext.result +++ b/mysql-test/r/fulltext.result @@ -147,6 +147,9 @@ aaa20 bbb15 aaa30 bbb10 select * from t1 where match a against ("+aaa* +ccc*" in boolean mode); a +select * from t1 where match a against ("+aaa10 +(bbb*)" in boolean mode); +a +aaa10 bbb20 drop table t1; CREATE TABLE t1 ( id int(11), diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test index 567fae069a1..e8f5d497692 100644 --- a/mysql-test/t/fulltext.test +++ b/mysql-test/t/fulltext.test @@ -78,6 +78,7 @@ insert t1 values ("aaa10 bbb20"), ("aaa20 bbb15"), ("aaa30 bbb10"); select * from t1 where match a against ("+aaa* +bbb*" in boolean mode); select * from t1 where match a against ("+aaa* +bbb1*" in boolean mode); select * from t1 where match a against ("+aaa* +ccc*" in boolean mode); +select * from t1 where match a against ("+aaa10 +(bbb*)" in boolean mode); drop table t1; # From 9c5fb81fc0712c5a2e26197e5cfc84a7694394e1 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 21 Nov 2003 13:22:49 +0100 Subject: [PATCH 18/47] - removed dependency on MySQL-client from the MySQL-devel RPM subpackage as it is not really required. (BUG 1610) Thanks to Scott Harrison for the suggestion. support-files/mysql.spec.sh: - removed dependency on MySQL-client from the MySQL-devel subpackage as it is not really required. (BUG 1610) --- support-files/mysql.spec.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index ffc74c7559d..974a3bde36a 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -120,7 +120,6 @@ Este pacote cont %package devel Release: %{release} -Requires: %{name}-client Summary: MySQL - Development header files and libraries Group: Applications/Databases Summary(pt_BR): MySQL - Medições de desempenho @@ -568,6 +567,11 @@ fi # The spec file changelog only includes changes made to the spec file # itself %changelog +* Fri Nov 21 2003 Lenz Grimmer + +- removed dependency on MySQL-client from the MySQL-devel subpackage + as it is not really required. (BUG 1610) + * Fri Aug 29 2003 Lenz Grimmer - Fixed BUG 1162 (removed macro names from the changelog) From c61d96d5baf8bb1d11502552a24cfca743e41419 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 23 Nov 2003 21:03:10 +0200 Subject: [PATCH 19/47] Fix test for binary builds mysql-test/r/rpl_change_master.result: Updated results --- mysql-test/r/rpl_change_master.result | 6 +++--- mysql-test/t/rpl_change_master.test | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/rpl_change_master.result b/mysql-test/r/rpl_change_master.result index be2aec616b0..966f07af9d5 100644 --- a/mysql-test/r/rpl_change_master.result +++ b/mysql-test/r/rpl_change_master.result @@ -8,7 +8,7 @@ select get_lock("a",5); get_lock("a",5) 1 create table t1(n int); -insert into t1 values(1+get_lock("a",10)*0); +insert into t1 values(1+get_lock("a",15)*0); insert into t1 values(2); stop slave; select * from t1; @@ -16,11 +16,11 @@ n 1 show slave status; Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space -127.0.0.1 root 9306 1 master-bin.001 273 slave-relay-bin.002 255 master-bin.001 No No 0 0 214 314 +127.0.0.1 root MASTER_MYPORT 1 master-bin.001 273 slave-relay-bin.002 255 master-bin.001 No No 0 0 214 314 change master to master_user='root'; show slave status; Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space -127.0.0.1 root 9306 1 master-bin.001 214 slave-relay-bin.001 4 master-bin.001 No No 0 0 214 4 +127.0.0.1 root MASTER_MYPORT 1 master-bin.001 214 slave-relay-bin.001 4 master-bin.001 No No 0 0 214 4 select release_lock("a"); release_lock("a") 1 diff --git a/mysql-test/t/rpl_change_master.test b/mysql-test/t/rpl_change_master.test index 61de22fe57b..a13e045cf48 100644 --- a/mysql-test/t/rpl_change_master.test +++ b/mysql-test/t/rpl_change_master.test @@ -4,15 +4,17 @@ connection slave; select get_lock("a",5); connection master; create table t1(n int); -insert into t1 values(1+get_lock("a",10)*0); +insert into t1 values(1+get_lock("a",15)*0); insert into t1 values(2); save_master_pos; connection slave; -sleep 3; # can't sync_with_master as we should be blocked +--real_sleep 3; # can't sync_with_master as we should be blocked stop slave; select * from t1; +--replace_result $MASTER_MYPORT MASTER_MYPORT show slave status; change master to master_user='root'; +--replace_result $MASTER_MYPORT MASTER_MYPORT show slave status; # Will restart from after the values(2), which is bug select release_lock("a"); From d8e425c240b01f263dd8cd8431e32e8ba9539b43 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 24 Nov 2003 13:57:49 +0400 Subject: [PATCH 20/47] Fix for bug #1855: mysqld crashes with certain SSL connections --- sql/sql_acl.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 065394c87d0..03a359d44e7 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -588,6 +588,11 @@ ulong acl_getroot(THD *thd, const char *host, const char *ip, const char *user, /* Prepare certificate (if exists) */ DBUG_PRINT("info",("checkpoint 1")); X509* cert=SSL_get_peer_certificate(ssl); + if (!cert) + { + user_access=NO_ACCESS; + break; + } DBUG_PRINT("info",("checkpoint 2")); /* If X509 issuer is speified, we check it... */ if (acl_user->x509_issuer) From 5281f34e6471af78526860442a2e38a07845e27f Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 24 Nov 2003 13:25:08 +0200 Subject: [PATCH 21/47] Fixed Bug#1907, option of type GET_BOOL with arg type OPT_ARG did not call get_one_option(). --- mysys/my_getopt.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 5644d81837d..662e33a3a5a 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -316,8 +316,6 @@ int handle_options(int *argc, char ***argv, else /* If argument differs from 0, enable option, else disable */ *((my_bool*) optp->value)= (my_bool) atoi(optend) != 0; } - (*argc)--; - continue; } else if (optp->arg_type == REQUIRED_ARG && !optend) { From 534ea9689face130dc8f64c2ed600b5956990333 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 24 Nov 2003 17:05:24 +0100 Subject: [PATCH 22/47] - Rephrased two option help texts to not start with "use the ..." as this confuses RPM's Perl module dependency checking (it adds a bogus requirement to "Perl(the)", as "use" is a Perl keyword). (BUG#1931) scripts/mysqlaccess.sh: - Rephrased option help text so it does not start with "use" as this confuses RPM's Perl module dependency checking (it adds a bogus requirement to "Perl(the)", as "use" is a Perl keyword). (BUG#1931) sql-bench/bench-init.pl.sh: - Rephrased option help text so it does not start with "use" as this confuses RPM's Perl module dependency checking (it adds a bogus requirement to "Perl(the)", as "use" is a Perl keyword). (BUG#1931) --- scripts/mysqlaccess.sh | 2 +- sql-bench/bench-init.pl.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/mysqlaccess.sh b/scripts/mysqlaccess.sh index 699e74834e3..75ef63ecdd0 100644 --- a/scripts/mysqlaccess.sh +++ b/scripts/mysqlaccess.sh @@ -286,7 +286,7 @@ Release Notes: * --old_server: mysqlaccess will now use a full where clause when retrieving information from the MySQL-server. If you are connecting to an old server (before v3.21) - use the option --old_server. + then use the option --old_server. 2.03 : (1998-02-27) - bugfix: * in Host::MatchTemplate: incorrect match if host-field was left empty. diff --git a/sql-bench/bench-init.pl.sh b/sql-bench/bench-init.pl.sh index 1ac5f29723b..d61551ffb3b 100644 --- a/sql-bench/bench-init.pl.sh +++ b/sql-bench/bench-init.pl.sh @@ -509,7 +509,7 @@ All benchmarks takes the following options: --socket='socket' If the database supports connecting through a Unix socket, - use this socket to connect + then use this socket to connect --regions This is a test specific option that is only used when debugging a test. From ea280fd3ff1ab19370fba66e7f001351f8a23413 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 25 Nov 2003 17:52:12 +0100 Subject: [PATCH 23/47] - Removed COPYING.LIB from all source and binary distributions after it was removed from manual.texi (where it was automatically generated from). Docs/Makefile.am: - don't create COPYING.LIB anymore (was removed from manual.texi) Makefile.am: - Removed COPYING.LIB from the source distribution scripts/make_binary_distribution.sh: - Removed COPYING.LIB from the binary distribution scripts/make_win_src_distribution.sh: - Removed COPYING.LIB from the windows source distribution support-files/mysql.spec.sh: - Removed COPYING.LIB from the Server RPM --- Docs/Makefile.am | 3 --- Makefile.am | 3 +-- scripts/make_binary_distribution.sh | 2 +- scripts/make_win_src_distribution.sh | 2 +- support-files/mysql.spec.sh | 2 +- 5 files changed, 4 insertions(+), 8 deletions(-) diff --git a/Docs/Makefile.am b/Docs/Makefile.am index 07dac2d9df1..bf7aaa747e3 100644 --- a/Docs/Makefile.am +++ b/Docs/Makefile.am @@ -204,9 +204,6 @@ INSTALL-BINARY: mysql.info $(GT) ../COPYING: mysql.info $(GT) perl -w $(GT) mysql.info "GPL license" "LGPL license" > $@ -../COPYING.LIB: mysql.info $(GT) - perl -w $(GT) mysql.info "LGPL license" "Function Index" > $@ - ../support-files/MacOSX/ReadMe.txt: mysql.info $(GT) perl -w $(GT) mysql.info "Mac OS X installation" "NetWare installation" > $@ diff --git a/Makefile.am b/Makefile.am index b9e0e88ff77..8aef19d0920 100644 --- a/Makefile.am +++ b/Makefile.am @@ -19,8 +19,7 @@ AUTOMAKE_OPTIONS = foreign # These are built from source in the Docs directory -EXTRA_DIST = INSTALL-SOURCE README \ - COPYING COPYING.LIB +EXTRA_DIST = INSTALL-SOURCE README COPYING SUBDIRS = . include @docs_dirs@ @readline_dir@ \ @thread_dirs@ pstack @sql_client_dirs@ \ @sql_server_dirs@ scripts man tests \ diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh index 8735fc800ce..300fc4a7020 100644 --- a/scripts/make_binary_distribution.sh +++ b/scripts/make_binary_distribution.sh @@ -85,7 +85,7 @@ do fi done -for i in COPYING COPYING.LIB README Docs/INSTALL-BINARY \ +for i in COPYING README Docs/INSTALL-BINARY \ MySQLEULA.txt LICENSE.doc README.NW do if [ -f $i ] diff --git a/scripts/make_win_src_distribution.sh b/scripts/make_win_src_distribution.sh index c521c4cfdcb..3556b00cbc7 100755 --- a/scripts/make_win_src_distribution.sh +++ b/scripts/make_win_src_distribution.sh @@ -282,7 +282,7 @@ touch $BASE/innobase/ib_config.h # cd $SOURCE -for i in COPYING COPYING.LIB ChangeLog README \ +for i in COPYING ChangeLog README \ INSTALL-SOURCE INSTALL-WIN \ INSTALL-WIN-SOURCE \ Docs/manual_toc.html Docs/manual.html \ diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 974a3bde36a..658b90d1a3f 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -444,7 +444,7 @@ fi %files server %defattr(755 root, root) -%doc %attr(644, root, root) COPYING COPYING.LIB README +%doc %attr(644, root, root) COPYING README %doc %attr(644, root, root) Docs/manual.{html,ps,texi,txt} Docs/manual_toc.html %doc %attr(644, root, root) support-files/my-*.cnf From 89bb913bbaa73660e6e469bc350ba65bc70f643d Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 25 Nov 2003 19:11:59 +0100 Subject: [PATCH 24/47] - Removed COPYING.LIB from txt_files target in Docs/Makefile.am Docs/Makefile.am: - Removed COPYING.LIB from txt_files target --- Docs/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Docs/Makefile.am b/Docs/Makefile.am index bf7aaa747e3..ff2b4fa4530 100644 --- a/Docs/Makefile.am +++ b/Docs/Makefile.am @@ -26,7 +26,7 @@ EXTRA_DIST = $(noinst_SCRIPTS) $(BUILT_SOURCES) mysqld_error.txt \ all: $(targets) txt_files -txt_files: ../INSTALL-SOURCE ../COPYING ../COPYING.LIB \ +txt_files: ../INSTALL-SOURCE ../COPYING \ INSTALL-BINARY ../support-files/MacOSX/ReadMe.txt CLEAN_FILES: $(BUILD_SOURCES) From 6413b0e945d128cbfbbd087b0a02707ed6a9551f Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 25 Nov 2003 19:19:20 +0100 Subject: [PATCH 25/47] - Fixed missing node name --- Docs/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Docs/Makefile.am b/Docs/Makefile.am index ff2b4fa4530..9a77202a91b 100644 --- a/Docs/Makefile.am +++ b/Docs/Makefile.am @@ -202,7 +202,7 @@ INSTALL-BINARY: mysql.info $(GT) perl -w $(GT) mysql.info "Installing binary" "Installing source" > $@ ../COPYING: mysql.info $(GT) - perl -w $(GT) mysql.info "GPL license" "LGPL license" > $@ + perl -w $(GT) mysql.info "GPL license" "Function Index" > $@ ../support-files/MacOSX/ReadMe.txt: mysql.info $(GT) perl -w $(GT) mysql.info "Mac OS X installation" "NetWare installation" > $@ From fa9047e280de35122bde867a19da1f9ec1297b10 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 26 Nov 2003 03:30:00 +0200 Subject: [PATCH 26/47] Added compilation comment to 'show variables' This makes it possible to check origin of binary from the output of 'show variables' include/mysql_version.h.in: Added MYSQL_COMPILATION_COMMENT sql/mysqld.cc: Added compilation comment to mysqld --version sql/set_var.cc: Added compilation comment to 'show variables' --- include/mysql_version.h.in | 1 + sql/mysqld.cc | 4 ++-- sql/set_var.cc | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/mysql_version.h.in b/include/mysql_version.h.in index da184665f6e..41d4ce081fb 100644 --- a/include/mysql_version.h.in +++ b/include/mysql_version.h.in @@ -19,6 +19,7 @@ #define MYSQL_PORT @MYSQL_TCP_PORT@ #define MYSQL_UNIX_ADDR "@MYSQL_UNIX_ADDR@" #define MYSQL_CONFIG_NAME "my" +#define MYSQL_COMPILATION_COMMENT "@COMPILATION_COMMENT@" /* mysqld compile time options */ #ifndef MYSQL_CHARSET diff --git a/sql/mysqld.cc b/sql/mysqld.cc index e5ddbfe7a33..4c6cf1d5039 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -4278,8 +4278,8 @@ struct show_var_st status_vars[]= { static void print_version(void) { - printf("%s Ver %s for %s on %s\n",my_progname, - server_version,SYSTEM_TYPE,MACHINE_TYPE); + printf("%s Ver %s for %s on %s (%s)\n",my_progname, + server_version,SYSTEM_TYPE,MACHINE_TYPE, MYSQL_COMPILATION_COMMENT); } static void use_help(void) diff --git a/sql/set_var.cc b/sql/set_var.cc index 03651967a7a..4aea611e401 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -593,6 +593,7 @@ struct show_var_st init_vars[]= { SHOW_SYS}, {sys_trans_prealloc_size.name, (char*) &sys_trans_prealloc_size, SHOW_SYS}, {"version", server_version, SHOW_CHAR}, + {"version_comment", (char*) MYSQL_COMPILATION_COMMENT, SHOW_CHAR}, {sys_net_wait_timeout.name, (char*) &sys_net_wait_timeout, SHOW_SYS}, {NullS, NullS, SHOW_LONG} }; From b5907ec1925c2c8f557c3159071851edd3bc0c16 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 28 Nov 2003 01:54:34 +0300 Subject: [PATCH 27/47] cleanup: no need to set rpl_parse, rpl_probe and rpl_pivot to zero as whole mysql structure is bzeroed in mysql_init(0) few lines before --- libmysql/libmysql.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 5d809adf36a..d5fe2cddc48 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -2276,8 +2276,6 @@ static MYSQL* spawn_init(MYSQL* parent, const char* host, else if (parent->options.db) child->options.db = my_strdup(parent->options.db, MYF(0)); - child->options.rpl_parse = child->options.rpl_probe = child->rpl_pivot = 0; - return child; } From 047f64677059028695d684e6fb368077c8db50b5 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 28 Nov 2003 01:57:05 +0300 Subject: [PATCH 28/47] no need to zero-initialize mysql->master->{rpl_pivot, options.rpl_parse, options.rpl_probe} as they are zero-initialized in spawn_init() --- libmysql/libmysql.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index d5fe2cddc48..0c9c68f4505 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -2289,9 +2289,6 @@ STDCALL mysql_set_master(MYSQL* mysql, const char* host, mysql_close(mysql->master); if (!(mysql->master = spawn_init(mysql, host, port, user, passwd))) return 1; - mysql->master->rpl_pivot = 0; - mysql->master->options.rpl_parse = 0; - mysql->master->options.rpl_probe = 0; return 0; } From 931f7a3566cba62bbe17a81ade6b1601ef3dd524 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 28 Nov 2003 12:36:45 +0100 Subject: [PATCH 29/47] bug #1945. item(expression)->name=0, crash in find_item_in_list --- mysql-test/r/order_by.result | 4 ++++ mysql-test/t/order_by.test | 8 ++++++++ sql/sql_base.cc | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result index 076c80035b2..093633d5f5a 100644 --- a/mysql-test/r/order_by.result +++ b/mysql-test/r/order_by.result @@ -542,3 +542,7 @@ a b 1 2 5 NULL DROP TABLE t1; +CREATE TABLE t1 (a INT, b INT); +SET @id=0; +UPDATE t1 SET a=0 ORDER BY (a=@id), b; +DROP TABLE t1; diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test index 1fb83509ebb..8215ec84ae3 100644 --- a/mysql-test/t/order_by.test +++ b/mysql-test/t/order_by.test @@ -345,3 +345,11 @@ SELECT * FROM t1 ORDER BY (a + b); SELECT * FROM t1 ORDER BY (a + b) DESC; DROP TABLE t1; +# +# Bug #1945 - Crashing bug with bad User Variables in UPDATE ... ORDER BY ... +# +CREATE TABLE t1 (a INT, b INT); +SET @id=0; +UPDATE t1 SET a=0 ORDER BY (a=@id), b; +DROP TABLE t1; + diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 47529b90b67..e4694adb9a2 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1837,7 +1837,7 @@ find_item_in_list(Item *find,List &items) } } else if (!table_name && (item->eq(find,0) || - find->name && + find->name && item->name && !my_strcasecmp(item->name,find->name))) { found=li.ref(); From e5cc604eabf843f25fad2e8e91c4360416b72471 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 28 Nov 2003 15:45:34 +0200 Subject: [PATCH 30/47] Fixed range optimzier bug (Bug #1828) mysql-test/r/range.result: test for range optimzier bug mysql-test/t/range.test: test for range optimzier bug --- mysql-test/r/range.result | 10 ++++++++++ mysql-test/t/range.test | 13 ++++++++++++- sql/opt_range.cc | 2 +- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result index 68987009598..e87df9a6c24 100644 --- a/mysql-test/r/range.result +++ b/mysql-test/r/range.result @@ -290,3 +290,13 @@ t1 range a,b a 5 NULL 2 Using where SELECT * FROM t1 WHERE a IN(1,2) AND b=5; a b DROP TABLE t1; +CREATE TABLE t1 (a int, b int, c int, INDEX (c,a,b)); +INSERT INTO t1 VALUES (1,0,0),(1,0,0),(1,0,0); +INSERT INTO t1 VALUES (0,1,0),(0,1,0),(0,1,0); +SELECT COUNT(*) FROM t1 WHERE (c=0 and a=1) or (c=0 and b=1); +COUNT(*) +6 +SELECT COUNT(*) FROM t1 WHERE (c=0 and b=1) or (c=0 and a=1); +COUNT(*) +6 +DROP TABLE t1; diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test index e09fa73256b..364ea2d4195 100644 --- a/mysql-test/t/range.test +++ b/mysql-test/t/range.test @@ -231,9 +231,20 @@ INSERT INTO t1 VALUES (21,4),(22,5),(23,5),(24,5),(25,5),(26,5),(30,5),(31,5),(32,5),(33,5), (33,5),(33,5),(33,5),(33,5),(34,5),(35,5); +# we expect that optimizer will choose index on A EXPLAIN SELECT * FROM t1 WHERE a IN(1,2) AND b=5; SELECT * FROM t1 WHERE a IN(1,2) AND b=5; DROP TABLE t1; -# we expect that optimizer will choose index on A +# +# Test error with +# + +CREATE TABLE t1 (a int, b int, c int, INDEX (c,a,b)); +INSERT INTO t1 VALUES (1,0,0),(1,0,0),(1,0,0); +INSERT INTO t1 VALUES (0,1,0),(0,1,0),(0,1,0); +# -- First reports 3; second reports 6 +SELECT COUNT(*) FROM t1 WHERE (c=0 and a=1) or (c=0 and b=1); +SELECT COUNT(*) FROM t1 WHERE (c=0 and b=1) or (c=0 and a=1); +DROP TABLE t1; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index e932b2c46d6..63850709285 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -70,7 +70,7 @@ public: {} inline bool is_same(SEL_ARG *arg) { - if (type != arg->type) + if (type != arg->type || part != arg->part) return 0; if (type != KEY_RANGE) return 1; From 88d274c62f4318a92e762f4efcfa4024a8f49916 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 28 Nov 2003 18:15:58 +0100 Subject: [PATCH 31/47] "optimization cleanup" reverted - problems on rpl_redirect test. It happens that mysql->client_next->client_next=mysql and mysql_close() goes into infinite loop. Results vary from simple sigsegv (FreeBSD), to hard system lockup (Linux) :) --- libmysql/libmysql.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 0c9c68f4505..763288a5e83 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -2276,6 +2276,8 @@ static MYSQL* spawn_init(MYSQL* parent, const char* host, else if (parent->options.db) child->options.db = my_strdup(parent->options.db, MYF(0)); + child->options.rpl_parse = child->options.rpl_probe = child->rpl_pivot = 0; + return child; } From 13f525c080c787af562aa1dd7b60d74889e41378 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 28 Nov 2003 20:41:33 +0200 Subject: [PATCH 32/47] rpl_parse and rpl_probe don't have to be reset as they are already 0 --- libmysql/libmysql.c | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 763288a5e83..6abc29d29f4 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -2256,29 +2256,33 @@ static MYSQL* spawn_init(MYSQL* parent, const char* host, const char* passwd) { MYSQL* child; - if (!(child = mysql_init(0))) - return 0; + DBUG_ENTER("spawn_init"); + if (!(child= mysql_init(0))) + DBUG_RETURN(0); - child->options.user = my_strdup((user) ? user : - (parent->user ? parent->user : - parent->options.user), MYF(0)); - child->options.password = my_strdup((passwd) ? passwd : - (parent->passwd ? - parent->passwd : - parent->options.password), MYF(0)); - child->options.port = port; - child->options.host = my_strdup((host) ? host : - (parent->host ? - parent->host : - parent->options.host), MYF(0)); + child->options.user= my_strdup((user) ? user : + (parent->user ? parent->user : + parent->options.user), MYF(0)); + child->options.password= my_strdup((passwd) ? passwd : + (parent->passwd ? + parent->passwd : + parent->options.password), MYF(0)); + child->options.port= port; + child->options.host= my_strdup((host) ? host : + (parent->host ? + parent->host : + parent->options.host), MYF(0)); if (parent->db) - child->options.db = my_strdup(parent->db, MYF(0)); + child->options.db= my_strdup(parent->db, MYF(0)); else if (parent->options.db) - child->options.db = my_strdup(parent->options.db, MYF(0)); + child->options.db= my_strdup(parent->options.db, MYF(0)); - child->options.rpl_parse = child->options.rpl_probe = child->rpl_pivot = 0; - - return child; + /* + rpl_pivot is set to 1 in mysql_init(); Reset it as we are not doing + replication here + */ + child->rpl_pivot= 0; + DBUG_RETURN(child); } From 8764ca94c958e5556b4fd0125ea1cf41f8b7af6c Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 1 Dec 2003 14:59:35 +0100 Subject: [PATCH 33/47] Removing unneeded code: the Intvar_log_event constructor calls the Log_event constructor which does e.server_id=thd.server_id. sql/log.cc: unneeded: the Intvar_log_event constructor calls the Log_event constructor which does e.server_id=thd.server_id. --- sql/log.cc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/sql/log.cc b/sql/log.cc index 33ca82aa14f..e6eaa3b802c 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1110,8 +1110,6 @@ bool MYSQL_LOG::write(Log_event* event_info) Intvar_log_event e(thd,(uchar) LAST_INSERT_ID_EVENT, thd->current_insert_id); e.set_log_pos(this); - if (thd->server_id) - e.server_id = thd->server_id; if (e.write(file)) goto err; } @@ -1119,8 +1117,6 @@ bool MYSQL_LOG::write(Log_event* event_info) { Intvar_log_event e(thd,(uchar) INSERT_ID_EVENT,thd->last_insert_id); e.set_log_pos(this); - if (thd->server_id) - e.server_id = thd->server_id; if (e.write(file)) goto err; } From b9418600bf5d9ed110af1fe41f19c157b8f5dc8f Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 2 Dec 2003 16:49:46 +0100 Subject: [PATCH 34/47] There is no reason that Intvar_log_event's constructor calls Log_event::Log_event() instead of Log_event::Log_event(THD*, ...) when the event is built in the master to be written in the binlog. Rand_log_event already used the good constructor, so there really is no reason for Intvar_log_event to be an exception. This fixes a test failure of last night (which appeared after I removed a useless e.server_id=thd->server_id in log.cc; in fact this line was not useless because it hid the bad constructor). Replication tests pass, with Valgrind too. sql/log_event.h: There is no reason that Intvar_log_event's constructor calls Log_event::Log_event() instead of Log_event::Log_event(THD*, ...) when the event is built in the master to be written in the binlog. Rand_log_event already used the good constructor, so there really is no reason for Intvar_log_event to be an exception. This fixes a test failure of last night (which appeared after I removed a useless e.server_id=thd->server_id in log.cc; in fact this line was not useless because it hid the bad constructor). --- sql/log_event.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/log_event.h b/sql/log_event.h index 2e6b7373dc2..929d550951e 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -529,7 +529,7 @@ public: #ifndef MYSQL_CLIENT Intvar_log_event(THD* thd_arg,uchar type_arg, ulonglong val_arg) - :Log_event(),val(val_arg),type(type_arg) + :Log_event(thd_arg,0,0),val(val_arg),type(type_arg) {} void pack_info(String* packet); int exec_event(struct st_relay_log_info* rli); From a2bdd6218c7ed36bf245eb378fa3b128ebf266ce Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 2 Dec 2003 19:39:51 +0300 Subject: [PATCH 35/47] Post-review fixes for bug #1790 'BIT_AND() result in GROUP BY different when SQL_BIG_RESULT used': - BIT_AND now returns BIGINT UNSIGNED - in case there were no matching rows BIT_AND returns 18446744073709551615 (but not NULL), BIT_OR returns 0 (but not NULL). That's how Monty wants it and how is described in our docs. include/my_global.h: Added definition for ULONGLONG_MAX. This is also a check that ULL type specifier can be used on all supported platforms. mysql-test/r/func_group.result: bug #1790, post-review work: test results fixed sql/item_sum.cc: small cleanup sql/item_sum.h: few style fixes. BIT_AND and BIT_OR now are both BIGINT UNSIGNED --- include/my_global.h | 14 ++++++++++++++ mysql-test/r/func_group.result | 10 +++++----- sql/item_sum.cc | 6 ++---- sql/item_sum.h | 14 ++++++-------- 4 files changed, 27 insertions(+), 17 deletions(-) diff --git a/include/my_global.h b/include/my_global.h index 349ac8ac82e..68c331aa414 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -603,11 +603,25 @@ extern double my_atof(const char*); #define HAVE_LONG_LONG 1 #endif +/* + Some pre-ANSI-C99 systems like AIX 5.1 and Linux/GCC 2.95 define + ULONGLONG_MAX, LONGLONG_MIN, LONGLONG_MAX; we use them if they're defined. +*/ + #if defined(HAVE_LONG_LONG) && !defined(LONGLONG_MIN) #define LONGLONG_MIN ((long long) 0x8000000000000000LL) #define LONGLONG_MAX ((long long) 0x7FFFFFFFFFFFFFFFLL) #endif +#if defined(HAVE_LONG_LONG) && !defined(ULONLONG_MAX) +/* First check for ANSI C99 definition: */ +#ifdef ULLONG_MAX +#define ULONGLONG_MAX ULLONG_MAX +#else +#define ULONGLONG_MAX ((unsigned long long)(~0ULL)) +#endif +#endif /* defined (HAVE_LONG_LONG) && !defined(ULONLONG_MAX)*/ + #if SIZEOF_LONG == 4 #define INT_MIN32 (long) 0x80000000L #define INT_MAX32 (long) 0x7FFFFFFFL diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index a1563271917..f6a30813bb0 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -47,7 +47,7 @@ sum(all a) count(all a) avg(all a) std(all a) bit_or(all a) bit_and(all a) min(a 21 6 3.5000 1.7078 7 0 1 6 E select grp, sum(a),count(a),avg(a),std(a),bit_or(a),bit_and(a),min(a),max(a),min(c),max(c) from t1 group by grp; grp sum(a) count(a) avg(a) std(a) bit_or(a) bit_and(a) min(a) max(a) min(c) max(c) -NULL NULL 0 NULL NULL 0 -1 NULL NULL +NULL NULL 0 NULL NULL 0 18446744073709551615 NULL NULL 1 1 1 1.0000 0.0000 1 1 1 1 a a 2 5 2 2.5000 0.5000 3 2 2 3 b c 3 15 3 5.0000 0.8165 7 4 4 6 C E @@ -218,8 +218,8 @@ insert into t1 values (1,null); insert into t1 values (2,null); select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a; a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) -1 0 NULL NULL NULL NULL NULL -1 0 -2 0 NULL NULL NULL NULL NULL -1 0 +1 0 NULL NULL NULL NULL NULL 18446744073709551615 0 +2 0 NULL NULL NULL NULL NULL 18446744073709551615 0 select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a; a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) 1 0 NULL NULL NULL NULL NULL -1 0 @@ -227,7 +227,7 @@ a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) insert into t1 values (2,1); select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a; a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) -1 0 NULL NULL NULL NULL NULL -1 0 +1 0 NULL NULL NULL NULL NULL 18446744073709551615 0 2 1 1 1.0000 0.0000 1 1 1 1 select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a; a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) @@ -236,7 +236,7 @@ a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) insert into t1 values (3,1); select a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a; a count(b) sum(b) avg(b) std(b) min(b) max(b) bit_and(b) bit_or(b) -1 0 NULL NULL NULL NULL NULL -1 0 +1 0 NULL NULL NULL NULL NULL 18446744073709551615 0 2 1 1 1.0000 0.0000 1 1 1 1 3 1 1 1.0000 0.0000 1 1 1 1 select SQL_BIG_RESULT a,count(b), sum(b), avg(b), std(b), min(b), max(b), bit_and(b), bit_or(b) from t1 group by a; diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 36a3c6b009b..5a5934db0cd 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -615,10 +615,8 @@ void Item_sum_avg::reset_field() void Item_sum_bit::reset_field() { - char *res= result_field->ptr; - bits= reset_bits; - add(); - int8store(res, bits); + reset(); + int8store(result_field->ptr, bits); } void Item_sum_bit::update_field() diff --git a/sql/item_sum.h b/sql/item_sum.h index c91abbded28..d3a328be032 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -361,10 +361,10 @@ public: class Item_sum_bit :public Item_sum_int { - protected: +protected: ulonglong reset_bits,bits; - public: +public: Item_sum_bit(Item *item_par,ulonglong reset_arg) :Item_sum_int(item_par),reset_bits(reset_arg),bits(reset_arg) {} enum Sumfunctype sum_func () const {return SUM_BIT_FUNC;} @@ -373,6 +373,8 @@ class Item_sum_bit :public Item_sum_int void reset_field(); void update_field(); unsigned int size_of() { return sizeof(*this);} + void fix_length_and_dec() + { decimals=0; max_length=21; unsigned_flag=1; maybe_null=null_value=0; } }; @@ -383,20 +385,16 @@ public: bool add(); const char *func_name() const { return "bit_or"; } unsigned int size_of() { return sizeof(*this);} - void fix_length_and_dec() - { decimals=0; max_length=21; unsigned_flag=1; maybe_null=null_value=0; } }; class Item_sum_and :public Item_sum_bit { - public: - Item_sum_and(Item *item_par) :Item_sum_bit(item_par, ~(ulonglong) LL(0)) {} +public: + Item_sum_and(Item *item_par) :Item_sum_bit(item_par, ULONGLONG_MAX) {} bool add(); const char *func_name() const { return "bit_and"; } unsigned int size_of() { return sizeof(*this);} - void fix_length_and_dec() - { decimals=0; max_length=21; unsigned_flag=0; maybe_null=null_value=0; } }; /* From f5d7229762e3c0e4cf98f223b41cb6d381a767bf Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 2 Dec 2003 20:25:45 +0300 Subject: [PATCH 36/47] Fix for Bug #1448 "Date parsing fails, and fails to complain about it". Now numbers representing illegal timestamps are converted to 0 value if they are stored as timestamp or datetime. This behaviour is consistent with manual and with behaviour of string -> timestamp conversion. mysql-test/r/type_datetime.result: Added test if ranges are checked during integer, string -> timestamp conversion mysql-test/r/type_timestamp.result: Added test if ranges are checked during integer, string -> datetime conversion mysql-test/t/type_datetime.test: Added test if ranges are checked during integer, string -> datetime conversion mysql-test/t/type_timestamp.test: Added test if ranges are checked during integer, string -> timestamp conversion sql/field.cc: Checks of month, day, hour, minute and second ranges were added to storing of integer into Field_datetime and Field_timestamp and so for integer -> datetime, timestamp conversion. --- mysql-test/r/type_datetime.result | 15 ++++++- mysql-test/r/type_timestamp.result | 20 ++++++++- mysql-test/t/type_datetime.test | 5 ++- mysql-test/t/type_timestamp.test | 7 ++- sql/field.cc | 70 +++++++++++++++++++++--------- 5 files changed, 89 insertions(+), 28 deletions(-) diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result index 5df4f355cfb..756deab80e0 100644 --- a/mysql-test/r/type_datetime.result +++ b/mysql-test/r/type_datetime.result @@ -1,6 +1,6 @@ drop table if exists t1; create table t1 (t datetime); -insert into t1 values(101),(691231),(700101),(991231),(10000101),(99991231),(101000000),(691231000000),(700101000000),(991231235959),(10000101000000),(99991231235959); +insert into t1 values(101),(691231),(700101),(991231),(10000101),(99991231),(101000000),(691231000000),(700101000000),(991231235959),(10000101000000),(99991231235959),(20030102030460),(20030102036301),(20030102240401),(20030132030401),(20031302030460); select * from t1; t 2000-01-01 00:00:00 @@ -15,6 +15,11 @@ t 1999-12-31 23:59:59 1000-01-01 00:00:00 9999-12-31 23:59:59 +0000-00-00 00:00:00 +0000-00-00 00:00:00 +0000-00-00 00:00:00 +0000-00-00 00:00:00 +0000-00-00 00:00:00 delete from t1 where t > 0; optimize table t1; Table Op Msg_type Msg_text @@ -22,7 +27,8 @@ test.t1 optimize status OK check table t1; Table Op Msg_type Msg_text test.t1 check status OK -insert into t1 values("000101"),("691231"),("700101"),("991231"),("00000101"),("00010101"),("99991231"),("00101000000"),("691231000000"),("700101000000"),("991231235959"),("10000101000000"),("99991231235959"); +delete from t1; +insert into t1 values("000101"),("691231"),("700101"),("991231"),("00000101"),("00010101"),("99991231"),("00101000000"),("691231000000"),("700101000000"),("991231235959"),("10000101000000"),("99991231235959"),("20030102030460"),("20030102036301"),("20030102240401"),("20030132030401"),("20031302030460"); select * from t1; t 2000-01-01 00:00:00 @@ -38,6 +44,11 @@ t 1999-12-31 23:59:59 1000-01-01 00:00:00 9999-12-31 23:59:59 +0000-00-00 00:00:00 +0000-00-00 00:00:00 +0000-00-00 00:00:00 +0000-00-00 00:00:00 +0000-00-00 00:00:00 drop table t1; CREATE TABLE t1 (a timestamp, b date, c time, d datetime); insert into t1 (b,c,d) values(now(),curtime(),now()); diff --git a/mysql-test/r/type_timestamp.result b/mysql-test/r/type_timestamp.result index 3d5d74709c1..9403b73d459 100644 --- a/mysql-test/r/type_timestamp.result +++ b/mysql-test/r/type_timestamp.result @@ -43,7 +43,7 @@ date_format(a,"%Y %y") year(a) year(now()) 1970 70 1970 1970 drop table t1; create table t1 (ix timestamp); -insert into t1 values (19991101000000),(19990102030405),(19990630232922),(19990601000000),(19990930232922),(19990531232922),(19990501000000),(19991101000000),(19990501000000); +insert into t1 values (19991101000000),(19990102030405),(19990630232922),(19990601000000),(19990930232922),(19990531232922),(19990501000000),(19991101000000),(19990501000000),(20030101010160),(20030101016001),(20030101240101),(20030132010101),(20031301010101); select * from t1; ix 19991101000000 @@ -55,6 +55,24 @@ ix 19990501000000 19991101000000 19990501000000 +00000000000000 +00000000000000 +00000000000000 +00000000000000 +00000000000000 +delete from t1; +insert into t1 values ("19991101000000"),("19990102030405"),("19990630232922"),("19990601000000"),("20030101010160"),("20030101016001"),("20030101240101"),("20030132010101"),("20031301010101"); +select * from t1; +ix +19991101000000 +19990102030405 +19990630232922 +19990601000000 +00000000000000 +00000000000000 +00000000000000 +00000000000000 +00000000000000 drop table t1; CREATE TABLE t1 (date date, date_time datetime, time_stamp timestamp); INSERT INTO t1 VALUES ("1998-12-31","1998-12-31 23:59:59",19981231235959); diff --git a/mysql-test/t/type_datetime.test b/mysql-test/t/type_datetime.test index 51b65d00243..850e5238111 100644 --- a/mysql-test/t/type_datetime.test +++ b/mysql-test/t/type_datetime.test @@ -4,12 +4,13 @@ drop table if exists t1; create table t1 (t datetime); -insert into t1 values(101),(691231),(700101),(991231),(10000101),(99991231),(101000000),(691231000000),(700101000000),(991231235959),(10000101000000),(99991231235959); +insert into t1 values(101),(691231),(700101),(991231),(10000101),(99991231),(101000000),(691231000000),(700101000000),(991231235959),(10000101000000),(99991231235959),(20030102030460),(20030102036301),(20030102240401),(20030132030401),(20031302030460); select * from t1; delete from t1 where t > 0; optimize table t1; check table t1; -insert into t1 values("000101"),("691231"),("700101"),("991231"),("00000101"),("00010101"),("99991231"),("00101000000"),("691231000000"),("700101000000"),("991231235959"),("10000101000000"),("99991231235959"); +delete from t1; +insert into t1 values("000101"),("691231"),("700101"),("991231"),("00000101"),("00010101"),("99991231"),("00101000000"),("691231000000"),("700101000000"),("991231235959"),("10000101000000"),("99991231235959"),("20030102030460"),("20030102036301"),("20030102240401"),("20030132030401"),("20031302030460"); select * from t1; drop table t1; diff --git a/mysql-test/t/type_timestamp.test b/mysql-test/t/type_timestamp.test index eb0def74a17..0c88f1b8025 100644 --- a/mysql-test/t/type_timestamp.test +++ b/mysql-test/t/type_timestamp.test @@ -34,8 +34,11 @@ select date_format(a,"%Y %y"),year(a),year(now()) from t1; drop table t1; create table t1 (ix timestamp); -insert into t1 values (19991101000000),(19990102030405),(19990630232922),(19990601000000),(19990930232922),(19990531232922),(19990501000000),(19991101000000),(19990501000000); -select * from t1; +insert into t1 values (19991101000000),(19990102030405),(19990630232922),(19990601000000),(19990930232922),(19990531232922),(19990501000000),(19991101000000),(19990501000000),(20030101010160),(20030101016001),(20030101240101),(20030132010101),(20031301010101); +select * from t1; +delete from t1; +insert into t1 values ("19991101000000"),("19990102030405"),("19990630232922"),("19990601000000"),("20030101010160"),("20030101016001"),("20030101240101"),("20030132010101"),("20031301010101"); +select * from t1; drop table t1; CREATE TABLE t1 (date date, date_time datetime, time_stamp timestamp); diff --git a/sql/field.cc b/sql/field.cc index 43481ca0963..259314cb4db 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -2520,31 +2520,59 @@ void Field_timestamp::store(double nr) ** function. */ -static longlong fix_datetime(longlong nr) +static longlong fix_datetime(longlong nr, TIME *time_res) { + long part1,part2; + if (nr == LL(0) || nr >= LL(10000101000000)) - return nr; // Normal datetime >= Year 1000 + goto ok; if (nr < 101) goto err; if (nr <= (YY_PART_YEAR-1)*10000L+1231L) - return (nr+20000000L)*1000000L; // YYMMDD, year: 2000-2069 + { + nr= (nr+20000000L)*1000000L; // YYMMDD, year: 2000-2069 + goto ok; + } if (nr < (YY_PART_YEAR)*10000L+101L) goto err; if (nr <= 991231L) - return (nr+19000000L)*1000000L; // YYMMDD, year: 1970-1999 + { + nr= (nr+19000000L)*1000000L; // YYMMDD, year: 1970-1999 + goto ok; + } if (nr < 10000101L) goto err; if (nr <= 99991231L) - return nr*1000000L; + { + nr= nr*1000000L; + goto ok; + } if (nr < 101000000L) goto err; if (nr <= (YY_PART_YEAR-1)*LL(10000000000)+LL(1231235959)) - return nr+LL(20000000000000); // YYMMDDHHMMSS, 2000-2069 + { + nr= nr+LL(20000000000000); // YYMMDDHHMMSS, 2000-2069 + goto ok; + } if (nr < YY_PART_YEAR*LL(10000000000)+ LL(101000000)) goto err; if (nr <= LL(991231235959)) - return nr+LL(19000000000000); // YYMMDDHHMMSS, 1970-1999 + nr= nr+LL(19000000000000); // YYMMDDHHMMSS, 1970-1999 + ok: + part1=(long) (nr/LL(1000000)); + part2=(long) (nr - (longlong) part1*LL(1000000)); + time_res->year= (int) (part1/10000L); part1%=10000L; + time_res->month= (int) part1 / 100; + time_res->day= (int) part1 % 100; + time_res->hour= (int) (part2/10000L); part2%=10000L; + time_res->minute=(int) part2 / 100; + time_res->second=(int) part2 % 100; + + if (time_res->month <= 12 && time_res->day <= 31 && time_res->hour <= 23 && + time_res->minute <= 59 && time_res->second <= 59) + return nr; + err: current_thd->cuted_fields++; return LL(0); @@ -2555,20 +2583,18 @@ void Field_timestamp::store(longlong nr) { TIME l_time; time_t timestamp; - long part1,part2; - if ((nr=fix_datetime(nr))) + if ((nr=fix_datetime(nr, &l_time))) { long not_used; - part1=(long) (nr/LL(1000000)); - part2=(long) (nr - (longlong) part1*LL(1000000)); - l_time.year= (int) (part1/10000L); part1%=10000L; - l_time.month= (int) part1 / 100; - l_time.day= (int) part1 % 100; - l_time.hour= (int) (part2/10000L); part2%=10000L; - l_time.minute=(int) part2 / 100; - l_time.second=(int) part2 % 100; - timestamp=my_gmt_sec(&l_time, ¬_used); + + if (l_time.year >= TIMESTAMP_MAX_YEAR || l_time.year < 1900+YY_PART_YEAR) + { + current_thd->cuted_fields++; + timestamp=0; + } + else + timestamp=my_gmt_sec(&l_time, ¬_used); } else timestamp=0; @@ -3406,13 +3432,15 @@ void Field_datetime::store(double nr) void Field_datetime::store(longlong nr) { - if (nr < 0 || nr > LL(99991231235959)) + TIME l_time; + + nr=fix_datetime(nr, &l_time); + + if (l_time.year > 9999) { nr=0; current_thd->cuted_fields++; } - else - nr=fix_datetime(nr); #ifdef WORDS_BIGENDIAN if (table->db_low_byte_first) { From 8be4234f6162da34e1ecd007b67b3ef0650b16d1 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 2 Dec 2003 21:05:40 +0300 Subject: [PATCH 37/47] Fix for bug #1980 BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted --- BitKeeper/etc/logging_ok | 1 + mysql-test/r/multi_update.result | 26 ++++++++++++++++++ mysql-test/t/multi_update.test | 46 ++++++++++++++++++++++++++++++++ sql/uniques.cc | 14 +++++++--- 4 files changed, 83 insertions(+), 4 deletions(-) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 9dea6a7fa44..17af13c2e75 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -103,6 +103,7 @@ serg@serg.mylan serg@serg.mysql.com serg@sergbook.mylan serg@sergbook.mysql.com +sergefp@mysql.com sinisa@rhols221.adsl.netsonic.fi tfr@beta.frontier86.ee tfr@indrek.tfr.cafe.ee diff --git a/mysql-test/r/multi_update.result b/mysql-test/r/multi_update.result index 350cea420b6..233c99fb22b 100644 --- a/mysql-test/r/multi_update.result +++ b/mysql-test/r/multi_update.result @@ -327,3 +327,29 @@ select t1.a, t1.b,t2.a, t2.b from t1 left join t2 on t1.a=t2.a where t1.b=1 and a b a b 2 2 NULL NULL drop table t1,t2; +set @ttype_save=@@table_type; +set @@table_type=innodb; +create table t1 ( c char(8) not null ); +insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9'); +insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F'); +alter table t1 add b char(8) not null; +alter table t1 add a char(8) not null; +alter table t1 add primary key (a,b,c); +update t1 set a=c, b=c; +create table t2 like t1; +insert into t2 select * from t1; +delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b; +drop table t1,t2; +set @@table_type=bdb; +create table t1 ( c char(8) not null ); +insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9'); +insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F'); +alter table t1 add b char(8) not null; +alter table t1 add a char(8) not null; +alter table t1 add primary key (a,b,c); +update t1 set a=c, b=c; +create table t2 like t1; +insert into t2 select * from t1; +delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b; +set @@table_type=@ttype_save; +drop table t1,t2; diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test index 7aa4e74cec0..bf6c3db9306 100644 --- a/mysql-test/t/multi_update.test +++ b/mysql-test/t/multi_update.test @@ -267,3 +267,49 @@ insert into t2 values (1,1), (3,1); update t1 left join t2 on t1.a=t2.a set t1.b=2, t2.b=2 where t1.b=1 and t2.b=1 or t2.a is NULL; select t1.a, t1.b,t2.a, t2.b from t1 left join t2 on t1.a=t2.a where t1.b=1 and t2.b=1 or t2.a is NULL; drop table t1,t2; + +# +# Test for bug #1980. +# +set @ttype_save=@@table_type; + +--disable_warnings +set @@table_type=innodb; +create table t1 ( c char(8) not null ); +--enable_warnings + +insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9'); +insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F'); + +alter table t1 add b char(8) not null; +alter table t1 add a char(8) not null; +alter table t1 add primary key (a,b,c); +update t1 set a=c, b=c; + +create table t2 like t1; +insert into t2 select * from t1; + +delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b; + +drop table t1,t2; + +--disable_warnings +set @@table_type=bdb; +create table t1 ( c char(8) not null ); +--enable_warnings + +insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9'); +insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F'); + +alter table t1 add b char(8) not null; +alter table t1 add a char(8) not null; +alter table t1 add primary key (a,b,c); +update t1 set a=c, b=c; + +create table t2 like t1; +insert into t2 select * from t1; + +delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b; + +set @@table_type=@ttype_save; +drop table t1,t2; diff --git a/sql/uniques.cc b/sql/uniques.cc index d00893a8605..967392d12d5 100644 --- a/sql/uniques.cc +++ b/sql/uniques.cc @@ -37,14 +37,20 @@ int unique_write_to_file(gptr key, element_count count, Unique *unique) { + /* + Use unique->size (size of element stored in the tree) and not + unique->tree.size_of_element. The latter is different from unique->size + when tree implementation chooses to store pointer to key in TREE_ELEMENT + (instead of storing the element itself there) + */ return my_b_write(&unique->file, (byte*) key, - unique->tree.size_of_element) ? 1 : 0; + unique->size) ? 1 : 0; } int unique_write_to_ptrs(gptr key, element_count count, Unique *unique) { - memcpy(unique->record_pointers, key, unique->tree.size_of_element); - unique->record_pointers+=unique->tree.size_of_element; + memcpy(unique->record_pointers, key, unique->size); + unique->record_pointers+=unique->size; return 0; } @@ -132,7 +138,7 @@ bool Unique::get(TABLE *table) bzero((char*) &sort_param,sizeof(sort_param)); sort_param.max_rows= elements; sort_param.sort_form=table; - sort_param.sort_length=sort_param.ref_length=tree.size_of_element; + sort_param.sort_length=sort_param.ref_length=size; sort_param.keys= max_in_memory_size / sort_param.sort_length; sort_param.not_killable=1; From 930f94bf174b183a618591f6a40b3dc75b26dae0 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 3 Dec 2003 13:56:33 +0100 Subject: [PATCH 38/47] - Bugfix for the Mac OS X startup script: Suppress the annoying "$1: unbound variable" error when no option was given support-files/MacOSX/MySQL: - Suppress the annoying "$1: unbound variable" error when no option was given --- support-files/MacOSX/MySQL | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/support-files/MacOSX/MySQL b/support-files/MacOSX/MySQL index dfba5f8f982..f6579700384 100755 --- a/support-files/MacOSX/MySQL +++ b/support-files/MacOSX/MySQL @@ -11,6 +11,13 @@ # Written by Lenz Grimmer # +# Suppress the annoying "$1: unbound variable" error when no option +# was given +if [ -z $1 ] ; then + echo "Usage: $0 [start|stop|restart] " + exit 1 +fi + # Source the common setup functions for startup scripts test -r /etc/rc.common || exit 1 . /etc/rc.common From bc3977ca3413d0aa0f281d14068456b5b491f7d7 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 3 Dec 2003 19:49:31 +0300 Subject: [PATCH 39/47] Fix for bug #1980 tests --- mysql-test/r/multi_update.result | 4 ++-- mysql-test/t/multi_update.test | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/multi_update.result b/mysql-test/r/multi_update.result index 233c99fb22b..d286b01c1c7 100644 --- a/mysql-test/r/multi_update.result +++ b/mysql-test/r/multi_update.result @@ -336,7 +336,7 @@ alter table t1 add b char(8) not null; alter table t1 add a char(8) not null; alter table t1 add primary key (a,b,c); update t1 set a=c, b=c; -create table t2 like t1; +create table t2 (c char(8) not null, b char(8) not null, a char(8) not null, primary key(a,b,c)); insert into t2 select * from t1; delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b; drop table t1,t2; @@ -348,7 +348,7 @@ alter table t1 add b char(8) not null; alter table t1 add a char(8) not null; alter table t1 add primary key (a,b,c); update t1 set a=c, b=c; -create table t2 like t1; +create table t2 (c char(8) not null, b char(8) not null, a char(8) not null, primary key(a,b,c)); insert into t2 select * from t1; delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b; set @@table_type=@ttype_save; diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test index bf6c3db9306..fb2a1ff2b6f 100644 --- a/mysql-test/t/multi_update.test +++ b/mysql-test/t/multi_update.test @@ -286,7 +286,7 @@ alter table t1 add a char(8) not null; alter table t1 add primary key (a,b,c); update t1 set a=c, b=c; -create table t2 like t1; +create table t2 (c char(8) not null, b char(8) not null, a char(8) not null, primary key(a,b,c)); insert into t2 select * from t1; delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b; @@ -306,7 +306,7 @@ alter table t1 add a char(8) not null; alter table t1 add primary key (a,b,c); update t1 set a=c, b=c; -create table t2 like t1; +create table t2 (c char(8) not null, b char(8) not null, a char(8) not null, primary key(a,b,c)); insert into t2 select * from t1; delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b; From c2b60a6f59f12543a04497cf0196384782f3fbdd Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 4 Dec 2003 14:12:01 +0400 Subject: [PATCH 40/47] Fix for bug#1944 'Function RPad() sometimes produce unexpected result' --- mysql-test/r/func_str.result | 18 ++++++++++++------ mysql-test/t/func_str.test | 6 ++++-- sql/item_strfunc.cc | 4 ++-- sql/item_strfunc.h | 4 ++-- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index 0bac5111a05..dcb788f520f 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -119,12 +119,12 @@ montymontymontymontymonty * * select reverse('abc'),reverse('abcd'); reverse('abc') reverse('abcd') cba dcba -select rpad('a',4,'1'),rpad('a',4,'12'),rpad('abcd',3,'12'); -rpad('a',4,'1') rpad('a',4,'12') rpad('abcd',3,'12') -a111 a121 abc -select lpad('a',4,'1'),lpad('a',4,'12'),lpad('abcd',3,'12'); -lpad('a',4,'1') lpad('a',4,'12') lpad('abcd',3,'12') -111a 121a abc +select rpad('a',4,'1'),rpad('a',4,'12'),rpad('abcd',3,'12'), rpad(11, 10 , 22), rpad("ab", 10, 22); +rpad('a',4,'1') rpad('a',4,'12') rpad('abcd',3,'12') rpad(11, 10 , 22) rpad("ab", 10, 22) +a111 a121 abc 1122222222 ab22222222 +select lpad('a',4,'1'),lpad('a',4,'12'),lpad('abcd',3,'12'), lpad(11, 10 , 22); +lpad('a',4,'1') lpad('a',4,'12') lpad('abcd',3,'12') lpad(11, 10 , 22) +111a 121a abc 2222222211 select rpad(741653838,17,'0'),lpad(741653838,17,'0'); rpad(741653838,17,'0') lpad(741653838,17,'0') 74165383800000000 00000000741653838 @@ -134,6 +134,12 @@ abcdaba abaabcd select rpad('abcd',1,'ab'),lpad('abcd',1,'ab'); rpad('abcd',1,'ab') lpad('abcd',1,'ab') a a +select rpad('STRING', 20, CONCAT('p','a','d') ); +rpad('STRING', 20, CONCAT('p','a','d') ) +STRINGpadpadpadpadpa +select lpad('STRING', 20, CONCAT('p','a','d') ); +lpad('STRING', 20, CONCAT('p','a','d') ) +padpadpadpadpaSTRING select LEAST(NULL,'HARRY','HARRIOT',NULL,'HAROLD'),GREATEST(NULL,'HARRY','HARRIOT',NULL,'HAROLD'); LEAST(NULL,'HARRY','HARRIOT',NULL,'HAROLD') GREATEST(NULL,'HARRY','HARRIOT',NULL,'HAROLD') HAROLD HARRY diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index 5ea3654134b..b07b0b635c1 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -49,11 +49,13 @@ select aes_decrypt("a","a"); select aes_decrypt(aes_encrypt("","a"),"a"); select repeat('monty',5),concat('*',space(5),'*'); select reverse('abc'),reverse('abcd'); -select rpad('a',4,'1'),rpad('a',4,'12'),rpad('abcd',3,'12'); -select lpad('a',4,'1'),lpad('a',4,'12'),lpad('abcd',3,'12'); +select rpad('a',4,'1'),rpad('a',4,'12'),rpad('abcd',3,'12'), rpad(11, 10 , 22), rpad("ab", 10, 22); +select lpad('a',4,'1'),lpad('a',4,'12'),lpad('abcd',3,'12'), lpad(11, 10 , 22); select rpad(741653838,17,'0'),lpad(741653838,17,'0'); select rpad('abcd',7,'ab'),lpad('abcd',7,'ab'); select rpad('abcd',1,'ab'),lpad('abcd',1,'ab'); +select rpad('STRING', 20, CONCAT('p','a','d') ); +select lpad('STRING', 20, CONCAT('p','a','d') ); select LEAST(NULL,'HARRY','HARRIOT',NULL,'HAROLD'),GREATEST(NULL,'HARRY','HARRIOT',NULL,'HAROLD'); select least(1,2,3) | greatest(16,32,8), least(5,4)*1,greatest(-1.0,1.0)*1,least(3,2,1)*1.0,greatest(1,1.1,1.0),least("10",9),greatest("A","B","0"); diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index fe9c8b9e099..dd1ec6bd2da 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1806,7 +1806,7 @@ String *Item_func_rpad::val_str(String *str) const char *ptr_pad; int32 count= (int32) args[1]->val_int(); String *res =args[0]->val_str(str); - String *rpad = args[2]->val_str(str); + String *rpad = args[2]->val_str(&rpad_str); if (!res || args[1]->null_value || !rpad || count < 0) goto err; @@ -1866,7 +1866,7 @@ String *Item_func_lpad::val_str(String *str) const char *ptr_pad; ulong count= (long) args[1]->val_int(); String *res= args[0]->val_str(str); - String *lpad= args[2]->val_str(str); + String *lpad= args[2]->val_str(&lpad_str); if (!res || args[1]->null_value || !lpad) goto err; diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 5c9706ed633..fc98ebfe67d 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -436,7 +436,7 @@ public: class Item_func_rpad :public Item_str_func { - String tmp_value; + String tmp_value, rpad_str; public: Item_func_rpad(Item *arg1,Item *arg2,Item *arg3) :Item_str_func(arg1,arg2,arg3) {} @@ -449,7 +449,7 @@ public: class Item_func_lpad :public Item_str_func { - String tmp_value; + String tmp_value, lpad_str; public: Item_func_lpad(Item *arg1,Item *arg2,Item *arg3) :Item_str_func(arg1,arg2,arg3) {} From 8479e5a379044acad53baa8f9b7a8cd9266c582a Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 4 Dec 2003 15:30:14 +0100 Subject: [PATCH 41/47] Fix for BUG#2011 "rare race condition producing "binlog has bad magic number" error in slave". The problem was that when the slave SQL thread reads a hot relay log (hot = the one being written to by the slave I/O thread), it must have the LOCK_log. It already took it for read_log_event(), but needs it also for check_binlog_magic(). This should fix all recently reported failures of the rpl_max_relay_size test in 4.1 and 5.0 (though the bug exists since 4.0, it showed up first in 5.0). sql/slave.cc: Fix for BUG#2011 "rare race condition producing "binlog has bad magic number" error in slave". The problem was that when the slave SQL thread reads a hot relay log (hot = the one being written to by the slave I/O thread), it must have the LOCK_log. It already took it for read_log_event(), but needs it also for check_binlog_magic(). --- sql/slave.cc | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/sql/slave.cc b/sql/slave.cc index 6816d968007..5bc31fd6a21 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -3497,8 +3497,20 @@ rli->relay_log_pos=%s rli->pending=%lu", sizeof(rli->relay_log_name)-1); flush_relay_log_info(rli); } - - // next log is hot + + /* + Now we want to open this next log. To know if it's a hot log (the one + being written by the I/O thread now) or a cold log, we can use + is_active(); if it is hot, we use the I/O cache; if it's cold we open + the file normally. But if is_active() reports that the log is hot, this + may change between the test and the consequence of the test. So we may + open the I/O cache whereas the log is now cold, which is nonsense. + To guard against this, we need to have LOCK_log. + */ + + DBUG_PRINT("info",("hot_log: %d",hot_log)); + if (!hot_log) /* if hot_log, we already have this mutex */ + pthread_mutex_lock(log_lock); if (rli->relay_log.is_active(rli->linfo.log_file_name)) { #ifdef EXTRA_DEBUG @@ -3511,15 +3523,24 @@ rli->relay_log_pos=%s rli->pending=%lu", /* Read pointer has to be at the start since we are the only - reader + reader. + We must keep the LOCK_log to read the 4 first bytes, as this is a hot + log (same as when we call read_log_event() above: for a hot log we + take the mutex). */ if (check_binlog_magic(cur_log,&errmsg)) + { + if (!hot_log) pthread_mutex_unlock(log_lock); goto err; + } + if (!hot_log) pthread_mutex_unlock(log_lock); continue; } + if (!hot_log) pthread_mutex_unlock(log_lock); /* - if we get here, the log was not hot, so we will have to - open it ourselves + if we get here, the log was not hot, so we will have to open it + ourselves. We are sure that the log is still not hot now (a log can get + from hot to cold, but not from cold to hot). No need for LOCK_log. */ #ifdef EXTRA_DEBUG sql_print_error("next log '%s' is not active", From 8f4ed1d72cacfec81737af77c1b215ca7a9ed410 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 4 Dec 2003 19:02:48 +0300 Subject: [PATCH 42/47] Fix undeterministic behaviour of year check if we failed to classify integer as datetime in Field_datetime::store(). Stylistic clean-ups. sql/field.cc: Fix undeterministic behaviour of year check if we failed to classify integer as datetime Stylistic clean-ups. --- sql/field.cc | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/sql/field.cc b/sql/field.cc index 259314cb4db..1070d0f7b7d 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -2569,7 +2569,8 @@ static longlong fix_datetime(longlong nr, TIME *time_res) time_res->minute=(int) part2 / 100; time_res->second=(int) part2 % 100; - if (time_res->month <= 12 && time_res->day <= 31 && time_res->hour <= 23 && + if (time_res->year <= 9999 && time_res->month <= 12 && + time_res->day <= 31 && time_res->hour <= 23 && time_res->minute <= 59 && time_res->second <= 59) return nr; @@ -2584,7 +2585,7 @@ void Field_timestamp::store(longlong nr) TIME l_time; time_t timestamp; - if ((nr=fix_datetime(nr, &l_time))) + if ((nr= fix_datetime(nr, &l_time))) { long not_used; @@ -3432,15 +3433,10 @@ void Field_datetime::store(double nr) void Field_datetime::store(longlong nr) { - TIME l_time; + TIME not_used; - nr=fix_datetime(nr, &l_time); + nr= fix_datetime(nr, ¬_used); - if (l_time.year > 9999) - { - nr=0; - current_thd->cuted_fields++; - } #ifdef WORDS_BIGENDIAN if (table->db_low_byte_first) { From ee52d2925d40f3d7e7d70a7e246023e8627be489 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 4 Dec 2003 19:48:10 +0200 Subject: [PATCH 43/47] Allow space in service names move bdb/innodb tests to right places mysql-test/r/bdb.result: Update results after test changes mysql-test/r/innodb.result: Update results after test changes mysql-test/r/multi_update.result: Update results after test changes mysql-test/t/bdb.test: Move bdb tests here mysql-test/t/innodb.test: Move innodb test here mysql-test/t/multi_update.test: move bdb/innodb tests to repective test sql/mysqld.cc: Allow space in service names --- mysql-test/r/bdb.result | 11 ++++++++ mysql-test/r/innodb.result | 11 ++++++++ mysql-test/r/multi_update.result | 26 ------------------ mysql-test/t/bdb.test | 19 +++++++++++++ mysql-test/t/innodb.test | 19 +++++++++++++ mysql-test/t/multi_update.test | 46 -------------------------------- sql/mysqld.cc | 2 +- 7 files changed, 61 insertions(+), 73 deletions(-) diff --git a/mysql-test/r/bdb.result b/mysql-test/r/bdb.result index ebc2866183c..05845df9dd3 100644 --- a/mysql-test/r/bdb.result +++ b/mysql-test/r/bdb.result @@ -1154,3 +1154,14 @@ x 7 6 drop table t1; +create table t1 ( c char(8) not null ) type=bdb; +insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9'); +insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F'); +alter table t1 add b char(8) not null; +alter table t1 add a char(8) not null; +alter table t1 add primary key (a,b,c); +update t1 set a=c, b=c; +create table t2 (c char(8) not null, b char(8) not null, a char(8) not null, primary key(a,b,c)) type=bdb; +insert into t2 select * from t1; +delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b; +drop table t1,t2; diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result index e9cdf962022..3938fc80f10 100644 --- a/mysql-test/r/innodb.result +++ b/mysql-test/r/innodb.result @@ -1222,3 +1222,14 @@ a b 111 100 111 100 drop table t1; +create table t1 ( c char(8) not null ) type=innodb; +insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9'); +insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F'); +alter table t1 add b char(8) not null; +alter table t1 add a char(8) not null; +alter table t1 add primary key (a,b,c); +update t1 set a=c, b=c; +create table t2 (c char(8) not null, b char(8) not null, a char(8) not null, primary key(a,b,c)) type=innodb; +insert into t2 select * from t1; +delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b; +drop table t1,t2; diff --git a/mysql-test/r/multi_update.result b/mysql-test/r/multi_update.result index d286b01c1c7..350cea420b6 100644 --- a/mysql-test/r/multi_update.result +++ b/mysql-test/r/multi_update.result @@ -327,29 +327,3 @@ select t1.a, t1.b,t2.a, t2.b from t1 left join t2 on t1.a=t2.a where t1.b=1 and a b a b 2 2 NULL NULL drop table t1,t2; -set @ttype_save=@@table_type; -set @@table_type=innodb; -create table t1 ( c char(8) not null ); -insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9'); -insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F'); -alter table t1 add b char(8) not null; -alter table t1 add a char(8) not null; -alter table t1 add primary key (a,b,c); -update t1 set a=c, b=c; -create table t2 (c char(8) not null, b char(8) not null, a char(8) not null, primary key(a,b,c)); -insert into t2 select * from t1; -delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b; -drop table t1,t2; -set @@table_type=bdb; -create table t1 ( c char(8) not null ); -insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9'); -insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F'); -alter table t1 add b char(8) not null; -alter table t1 add a char(8) not null; -alter table t1 add primary key (a,b,c); -update t1 set a=c, b=c; -create table t2 (c char(8) not null, b char(8) not null, a char(8) not null, primary key(a,b,c)); -insert into t2 select * from t1; -delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b; -set @@table_type=@ttype_save; -drop table t1,t2; diff --git a/mysql-test/t/bdb.test b/mysql-test/t/bdb.test index d0cc63a9389..2dfaecba9b1 100644 --- a/mysql-test/t/bdb.test +++ b/mysql-test/t/bdb.test @@ -796,3 +796,22 @@ select * from t1 where x <= 10 and x >= 7 order by x desc; select * from t1 where x <= 8 and x >= 5 order by x desc; select * from t1 where x < 8 and x > 5 order by x desc; drop table t1; + +# +# Test of multi-table-updates (bug #1980). +# + +create table t1 ( c char(8) not null ) type=bdb; +insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9'); +insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F'); + +alter table t1 add b char(8) not null; +alter table t1 add a char(8) not null; +alter table t1 add primary key (a,b,c); +update t1 set a=c, b=c; + +create table t2 (c char(8) not null, b char(8) not null, a char(8) not null, primary key(a,b,c)) type=bdb; +insert into t2 select * from t1; + +delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b; +drop table t1,t2; diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test index e46f5801418..ea9c5e0cf55 100644 --- a/mysql-test/t/innodb.test +++ b/mysql-test/t/innodb.test @@ -838,3 +838,22 @@ update t1 set b=100 where a=1 order by b desc limit 2; update t1 set a=a+10+b where a=1 order by b; select * from t1 order by a,b; drop table t1; + +# +# Test of multi-table-updates (bug #1980). +# + +create table t1 ( c char(8) not null ) type=innodb; +insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9'); +insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F'); + +alter table t1 add b char(8) not null; +alter table t1 add a char(8) not null; +alter table t1 add primary key (a,b,c); +update t1 set a=c, b=c; + +create table t2 (c char(8) not null, b char(8) not null, a char(8) not null, primary key(a,b,c)) type=innodb; +insert into t2 select * from t1; + +delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b; +drop table t1,t2; diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test index fb2a1ff2b6f..7aa4e74cec0 100644 --- a/mysql-test/t/multi_update.test +++ b/mysql-test/t/multi_update.test @@ -267,49 +267,3 @@ insert into t2 values (1,1), (3,1); update t1 left join t2 on t1.a=t2.a set t1.b=2, t2.b=2 where t1.b=1 and t2.b=1 or t2.a is NULL; select t1.a, t1.b,t2.a, t2.b from t1 left join t2 on t1.a=t2.a where t1.b=1 and t2.b=1 or t2.a is NULL; drop table t1,t2; - -# -# Test for bug #1980. -# -set @ttype_save=@@table_type; - ---disable_warnings -set @@table_type=innodb; -create table t1 ( c char(8) not null ); ---enable_warnings - -insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9'); -insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F'); - -alter table t1 add b char(8) not null; -alter table t1 add a char(8) not null; -alter table t1 add primary key (a,b,c); -update t1 set a=c, b=c; - -create table t2 (c char(8) not null, b char(8) not null, a char(8) not null, primary key(a,b,c)); -insert into t2 select * from t1; - -delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b; - -drop table t1,t2; - ---disable_warnings -set @@table_type=bdb; -create table t1 ( c char(8) not null ); ---enable_warnings - -insert into t1 values ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'),('8'),('9'); -insert into t1 values ('A'),('B'),('C'),('D'),('E'),('F'); - -alter table t1 add b char(8) not null; -alter table t1 add a char(8) not null; -alter table t1 add primary key (a,b,c); -update t1 set a=c, b=c; - -create table t2 (c char(8) not null, b char(8) not null, a char(8) not null, primary key(a,b,c)); -insert into t2 select * from t1; - -delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b; - -set @@table_type=@ttype_save; -drop table t1,t2; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 4c6cf1d5039..2e87ade9174 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2573,7 +2573,7 @@ default_service_handling(char **argv, } /* We must have servicename last */ *pos++= ' '; - strmake(pos, servicename, (uint) (end+2 - pos)); + (void) add_quoted_string(pos, servicename, end); if (Service.got_service_option(argv, "install")) { From dbd810e0751b56d87e74f5b275cb3c1ba52c2eb4 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 4 Dec 2003 13:58:21 -0500 Subject: [PATCH 44/47] Fix InstallShield 'String Tables could not be loaded' issue VC++Files/InstallShield/4.0.XX-classic/String Tables/0009-English/value.shl: This should not be the product version; it must match Default.shl VC++Files/InstallShield/4.0.XX-gpl/String Tables/0009-English/value.shl: This should not be the product version; it must match Default.shl VC++Files/InstallShield/4.0.XX-pro/String Tables/0009-English/value.shl: This should not be the product version; it must match Default.shl --- .../4.0.XX-classic/String Tables/0009-English/value.shl | 2 +- .../4.0.XX-gpl/String Tables/0009-English/value.shl | 2 +- .../4.0.XX-pro/String Tables/0009-English/value.shl | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/VC++Files/InstallShield/4.0.XX-classic/String Tables/0009-English/value.shl b/VC++Files/InstallShield/4.0.XX-classic/String Tables/0009-English/value.shl index 5f767a63f43..868c801c68c 100755 --- a/VC++Files/InstallShield/4.0.XX-classic/String Tables/0009-English/value.shl +++ b/VC++Files/InstallShield/4.0.XX-classic/String Tables/0009-English/value.shl @@ -19,5 +19,5 @@ ERROR_UNINSTSETUP=unInstaller setup failed to initialize. You may not be able t [General] Language=0009 Type=STRINGTABLESPECIFIC -Version=@VERSION@ +Version=1.00.000 diff --git a/VC++Files/InstallShield/4.0.XX-gpl/String Tables/0009-English/value.shl b/VC++Files/InstallShield/4.0.XX-gpl/String Tables/0009-English/value.shl index 0a6c33be42b..35e7c278cc9 100755 --- a/VC++Files/InstallShield/4.0.XX-gpl/String Tables/0009-English/value.shl +++ b/VC++Files/InstallShield/4.0.XX-gpl/String Tables/0009-English/value.shl @@ -19,5 +19,5 @@ ERROR_UNINSTSETUP=unInstaller setup failed to initialize. You may not be able t [General] Language=0009 Type=STRINGTABLESPECIFIC -Version=@VERSION@ +Version=1.00.000 diff --git a/VC++Files/InstallShield/4.0.XX-pro/String Tables/0009-English/value.shl b/VC++Files/InstallShield/4.0.XX-pro/String Tables/0009-English/value.shl index 61b2e6fb50f..525f3be0b3e 100755 --- a/VC++Files/InstallShield/4.0.XX-pro/String Tables/0009-English/value.shl +++ b/VC++Files/InstallShield/4.0.XX-pro/String Tables/0009-English/value.shl @@ -19,5 +19,5 @@ ERROR_UNINSTSETUP=unInstaller setup failed to initialize. You may not be able t [General] Language=0009 Type=STRINGTABLESPECIFIC -Version=@VERSION@ +Version=1.00.000 From 66927c51fa8e25f9d8a9d818f4ff7ed2a64c5ecb Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 4 Dec 2003 22:42:18 +0100 Subject: [PATCH 45/47] - Fix for BUG#1858 "SQL-Thread stops working when using optimize table": we change THD::system_thread from a 'bool' to a bitmap to be able to distinguish between delayed-insert threads and slave threads. - Fix for BUG#1701 "Update from multiple tables" (one line in sql_parse.cc, plus a new test rpl_multi_update.test). That's just adding an initialization. sql/repl_failsafe.cc: comment to warn about this unused code sql/slave.cc: Now thd->system_thread is a bitmap, not a bool. sql/sql_class.h: 'bool' for THD::system_thread is not accurate enough; sometimes we need to distinguish between delayed-insert threads and slave threads; so changing THD::system_thread to a bitmap (uint). sql/sql_insert.cc: thd.system_thread is now a bitmap sql/sql_parse.cc: We need to initialize thd->lex.select_lex.options in mysql_init_query(); it's already initialized in dispatch_command() but replication calls mysql_parse() directly, thus bypassing dispatch_command(). Not initing it here leads to a query influencing the next query, in the slave SQL thread. The initialization in dispatch_command() must be kept as this command uses the variable in tests, even when the command was not a query (i.e. when mysql_init_query() was not called). --- mysql-test/r/rpl_multi_update.result | 27 +++++++++++++++++++++++++++ mysql-test/t/rpl_multi_update.test | 25 +++++++++++++++++++++++++ sql/repl_failsafe.cc | 7 +++++++ sql/slave.cc | 4 +++- sql/sql_class.h | 9 +++++++-- sql/sql_insert.cc | 2 +- sql/sql_parse.cc | 6 ++++++ 7 files changed, 76 insertions(+), 4 deletions(-) create mode 100644 mysql-test/r/rpl_multi_update.result create mode 100644 mysql-test/t/rpl_multi_update.test diff --git a/mysql-test/r/rpl_multi_update.result b/mysql-test/r/rpl_multi_update.result new file mode 100644 index 00000000000..1fa1dd104d2 --- /dev/null +++ b/mysql-test/r/rpl_multi_update.result @@ -0,0 +1,27 @@ +slave stop; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +slave start; +drop table if exists t1,t2; +CREATE TABLE t1 ( +a int unsigned not null auto_increment primary key, +b int unsigned, +) TYPE=MyISAM; +CREATE TABLE t2 ( +a int unsigned not null auto_increment primary key, +b int unsigned +) TYPE=MyISAM; +INSERT INTO t1 VALUES (NULL, 0); +INSERT INTO t1 SELECT NULL, 0 FROM t1; +INSERT INTO t2 VALUES (NULL, 0), (NULL,1); +SELECT * FROM t1 ORDER BY a; +a b +1 0 +2 0 +SELECT * FROM t2 ORDER BY a; +a b +1 0 +2 1 +UPDATE t1, t2 SET t1.b = t2.b WHERE t1.a = t2.a; diff --git a/mysql-test/t/rpl_multi_update.test b/mysql-test/t/rpl_multi_update.test new file mode 100644 index 00000000000..c44239594dd --- /dev/null +++ b/mysql-test/t/rpl_multi_update.test @@ -0,0 +1,25 @@ +source include/master-slave.inc; +drop table if exists t1,t2; + +CREATE TABLE t1 ( + a int unsigned not null auto_increment primary key, + b int unsigned, +) TYPE=MyISAM; + +CREATE TABLE t2 ( + a int unsigned not null auto_increment primary key, + b int unsigned +) TYPE=MyISAM; + +INSERT INTO t1 VALUES (NULL, 0); +INSERT INTO t1 SELECT NULL, 0 FROM t1; + +INSERT INTO t2 VALUES (NULL, 0), (NULL,1); + +SELECT * FROM t1 ORDER BY a; +SELECT * FROM t2 ORDER BY a; + +UPDATE t1, t2 SET t1.b = t2.b WHERE t1.a = t2.a; +save_master_pos; +connection slave; +sync_with_master; diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index 8deb23e8586..6b91d81b487 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -52,6 +52,13 @@ static Slave_log_event* find_slave_event(IO_CACHE* log, const char* log_file_name, char* errmsg); +/* + All of the functions defined in this file which are not used (the ones to + handle failsafe) are not used; their code has not been updated for more than + one year now so should be considered as BADLY BROKEN. Do not enable it. + The used functions (to handle LOAD DATA FROM MASTER, plus some small + functions like register_slave()) are working. +*/ static int init_failsafe_rpl_thread(THD* thd) { diff --git a/sql/slave.cc b/sql/slave.cc index 5bc31fd6a21..25eeb34e3a7 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -2021,7 +2021,9 @@ improper_arguments: %d timed_out: %d", static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type) { DBUG_ENTER("init_slave_thread"); - thd->system_thread = thd->bootstrap = 1; + thd->system_thread = (thd_type == SLAVE_THD_SQL) ? + SYSTEM_THREAD_SLAVE_SQL : SYSTEM_THREAD_SLAVE_IO; + thd->bootstrap= 1; thd->host_or_ip= ""; thd->client_capabilities = 0; my_net_init(&thd->net, 0); diff --git a/sql/sql_class.h b/sql/sql_class.h index 58543a3d230..9287a0c8c79 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -460,7 +460,7 @@ public: long dbug_thread_id; pthread_t real_id; uint current_tablenr,tmp_table,cond_count; - uint server_status,open_options; + uint server_status,open_options,system_thread; uint32 query_length; uint32 db_length; /* variables.transaction_isolation is reset to this after each commit */ @@ -470,7 +470,7 @@ public: bool set_query_id,locked,count_cuted_fields,some_tables_deleted; bool no_errors, allow_sum_func, password, fatal_error; bool query_start_used,last_insert_id_used,insert_id_used,rand_used; - bool system_thread,in_lock_tables,global_read_lock; + bool in_lock_tables,global_read_lock; bool query_error, bootstrap, cleanup_done; bool safe_to_cache_query; bool volatile killed; @@ -592,6 +592,11 @@ public: CHANGED_TABLE_LIST * changed_table_dup(const char *key, long key_length); }; +/* Flags for the THD::system_thread (bitmap) variable */ +#define SYSTEM_THREAD_DELAYED_INSERT 1 +#define SYSTEM_THREAD_SLAVE_IO 2 +#define SYSTEM_THREAD_SLAVE_SQL 4 + /* Used to hold information about file and file structure in exchainge via non-DB file (...INTO OUTFILE..., ...LOAD DATA...) diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 3aefee61c27..3414e76e092 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -550,7 +550,7 @@ public: thd.command=COM_DELAYED_INSERT; bzero((char*) &thd.net,sizeof(thd.net)); // Safety - thd.system_thread=1; + thd.system_thread= SYSTEM_THREAD_DELAYED_INSERT; thd.host_or_ip= ""; bzero((char*) &info,sizeof(info)); pthread_mutex_init(&mutex,MY_MUTEX_INIT_FAST); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 0789a1768d1..2d40d6fcf36 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2902,6 +2902,12 @@ mysql_init_query(THD *thd) thd->lex.select_lex.table_list.first=0; thd->lex.select_lex.table_list.next= (byte**) &thd->lex.select_lex.table_list.first; thd->lex.select_lex.next=0; + /* + select_lex.options is also inited in dispatch_command(), but for + replication (which bypasses dispatch_command() and calls mysql_parse() + directly) we must do it here. + */ + thd->lex.select_lex.options=0; thd->lex.olap=0; thd->lex.select->olap= UNSPECIFIED_OLAP_TYPE; thd->fatal_error=0; // Safety From d4e3cc72195f6bbb450b3d1bad8fe9f735d6872a Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 5 Dec 2003 12:52:07 +0300 Subject: [PATCH 46/47] attempt to make ULONGLONG_MAX work on Windows. include/config-win.h: ULONGLONG_MAX definition added include/my_global.h: comment about config-win.h added --- include/config-win.h | 1 + include/my_global.h | 1 + 2 files changed, 2 insertions(+) diff --git a/include/config-win.h b/include/config-win.h index 53dff5d63af..b30f50f0edb 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -85,6 +85,7 @@ #define LONGLONG_MIN ((__int64) 0x8000000000000000) #define LONGLONG_MAX ((__int64) 0x7FFFFFFFFFFFFFFF) +#define ULONGLONG_MAX ((unsigned __int64) 0xFFFFFFFFFFFFFFFF) #define LL(A) ((__int64) A) /* Type information */ diff --git a/include/my_global.h b/include/my_global.h index 68c331aa414..ca74cb07868 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -606,6 +606,7 @@ extern double my_atof(const char*); /* Some pre-ANSI-C99 systems like AIX 5.1 and Linux/GCC 2.95 define ULONGLONG_MAX, LONGLONG_MIN, LONGLONG_MAX; we use them if they're defined. + Also on Windows we define these constants by hand in config-win.h. */ #if defined(HAVE_LONG_LONG) && !defined(LONGLONG_MIN) From e425b98a0129dd72c68fc995ee086fe68c0138dd Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 5 Dec 2003 19:20:06 +0300 Subject: [PATCH 47/47] typo fixed --- include/my_global.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/my_global.h b/include/my_global.h index ca74cb07868..bcd6004d72a 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -614,14 +614,14 @@ extern double my_atof(const char*); #define LONGLONG_MAX ((long long) 0x7FFFFFFFFFFFFFFFLL) #endif -#if defined(HAVE_LONG_LONG) && !defined(ULONLONG_MAX) +#if defined(HAVE_LONG_LONG) && !defined(ULONGLONG_MAX) /* First check for ANSI C99 definition: */ #ifdef ULLONG_MAX #define ULONGLONG_MAX ULLONG_MAX #else #define ULONGLONG_MAX ((unsigned long long)(~0ULL)) #endif -#endif /* defined (HAVE_LONG_LONG) && !defined(ULONLONG_MAX)*/ +#endif /* defined (HAVE_LONG_LONG) && !defined(ULONGLONG_MAX)*/ #if SIZEOF_LONG == 4 #define INT_MIN32 (long) 0x80000000L