MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:kgeorge Date:April 20 2006 8:05am
Subject:bk commit into 5.1 tree (gkodinov:1.2359) BUG#18492
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of kgeorge. When kgeorge 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.2359 06/04/20 11:05:21 gkodinov@stripped +6 -0
  BUG#18492: mysqld reports ER_ILLEGAL_REFERENCE in --ps-protocol
  
  Fix for the bug 
   
  when no tables are present in an IN subquery and the subquery is complex (not a single select)
  and there is no GROUP BY/HAVING/aggregate functions then it's single select list item was 
  substituted with const 1 (thus becoming unreferenced) and then a special null concious reference 
  (class Item_null_helper : Item_ref_null_helper) was added.
  This was OK for non-prepared statements (because the select list item was allready fixed at the 
  time this reference was created).
  However for prepared statements the item didn't got fixed (as it's not referenced from anywhere)
  and caused an error in Item_ref's code.
  
  Fixed by not substituting the item in the select list so it get's fixed even in the prepared 
  statement's case. Discussed the fix with Sanja. Took out the Item_null_helper class as the 
  ref_pointer_array can be used so it's base class can be used instead. 

  sql/item_subselect.cc
    1.122 06/04/20 11:05:16 gkodinov@stripped +8 -6
    BUG#18492: mysqld reports ER_ILLEGAL_REFERENCE in --ps-protocol
    
    Fix for the bug 
     
    when no tables are present in an IN subquery and the subquery is complex (not a single select)
    and there is no GROUP BY/HAVING/aggregate functions then it's single select list item was 
    substituted with const 1 (thus becoming unreferenced) and then a special null concious reference 
    (class Item_null_helper : Item_ref_null_helper) was added.
    This was OK for non-prepared statements (because the select list item was allready fixed at the 
    time this reference was created).
    However for prepared statements the item didn't got fixed (as it's not referenced from anywhere)
    and caused an error in Item_ref's code.
    
    Fixed by not substituting the item in the select list so it get's fixed even in the prepared 
    statement's case. Discussed the fix with Sanja. Took out the Item_null_helper class as the 
    ref_pointer_array can be used so it's base class can be used instead. 

  sql/item.h
    1.196 06/04/20 11:05:15 gkodinov@stripped +0 -15
    BUG#18492: mysqld reports ER_ILLEGAL_REFERENCE in --ps-protocol
    
    Removed the Item_null_helper class (no longer needed)

  sql/item.cc
    1.184 06/04/20 11:05:15 gkodinov@stripped +0 -7
    BUG#18492: mysqld reports ER_ILLEGAL_REFERENCE in --ps-protocol
    
    Removed the Item_null_helper class

  mysql-test/t/ps_11bugs.test
    1.6 06/04/20 11:05:15 gkodinov@stripped +16 -0
    BUG#18492: mysqld reports ER_ILLEGAL_REFERENCE in --ps-protocol
    
    Testcase added

  mysql-test/r/subselect.result
    1.142 06/04/20 11:05:15 gkodinov@stripped +1 -1
    BUG#18492: mysqld reports ER_ILLEGAL_REFERENCE in --ps-protocol
    
    Fixed explain output

  mysql-test/r/ps_11bugs.result
    1.4 06/04/20 11:05:15 gkodinov@stripped +14 -0
    BUG#18492: mysqld reports ER_ILLEGAL_REFERENCE in --ps-protocol
    
    Testcase added

# 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:	gkodinov
# Host:	rakia.progem.bg
# Root:	/home/kgeorge/mysql/5.1/B18492

--- 1.183/sql/item.cc	2006-04-08 11:48:26 +03:00
+++ 1.184/sql/item.cc	2006-04-20 11:05:15 +03:00
@@ -5184,13 +5184,6 @@
   return FALSE;
 }
 
-void Item_null_helper::print(String *str)
-{
-  str->append(STRING_WITH_LEN("<null_helper>("));
-  store->print(str);
-  str->append(')');
-}
-
 
 bool Item_default_value::eq(const Item *item, bool binary_cmp) const
 {

--- 1.195/sql/item.h	2006-04-04 14:14:56 +03:00
+++ 1.196/sql/item.h	2006-04-20 11:05:15 +03:00
@@ -1904,21 +1904,6 @@
   }
 };
 
-class Item_null_helper :public Item_ref_null_helper
-{
-  Item *store;
-public:
-  Item_null_helper(Name_resolution_context *context_arg,
-                   Item_in_subselect* master, Item *item,
-		   const char *table_name_arg, const char *field_name_arg)
-    :Item_ref_null_helper(context_arg, master, (store= 0, &store),
-                          table_name_arg, field_name_arg),
-     store(item)
-    { ref= &store; }
-  void print(String *str);
-};
-
-
 /*
   The following class is used to optimize comparing of date and bigint columns
   We need to save the original item ('ref') to be able to call

--- 1.141/mysql-test/r/subselect.result	2006-04-06 12:36:07 +03:00
+++ 1.142/mysql-test/r/subselect.result	2006-04-20 11:05:15 +03:00
@@ -744,7 +744,7 @@
 3	DEPENDENT UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
 NULL	UNION RESULT	<union2,3>	ALL	NULL	NULL	NULL	NULL	NULL	
 Warnings:
-Note	1003	select `test`.`t2`.`id` AS `id` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`id`,<exists>(select 1 AS `Not_used` having (<cache>(`test`.`t2`.`id`) = <null_helper>(1)) union select 1 AS `Not_used` having (<cache>(`test`.`t2`.`id`) = <null_helper>(3))))
+Note	1003	select `test`.`t2`.`id` AS `id` from `test`.`t2` where <in_optimizer>(`test`.`t2`.`id`,<exists>(select 1 AS `1` having (<cache>(`test`.`t2`.`id`) = <ref_null_helper>(1)) union select 3 AS `3` having (<cache>(`test`.`t2`.`id`) = <ref_null_helper>(3))))
 SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 3);
 id
 SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2);

--- 1.121/sql/item_subselect.cc	2005-12-12 21:55:12 +02:00
+++ 1.122/sql/item_subselect.cc	2006-04-20 11:05:16 +03:00
@@ -931,14 +931,15 @@
   {
     Item *item= (Item*) select_lex->item_list.head();
 
-    select_lex->item_list.empty();
-    select_lex->item_list.push_back(new Item_int("Not_used",
-						 (longlong) 1, 21));
-    select_lex->ref_pointer_array[0]= select_lex->item_list.head();
     if (select_lex->table_list.elements)
     {
       bool tmp;
       Item *having= item, *orig_item= item;
+
+      select_lex->item_list.empty();
+      select_lex->item_list.push_back(new Item_int("Not_used",
+                                                   (longlong) 1, 21));
+      select_lex->ref_pointer_array[0]= select_lex->item_list.head();
       item= func->create(expr, item);
       if (!abort_on_null && orig_item->maybe_null)
       {
@@ -995,8 +996,9 @@
 	  argument (reference) to fix_fields()
         */
         item= func->create(expr,
-                           new Item_null_helper(&select_lex->context,
-                                                this, item,
+                           new Item_ref_null_helper(&select_lex->context,
+                                                this, 
+                                                select_lex->ref_pointer_array,
                                                 (char *)"<no matter>",
                                                 (char *)"<result>"));
 #ifdef CORRECT_BUT_TOO_SLOW_TO_BE_USABLE

--- 1.3/mysql-test/r/ps_11bugs.result	2004-10-15 13:56:54 +03:00
+++ 1.4/mysql-test/r/ps_11bugs.result	2006-04-20 11:05:15 +03:00
@@ -116,3 +116,17 @@
 cola	colb	cold
 aaaa	yyyy	R
 drop table t1, t2;
+create table t1 (a int primary key);
+insert into t1 values (1);
+explain select * from t1 where 3 in (select (1+1) union select 1);
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	PRIMARY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	Impossible WHERE noticed after reading const tables
+2	DEPENDENT SUBQUERY	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+3	DEPENDENT UNION	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
+NULL	UNION RESULT	<union2,3>	ALL	NULL	NULL	NULL	NULL	NULL	
+select * from t1 where 3 in (select (1+1) union select 1);
+a
+prepare st_18492 from 'select * from t1 where 3 in (select (1+1) union select 1)';
+execute st_18492;
+a
+drop table t1;

--- 1.5/mysql-test/t/ps_11bugs.test	2005-07-28 03:21:46 +03:00
+++ 1.6/mysql-test/t/ps_11bugs.test	2006-04-20 11:05:15 +03:00
@@ -130,3 +130,19 @@
 # end of bug#1676
 
 # End of 4.1 tests
+
+# bug#18492: mysqld reports ER_ILLEGAL_REFERENCE in --ps-protocol
+
+create table t1 (a int primary key);
+insert into t1 values (1);
+
+explain select * from t1 where 3 in (select (1+1) union select 1);
+
+select * from t1 where 3 in (select (1+1) union select 1);
+
+prepare st_18492 from 'select * from t1 where 3 in (select (1+1) union select 1)';
+execute st_18492;
+
+drop table t1;
+
+# end of bug#18492
Thread
bk commit into 5.1 tree (gkodinov:1.2359) BUG#18492kgeorge20 Apr