MySQL Lists are EOL. Please join:

List:Internals« Previous MessageNext Message »
From:eugene Date:August 4 2005 2:05pm
Subject:bk commit into 4.1 tree (evgen:1.2380) BUG#12266
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of evgen. When evgen does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2380 05/08/04 18:05:33 evgen@stripped +3 -0
  Fix bug#12266 GROUP BY DATE(LEFT(column,8)) returns result strings with reduced
  length.
  
  When temporary field created for DATE(LEFT(column,8)) expression, max_length
  value is taken from Item_date_typecast, and it is getting it from underlaid
  Item_func_left and it's max_length is 8 in given expression. And all this
  results in stripping last 2 digits.
  
  To Item_date_typecast class added its own fix_length_and_dec() function 
  that sets max_length value to 10, which is proper for DATE field.

  sql/item_timefunc.h
    1.53 05/08/04 17:50:37 evgen@stripped +6 -0
    Fix bug#12266 GROUP BY DATE(LEFT(column,8)) returns result strings with reduced length.
    To Item_date_typecast class added its own fix_length_and_dec() which sets proper max_length value.

  mysql-test/r/group_by.result
    1.51 05/08/04 17:42:24 evgen@stripped +7 -0
    Test case for bug#12266 GROUP BY DATE(LEFT(column,8)) returns result strings with reduced length.

  mysql-test/t/group_by.test
    1.42 05/08/04 17:39:35 evgen@stripped +10 -0
    Test case for bug#12266 GROUP BY DATE(LEFT(column,8)) returns result strings with reduced length.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	evgen
# Host:	moonbone.local
# Root:	/work/mysql-4.1-bug-12266

--- 1.52/sql/item_timefunc.h	2005-05-04 17:05:53 +04:00
+++ 1.53/sql/item_timefunc.h	2005-08-04 17:50:37 +04:00
@@ -709,6 +709,12 @@
   {
     return (new Field_date(maybe_null, name, t_arg, &my_charset_bin));
   }  
+  void fix_length_and_dec()
+  {
+    collation.set(&my_charset_bin);
+    max_length= 10;
+    maybe_null= 1;
+  }
 };
 
 

--- 1.50/mysql-test/r/group_by.result	2005-06-28 14:17:15 +04:00
+++ 1.51/mysql-test/r/group_by.result	2005-08-04 17:42:24 +04:00
@@ -757,3 +757,10 @@
 n
 2
 DROP TABLE t1;
+create table t1 (f1 date);
+insert into t1 values('2005-06-06');
+insert into t1 values('2005-06-06');
+select date(left(f1+0,8)) from t1 group by 1;
+date(left(f1+0,8))
+2005-06-06
+drop table t1;

--- 1.41/mysql-test/t/group_by.test	2005-07-28 04:21:42 +04:00
+++ 1.42/mysql-test/t/group_by.test	2005-08-04 17:39:35 +04:00
@@ -590,4 +590,14 @@
 SELECT n+1 AS n FROM t1 GROUP BY n;
 DROP TABLE t1;
 
+#
+# Bug #12266 GROUP BY expression on DATE column produces result with
+#            reduced length
+#
+create table t1 (f1 date);
+insert into t1 values('2005-06-06');
+insert into t1 values('2005-06-06'); 
+select date(left(f1+0,8)) from t1 group by 1;
+drop table t1;
+
 # End of 4.1 tests
Thread
bk commit into 4.1 tree (evgen:1.2380) BUG#12266eugene4 Aug