From dc25060a5ff117a1c859d4412f2172d762b24109 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 31 May 2004 21:10:15 +0300 Subject: [PATCH 1/3] correct table_hash_search call --- sql/sql_acl.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 4d85741cdaa..af82e4516d6 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -2206,7 +2206,7 @@ bool check_grant_all_columns(THD *thd,uint want_access, TABLE *table) if (table->grant.version != grant_version) { table->grant.grant_table= - table_hash_search(thd->host,thd->ip,thd->db, + table_hash_search(thd->host, thd->ip, table->table_cache_key, thd->priv_user, table->real_name,0); /* purecov: inspected */ table->grant.version=grant_version; /* purecov: inspected */ @@ -2312,7 +2312,7 @@ uint get_column_grant(THD *thd, TABLE_LIST *table, Field *field) if (table->grant.version != grant_version) { table->grant.grant_table= - table_hash_search(thd->host,thd->ip,thd->db, + table_hash_search(thd->host, thd->ip, table->db, thd->priv_user, table->real_name,0); /* purecov: inspected */ table->grant.version=grant_version; /* purecov: inspected */ From 21a4f53e0e4bd6484ac0862013b17669e77dc9eb Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 3 Jun 2004 15:38:38 +0300 Subject: [PATCH 2/3] removed incorrect destructor (to prevent deleting item by recursion instead of by list scanning in case of chained OR or AND) --- sql/item_cmpfunc.h | 1 - 1 file changed, 1 deletion(-) diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index c33042e11ab..a1ed19c1078 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -534,7 +534,6 @@ public: Item_cond() : Item_bool_func() { const_item_cache=0; } Item_cond(Item *i1,Item *i2) :Item_bool_func() { list.push_back(i1); list.push_back(i2); } - ~Item_cond() { list.delete_elements(); } bool add(Item *item) { return list.push_back(item); } bool fix_fields(THD *,struct st_table_list *); From 3665b3be90c2821dc95903cdf39df7a54e3c91a1 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 7 Jun 2004 20:35:05 +0400 Subject: [PATCH 3/3] Fix for bug #4036 multiple SELECT DATE_FORMAT, incorrect results --- mysql-test/r/type_date.result | 2 ++ mysql-test/t/type_date.test | 8 ++++++++ sql/field.cc | 18 ++++++++++++++++++ sql/field.h | 1 + 4 files changed, 29 insertions(+) diff --git a/mysql-test/r/type_date.result b/mysql-test/r/type_date.result index df8f0ee1814..535cad40b8c 100644 --- a/mysql-test/r/type_date.result +++ b/mysql-test/r/type_date.result @@ -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 diff --git a/mysql-test/t/type_date.test b/mysql-test/t/type_date.test index 68c2d55aac9..f3c2acab16e 100644 --- a/mysql-test/t/type_date.test +++ b/mysql-test/t/type_date.test @@ -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; diff --git a/sql/field.cc b/sql/field.cc index 246427cc2ac..d98c9e69d5e 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -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); diff --git a/sql/field.h b/sql/field.h index fb3cf2178e2..657c45cabe6 100644 --- a/sql/field.h +++ b/sql/field.h @@ -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);