summaryrefslogtreecommitdiffstats
path: root/storage/spider/ha_spider.cc
diff options
context:
space:
mode:
Diffstat (limited to 'storage/spider/ha_spider.cc')
-rw-r--r--storage/spider/ha_spider.cc169
1 files changed, 52 insertions, 117 deletions
diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc
index c998fd18..c2fbb776 100644
--- a/storage/spider/ha_spider.cc
+++ b/storage/spider/ha_spider.cc
@@ -238,7 +238,6 @@ int ha_spider::open(
DBUG_PRINT("info",("spider this=%p", this));
dup_key_idx = (uint) -1;
- conn_kinds = SPIDER_CONN_KIND_MYSQL;
table->file->get_no_parts("", &part_num);
if (part_num)
{
@@ -310,10 +309,10 @@ int ha_spider::open(
my_bitmap_buffer_size(table->read_set));
wide_handler_alloc = TRUE;
- if (!share && !spider_get_share(name, table, thd, this, &error_num))
- goto error_get_share;
+ if (!share && !spider_get_share(name, table, thd, this, &error_num))
+ goto error_get_share;
- wide_share = share->wide_share;
+ wide_share = share->wide_share;
DBUG_PRINT("info",("spider create partition_handler"));
DBUG_PRINT("info",("spider table=%p", table));
@@ -598,22 +597,7 @@ int ha_spider::check_access_kind_for_connection(
int error_num, roop_count;
DBUG_ENTER("ha_spider::check_access_kind_for_connection");
DBUG_PRINT("info",("spider this=%p", this));
- conn_kinds = 0;
- switch (wide_handler->sql_command)
- {
- case SQLCOM_UPDATE:
- case SQLCOM_UPDATE_MULTI:
- case SQLCOM_DELETE:
- case SQLCOM_DELETE_MULTI:
- default:
- conn_kinds |= SPIDER_CONN_KIND_MYSQL;
- for (roop_count = 0; roop_count < (int) share->link_count; roop_count++)
- {
- conn_kind[roop_count] = SPIDER_CONN_KIND_MYSQL;
- }
- break;
- }
- if ((error_num = spider_check_trx_and_get_conn(thd, this, TRUE)))
+ if ((error_num= spider_check_trx_and_get_conn(thd, this)))
{
DBUG_RETURN(error_num);
}
@@ -1048,8 +1032,6 @@ int ha_spider::reset()
for (roop_count = share->link_count - 1; roop_count >= 0; roop_count--)
{
result_list.update_sqls[roop_count].length(0);
-
- conn_kind[roop_count] = SPIDER_CONN_KIND_MYSQL;
}
result_list.bulk_update_mode = 0;
result_list.bulk_update_size = 0;
@@ -1075,7 +1057,6 @@ int ha_spider::reset()
result_list.use_union = FALSE;
result_list.use_both_key = FALSE;
pt_clone_last_searcher = NULL;
- conn_kinds = SPIDER_CONN_KIND_MYSQL;
use_index_merge = FALSE;
init_rnd_handler = FALSE;
if (multi_range_keys)
@@ -3118,6 +3099,7 @@ ha_rows ha_spider::multi_range_read_info_const(
uint n_ranges,
uint *bufsz,
uint *flags,
+ ha_rows limit,
Cost_estimate *cost
)
{
@@ -3157,6 +3139,7 @@ ha_rows ha_spider::multi_range_read_info_const(
n_ranges,
bufsz,
flags,
+ limit,
cost
);
*flags &= ~HA_MRR_USE_DEFAULT_IMPL;
@@ -6443,13 +6426,6 @@ int ha_spider::info(
auto_inc_temporary = FALSE;
#endif
wide_handler->sql_command = thd_sql_command(thd);
-/*
- if (
- sql_command == SQLCOM_DROP_TABLE ||
- sql_command == SQLCOM_ALTER_TABLE ||
- sql_command == SQLCOM_SHOW_CREATE
- ) {
-*/
if (flag & HA_STATUS_AUTO)
{
if (share->lgtm_tblhnd_share->auto_increment_value)
@@ -6467,9 +6443,6 @@ int ha_spider::info(
wide_handler->sql_command == SQLCOM_ALTER_TABLE
)
DBUG_RETURN(0);
-/*
- }
-*/
if (flag &
(HA_STATUS_TIME | HA_STATUS_CONST | HA_STATUS_VARIABLE | HA_STATUS_AUTO))
@@ -6547,8 +6520,7 @@ int ha_spider::info(
pthread_mutex_lock(&share->sts_mutex);
if (difftime(tmp_time, share->sts_get_time) >= sts_interval)
{
- if ((error_num = spider_check_trx_and_get_conn(ha_thd(), this,
- FALSE)))
+ if ((error_num= spider_check_trx_and_get_conn(ha_thd(), this)))
{
pthread_mutex_unlock(&share->sts_mutex);
if (!share->sts_init)
@@ -7137,7 +7109,7 @@ int ha_spider::check_crd()
}
if (crd_mode == 3)
crd_mode = 1;
- if ((error_num = spider_check_trx_and_get_conn(ha_thd(), this, FALSE)))
+ if ((error_num= spider_check_trx_and_get_conn(ha_thd(), this)))
{
DBUG_RETURN(check_error_mode(error_num));
}
@@ -8325,7 +8297,7 @@ int ha_spider::truncate()
DBUG_RETURN(ER_SPIDER_READ_ONLY_NUM);
}
wide_handler->sql_command = SQLCOM_TRUNCATE;
- if ((error_num = spider_check_trx_and_get_conn(thd, this, FALSE)))
+ if ((error_num= spider_check_trx_and_get_conn(thd, this)))
{
DBUG_RETURN(error_num);
}
@@ -8349,38 +8321,47 @@ int ha_spider::truncate()
DBUG_RETURN(0);
}
-
-double ha_spider::scan_time()
+IO_AND_CPU_COST ha_spider::scan_time()
{
+ IO_AND_CPU_COST cost;
DBUG_ENTER("ha_spider::scan_time");
DBUG_PRINT("info",("spider this=%p", this));
- DBUG_PRINT("info",("spider scan_time = %.6f",
- share->scan_rate * share->stat.records * share->stat.mean_rec_length + 2));
- DBUG_RETURN(share->scan_rate * share->stat.records *
- share->stat.mean_rec_length + 2);
+ cost.io=0;
+ cost.cpu= (DISK_READ_COST * share->stat.records * share->stat.mean_rec_length);
+ DBUG_PRINT("info",("spider scan_time = %.6f", cost.cpu));
+ DBUG_RETURN(cost);
}
-double ha_spider::read_time(
- uint index,
- uint ranges,
- ha_rows rows
-) {
- DBUG_ENTER("ha_spider::read_time");
+IO_AND_CPU_COST ha_spider::rnd_pos_time(ha_rows rows)
+{
+ IO_AND_CPU_COST cost= { 0.0, 0.0}; // Row is in memory
+ return cost;
+}
+
+IO_AND_CPU_COST ha_spider::keyread_time(uint index, ulong ranges, ha_rows rows,
+ ulonglong blocks)
+{
+ IO_AND_CPU_COST cost;
+ DBUG_ENTER("ha_spider::keyread_time");
DBUG_PRINT("info",("spider this=%p", this));
+
+ /*
+ Here we only calculate transfer costs. The normal handler cost functions
+ will add costs for accessing a row/key.
+ */
if (wide_handler->keyread)
{
- DBUG_PRINT("info",("spider read_time(keyread) = %.6f",
- share->read_rate * table->key_info[index].key_length *
- rows / 2 + 2));
- DBUG_RETURN(share->read_rate * table->key_info[index].key_length *
- rows / 2 + 2);
+ cost.io= 0;
+ cost.cpu= DISK_READ_COST * rows * table->key_info[index].key_length;
} else {
- DBUG_PRINT("info",("spider read_time = %.6f",
- share->read_rate * share->stat.mean_rec_length * rows + 2));
- DBUG_RETURN(share->read_rate * share->stat.mean_rec_length * rows + 2);
+ cost.io= 0;
+ cost.cpu= DISK_READ_COST * rows * share->stat.mean_rec_length;
}
+ DBUG_PRINT("info",("spider scan_time(keyread) = %.6f", cost.cpu));
+ DBUG_RETURN(cost);
}
+
const key_map *ha_spider::keys_to_use_for_scanning()
{
DBUG_ENTER("ha_spider::keys_to_use_for_scanning");
@@ -8451,7 +8432,6 @@ int ha_spider::create(
SPIDER_TRX *trx;
TABLE *table_tables = NULL;
SPIDER_Open_tables_backup open_tables_backup;
- bool need_lock = FALSE;
DBUG_ENTER("ha_spider::create");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_PRINT("info",("spider name=%s", name));
@@ -8529,7 +8509,7 @@ int ha_spider::create(
if (
!(table_tables = spider_open_sys_table(
current_thd, SPIDER_SYS_TABLES_TABLE_NAME_STR,
- SPIDER_SYS_TABLES_TABLE_NAME_LEN, TRUE, &open_tables_backup, FALSE,
+ SPIDER_SYS_TABLES_TABLE_NAME_LEN, TRUE, &open_tables_backup,
&error_num))
) {
goto error;
@@ -8549,8 +8529,7 @@ int ha_spider::create(
) {
goto error;
}
- spider_close_sys_table(current_thd, table_tables,
- &open_tables_backup, FALSE);
+ spider_sys_close_table(current_thd, &open_tables_backup);
table_tables = NULL;
} else if (
sql_command == SQLCOM_ALTER_TABLE
@@ -8583,11 +8562,10 @@ int ha_spider::create(
) &&
memcmp(name + strlen(name) - 5, "#TMP#", 5)
) {
- need_lock = TRUE;
if (
!(table_tables = spider_open_sys_table(
current_thd, SPIDER_SYS_TABLES_TABLE_NAME_STR,
- SPIDER_SYS_TABLES_TABLE_NAME_LEN, TRUE, &open_tables_backup, TRUE,
+ SPIDER_SYS_TABLES_TABLE_NAME_LEN, TRUE, &open_tables_backup,
&error_num))
) {
goto error;
@@ -8597,8 +8575,7 @@ int ha_spider::create(
) {
goto error;
}
- spider_close_sys_table(current_thd, table_tables,
- &open_tables_backup, TRUE);
+ spider_sys_close_table(current_thd, &open_tables_backup);
table_tables = NULL;
}
}
@@ -8627,8 +8604,7 @@ int ha_spider::create(
error:
if (table_tables)
- spider_close_sys_table(current_thd, table_tables,
- &open_tables_backup, need_lock);
+ spider_sys_close_table(current_thd, &open_tables_backup);
if (tmp_share.lgtm_tblhnd_share)
spider_free_lgtm_tblhnd_share_alloc(tmp_share.lgtm_tblhnd_share, FALSE);
if (tmp_share.static_key_cardinality)
@@ -8700,7 +8676,6 @@ int ha_spider::rename_table(
SPIDER_ALTER_TABLE *alter_table_from, *alter_table_to;
SPIDER_LGTM_TBLHND_SHARE *from_lgtm_tblhnd_share, *to_lgtm_tblhnd_share;
SPIDER_Open_tables_backup open_tables_backup;
- bool need_lock = FALSE;
DBUG_ENTER("ha_spider::rename_table");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_PRINT("info",("spider from=%s", from));
@@ -8732,7 +8707,7 @@ int ha_spider::rename_table(
if (
!(table_tables = spider_open_sys_table(
current_thd, SPIDER_SYS_TABLES_TABLE_NAME_STR,
- SPIDER_SYS_TABLES_TABLE_NAME_LEN, TRUE, &open_tables_backup, FALSE,
+ SPIDER_SYS_TABLES_TABLE_NAME_LEN, TRUE, &open_tables_backup,
&error_num))
) {
goto error;
@@ -8743,8 +8718,7 @@ int ha_spider::rename_table(
) {
goto error;
}
- spider_close_sys_table(current_thd, table_tables,
- &open_tables_backup, FALSE);
+ spider_sys_close_table(current_thd, &open_tables_backup);
table_tables = NULL;
/* release table mon list */
@@ -8787,20 +8761,9 @@ int ha_spider::rename_table(
("spider alter_info.flags: %llu alter_info.partition_flags: %lu",
thd->lex->alter_info.flags, thd->lex->alter_info.partition_flags));
if (
- (thd->lex->alter_info.partition_flags &
- (
- SPIDER_ALTER_PARTITION_ADD | SPIDER_ALTER_PARTITION_DROP |
- SPIDER_ALTER_PARTITION_COALESCE | SPIDER_ALTER_PARTITION_REORGANIZE |
- SPIDER_ALTER_PARTITION_TABLE_REORG | SPIDER_ALTER_PARTITION_REBUILD
- )
- )
- )
- need_lock = TRUE;
-
- if (
!(table_tables = spider_open_sys_table(
current_thd, SPIDER_SYS_TABLES_TABLE_NAME_STR,
- SPIDER_SYS_TABLES_TABLE_NAME_LEN, TRUE, &open_tables_backup, need_lock,
+ SPIDER_SYS_TABLES_TABLE_NAME_LEN, TRUE, &open_tables_backup,
&error_num))
) {
goto error;
@@ -8829,8 +8792,7 @@ int ha_spider::rename_table(
goto error;
}
}
- spider_close_sys_table(current_thd, table_tables,
- &open_tables_backup, need_lock);
+ spider_sys_close_table(current_thd, &open_tables_backup);
table_tables = NULL;
if (!alter_table_from->now_create)
@@ -8888,8 +8850,7 @@ int ha_spider::rename_table(
error:
if (table_tables)
- spider_close_sys_table(current_thd, table_tables,
- &open_tables_backup, need_lock);
+ spider_sys_close_table(current_thd, &open_tables_backup);
pthread_mutex_lock(&spider_lgtm_tblhnd_share_mutex);
to_lgtm_tblhnd_share = spider_get_lgtm_tblhnd_share(
to, to_len, to_hash_value, TRUE, FALSE, &tmp_error_num);
@@ -8909,7 +8870,6 @@ int ha_spider::delete_table(
uint sql_command = thd_sql_command(thd);
SPIDER_ALTER_TABLE *alter_table;
SPIDER_Open_tables_backup open_tables_backup;
- bool need_lock = FALSE;
DBUG_ENTER("ha_spider::delete_table");
DBUG_PRINT("info",("spider this=%p", this));
DBUG_PRINT("info",("spider name=%s", name));
@@ -8956,21 +8916,9 @@ int ha_spider::delete_table(
("spider alter_info.flags: %llu alter_info.partition_flags: %lu",
thd->lex->alter_info.flags, thd->lex->alter_info.partition_flags));
if (
- sql_command == SQLCOM_ALTER_TABLE &&
- (thd->lex->alter_info.partition_flags &
- (
- SPIDER_ALTER_PARTITION_ADD | SPIDER_ALTER_PARTITION_DROP |
- SPIDER_ALTER_PARTITION_COALESCE | SPIDER_ALTER_PARTITION_REORGANIZE |
- SPIDER_ALTER_PARTITION_TABLE_REORG | SPIDER_ALTER_PARTITION_REBUILD
- )
- )
- )
- need_lock = TRUE;
-
- if (
!(table_tables = spider_open_sys_table(
current_thd, SPIDER_SYS_TABLES_TABLE_NAME_STR,
- SPIDER_SYS_TABLES_TABLE_NAME_LEN, TRUE, &open_tables_backup, need_lock,
+ SPIDER_SYS_TABLES_TABLE_NAME_LEN, TRUE, &open_tables_backup,
&error_num))
) {
goto error;
@@ -8985,8 +8933,7 @@ int ha_spider::delete_table(
error_num= HA_ERR_NO_SUCH_TABLE;
goto error;
}
- spider_close_sys_table(current_thd, table_tables,
- &open_tables_backup, need_lock);
+ spider_sys_close_table(current_thd, &open_tables_backup);
table_tables = NULL;
/* release table mon list */
@@ -9010,8 +8957,7 @@ int ha_spider::delete_table(
error:
if (table_tables)
- spider_close_sys_table(current_thd, table_tables,
- &open_tables_backup, need_lock);
+ spider_sys_close_table(current_thd, &open_tables_backup);
DBUG_RETURN(error_num);
}
@@ -11730,7 +11676,6 @@ int ha_spider::mk_bulk_tmp_table_and_bulk_start()
dbton_hdl->first_link_idx >= 0 &&
dbton_hdl->need_copy_for_update(roop_count)
) {
-#ifdef SPIDER_use_LEX_CSTRING_for_Field_blob_constructor
LEX_CSTRING field_name = {STRING_WITH_LEN("a")};
if (
!tmp_table[roop_count] &&
@@ -11739,15 +11684,6 @@ int ha_spider::mk_bulk_tmp_table_and_bulk_start()
&result_list.upd_tmp_tbl_prms[roop_count],
&field_name, result_list.update_sqls[roop_count].charset()))
)
-#else
- if (
- !tmp_table[roop_count] &&
- !(tmp_table[roop_count] = spider_mk_sys_tmp_table(
- wide_handler->trx->thd, table,
- &result_list.upd_tmp_tbl_prms[roop_count], "a",
- result_list.update_sqls[roop_count].charset()))
- )
-#endif
{
error_num = HA_ERR_OUT_OF_MEM;
goto error_2;
@@ -11903,8 +11839,7 @@ int ha_spider::append_lock_tables_list()
DBUG_PRINT("info",("spider lock_table_type=%u",
wide_handler->lock_table_type));
- if ((error_num = spider_check_trx_and_get_conn(wide_handler->trx->thd, this,
- FALSE)))
+ if ((error_num= spider_check_trx_and_get_conn(wide_handler->trx->thd, this)))
{
DBUG_RETURN(error_num);
}