List:General Discussion« Previous MessageNext Message »
From:Michael Widenius Date:December 3 1999 9:46am
Subject:3.23.6a bug REPOST
View as plain text  
Hi!

>>>>> "Stephen" == Stephen J Taranto <staranto@stripped> writes:

Stephen> From: staranto@stripped
Stephen> To: mysql@stripped
Stephen> Subject: First time query fails 3.23.6-a

>> Description:
Stephen> 	Refer to the following session trace.  The first time this
Stephen> 	query is executed through the mysql monitor it fails.  All
Stephen> 	subsequent times in the monitor session work properly.

<cut>

>> How-To-Repeat:

<cut>

Thanks for the test tables;  I was able to repeate this on my machine!

On the other hand, I got the same problem when using ISAM tables ...

It took a while to fix this as the simple fix gave a performance
problem :(

This fix will be in 3.23.7;  As 3.23.7 fixes a lot of small problems
in 3.23.6, it may be a good idea to wait for this instead of patching
3.23.6.

Regards,
Monty


*** /my/monty/master/mysql-3.23.6-alpha/sql/opt_range.cc	Wed Nov 10 14:38:11 1999
--- ./opt_range.cc	Fri Dec  3 10:39:01 1999
***************
*** 603,609 ****
  
      /* set up parameter that is passed to all functions */
      param.baseflag=basflag;
!     param.prev_tables=prev_tables;
      param.read_tables=read_tables;
      param.current_table= head->map;
      param.table=head;
--- 602,608 ----
  
      /* set up parameter that is passed to all functions */
      param.baseflag=basflag;
!     param.prev_tables=prev_tables | const_tables;
      param.read_tables=read_tables;
      param.current_table= head->map;
      param.table=head;
*** /my/monty/master/mysql-3.23.6-alpha/sql/sql_select.cc	Thu Nov 11 13:11:09 1999
--- ./sql_select.cc	Fri Dec  3 11:29:39 1999
***************
*** 915,930 ****
        ha_rows records;
        if (!select)
  	select=make_select(s->table,const_table_map,
! 			   const_table_map,
  			   and_conds(conds,s->on_expr),&error);
        records=get_quick_record_count(select,s->table, s->const_keys);
        s->quick=select->quick;
        s->needed_reg=select->needed_reg;
        select->quick=0;
        if (records != HA_POS_ERROR)
        {
  	s->found_records=records;
! 	s->read_time= s->quick ? s->quick->read_time : 0;
        }
      }
    }
--- 917,933 ----
        ha_rows records;
        if (!select)
  	select=make_select(s->table,const_table_map,
! 			   0,
  			   and_conds(conds,s->on_expr),&error);
        records=get_quick_record_count(select,s->table, s->const_keys);
        s->quick=select->quick;
        s->needed_reg=select->needed_reg;
        select->quick=0;
+       select->read_tables=const_table_map;
        if (records != HA_POS_ERROR)
        {
  	s->found_records=records;
! 	s->read_time= (ha_rows) (s->quick ? s->quick->read_time : 0);
        }
      }
    }
***************
*** 1989,1995 ****
  	  }
  	  tab->quick=0;
  	}
! 	uint ref_key=(uint) select->head->reginfo.join_tab->ref.key+1;
  	if (i == join->const_tables && ref_key)
  	{
  	  if (tab->const_keys && tab->table->reginfo.impossible_range)
--- 1992,1998 ----
  	  }
  	  tab->quick=0;
  	}
! 	uint ref_key=(uint) sel->head->reginfo.join_tab->ref.key+1;
  	if (i == join->const_tables && ref_key)
  	{
  	  if (tab->const_keys && tab->table->reginfo.impossible_range)
***************
*** 1998,2009 ****
  	else if (tab->type == JT_ALL)
  	{
  	  if (tab->const_keys &&
! 	      tab->table->reginfo.impossible_range ||
! 	      (tab->keys & ~ tab->const_keys && i > 0) &&
! 	      sel->test_quick_select(tab->keys,
! 				     used_tables & ~ current_map,
! 				     join->thd->select_limit) < 0)
  	    DBUG_RETURN(1);				// Impossible range
  	  if ((sel->quick_keys | sel->needed_reg) & ~tab->checked_keys)
  	  {
  	    tab->keys=sel->quick_keys | sel->needed_reg;
--- 2001,2020 ----
  	else if (tab->type == JT_ALL)
  	{
  	  if (tab->const_keys &&
! 	      tab->table->reginfo.impossible_range)
! 	    DBUG_RETURN(1);				// Impossible range
! 	  if ((tab->keys & ~ tab->const_keys && i > 0))
! 	  {
! 	    if (sel->test_quick_select(tab->keys,
! 				       used_tables & ~ current_map,
! 				       join->thd->select_limit) < 0)
  	    DBUG_RETURN(1);				// Impossible range
+ 	  }
+ 	  else
+ 	  {
+ 	    sel->needed_reg=tab->needed_reg;
+ 	    sel->quick_keys=0;
+ 	  }
  	  if ((sel->quick_keys | sel->needed_reg) & ~tab->checked_keys)
  	  {
  	    tab->keys=sel->quick_keys | sel->needed_reg;
Thread
3.23.6a bug REPOSTStephen J. Taranto1 Dec
  • 3.23.6a bug REPOSTMichael Widenius3 Dec
  • Re: 3.23.6a bug REPOSTStephen J. Taranto3 Dec