List:Internals« Previous MessageNext Message »
From:sanja Date:May 9 2005 1:06am
Subject:bk commit into 5.0 tree (bell:1.1950)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of bell. When bell 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.1950 05/05/09 02:06:18 bell@stripped +4 -0
  merge

  mysql-test/r/sp.result
    1.124 05/05/09 02:06:11 bell@stripped +8 -8
    merge

  sql/sp_head.cc
    1.133 05/05/09 02:01:23 bell@stripped +0 -0
    Auto merged

  sql/item.cc
    1.120 05/05/09 02:01:23 bell@stripped +0 -0
    Auto merged

  mysql-test/t/sp.test
    1.118 05/05/09 02:01:22 bell@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:	bell
# Host:	book.sanja.is.com.ua
# Root:	/Users/bell/mysql/bk/work-bug-5.0/RESYNC

--- 1.119/sql/item.cc	2005-05-07 15:02:39 +03:00
+++ 1.120/sql/item.cc	2005-05-09 02:01:23 +03:00
@@ -740,6 +740,13 @@
   return thd->spcont->get_item(m_offset);
 }
 
+
+Item **
+Item_splocal::this_item_addr(THD *thd, Item **addr)
+{
+  return thd->spcont->get_item_addr(m_offset);
+}
+
 Item *
 Item_splocal::this_const_item() const
 {

--- 1.123/mysql-test/r/sp.result	2005-05-07 19:05:52 +03:00
+++ 1.124/mysql-test/r/sp.result	2005-05-09 02:06:11 +03:00
@@ -3073,4 +3073,29 @@
 call bug9841()|
 drop view v1|
 drop procedure bug9841|
+drop procedure if exists bug5963|
+create procedure bug5963_1 () begin declare v int; set v = (select s1 from t3); select v;
end;|
+create table t3 (s1 int)|
+insert into t3 values (5)|
+call bug5963_1()|
+v
+5
+call bug5963_1()|
+v
+5
+drop procedure bug5963_1|
+drop table t3|
+create procedure bug5963_2 (cfk_value int) 
+begin 
+if cfk_value in (select cpk from t3) then 
+set @x = 5; 
+end if; 
+end; 
+|
+create table t3 (cpk int)|
+insert into t3 values (1)|
+call bug5963_2(1)|
+call bug5963_2(1)|
+drop procedure bug5963_2|
+drop table t3|
 drop table t1,t2;

--- 1.117/mysql-test/t/sp.test	2005-05-07 19:05:52 +03:00
+++ 1.118/mysql-test/t/sp.test	2005-05-09 02:01:22 +03:00
@@ -3773,6 +3773,35 @@
 
 
 #
+# BUG#5963 subqueries in SET/IF
+#
+--disable_warnings
+drop procedure if exists bug5963|
+--enable_warnings
+
+create procedure bug5963_1 () begin declare v int; set v = (select s1 from t3); select v;
end;|
+create table t3 (s1 int)|
+insert into t3 values (5)|
+call bug5963_1()|
+call bug5963_1()|
+drop procedure bug5963_1|
+drop table t3|
+
+create procedure bug5963_2 (cfk_value int) 
+begin 
+  if cfk_value in (select cpk from t3) then 
+    set @x = 5; 
+  end if; 
+  end; 
+| 
+create table t3 (cpk int)| 
+insert into t3 values (1)| 
+call bug5963_2(1)|
+call bug5963_2(1)|
+drop procedure bug5963_2|
+drop table t3|
+
+#
 # BUG#NNNN: New bug synopsis
 #
 #--disable_warnings

--- 1.132/sql/sp_head.cc	2005-05-06 13:46:04 +03:00
+++ 1.133/sql/sp_head.cc	2005-05-09 02:01:23 +03:00
@@ -97,19 +97,48 @@
   }
 }
 
+
+/*
+  Prepare Item for execution (call of fix_fields)
+
+  SYNOPSIS
+    sp_prepare_func_item()
+    thd       thread handler
+    it_addr   pointer on item refernce
+
+  RETURN
+    NULL  error
+    prepared item
+*/
+
+static Item *
+sp_prepare_func_item(THD* thd, Item **it_addr)
+{
+  Item *it= *it_addr;
+  DBUG_ENTER("sp_prepare_func_item");
+  it_addr= it->this_item_addr(thd, it_addr);
+
+  if (!it->fixed && (*it_addr)->fix_fields(thd, 0, it_addr))
+  {
+    DBUG_PRINT("info", ("fix_fields() failed"));
+    DBUG_RETURN(NULL);
+  }
+  DBUG_RETURN(*it_addr);
+}
+
+
 /* Evaluate a (presumed) func item. Always returns an item, the parameter
 ** if nothing else.
 */
 Item *
-sp_eval_func_item(THD *thd, Item *it, enum enum_field_types type)
+sp_eval_func_item(THD *thd, Item **it_addr, enum enum_field_types type)
 {
   DBUG_ENTER("sp_eval_func_item");
-  it= it->this_item();
+  Item *it= sp_prepare_func_item(thd, it_addr);
   DBUG_PRINT("info", ("type: %d", type));
 
-  if (!it->fixed && it->fix_fields(thd, 0, &it))
+  if (!it)
   {
-    DBUG_PRINT("info", ("fix_fields() failed"));
     DBUG_RETURN(NULL);
   }
 
@@ -679,7 +708,7 @@
   for (i= 0 ; i < params && i < argcount ; i++)
   {
     sp_pvar_t *pvar = m_pcont->find_pvar(i);
-    Item *it= sp_eval_func_item(thd, *argp++, pvar->type);
+    Item *it= sp_eval_func_item(thd, argp++, pvar->type);
 
     if (it)
       nctx->push_item(it);
@@ -761,7 +790,7 @@
   {
     Item_null *nit= NULL;	// Re-use this, and only create if needed
     uint i;
-    List_iterator_fast<Item> li(*args);
+    List_iterator<Item> li(*args);
     Item *it;
 
     nctx= new sp_rcontext(csize, hmax, cmax);
@@ -794,7 +823,7 @@
 	}
 	else
 	{
-	  Item *it2= sp_eval_func_item(thd, it, pvar->type);
+	  Item *it2= sp_eval_func_item(thd, li.ref(), pvar->type);
 
 	  if (it2)
 	    nctx->push_item(it2); // IN or INOUT
@@ -1439,7 +1468,7 @@
   Item *it;
   int res;
 
-  it= sp_eval_func_item(thd, m_value, m_type);
+  it= sp_eval_func_item(thd, &m_value, m_type);
   if (! it)
     res= -1;
   else
@@ -1569,13 +1598,13 @@
   Item *it;
   int res;
 
-  it= sp_eval_func_item(thd, m_expr, MYSQL_TYPE_TINY);
+  it= sp_prepare_func_item(thd, &m_expr);
   if (!it)
     res= -1;
   else
   {
     res= 0;
-    if (it->val_int())
+    if (it->val_bool())
       *nextp = m_dest;
     else
       *nextp = m_ip+1;
@@ -1627,13 +1656,13 @@
   Item *it;
   int res;
 
-  it= sp_eval_func_item(thd, m_expr, MYSQL_TYPE_TINY);
+  it= sp_prepare_func_item(thd, &m_expr);
   if (! it)
     res= -1;
   else
   {
     res= 0;
-    if (! it->val_int())
+    if (! it->val_bool())
       *nextp = m_dest;
     else
       *nextp = m_ip+1;
@@ -1685,7 +1714,7 @@
   Item *it;
   int res;
 
-  it= sp_eval_func_item(thd, m_value, m_type);
+  it= sp_eval_func_item(thd, &m_value, m_type);
   if (! it)
     res= -1;
   else
Thread
bk commit into 5.0 tree (bell:1.1950)sanja9 May