List:Commits« Previous MessageNext Message »
From:igor Date:February 7 2007 9:18am
Subject:bk commit into 5.0 tree (igor:1.2404) BUG#26124
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of igor. When igor 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@stripped, 2007-02-07 00:18:36-08:00, igor@stripped +3 -0
  Fixed bug #26124: SELECT from a view wrapper over a table 
  with a column of the DATETIME type could return a wrong 
  result set if the WHERE clause included a BETWEEN condition
  on the column.
  Fixed the method Item_func_between::fix_length_and_dec
  where the aggregation type for BETWEEN predicates calculated
  incorrectly if the first argument was a view column of the
  DATETIME type.

  mysql-test/r/view.result@stripped, 2007-02-07 00:18:34-08:00, igor@stripped +18 -0
    Added a test case for bug #26124.

  mysql-test/t/view.test@stripped, 2007-02-07 00:18:34-08:00, igor@stripped +16 -0
    Added a test case for bug #26124.

  sql/item_cmpfunc.cc@stripped, 2007-02-07 00:18:34-08:00, igor@stripped +2 -2
    Fixed bug #26124: SELECT from a view wrapper over a table 
    with a column of the DATETIME type could return a wrong 
    result set if the WHERE clause included a BETWEEN condition
    on the column.
    Fixed the method Item_func_between::fix_length_and_dec
    where the aggregation type for BETWEEN predicates calculated
    incorrectly if the first argument was a view column of the
    DATETIME type.
     

# 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:	igor
# Host:	olga.mysql.com
# Root:	/home/igor/dev-opt/mysql-5.0-opt-bug26124

--- 1.231/sql/item_cmpfunc.cc	2007-02-07 00:18:42 -08:00
+++ 1.232/sql/item_cmpfunc.cc	2007-02-07 00:18:42 -08:00
@@ -1185,11 +1185,11 @@
     They are compared as integers, so for const item this time-consuming
     conversion can be done only once, not for every single comparison
   */
-  if (args[0]->type() == FIELD_ITEM &&
+  if (args[0]->real_item()->type() == FIELD_ITEM &&
       thd->lex->sql_command != SQLCOM_CREATE_VIEW &&
       thd->lex->sql_command != SQLCOM_SHOW_CREATE)
   {
-    Field *field=((Item_field*) args[0])->field;
+    Field *field=((Item_field*) (args[0]->real_item()))->field;
     if (field->can_be_compared_as_longlong())
     {
       /*

--- 1.187/mysql-test/r/view.result	2007-02-07 00:18:42 -08:00
+++ 1.188/mysql-test/r/view.result	2007-02-07 00:18:42 -08:00
@@ -3034,4 +3034,22 @@
 View	Create View
 v1	CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1`
AS select _latin1'The\ZEnd' AS `TheEnd`
 DROP VIEW v1;
+CREATE TABLE t1 (mydate DATETIME);
+INSERT INTO t1 VALUES 
+('2007-01-01'), ('2007-01-02'), ('2007-01-30'), ('2007-01-31');
+CREATE VIEW v1 AS SELECT mydate from t1;
+SELECT * FROM t1 WHERE mydate BETWEEN '2007-01-01' AND '2007-01-31';
+mydate
+2007-01-01 00:00:00
+2007-01-02 00:00:00
+2007-01-30 00:00:00
+2007-01-31 00:00:00
+SELECT * FROM v1 WHERE mydate BETWEEN '2007-01-01' AND '2007-01-31';
+mydate
+2007-01-01 00:00:00
+2007-01-02 00:00:00
+2007-01-30 00:00:00
+2007-01-31 00:00:00
+DROP VIEW v1;
+DROP TABLE t1;
 End of 5.0 tests.

--- 1.172/mysql-test/t/view.test	2007-02-07 00:18:42 -08:00
+++ 1.173/mysql-test/t/view.test	2007-02-07 00:18:42 -08:00
@@ -2986,4 +2986,20 @@
 
 DROP VIEW v1;
 
+#
+# Bug #26124: BETWEEN over a view column of the DATETIME type
+#
+
+CREATE TABLE t1 (mydate DATETIME);
+INSERT INTO t1 VALUES 
+  ('2007-01-01'), ('2007-01-02'), ('2007-01-30'), ('2007-01-31');
+
+CREATE VIEW v1 AS SELECT mydate from t1;
+
+SELECT * FROM t1 WHERE mydate BETWEEN '2007-01-01' AND '2007-01-31';
+SELECT * FROM v1 WHERE mydate BETWEEN '2007-01-01' AND '2007-01-31';
+
+DROP VIEW v1;
+DROP TABLE t1;
+
 --echo End of 5.0 tests.
Thread
bk commit into 5.0 tree (igor:1.2404) BUG#26124igor7 Feb