MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:ingo Date:June 13 2006 7:00pm
Subject:bk commit into 4.1 tree (ingo:1.2495) BUG#11824
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 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.2495 06/06/13 21:00:12 ingo@stripped +4 -0
  Bug#11824 - internal /tmp/*.{MYD,MYI} files remain, causing subsequent queries to fail
  
  Very complex select statements can create temporary tables
  that are too big to be represented as a MyISAM table.
  This was not checked at table creation time, but only at
  open time. The result was an attempt to delete the table.
  But MyISAM tries to open the table for repair before
  deleting the files. This will almost always succeed.
  But in this case we have an "impossible" table. The open
  failed. Hence the files were not deleted. Also the error
  message was a bit unspecific.
  
  I added a force parameter to the MyISAM delete table function.
  This is used for temporary tables now. Their files are
  deleted even if an open for repair fails.
  
  I also added a check in mi_create() to prevent the creation
  of an "impossible" table. A more decriptive error message is
  given in this case.
  
  No test case. The required select statement is way too
  large for the test suite. I added a test script to the
  bug report.

  sql/ha_myisam.cc
    1.163 06/06/13 21:00:08 ingo@stripped +2 -1
    Bug#11824 - internal /tmp/*.{MYD,MYI} files remain, causing subsequent queries to fail
    Using the new force parameter to force deletion of temporary
    files even if they are too corrupt to be repaired.

  myisam/mi_delete_table.c
    1.10 06/06/13 21:00:08 ingo@stripped +22 -5
    Bug#11824 - internal /tmp/*.{MYD,MYI} files remain, causing subsequent queries to fail
    Added a force parameter to mi_delete_table().

  myisam/mi_create.c
    1.48 06/06/13 21:00:08 ingo@stripped +16 -0
    Bug#11824 - internal /tmp/*.{MYD,MYI} files remain, causing subsequent queries to fail
    Added a check to mi_create() that the table description
    header of the index file does not exceed 64KB. The header
    has only 16 bits to encode its length.

  include/myisam.h
    1.67 06/06/13 21:00:08 ingo@stripped +1 -1
    Bug#11824 - internal /tmp/*.{MYD,MYI} files remain, causing subsequent queries to fail
    Added a force parameter to mi_delete_table.

# 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-4.1-aid

--- 1.66/include/myisam.h	2005-10-23 00:46:04 +02:00
+++ 1.67/include/myisam.h	2006-06-13 21:00:08 +02:00
@@ -226,7 +226,7 @@ extern int mi_create(const char *name,ui
 		     uint columns, MI_COLUMNDEF *columndef,
 		     uint uniques, MI_UNIQUEDEF *uniquedef,
 		     MI_CREATE_INFO *create_info, uint flags);
-extern int mi_delete_table(const char *name);
+extern int mi_delete_table(const char *name, my_bool force);
 extern int mi_rename(const char *from, const char *to);
 extern int mi_extra(struct st_myisam_info *file,
 		    enum ha_extra_function function,

--- 1.47/myisam/mi_create.c	2005-07-23 17:03:31 +02:00
+++ 1.48/myisam/mi_create.c	2006-06-13 21:00:08 +02:00
@@ -59,6 +59,8 @@ int mi_create(const char *name,uint keys
   my_off_t key_root[MI_MAX_POSSIBLE_KEY],key_del[MI_MAX_KEY_BLOCK_SIZE];
   MI_CREATE_INFO tmp_create_info;
   DBUG_ENTER("mi_create");
+  DBUG_PRINT("enter", ("keys: %u  columns: %u  uniques: %u  flags: %u",
+                      keys, columns, uniques, flags));
 
   if (!ci)
   {
@@ -447,6 +449,15 @@ int mi_create(const char *name,uint keys
 			       uniques * MI_UNIQUEDEF_SIZE +
 			       (key_segs + unique_key_parts)*HA_KEYSEG_SIZE+
 			       columns*MI_COLUMNDEF_SIZE);
+  DBUG_PRINT("info", ("info_length: %u", info_length));
+  /* There are only 16 bits for the total header length. */
+  if (info_length > 65535)
+  {
+    my_printf_error(0, "MyISAM table '%s' is too complex.",
+                    MYF(0), name + dirname_length(name));
+    my_errno= HA_WRONG_CREATE_OPTION;
+    goto err;
+  }
 
   bmove(share.state.header.file_version,(byte*) myisam_file_magic,4);
   ci->old_options=options| (ci->old_options & HA_OPTION_TEMP_COMPRESS_RECORD ?
@@ -594,6 +605,7 @@ int mi_create(const char *name,uint keys
     errpos=3;
   }
 
+  DBUG_PRINT("info", ("write state info and base info"));
   if (mi_state_info_write(file, &share.state, 2) ||
       mi_base_info_write(file, &share.base))
     goto err;
@@ -607,6 +619,7 @@ int mi_create(const char *name,uint keys
 #endif
 
   /* Write key and keyseg definitions */
+  DBUG_PRINT("info", ("write key and keyseg definitions"));
   for (i=0 ; i < share.base.keys - uniques; i++)
   {
     uint sp_segs=(keydefs[i].flag & HA_SPATIAL) ? 2*SPDIMS : 0;
@@ -655,6 +668,7 @@ int mi_create(const char *name,uint keys
   }
 
   /* Save unique definition */
+  DBUG_PRINT("info", ("write unique definitions"));
   for (i=0 ; i < share.state.header.uniques ; i++)
   {
     if (mi_uniquedef_write(file, &uniquedefs[i]))
@@ -665,6 +679,7 @@ int mi_create(const char *name,uint keys
 	goto err;
     }
   }
+  DBUG_PRINT("info", ("write field definitions"));
   for (i=0 ; i < share.base.fields ; i++)
     if (mi_recinfo_write(file, &recinfo[i]))
       goto err;
@@ -679,6 +694,7 @@ int mi_create(const char *name,uint keys
 #endif
 
 	/* Enlarge files */
+  DBUG_PRINT("info", ("enlarge to keystart: %lu", (ulong) share.base.keystart));
   if (my_chsize(file,(ulong) share.base.keystart,0,MYF(0)))
     goto err;
 

--- 1.9/myisam/mi_delete_table.c	2004-01-19 23:51:14 +01:00
+++ 1.10/myisam/mi_delete_table.c	2006-06-13 21:00:08 +02:00
@@ -20,7 +20,21 @@
 
 #include "fulltext.h"
 
-int mi_delete_table(const char *name)
+/*
+  Delete a MyISAM table.
+
+  SYNOPSIS
+    mi_delete_table()
+      name                      table name
+      force                     force deletion of files even if table
+                                cannot be opened for repair (very corrupt)
+
+  RETURN
+    0           OK
+    != 0        my_errno error number
+*/
+
+int mi_delete_table(const char *name, my_bool force)
 {
   char from[FN_REFLEN];
 #ifdef USE_RAID
@@ -35,11 +49,14 @@ int mi_delete_table(const char *name)
   {
     MI_INFO *info;
     /* we use 'open_for_repair' to be able to delete a crashed table */
-    if (!(info=mi_open(name, O_RDONLY, HA_OPEN_FOR_REPAIR)))
+    if ((info= mi_open(name, O_RDONLY, HA_OPEN_FOR_REPAIR)))
+    {
+      raid_type =      info->s->base.raid_type;
+      raid_chunks =    info->s->base.raid_chunks;
+      mi_close(info);
+    }
+    else if (!force)
       DBUG_RETURN(my_errno);
-    raid_type =      info->s->base.raid_type;
-    raid_chunks =    info->s->base.raid_chunks;
-    mi_close(info);
   }
 #ifdef EXTRA_DEBUG
   check_table_is_closed(name,"delete");

--- 1.162/sql/ha_myisam.cc	2005-10-21 04:29:11 +02:00
+++ 1.163/sql/ha_myisam.cc	2006-06-13 21:00:08 +02:00
@@ -1300,7 +1300,8 @@ int ha_myisam::delete_all_rows()
 
 int ha_myisam::delete_table(const char *name)
 {
-  return mi_delete_table(name);
+  /* Force deletion of temporary tables. Bug #11824 */
+  return mi_delete_table(name, (table && (table->tmp_table != NO_TMP_TABLE)));
 }
 
 
Thread
bk commit into 4.1 tree (ingo:1.2495) BUG#11824ingo13 Jun