[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mysql-bugs
Subject:    Patches for two bugs in 3.23.35
From:       Sinisa Milivojevic <sinisa () mysql ! com>
Date:       2001-03-21 17:09:26
[Download RAW message or body]


Hi!

There were two bugs reported in 3.23.35.

First one deals with info not being displayed after table has been
changed with UPDATE, LOAD DATA or similar. Here is patch for that bug:


===== sql_parse.cc 1.118 vs edited =====
*** /tmp/sql_parse.cc-1.118-23407       Wed Mar 21 00:58:38 2001
--- edited/sql_parse.cc Wed Mar 21 14:24:21 2001
***************
*** 455,461 ****
      db=strend(passwd)+1;
    if (thd->client_capabilities & CLIENT_INTERACTIVE)
      thd->inactive_timeout=net_interactive_timeout;
!   if (thd->client_capabilities & CLIENT_TRANSACTIONS)
      thd->net.return_status= &thd->server_status;
    net->timeout=net_read_timeout;
    if (check_user(thd,COM_CONNECT, user, passwd, db, 1))
--- 455,462 ----
      db=strend(passwd)+1;
    if (thd->client_capabilities & CLIENT_INTERACTIVE)
      thd->inactive_timeout=net_interactive_timeout;
!   if ((thd->client_capabilities & CLIENT_TRANSACTIONS) &&
!       opt_using_transactions)
      thd->net.return_status= &thd->server_status;
    net->timeout=net_read_timeout;
    if (check_user(thd,COM_CONNECT, user, passwd, db, 1))


And a second bug deals with UPDATE not working in certain cases. Here
is a patch for this bug:


===== sql/sql_load.cc 1.22 vs edited =====
*** /tmp/sql_load.cc-1.22-24964	Sun Dec 24 15:18:59 2000
--- edited/sql/sql_load.cc	Wed Mar 21 19:38:21 2001
***************
*** 91,97 ****
    else
    {						// Part field list
      thd->dupp_field=0;
!     if (setup_fields(thd,table_list,fields,1,0) < 0)
        DBUG_RETURN(-1);
      if (thd->dupp_field)
      {
--- 91,97 ----
    else
    {						// Part field list
      thd->dupp_field=0;
!     if (setup_tables(table_list) || setup_fields(thd,table_list,fields,1,0))
        DBUG_RETURN(-1);
      if (thd->dupp_field)
      {
===== sql/sql_insert.cc 1.34 vs edited =====
*** /tmp/sql_insert.cc-1.34-24964	Tue Mar 13 11:44:01 2001
--- edited/sql/sql_insert.cc	Wed Mar 21 19:38:21 2001
***************
*** 78,84 ****
      table_list.grant=table->grant;
  
      thd->dupp_field=0;
!     if (setup_fields(thd,&table_list,fields,1,0))
        return -1;
      if (thd->dupp_field)
      {
--- 78,84 ----
      table_list.grant=table->grant;
  
      thd->dupp_field=0;
!     if (setup_tables(&table_list) || setup_fields(thd,&table_list,fields,1,0))
        return -1;
      if (thd->dupp_field)
      {
***************
*** 151,157 ****
    save_time_stamp=table->time_stamp;
    values= its++;
    if (check_insert_fields(thd,table,fields,*values,1) ||
!       setup_fields(thd,table_list,*values,0,0))
    {
      table->time_stamp=save_time_stamp;
      goto abort;
--- 151,157 ----
    save_time_stamp=table->time_stamp;
    values= its++;
    if (check_insert_fields(thd,table,fields,*values,1) ||
!       setup_tables(table_list) || setup_fields(thd,table_list,*values,0,0))
    {
      table->time_stamp=save_time_stamp;
      goto abort;
***************
*** 168,174 ****
        table->time_stamp=save_time_stamp;
        goto abort;
      }
!     if (setup_fields(thd,table_list,*values,0,0))
      {
        table->time_stamp=save_time_stamp;
        goto abort;
--- 168,174 ----
        table->time_stamp=save_time_stamp;
        goto abort;
      }
!     if (setup_tables(table_list) || setup_fields(thd,table_list,*values,0,0))
      {
        table->time_stamp=save_time_stamp;
        goto abort;
===== sql/sql_base.cc 1.67 vs edited =====
*** /tmp/sql_base.cc-1.67-24964	Sat Mar  3 03:03:12 2001
--- edited/sql/sql_base.cc	Wed Mar 21 19:34:56 2001
***************
*** 39,45 ****
  			  List_iterator<Item> *it);
  static void free_cache_entry(TABLE *entry);
  static void mysql_rm_tmp_tables(void);
! static key_map get_key_map_from_key_list(THD *thd, TABLE *table,
  					 List<String> *index_list);
  
  
--- 39,45 ----
  			  List_iterator<Item> *it);
  static void free_cache_entry(TABLE *entry);
  static void mysql_rm_tmp_tables(void);
! static key_map get_key_map_from_key_list(TABLE *table,
  					 List<String> *index_list);
  
  
***************
*** 1711,1721 ****
    return found;
  }
  
- 
  /****************************************************************************
  ** Check that all given fields exists and fill struct with current data
- ** Check also that the 'used keys' and 'ignored keys' exists and set up the
- ** table structure accordingly
  ****************************************************************************/
  
  int setup_fields(THD *thd, TABLE_LIST *tables, List<Item> &fields,
--- 1711,1718 ----
***************
*** 1729,1735 ****
    thd->allow_sum_func= test(sum_func_list);
    thd->where="field list";
  
!   /* Remap table numbers if INSERT ... SELECT */
    uint tablenr=0;
    for (TABLE_LIST *table=tables ; table ; table=table->next,tablenr++)
    {
--- 1726,1761 ----
    thd->allow_sum_func= test(sum_func_list);
    thd->where="field list";
  
!   while ((item=it++))
!   {
!     if (item->type() == Item::FIELD_ITEM &&
! 	((Item_field*) item)->field_name[0] == '*')
!     {
!       if (insert_fields(thd,tables,((Item_field*) item)->table_name,&it))
! 	DBUG_RETURN(-1); /* purecov: inspected */
!     }
!     else
!     {
!       if (item->fix_fields(thd,tables))
! 	DBUG_RETURN(-1); /* purecov: inspected */
!       if (item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM)
! 	item->split_sum_func(*sum_func_list);
!       thd->used_tables|=item->used_tables();
!     }
!   }
!   DBUG_RETURN(test(thd->fatal_error));
! }
! 
! 
! /*
!   Remap table numbers if INSERT ... SELECT
!   Check also that the 'used keys' and 'ignored keys' exists and set up the
!   table structure accordingly
! */
! 
! bool setup_tables(TABLE_LIST *tables)
! {
!   DBUG_ENTER("setup_tables");
    uint tablenr=0;
    for (TABLE_LIST *table=tables ; table ; table=table->next,tablenr++)
    {
***************
*** 1739,1786 ****
        table->table->maybe_null=1;		// LEFT OUTER JOIN ...
      if (table->use_index)
      {
!       key_map map= get_key_map_from_key_list(thd,table->table,
  					     table->use_index);
        if (map == ~(key_map) 0)
! 	DBUG_RETURN(-1);
        table->table->keys_in_use_for_query=map;
      }
      if (table->ignore_index)
      {
!       key_map map= get_key_map_from_key_list(thd,table->table,
  					     table->ignore_index);
        if (map == ~(key_map) 0)
! 	DBUG_RETURN(-1);
        table->table->keys_in_use_for_query &= ~map;
      }
    }
    if (tablenr > MAX_TABLES)
    {
      my_error(ER_TOO_MANY_TABLES,MYF(0),MAX_TABLES);
!     DBUG_RETURN(-1);
!   }
!   while ((item=it++))
!   {
!     if (item->type() == Item::FIELD_ITEM &&
! 	((Item_field*) item)->field_name[0] == '*')
!     {
!       if (insert_fields(thd,tables,((Item_field*) item)->table_name,&it))
! 	DBUG_RETURN(-1); /* purecov: inspected */
!     }
!     else
!     {
!       if (item->fix_fields(thd,tables))
! 	DBUG_RETURN(-1); /* purecov: inspected */
!       if (item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM)
! 	item->split_sum_func(*sum_func_list);
!       thd->used_tables|=item->used_tables();
!     }
    }
!   DBUG_RETURN(test(thd->fatal_error));
  }
  
  
! static key_map get_key_map_from_key_list(THD *thd, TABLE *table,
  					 List<String> *index_list)
  {
    key_map map=0;
--- 1765,1795 ----
        table->table->maybe_null=1;		// LEFT OUTER JOIN ...
      if (table->use_index)
      {
!       key_map map= get_key_map_from_key_list(table->table,
  					     table->use_index);
        if (map == ~(key_map) 0)
! 	DBUG_RETURN(1);
        table->table->keys_in_use_for_query=map;
      }
      if (table->ignore_index)
      {
!       key_map map= get_key_map_from_key_list(table->table,
  					     table->ignore_index);
        if (map == ~(key_map) 0)
! 	DBUG_RETURN(1);
        table->table->keys_in_use_for_query &= ~map;
      }
    }
    if (tablenr > MAX_TABLES)
    {
      my_error(ER_TOO_MANY_TABLES,MYF(0),MAX_TABLES);
!     DBUG_RETURN(1);
    }
!   DBUG_RETURN(0);
  }
  
  
! static key_map get_key_map_from_key_list(TABLE *table, 
  					 List<String> *index_list)
  {
    key_map map=0;
===== sql/sql_update.cc 1.29 vs edited =====
*** /tmp/sql_update.cc-1.29-24964	Wed Mar 21 00:58:38 2001
--- edited/sql/sql_update.cc	Wed Mar 21 19:34:57 2001
***************
*** 70,76 ****
    table->quick_keys=0;
    want_privilege=table->grant.want_privilege;
    table->grant.want_privilege=(SELECT_ACL & ~table->grant.privilege);
!   if (setup_conds(thd,table_list,&conds))
      DBUG_RETURN(-1);				/* purecov: inspected */
    old_used_keys=table->used_keys;		// Keys used in WHERE
  
--- 70,76 ----
    table->quick_keys=0;
    want_privilege=table->grant.want_privilege;
    table->grant.want_privilege=(SELECT_ACL & ~table->grant.privilege);
!   if (setup_tables(table_list) || setup_conds(thd,table_list,&conds))
      DBUG_RETURN(-1);				/* purecov: inspected */
    old_used_keys=table->used_keys;		// Keys used in WHERE
  
===== sql/sql_select.cc 1.88 vs edited =====
*** /tmp/sql_select.cc-1.88-24964	Wed Mar  7 23:50:43 2001
--- edited/sql/sql_select.cc	Wed Mar 21 19:43:53 2001
***************
*** 174,180 ****
    thd->proc_info="init";
    thd->used_tables=0;				// Updated by setup_fields
  
!   if (setup_fields(thd,tables,fields,1,&all_fields) ||
        setup_conds(thd,tables,&conds) ||
        setup_order(thd,tables,fields,all_fields,order) ||
        setup_group(thd,tables,fields,all_fields,group,&hidden_group_fields) ||
--- 174,181 ----
    thd->proc_info="init";
    thd->used_tables=0;				// Updated by setup_fields
  
!   if (setup_tables(tables) ||
!       setup_fields(thd,tables,fields,1,&all_fields) ||
        setup_conds(thd,tables,&conds) ||
        setup_order(thd,tables,fields,all_fields,order) ||
        setup_group(thd,tables,fields,all_fields,group,&hidden_group_fields) ||
===== sql/mysql_priv.h 1.89 vs edited =====
*** /tmp/mysql_priv.h-1.89-24964	Wed Mar 21 00:58:37 2001
--- edited/sql/mysql_priv.h	Wed Mar 21 19:45:20 2001
***************
*** 402,407 ****
--- 402,408 ----
  SQL_SELECT *make_select(TABLE *head, table_map const_tables,
  			table_map read_tables, COND *conds, int *error);
  Item ** find_item_in_list(Item *item,List<Item> &items);
+ bool setup_tables(TABLE_LIST *tables);
  int setup_fields(THD *thd,TABLE_LIST *tables,List<Item> &item,
  		 bool set_query_id,List<Item> *sum_func_list);
  int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds);



Both patches have been fully tested.



Regards,

Sinisa

      ____  __     _____   _____  ___     ==  MySQL AB
     /*/\*\/\*\   /*/ \*\ /*/ \*\ |*|     Sinisa Milivojevic
    /*/ /*/ /*/   \*\_   |*|   |*||*|     mailto:sinisa@mysql.com
   /*/ /*/ /*/\*\/*/  \*\|*|   |*||*|     Larnaca, Cyprus
  /*/     /*/  /*/\*\_/*/ \*\_/*/ |*|____
  ^^^^^^^^^^^^/*/^^^^^^^^^^^\*\^^^^^^^^^^^
             /*/             \*\                Developers Team

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail bugs-thread1129@lists.mysql.com
To unsubscribe, e-mail <bugs-unsubscribe@lists.mysql.com>

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic