summaryrefslogtreecommitdiff
path: root/sql/item_timefunc.cc
diff options
context:
space:
mode:
authormonty@mashka.mysql.fi <>2002-11-12 12:42:42 +0200
committermonty@mashka.mysql.fi <>2002-11-12 12:42:42 +0200
commit97bb57f76526719e1bf53c1dcb55fa9ba87893df (patch)
tree64ca040d65207f67531780b5d412e720c122c372 /sql/item_timefunc.cc
parent876f3f4d308739805a0a1ac71c32c9dc3060a948 (diff)
downloadmariadb-git-97bb57f76526719e1bf53c1dcb55fa9ba87893df.tar.gz
Extended WEEK() to be able to handle ISO weeks.
unlink socket file if mysqld dies on startup Some optimization of AND expressions
Diffstat (limited to 'sql/item_timefunc.cc')
-rw-r--r--sql/item_timefunc.cc19
1 files changed, 16 insertions, 3 deletions
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(&ltime,0))
return 0;
- return (longlong) calc_week(&ltime, 0, args[1]->val_int() == 0, &year);
+ week_format= args[1]->val_int();
+ return (longlong) calc_week(&ltime,
+ (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(&ltime,0))
return 0;
- week=calc_week(&ltime, 1, args[1]->val_int() == 0, &year);
+ week=calc_week(&ltime, 1, (args[1]->val_int() & 1) == 0, &year);
return week+year*100;
}