1
0
mirror of https://github.com/MariaDB/server.git synced 2025-12-24 11:21:21 +03:00

Merge mronstrom@bk-internal.mysql.com:/home/bk/mysql-5.1

into mysql.com:/Users/mikron/wl1682
This commit is contained in:
mronstrom@mysql.com
2005-05-12 12:01:01 +02:00
30 changed files with 1737 additions and 513 deletions

View File

@@ -194,54 +194,67 @@ enum db_type ha_checktype(enum db_type database_type)
handler *get_new_handler(TABLE *table, enum db_type db_type)
{
handler *file;
switch (db_type) {
#ifndef NO_HASH
case DB_TYPE_HASH:
return new ha_hash(table);
file= new ha_hash(table);
#endif
#ifdef HAVE_ISAM
case DB_TYPE_MRG_ISAM:
return new ha_isammrg(table);
file= new ha_isammrg(table);
break;
case DB_TYPE_ISAM:
return new ha_isam(table);
file= new ha_isam(table);
break;
#else
case DB_TYPE_MRG_ISAM:
return new ha_myisammrg(table);
file= new ha_myisammrg(table);
break;
#endif
#ifdef HAVE_BERKELEY_DB
case DB_TYPE_BERKELEY_DB:
return new ha_berkeley(table);
file= new ha_berkeley(table);
break;
#endif
#ifdef HAVE_INNOBASE_DB
case DB_TYPE_INNODB:
return new ha_innobase(table);
file= new ha_innobase(table);
break;
#endif
#ifdef HAVE_EXAMPLE_DB
case DB_TYPE_EXAMPLE_DB:
return new ha_example(table);
file= new ha_example(table);
break;
#endif
#ifdef HAVE_ARCHIVE_DB
case DB_TYPE_ARCHIVE_DB:
return new ha_archive(table);
file= new ha_archive(table);
break;
#endif
#ifdef HAVE_BLACKHOLE_DB
case DB_TYPE_BLACKHOLE_DB:
return new ha_blackhole(table);
file= new ha_blackhole(table);
break;
#endif
#ifdef HAVE_FEDERATED_DB
case DB_TYPE_FEDERATED_DB:
return new ha_federated(table);
file= new ha_federated(table);
break;
#endif
#ifdef HAVE_CSV_DB
case DB_TYPE_CSV_DB:
return new ha_tina(table);
file= new ha_tina(table);
break;
#endif
#ifdef HAVE_NDBCLUSTER_DB
case DB_TYPE_NDBCLUSTER:
return new ha_ndbcluster(table);
file= new ha_ndbcluster(table);
break;
#endif
case DB_TYPE_HEAP:
return new ha_heap(table);
file= new ha_heap(table);
break;
default: // should never happen
{
enum db_type def=(enum db_type) current_thd->variables.table_type;
@@ -251,10 +264,21 @@ handler *get_new_handler(TABLE *table, enum db_type db_type)
}
/* Fall back to MyISAM */
case DB_TYPE_MYISAM:
return new ha_myisam(table);
file= new ha_myisam(table);
break;
case DB_TYPE_MRG_MYISAM:
return new ha_myisammrg(table);
file= new ha_myisammrg(table);
break;
}
if (file)
{
if (file->ha_initialise())
{
delete file;
file=0;
}
}
return file;
}
/*
@@ -1320,6 +1344,84 @@ int handler::ha_open(const char *name, int mode, int test_if_locked)
DBUG_RETURN(error);
}
int handler::ha_initialise()
{
DBUG_ENTER("ha_initialise");
if (table && table->s->fields &&
ha_allocate_read_write_set(table->s->fields))
{
DBUG_RETURN(TRUE);
}
DBUG_RETURN(FALSE);
}
int handler::ha_allocate_read_write_set(ulong no_fields)
{
uint bitmap_size= 4*(((no_fields+1)+31)/32);
uchar *read_buf, *write_buf;
DBUG_ENTER("ha_allocate_read_write_set");
DBUG_PRINT("info", ("no_fields = %d", no_fields));
read_set= (MY_BITMAP*)sql_alloc(sizeof(MY_BITMAP));
write_set= (MY_BITMAP*)sql_alloc(sizeof(MY_BITMAP));
read_buf= (uchar*)sql_alloc(bitmap_size);
write_buf= (uchar*)sql_alloc(bitmap_size);
DBUG_ASSERT(!bitmap_init(read_set, read_buf, (no_fields+1), FALSE));
DBUG_ASSERT(!bitmap_init(write_set, write_buf, (no_fields+1), FALSE));
if (!read_set || !write_set || !read_buf || !write_buf)
{
ha_deallocate_read_write_set();
DBUG_RETURN(TRUE);
}
ha_clear_all_set();
DBUG_RETURN(FALSE);
}
void handler::ha_deallocate_read_write_set()
{
DBUG_ENTER("ha_deallocate_read_write_set");
read_set=write_set=0;
DBUG_VOID_RETURN;
}
void handler::ha_clear_all_set()
{
DBUG_ENTER("ha_clear_all_set");
bitmap_clear_all(read_set);
bitmap_clear_all(write_set);
bitmap_set_bit(read_set, 0);
bitmap_set_bit(write_set, 0);
DBUG_VOID_RETURN;
}
int handler::ha_retrieve_all_cols()
{
DBUG_ENTER("handler::ha_retrieve_all_cols");
bitmap_set_all(read_set);
DBUG_RETURN(0);
}
int handler::ha_retrieve_all_pk()
{
DBUG_ENTER("ha_retrieve_all_pk");
ha_set_primary_key_in_read_set();
DBUG_RETURN(0);
}
void handler::ha_set_primary_key_in_read_set()
{
ulong prim_key= table->s->primary_key;
DBUG_ENTER("handler::ha_set_primary_key_in_read_set");
DBUG_PRINT("info", ("Primary key = %d", prim_key));
if (prim_key != MAX_KEY)
{
KEY_PART_INFO *key_part= table->key_info[prim_key].key_part;
KEY_PART_INFO *key_part_end= key_part +
table->key_info[prim_key].key_parts;
for (;key_part != key_part_end; ++key_part)
ha_set_bit_in_read_set(key_part->fieldnr);
}
DBUG_VOID_RETURN;
}
/*
Read first row (only) from a table
This is never called for InnoDB or BDB tables, as these table types