summaryrefslogtreecommitdiff
path: root/myisam
diff options
context:
space:
mode:
authoringo/mydev@chilla.local <>2006-07-08 19:23:55 +0200
committeringo/mydev@chilla.local <>2006-07-08 19:23:55 +0200
commiteaa9350c9005bf7c625660d7b54f416246da00c1 (patch)
tree5e2f5323b2b583581b89036f5d879746ce7e6f75 /myisam
parent2303077238b32703749dc6f9d6f184ff30f9e251 (diff)
parente67bdaf604418ce51fc74db2b69f143a28ef9746 (diff)
downloadmariadb-git-eaa9350c9005bf7c625660d7b54f416246da00c1.tar.gz
Merge chilla.local:/home/mydev/mysql-4.1-bug11824
into chilla.local:/home/mydev/mysql-4.1-amerge
Diffstat (limited to 'myisam')
-rw-r--r--myisam/mi_create.c17
-rw-r--r--myisam/mi_delete_table.c24
2 files changed, 35 insertions, 6 deletions
diff --git a/myisam/mi_create.c b/myisam/mi_create.c
index d15cad2840f..c1310a8012d 100644
--- a/myisam/mi_create.c
+++ b/myisam/mi_create.c
@@ -59,6 +59,8 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
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,16 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
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' has too many columns and/or "
+ "indexes and/or unique constraints.",
+ 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 ?
@@ -616,6 +628,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
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;
@@ -629,6 +642,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
#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;
@@ -677,6 +691,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
}
/* 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]))
@@ -687,6 +702,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
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;
@@ -701,6 +717,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
#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;
diff --git a/myisam/mi_delete_table.c b/myisam/mi_delete_table.c
index 6843881568d..2fba31cf8be 100644
--- a/myisam/mi_delete_table.c
+++ b/myisam/mi_delete_table.c
@@ -34,12 +34,24 @@ int mi_delete_table(const char *name)
#ifdef USE_RAID
{
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)))
- DBUG_RETURN(my_errno);
- raid_type = info->s->base.raid_type;
- raid_chunks = info->s->base.raid_chunks;
- mi_close(info);
+ /*
+ When built with RAID support, we need to determine if this table
+ makes use of the raid feature. If yes, we need to remove all raid
+ chunks. This is done with my_raid_delete(). Unfortunately it is
+ necessary to open the table just to check this. We use
+ 'open_for_repair' to be able to open even a crashed table. If even
+ this open fails, we assume no raid configuration for this table
+ and try to remove the normal data file only. This may however
+ leave the raid chunks behind.
+ */
+ if (!(info= mi_open(name, O_RDONLY, HA_OPEN_FOR_REPAIR)))
+ raid_type= 0;
+ else
+ {
+ 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");