List:Commits« Previous MessageNext Message »
From:igor Date:February 3 2006 6:23am
Subject:bk commit into 5.0 tree (igor:1.2028)
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
  1.2028 06/02/02 21:23:36 igor@stripped +6 -0
  Merge rurik.mysql.com:/home/igor/dev/mysql-4.1-0
  into  rurik.mysql.com:/home/igor/dev/mysql-5.0-0

  sql/sql_select.cc
    1.392 06/02/02 21:23:30 igor@stripped +8 -2
    Manual merge

  sql/sql_prepare.cc
    1.168 06/02/02 21:23:30 igor@stripped +110 -20
    Manual merge

  sql/sql_lex.h
    1.211 06/02/02 21:23:30 igor@stripped +0 -0
    Manual merge

  sql/sql_lex.cc
    1.177 06/02/02 21:23:30 igor@stripped +1 -3
    Manual merge

  mysql-test/r/having.result
    1.19 06/02/02 21:23:30 igor@stripped +17 -0
    Manual merge

  mysql-test/t/having.test
    1.18 06/02/02 20:39:19 igor@stripped +0 -0
    Auto merged

# 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:	rurik.mysql.com
# Root:	/home/igor/dev/mysql-5.0-0/RESYNC

--- 1.176/sql/sql_lex.cc	2005-12-10 23:30:52 -08:00
+++ 1.177/sql/sql_lex.cc	2006-02-02 21:23:30 -08:00
@@ -1122,7 +1122,7 @@
   embedding= leaf_tables= 0;
   item_list.empty();
   join= 0;
-  having= where= prep_where= 0;
+  having= prep_having= where= prep_where= 0;
   olap= UNSPECIFIED_OLAP_TYPE;
   having_fix_field= 0;
   context.select_lex= this;

--- 1.210/sql/sql_lex.h	2005-12-10 23:30:52 -08:00
+++ 1.211/sql/sql_lex.h	2006-02-02 21:23:30 -08:00
@@ -474,6 +474,7 @@
   char *db;
   Item *where, *having;                         /* WHERE & HAVING clauses */
   Item *prep_where; /* saved WHERE clause for prepared statement processing */
+  Item *prep_having;/* saved HAVING clause for prepared statement processing */
   /* point on lex in which it was created, used in view subquery detection */
   st_lex *parent_lex;
   enum olap_type olap;

--- 1.391/sql/sql_select.cc	2006-02-02 13:47:15 -08:00
+++ 1.392/sql/sql_select.cc	2006-02-02 21:23:30 -08:00
@@ -612,6 +612,7 @@
     build_bitmap_for_nested_joins(join_list, 0);
 
     sel->prep_where= conds ? conds->copy_andor_structure(thd) : 0;
+    sel->prep_having= having ? having->copy_andor_structure(thd) : 0;
 
     if (arena)
       thd->restore_active_arena(arena, &backup);
@@ -625,13 +626,26 @@
     DBUG_RETURN(1);
   }
 
-  if (cond_value == Item::COND_FALSE ||
-      (!unit->select_limit_cnt && !(select_options & OPTION_FOUND_ROWS)))
-  {						/* Impossible cond */
-    DBUG_PRINT("info", ("Impossible WHERE"));
-    zero_result_cause= "Impossible WHERE";
-    error= 0;
-    DBUG_RETURN(0);
+  {
+    Item::cond_result having_value;
+    having= optimize_cond(thd, having, &having_value);
+    if (thd->net.report_error)
+    {
+      error= 1;
+      DBUG_PRINT("error",("Error from optimize_cond"));
+      DBUG_RETURN(1);
+    }
+
+    if (cond_value == Item::COND_FALSE || having_value == Item::COND_FALSE || 
+        (!unit->select_limit_cnt && !(select_options &
OPTION_FOUND_ROWS)))
+    {						/* Impossible cond */
+      DBUG_PRINT("info", (having_value == Item::COND_FALSE ? 
+                            "Impossible HAVING" : "Impossible WHERE"));
+      zero_result_cause=  ?
+                           "Impossible HAVING" : "Impossible WHERE";
+      error= 0;
+      DBUG_RETURN(0);
+    }
   }
 
   /* Optimize count(*), min() and max() */

--- 1.18/mysql-test/r/having.result	2006-01-07 23:10:03 -08:00
+++ 1.19/mysql-test/r/having.result	2006-02-02 21:23:30 -08:00
@@ -141,6 +141,40 @@
 6
 4
 DROP TABLE t1;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+CREATE TABLE t1 (a int);
+INSERT INTO t1 VALUES (1), (2), (1), (3), (2), (1);
+SELECT a FROM t1 GROUP BY a HAVING a > 1;
+a
+2
+3
+SELECT a FROM t1 GROUP BY a HAVING 1 != 1 AND a > 1;
+a
+SELECT 0 AS x, a FROM t1 GROUP BY x,a HAVING x=1 AND a > 1;
+x	a
+EXPLAIN SELECT a FROM t1 GROUP BY a HAVING 1 != 1 AND a > 1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible HAVING
+EXPLAIN SELECT 0 AS x, a FROM t1 GROUP BY x,a HAVING x=1 AND a > 1;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible HAVING
+DROP table t1;
 create table t1 (col1 int, col2 varchar(5), col_t1 int);
 create table t2 (col1 int, col2 varchar(5), col_t2 int);
 create table t3 (col1 int, col2 varchar(5), col_t3 int);

--- 1.17/mysql-test/t/having.test	2006-01-07 23:04:52 -08:00
+++ 1.18/mysql-test/t/having.test	2006-02-02 20:39:19 -08:00
@@ -135,6 +135,22 @@
 
 DROP TABLE t1;
 
+#
+# Bug #14927: HAVING clause containing constant false conjunct
+#
+
+CREATE TABLE t1 (a int);
+INSERT INTO t1 VALUES (1), (2), (1), (3), (2), (1);
+
+SELECT a FROM t1 GROUP BY a HAVING a > 1;
+SELECT a FROM t1 GROUP BY a HAVING 1 != 1 AND a > 1;
+SELECT 0 AS x, a FROM t1 GROUP BY x,a HAVING x=1 AND a > 1;
+
+EXPLAIN SELECT a FROM t1 GROUP BY a HAVING 1 != 1 AND a > 1;
+EXPLAIN SELECT 0 AS x, a FROM t1 GROUP BY x,a HAVING x=1 AND a > 1;
+
+DROP table t1;  
+
 # End of 4.1 tests
 
 #

--- 1.167/sql/sql_prepare.cc	2006-01-24 04:48:13 -08:00
+++ 1.168/sql/sql_prepare.cc	2006-02-02 21:23:30 -08:00
@@ -1862,6 +1862,96 @@
   {
     /* Statement map deletes statement on erase */
     thd->stmt_map.erase(stmt);
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
   }
   else
     mysql_log.write(thd, COM_STMT_PREPARE, "[%lu] %s", stmt->id, packet);
@@ -1955,11 +2045,14 @@
   }
   else
   {
-    query_str= lex->prepared_stmt_code.str;
-    *query_len= lex->prepared_stmt_code.length;
-  }
-end:
-  return query_str;
+    stmt->setup_set_params();
+    SELECT_LEX *sl= stmt->lex->all_selects_list;
+    for (; sl; sl= sl->next_select_in_list())
+    {
+      /*
+        during query optimisation.
+      */
+      sl->prep_where= sl->where;
 }
 
 
@@ -2066,14 +2159,19 @@
       sl->exclude_from_table_unique_test= FALSE;
 
       /*
-        Copy WHERE clause pointers to avoid damaging they by optimisation
+        Copy WHERE, HAVING clause pointers to avoid damaging them by optimisation
       */
-      if (sl->prep_where)
-      {
-        sl->where= sl->prep_where->copy_andor_structure(thd);
-        sl->where->cleanup();
-      }
-      DBUG_ASSERT(sl->join == 0);
+     if (sl->prep_where)
+     {
+       sl->where= sl->prep_where->copy_andor_structure(thd);
+       sl->where->cleanup();
+     }
+     if (sl->prep_having)
+     {
+       sl->having= sl->prep_having->copy_andor_structure(thd);
+       sl->having->cleanup();
+     }
+     DBUG_ASSERT(sl->join == 0);
       ORDER *order;
       /* Fix GROUP list */
       for (order= (ORDER *)sl->group_list.first; order; order= order->next)
Thread
bk commit into 5.0 tree (igor:1.2028)igor3 Feb