diff options
-rw-r--r-- | mysql-test/r/func_time.result | 6 | ||||
-rw-r--r-- | mysql-test/t/func_time.test | 3 | ||||
-rw-r--r-- | sql/item_cmpfunc.cc | 5 | ||||
-rw-r--r-- | sql/item_cmpfunc.h | 5 | ||||
-rw-r--r-- | sql/item_timefunc.cc | 19 | ||||
-rw-r--r-- | sql/mysqld.cc | 8 | ||||
-rw-r--r-- | sql/sql_base.cc | 4 | ||||
-rw-r--r-- | tests/Makefile.am | 2 |
8 files changed, 42 insertions, 10 deletions
diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index e4fd25a34f0..4a1012f73bf 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -84,6 +84,12 @@ select yearweek("2000-01-01",1) as '2000', yearweek("2001-01-01",1) as '2001', y select yearweek("2000-01-06",1) as '2000', yearweek("2001-01-06",1) as '2001', yearweek("2002-01-06",1) as '2002',yearweek("2003-01-06",1) as '2003', yearweek("2004-01-06",1) as '2004', yearweek("2005-01-06",1) as '2005', yearweek("2006-01-06",1) as '2006'; 2000 2001 2002 2003 2004 2005 2006 200001 200101 200201 200302 200402 200501 200601 +select week(19981231,2), week(19981231,3), week(20000101,2), week(20000101,3); +week(19981231,2) week(19981231,3) week(20000101,2) week(20000101,3) +52 53 52 52 +select week(20001231,2),week(20001231,3); +week(20001231,2) week(20001231,3) +1 52 select date_format('1998-12-31','%x-%v'),date_format('1999-01-01','%x-%v'); date_format('1998-12-31','%x-%v') date_format('1999-01-01','%x-%v') 1998-53 1998-53 diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index 7d5ab73fa4c..2ff57959965 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -34,6 +34,9 @@ select yearweek("2000-01-01",0) as '2000', yearweek("2001-01-01",0) as '2001', y select yearweek("2000-01-06",0) as '2000', yearweek("2001-01-06",0) as '2001', yearweek("2002-01-06",0) as '2002',yearweek("2003-01-06",0) as '2003', yearweek("2004-01-06",0) as '2004', yearweek("2005-01-06",0) as '2005', yearweek("2006-01-06",0) as '2006'; select yearweek("2000-01-01",1) as '2000', yearweek("2001-01-01",1) as '2001', yearweek("2002-01-01",1) as '2002',yearweek("2003-01-01",1) as '2003', yearweek("2004-01-01",1) as '2004', yearweek("2005-01-01",1) as '2005', yearweek("2006-01-01",1) as '2006'; select yearweek("2000-01-06",1) as '2000', yearweek("2001-01-06",1) as '2001', yearweek("2002-01-06",1) as '2002',yearweek("2003-01-06",1) as '2003', yearweek("2004-01-06",1) as '2004', yearweek("2005-01-06",1) as '2005', yearweek("2006-01-06",1) as '2006'; +select week(19981231,2), week(19981231,3), week(20000101,2), week(20000101,3); +select week(20001231,2),week(20001231,3); + select date_format('1998-12-31','%x-%v'),date_format('1999-01-01','%x-%v'); select date_format('1999-12-31','%x-%v'),date_format('2000-01-01','%x-%v'); diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 93e24525d06..ee587289168 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -533,7 +533,6 @@ Item_func_if::fix_length_and_dec() else cached_result_type=arg1_type; // Should be INT_RESULT } - args[0]->top_level_item(); } @@ -1122,6 +1121,8 @@ Item_cond::fix_fields(THD *thd,TABLE_LIST *tables) #endif item= *li.ref(); // new current item } + if (abort_on_null) + item->top_level_item(); if (item->fix_fields(thd,tables)) return 1; /* purecov: inspected */ used_tables_cache|=item->used_tables(); @@ -1129,8 +1130,6 @@ Item_cond::fix_fields(THD *thd,TABLE_LIST *tables) const_item_cache&=item->const_item(); if (item->maybe_null) maybe_null=1; - if (abort_on_null) - item->top_level_item(); } if (thd) thd->cond_count+=list.elements; diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index f2c0ee403d2..e163bc40a6e 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -216,6 +216,11 @@ public: longlong val_int(); String *val_str(String *str); enum Item_result result_type () const { return cached_result_type; } + bool fix_fields(THD *thd,struct st_table_list *tlist) + { + args[0]->top_level_item(); + return Item_func::fix_fields(thd,tlist); + } void fix_length_and_dec(); const char *func_name() const { return "if"; } unsigned int size_of() { return sizeof(*this);} diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 1e222fddcfc..558dd807d80 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -175,15 +175,28 @@ longlong Item_func_second::val_int() } -// Returns the week of year in the range of 0 - 53 +/* + Returns the week of year. + + The bits in week_format has the following meaning: + 0 If not set: USA format: Sunday is first day of week + If set: ISO format: Monday is first day of week + 1 If not set: Week is in range 0-53 + If set Week is in range 1-53. +*/ longlong Item_func_week::val_int() { uint year; + uint week_format; TIME ltime; if (get_arg0_date(<ime,0)) return 0; - return (longlong) calc_week(<ime, 0, args[1]->val_int() == 0, &year); + week_format= args[1]->val_int(); + return (longlong) calc_week(<ime, + (week_format & 2) != 0, + (week_format & 1) == 0, + &year); } @@ -193,7 +206,7 @@ longlong Item_func_yearweek::val_int() TIME ltime; if (get_arg0_date(<ime,0)) return 0; - week=calc_week(<ime, 1, args[1]->val_int() == 0, &year); + week=calc_week(<ime, 1, (args[1]->val_int() & 1) == 0, &year); return week+year*100; } diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 48c7cbe3ba3..62f8ed62877 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2003,6 +2003,8 @@ int main(int argc, char **argv) if (ha_init()) { sql_print_error("Can't init databases"); + if (unix_sock != INVALID_SOCKET) + unlink(mysql_unix_port); exit(1); } ha_key_cache(); @@ -2038,6 +2040,8 @@ int main(int argc, char **argv) pthread_key_create(&THR_MALLOC,NULL)) { sql_print_error("Can't create thread-keys"); + if (unix_sock != INVALID_SOCKET) + unlink(mysql_unix_port); exit(1); } start_signal_handler(); // Creates pidfile @@ -2050,6 +2054,8 @@ int main(int argc, char **argv) if (!opt_bootstrap) (void) my_delete(pidfile_name,MYF(MY_WME)); // Not needed anymore #endif + if (unix_sock != INVALID_SOCKET) + unlink(mysql_unix_port); exit(1); } if (!opt_noacl) @@ -4467,8 +4473,8 @@ fn_format_relative_to_data_home(my_string to, const char *name, static void fix_paths(void) { char buff[FN_REFLEN]; - (void) fn_format(mysql_home,mysql_home,"","",16); // Remove symlinks convert_dirname(mysql_home,mysql_home,NullS); + my_realpath(mysql_home,mysql_home,MYF(0)); convert_dirname(mysql_real_data_home,mysql_real_data_home,NullS); convert_dirname(language,language,NullS); (void) my_load_path(mysql_home,mysql_home,""); // Resolve current dir diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 42d35c05f23..23ba04bd6ed 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -376,14 +376,14 @@ bool close_cached_tables(THD *thd, bool if_wait_for_refresh, if (!found) if_wait_for_refresh=0; // Nothing to wait for } + if (!tables) + kill_delayed_threads(); if (if_wait_for_refresh) { /* If there is any table that has a lower refresh_version, wait until this is closed (or this thread is killed) before returning */ - if (!tables) - kill_delayed_threads(); thd->mysys_var->current_mutex= &LOCK_open; thd->mysys_var->current_cond= &COND_refresh; thd->proc_info="Flushing tables"; diff --git a/tests/Makefile.am b/tests/Makefile.am index cdb623fa2a0..356da61ed57 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -24,7 +24,7 @@ EXTRA_DIST = auto_increment.res auto_increment.tst \ insert_and_repair.pl \ grant.pl grant.res test_delayed_insert.pl \ pmail.pl mail_to_db.pl table_types.pl \ - udf_test udf_test.res + udf_test udf_test.res myisam-big-rows.tst # Don't update the files from bitkeeper %::SCCS/s.% |