List:Internals« Previous MessageNext Message »
From:konstantin Date:June 7 2005 10:35pm
Subject:bk commit into 5.0 tree (konstantin:1.1945) BUG#7306
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of kostja. When kostja 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.1945 05/06/08 00:34:53 konstantin@stripped +5 -0
  A followup patch for Bug#7306 (limit in prepared statements):
  don't evaluate subqueries during statement prepare, even if they
  are not correlated.
  With post-review fixes.

  sql/sql_prepare.cc
    1.117 05/06/08 00:34:46 konstantin@stripped +3 -0
    Switch off the uncacheable flag when prepare is done.

  sql/sql_parse.cc
    1.451 05/06/08 00:34:46 konstantin@stripped +8 -6
    Mark new SELECT_LEXes as uncacheable if they created during 
    statement prepare.

  sql/sql_lex.h
    1.182 05/06/08 00:34:46 konstantin@stripped +1 -0
    Comment fixed.

  sql/sql_lex.cc
    1.148 05/06/08 00:34:45 konstantin@stripped +1 -0
    Add a missing assert: noone can call unit::set_limit from 
    mysql_stmt_prepare.

  sql/mysql_priv.h
    1.310 05/06/08 00:34:45 konstantin@stripped +2 -0
    Add UNCACHEABLE_PREPARE to mark subqueries as non-constant in 
    mysql_stmt_prepare

# 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:	konstantin
# Host:	dragonfly.local
# Root:	/opt/local/work/mysql-5.0-7306-final

--- 1.309/sql/mysql_priv.h	2005-06-07 12:30:02 +04:00
+++ 1.310/sql/mysql_priv.h	2005-06-08 00:34:45 +04:00
@@ -336,6 +336,8 @@
 #define UNCACHEABLE_SIDEEFFECT	4
 // forcing to save JOIN for explain
 #define UNCACHEABLE_EXPLAIN     8
+/* Don't evaluate subqueries in prepare even if they're not correlated */
+#define UNCACHEABLE_PREPARE    16
 
 #ifdef EXTRA_DEBUG
 /*

--- 1.147/sql/sql_lex.cc	2005-06-07 14:11:28 +04:00
+++ 1.148/sql/sql_lex.cc	2005-06-08 00:34:45 +04:00
@@ -1757,6 +1757,7 @@
 {
   ulonglong select_limit_val;
 
+  DBUG_ASSERT(! thd->current_arena->is_stmt_prepare());
   select_limit_val= sl->select_limit ? sl->select_limit->val_uint() :
                                        HA_POS_ERROR;
   offset_limit_cnt= sl->offset_limit ? sl->offset_limit->val_uint() : ULL(0);

--- 1.181/sql/sql_lex.h	2005-06-07 14:11:28 +04:00
+++ 1.182/sql/sql_lex.h	2005-06-08 00:34:46 +04:00
@@ -303,6 +303,7 @@
       UNCACHEABLE_RAND
       UNCACHEABLE_SIDEEFFECT
       UNCACHEABLE_EXPLAIN
+      UNCACHEABLE_PREPARE
   */
   uint8 uncacheable;
   enum sub_select_type linkage;

--- 1.450/sql/sql_parse.cc	2005-06-07 16:28:05 +04:00
+++ 1.451/sql/sql_parse.cc	2005-06-08 00:34:46 +04:00
@@ -5169,26 +5169,28 @@
 mysql_new_select(LEX *lex, bool move_down)
 {
   SELECT_LEX *select_lex;
-  THD *thd;
+  THD *thd= lex->thd;
   DBUG_ENTER("mysql_new_select");
 
-  if (!(select_lex= new(lex->thd->mem_root) SELECT_LEX()))
+  if (!(select_lex= new (thd->mem_root) SELECT_LEX()))
     DBUG_RETURN(1);
-  select_lex->select_number= ++lex->thd->select_number;
+  select_lex->select_number= ++thd->select_number;
   select_lex->init_query();
   select_lex->init_select();
   select_lex->parent_lex= lex;
+  if (thd->current_arena->is_stmt_prepare())
+    select_lex->uncacheable|= UNCACHEABLE_PREPARE;
   if (move_down)
   {
     SELECT_LEX_UNIT *unit;
     lex->subqueries= TRUE;
     /* first select_lex of subselect or derived table */
-    if (!(unit= new(lex->thd->mem_root) SELECT_LEX_UNIT()))
+    if (!(unit= new (thd->mem_root) SELECT_LEX_UNIT()))
       DBUG_RETURN(1);
 
     unit->init_query();
     unit->init_select();
-    unit->thd= lex->thd;
+    unit->thd= thd;
     unit->include_down(lex->current_select);
     unit->link_next= 0;
     unit->link_prev= 0;
@@ -5212,7 +5214,7 @@
 	as far as we included SELECT_LEX for UNION unit should have
 	fake SELECT_LEX for UNION processing
       */
-      if (!(fake= unit->fake_select_lex= new(lex->thd->mem_root) SELECT_LEX()))
+      if (!(fake= unit->fake_select_lex= new (thd->mem_root) SELECT_LEX()))
         DBUG_RETURN(1);
       fake->include_standalone(unit,
 			       (SELECT_LEX_NODE**)&unit->fake_select_lex);

--- 1.116/sql/sql_prepare.cc	2005-05-16 14:34:19 +04:00
+++ 1.117/sql/sql_prepare.cc	2005-06-08 00:34:46 +04:00
@@ -1838,7 +1838,10 @@
     optimisation.
   */
   for (; sl; sl= sl->next_select_in_list())
+  {
     sl->prep_where= sl->where;
+    sl->uncacheable&= ~UNCACHEABLE_PREPARE;
+  }
 
   for (TABLE_LIST *table= lex->query_tables; table; table= table->next_global)
     table->prep_on_expr= table->on_expr;
Thread
bk commit into 5.0 tree (konstantin:1.1945) BUG#7306konstantin7 Jun