diff options
author | unknown <monty@tik.mysql.com> | 2000-10-15 18:45:53 +0300 |
---|---|---|
committer | unknown <monty@tik.mysql.com> | 2000-10-15 18:45:53 +0300 |
commit | d78f9840978cf60b73f13f6a5201ed5593636573 (patch) | |
tree | 51edb97a7ba1e486acf5bdba590984b73c775b29 | |
parent | 31ed959ba37ae81b9b0eb2079f1576f34f1241c7 (diff) | |
download | mariadb-git-d78f9840978cf60b73f13f6a5201ed5593636573.tar.gz |
Changed meaning of HA_EXTRA_RESET and start of hidden primary keys for BDB tables
heap/hp_extra.c:
Changed meaning of HA_EXTRA_RESET
include/my_base.h:
Added HA_EXTRA_RESET_STATE
isam/extra.c:
Changed meaning of HA_EXTRA_RESET
isam/pack_isam.c:
Addapt to changed HA_EXTRA_RESET
merge/extra.c:
Changed meaning of HA_EXTRA_RESET
myisam/mi_extra.c:
Changed meaning of HA_EXTRA_RESET
myisam/myisampack.c:
Addapt to changed HA_EXTRA_RESET
myisammrg/myrg_extra.c:
Addapt to changed HA_EXTRA_RESET
sql/filesort.cc:
Addapt to changed HA_EXTRA_RESET
sql/ha_berkeley.cc:
Hidden primary key
sql/ha_berkeley.h:
Hidden primary key
BitKeeper/etc/logging_ok:
Logging to logging@openlogging.org accepted
-rw-r--r-- | BitKeeper/etc/logging_ok | 27 | ||||
-rw-r--r-- | heap/hp_extra.c | 1 | ||||
-rw-r--r-- | include/my_base.h | 3 | ||||
-rw-r--r-- | isam/extra.c | 8 | ||||
-rw-r--r-- | isam/pack_isam.c | 4 | ||||
-rw-r--r-- | merge/extra.c | 4 | ||||
-rw-r--r-- | myisam/mi_extra.c | 18 | ||||
-rw-r--r-- | myisam/myisampack.c | 4 | ||||
-rw-r--r-- | myisammrg/myrg_extra.c | 4 | ||||
-rw-r--r-- | sql/filesort.cc | 4 | ||||
-rw-r--r-- | sql/ha_berkeley.cc | 31 | ||||
-rw-r--r-- | sql/ha_berkeley.h | 5 |
12 files changed, 71 insertions, 42 deletions
diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 9fd5747e088..a6b0f220269 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -1,26 +1 @@ -bk@work.mysql.com -davida@work.mysql.com -jamppa@work.mysql.com -jcole@ham.spaceapes.com -jcole@jcole.burghcom.com -jcole@nslinux.bedford.progress.com -jcole@tetra.bedford.progress.com -jcole@tetra.spaceapes.com -matt@work.mysql.com -monty@donna.mysql.com -monty@work.mysql.com -mwagner@evoq.home.mwagner.org -nusphere@main.burghcom.com -paul@central.snake.net -paul@work.mysql.com -sasha@mysql.sashanet.com -sasha@work.mysql.com -serg@infomag.ape.relarn.ru -serg@serg.mysql.com -serg@work.mysql.com -sinisa@work.mysql.com -spurr@nslinux.bedford.progress.com -tim@localhost.polyesthetic.msg -tim@threads.polyesthetic.msg -tim@work.mysql.com -tonu@work.mysql.com +monty@tik.mysql.com diff --git a/heap/hp_extra.c b/heap/hp_extra.c index 581ca1e8e56..133be01c676 100644 --- a/heap/hp_extra.c +++ b/heap/hp_extra.c @@ -29,6 +29,7 @@ int heap_extra(register HP_INFO *info, enum ha_extra_function function) switch (function) { case HA_EXTRA_RESET: + case HA_EXTRA_RESET_STATE: info->lastinx= -1; info->current_record= (ulong) ~0L; info->current_hash_ptr=0; diff --git a/include/my_base.h b/include/my_base.h index 033b38672d3..5c76b5a6bc3 100644 --- a/include/my_base.h +++ b/include/my_base.h @@ -87,7 +87,8 @@ enum ha_extra_function { HA_EXTRA_REINIT_CACHE=20, /* init cache from current record */ HA_EXTRA_FORCE_REOPEN=21, /* Datafile have changed on disk */ HA_EXTRA_FLUSH, /* Flush tables to disk */ - HA_EXTRA_NO_ROWS /* Don't write rows */ + HA_EXTRA_NO_ROWS, /* Don't write rows */ + HA_EXTRA_RESET_STATE /* Reset positions */ }; /* The following is parameter to ha_panic() */ diff --git a/isam/extra.c b/isam/extra.c index dc9b6ce2d19..1d333fa372f 100644 --- a/isam/extra.c +++ b/isam/extra.c @@ -36,6 +36,14 @@ int nisam_extra(N_INFO *info, enum ha_extra_function function) switch (function) { case HA_EXTRA_RESET: + if (info->opt_flag & (READ_CACHE_USED | WRITE_CACHE_USED)) + { + info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED); + error=end_io_cache(&info->rec_cache); + } + info->opt_flag&= ~(KEY_READ_USED | REMEMBER_OLD_POS); + + case HA_EXTRA_RESET_STATE: info->lastinx= 0; /* Use first index as def */ info->int_pos=info->lastpos= NI_POS_ERROR; info->page_changed=1; diff --git a/isam/pack_isam.c b/isam/pack_isam.c index 1040096fa4a..cadec5bcef5 100644 --- a/isam/pack_isam.c +++ b/isam/pack_isam.c @@ -2012,8 +2012,8 @@ static int mrg_rrnd(MRG_INFO *info,byte *buf) { isam_info= *(info->current=info->file); info->end=info->current+info->count; - nisam_extra(isam_info,HA_EXTRA_CACHE); nisam_extra(isam_info,HA_EXTRA_RESET); + nisam_extra(isam_info,HA_EXTRA_CACHE); filepos=isam_info->s->pack.header_length; } else @@ -2035,8 +2035,8 @@ static int mrg_rrnd(MRG_INFO *info,byte *buf) info->current++; isam_info= *info->current; filepos=isam_info->s->pack.header_length; - nisam_extra(isam_info,HA_EXTRA_CACHE); nisam_extra(isam_info,HA_EXTRA_RESET); + nisam_extra(isam_info,HA_EXTRA_CACHE); } } diff --git a/merge/extra.c b/merge/extra.c index c20241228a2..343806dbfad 100644 --- a/merge/extra.c +++ b/merge/extra.c @@ -32,9 +32,9 @@ enum ha_extra_function function; info->cache_in_use=1; else { - if (function == HA_EXTRA_NO_CACHE) + if (function == HA_EXTRA_NO_CACHE || function == HA_EXTRA_RESET) info->cache_in_use=0; - if (function == HA_EXTRA_RESET) + if (function == HA_EXTRA_RESET || function == HA_EXTRA_RESET_STATE) { info->current_table=0; info->last_used_table=info->open_tables; diff --git a/myisam/mi_extra.c b/myisam/mi_extra.c index b90b5b35780..eaf9400babe 100644 --- a/myisam/mi_extra.c +++ b/myisam/mi_extra.c @@ -37,6 +37,24 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function) switch (function) { case HA_EXTRA_RESET: + /* + Free buffers and reset the following flags: + EXTRA_CACHE, EXTRA_WRITE_CACHE, EXTRA_KEYREAD, EXTRA_QUICK + */ + if (info->opt_flag & (READ_CACHE_USED | WRITE_CACHE_USED)) + { + info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED); + error=end_io_cache(&info->rec_cache); + } +#if defined(HAVE_MMAP) && defined(HAVE_MADVICE) + if (info->opt_flag & MEMMAP_USED) + madvise(share->file_map,share->state.state.data_file_length,MADV_RANDOM); +#endif + info->opt_flag&= ~(KEY_READ_USED | REMEMBER_OLD_POS); + info->quick_mode=0; + /* Fall through */ + + case HA_EXTRA_RESET_STATE: /* Reset state (don't free buffers) */ info->lastinx= 0; /* Use first index as def */ info->last_search_keypage=info->lastpos= HA_OFFSET_ERROR; info->page_changed=1; diff --git a/myisam/myisampack.c b/myisam/myisampack.c index fbb543152f8..ef9be13687e 100644 --- a/myisam/myisampack.c +++ b/myisam/myisampack.c @@ -2104,8 +2104,8 @@ static int mrg_rrnd(MRG_INFO *info,byte *buf) { isam_info= *(info->current=info->file); info->end=info->current+info->count; - mi_extra(isam_info,HA_EXTRA_CACHE); mi_extra(isam_info,HA_EXTRA_RESET); + mi_extra(isam_info,HA_EXTRA_CACHE); filepos=isam_info->s->pack.header_length; } else @@ -2127,8 +2127,8 @@ static int mrg_rrnd(MRG_INFO *info,byte *buf) info->current++; isam_info= *info->current; filepos=isam_info->s->pack.header_length; - mi_extra(isam_info,HA_EXTRA_CACHE); mi_extra(isam_info,HA_EXTRA_RESET); + mi_extra(isam_info,HA_EXTRA_CACHE); } } diff --git a/myisammrg/myrg_extra.c b/myisammrg/myrg_extra.c index 0927728e2c1..4b5353a146d 100644 --- a/myisammrg/myrg_extra.c +++ b/myisammrg/myrg_extra.c @@ -31,9 +31,9 @@ int myrg_extra(MYRG_INFO *info,enum ha_extra_function function) info->cache_in_use=1; else { - if (function == HA_EXTRA_NO_CACHE) + if (function == HA_EXTRA_NO_CACHE || function == HA_EXTRA_RESET) info->cache_in_use=0; - if (function == HA_EXTRA_RESET) + if (function == HA_EXTRA_RESET || function == HA_EXTRA_RESET_STATE) { info->current_table=0; info->last_used_table=info->open_tables; diff --git a/sql/filesort.cc b/sql/filesort.cc index 32947a06ba1..08aca12d5b8 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -330,7 +330,9 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, next_pos=ref_pos; if (! indexfile && ! quick_select) { - file->reset(); + file->reset(); // QQ; Shouldn't be needed + if (table->keyread) // QQ Can be removed after the reset + file->extra(HA_EXTRA_KEYREAD); // QQ is removed next_pos=(byte*) 0; /* Find records in sequence */ file->rnd_init(); file->extra(HA_EXTRA_CACHE); /* Quicker reads */ diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc index 5f156622901..e5c9f66e200 100644 --- a/sql/ha_berkeley.cc +++ b/sql/ha_berkeley.cc @@ -319,8 +319,14 @@ int ha_berkeley::open(const char *name, int mode, uint test_if_locked) /* Open other keys */ bzero((char*) key_file,sizeof(*key_file)*table->keys); - key_used_on_scan=primary_key=table->primary_key; - key_file[primary_key]=file; + if ((key_used_on_scan=primary_key=table->primary_key) < MAX_KEY) + key_file[primary_key]=file; + else // No primary key + { + hidden_primary_key=1; + if (!share->primary_key_inited) + update_auto_primary_key(); + } bzero((char*) ¤t_row,sizeof(current_row)); DB **ptr=key_file; @@ -1387,8 +1393,6 @@ static BDB_SHARE *get_share(const char *table_name) if ((share=(BDB_SHARE *) my_malloc(sizeof(*share)+length+1, MYF(MY_WME | MY_ZEROFILL)))) { - // pthread_mutex_init(&share->mutex); - // pthread_cond_init(&share->cond); share->table_name_length=length; share->table_name=(char*) (share+1); strmov(share->table_name,table_name); @@ -1399,6 +1403,7 @@ static BDB_SHARE *get_share(const char *table_name) return 0; } thr_lock_init(&share->lock); + pthread_mutex_init(&share->mutex); } } share->use_count++; @@ -1413,10 +1418,26 @@ static void free_share(BDB_SHARE *share) { hash_delete(&bdb_open_tables, (gptr) share); thr_lock_delete(&share->lock); - // pthread_mutex_destroy(&share->mutex); + pthread_mutex_destroy(&share->mutex); my_free((gptr) share, MYF(0)); } pthread_mutex_unlock(&bdb_mutex); } + +void ha_berkeley::update_auto_primary_key() +{ + (void) extra(HA_EXTRA_KEYREAD); + pthread_mutex_lock(&share->mutex); + if (!share->primary_key_inited) + { + index_init(primary_key); + if (!index_last(table->record[1])) + share->auto_ident=current_ident; + index_end(); + } + pthread_mutex_unlock(&share->mutex); + (void) extra(HA_EXTRA_NO_KEYREAD); +} + #endif /* HAVE_BERKELEY_DB */ diff --git a/sql/ha_berkeley.h b/sql/ha_berkeley.h index 519e4b62cf9..89ee6e58332 100644 --- a/sql/ha_berkeley.h +++ b/sql/ha_berkeley.h @@ -24,9 +24,12 @@ #include <db.h> typedef struct st_berkeley_share { + ulonglong auto_ident; THR_LOCK lock; + pthread_mutex_t mutex; char *table_name; uint table_name_length,use_count; + my_bool inited; } BDB_SHARE; class ha_berkeley: public handler @@ -44,7 +47,7 @@ class ha_berkeley: public handler ulong int_option_flag; ulong alloced_rec_buff_length; uint primary_key,last_dup_key; - bool fixed_length_row, fixed_length_primary_key; + bool fixed_length_row, fixed_length_primary_key, hidden_primary_key; bool fix_rec_buff_for_blob(ulong length); ulong max_row_length(const byte *buf); |