Commit 7d97d67f authored by monty@hundin.mysql.fi's avatar monty@hundin.mysql.fi

Merge work:/home/bk/mysql-4.0 into hundin.mysql.fi:/my/bk/mysql-4.0

parents a877b10c 2662e135
...@@ -45712,6 +45712,8 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}. ...@@ -45712,6 +45712,8 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}.
@itemize @bullet @itemize @bullet
@item @item
Changed WEEK(#,0) to match the calender in the USA.
@item
Cleaned up global lock handling for @code{FLUSH TABLES WITH READ LOCK} Cleaned up global lock handling for @code{FLUSH TABLES WITH READ LOCK}
@item @item
Fixed problem with @code{DATETIME = constant} in @code{WHERE} optimization. Fixed problem with @code{DATETIME = constant} in @code{WHERE} optimization.
...@@ -73,6 +73,9 @@ int _mi_read_cache(IO_CACHE *info, byte *buff, my_off_t pos, uint length, ...@@ -73,6 +73,9 @@ int _mi_read_cache(IO_CACHE *info, byte *buff, my_off_t pos, uint length,
if (!(flag & READING_HEADER) || info->error == -1 || if (!(flag & READING_HEADER) || info->error == -1 ||
(uint) info->error+in_buff_length < 3) (uint) info->error+in_buff_length < 3)
{ {
DBUG_PRINT("error",
("Error %d reading next-multi-part block (Got %d bytes)",
my_errno, info->error));
if (!my_errno) if (!my_errno)
my_errno=HA_ERR_WRONG_IN_RECORD; my_errno=HA_ERR_WRONG_IN_RECORD;
DBUG_RETURN(1); DBUG_RETURN(1);
...@@ -87,6 +90,9 @@ int _mi_read_cache(IO_CACHE *info, byte *buff, my_off_t pos, uint length, ...@@ -87,6 +90,9 @@ int _mi_read_cache(IO_CACHE *info, byte *buff, my_off_t pos, uint length,
if (!(flag & READING_HEADER) || (int) read_length == -1 || if (!(flag & READING_HEADER) || (int) read_length == -1 ||
read_length+in_buff_length < 3) read_length+in_buff_length < 3)
{ {
DBUG_PRINT("error",
("Error %d reading new block (Got %d bytes)",
my_errno, (int) read_length));
if (!my_errno) if (!my_errno)
my_errno=HA_ERR_WRONG_IN_RECORD; my_errno=HA_ERR_WRONG_IN_RECORD;
DBUG_RETURN(1); DBUG_RETURN(1);
......
...@@ -1009,8 +1009,13 @@ char *mi_recinfo_read(char *ptr, MI_COLUMNDEF *recinfo) ...@@ -1009,8 +1009,13 @@ char *mi_recinfo_read(char *ptr, MI_COLUMNDEF *recinfo)
} }
/************************************************************************** /**************************************************************************
** Help functions for recover Open data file with or without RAID
*************************************************************************/ We can't use dup() here as the data file descriptors need to have different
active seek-positions.
The argument file_to_dup is here for the future if there would on some OS
exist a dup()-like call that would give us two different file descriptors.
*************************************************************************/
int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share, File file_to_dup) int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share, File file_to_dup)
{ {
...@@ -1026,9 +1031,6 @@ int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share, File file_to_dup) ...@@ -1026,9 +1031,6 @@ int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share, File file_to_dup)
} }
else else
#endif #endif
if (file_to_dup >= 0)
info->dfile=my_dup(file_to_dup,MYF(MY_WME));
else
info->dfile=my_open(share->data_file_name, share->mode | O_SHARE, info->dfile=my_open(share->data_file_name, share->mode | O_SHARE,
MYF(MY_WME)); MYF(MY_WME));
return info->dfile >= 0 ? 0 : 1; return info->dfile >= 0 ? 0 : 1;
......
...@@ -27,19 +27,35 @@ DAYOFYEAR("1997-03-03") WEEK("1998-03-03") QUARTER(980303) ...@@ -27,19 +27,35 @@ DAYOFYEAR("1997-03-03") WEEK("1998-03-03") QUARTER(980303)
HOUR("1997-03-03 23:03:22") MINUTE("23:03:22") SECOND(230322) HOUR("1997-03-03 23:03:22") MINUTE("23:03:22") SECOND(230322)
23 3 22 23 3 22
week(19980101) week(19970101) week(19980101,1) week(19970101,1) week(19980101) week(19970101) week(19980101,1) week(19970101,1)
0 1 1 1 0 0 1 1
week(19981231) week(19971231) week(19981231,1) week(19971231,1) week(19981231) week(19971231) week(19981231,1) week(19971231,1)
52 53 53 53 52 52 53 53
week(19950101) week(19950101,1) week(19950101) week(19950101,1)
1 0 1 0
yearweek('1981-12-31',1) yearweek('1982-01-01',1) yearweek('1982-12-31',1) yearweek('1983-01-01',1) yearweek('1981-12-31',1) yearweek('1982-01-01',1) yearweek('1982-12-31',1) yearweek('1983-01-01',1)
198153 198153 198252 198252 198153 198153 198252 198252
yearweek('1987-01-01',1) yearweek('1987-01-01')
198701 198652
2000 2001 2002 2003 2004 2005 2006
0 0 0 0 0 0 1
2000 2001 2002 2003 2004 2005 2006
1 0 1 1 1 1 1
2000 2001 2002 2003 2004 2005 2006
0 1 1 1 1 0 0
2000 2001 2002 2003 2004 2005 2006
1 1 1 2 2 1 1
2000 2001 2002 2003 2004 2005 2006
199952 200053 200152 200252 200352 200452 200601
2000 2001 2002 2003 2004 2005 2006
200001 200053 200201 200301 200401 200501 200601
2000 2001 2002 2003 2004 2005 2006
199952 200101 200201 200301 200401 200453 200552
2000 2001 2002 2003 2004 2005 2006
200001 200101 200201 200302 200402 200501 200601
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
date_format('1999-12-31','%x-%v') date_format('2000-01-01','%x-%v') date_format('1999-12-31','%x-%v') date_format('2000-01-01','%x-%v')
1999-52 1999-52 1999-52 1999-52
yearweek('1987-01-01',1) yearweek('1987-01-01')
198701 198653
dayname("1962-03-03") dayname("1962-03-03")+0 dayname("1962-03-03") dayname("1962-03-03")+0
Saturday 5 Saturday 5
monthname("1972-03-04") monthname("1972-03-04")+0 monthname("1972-03-04") monthname("1972-03-04")+0
......
...@@ -17,13 +17,23 @@ select month("1997-01-02"),year("98-02-03"),dayofyear("1997-12-31"); ...@@ -17,13 +17,23 @@ select month("1997-01-02"),year("98-02-03"),dayofyear("1997-12-31");
select month("2001-02-00"),year("2001-00-00"); select month("2001-02-00"),year("2001-00-00");
select DAYOFYEAR("1997-03-03"), WEEK("1998-03-03"), QUARTER(980303); select DAYOFYEAR("1997-03-03"), WEEK("1998-03-03"), QUARTER(980303);
select HOUR("1997-03-03 23:03:22"), MINUTE("23:03:22"), SECOND(230322); select HOUR("1997-03-03 23:03:22"), MINUTE("23:03:22"), SECOND(230322);
# Test of week and yearweek
select week(19980101),week(19970101),week(19980101,1),week(19970101,1); select week(19980101),week(19970101),week(19980101,1),week(19970101,1);
select week(19981231),week(19971231),week(19981231,1),week(19971231,1); select week(19981231),week(19971231),week(19981231,1),week(19971231,1);
select week(19950101),week(19950101,1); select week(19950101),week(19950101,1);
select yearweek('1981-12-31',1),yearweek('1982-01-01',1),yearweek('1982-12-31',1),yearweek('1983-01-01',1); select yearweek('1981-12-31',1),yearweek('1982-01-01',1),yearweek('1982-12-31',1),yearweek('1983-01-01',1);
select yearweek('1987-01-01',1),yearweek('1987-01-01');
select week("2000-01-01",0) as '2000', week("2001-01-01",0) as '2001', week("2002-01-01",0) as '2002',week("2003-01-01",0) as '2003', week("2004-01-01",0) as '2004', week("2005-01-01",0) as '2005', week("2006-01-01",0) as '2006';
select week("2000-01-06",0) as '2000', week("2001-01-06",0) as '2001', week("2002-01-06",0) as '2002',week("2003-01-06",0) as '2003', week("2004-01-06",0) as '2004', week("2005-01-06",0) as '2005', week("2006-01-06",0) as '2006';
select week("2000-01-01",1) as '2000', week("2001-01-01",1) as '2001', week("2002-01-01",1) as '2002',week("2003-01-01",1) as '2003', week("2004-01-01",1) as '2004', week("2005-01-01",1) as '2005', week("2006-01-01",1) as '2006';
select week("2000-01-06",1) as '2000', week("2001-01-06",1) as '2001', week("2002-01-06",1) as '2002',week("2003-01-06",1) as '2003', week("2004-01-06",1) as '2004', week("2005-01-06",1) as '2005', week("2006-01-06",1) as '2006';
select yearweek("2000-01-01",0) as '2000', yearweek("2001-01-01",0) as '2001', yearweek("2002-01-01",0) as '2002',yearweek("2003-01-01",0) as '2003', yearweek("2004-01-01",0) as '2004', yearweek("2005-01-01",0) as '2005', yearweek("2006-01-01",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-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 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');
select yearweek('1987-01-01',1),yearweek('1987-01-01');
select dayname("1962-03-03"),dayname("1962-03-03")+0; select dayname("1962-03-03"),dayname("1962-03-03")+0;
select monthname("1972-03-04"),monthname("1972-03-04")+0; select monthname("1972-03-04"),monthname("1972-03-04")+0;
......
...@@ -176,7 +176,9 @@ uint calc_week(TIME *l_time, bool with_year, bool sunday_first_day_of_week, ...@@ -176,7 +176,9 @@ uint calc_week(TIME *l_time, bool with_year, bool sunday_first_day_of_week,
ulong first_daynr=calc_daynr(l_time->year,1,1); ulong first_daynr=calc_daynr(l_time->year,1,1);
uint weekday=calc_weekday(first_daynr,sunday_first_day_of_week); uint weekday=calc_weekday(first_daynr,sunday_first_day_of_week);
*year=l_time->year; *year=l_time->year;
if (l_time->month == 1 && weekday >= 4 && l_time->day <= 7-weekday) if (l_time->month == 1 && l_time->day <= 7-weekday &&
((!sunday_first_day_of_week && weekday >= 4) ||
(sunday_first_day_of_week && weekday != 0)))
{ {
/* Last week of the previous year */ /* Last week of the previous year */
if (!with_year) if (!with_year)
...@@ -186,7 +188,8 @@ uint calc_week(TIME *l_time, bool with_year, bool sunday_first_day_of_week, ...@@ -186,7 +188,8 @@ uint calc_week(TIME *l_time, bool with_year, bool sunday_first_day_of_week,
first_daynr-= (days=calc_days_in_year(*year)); first_daynr-= (days=calc_days_in_year(*year));
weekday= (weekday + 53*7- days) % 7; weekday= (weekday + 53*7- days) % 7;
} }
if (weekday >= 4) if ((sunday_first_day_of_week && weekday != 0) ||
(!sunday_first_day_of_week && weekday >= 4))
days= daynr - (first_daynr+ (7-weekday)); days= daynr - (first_daynr+ (7-weekday));
else else
days= daynr - (first_daynr - weekday); days= daynr - (first_daynr - weekday);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment