List:Commits« Previous MessageNext Message »
From:Kristofer Pettersson Date:November 20 2009 9:38pm
Subject:bzr commit into mysql-pe branch (kristofer.pettersson:3699)
View as plain text  
#At file:///Users/thek/Development/mysql-pe/ based on revid:kristofer.pettersson@stripped

 3699 Kristofer Pettersson	2009-11-20 [merge]
      manual merge mysql-5.1-bugteam => mysql-pe

    modified:
      mysys/hash.c
      sql/log.cc
      sql/repl_failsafe.cc
      sql/rpl_tblmap.cc
      sql/sp.cc
      sql/sp.h
      sql/sp_cache.cc
      sql/sp_head.cc
      sql/sp_head.h
      sql/sql_acl.cc
      sql/sql_select.cc
      sql/sql_yacc.yy
      sql/table.cc
=== modified file 'mysys/hash.c'
--- a/mysys/hash.c	2009-09-17 15:53:46 +0000
+++ b/mysys/hash.c	2009-11-20 21:37:31 +0000
@@ -340,6 +340,7 @@ my_bool my_hash_insert(HASH *info, const
   size_t idx,halfbuff,hash_nr,first_index;
   uchar *UNINIT_VAR(ptr_to_rec),*UNINIT_VAR(ptr_to_rec2);
   HASH_LINK *data,*empty,*UNINIT_VAR(gpos),*UNINIT_VAR(gpos2),*pos;
+  DBUG_EXECUTE("fail_hash_insert",return(TRUE););
 
   if (info->flags & HASH_UNIQUE)
   {

=== modified file 'sql/log.cc'
--- a/sql/log.cc	2009-11-09 10:27:46 +0000
+++ b/sql/log.cc	2009-11-20 21:37:31 +0000
@@ -7621,9 +7621,8 @@ int TC_LOG_BINLOG::recover(IO_CACHE *log
       Xid_log_event *xev=(Xid_log_event *)ev;
       uchar *x= (uchar *) memdup_root(&mem_root, (uchar*) &xev->xid,
                                       sizeof(xev->xid));
-      if (! x)
+      if (!x || my_hash_insert(&xids, x))
         goto err2;
-      my_hash_insert(&xids, x);
     }
     delete ev;
   }

=== modified file 'sql/repl_failsafe.cc'
--- a/sql/repl_failsafe.cc	2009-11-02 15:11:43 +0000
+++ b/sql/repl_failsafe.cc	2009-11-20 21:37:31 +0000
@@ -559,7 +559,12 @@ HOSTS";
 	goto err;
       }
       si->server_id = log_server_id;
-      my_hash_insert(&slave_list, (uchar*)si);
+      if (my_hash_insert(&slave_list, (uchar*)si))
+      {
+        error= "the slave is out of memory";
+        pthread_mutex_unlock(&LOCK_slave_list);
+        goto err;
+      }
     }
     strmake(si->host, row[1], sizeof(si->host)-1);
     si->port = atoi(row[port_ind]);

=== modified file 'sql/rpl_tblmap.cc'
--- a/sql/rpl_tblmap.cc	2009-10-23 06:47:02 +0000
+++ b/sql/rpl_tblmap.cc	2009-11-20 21:37:31 +0000
@@ -119,7 +119,13 @@ int table_mapping::set_table(ulong table
   }
   e->table_id= table_id;
   e->table= table;
-  my_hash_insert(&m_table_ids,(uchar *)e);
+  if (my_hash_insert(&m_table_ids,(uchar *)e))
+  {
+    /* we add this entry to the chain of free (free for use) entries */
+    e->next= m_free;
+    m_free= e;
+    DBUG_RETURN(ERR_MEMORY_ALLOCATION);
+  }
 
   DBUG_PRINT("info", ("tid %lu -> table %p (%s)", 
 		      table_id, e->table,

=== modified file 'sql/sp.cc'
--- a/sql/sp.cc	2009-11-20 12:49:47 +0000
+++ b/sql/sp.cc	2009-11-20 21:37:31 +0000
@@ -1448,7 +1448,8 @@ bool sp_add_used_routine(Query_tables_li
     if (!rn)              // OOM. Error will be reported using fatal_error().
       return FALSE;
     rn->mdl_request.init(key, MDL_SHARED);
-    my_hash_insert(&prelocking_ctx->sroutines, (uchar *)rn);
+    if (my_hash_insert(&prelocking_ctx->sroutines, (uchar *)rn))
+      return FALSE;
     prelocking_ctx->sroutines_list.link_in_list((uchar *)rn, (uchar **)&rn->next);
     rn->belong_to_view= belong_to_view;
     return TRUE;
@@ -1531,17 +1532,24 @@ void sp_remove_not_own_routines(Query_ta
     dependant on time of life of elements from source hash. It also
     won't touch lists linking elements in source and destination
     hashes.
+  @returns
+    @return TRUE Failure
+    @return FALSE Success
 */
 
-void sp_update_sp_used_routines(HASH *dst, HASH *src)
+bool sp_update_sp_used_routines(HASH *dst, HASH *src)
 {
   for (uint i=0 ; i < src->records ; i++)
   {
     Sroutine_hash_entry *rt= (Sroutine_hash_entry *)my_hash_element(src, i);
     if (!my_hash_search(dst, (uchar *)rt->mdl_request.key.ptr(),
                         rt->mdl_request.key.length()))
-      my_hash_insert(dst, (uchar *)rt);
+    {
+      if (my_hash_insert(dst, (uchar *)rt))
+        return TRUE;
+    }
   }
+  return FALSE;
 }
 
 

=== modified file 'sql/sp.h'
--- a/sql/sp.h	2009-10-12 09:08:34 +0000
+++ b/sql/sp.h	2009-11-20 21:37:31 +0000
@@ -127,7 +127,7 @@ void sp_add_used_routine(Query_tables_li
 bool sp_add_used_routine(Query_tables_list *prelocking_ctx, Query_arena *arena,
                          const MDL_key *key, TABLE_LIST *belong_to_view);
 void sp_remove_not_own_routines(Query_tables_list *prelocking_ctx);
-void sp_update_sp_used_routines(HASH *dst, HASH *src);
+bool sp_update_sp_used_routines(HASH *dst, HASH *src);
 void sp_update_stmt_used_routines(THD *thd, Query_tables_list *prelocking_ctx,
                                   HASH *src, TABLE_LIST *belong_to_view);
 void sp_update_stmt_used_routines(THD *thd, Query_tables_list *prelocking_ctx,

=== modified file 'sql/sp_cache.cc'
--- a/sql/sp_cache.cc	2009-10-23 06:47:02 +0000
+++ b/sql/sp_cache.cc	2009-11-20 21:37:31 +0000
@@ -36,10 +36,16 @@ public:
   sp_cache();
   ~sp_cache();
 
-  inline void insert(sp_head *sp)
+  /**
+   Inserts a sp_head object into a hash table.
+
+   @returns Success status
+     @return TRUE Failure
+     @return FALSE Success
+  */
+  inline bool insert(sp_head *sp)
   {
-    /* TODO: why don't we check return value? */
-    my_hash_insert(&m_hashtable, (const uchar *)sp);
+    return my_hash_insert(&m_hashtable, (const uchar *)sp);
   }
 
   inline sp_head *lookup(char *name, uint namelen)

=== modified file 'sql/sp_head.cc'
--- a/sql/sp_head.cc	2009-11-20 12:49:47 +0000
+++ b/sql/sp_head.cc	2009-11-20 21:37:31 +0000
@@ -2101,7 +2101,7 @@ sp_head::reset_lex(THD *thd)
 }
 
 /// Restore lex during parsing, after we have parsed a sub statement.
-void
+bool
 sp_head::restore_lex(THD *thd)
 {
   DBUG_ENTER("sp_head::restore_lex");
@@ -2112,7 +2112,7 @@ sp_head::restore_lex(THD *thd)
 
   oldlex= (LEX *)m_lex.pop();
   if (! oldlex)
-    return;			// Nothing to restore
+    DBUG_RETURN(FALSE);			// Nothing to restore
 
   oldlex->trg_table_fields.push_back(&sublex->trg_table_fields);
 
@@ -2140,7 +2140,7 @@ sp_head::restore_lex(THD *thd)
     delete sublex;
   }
   thd->lex= oldlex;
-  DBUG_VOID_RETURN;
+  DBUG_RETURN(FALSE);
 }
 
 /**
@@ -3894,7 +3894,8 @@ sp_head::merge_table_list(THD *thd, TABL
         tab->lock_transactional= table->lock_transactional;
         tab->lock_count= tab->query_lock_count= 1;
         tab->trg_event_map= table->trg_event_map;
-        my_hash_insert(&m_sptabs, (uchar *)tab);
+        if (my_hash_insert(&m_sptabs, (uchar *)tab))
+          return FALSE;
       }
     }
   return TRUE;

=== modified file 'sql/sp_head.h'
--- a/sql/sp_head.h	2009-10-12 09:08:34 +0000
+++ b/sql/sp_head.h	2009-11-20 21:37:31 +0000
@@ -319,7 +319,7 @@ public:
 
     @todo Conflicting comment in sp_head.cc
   */
-  void
+  bool
   restore_lex(THD *thd);
 
   /// Put the instruction on the backpatch list, associated with the label.

=== modified file 'sql/sql_acl.cc'
--- a/sql/sql_acl.cc	2009-11-09 10:27:46 +0000
+++ b/sql/sql_acl.cc	2009-11-20 21:37:31 +0000
@@ -2470,7 +2470,12 @@ GRANT_TABLE::GRANT_TABLE(TABLE *form, TA
         privs = cols = 0;			/* purecov: deadcode */
         return;				/* purecov: deadcode */
       }
-      my_hash_insert(&hash_columns, (uchar *) mem_check);
+      if (my_hash_insert(&hash_columns, (uchar *) mem_check))
+      {
+        /* Invalidate this entry */
+        privs= cols= 0;
+        return;
+      }
     } while (!col_privs->file->index_next(col_privs->record[0]) &&
              !key_cmp_if_same(col_privs,key,0,key_prefix_len));
     col_privs->file->ha_index_end();
@@ -2676,7 +2681,11 @@ static int replace_column_table(GRANT_TA
 	goto end;				/* purecov: inspected */
       }
       grant_column= new GRANT_COLUMN(column->column,privileges);
-      my_hash_insert(&g_t->hash_columns,(uchar*) grant_column);
+      if (my_hash_insert(&g_t->hash_columns,(uchar*) grant_column))
+      {
+        result= -1;
+        goto end;
+      }
     }
   }
 
@@ -3213,12 +3222,12 @@ int mysql_table_grant(THD *thd, TABLE_LI
 				     Str->user.str, table_name,
 				     rights,
 				     column_priv);
-      if (!grant_table)				// end of memory
+      if (!grant_table ||
+        my_hash_insert(&column_priv_hash,(uchar*) grant_table))
       {
 	result= TRUE;				/* purecov: deadcode */
 	continue;				/* purecov: deadcode */
       }
-      my_hash_insert(&column_priv_hash,(uchar*) grant_table);
     }
 
     /* If revoke_grant, calculate the new column privilege for tables_priv */
@@ -3423,12 +3432,13 @@ bool mysql_routine_grant(THD *thd, TABLE
       grant_name= new GRANT_NAME(Str->host.str, db_name,
 				 Str->user.str, table_name,
 				 rights, TRUE);
-      if (!grant_name)
+      if (!grant_name ||
+        my_hash_insert(is_proc ?
+                       &proc_priv_hash : &func_priv_hash,(uchar*) grant_name))
       {
         result= TRUE;
 	continue;
       }
-      my_hash_insert(is_proc ? &proc_priv_hash : &func_priv_hash,(uchar*) grant_name);
     }
 
     if (replace_routine_table(thd, grant_name, tables[1].table, *Str,

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2009-11-20 13:50:24 +0000
+++ b/sql/sql_select.cc	2009-11-20 21:37:31 +0000
@@ -19696,7 +19696,10 @@ static int remove_dup_with_hash_index(TH
 	goto err;
     }
     else
-      (void) my_hash_insert(&hash, org_key_pos);
+    {
+      if (my_hash_insert(&hash, org_key_pos))
+        goto err;
+    }
     key_pos+=extra_length;
   }
   my_free((char*) key_buffer,MYF(0));

=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy	2009-11-20 13:50:24 +0000
+++ b/sql/sql_yacc.yy	2009-11-20 21:37:31 +0000
@@ -3297,7 +3297,8 @@ sp_if:
                 sp->add_instr(i))
               MYSQL_YYABORT;
 
-            sp->restore_lex(YYTHD);
+            if (sp->restore_lex(YYTHD))
+              MYSQL_YYABORT;
           }
           sp_proc_stmts1
           {

=== modified file 'sql/table.cc'
--- a/sql/table.cc	2009-11-02 15:16:58 +0000
+++ b/sql/table.cc	2009-11-20 21:37:31 +0000
@@ -1455,8 +1455,16 @@ static int open_binary_frm(THD *thd, TAB
       share->timestamp_field_offset= i;
 
     if (use_hash)
-      (void) my_hash_insert(&share->name_hash,
-                            (uchar*) field_ptr); // never fail
+      if (my_hash_insert(&share->name_hash, (uchar*) field_ptr) )
+      {
+        /*
+          Set return code 8 here to indicate that an error has
+          occurred but that the error message already has been
+          sent (OOM).
+        */
+        error= 8; 
+        goto err;
+      }
   }
   *field_ptr=0;					// End marker
 


Attachment: [text/bzr-bundle]
Thread
bzr commit into mysql-pe branch (kristofer.pettersson:3699)Kristofer Pettersson20 Nov