summaryrefslogtreecommitdiff
path: root/myisam
diff options
context:
space:
mode:
authorunknown <monty@donna.mysql.com>2000-08-15 20:09:37 +0300
committerunknown <monty@donna.mysql.com>2000-08-15 20:09:37 +0300
commit8b3993bc017512c3bf20315b12d1a8b7a6870381 (patch)
tree5f72e7444fbc3c8d944a66b54b26550a04e4f0be /myisam
parent99110483b2271095dd8b2cb655e3a054f6f7c5a5 (diff)
downloadmariadb-git-8b3993bc017512c3bf20315b12d1a8b7a6870381.tar.gz
Fixed for Ia64 + delayed key creation + a lot of small bug fixes
Docs/Makefile.am: Removed typo Docs/internals.texi: Added documentation about filesort Docs/manual.texi: Lots of changes, including information about the password in the mysql.user table config.h.in: ***MISSING WEAVE*** heap/hp_rnext.c: Fix of reading of read-next include/config-win.h: Fix for Ia64 include/global.h: Fix for Ia64 include/my_base.h: Fix for Ia64 include/myisam.h: New repair options isam/_dynrec.c: Typo fixes isam/_search.c: Fix for Ia64 merge/rrnd.c: Fix of ORDER BY for MERGE tables myisam/ft_eval.c: Fix for Ia64 myisam/ft_parser.c: Fix for Ia64 myisam/ft_static.c: Portability fixes myisam/mi_check.c: Fix for Ia64 + delay key creation myisam/mi_locking.c: Portability fixes myisam/myisamdef.h: Fixes for automatic table repair myisam/myisampack.c: Version number increment myisammrg/myrg_rrnd.c: Fix of ORDER BY for mymerge tables mysql.proj: Updated mysys/charset.c: Fix for Ia64 mysys/mf_casecnv.c: Fix for Ia64 mysys/mf_pack.c: Fix for Ia64 mysys/mf_path.c: Fix for Ia64 mysys/mf_wfile.c: Fix for Ia64 mysys/my_alloc.c: Fix for Ia64 mysys/my_lib.c: Fix for Ia64 mysys/my_lread.c: Fix for Ia64 mysys/my_lwrite.c: Fix for Ia64 mysys/my_winthread.c: Fix for Ia64 mysys/string.c: Fix for Ia64 mysys/thr_alarm.c: Fix for Ia64 mysys/thr_rwlock.c: Fix of scheduler bug for systems without rw_locks regex/regcomp.c: Fix for Ia64 regex/regex.h: Fix for Ia64 regex/regex2.h: Fix for Ia64 scripts/mysqlhotcopy.sh: Explicit version number (because of bitkeeper) sql-bench/bench-init.pl.sh: New help message sql-bench/server-cfg.sh: Updates for postgreSQL 7.0 sql/ChangeLog: Changelog sql/field.cc: Fix of datetime function handling sql/filesort.cc: More comments sql/gen_lex_hash.cc: More options sql/ha_berkeley.cc: Fix for part key reading sql/ha_berkeley.h: Indentation sql/ha_myisam.cc: Fix for delayed key creation sql/ha_myisam.h: Fix for delayed key creation sql/handler.h: Fix for delayed key creation sql/item_func.cc: Fix of crash when using constant expression with UDF functions in WHERE sql/item_timefunc.cc: Fix of datetime function handling sql/mini_client.cc: Portability fix sql/mysql_priv.h: Optimization of select initialization sql/mysqld.cc: Portability fixes, thread cache and min argument for connect_timeout sql/sql_load.cc: Delayed key handling sql/sql_parse.cc: Portability fixes and select initialization optimization sql/sql_select.cc: Small optimization + more comments sql/sql_table.cc: Fix default value adding to blob with alter table + delayed index creation sql/sql_yacc.yy: Optimized select initialization sql/structs.h: Fix for part key read strings/ctype-sjis.c: Fix for Ia64 strings/ctype-tis620.c: Fix for Ia64 strings/t_ctype.h: bk fix support-files/mysql.spec.sh: Added comment vio/viotest-ssl.cc: bk fix vio/viotest-sslconnect.cc: bk fix vio/viotest.cc: bk fix BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted
Diffstat (limited to 'myisam')
-rw-r--r--myisam/ft_eval.c6
-rw-r--r--myisam/ft_parser.c2
-rw-r--r--myisam/ft_static.c20
-rw-r--r--myisam/mi_check.c95
-rw-r--r--myisam/mi_locking.c4
-rw-r--r--myisam/myisamdef.h3
-rw-r--r--myisam/myisampack.c2
7 files changed, 105 insertions, 27 deletions
diff --git a/myisam/ft_eval.c b/myisam/ft_eval.c
index b8628724642..eeb414a7505 100644
--- a/myisam/ft_eval.c
+++ b/myisam/ft_eval.c
@@ -84,7 +84,7 @@ int main(int argc,char *argv[])
for(i=1;create_record(record,qf);i++) {
FT_DOCLIST *result; double w; int t;
- result=ft_init_search(file,0,blob_record,strlen(blob_record),1);
+ result=ft_init_search(file,0,blob_record,(uint) strlen(blob_record),1);
if(!result) {
printf("Query %d failed with errno %3d\n",i,my_errno);
goto err;
@@ -177,7 +177,7 @@ int create_record(char *pos, FILE *file)
{
if(feof(file)) return 0; else print_error(1,"fgets(docid) - 1");
}
- tmp=strlen(pos+2)-1;
+ tmp=(uint) strlen(pos+2)-1;
int2store(pos,tmp);
pos+=recinfo[0].length;
@@ -185,7 +185,7 @@ int create_record(char *pos, FILE *file)
if(!(fgets(blob_record,MAX_BLOB_LENGTH,file)))
print_error(1,"fgets(docid) - 2");
- tmp=strlen(blob_record);
+ tmp=(uint) strlen(blob_record);
int4store(pos,tmp);
ptr=blob_record;
memcpy_fixed(pos+4,&ptr,sizeof(char*));
diff --git a/myisam/ft_parser.c b/myisam/ft_parser.c
index e2fcd2b00a1..588f5831dce 100644
--- a/myisam/ft_parser.c
+++ b/myisam/ft_parser.c
@@ -140,7 +140,7 @@ TREE * ft_parse(TREE *wtree, byte *doc, int doclen)
if(word_char(*doc)) break;
for(w.pos=doc; doc<end; doc++)
if(!word_char(*doc)) break;
- if((w.len=doc-w.pos) < MIN_WORD_LEN) continue;
+ if((w.len= (uint) (doc-w.pos)) < MIN_WORD_LEN) continue;
if(!tree_insert(wtree, &w, 0))
{
delete_tree(wtree);
diff --git a/myisam/ft_static.c b/myisam/ft_static.c
index 5cbcff85b54..34b9368d522 100644
--- a/myisam/ft_static.c
+++ b/myisam/ft_static.c
@@ -19,19 +19,19 @@
#include "ftdefs.h"
const MI_KEYSEG ft_keysegs[FT_SEGS]={
- {
- HA_KEYTYPE_VARTEXT, // type
- 7, // language
- 0, 0, 0, // null_bit, bit_start, bit_end
- HA_VAR_LENGTH | HA_PACK_KEY, // flag
- HA_FT_MAXLEN, // length
+{
+ HA_KEYTYPE_VARTEXT, /* type */
+ 7, /* language */
+ 0, 0, 0, /* null_bit, bit_start, bit_end */
+ HA_VAR_LENGTH | HA_PACK_KEY, /* flag */
+ HA_FT_MAXLEN, /* length */
#ifdef EVAL_RUN
- HA_FT_WLEN+1, // start
+ HA_FT_WLEN+1, /* start */
#else /* EVAL_RUN */
- HA_FT_WLEN, // start
+ HA_FT_WLEN, /* start */
#endif /* EVAL_RUN */
- 0, // null_pos
- NULL // sort_order
+ 0, /* null_pos */
+ NULL /* sort_order */
},
#ifdef EVAL_RUN
{
diff --git a/myisam/mi_check.c b/myisam/mi_check.c
index 5b5583b136e..f8667afb46a 100644
--- a/myisam/mi_check.c
+++ b/myisam/mi_check.c
@@ -220,7 +220,7 @@ static int check_k_link(MI_CHECK *param, register MI_INFO *info, uint nr)
if (next_link > info->state->key_file_length ||
next_link & (info->s->blocksize-1))
DBUG_RETURN(1);
- if (!(buff=key_cache_read(info->s->kfile, next_link, info->buff,
+ if (!(buff=key_cache_read(info->s->kfile, next_link, (byte*) info->buff,
myisam_block_size, block_size, 1)))
DBUG_RETURN(1);
next_link=mi_sizekorr(buff);
@@ -1228,6 +1228,8 @@ err:
VOID(my_raid_delete(param->temp_filename,info->s->base.raid_chunks,
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));
@@ -1580,7 +1582,7 @@ err:
DBUG_RETURN(1);
}
- /* Fix table using sorting */
+ /* Fix table or given index using sorting */
/* saves new table in temp_filename */
int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
@@ -1597,6 +1599,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
ulong *rec_per_key_part;
char llbuff[22];
SORT_INFO *sort_info= &param->sort_info;
+ ulonglong key_map=share->state.key_map;
DBUG_ENTER("rep_by_sort");
start_records=info->state->records;
@@ -1621,7 +1624,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
init_io_cache(&info->rec_cache,info->dfile,
(uint) param->write_buffer_length,
WRITE_CACHE,new_header_length,1,
- MYF(MY_WME | MY_WAIT_IF_FULL))))
+ MYF(MY_WME | MY_WAIT_IF_FULL) & param->myf_rw)))
goto err;
sort_info->key_block_end=sort_info->key_block+param->sort_key_blocks;
info->opt_flag|=WRITE_CACHE_USED;
@@ -1664,10 +1667,15 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
}
info->update= (short) (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
- for (i=0 ; i < share->base.keys ; i++)
- share->state.key_root[i]= HA_OFFSET_ERROR;
- for (i=0 ; i < share->state.header.max_block_size ; i++)
- share->state.key_del[i]= HA_OFFSET_ERROR;
+ if (!(param->testflag & T_CREATE_MISSING_KEYS))
+ {
+ for (i=0 ; i < share->base.keys ; i++)
+ share->state.key_root[i]= HA_OFFSET_ERROR;
+ for (i=0 ; i < share->state.header.max_block_size ; i++)
+ share->state.key_del[i]= HA_OFFSET_ERROR;
+ }
+ else
+ key_map= ~key_map; /* Create the missing keys */
info->state->key_file_length=share->base.keystart;
@@ -1696,7 +1704,8 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
else
length=share->base.pack_reclength;
sort_param.max_records=sort_info->max_records=
- (ha_rows) (sort_info->filelength/length+1);
+ ((param->testflag & T_TRUST_HEADER) ? info->state->records :
+ (ha_rows) (sort_info->filelength/length+1));
sort_param.key_cmp=sort_key_cmp;
sort_param.key_write=sort_key_write;
sort_param.key_read=sort_key_read;
@@ -1714,7 +1723,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
rec_per_key_part+=sort_info->keyinfo->keysegs, sort_info->key++)
{
sort_info->keyinfo=share->keyinfo+sort_info->key;
- if (!(((ulonglong) 1 << sort_info->key) & share->state.key_map))
+ if (!(((ulonglong) 1 << sort_info->key) & key_map))
continue;
if ((!(param->testflag & T_SILENT)))
@@ -1755,6 +1764,15 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info,
param->read_cache.end_of_file=sort_info->filepos;
if (write_data_suffix(param,info) || end_io_cache(&info->rec_cache))
goto err;
+ if (param->testflag & T_SAFE_REPAIR)
+ {
+ /* Don't repair if we loosed more than one row */
+ if (info->state->records+1 < start_records)
+ {
+ info->state->records=start_records;
+ goto err;
+ }
+ }
share->state.state.data_file_length = info->state->data_file_length
= sort_info->filepos;
/* Only whole records */
@@ -1837,6 +1855,8 @@ err:
VOID(my_raid_delete(param->temp_filename,info->s->base.raid_chunks,
MYF(MY_WME)));
}
+ mi_mark_crashed_on_repair(info);
+ info->update|= HA_STATE_CHANGED;
}
my_free((gptr) sort_info->key_block,MYF(MY_ALLOW_ZERO_PTR));
my_free(sort_info->record,MYF(MY_ALLOW_ZERO_PTR));
@@ -1844,7 +1864,7 @@ err:
VOID(end_io_cache(&param->read_cache));
VOID(end_io_cache(&info->rec_cache));
info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED);
- if (!got_error && param->testflag & T_UNPACK)
+ if (!got_error && (param->testflag & T_UNPACK))
{
share->state.header.options[0]&= (uchar) ~HA_OPTION_COMPRESS_RECORD;
share->pack.header_length=0;
@@ -2884,3 +2904,58 @@ ha_checksum mi_byte_checksum(const byte *buf, uint length)
test(crc & (((ha_checksum) 1) << (8*sizeof(ha_checksum)-1)));
return crc;
}
+
+/*
+ Deactive all not unique index that can be recreated fast
+ These include packed keys on which sorting will use more temporary
+ space than the max allowed file length or for which the unpacked keys
+ will take much more space than packed keys.
+ Note that 'rows' may be zero for the case when we don't know how many
+ rows we will put into the file.
+ */
+
+static my_bool mi_too_big_key_for_sort(MI_KEYDEF *key, ha_rows rows)
+{
+ return (key->flag & (HA_BINARY_PACK_KEY | HA_VAR_LENGTH_KEY | HA_FULLTEXT) &&
+ ((ulonglong) rows * key->maxlength > MAX_FILE_SIZE ||
+ (ulonglong) rows * (key->maxlength - key->minlength) / 2 >
+ MI_MAX_TEMP_LENGTH ||
+ (rows == 0 && (key->maxlength / key->minlength) > 2)));
+}
+
+
+void mi_dectivate_non_unique_index(MI_INFO *info, ha_rows rows)
+{
+ MYISAM_SHARE *share=info->s;
+ uint i;
+ if (!info->state->records) /* Don't do this if old rows */
+ {
+ MI_KEYDEF *key=share->keyinfo;
+ for (i=0 ; i < share->base.keys ; i++,key++)
+ {
+ if (!(key->flag & HA_NOSAME) && ! mi_too_big_key_for_sort(key,rows))
+ {
+ share->state.key_map&= ~ ((ulonglong) 1 << i);
+ info->update|= HA_STATE_CHANGED;
+ }
+ }
+ }
+}
+
+
+/* Return TRUE if we can use repair by sorting */
+
+my_bool mi_test_if_sort_rep(MI_INFO *info, ha_rows rows)
+{
+ MYISAM_SHARE *share=info->s;
+ uint i;
+ MI_KEYDEF *key=share->keyinfo;
+ if (!share->state.key_map)
+ return FALSE; /* Can't use sort */
+ for (i=0 ; i < share->base.keys ; i++,key++)
+ {
+ if (mi_too_big_key_for_sort(key,rows))
+ return FALSE;
+ }
+ return TRUE;
+}
diff --git a/myisam/mi_locking.c b/myisam/mi_locking.c
index 2ef62c23430..24a23bda7e2 100644
--- a/myisam/mi_locking.c
+++ b/myisam/mi_locking.c
@@ -74,12 +74,12 @@ int mi_lock_database(MI_INFO *info, int lock_type)
share->state.process= share->last_process=share->this_process;
share->state.unique= info->last_unique= info->this_unique;
#ifndef HAVE_PREAD
- pthread_mutex_lock(&THR_LOCK_keycache); // QQ; Has to be removed!
+ pthread_mutex_lock(&THR_LOCK_keycache); /* QQ; Has to be removed! */
#endif
if (mi_state_info_write(share->kfile, &share->state, 1))
error=my_errno;
#ifndef HAVE_PREAD
- pthread_mutex_unlock(&THR_LOCK_keycache);// QQ; Has to be removed!
+ pthread_mutex_unlock(&THR_LOCK_keycache);/* QQ; Has to be removed! */
#endif
share->changed=0;
if (myisam_flush)
diff --git a/myisam/myisamdef.h b/myisam/myisamdef.h
index 13bb2e7efad..e1263c89ff5 100644
--- a/myisam/myisamdef.h
+++ b/myisam/myisamdef.h
@@ -284,7 +284,9 @@ 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|=2
+#define mi_mark_crashed_on_repair(x) (x)->s->state.changed|=4+2
#define mi_is_crashed(x) ((x)->s->state.changed & 2)
+#define mi_is_crashed_on_repair(x) ((x)->s->state.changed & 4)
/* Functions to store length of space packed keys, VARCHAR or BLOB keys */
@@ -606,6 +608,7 @@ void mi_get_status(void* param);
void mi_update_status(void* param);
void mi_copy_status(void* to,void *from);
my_bool mi_check_status(void* param);
+void mi_dectivate_non_unique_index(MI_INFO *info, ha_rows rows);
/* Functions needed by mi_check */
#ifdef __cplusplus
diff --git a/myisam/myisampack.c b/myisam/myisampack.c
index 3421f77c8d8..23d7f494994 100644
--- a/myisam/myisampack.c
+++ b/myisam/myisampack.c
@@ -249,7 +249,7 @@ static struct option long_options[] =
static void print_version(void)
{
- printf("%s Ver 1.7 for %s on %s\n",my_progname,SYSTEM_TYPE,MACHINE_TYPE);
+ printf("%s Ver 1.8 for %s on %s\n",my_progname,SYSTEM_TYPE,MACHINE_TYPE);
}
static void usage(void)