List:Commits« Previous MessageNext Message »
From:ingo Date:December 23 2005 12:11pm
Subject:bk commit into 5.0 tree (ingo:1.1994) BUG#4692
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of mydev. When mydev 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
  1.1994 05/12/23 13:11:49 ingo@stripped +3 -0
  BUG#4692 - DISABLE/ENABLE KEYS waste a space
  Not to be pushed.
  This is a technology preview for dropping MyISAM indexes.
  It can handle btree indexes only as yet.

  myisam/mi_page.c
    1.23 05/12/23 13:11:44 ingo@stripped +77 -0
    BUG#4692 - DISABLE/ENABLE KEYS waste a space
    Not to be pushed.
    This is a technology preview for dropping MyISAM indexes.
    It can handle btree indexes only as yet.
    Drop index pages from an btree index.

  myisam/mi_open.c
    1.96 05/12/23 13:11:44 ingo@stripped +10 -1
    BUG#4692 - DISABLE/ENABLE KEYS waste a space
    Not to be pushed.
    This is a technology preview for dropping MyISAM indexes.
    It can handle btree indexes only as yet.
    Drop index pages from indexes disabled by mi_disable_indexes().
    ENABLE KEYS re-creates the index trees.

  myisam/mi_extra.c
    1.47 05/12/23 13:11:44 ingo@stripped +9 -0
    BUG#4692 - DISABLE/ENABLE KEYS waste a space
    Not to be pushed.
    This is a technology preview for dropping MyISAM indexes.
    It can handle btree indexes only as yet.
    Drop index pages from indexes disabled by mi_extra(HA_EXTRA_NO_KEYS).
    ENABLE KEYS re-creates the index trees.

# 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:	ingo
# Host:	chilla.local
# Root:	/home/mydev/mysql-5.0-bug4692

--- 1.46/myisam/mi_extra.c	2005-09-01 04:11:41 +02:00
+++ 1.47/myisam/mi_extra.c	2005-12-23 13:11:44 +01:00
@@ -254,6 +254,15 @@
         {
           mi_clear_key_active(share->state.key_map, i);
           info->update|= HA_STATE_CHANGED;
+
+          DBUG_PRINT("info", ("drop tree for key: %u", i));
+          if (mi_drop_tree(info, share->keyinfo + i,
+                           share->state.key_root[i]))
+          {
+            error= 1;
+            break;
+          }
+          share->state.key_root[i]= HA_OFFSET_ERROR;
         }
       }
 

--- 1.95/myisam/mi_open.c	2005-09-30 12:56:24 +02:00
+++ 1.96/myisam/mi_open.c	2005-12-23 13:11:44 +01:00
@@ -1199,14 +1199,23 @@
 
   RETURN
     0  ok
+    1  Error
 */
 
 int mi_disable_indexes(MI_INFO *info)
 {
+  uint         idx;
   MYISAM_SHARE *share= info->s;
 
   mi_clear_all_keys_active(share->state.key_map);
-  return 0;
+
+  for (idx= 0; idx < share->base.keys; idx++)
+  {
+    if (mi_drop_tree(info, share->keyinfo + idx, share->state.key_root[idx]))
+      return 1;
+    share->state.key_root[idx]= HA_OFFSET_ERROR;
+  }
+  return mi_state_info_write(share->kfile, &share->state, 1 + 2);
 }
 
 

--- 1.22/myisam/mi_page.c	2004-12-31 02:47:50 +01:00
+++ 1.23/myisam/mi_page.c	2005-12-23 13:11:44 +01:00
@@ -102,6 +102,83 @@
 } /* mi_write_keypage */
 
 
+/*
+  Drop a btree index. Also used recursively for sub-trees.
+
+  SYNOPSIS
+    mi_drop_tree()
+      info              MyISAM handle.
+      keyinfo           Key definition information.
+      root              Position of root of (sub-) tree in key file.
+
+  RETURN VALUE
+    0           OK
+    1           Error
+*/
+
+int mi_drop_tree(MI_INFO *info, MI_KEYDEF *keyinfo, my_off_t root)
+{
+  uint          nod_flag;
+  my_off_t      branch_page;
+  uchar         *buff;
+  uchar         *keypos;
+  uchar         *endpos;
+  uchar         key[MI_MAX_KEY_BUFF];
+  DBUG_ENTER("mi_drop_tree");
+  DBUG_PRINT("enter", ("root: 0x%lx", (ulong) root));
+
+  if (root == HA_OFFSET_ERROR)
+    goto end;
+
+  /* Get a buffer for the key block. */
+  if (! (buff= (uchar*) my_malloc(keyinfo->block_length, MYF(MY_WME))))
+    goto err;
+
+  /* Read the root key block. (root of sub-tree in later iterations) */
+  if (! _mi_fetch_keypage(info, keyinfo, root, DFLT_INIT_HITS, buff, 0))
+    goto err;
+
+  /* Test if it is a "node" or a "leaf". */
+  nod_flag= mi_test_if_nod(buff);
+  if (nod_flag)
+  {
+    /*
+      A "node" starts with 2 bytes block length and
+      a pointer to the block with the lowest key values.
+      After this, a series of (key value, block pointer) follows.
+    */
+    endpos= buff + mi_getint(buff);
+    keypos= buff + 2 + nod_flag;
+    key[0]= '\0';
+    for (;;)
+    {
+      /* Recursively drop the tree at the current position. */
+      branch_page= _mi_kpos(nod_flag, keypos);
+      if (mi_drop_tree(info, keyinfo, branch_page))
+        goto err;
+
+      if (keypos >= endpos)
+        break;
+      /* Calculate next key position. */
+      if (! (*keyinfo->get_key)(keyinfo, nod_flag, &keypos, key))
+        goto err;
+    }
+  }
+
+  /* Free the block. */
+  if (_mi_dispose(info, keyinfo, root, DFLT_INIT_HITS))
+    goto err;
+
+end:
+  my_free((gptr) buff, MYF(0));
+  DBUG_RETURN(0);
+
+err:
+  my_free((gptr) buff, MYF(MY_ALLOW_ZERO_PTR));
+  DBUG_RETURN(1);
+}
+
+
 	/* Remove page from disk */
 
 int _mi_dispose(register MI_INFO *info, MI_KEYDEF *keyinfo, my_off_t pos,
Thread
bk commit into 5.0 tree (ingo:1.1994) BUG#4692ingo23 Dec