summaryrefslogtreecommitdiff
path: root/myisam
diff options
context:
space:
mode:
authorunknown <monty@donna.mysql.com>2000-10-17 00:47:38 +0300
committerunknown <monty@donna.mysql.com>2000-10-17 00:47:38 +0300
commit6842cd1c059c53c44b8342e73ee031bf0a345b13 (patch)
tree1d1e9f4786133bc24df75cded48fd6683bbd8687 /myisam
parent7c96a2529062295ef2379fbd4e387cbc5e5e0b7c (diff)
parent0c511215f23809c4b9e8f5c26ad96520252e7758 (diff)
downloadmariadb-git-6842cd1c059c53c44b8342e73ee031bf0a345b13.tar.gz
Merge work:/home/bk/mysql into donna.mysql.com:/home/my/bk/mysql
Docs/manual.texi: Auto merged
Diffstat (limited to 'myisam')
-rw-r--r--myisam/mi_check.c10
-rw-r--r--myisam/mi_open.c78
-rw-r--r--myisam/myisamchk.c27
-rw-r--r--myisam/myisamdef.h2
4 files changed, 51 insertions, 66 deletions
diff --git a/myisam/mi_check.c b/myisam/mi_check.c
index a35ccc7edf4..31d4aca1309 100644
--- a/myisam/mi_check.c
+++ b/myisam/mi_check.c
@@ -1172,9 +1172,9 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info,
if (my_errno != HA_ERR_FOUND_DUPP_KEY) goto err;
DBUG_DUMP("record",(byte*) sort_info->record,share->base.pack_reclength);
mi_check_print_info(param,"Duplicate key %2d for record at %10s against new record at %10s",
- info->errkey+1,
- llstr(sort_info->start_recpos,llbuff),
- llstr(info->lastpos,llbuff2));
+ info->errkey+1,
+ llstr(sort_info->start_recpos,llbuff),
+ llstr(info->dupp_key_pos,llbuff2));
if (param->testflag & T_VERBOSE)
{
VOID(_mi_make_key(info,(uint) info->errkey,info->lastkey,
@@ -2350,8 +2350,8 @@ int sort_write_record(SORT_INFO *sort_info)
if (sort_info->buff_length < reclength)
{
if (!(sort_info->buff=my_realloc(sort_info->buff, (uint) reclength,
- MYF(MY_FREE_ON_ERROR |
- MY_ALLOW_ZERO_PTR))))
+ MYF(MY_FREE_ON_ERROR |
+ MY_ALLOW_ZERO_PTR))))
DBUG_RETURN(1);
sort_info->buff_length=reclength;
}
diff --git a/myisam/mi_open.c b/myisam/mi_open.c
index 942b4cee491..aeaf9e5e9b4 100644
--- a/myisam/mi_open.c
+++ b/myisam/mi_open.c
@@ -101,6 +101,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
(kfile=my_open(name_buff,(open_mode=O_RDONLY) | O_SHARE,MYF(0))) < 0)
goto err;
}
+ share->mode=open_mode;
errpos=1;
if (my_read(kfile,(char*) share->state.header.file_version,head_length,
MYF(MY_NABP)))
@@ -343,28 +344,11 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
lock_error=1; /* Database unlocked */
}
-#ifdef USE_RAID
- if (share->base.raid_type)
- {
- if ((info.dfile=my_raid_open(fn_format(name_buff,name,"",MI_NAME_DEXT,
- 2+4),
- mode | O_SHARE,
- share->base.raid_type,
- share->base.raid_chunks,
- share->base.raid_chunksize,
- MYF(MY_WME | MY_RAID))) < 0)
+ if (mi_open_datafile(&info, share))
goto err;
- }
- else
-#endif
- if ((info.dfile=my_open(fn_format(name_buff,name,"",MI_NAME_DEXT,2+4),
- mode | O_SHARE,
- MYF(MY_WME))) < 0)
- goto err;
errpos=5;
share->kfile=kfile;
- share->mode=open_mode;
share->this_process=(ulong) getpid();
share->rnd= (int) share->this_process; /* rnd-counter for splits */
#ifndef DBUG_OFF
@@ -433,27 +417,8 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
my_errno=EACCES; /* Can't open in write mode */
goto err;
}
-#ifdef USE_RAID
- if (share->base.raid_type)
- {
- if ((info.dfile=my_raid_open(fn_format(name_buff,old_info->filename,"",
- MI_NAME_DEXT, 2+4),
- mode | O_SHARE,
- share->base.raid_type,
- share->base.raid_chunks,
- share->base.raid_chunksize,
- MYF(MY_WME | MY_RAID))) < 0)
+ if (mi_open_datafile(&info, share))
goto err;
- }
- else
-#endif
- if ((info.dfile=my_open(fn_format(name_buff,old_info->filename,"",
- MI_NAME_DEXT,2+4),
- mode | O_SHARE,MYF(MY_WME))) < 0)
- {
- my_errno=errno;
- goto err;
- }
errpos=5;
}
@@ -1009,3 +974,40 @@ char *mi_recinfo_read(char *ptr, MI_COLUMNDEF *recinfo)
recinfo->null_pos=mi_uint2korr(ptr); ptr +=2;
return ptr;
}
+
+/**************************************************************************
+ ** Help functions for recover
+ *************************************************************************/
+
+int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share)
+{
+ char name_buff[FN_REFLEN];
+ (void) fn_format(name_buff, share->filename,"",MI_NAME_DEXT, 2+4);
+
+#ifdef USE_RAID
+ if (share->base.raid_type)
+ {
+ if ((info->dfile=my_raid_open(name_buff,
+ share->mode | O_SHARE,
+ share->base.raid_type,
+ share->base.raid_chunks,
+ share->base.raid_chunksize,
+ MYF(MY_WME | MY_RAID))) < 0)
+ return 1;
+ }
+ else
+#endif
+ if ((info->dfile=my_open(name_buff, share->mode | O_SHARE,
+ MYF(MY_WME))) < 0)
+ return 1;
+ return 0;
+}
+
+
+int mi_open_keyfile(MYISAM_SHARE *share)
+{
+ if ((share->kfile=my_open(share->filename, share->mode | O_SHARE,
+ MYF(MY_WME))) < 0)
+ return 1;
+ return 0;
+}
diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c
index 7fad3349d37..26e1699a07c 100644
--- a/myisam/myisamchk.c
+++ b/myisam/myisamchk.c
@@ -196,7 +196,7 @@ static struct option long_options[] =
static void print_version(void)
{
- printf("%s Ver 1.34 for %s at %s\n",my_progname,SYSTEM_TYPE,
+ printf("%s Ver 1.35 for %s at %s\n",my_progname,SYSTEM_TYPE,
MACHINE_TYPE);
}
@@ -677,27 +677,7 @@ static int myisamchk(MI_CHECK *param, my_string filename)
error|=change_to_newfile(fixed_name,MI_NAME_DEXT,DATA_TMP_EXT,
raid_chunks,
MYF(0));
-#ifdef USE_RAID
- if (share->base.raid_type)
- {
- mi_check_print_info(&check_param,"Opening as RAID-ed table\n");
- info->dfile=my_raid_open(fn_format(param->temp_filename,
- fixed_name,"",
- MI_NAME_DEXT, 2+4),
- O_RDWR | O_SHARE,
- share->base.raid_type,
- raid_chunks,
- share->base.raid_chunksize,
- MYF(MY_WME | MY_RAID));
- }
- else
-#endif
- info->dfile=my_open(fn_format(param->temp_filename,
- fixed_name,"",
- MI_NAME_DEXT,2+4),
- O_RDWR | O_SHARE,
- MYF(MY_WME));
- if (info->dfile < 0)
+ if (mi_open_datafile(info,info->s))
error=1;
param->out_flag&= ~O_NEW_DATA; /* We are using new datafile */
param->read_cache.file=info->dfile;
@@ -1142,7 +1122,8 @@ static int mi_sort_records(MI_CHECK *param,
SORT_INFO *sort_info= &param->sort_info;
DBUG_ENTER("sort_records");
- bzero((char*) sort_info,sizeof(sort_info));
+ bzero((char*) sort_info,sizeof(*sort_info));
+ sort_info->param=param;
keyinfo= &share->keyinfo[sort_key];
got_error=1;
temp_buff=0;
diff --git a/myisam/myisamdef.h b/myisam/myisamdef.h
index e436e0872ca..1af94de1990 100644
--- a/myisam/myisamdef.h
+++ b/myisam/myisamdef.h
@@ -626,6 +626,8 @@ int _mi_rkey(MI_INFO *info, byte *buf, int inx, const byte *key, uint key_len,
enum ha_rkey_function search_flag, bool raw_key);
my_bool check_table_is_closed(const char *name, const char *where);
+int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share);
+int mi_open_keyfile(MYISAM_SHARE *share);
/* Functions needed by mi_check */
#ifdef __cplusplus