diff options
author | unknown <monty@tramp.mysql.fi> | 2000-09-26 00:33:25 +0300 |
---|---|---|
committer | unknown <monty@tramp.mysql.fi> | 2000-09-26 00:33:25 +0300 |
commit | 7fe58c4f5bea627bb38bfbcb0cc5885e3f6129c6 (patch) | |
tree | 047c90e932cb7b90a58fe795b855351027725c29 /myisam | |
parent | 5f12486229fb578f2e170238ab2cdd7c9bf42a82 (diff) | |
download | mariadb-git-7fe58c4f5bea627bb38bfbcb0cc5885e3f6129c6.tar.gz |
RIGHT JOIN, part of automatic repair of MyISAM tables, backup on repair,
reading from FIFO, fixes for FULLTEXT, @@IDENTITY
Docs/manual.texi:
Update of RIGHT JOIN
client/mysql.cc:
Faster HTML generation
extra/perror.c:
Added MyISAM error messages
include/my_base.h:
Update for automatic repair of MyISAM tables
include/my_sys.h:
Backup files and FIFO
include/myisam.h:
Automatic repair and backup files
include/mysqld_error.h:
New error message
myisam/mi_check.c:
Update for automatic repair of MyISAM tables
myisam/mi_locking.c:
Fixed comment
myisam/mi_open.c:
Update for automatic repair of MyISAM tables
myisam/myisamchk.c:
Update for automatic repair of MyISAM tables
myisam/myisamdef.h:
Update for automatic repair of MyISAM tables
mysys/mf_getdate.c:
Added new parameter option for backup files
mysys/my_open.c:
Added debug information
mysys/my_redel.c:
Backup file handling
sql/ha_berkeley.cc:
Updated interface
sql/ha_berkeley.h:
Updated interface
sql/ha_heap.cc:
Updated interface
sql/ha_heap.h:
Updated interface
sql/ha_isam.cc:
Updated interface
sql/ha_isam.h:
Updated interface
sql/ha_isammrg.cc:
Updated interface
sql/ha_isammrg.h:
Updated interface
sql/ha_myisam.cc:
Update for automatic repair of MyISAM tables
sql/ha_myisam.h:
Updated interface
sql/ha_myisammrg.cc:
Updated interface
sql/ha_myisammrg.h:
Updated interface
sql/handler.h:
Updated interface
sql/item.h:
Added @@identity
sql/item_func.cc:
Added @@identity
sql/lex.h:
Added RIGHT JOIN
sql/mf_iocache.cc:
Update for reading from FIFO
sql/mysqld.cc:
Update for automatic repair of MyISAM tables
sql/share/czech/errmsg.sys:
Added @@identity
sql/share/czech/errmsg.txt:
Added @@identity
sql/share/danish/errmsg.sys:
Added @@identity
sql/share/danish/errmsg.txt:
Added @@identity
sql/share/dutch/errmsg.sys:
Added @@identity
sql/share/dutch/errmsg.txt:
Added @@identity
sql/share/english/errmsg.sys:
Added @@identity
sql/share/english/errmsg.txt:
Added @@identity
sql/share/estonian/errmsg.sys:
Added @@identity
sql/share/estonian/errmsg.txt:
Added @@identity
sql/share/french/errmsg.sys:
Added @@identity
sql/share/french/errmsg.txt:
Added @@identity
sql/share/german/errmsg.sys:
Added @@identity
sql/share/german/errmsg.txt:
Added @@identity
sql/share/greek/errmsg.sys:
Added @@identity
sql/share/greek/errmsg.txt:
Added @@identity
sql/share/hungarian/errmsg.sys:
Added @@identity
sql/share/hungarian/errmsg.txt:
Added @@identity
sql/share/italian/errmsg.sys:
Added @@identity
sql/share/italian/errmsg.txt:
Added @@identity
sql/share/japanese/errmsg.sys:
Added @@identity
sql/share/japanese/errmsg.txt:
Added @@identity
sql/share/korean/errmsg.sys:
Added @@identity
sql/share/korean/errmsg.txt:
Added @@identity
sql/share/norwegian-ny/errmsg.txt:
Added @@identity
sql/share/norwegian/errmsg.txt:
Added @@identity
sql/share/polish/errmsg.sys:
Added @@identity
sql/share/polish/errmsg.txt:
Added @@identity
sql/share/portuguese/errmsg.sys:
Added @@identity
sql/share/portuguese/errmsg.txt:
Added @@identity
sql/share/romanian/errmsg.txt:
Added @@identity
sql/share/russian/errmsg.sys:
Added @@identity
sql/share/russian/errmsg.txt:
Added @@identity
sql/share/slovak/errmsg.sys:
Added @@identity
sql/share/slovak/errmsg.txt:
Added @@identity
sql/share/spanish/errmsg.sys:
Added @@identity
sql/share/spanish/errmsg.txt:
Added @@identity
sql/share/swedish/errmsg.OLD:
Added @@identity
sql/share/swedish/errmsg.sys:
Added @@identity
sql/share/swedish/errmsg.txt:
Added @@identity
sql/sql_base.cc:
Fix for RIGHT JOIN
sql/sql_db.cc:
Update for automatic repair of MyISAM tables
sql/sql_load.cc:
Added reading from FIFO
sql/sql_parse.cc:
Fix for RIGHT JOIN
sql/sql_select.cc:
Fix for RIGHT JOIN
sql/sql_table.cc:
cleanup
sql/sql_yacc.yy:
Added RIGHT JOIN
sql/table.cc:
Fix handling of FULLTEXT index
sql/table.h:
Added RIGHT JOIN
BitKeeper/etc/logging_ok:
Logging to logging@openlogging.org accepted
Diffstat (limited to 'myisam')
-rw-r--r-- | myisam/mi_check.c | 42 | ||||
-rw-r--r-- | myisam/mi_locking.c | 2 | ||||
-rw-r--r-- | myisam/mi_open.c | 37 | ||||
-rw-r--r-- | myisam/myisamchk.c | 43 | ||||
-rw-r--r-- | myisam/myisamdef.h | 5 |
5 files changed, 83 insertions, 46 deletions
diff --git a/myisam/mi_check.c b/myisam/mi_check.c index 1d5806486b1..88447231f02 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -1246,7 +1246,6 @@ err: MYF(MY_WME))); } mi_mark_crashed_on_repair(info); - info->update|= HA_STATE_CHANGED; } if (sort_info->record) my_free(sort_info->record,MYF(0)); @@ -1544,7 +1543,8 @@ err: int change_to_newfile(const char * filename, const char * old_ext, const char * new_ext, - uint raid_chunks __attribute__((unused))) + uint raid_chunks __attribute__((unused)), + myf MyFlags) { char old_filename[FN_REFLEN],new_filename[FN_REFLEN]; #ifdef USE_RAID @@ -1552,11 +1552,11 @@ int change_to_newfile(const char * filename, const char * old_ext, return my_raid_redel(fn_format(old_filename,filename,"",old_ext,2+4), fn_format(new_filename,filename,"",new_ext,2+4), raid_chunks, - MYF(MY_WME+MY_LINK_WARNING)); + MYF(MY_WME | MY_LINK_WARNING | MyFlags)); #endif return my_redel(fn_format(old_filename,filename,"",old_ext,2+4), fn_format(new_filename,filename,"",new_ext,2+4), - MYF(MY_WME+MY_LINK_WARNING)); + MYF(MY_WME | MY_LINK_WARNING | MyFlags)); } /* change_to_newfile */ @@ -1901,9 +1901,10 @@ err: VOID(my_close(new_file,MYF(0))); VOID(my_raid_delete(param->temp_filename,info->s->base.raid_chunks, MYF(MY_WME))); + if (info->dfile == new_file) + info->dfile=0; } mi_mark_crashed_on_repair(info); - info->update|= HA_STATE_CHANGED; } else if (key_map == share->state.key_map) share->state.changed&= ~STATE_NOT_OPTIMIZED_KEYS; @@ -1986,7 +1987,11 @@ static int sort_get_next_record(SORT_INFO *sort_info) { if (my_b_read(¶m->read_cache,sort_info->record, share->base.pack_reclength)) + { + if (param->read_cache.error) + param->out_flag |= O_DATA_LOST; DBUG_RETURN(-1); + } sort_info->start_recpos=sort_info->pos; if (!sort_info->fix_datafile) sort_info->filepos=sort_info->pos; @@ -2179,14 +2184,14 @@ static int sort_get_next_record(SORT_INFO *sort_info) param->read_cache.end_of_file) { mi_check_print_info(param,"Found block that points outside data file at %s", - llstr(sort_info->start_recpos,llbuff)); + llstr(sort_info->start_recpos,llbuff)); goto try_next; } if (_mi_read_cache(¶m->read_cache,to,block_info.filepos, block_info.data_len, test(found_record == 1))) { mi_check_print_info(param,"Read error for block at: %s (error: %d); Skipped", - llstr(block_info.filepos,llbuff),my_errno); + llstr(block_info.filepos,llbuff),my_errno); goto try_next; } left_length-=block_info.data_len; @@ -2195,13 +2200,14 @@ static int sort_get_next_record(SORT_INFO *sort_info) if (pos == HA_OFFSET_ERROR && left_length) { mi_check_print_info(param,"Wrong block with wrong total length starting at %s", - llstr(sort_info->start_recpos,llbuff)); + llstr(sort_info->start_recpos,llbuff)); goto try_next; } if (pos + MI_BLOCK_INFO_HEADER_LENGTH > param->read_cache.end_of_file) { mi_check_print_info(param,"Found link that points at %s (outside data file) at %s", - llstr(pos,llbuff2), llstr(sort_info->start_recpos,llbuff)); + llstr(pos,llbuff2), + llstr(sort_info->start_recpos,llbuff)); goto try_next; } } while (left_length); @@ -2218,7 +2224,7 @@ static int sort_get_next_record(SORT_INFO *sort_info) if (_mi_rec_check(info, sort_info->record)) { mi_check_print_info(param,"Found wrong packed record at %s", - llstr(sort_info->start_recpos,llbuff)); + llstr(sort_info->start_recpos,llbuff)); goto try_next; } } @@ -2251,7 +2257,8 @@ static int sort_get_next_record(SORT_INFO *sort_info) { if (! searching) mi_check_print_info(param,"Found block with wrong recordlength: %d at %s\n", - block_info.rec_len, llstr(sort_info->pos,llbuff)); + block_info.rec_len, + llstr(sort_info->pos,llbuff)); continue; } if (_mi_read_cache(¶m->read_cache,(byte*) info->rec_buff, @@ -2259,14 +2266,15 @@ static int sort_get_next_record(SORT_INFO *sort_info) { if (! searching) mi_check_print_info(param,"Couldn't read hole record from %s", - llstr(sort_info->pos,llbuff)); + llstr(sort_info->pos,llbuff)); continue; } if (_mi_pack_rec_unpack(info,sort_info->record,info->rec_buff, block_info.rec_len)) { if (! searching) - mi_check_print_info(param,"Found wrong record at %s", llstr(sort_info->pos,llbuff)); + mi_check_print_info(param,"Found wrong record at %s", + llstr(sort_info->pos,llbuff)); continue; } if (!sort_info->fix_datafile) @@ -3011,9 +3019,13 @@ void mi_disable_non_unique_index(MI_INFO *info, ha_rows rows) } -/* Return TRUE if we can use repair by sorting */ +/* + Return TRUE if we can use repair by sorting + One can set the force argument to force to use sorting + even if the temporary file would be quite big! +*/ -my_bool mi_test_if_sort_rep(MI_INFO *info, ha_rows rows) +my_bool mi_test_if_sort_rep(MI_INFO *info, ha_rows rows, my_bool force) { MYISAM_SHARE *share=info->s; uint i; diff --git a/myisam/mi_locking.c b/myisam/mi_locking.c index f34497fc0b6..a5cbdd4f906 100644 --- a/myisam/mi_locking.c +++ b/myisam/mi_locking.c @@ -392,7 +392,7 @@ int _mi_test_if_changed(register MI_INFO *info) } /* _mi_test_if_changed */ -/* Put a mark in the .ISM file that someone is updating the table */ +/* Put a mark in the .MYI file that someone is updating the table */ int _mi_mark_file_changed(MI_INFO *info) { diff --git a/myisam/mi_open.c b/myisam/mi_open.c index 70096f33c5e..f962d0485c8 100644 --- a/myisam/mi_open.c +++ b/myisam/mi_open.c @@ -57,16 +57,14 @@ static MI_INFO *test_if_reopen(char *filename) /****************************************************************************** - open a isam database. - if handle_locking is 0 then exit with error if database is locked - if handle_locking is 1 then wait if database is locked - if handle_locking is 2 then continue, but count-vars in st_i_info - may be wrong. count-vars are automaticly fixed after next isam - request. + open a MyISAM database. + See my_base.h for the handle_locking argument + if handle_locking and HA_OPEN_ABORT_IF_CRASHED then abort if the table + is marked crashed or if we are not using locking and the table doesn't + have an open count of 0. ******************************************************************************/ - -MI_INFO *mi_open(const char *name, int mode, uint handle_locking) +MI_INFO *mi_open(const char *name, int mode, uint open_flags) { int lock_error,kfile,open_mode,save_errno; uint i,j,len,errpos,head_length,base_pos,offset,info_length,extra,keys, @@ -139,12 +137,12 @@ MI_INFO *mi_open(const char *name, int mode, uint handle_locking) errpos=2; VOID(my_seek(kfile,0L,MY_SEEK_SET,MYF(0))); - if (!(handle_locking & HA_OPEN_TMP_TABLE)) + if (!(open_flags & HA_OPEN_TMP_TABLE)) { if ((lock_error=my_lock(kfile,F_RDLCK,0L,F_TO_EOF, - MYF(handle_locking & HA_OPEN_WAIT_IF_LOCKED ? + MYF(open_flags & HA_OPEN_WAIT_IF_LOCKED ? 0 : MY_DONT_WAIT))) && - !(handle_locking & HA_OPEN_IGNORE_IF_LOCKED)) + !(open_flags & HA_OPEN_IGNORE_IF_LOCKED)) goto err; } errpos=3; @@ -176,6 +174,14 @@ MI_INFO *mi_open(const char *name, int mode, uint handle_locking) disk_pos=my_n_base_info_read(disk_cache+base_pos, &share->base); share->state.state_length=base_pos; + if ((open_flags & HA_OPEN_ABORT_IF_CRASHED) && + ((share->state.changed & STATE_CRASHED) || + (my_disable_locking && share->state.open_count))) + { + my_errno=((share->state.changed & STATE_CRASHED_ON_REPAIR) ? + HA_ERR_CRASHED_ON_REPAIR : HA_ERR_CRASHED); + goto err; + } /* Correct max_file_length based on length of sizeof_t */ max_data_file_length= (share->options & (HA_OPTION_PACK_RECORD | HA_OPTION_COMPRESS_RECORD)) ? @@ -273,7 +279,10 @@ MI_INFO *mi_open(const char *name, int mode, uint handle_locking) } } if (share->keyinfo[i].flag & HA_FULLTEXT) /* SerG */ + { share->keyinfo[i].seg=pos-FT_SEGS; /* SerG */ + share->fulltext_index=1; + } share->keyinfo[i].end=pos; pos->type=HA_KEYTYPE_END; /* End */ pos->length=share->base.rec_reflength; @@ -401,7 +410,7 @@ MI_INFO *mi_open(const char *name, int mode, uint handle_locking) ((share->options & (HA_OPTION_READ_ONLY_DATA | HA_OPTION_TMP_TABLE | HA_OPTION_COMPRESS_RECORD | HA_OPTION_TEMP_COMPRESS_RECORD)) || - (handle_locking & HA_OPEN_TMP_TABLE)) ? 0 : 1; + (open_flags & HA_OPEN_TMP_TABLE)) ? 0 : 1; if (share->concurrent_insert) { share->lock.get_status=mi_get_status; @@ -484,7 +493,7 @@ MI_INFO *mi_open(const char *name, int mode, uint handle_locking) info.lock_type=F_RDLCK; share->r_locks++; } - if ((handle_locking & HA_OPEN_TMP_TABLE) || + if ((open_flags & HA_OPEN_TMP_TABLE) || (share->options & HA_OPTION_TMP_TABLE)) { share->temporary=share->delay_key_write=1; @@ -492,7 +501,7 @@ MI_INFO *mi_open(const char *name, int mode, uint handle_locking) share->w_locks++; /* We don't have to update status */ info.lock_type=F_WRLCK; } - if (((handle_locking & HA_OPEN_DELAY_KEY_WRITE) || + if (((open_flags & HA_OPEN_DELAY_KEY_WRITE) || (share->options & HA_OPTION_DELAY_KEY_WRITE)) && myisam_delay_key_write) share->delay_key_write=1; diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c index 73cd50b4e49..aa5ba48c03f 100644 --- a/myisam/myisamchk.c +++ b/myisam/myisamchk.c @@ -16,7 +16,7 @@ /* Descript, check and repair of ISAM tables */ -#include "myisamdef.h" +#include "fulltext.h" #include <m_ctype.h> #include <stdarg.h> @@ -123,6 +123,7 @@ int main(int argc, char **argv) llstr(check_param.total_deleted,buff2)); } free_defaults(default_argv); + ft_free_stopwords(); my_end(check_param.testflag & T_INFO ? MY_CHECK_ERROR | MY_GIVE_INFO : MY_CHECK_ERROR); exit(error); #ifndef _lint @@ -151,13 +152,14 @@ enum options {OPT_CHARSETS_DIR=256, OPT_SET_CHARSET,OPT_START_CHECK_POS}; static struct option long_options[] = { - {"analyze", no_argument, 0, 'a'}, - {"block-search", required_argument, 0, 'b'}, + {"analyze", no_argument, 0, 'a'}, + {"block-search", required_argument,0, 'b'}, + {"backup", no_argument, 0, 'B'}, {"character-sets-dir",required_argument,0, OPT_CHARSETS_DIR}, - {"check", no_argument, 0, 'c'}, + {"check", no_argument, 0, 'c'}, {"check-only-changed",no_argument, 0, 'C'}, #ifndef DBUG_OFF - {"debug", required_argument, 0, '#'}, + {"debug", optional_argument, 0, '#'}, #endif {"description", no_argument, 0, 'd'}, {"data-file-length", required_argument, 0, 'D'}, @@ -232,6 +234,7 @@ static void usage(void) -T, --read-only Don't mark table as checked\n"); puts("Repair options (When using -r or -o) \n\ + -B, --backup Make a backup of the .MYD file as 'filename-time.BAK'\n\ -D, --data-file-length=# Max length of data file (when recreating data\n\ file when it's full)\n\ -e, --extend-check Try to recover every possible row from the data file\n\ @@ -296,7 +299,7 @@ static void get_options(register int *argc,register char ***argv) set_all_changeable_vars(changeable_vars); if (isatty(fileno(stdout))) check_param.testflag|=T_WRITE_LOOP; - while ((c=getopt_long(*argc,*argv,"acCdeifF?lqrmosSTuUvVw#:b:D:k:O:R:A::t:", + while ((c=getopt_long(*argc,*argv,"aBcCdeifF?lqrmosSTuUvVw#:b:D:k:O:R:A::t:", long_options, &option_index)) != EOF) { switch(c) { @@ -313,6 +316,9 @@ static void get_options(register int *argc,register char ***argv) case 'b': check_param.search_after_block=strtoul(optarg,NULL,10); break; + case 'B': + check_param.testflag|= T_BACKUP_DATA; + break; case 'c': check_param.testflag|= T_CHECK; break; @@ -406,7 +412,7 @@ static void get_options(register int *argc,register char ***argv) check_param.testflag|= T_UPDATE_STATE; break; case '#': - DBUG_PUSH(optarg ? optarg : "d:t:o,/tmp/isamchk"); + DBUG_PUSH(optarg ? optarg : "d:t:o,/tmp/myisamchk.trace"); break; case 'V': print_version(); @@ -520,7 +526,6 @@ static int myisamchk(MI_CHECK *param, my_string filename) share->r_locks=0; raid_chunks=share->base.raid_chunks; - /* Skipp the checking of the file if: We are using --fast and the table is closed properly @@ -587,7 +592,7 @@ static int myisamchk(MI_CHECK *param, my_string filename) recreate=1; if (!(param->testflag & (T_REP | T_REP_BY_SORT))) { - param->testflag|=T_REP_BY_SORT; /* if only STATISTICS */ + param->testflag|=T_REP_BY_SORT; /* if only STATISTICS */ if (!(param->testflag & T_SILENT)) printf("- '%s' has old table-format. Recreating index\n",filename); if (!rep_quick) @@ -606,6 +611,9 @@ static int myisamchk(MI_CHECK *param, my_string filename) } else { + if (share->fulltext_index) + ft_init_stopwords(ft_precompiled_stopwords); /* SerG */ + if (!(param->testflag & T_READONLY)) lock_type = F_WRLCK; /* table is changed */ else @@ -649,9 +657,10 @@ static int myisamchk(MI_CHECK *param, my_string filename) } if (!error) { - if (param->testflag & T_REP_BY_SORT && + if ((param->testflag & T_REP_BY_SORT) && (share->state.key_map || - (rep_quick && !param->keys_in_use && !recreate))) + (rep_quick && !param->keys_in_use && !recreate)) && + mi_test_if_sort_rep(info, info->state->records, 1)) error=mi_repair_by_sort(&check_param,info,fixed_name,rep_quick); else if (param->testflag & (T_REP | T_REP_BY_SORT)) error=mi_repair(&check_param, info,fixed_name,rep_quick); @@ -662,7 +671,8 @@ static int myisamchk(MI_CHECK *param, my_string filename) { /* Change temp file to org file */ VOID(my_close(info->dfile,MYF(MY_WME))); /* Close new file */ error|=change_to_newfile(fixed_name,MI_NAME_DEXT,DATA_TMP_EXT, - raid_chunks); + raid_chunks, + MYF(0)); #ifdef USE_RAID if (share->base.raid_type) { @@ -811,9 +821,12 @@ end2: { if (param->out_flag & O_NEW_DATA) error|=change_to_newfile(fixed_name,MI_NAME_DEXT,DATA_TMP_EXT, - raid_chunks); + raid_chunks, + ((param->testflag & T_BACKUP_DATA) ? + MYF(MY_REDEL_MAKE_BACKUP) : MYF(0))); if (param->out_flag & O_NEW_INDEX) - error|=change_to_newfile(fixed_name,MI_NAME_IEXT,INDEX_TMP_EXT,0); + error|=change_to_newfile(fixed_name,MI_NAME_IEXT,INDEX_TMP_EXT,0, + MYF(0)); } VOID(fflush(stdout)); VOID(fflush(stderr)); if (param->error_printed) @@ -1381,6 +1394,7 @@ void mi_check_print_warning(MI_CHECK *param, const char *fmt,...) if (param->testflag & T_SILENT) fprintf(stderr,"%s: MyISAM file %s\n",my_progname, param->isam_file_name); + param->out_flag|= O_DATA_LOST; } param->warning_printed=1; va_start(args,fmt); @@ -1405,6 +1419,7 @@ void mi_check_print_error(MI_CHECK *param, const char *fmt,...) { if (param->testflag & T_SILENT) fprintf(stderr,"%s: ISAM file %s\n",my_progname,param->isam_file_name); + param->out_flag|= O_DATA_LOST; } param->error_printed|=1; va_start(args,fmt); diff --git a/myisam/myisamdef.h b/myisam/myisamdef.h index 491c0cb1bc4..8784afca0d9 100644 --- a/myisam/myisamdef.h +++ b/myisam/myisamdef.h @@ -179,7 +179,8 @@ typedef struct st_mi_isam_share { /* Shared between opens */ global_changed, /* If changed since open */ not_flushed, temporary,delay_key_write, - concurrent_insert; + concurrent_insert, + fulltext_index; myf write_flag; int rnd; /* rnd-counter */ MI_DECODE_TREE *decode_trees; @@ -294,7 +295,7 @@ struct st_myisam_info { mi_int2store(x,boh); } #define mi_test_if_nod(x) (x[0] & 128 ? info->s->base.key_reflength : 0) #define mi_mark_crashed(x) (x)->s->state.changed|=STATE_CRASHED -#define mi_mark_crashed_on_repair(x) (x)->s->state.changed|=STATE_CRASHED|STATE_CRASHED_ON_REPAIR +#define mi_mark_crashed_on_repair(x) { (x)->s->state.changed|=STATE_CRASHED|STATE_CRASHED_ON_REPAIR ; (x)->update|= HA_STATE_CHANGED; } #define mi_is_crashed(x) ((x)->s->state.changed & STATE_CRASHED) #define mi_is_crashed_on_repair(x) ((x)->s->state.changed & STATE_CRASHED_ON_REPAIR) |