Guilhem,
On 11.07.2007, at 16:58, Guilhem Bichot wrote:
> Hello,
>
> On Wed, Jul 11, 2007 at 10:49:57AM +0300, kgeorge@stripped wrote:
>> ChangeSet@stripped, 2007-07-11 10:49:54+03:00, gkodinov@stripped
>> +9 -0
>> Bug #29325:
>> By default MyISAM overwrites .MYD and .MYI files no
>> DATA DIRECTORY option is used. This can lead to two tables
>> using the same .MYD and .MYI files (that can't be dropped).
>>
>> To prevent CREATE TABLE from overwriting a file a new option
>> is introduced : keep_files_on_create
>> When this is on the CREATE TABLE throws an error if either
>> the .MYD or .MYI exists for a MyISAM table.
>> The option is off by default (resulting in compatible behavior).
>
>> diff -Nrup a/myisam/mi_create.c b/myisam/mi_create.c
>> --- a/myisam/mi_create.c 2007-03-13 16:05:10 +02:00
>> +++ b/myisam/mi_create.c 2007-07-11 10:49:53 +03:00
>> @@ -586,7 +586,8 @@ int mi_create(const char *name,uint keys
>> 32 : 0));
>> linkname_ptr=0;
>> /* Replace the current file */
>> - create_flag=MY_DELETE_OLD;
>> + if (!(flags & HA_CREATE_KEEP_FILES))
>> + create_flag=MY_DELETE_OLD;
>> }
>>
>> /*
>> @@ -647,7 +648,8 @@ int mi_create(const char *name,uint keys
>> {
>> fn_format(filename,name,"",MI_NAME_DEXT,4);
>> linkname_ptr=0;
>> - create_flag=MY_DELETE_OLD;
>> + if (!(flags & HA_CREATE_KEEP_FILES))
>> + create_flag=MY_DELETE_OLD;
>> }
>> if ((dfile=
>> my_create_with_symlink(linkname_ptr, filename, 0, create_mode,
>
> ha_myisam::create() and mi_create() are also called in case of
> TRUNCATE TABLE (destroying old data and index files as it creates new
> empty ones). I wonder if it could fail now, with the new option on.
This option (HA_CREATE_KEEP_FILES) is never passed down for TRUNCATE
TABLE.
> Could you please verify, with the new option on and a simple table
> like this:
>
> create table t(a int) engine=myisam;
> insert into t values(1);
> truncate table t;
>
> that TRUNCATE still works, and if it works, add this in a .test file?
Good idea. The patch is at http://lists.mysql.com/commits/30697. Can
you please check it out and let me know if it's OK to push ?
Best Regards,
Joro
--
Georgi Kodinov, Senior Software Engineer
MySQL AB, Plovdiv, Bulgaria, www.mysql.com
Office: +359 32 634 397 Mobile: +359 887 700 566 Skype: georgekodinov
Are you MySQL certified? www.mysql.com/certification