mirror of
https://github.com/MariaDB/server.git
synced 2025-01-15 19:42:28 +01:00
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
This commit is contained in:
parent
31ed959ba3
commit
d78f984097
12 changed files with 71 additions and 42 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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() */
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue