mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
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
This commit is contained in:
@ -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';
|
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
|
2000 2001 2002 2003 2004 2005 2006
|
||||||
200001 200101 200201 200302 200402 200501 200601
|
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');
|
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')
|
date_format('1998-12-31','%x-%v') date_format('1999-01-01','%x-%v')
|
||||||
1998-53 1998-53
|
1998-53 1998-53
|
||||||
|
@ -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-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-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 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('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');
|
select date_format('1999-12-31','%x-%v'),date_format('2000-01-01','%x-%v');
|
||||||
|
|
||||||
|
@ -533,7 +533,6 @@ Item_func_if::fix_length_and_dec()
|
|||||||
else
|
else
|
||||||
cached_result_type=arg1_type; // Should be INT_RESULT
|
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
|
#endif
|
||||||
item= *li.ref(); // new current item
|
item= *li.ref(); // new current item
|
||||||
}
|
}
|
||||||
|
if (abort_on_null)
|
||||||
|
item->top_level_item();
|
||||||
if (item->fix_fields(thd,tables))
|
if (item->fix_fields(thd,tables))
|
||||||
return 1; /* purecov: inspected */
|
return 1; /* purecov: inspected */
|
||||||
used_tables_cache|=item->used_tables();
|
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();
|
const_item_cache&=item->const_item();
|
||||||
if (item->maybe_null)
|
if (item->maybe_null)
|
||||||
maybe_null=1;
|
maybe_null=1;
|
||||||
if (abort_on_null)
|
|
||||||
item->top_level_item();
|
|
||||||
}
|
}
|
||||||
if (thd)
|
if (thd)
|
||||||
thd->cond_count+=list.elements;
|
thd->cond_count+=list.elements;
|
||||||
|
@ -216,6 +216,11 @@ public:
|
|||||||
longlong val_int();
|
longlong val_int();
|
||||||
String *val_str(String *str);
|
String *val_str(String *str);
|
||||||
enum Item_result result_type () const { return cached_result_type; }
|
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();
|
void fix_length_and_dec();
|
||||||
const char *func_name() const { return "if"; }
|
const char *func_name() const { return "if"; }
|
||||||
unsigned int size_of() { return sizeof(*this);}
|
unsigned int size_of() { return sizeof(*this);}
|
||||||
|
@ -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()
|
longlong Item_func_week::val_int()
|
||||||
{
|
{
|
||||||
uint year;
|
uint year;
|
||||||
|
uint week_format;
|
||||||
TIME ltime;
|
TIME ltime;
|
||||||
if (get_arg0_date(<ime,0))
|
if (get_arg0_date(<ime,0))
|
||||||
return 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;
|
TIME ltime;
|
||||||
if (get_arg0_date(<ime,0))
|
if (get_arg0_date(<ime,0))
|
||||||
return 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;
|
return week+year*100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2003,6 +2003,8 @@ int main(int argc, char **argv)
|
|||||||
if (ha_init())
|
if (ha_init())
|
||||||
{
|
{
|
||||||
sql_print_error("Can't init databases");
|
sql_print_error("Can't init databases");
|
||||||
|
if (unix_sock != INVALID_SOCKET)
|
||||||
|
unlink(mysql_unix_port);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
ha_key_cache();
|
ha_key_cache();
|
||||||
@ -2038,6 +2040,8 @@ int main(int argc, char **argv)
|
|||||||
pthread_key_create(&THR_MALLOC,NULL))
|
pthread_key_create(&THR_MALLOC,NULL))
|
||||||
{
|
{
|
||||||
sql_print_error("Can't create thread-keys");
|
sql_print_error("Can't create thread-keys");
|
||||||
|
if (unix_sock != INVALID_SOCKET)
|
||||||
|
unlink(mysql_unix_port);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
start_signal_handler(); // Creates pidfile
|
start_signal_handler(); // Creates pidfile
|
||||||
@ -2050,6 +2054,8 @@ int main(int argc, char **argv)
|
|||||||
if (!opt_bootstrap)
|
if (!opt_bootstrap)
|
||||||
(void) my_delete(pidfile_name,MYF(MY_WME)); // Not needed anymore
|
(void) my_delete(pidfile_name,MYF(MY_WME)); // Not needed anymore
|
||||||
#endif
|
#endif
|
||||||
|
if (unix_sock != INVALID_SOCKET)
|
||||||
|
unlink(mysql_unix_port);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (!opt_noacl)
|
if (!opt_noacl)
|
||||||
@ -4467,8 +4473,8 @@ fn_format_relative_to_data_home(my_string to, const char *name,
|
|||||||
static void fix_paths(void)
|
static void fix_paths(void)
|
||||||
{
|
{
|
||||||
char buff[FN_REFLEN];
|
char buff[FN_REFLEN];
|
||||||
(void) fn_format(mysql_home,mysql_home,"","",16); // Remove symlinks
|
|
||||||
convert_dirname(mysql_home,mysql_home,NullS);
|
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(mysql_real_data_home,mysql_real_data_home,NullS);
|
||||||
convert_dirname(language,language,NullS);
|
convert_dirname(language,language,NullS);
|
||||||
(void) my_load_path(mysql_home,mysql_home,""); // Resolve current dir
|
(void) my_load_path(mysql_home,mysql_home,""); // Resolve current dir
|
||||||
|
@ -376,14 +376,14 @@ bool close_cached_tables(THD *thd, bool if_wait_for_refresh,
|
|||||||
if (!found)
|
if (!found)
|
||||||
if_wait_for_refresh=0; // Nothing to wait for
|
if_wait_for_refresh=0; // Nothing to wait for
|
||||||
}
|
}
|
||||||
|
if (!tables)
|
||||||
|
kill_delayed_threads();
|
||||||
if (if_wait_for_refresh)
|
if (if_wait_for_refresh)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
If there is any table that has a lower refresh_version, wait until
|
If there is any table that has a lower refresh_version, wait until
|
||||||
this is closed (or this thread is killed) before returning
|
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_mutex= &LOCK_open;
|
||||||
thd->mysys_var->current_cond= &COND_refresh;
|
thd->mysys_var->current_cond= &COND_refresh;
|
||||||
thd->proc_info="Flushing tables";
|
thd->proc_info="Flushing tables";
|
||||||
|
@ -24,7 +24,7 @@ EXTRA_DIST = auto_increment.res auto_increment.tst \
|
|||||||
insert_and_repair.pl \
|
insert_and_repair.pl \
|
||||||
grant.pl grant.res test_delayed_insert.pl \
|
grant.pl grant.res test_delayed_insert.pl \
|
||||||
pmail.pl mail_to_db.pl table_types.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
|
# Don't update the files from bitkeeper
|
||||||
%::SCCS/s.%
|
%::SCCS/s.%
|
||||||
|
Reference in New Issue
Block a user