Fix for bug #4036 multiple SELECT DATE_FORMAT, incorrect results

parent 73964382
......@@ -22,3 +22,5 @@ DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ' , t2.GMT))
Wed, 06 March 2002 10:11:12 GMT-0800
DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ' , t2.GMT)) DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ' , t2.GMT))
Wed, 06 March 2002 10:11:12 GMT-0800 Wed, 06 March 2002 10:11:12 GMT-0800
DATE_FORMAT(f1, "%l.%i %p") DATE_FORMAT(f2, "%l.%i %p")
9.00 AM 12.00 PM
......@@ -75,3 +75,11 @@ SELECT DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ' , t2.
INSERT INTO t1 VALUES(1);
SELECT DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ' , t2.GMT)), DATE_FORMAT("2002-03-06 10:11:12", CONCAT('%a, %d %M %Y %H:%i:%s ' , t2.GMT)) FROM t1,t2 GROUP BY t1.AFIELD;
drop table t1,t2;
#
# Bug 4036
#
CREATE TABLE t1 (f1 time default NULL, f2 time default NULL) TYPE=MyISAM;
INSERT INTO t1 (f1, f2) VALUES ('09:00', '12:00');
SELECT DATE_FORMAT(f1, "%l.%i %p") , DATE_FORMAT(f2, "%l.%i %p") FROM t1;
DROP TABLE t1;
......@@ -2649,6 +2649,24 @@ String *Field_time::val_str(String *val_buffer,
return val_buffer;
}
bool Field_time::get_date(TIME *ltime,
bool fuzzydate __attribute__((unused)))
{
long tmp=(long) sint3korr(ptr);
ltime->neg=0;
if (tmp < 0)
{
ltime->neg= 1;
tmp=-tmp;
}
ltime->hour=tmp/10000;
tmp-=ltime->hour*10000;
ltime->minute= tmp/100;
ltime->second= tmp % 100;
ltime->year= ltime->month= ltime->day= ltime->second_part= 0;
return 0;
}
bool Field_time::get_time(TIME *ltime)
{
long tmp=(long) sint3korr(ptr);
......
......@@ -658,6 +658,7 @@ public:
double val_real(void);
longlong val_int(void);
String *val_str(String*,String *);
bool get_date(TIME *ltime,bool fuzzydate);
bool get_time(TIME *ltime);
int cmp(const char *,const char*);
void sort_string(char *buff,uint length);
......
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