Commit f72b5978 authored by unknown's avatar unknown
Browse files

Merge bk-internal.mysql.com:/home/bk/mysql-4.1

into mysql.com:/home/dlenev/src/mysql-4.1-bg6462


sql/set_var.cc:
  Auto merged
parents abb53b6f 4389be75
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -1990,3 +1990,18 @@ ac
700
NULL
drop tables t1,t2;
create table t1 (a int not null, b int not null, c int, primary key (a,b));
insert into t1 values (1,1,1), (2,2,2), (3,3,3);
set @b:= 0;
explain select sum(a) from t1 where b > @b;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t1	index	NULL	PRIMARY	8	NULL	3	Using where; Using index
set @a:= (select sum(a) from t1 where b > @b);
explain select a from t1 where c=2;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	Using where
do @a:= (select sum(a) from t1 where b > @b);
explain select a from t1 where c=2;
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	Using where
drop table t1;
+19 −0
Original line number Diff line number Diff line
@@ -1282,3 +1282,22 @@ INSERT INTO `t2` VALUES (6,5,12,7,'a'),(12,0,0,7,'a'),(12,1,0,7,'a'),(12,5,5,7,'
SELECT b.sc FROM (SELECT (SELECT a.access FROM t1 a WHERE a.map = op.map AND a.slave = op.pid AND a.master = 1) ac FROM t2 op WHERE op.id = 12 AND op.map = 0) b;
SELECT b.ac FROM (SELECT (SELECT a.access FROM t1 a WHERE a.map = op.map AND a.slave = op.pid AND a.master = 1) ac FROM t2 op WHERE op.id = 12 AND op.map = 0) b;
drop tables t1,t2;

#
# Test for bug #6462. "Same request on same data returns different
# results." a.k.a. "Proper cleanup of subqueries is missing for 
# SET and DO statements".
#
create table t1 (a int not null, b int not null, c int, primary key (a,b));
insert into t1 values (1,1,1), (2,2,2), (3,3,3);
set @b:= 0;
# Let us check that subquery will use covering index
explain select sum(a) from t1 where b > @b;
# This should not crash -debug server due to failing assertion
set @a:= (select sum(a) from t1 where b > @b);
# And this should not falsely report index usage
explain select a from t1 where c=2;
# Same for DO statement
do @a:= (select sum(a) from t1 where b > @b);
explain select a from t1 where c=2;
drop table t1;
+11 −6
Original line number Diff line number Diff line
@@ -2733,13 +2733,18 @@ int sql_set_variables(THD *thd, List<set_var_base> *var_list)
  while ((var=it++))
  {
    if ((error=var->check(thd)))
      DBUG_RETURN(error);
      goto err;
  }
  if (thd->net.report_error)
    DBUG_RETURN(1);
  if (!thd->net.report_error)
  {
    it.rewind();
    while ((var= it++))
      error|= var->update(thd);         // Returns 0, -1 or 1
  }
  else
    error= 1;
err:
  free_underlaid_joins(thd, &thd->lex->select_lex);
  DBUG_RETURN(error);
}

+1 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ int mysql_do(THD *thd, List<Item> &values)
    DBUG_RETURN(-1);
  while ((value = li++))
    value->val_int();
  free_underlaid_joins(thd, &thd->lex->select_lex);
  thd->clear_error(); // DO always is OK
  send_ok(thd);
  DBUG_RETURN(0);