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/item_timefunc.cc | |
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/item_timefunc.cc')
-rw-r--r-- | sql/item_timefunc.cc | 19 |
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(<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; } |