mirror of
https://github.com/MariaDB/server.git
synced 2025-08-30 11:22:14 +03:00
Merge mysql.com:/home/mydev/mysql-5.1--main
into mysql.com:/home/mydev/mysql-5.1-amerge
This commit is contained in:
@@ -139,7 +139,7 @@ static HASH archive_open_tables;
|
||||
#define ARCHIVE_CHECK_HEADER 254 // The number we use to determine corruption
|
||||
|
||||
/* Static declarations for handerton */
|
||||
static handler *archive_create_handler(TABLE_SHARE *table);
|
||||
static handler *archive_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root);
|
||||
/*
|
||||
Number of rows that will force a bulk insert.
|
||||
*/
|
||||
@@ -147,9 +147,9 @@ static handler *archive_create_handler(TABLE_SHARE *table);
|
||||
|
||||
handlerton archive_hton;
|
||||
|
||||
static handler *archive_create_handler(TABLE_SHARE *table)
|
||||
static handler *archive_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root)
|
||||
{
|
||||
return new ha_archive(table);
|
||||
return new (mem_root) ha_archive(table);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -662,8 +662,8 @@ int ha_archive::create(const char *name, TABLE *table_arg,
|
||||
int error;
|
||||
DBUG_ENTER("ha_archive::create");
|
||||
|
||||
auto_increment_value= (create_info->auto_increment_value ?
|
||||
create_info->auto_increment_value -1 :
|
||||
stats.auto_increment_value= (create_info->auto_increment_value ?
|
||||
create_info->auto_increment_value -1 :
|
||||
(ulonglong) 0);
|
||||
|
||||
for (uint key= 0; key < table_arg->s->keys; key++)
|
||||
@@ -693,7 +693,7 @@ int ha_archive::create(const char *name, TABLE *table_arg,
|
||||
goto error;
|
||||
}
|
||||
|
||||
write_meta_file(create_file, 0, auto_increment_value, 0,
|
||||
write_meta_file(create_file, 0, stats.auto_increment_value, 0,
|
||||
(char *)create_info->data_file_name,
|
||||
FALSE);
|
||||
my_close(create_file,MYF(0));
|
||||
@@ -889,7 +889,7 @@ int ha_archive::write_row(byte *buf)
|
||||
else
|
||||
{
|
||||
if (temp_auto > share->auto_increment_value)
|
||||
auto_increment_value= share->auto_increment_value= temp_auto;
|
||||
stats.auto_increment_value= share->auto_increment_value= temp_auto;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -912,9 +912,13 @@ error:
|
||||
}
|
||||
|
||||
|
||||
ulonglong ha_archive::get_auto_increment()
|
||||
void ha_archive::get_auto_increment(ulonglong offset, ulonglong increment,
|
||||
ulonglong nb_desired_values,
|
||||
ulonglong *first_value,
|
||||
ulonglong *nb_reserved_values)
|
||||
{
|
||||
return share->auto_increment_value + 1;
|
||||
*nb_reserved_values= 1;
|
||||
*first_value= share->auto_increment_value + 1;
|
||||
}
|
||||
|
||||
/* Initialized at each key walk (called multiple times unlike rnd_init()) */
|
||||
@@ -1024,7 +1028,7 @@ int ha_archive::rnd_init(bool scan)
|
||||
{
|
||||
scan_rows= share->rows_recorded;
|
||||
DBUG_PRINT("info", ("archive will retrieve %llu rows", scan_rows));
|
||||
records= 0;
|
||||
stats.records= 0;
|
||||
|
||||
/*
|
||||
If dirty, we lock, and then reset/flush the data.
|
||||
@@ -1061,6 +1065,7 @@ int ha_archive::get_row(azio_stream *file_to_read, byte *buf)
|
||||
uint *ptr, *end;
|
||||
char *last;
|
||||
size_t total_blob_length= 0;
|
||||
MY_BITMAP *read_set= table->read_set;
|
||||
DBUG_ENTER("ha_archive::get_row");
|
||||
|
||||
read= azread(file_to_read, buf, table->s->reclength);
|
||||
@@ -1086,8 +1091,9 @@ int ha_archive::get_row(azio_stream *file_to_read, byte *buf)
|
||||
ptr != end ;
|
||||
ptr++)
|
||||
{
|
||||
if (ha_get_bit_in_read_set(((Field_blob*) table->field[*ptr])->fieldnr))
|
||||
total_blob_length += ((Field_blob*) table->field[*ptr])->get_length();
|
||||
if (bitmap_is_set(read_set,
|
||||
(((Field_blob*) table->field[*ptr])->field_index)))
|
||||
total_blob_length += ((Field_blob*) table->field[*ptr])->get_length();
|
||||
}
|
||||
|
||||
/* Adjust our row buffer if we need be */
|
||||
@@ -1102,7 +1108,8 @@ int ha_archive::get_row(azio_stream *file_to_read, byte *buf)
|
||||
size_t size= ((Field_blob*) table->field[*ptr])->get_length();
|
||||
if (size)
|
||||
{
|
||||
if (ha_get_bit_in_read_set(((Field_blob*) table->field[*ptr])->fieldnr))
|
||||
if (bitmap_is_set(read_set,
|
||||
((Field_blob*) table->field[*ptr])->field_index))
|
||||
{
|
||||
read= azread(file_to_read, last, size);
|
||||
if ((size_t) read != size)
|
||||
@@ -1143,7 +1150,7 @@ int ha_archive::rnd_next(byte *buf)
|
||||
|
||||
|
||||
if (rc != HA_ERR_END_OF_FILE)
|
||||
records++;
|
||||
stats.records++;
|
||||
|
||||
DBUG_RETURN(rc);
|
||||
}
|
||||
@@ -1264,7 +1271,7 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt)
|
||||
if (!rc)
|
||||
{
|
||||
share->rows_recorded= 0;
|
||||
auto_increment_value= share->auto_increment_value= 0;
|
||||
stats.auto_increment_value= share->auto_increment_value= 0;
|
||||
while (!(rc= get_row(&archive, buf)))
|
||||
{
|
||||
real_write_row(buf, &writer);
|
||||
@@ -1274,7 +1281,7 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt)
|
||||
ulonglong auto_value=
|
||||
(ulonglong) field->val_int((char*)(buf + field->offset()));
|
||||
if (share->auto_increment_value < auto_value)
|
||||
auto_increment_value= share->auto_increment_value=
|
||||
stats.auto_increment_value= share->auto_increment_value=
|
||||
auto_value;
|
||||
}
|
||||
share->rows_recorded++;
|
||||
@@ -1389,7 +1396,7 @@ void ha_archive::update_create_info(HA_CREATE_INFO *create_info)
|
||||
ha_archive::info(HA_STATUS_AUTO | HA_STATUS_CONST);
|
||||
if (!(create_info->used_fields & HA_CREATE_USED_AUTO))
|
||||
{
|
||||
create_info->auto_increment_value= auto_increment_value;
|
||||
create_info->auto_increment_value= stats.auto_increment_value;
|
||||
}
|
||||
if (*share->real_path)
|
||||
create_info->data_file_name= share->real_path;
|
||||
@@ -1406,8 +1413,8 @@ void ha_archive::info(uint flag)
|
||||
This should be an accurate number now, though bulk and delayed inserts can
|
||||
cause the number to be inaccurate.
|
||||
*/
|
||||
records= share->rows_recorded;
|
||||
deleted= 0;
|
||||
stats.records= share->rows_recorded;
|
||||
stats.deleted= 0;
|
||||
/* Costs quite a bit more to get all information */
|
||||
if (flag & HA_STATUS_TIME)
|
||||
{
|
||||
@@ -1415,17 +1422,17 @@ void ha_archive::info(uint flag)
|
||||
|
||||
VOID(my_stat(share->data_file_name, &file_stat, MYF(MY_WME)));
|
||||
|
||||
mean_rec_length= table->s->reclength + buffer.alloced_length();
|
||||
data_file_length= file_stat.st_size;
|
||||
create_time= file_stat.st_ctime;
|
||||
update_time= file_stat.st_mtime;
|
||||
max_data_file_length= share->rows_recorded * mean_rec_length;
|
||||
stats.mean_rec_length= table->s->reclength + buffer.alloced_length();
|
||||
stats.data_file_length= file_stat.st_size;
|
||||
stats.create_time= file_stat.st_ctime;
|
||||
stats.update_time= file_stat.st_mtime;
|
||||
stats.max_data_file_length= share->rows_recorded * stats.mean_rec_length;
|
||||
}
|
||||
delete_length= 0;
|
||||
index_file_length=0;
|
||||
stats.delete_length= 0;
|
||||
stats.index_file_length=0;
|
||||
|
||||
if (flag & HA_STATUS_AUTO)
|
||||
auto_increment_value= share->auto_increment_value;
|
||||
stats.auto_increment_value= share->auto_increment_value;
|
||||
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
@@ -1554,6 +1561,7 @@ mysql_declare_plugin(archive)
|
||||
archive_db_init, /* Plugin Init */
|
||||
archive_db_done, /* Plugin Deinit */
|
||||
0x0100 /* 1.0 */,
|
||||
0
|
||||
}
|
||||
mysql_declare_plugin_end;
|
||||
|
||||
|
@@ -74,16 +74,19 @@ public:
|
||||
const char *table_type() const { return "ARCHIVE"; }
|
||||
const char *index_type(uint inx) { return "NONE"; }
|
||||
const char **bas_ext() const;
|
||||
ulong table_flags() const
|
||||
ulonglong table_flags() const
|
||||
{
|
||||
return (HA_REC_NOT_IN_SEQ | HA_NOT_EXACT_COUNT | HA_CAN_BIT_FIELD |
|
||||
return (HA_NO_TRANSACTIONS | HA_REC_NOT_IN_SEQ | HA_CAN_BIT_FIELD |
|
||||
HA_FILE_BASED | HA_CAN_INSERT_DELAYED | HA_CAN_GEOMETRY);
|
||||
}
|
||||
ulong index_flags(uint idx, uint part, bool all_parts) const
|
||||
{
|
||||
return HA_ONLY_WHOLE_INDEX;
|
||||
}
|
||||
ulonglong get_auto_increment();
|
||||
virtual void get_auto_increment(ulonglong offset, ulonglong increment,
|
||||
ulonglong nb_desired_values,
|
||||
ulonglong *first_value,
|
||||
ulonglong *nb_reserved_values);
|
||||
uint max_supported_keys() const { return 1; }
|
||||
uint max_supported_key_length() const { return sizeof(ulonglong); }
|
||||
uint max_supported_key_part_length() const { return sizeof(ulonglong); }
|
||||
|
@@ -25,10 +25,10 @@
|
||||
/* Static declarations for handlerton */
|
||||
|
||||
handlerton blackhole_hton;
|
||||
|
||||
static handler *blackhole_create_handler(TABLE_SHARE *table)
|
||||
static handler *blackhole_create_handler(TABLE_SHARE *table,
|
||||
MEM_ROOT *mem_root)
|
||||
{
|
||||
return new ha_blackhole(table);
|
||||
return new (mem_root) ha_blackhole(table);
|
||||
}
|
||||
|
||||
|
||||
@@ -123,16 +123,9 @@ void ha_blackhole::info(uint flag)
|
||||
{
|
||||
DBUG_ENTER("ha_blackhole::info");
|
||||
|
||||
records= 0;
|
||||
deleted= 0;
|
||||
errkey= 0;
|
||||
mean_rec_length= 0;
|
||||
data_file_length= 0;
|
||||
index_file_length= 0;
|
||||
max_data_file_length= 0;
|
||||
delete_length= 0;
|
||||
bzero((char*) &stats, sizeof(stats));
|
||||
if (flag & HA_STATUS_AUTO)
|
||||
auto_increment_value= 1;
|
||||
stats.auto_increment_value= 1;
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
@@ -230,5 +223,6 @@ mysql_declare_plugin(blackhole)
|
||||
blackhole_init, /* Plugin Init */
|
||||
NULL, /* Plugin Deinit */
|
||||
0x0100 /* 1.0 */,
|
||||
0
|
||||
}
|
||||
mysql_declare_plugin_end;
|
||||
|
@@ -40,12 +40,11 @@ public:
|
||||
*/
|
||||
const char *index_type(uint key_number);
|
||||
const char **bas_ext() const;
|
||||
ulong table_flags() const
|
||||
ulonglong table_flags() const
|
||||
{
|
||||
return(HA_NULL_IN_KEY | HA_CAN_FULLTEXT | HA_CAN_SQL_HANDLER |
|
||||
HA_DUPP_POS | HA_CAN_INDEX_BLOBS | HA_AUTO_PART_KEY |
|
||||
HA_FILE_BASED | HA_CAN_GEOMETRY | HA_READ_RND_SAME |
|
||||
HA_CAN_INSERT_DELAYED);
|
||||
HA_CAN_INDEX_BLOBS | HA_AUTO_PART_KEY |
|
||||
HA_FILE_BASED | HA_CAN_GEOMETRY | HA_CAN_INSERT_DELAYED);
|
||||
}
|
||||
ulong index_flags(uint inx, uint part, bool all_parts) const
|
||||
{
|
||||
@@ -84,5 +83,4 @@ public:
|
||||
THR_LOCK_DATA **store_lock(THD *thd,
|
||||
THR_LOCK_DATA **to,
|
||||
enum thr_lock_type lock_type);
|
||||
bool has_transactions() { return 1; }
|
||||
};
|
||||
|
@@ -74,7 +74,7 @@ static int write_meta_file(File meta_file, ha_rows rows, bool dirty);
|
||||
pthread_mutex_t tina_mutex;
|
||||
static HASH tina_open_tables;
|
||||
static int tina_init= 0;
|
||||
static handler *tina_create_handler(TABLE_SHARE *table);
|
||||
static handler *tina_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root);
|
||||
static int tina_init_func();
|
||||
|
||||
handlerton tina_hton;
|
||||
@@ -465,9 +465,9 @@ byte * find_eoln(byte *data, off_t begin, off_t end, int *eoln_len)
|
||||
}
|
||||
|
||||
|
||||
static handler *tina_create_handler(TABLE_SHARE *table)
|
||||
static handler *tina_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root)
|
||||
{
|
||||
return new ha_tina(table);
|
||||
return new (mem_root) ha_tina(table);
|
||||
}
|
||||
|
||||
|
||||
@@ -494,8 +494,10 @@ ha_tina::ha_tina(TABLE_SHARE *table_arg)
|
||||
int ha_tina::encode_quote(byte *buf)
|
||||
{
|
||||
char attribute_buffer[1024];
|
||||
String attribute(attribute_buffer, sizeof(attribute_buffer), &my_charset_bin);
|
||||
String attribute(attribute_buffer, sizeof(attribute_buffer),
|
||||
&my_charset_bin);
|
||||
|
||||
my_bitmap_map *org_bitmap= dbug_tmp_use_all_columns(table, table->read_set);
|
||||
buffer.length(0);
|
||||
for (Field **field=table->field ; *field ; field++)
|
||||
{
|
||||
@@ -556,6 +558,7 @@ int ha_tina::encode_quote(byte *buf)
|
||||
buffer.append('\n');
|
||||
//buffer.replace(buffer.length(), 0, "\n", 1);
|
||||
|
||||
dbug_tmp_restore_column_map(table->read_set, org_bitmap);
|
||||
return (buffer.length());
|
||||
}
|
||||
|
||||
@@ -609,6 +612,7 @@ int ha_tina::find_current_row(byte *buf)
|
||||
byte *mapped_ptr;
|
||||
byte *end_ptr;
|
||||
int eoln_len;
|
||||
my_bitmap_map *org_bitmap;
|
||||
DBUG_ENTER("ha_tina::find_current_row");
|
||||
|
||||
mapped_ptr= (byte *)share->mapped_file + current_position;
|
||||
@@ -621,13 +625,19 @@ int ha_tina::find_current_row(byte *buf)
|
||||
local_saved_data_file_length, &eoln_len)) == 0)
|
||||
DBUG_RETURN(HA_ERR_END_OF_FILE);
|
||||
|
||||
/* Avoid asserts in ::store() for columns that are not going to be updated */
|
||||
org_bitmap= dbug_tmp_use_all_columns(table, table->write_set);
|
||||
|
||||
for (Field **field=table->field ; *field ; field++)
|
||||
{
|
||||
buffer.length(0);
|
||||
if (*mapped_ptr == '"')
|
||||
mapped_ptr++; // Increment past the first quote
|
||||
else
|
||||
{
|
||||
dbug_tmp_restore_column_map(table->write_set, org_bitmap);
|
||||
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
|
||||
}
|
||||
for(;mapped_ptr != end_ptr; mapped_ptr++)
|
||||
{
|
||||
// Need to convert line feeds!
|
||||
@@ -660,15 +670,20 @@ int ha_tina::find_current_row(byte *buf)
|
||||
we are working with a damaged file.
|
||||
*/
|
||||
if (mapped_ptr == end_ptr -1)
|
||||
{
|
||||
dbug_tmp_restore_column_map(table->write_set, org_bitmap);
|
||||
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
|
||||
}
|
||||
buffer.append(*mapped_ptr);
|
||||
}
|
||||
}
|
||||
(*field)->store(buffer.ptr(), buffer.length(), system_charset_info);
|
||||
if (bitmap_is_set(table->read_set, (*field)->field_index))
|
||||
(*field)->store(buffer.ptr(), buffer.length(), system_charset_info);
|
||||
}
|
||||
next_position= (end_ptr - share->mapped_file)+eoln_len;
|
||||
/* Maybe use \N for null? */
|
||||
memset(buf, 0, table->s->null_bytes); /* We do not implement nulls! */
|
||||
dbug_tmp_restore_column_map(table->write_set, org_bitmap);
|
||||
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
@@ -886,7 +901,7 @@ int ha_tina::write_row(byte * buf)
|
||||
update_status();
|
||||
pthread_mutex_unlock(&share->mutex);
|
||||
|
||||
records++;
|
||||
stats.records++;
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
@@ -945,7 +960,7 @@ int ha_tina::delete_row(const byte * buf)
|
||||
if (chain_append())
|
||||
DBUG_RETURN(-1);
|
||||
|
||||
--records;
|
||||
stats.records--;
|
||||
|
||||
/* DELETE should never happen on the log table */
|
||||
DBUG_ASSERT(!share->is_log_table);
|
||||
@@ -993,7 +1008,7 @@ int ha_tina::rnd_init(bool scan)
|
||||
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
|
||||
|
||||
current_position= next_position= 0;
|
||||
records= 0;
|
||||
stats.records= 0;
|
||||
records_is_known= 0;
|
||||
chain_ptr= chain;
|
||||
#ifdef HAVE_MADVISE
|
||||
@@ -1035,7 +1050,7 @@ int ha_tina::rnd_next(byte *buf)
|
||||
if ((rc= find_current_row(buf)))
|
||||
DBUG_RETURN(rc);
|
||||
|
||||
records++;
|
||||
stats.records++;
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
@@ -1078,8 +1093,8 @@ void ha_tina::info(uint flag)
|
||||
{
|
||||
DBUG_ENTER("ha_tina::info");
|
||||
/* This is a lie, but you don't want the optimizer to see zero or 1 */
|
||||
if (!records_is_known && records < 2)
|
||||
records= 2;
|
||||
if (!records_is_known && stats.records < 2)
|
||||
stats.records= 2;
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
@@ -1192,6 +1207,8 @@ int ha_tina::repair(THD* thd, HA_CHECK_OPT* check_opt)
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* Don't assert in field::val() functions */
|
||||
table->use_all_columns();
|
||||
if (!(buf= (byte*) my_malloc(table->s->reclength, MYF(MY_WME))))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
|
||||
@@ -1295,7 +1312,7 @@ int ha_tina::delete_all_rows()
|
||||
if (get_mmap(share, 0) > 0)
|
||||
DBUG_RETURN(-1);
|
||||
|
||||
records=0;
|
||||
stats.records=0;
|
||||
DBUG_RETURN(rc);
|
||||
}
|
||||
|
||||
@@ -1402,6 +1419,7 @@ mysql_declare_plugin(csv)
|
||||
tina_init_func, /* Plugin Init */
|
||||
tina_done_func, /* Plugin Deinit */
|
||||
0x0100 /* 1.0 */,
|
||||
0
|
||||
}
|
||||
mysql_declare_plugin_end;
|
||||
|
||||
|
@@ -87,14 +87,16 @@ public:
|
||||
const char *table_type() const { return "CSV"; }
|
||||
const char *index_type(uint inx) { return "NONE"; }
|
||||
const char **bas_ext() const;
|
||||
ulong table_flags() const
|
||||
ulonglong table_flags() const
|
||||
{
|
||||
return (HA_REC_NOT_IN_SEQ | HA_NOT_EXACT_COUNT |
|
||||
HA_NO_AUTO_INCREMENT );
|
||||
return (HA_NO_TRANSACTIONS | HA_REC_NOT_IN_SEQ | HA_NO_AUTO_INCREMENT);
|
||||
}
|
||||
ulong index_flags(uint idx, uint part, bool all_parts) const
|
||||
{
|
||||
/* We will never have indexes so this will never be called(AKA we return zero) */
|
||||
/*
|
||||
We will never have indexes so this will never be called(AKA we return
|
||||
zero)
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
uint max_record_length() const { return HA_MAX_REC_LENGTH; }
|
||||
@@ -104,7 +106,7 @@ public:
|
||||
/*
|
||||
Called in test_quick_select to determine if indexes should be used.
|
||||
*/
|
||||
virtual double scan_time() { return (double) (records+deleted) / 20.0+10; }
|
||||
virtual double scan_time() { return (double) (stats.records+stats.deleted) / 20.0+10; }
|
||||
/* The next method will never be called */
|
||||
virtual bool fast_key_read() { return 1;}
|
||||
/*
|
||||
|
@@ -72,7 +72,7 @@
|
||||
|
||||
#include <mysql/plugin.h>
|
||||
|
||||
static handler* example_create_handler(TABLE_SHARE *table);
|
||||
static handler *example_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root);
|
||||
static int example_init_func();
|
||||
static bool example_init_func_for_handlerton();
|
||||
static int example_panic(enum ha_panic_function flag);
|
||||
@@ -199,9 +199,9 @@ static int free_share(EXAMPLE_SHARE *share)
|
||||
}
|
||||
|
||||
|
||||
static handler* example_create_handler(TABLE_SHARE *table)
|
||||
static handler* example_create_handler(TABLE_SHARE *table, MEM_ROOT *mem_root)
|
||||
{
|
||||
return new ha_example(table);
|
||||
return new (mem_root) ha_example(table);
|
||||
}
|
||||
|
||||
|
||||
@@ -714,6 +714,7 @@ mysql_declare_plugin(example)
|
||||
example_init_func, /* Plugin Init */
|
||||
example_done_func, /* Plugin Deinit */
|
||||
0x0001 /* 0.1 */,
|
||||
0
|
||||
}
|
||||
mysql_declare_plugin_end;
|
||||
|
||||
|
@@ -62,7 +62,7 @@ public:
|
||||
implements. The current table flags are documented in
|
||||
handler.h
|
||||
*/
|
||||
ulong table_flags() const
|
||||
ulonglong table_flags() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public:
|
||||
/*
|
||||
Called in test_quick_select to determine if indexes should be used.
|
||||
*/
|
||||
virtual double scan_time() { return (double) (records+deleted) / 20.0+10; }
|
||||
virtual double scan_time() { return (double) (stats.records+stats.deleted) / 20.0+10; }
|
||||
/*
|
||||
The next method will never be called if you do not implement indexes.
|
||||
*/
|
||||
|
@@ -32,13 +32,8 @@ int heap_extra(register HP_INFO *info, enum ha_extra_function function)
|
||||
DBUG_ENTER("heap_extra");
|
||||
|
||||
switch (function) {
|
||||
case HA_EXTRA_RESET:
|
||||
case HA_EXTRA_RESET_STATE:
|
||||
info->lastinx= -1;
|
||||
info->current_record= (ulong) ~0L;
|
||||
info->current_hash_ptr=0;
|
||||
info->update=0;
|
||||
break;
|
||||
heap_reset(info);
|
||||
case HA_EXTRA_NO_READCHECK:
|
||||
info->opt_flag&= ~READ_CHECK_USED; /* No readcheck */
|
||||
break;
|
||||
@@ -56,6 +51,16 @@ int heap_extra(register HP_INFO *info, enum ha_extra_function function)
|
||||
} /* heap_extra */
|
||||
|
||||
|
||||
int heap_reset(HP_INFO *info)
|
||||
{
|
||||
info->lastinx= -1;
|
||||
info->current_record= (ulong) ~0L;
|
||||
info->current_hash_ptr=0;
|
||||
info->update=0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Start/Stop Inserting Duplicates Into a Table, WL#1648.
|
||||
*/
|
||||
|
@@ -469,7 +469,7 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
|
||||
printf("- Read through all records with scan\n");
|
||||
if (heap_extra(file,HA_EXTRA_RESET) || heap_extra(file,HA_EXTRA_CACHE))
|
||||
if (heap_reset(file) || heap_extra(file,HA_EXTRA_CACHE))
|
||||
{
|
||||
puts("got error from heap_extra");
|
||||
goto end;
|
||||
|
@@ -603,8 +603,9 @@ static int ftb_phrase_add_word(MYSQL_FTPARSER_PARAM *param,
|
||||
{
|
||||
FT_WORD *phrase_word= (FT_WORD *)phrase->data;
|
||||
FT_WORD *document_word= (FT_WORD *)document->data;
|
||||
if (my_strnncoll(phrase_param->cs, phrase_word->pos, phrase_word->len,
|
||||
document_word->pos, document_word->len))
|
||||
if (my_strnncoll(phrase_param->cs, (uchar*) phrase_word->pos,
|
||||
phrase_word->len,
|
||||
(uchar*) document_word->pos, document_word->len))
|
||||
return 0;
|
||||
}
|
||||
phrase_param->match++;
|
||||
|
@@ -47,29 +47,6 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg)
|
||||
DBUG_PRINT("enter",("function: %d",(int) function));
|
||||
|
||||
switch (function) {
|
||||
case HA_EXTRA_RESET:
|
||||
/*
|
||||
Free buffers and reset the following flags:
|
||||
EXTRA_CACHE, EXTRA_WRITE_CACHE, EXTRA_KEYREAD, EXTRA_QUICK
|
||||
|
||||
If the row buffer cache is large (for dynamic tables), reduce it
|
||||
to save memory.
|
||||
*/
|
||||
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 (share->base.blobs)
|
||||
mi_alloc_rec_buff(info, -1, &info->rec_buff);
|
||||
#if defined(HAVE_MMAP) && defined(HAVE_MADVISE)
|
||||
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;
|
||||
@@ -425,3 +402,36 @@ static void mi_extra_keyflag(MI_INFO *info, enum ha_extra_function function)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int mi_reset(MI_INFO *info)
|
||||
{
|
||||
int error= 0;
|
||||
MYISAM_SHARE *share=info->s;
|
||||
DBUG_ENTER("mi_reset");
|
||||
/*
|
||||
Free buffers and reset the following flags:
|
||||
EXTRA_CACHE, EXTRA_WRITE_CACHE, EXTRA_KEYREAD, EXTRA_QUICK
|
||||
|
||||
If the row buffer cache is large (for dynamic tables), reduce it
|
||||
to save memory.
|
||||
*/
|
||||
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 (share->base.blobs)
|
||||
mi_alloc_rec_buff(info, -1, &info->rec_buff);
|
||||
#if defined(HAVE_MMAP) && defined(HAVE_MADVISE)
|
||||
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;
|
||||
info->lastinx= 0; /* Use first index as def */
|
||||
info->last_search_keypage= info->lastpos= HA_OFFSET_ERROR;
|
||||
info->page_changed= 1;
|
||||
info->update= ((info->update & HA_STATE_CHANGED) | HA_STATE_NEXT_FOUND |
|
||||
HA_STATE_PREV_FOUND);
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
@@ -259,15 +259,16 @@ int _mi_seq_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page,
|
||||
{
|
||||
mi_print_error(info->s, HA_ERR_CRASHED);
|
||||
my_errno=HA_ERR_CRASHED;
|
||||
DBUG_PRINT("error",("Found wrong key: length: %u page: %lx end: %lx",
|
||||
length, (long) page, (long) end));
|
||||
DBUG_PRINT("error",
|
||||
("Found wrong key: length: %u page: 0x%lx end: 0x%lx",
|
||||
length, (long) page, (long) end));
|
||||
DBUG_RETURN(MI_FOUND_WRONG_KEY);
|
||||
}
|
||||
if ((flag=ha_key_cmp(keyinfo->seg,t_buff,key,key_len,comp_flag,
|
||||
not_used)) >= 0)
|
||||
break;
|
||||
#ifdef EXTRA_DEBUG
|
||||
DBUG_PRINT("loop",("page: %lx key: '%s' flag: %d", (long) page, t_buff,
|
||||
DBUG_PRINT("loop",("page: 0x%lx key: '%s' flag: %d", (long) page, t_buff,
|
||||
flag));
|
||||
#endif
|
||||
memcpy(buff,t_buff,length);
|
||||
@@ -276,7 +277,7 @@ int _mi_seq_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page,
|
||||
if (flag == 0)
|
||||
memcpy(buff,t_buff,length); /* Result is first key */
|
||||
*last_key= page == end;
|
||||
DBUG_PRINT("exit",("flag: %d ret_pos: %lx", flag, (long) *ret_pos));
|
||||
DBUG_PRINT("exit",("flag: %d ret_pos: 0x%lx", flag, (long) *ret_pos));
|
||||
DBUG_RETURN(flag);
|
||||
} /* _mi_seq_search */
|
||||
|
||||
@@ -416,8 +417,9 @@ int _mi_prefix_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page,
|
||||
{
|
||||
mi_print_error(info->s, HA_ERR_CRASHED);
|
||||
my_errno=HA_ERR_CRASHED;
|
||||
DBUG_PRINT("error",("Found wrong key: length: %u page: %lx end: %lx",
|
||||
length, (long) page, (long) end));
|
||||
DBUG_PRINT("error",
|
||||
("Found wrong key: length: %u page: 0x%lx end: %lx",
|
||||
length, (long) page, (long) end));
|
||||
DBUG_RETURN(MI_FOUND_WRONG_KEY);
|
||||
}
|
||||
|
||||
@@ -551,7 +553,7 @@ int _mi_prefix_search(MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *page,
|
||||
|
||||
*last_key= page == end;
|
||||
|
||||
DBUG_PRINT("exit",("flag: %d ret_pos: %lx", flag, (long) *ret_pos));
|
||||
DBUG_PRINT("exit",("flag: %d ret_pos: 0x%lx", flag, (long) *ret_pos));
|
||||
DBUG_RETURN(flag);
|
||||
} /* _mi_prefix_search */
|
||||
|
||||
@@ -813,7 +815,7 @@ uint _mi_get_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag,
|
||||
if (length > keyseg->length)
|
||||
{
|
||||
DBUG_PRINT("error",
|
||||
("Found too long null packed key: %u of %u at %lx",
|
||||
("Found too long null packed key: %u of %u at 0x%lx",
|
||||
length, keyseg->length, (long) *page_pos));
|
||||
DBUG_DUMP("key",(char*) *page_pos,16);
|
||||
mi_print_error(keyinfo->share, HA_ERR_CRASHED);
|
||||
@@ -870,7 +872,7 @@ uint _mi_get_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag,
|
||||
}
|
||||
if (length > (uint) keyseg->length)
|
||||
{
|
||||
DBUG_PRINT("error",("Found too long packed key: %u of %u at %lx",
|
||||
DBUG_PRINT("error",("Found too long packed key: %u of %u at 0x%lx",
|
||||
length, keyseg->length, (long) *page_pos));
|
||||
DBUG_DUMP("key",(char*) *page_pos,16);
|
||||
mi_print_error(keyinfo->share, HA_ERR_CRASHED);
|
||||
@@ -936,8 +938,9 @@ uint _mi_get_binary_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag,
|
||||
{
|
||||
if (length > keyinfo->maxlength)
|
||||
{
|
||||
DBUG_PRINT("error",("Found too long binary packed key: %u of %u at %lx",
|
||||
length, keyinfo->maxlength, (long) *page_pos));
|
||||
DBUG_PRINT("error",
|
||||
("Found too long binary packed key: %u of %u at 0x%lx",
|
||||
length, keyinfo->maxlength, (long) *page_pos));
|
||||
DBUG_DUMP("key",(char*) *page_pos,16);
|
||||
mi_print_error(keyinfo->share, HA_ERR_CRASHED);
|
||||
my_errno=HA_ERR_CRASHED;
|
||||
@@ -984,7 +987,7 @@ uint _mi_get_binary_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag,
|
||||
length-=tmp;
|
||||
from=page; from_end=page_end;
|
||||
}
|
||||
DBUG_PRINT("info",("key: %lx from: %lx length: %u",
|
||||
DBUG_PRINT("info",("key: 0x%lx from: 0x%lx length: %u",
|
||||
(long) key, (long) from, length));
|
||||
memmove((byte*) key, (byte*) from, (size_t) length);
|
||||
key+=length;
|
||||
@@ -1042,7 +1045,7 @@ uchar *_mi_get_key(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *page,
|
||||
}
|
||||
}
|
||||
}
|
||||
DBUG_PRINT("exit",("page: %lx length: %u", (long) page,
|
||||
DBUG_PRINT("exit",("page: 0x%lx length: %u", (long) page,
|
||||
*return_key_length));
|
||||
DBUG_RETURN(page);
|
||||
} /* _mi_get_key */
|
||||
@@ -1095,7 +1098,8 @@ uchar *_mi_get_last_key(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *page,
|
||||
uint nod_flag;
|
||||
uchar *lastpos;
|
||||
DBUG_ENTER("_mi_get_last_key");
|
||||
DBUG_PRINT("enter",("page: %lx endpos: %lx", (long) page, (long) endpos));
|
||||
DBUG_PRINT("enter",("page: 0x%lx endpos: 0x%lx", (long) page,
|
||||
(long) endpos));
|
||||
|
||||
nod_flag=mi_test_if_nod(page);
|
||||
if (! (keyinfo->flag & (HA_VAR_LENGTH_KEY | HA_BINARY_PACK_KEY)))
|
||||
@@ -1115,7 +1119,7 @@ uchar *_mi_get_last_key(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *page,
|
||||
*return_key_length=(*keyinfo->get_key)(keyinfo,nod_flag,&page,lastkey);
|
||||
if (*return_key_length == 0)
|
||||
{
|
||||
DBUG_PRINT("error",("Couldn't find last key: page: %lx",
|
||||
DBUG_PRINT("error",("Couldn't find last key: page: 0x%lx",
|
||||
(long) page));
|
||||
mi_print_error(info->s, HA_ERR_CRASHED);
|
||||
my_errno=HA_ERR_CRASHED;
|
||||
@@ -1123,7 +1127,7 @@ uchar *_mi_get_last_key(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *page,
|
||||
}
|
||||
}
|
||||
}
|
||||
DBUG_PRINT("exit",("lastpos: %lx length: %u", (long) lastpos,
|
||||
DBUG_PRINT("exit",("lastpos: 0x%lx length: %u", (long) lastpos,
|
||||
*return_key_length));
|
||||
DBUG_RETURN(lastpos);
|
||||
} /* _mi_get_last_key */
|
||||
@@ -1660,7 +1664,7 @@ _mi_calc_var_pack_key_length(MI_KEYDEF *keyinfo,uint nod_flag,uchar *next_key,
|
||||
ref_length=0;
|
||||
next_length_pack=0;
|
||||
}
|
||||
DBUG_PRINT("test",("length: %d next_key: %lx", length,
|
||||
DBUG_PRINT("test",("length: %d next_key: 0x%lx", length,
|
||||
(long) next_key));
|
||||
|
||||
{
|
||||
|
@@ -708,7 +708,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (!silent)
|
||||
printf("- mi_extra(CACHE) + mi_rrnd.... + mi_extra(NO_CACHE)\n");
|
||||
if (mi_extra(file,HA_EXTRA_RESET,0) || mi_extra(file,HA_EXTRA_CACHE,0))
|
||||
if (mi_reset(file) || mi_extra(file,HA_EXTRA_CACHE,0))
|
||||
{
|
||||
if (locking || (!use_blob && !pack_fields))
|
||||
{
|
||||
@@ -751,7 +751,7 @@ int main(int argc, char *argv[])
|
||||
DBUG_PRINT("progpos",("Removing keys"));
|
||||
lastpos = HA_OFFSET_ERROR;
|
||||
/* DBUG_POP(); */
|
||||
mi_extra(file,HA_EXTRA_RESET,0);
|
||||
mi_reset(file);
|
||||
found_parts=0;
|
||||
while ((error=mi_rrnd(file,read_record,HA_OFFSET_ERROR)) !=
|
||||
HA_ERR_END_OF_FILE)
|
||||
|
@@ -3033,7 +3033,7 @@ static int mrg_rrnd(PACK_MRG_INFO *info,byte *buf)
|
||||
{
|
||||
isam_info= *(info->current=info->file);
|
||||
info->end=info->current+info->count;
|
||||
mi_extra(isam_info, HA_EXTRA_RESET, 0);
|
||||
mi_reset(isam_info);
|
||||
mi_extra(isam_info, HA_EXTRA_CACHE, 0);
|
||||
filepos=isam_info->s->pack.header_length;
|
||||
}
|
||||
@@ -3056,7 +3056,7 @@ static int mrg_rrnd(PACK_MRG_INFO *info,byte *buf)
|
||||
info->current++;
|
||||
isam_info= *info->current;
|
||||
filepos=isam_info->s->pack.header_length;
|
||||
mi_extra(isam_info,HA_EXTRA_RESET, 0);
|
||||
mi_reset(isam_info);
|
||||
mi_extra(isam_info,HA_EXTRA_CACHE, 0);
|
||||
}
|
||||
}
|
||||
|
@@ -38,10 +38,10 @@ int myrg_extra(MYRG_INFO *info,enum ha_extra_function function,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (function == HA_EXTRA_NO_CACHE || function == HA_EXTRA_RESET ||
|
||||
function == HA_EXTRA_PREPARE_FOR_UPDATE)
|
||||
if (function == HA_EXTRA_NO_CACHE ||
|
||||
function == HA_EXTRA_PREPARE_FOR_UPDATE)
|
||||
info->cache_in_use=0;
|
||||
if (function == HA_EXTRA_RESET || function == HA_EXTRA_RESET_STATE)
|
||||
if (function == HA_EXTRA_RESET_STATE)
|
||||
{
|
||||
info->current_table=0;
|
||||
info->last_used_table=info->open_tables;
|
||||
@@ -66,3 +66,23 @@ void myrg_extrafunc(MYRG_INFO *info, invalidator_by_filename inv)
|
||||
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
||||
int myrg_reset(MYRG_INFO *info)
|
||||
{
|
||||
int save_error= 0;
|
||||
MYRG_TABLE *file;
|
||||
DBUG_ENTER("myrg_reset");
|
||||
|
||||
info->cache_in_use=0;
|
||||
info->current_table=0;
|
||||
info->last_used_table= info->open_tables;
|
||||
|
||||
for (file=info->open_tables ; file != info->end_table ; file++)
|
||||
{
|
||||
int error;
|
||||
if ((error= mi_reset(file->table)))
|
||||
save_error=error;
|
||||
}
|
||||
DBUG_RETURN(save_error);
|
||||
}
|
||||
|
@@ -1478,6 +1478,7 @@ public:
|
||||
* @return 0 or -1 on error, and tupleId in out parameter
|
||||
*/
|
||||
struct TupleIdRange {
|
||||
TupleIdRange() {}
|
||||
Uint64 m_first_tuple_id;
|
||||
Uint64 m_last_tuple_id;
|
||||
void reset() {
|
||||
|
Reference in New Issue
Block a user