List:Commits« Previous MessageNext Message »
From:kroki Date:November 24 2006 3:17pm
Subject:bk commit into 4.1 tree (kroki:1.2551) BUG#23443
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of tomash. When tomash 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@stripped, 2006-11-24 18:17:49+03:00, kroki@stripped +3 -0
  BUG#23443: user-defined variables can consume too much memory in the
             server
  
  The problem was that when memory was exhausted HEAP engine could crash
  (SQL user variables are stored in it).  Alternatively, if SET was used,
  it could report an error "You may only use constant expressions with SET"
  instead of "Out of memory (Needed NNNNNN bytes)".
  
  The solution is:
   - pass MY_WME to (some) calls to my_malloc() to get correct message.
   - fix heap_write() so that it won't assume that the only possible error
     is HA_ERR_FOUND_DUPP_KEY, and won't initiate key deletion that would
     lead to a crash.
  
  No test case is provided because we can't test out-of-memory behaviour
  in our current test framework.

  heap/hp_block.c@stripped, 2006-11-24 18:17:46+03:00, kroki@stripped +1 -1
    If allocation fails, write an error message.

  heap/hp_write.c@stripped, 2006-11-24 18:17:46+03:00, kroki@stripped +19 -16
    If insertion failed for reasons other than HA_ERR_FOUND_DUPP_KEY
    (likely OOM), just report the error to the caller, do not try to delete
    the key because it wasn't inserted yet.

  sql/item_func.cc@stripped, 2006-11-24 18:17:46+03:00, kroki@stripped +3 -2
    Add MY_WME so that OOM error will be reported.

# 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:	kroki
# Host:	moonlight.intranet
# Root:	/home/tomash/src/mysql_ab/mysql-4.1-bug23443

--- 1.6/heap/hp_block.c	2006-11-24 18:17:54 +03:00
+++ 1.7/heap/hp_block.c	2006-11-24 18:17:54 +03:00
@@ -76,7 +76,7 @@ int hp_get_new_block(HP_BLOCK *block, ul
     and my_default_record_cache_size we get about 1/128 unused memory.
    */
   *alloc_length=sizeof(HP_PTRS)*i+block->records_in_block* block->recbuffer;
-  if (!(root=(HP_PTRS*) my_malloc(*alloc_length,MYF(0))))
+  if (!(root=(HP_PTRS*) my_malloc(*alloc_length,MYF(MY_WME))))
     return 1;
 
   if (i == 0)

--- 1.20/heap/hp_write.c	2006-11-24 18:17:54 +03:00
+++ 1.21/heap/hp_write.c	2006-11-24 18:17:54 +03:00
@@ -68,24 +68,27 @@ int heap_write(HP_INFO *info, const byte
   DBUG_RETURN(0);
 
 err:
-  DBUG_PRINT("info",("Duplicate key: %d", keydef - share->keydef));
-  info->errkey= keydef - share->keydef;
-  if (keydef->algorithm == HA_KEY_ALG_BTREE)
+  if (my_errno == HA_ERR_FOUND_DUPP_KEY)
   {
-    /* we don't need to delete non-inserted key from rb-tree */
-    keydef--;
-  }
-  while (keydef >= share->keydef)
-  {
-    if ((*keydef->delete_key)(info, keydef, record, pos, 0))
-      break;
-    keydef--;
-  } 
+    DBUG_PRINT("info",("Duplicate key: %d", keydef - share->keydef));
+    info->errkey= keydef - share->keydef;
+    if (keydef->algorithm == HA_KEY_ALG_BTREE)
+    {
+      /* we don't need to delete non-inserted key from rb-tree */
+      keydef--;
+    }
+    while (keydef >= share->keydef)
+    {
+      if ((*keydef->delete_key)(info, keydef, record, pos, 0))
+        break;
+      keydef--;
+    }
 
-  share->deleted++;
-  *((byte**) pos)=share->del_link;
-  share->del_link=pos;
-  pos[share->reclength]=0;			/* Record deleted */
+    share->deleted++;
+    *((byte**) pos)=share->del_link;
+    share->del_link=pos;
+    pos[share->reclength]=0;			/* Record deleted */
+  }
 
   DBUG_RETURN(my_errno);
 } /* heap_write */

--- 1.267/sql/item_func.cc	2006-11-24 18:17:54 +03:00
+++ 1.268/sql/item_func.cc	2006-11-24 18:17:54 +03:00
@@ -2468,8 +2468,9 @@ bool Item_func_set_user_var::update_hash
 	char *pos= (char*) entry+ ALIGN_SIZE(sizeof(user_var_entry));
 	if (entry->value == pos)
 	  entry->value=0;
-	if (!(entry->value=(char*) my_realloc(entry->value, length,
-					      MYF(MY_ALLOW_ZERO_PTR))))
+        entry->value= (char*) my_realloc(entry->value, length,
+                                         MYF(MY_ALLOW_ZERO_PTR | MY_WME));
+        if (!entry->value)
 	  goto err;
       }
     }
Thread
bk commit into 4.1 tree (kroki:1.2551) BUG#23443kroki24 Nov