diff options
author | unknown <monty@mashka.mysql.fi> | 2002-11-12 12:42:42 +0200 |
---|---|---|
committer | unknown <monty@mashka.mysql.fi> | 2002-11-12 12:42:42 +0200 |
commit | e1c1abd0e189e4581b9a22aed923df37e535e89b (patch) | |
tree | 64ca040d65207f67531780b5d412e720c122c372 /sql | |
parent | 3165440cdec9d1270a2101973cb75e67e334dc5c (diff) | |
download | mariadb-git-e1c1abd0e189e4581b9a22aed923df37e535e89b.tar.gz |
Extended WEEK() to be able to handle ISO weeks.
unlink socket file if mysqld dies on startup
Some optimization of AND expressions
mysql-test/r/func_time.result:
Update for new week() handling
mysql-test/t/func_time.test:
Update for new week() handling
sql/item_cmpfunc.cc:
Optimization of IF( and-expression,,)
sql/item_cmpfunc.h:
Optimization of AND expressions
sql/item_timefunc.cc:
Extended WEEK() to be able to handle ISO weeks.
sql/mysqld.cc:
unlink socket file if mysqld dies on startup
sql/sql_base.cc:
Fixed problem with SIGHUP and INSERT DELAYED
tests/Makefile.am:
Added missing myisam-big-rows.tst file to source distribution
Diffstat (limited to 'sql')
-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 |
5 files changed, 32 insertions, 9 deletions
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"; |