summaryrefslogtreecommitdiff
path: root/sql/item_timefunc.cc
diff options
context:
space:
mode:
authorkostja@bodhi.local <>2006-08-12 21:06:51 +0400
committerkostja@bodhi.local <>2006-08-12 21:06:51 +0400
commit04c97488f91c3db48be384c2ed14082dc6d6616b (patch)
treecccb1fdd583e353f4a229cbb0f9d585104db78f9 /sql/item_timefunc.cc
parentb341356abdfa869c71d42709a13c2192603fab1c (diff)
parent6691c623100134d666b142f5752fcc022bdd1ac9 (diff)
downloadmariadb-git-04c97488f91c3db48be384c2ed14082dc6d6616b.tar.gz
Merge bodhi.local:/opt/local/work/tmp_merge
into bodhi.local:/opt/local/work/mysql-5.1-runtime-merge
Diffstat (limited to 'sql/item_timefunc.cc')
-rw-r--r--sql/item_timefunc.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 2c8d8423d50..e0c80087c05 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -2756,6 +2756,8 @@ longlong Item_func_timestamp_diff::val_int()
{
uint year_beg, year_end, month_beg, month_end, day_beg, day_end;
uint years= 0;
+ uint second_beg, second_end, microsecond_beg, microsecond_end;
+
if (neg == -1)
{
year_beg= ltime2.year;
@@ -2764,6 +2766,10 @@ longlong Item_func_timestamp_diff::val_int()
month_end= ltime1.month;
day_beg= ltime2.day;
day_end= ltime1.day;
+ second_beg= ltime2.hour * 3600 + ltime2.minute * 60 + ltime2.second;
+ second_end= ltime1.hour * 3600 + ltime1.minute * 60 + ltime1.second;
+ microsecond_beg= ltime2.second_part;
+ microsecond_end= ltime1.second_part;
}
else
{
@@ -2773,6 +2779,10 @@ longlong Item_func_timestamp_diff::val_int()
month_end= ltime2.month;
day_beg= ltime1.day;
day_end= ltime2.day;
+ second_beg= ltime1.hour * 3600 + ltime1.minute * 60 + ltime1.second;
+ second_end= ltime2.hour * 3600 + ltime2.minute * 60 + ltime2.second;
+ microsecond_beg= ltime1.second_part;
+ microsecond_end= ltime2.second_part;
}
/* calc years */
@@ -2786,8 +2796,13 @@ longlong Item_func_timestamp_diff::val_int()
months+= 12 - (month_beg - month_end);
else
months+= (month_end - month_beg);
+
if (day_end < day_beg)
months-= 1;
+ else if ((day_end == day_beg) &&
+ ((second_end < second_beg) ||
+ (second_end == second_beg && microsecond_end < microsecond_beg)))
+ months-= 1;
}
switch (int_type) {