mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
direct aggregate with index merge
This commit is contained in:
@@ -87,6 +87,7 @@ ha_spider::ha_spider(
|
|||||||
mrr_key_buff = NULL;
|
mrr_key_buff = NULL;
|
||||||
#endif
|
#endif
|
||||||
append_tblnm_alias = NULL;
|
append_tblnm_alias = NULL;
|
||||||
|
has_clone_for_merge = FALSE;
|
||||||
is_clone = FALSE;
|
is_clone = FALSE;
|
||||||
clone_bitmap_init = FALSE;
|
clone_bitmap_init = FALSE;
|
||||||
pt_clone_source_handler = NULL;
|
pt_clone_source_handler = NULL;
|
||||||
@@ -188,6 +189,7 @@ ha_spider::ha_spider(
|
|||||||
mrr_key_buff = NULL;
|
mrr_key_buff = NULL;
|
||||||
#endif
|
#endif
|
||||||
append_tblnm_alias = NULL;
|
append_tblnm_alias = NULL;
|
||||||
|
has_clone_for_merge = FALSE;
|
||||||
is_clone = FALSE;
|
is_clone = FALSE;
|
||||||
clone_bitmap_init = FALSE;
|
clone_bitmap_init = FALSE;
|
||||||
pt_clone_source_handler = NULL;
|
pt_clone_source_handler = NULL;
|
||||||
@@ -283,6 +285,7 @@ handler *ha_spider::clone(
|
|||||||
HA_OPEN_IGNORE_IF_LOCKED))
|
HA_OPEN_IGNORE_IF_LOCKED))
|
||||||
DBUG_RETURN(NULL);
|
DBUG_RETURN(NULL);
|
||||||
spider->sync_from_clone_source_base(this);
|
spider->sync_from_clone_source_base(this);
|
||||||
|
has_clone_for_merge = TRUE;
|
||||||
|
|
||||||
DBUG_RETURN((handler *) spider);
|
DBUG_RETURN((handler *) spider);
|
||||||
}
|
}
|
||||||
@@ -1723,6 +1726,7 @@ int ha_spider::reset()
|
|||||||
result_list.use_union = FALSE;
|
result_list.use_union = FALSE;
|
||||||
pt_clone_last_searcher = NULL;
|
pt_clone_last_searcher = NULL;
|
||||||
conn_kinds = SPIDER_CONN_KIND_MYSQL;
|
conn_kinds = SPIDER_CONN_KIND_MYSQL;
|
||||||
|
has_clone_for_merge = FALSE;
|
||||||
while (condition)
|
while (condition)
|
||||||
{
|
{
|
||||||
tmp_cond = condition->next;
|
tmp_cond = condition->next;
|
||||||
@@ -7425,6 +7429,12 @@ void ha_spider::position(
|
|||||||
pt_clone_last_searcher->position(record);
|
pt_clone_last_searcher->position(record);
|
||||||
memcpy(ref, pt_clone_last_searcher->ref, ref_length);
|
memcpy(ref, pt_clone_last_searcher->ref, ref_length);
|
||||||
} else {
|
} else {
|
||||||
|
if (is_clone)
|
||||||
|
{
|
||||||
|
DBUG_PRINT("info",("spider set pt_clone_last_searcher (NULL) to %p",
|
||||||
|
pt_clone_source_handler));
|
||||||
|
pt_clone_source_handler->pt_clone_last_searcher = NULL;
|
||||||
|
}
|
||||||
memset(ref, '0', sizeof(SPIDER_POSITION));
|
memset(ref, '0', sizeof(SPIDER_POSITION));
|
||||||
DBUG_PRINT("info",("spider self position"));
|
DBUG_PRINT("info",("spider self position"));
|
||||||
DBUG_PRINT("info",
|
DBUG_PRINT("info",
|
||||||
|
@@ -125,6 +125,7 @@ public:
|
|||||||
bool clone_bitmap_init;
|
bool clone_bitmap_init;
|
||||||
ha_spider *pt_clone_source_handler;
|
ha_spider *pt_clone_source_handler;
|
||||||
ha_spider *pt_clone_last_searcher;
|
ha_spider *pt_clone_last_searcher;
|
||||||
|
bool has_clone_for_merge;
|
||||||
|
|
||||||
bool init_index_handler;
|
bool init_index_handler;
|
||||||
bool init_rnd_handler;
|
bool init_rnd_handler;
|
||||||
|
@@ -1097,6 +1097,7 @@ long long spider_copy_tables_body(
|
|||||||
for (roop_count = 0; roop_count < all_link_cnt; roop_count++)
|
for (roop_count = 0; roop_count < all_link_cnt; roop_count++)
|
||||||
{
|
{
|
||||||
spider[roop_count].conns = NULL;
|
spider[roop_count].conns = NULL;
|
||||||
|
spider[roop_count].change_table_ptr(table, table_share);
|
||||||
}
|
}
|
||||||
for (roop_count = 0, table_conn = copy_tables->table_conn[0];
|
for (roop_count = 0, table_conn = copy_tables->table_conn[0];
|
||||||
table_conn; roop_count++, table_conn = table_conn->next)
|
table_conn; roop_count++, table_conn = table_conn->next)
|
||||||
|
@@ -4871,7 +4871,7 @@ int spider_db_seek_tmp(
|
|||||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||||
pos->row->first();
|
pos->row->first();
|
||||||
}
|
}
|
||||||
if (spider->sql_kind[spider->result_link_idx] == SPIDER_SQL_KIND_SQL)
|
if (pos->sql_kind == SPIDER_SQL_KIND_SQL)
|
||||||
{
|
{
|
||||||
if (!spider->select_column_mode)
|
if (!spider->select_column_mode)
|
||||||
{
|
{
|
||||||
@@ -8045,6 +8045,7 @@ int spider_db_open_item_cache(
|
|||||||
DBUG_ENTER("spider_db_open_item_cache");
|
DBUG_ENTER("spider_db_open_item_cache");
|
||||||
if (!item_cache->const_item())
|
if (!item_cache->const_item())
|
||||||
DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM);
|
DBUG_RETURN(ER_SPIDER_COND_SKIP_NUM);
|
||||||
|
DBUG_PRINT("info",("spider result_type=%u", item_cache->result_type()));
|
||||||
switch (item_cache->result_type())
|
switch (item_cache->result_type())
|
||||||
{
|
{
|
||||||
case STRING_RESULT:
|
case STRING_RESULT:
|
||||||
|
@@ -3859,6 +3859,7 @@ spider_handlersocket_handler::~spider_handlersocket_handler()
|
|||||||
int spider_handlersocket_handler::init()
|
int spider_handlersocket_handler::init()
|
||||||
{
|
{
|
||||||
st_spider_share *share = spider->share;
|
st_spider_share *share = spider->share;
|
||||||
|
TABLE *table = spider->get_table();
|
||||||
DBUG_ENTER("spider_handlersocket_handler::init");
|
DBUG_ENTER("spider_handlersocket_handler::init");
|
||||||
DBUG_PRINT("info",("spider this=%p", this));
|
DBUG_PRINT("info",("spider this=%p", this));
|
||||||
if (!(link_for_hash = (SPIDER_LINK_FOR_HASH *)
|
if (!(link_for_hash = (SPIDER_LINK_FOR_HASH *)
|
||||||
@@ -3866,6 +3867,7 @@ int spider_handlersocket_handler::init()
|
|||||||
__func__, __FILE__, __LINE__, MYF(MY_WME | MY_ZEROFILL),
|
__func__, __FILE__, __LINE__, MYF(MY_WME | MY_ZEROFILL),
|
||||||
&link_for_hash,
|
&link_for_hash,
|
||||||
sizeof(SPIDER_LINK_FOR_HASH) * share->link_count,
|
sizeof(SPIDER_LINK_FOR_HASH) * share->link_count,
|
||||||
|
&minimum_select_bitmap, sizeof(uchar) * no_bytes_in_map(table->read_set),
|
||||||
NullS))
|
NullS))
|
||||||
) {
|
) {
|
||||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||||
@@ -4072,10 +4074,12 @@ int spider_handlersocket_handler::append_minimum_select_without_quote(
|
|||||||
int field_length;
|
int field_length;
|
||||||
bool appended = FALSE;
|
bool appended = FALSE;
|
||||||
DBUG_ENTER("spider_handlersocket_handler::append_minimum_select_without_quote");
|
DBUG_ENTER("spider_handlersocket_handler::append_minimum_select_without_quote");
|
||||||
|
minimum_select_bitmap_create();
|
||||||
for (field = table->field; *field; field++)
|
for (field = table->field; *field; field++)
|
||||||
{
|
{
|
||||||
if (minimum_select_bit_is_set((*field)->field_index))
|
if (minimum_select_bit_is_set((*field)->field_index))
|
||||||
{
|
{
|
||||||
|
spider_set_bit(minimum_select_bitmap, (*field)->field_index);
|
||||||
field_length =
|
field_length =
|
||||||
handlersocket_share->column_name_str[(*field)->field_index].length();
|
handlersocket_share->column_name_str[(*field)->field_index].length();
|
||||||
if (str->reserve(field_length + SPIDER_SQL_COMMA_LEN))
|
if (str->reserve(field_length + SPIDER_SQL_COMMA_LEN))
|
||||||
@@ -5500,16 +5504,68 @@ bool spider_handlersocket_handler::support_use_handler(
|
|||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool spider_handlersocket_handler::minimum_select_bit_is_set(
|
void spider_handlersocket_handler::minimum_select_bitmap_create()
|
||||||
uint field_index
|
{
|
||||||
) {
|
|
||||||
TABLE *table = spider->get_table();
|
TABLE *table = spider->get_table();
|
||||||
DBUG_ENTER("spider_handlersocket_handler::minimum_select_bit_is_set");
|
Field **field_p;
|
||||||
DBUG_RETURN(
|
DBUG_ENTER("spider_handlersocket_handler::minimum_select_bitmap_create");
|
||||||
|
memset(minimum_select_bitmap, 0, no_bytes_in_map(table->read_set));
|
||||||
|
if (
|
||||||
|
spider->has_clone_for_merge ||
|
||||||
|
#ifdef HA_CAN_BULK_ACCESS
|
||||||
|
(spider->is_clone && !spider->is_bulk_access_clone)
|
||||||
|
#else
|
||||||
|
spider->is_clone
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
|
/* need preparing for cmp_ref */
|
||||||
|
TABLE_SHARE *table_share = table->s;
|
||||||
|
if (
|
||||||
|
table_share->primary_key == MAX_KEY
|
||||||
|
) {
|
||||||
|
/* need all columns */
|
||||||
|
memset(minimum_select_bitmap, 0xFF, no_bytes_in_map(table->read_set));
|
||||||
|
DBUG_VOID_RETURN;
|
||||||
|
} else {
|
||||||
|
/* need primary key columns */
|
||||||
|
uint roop_count;
|
||||||
|
KEY *key_info;
|
||||||
|
KEY_PART_INFO *key_part;
|
||||||
|
Field *field;
|
||||||
|
key_info = &table_share->key_info[table_share->primary_key];
|
||||||
|
key_part = key_info->key_part;
|
||||||
|
for (roop_count = 0;
|
||||||
|
roop_count < spider_user_defined_key_parts(key_info);
|
||||||
|
roop_count++)
|
||||||
|
{
|
||||||
|
field = key_part[roop_count].field;
|
||||||
|
spider_set_bit(minimum_select_bitmap, field->field_index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (field_p = table->field; *field_p; field_p++)
|
||||||
|
{
|
||||||
|
uint field_index = (*field_p)->field_index;
|
||||||
|
if (
|
||||||
spider_bit_is_set(spider->searched_bitmap, field_index) |
|
spider_bit_is_set(spider->searched_bitmap, field_index) |
|
||||||
bitmap_is_set(table->read_set, field_index) |
|
bitmap_is_set(table->read_set, field_index) |
|
||||||
bitmap_is_set(table->write_set, field_index)
|
bitmap_is_set(table->write_set, field_index)
|
||||||
);
|
) {
|
||||||
|
spider_set_bit(minimum_select_bitmap, field_index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DBUG_VOID_RETURN;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool spider_handlersocket_handler::minimum_select_bit_is_set(
|
||||||
|
uint field_index
|
||||||
|
) {
|
||||||
|
DBUG_ENTER("spider_handlersocket_handler::minimum_select_bit_is_set");
|
||||||
|
DBUG_PRINT("info",("spider field_index=%u", field_index));
|
||||||
|
DBUG_PRINT("info",("spider minimum_select_bitmap=%s",
|
||||||
|
spider_bit_is_set(minimum_select_bitmap, field_index) ?
|
||||||
|
"TRUE" : "FALSE"));
|
||||||
|
DBUG_RETURN(spider_bit_is_set(minimum_select_bitmap, field_index));
|
||||||
}
|
}
|
||||||
|
|
||||||
void spider_handlersocket_handler::copy_minimum_select_bitmap(
|
void spider_handlersocket_handler::copy_minimum_select_bitmap(
|
||||||
@@ -5523,18 +5579,10 @@ void spider_handlersocket_handler::copy_minimum_select_bitmap(
|
|||||||
roop_count++)
|
roop_count++)
|
||||||
{
|
{
|
||||||
bitmap[roop_count] =
|
bitmap[roop_count] =
|
||||||
spider->searched_bitmap[roop_count] |
|
minimum_select_bitmap[roop_count];
|
||||||
((uchar *) table->read_set->bitmap)[roop_count] |
|
|
||||||
((uchar *) table->write_set->bitmap)[roop_count];
|
|
||||||
DBUG_PRINT("info",("spider roop_count=%d", roop_count));
|
DBUG_PRINT("info",("spider roop_count=%d", roop_count));
|
||||||
DBUG_PRINT("info",("spider bitmap=%d",
|
DBUG_PRINT("info",("spider bitmap=%d",
|
||||||
bitmap[roop_count]));
|
bitmap[roop_count]));
|
||||||
DBUG_PRINT("info",("spider searched_bitmap=%d",
|
|
||||||
spider->searched_bitmap[roop_count]));
|
|
||||||
DBUG_PRINT("info",("spider read_set=%d",
|
|
||||||
((uchar *) table->read_set->bitmap)[roop_count]));
|
|
||||||
DBUG_PRINT("info",("spider write_set=%d",
|
|
||||||
((uchar *) table->write_set->bitmap)[roop_count]));
|
|
||||||
}
|
}
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
@@ -493,6 +493,7 @@ public:
|
|||||||
int hs_skip;
|
int hs_skip;
|
||||||
spider_handlersocket_share *handlersocket_share;
|
spider_handlersocket_share *handlersocket_share;
|
||||||
SPIDER_LINK_FOR_HASH *link_for_hash;
|
SPIDER_LINK_FOR_HASH *link_for_hash;
|
||||||
|
uchar *minimum_select_bitmap;
|
||||||
spider_handlersocket_handler(
|
spider_handlersocket_handler(
|
||||||
ha_spider *spider,
|
ha_spider *spider,
|
||||||
spider_handlersocket_share *db_share
|
spider_handlersocket_share *db_share
|
||||||
@@ -937,6 +938,7 @@ public:
|
|||||||
bool support_use_handler(
|
bool support_use_handler(
|
||||||
int use_handler
|
int use_handler
|
||||||
);
|
);
|
||||||
|
void minimum_select_bitmap_create();
|
||||||
bool minimum_select_bit_is_set(
|
bool minimum_select_bit_is_set(
|
||||||
uint field_index
|
uint field_index
|
||||||
);
|
);
|
||||||
|
@@ -4763,6 +4763,7 @@ int spider_mysql_handler::init()
|
|||||||
st_spider_share *share = spider->share;
|
st_spider_share *share = spider->share;
|
||||||
int init_sql_alloc_size =
|
int init_sql_alloc_size =
|
||||||
spider_param_init_sql_alloc_size(thd, share->init_sql_alloc_size);
|
spider_param_init_sql_alloc_size(thd, share->init_sql_alloc_size);
|
||||||
|
TABLE *table = spider->get_table();
|
||||||
DBUG_ENTER("spider_mysql_handler::init");
|
DBUG_ENTER("spider_mysql_handler::init");
|
||||||
DBUG_PRINT("info",("spider this=%p", this));
|
DBUG_PRINT("info",("spider this=%p", this));
|
||||||
sql.init_calc_mem(59);
|
sql.init_calc_mem(59);
|
||||||
@@ -4794,6 +4795,7 @@ int spider_mysql_handler::init()
|
|||||||
__func__, __FILE__, __LINE__, MYF(MY_WME | MY_ZEROFILL),
|
__func__, __FILE__, __LINE__, MYF(MY_WME | MY_ZEROFILL),
|
||||||
&link_for_hash,
|
&link_for_hash,
|
||||||
sizeof(SPIDER_LINK_FOR_HASH) * share->link_count,
|
sizeof(SPIDER_LINK_FOR_HASH) * share->link_count,
|
||||||
|
&minimum_select_bitmap, sizeof(uchar) * no_bytes_in_map(table->read_set),
|
||||||
NullS))
|
NullS))
|
||||||
) {
|
) {
|
||||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||||
@@ -6071,10 +6073,12 @@ int spider_mysql_handler::append_minimum_select(
|
|||||||
int field_length;
|
int field_length;
|
||||||
bool appended = FALSE;
|
bool appended = FALSE;
|
||||||
DBUG_ENTER("spider_mysql_handler::append_minimum_select");
|
DBUG_ENTER("spider_mysql_handler::append_minimum_select");
|
||||||
|
minimum_select_bitmap_create();
|
||||||
for (field = table->field; *field; field++)
|
for (field = table->field; *field; field++)
|
||||||
{
|
{
|
||||||
if (minimum_select_bit_is_set((*field)->field_index))
|
if (minimum_select_bit_is_set((*field)->field_index))
|
||||||
{
|
{
|
||||||
|
spider_set_bit(minimum_select_bitmap, (*field)->field_index);
|
||||||
field_length =
|
field_length =
|
||||||
mysql_share->column_name_str[(*field)->field_index].length();
|
mysql_share->column_name_str[(*field)->field_index].length();
|
||||||
if (str->reserve(field_length +
|
if (str->reserve(field_length +
|
||||||
@@ -6156,10 +6160,12 @@ int spider_mysql_handler::append_minimum_select_with_alias(
|
|||||||
int field_length;
|
int field_length;
|
||||||
bool appended = FALSE;
|
bool appended = FALSE;
|
||||||
DBUG_ENTER("spider_mysql_handler::append_minimum_select_with_alias");
|
DBUG_ENTER("spider_mysql_handler::append_minimum_select_with_alias");
|
||||||
|
minimum_select_bitmap_create();
|
||||||
for (field = table->field; *field; field++)
|
for (field = table->field; *field; field++)
|
||||||
{
|
{
|
||||||
if (minimum_select_bit_is_set((*field)->field_index))
|
if (minimum_select_bit_is_set((*field)->field_index))
|
||||||
{
|
{
|
||||||
|
spider_set_bit(minimum_select_bitmap, (*field)->field_index);
|
||||||
field_length =
|
field_length =
|
||||||
mysql_share->column_name_str[(*field)->field_index].length();
|
mysql_share->column_name_str[(*field)->field_index].length();
|
||||||
if (str->reserve(alias_length + field_length +
|
if (str->reserve(alias_length + field_length +
|
||||||
@@ -11065,12 +11071,49 @@ bool spider_mysql_handler::support_use_handler(
|
|||||||
DBUG_RETURN(TRUE);
|
DBUG_RETURN(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool spider_mysql_handler::minimum_select_bit_is_set(
|
void spider_mysql_handler::minimum_select_bitmap_create()
|
||||||
uint field_index
|
{
|
||||||
) {
|
|
||||||
TABLE *table = spider->get_table();
|
TABLE *table = spider->get_table();
|
||||||
DBUG_ENTER("spider_mysql_handler::minimum_select_bit_is_set");
|
Field **field_p;
|
||||||
|
DBUG_ENTER("spider_mysql_handler::minimum_select_bitmap_create");
|
||||||
DBUG_PRINT("info",("spider this=%p", this));
|
DBUG_PRINT("info",("spider this=%p", this));
|
||||||
|
memset(minimum_select_bitmap, 0, no_bytes_in_map(table->read_set));
|
||||||
|
if (
|
||||||
|
spider->has_clone_for_merge ||
|
||||||
|
#ifdef HA_CAN_BULK_ACCESS
|
||||||
|
(spider->is_clone && !spider->is_bulk_access_clone)
|
||||||
|
#else
|
||||||
|
spider->is_clone
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
|
/* need preparing for cmp_ref */
|
||||||
|
TABLE_SHARE *table_share = table->s;
|
||||||
|
if (
|
||||||
|
table_share->primary_key == MAX_KEY
|
||||||
|
) {
|
||||||
|
/* need all columns */
|
||||||
|
memset(minimum_select_bitmap, 0xFF, no_bytes_in_map(table->read_set));
|
||||||
|
DBUG_VOID_RETURN;
|
||||||
|
} else {
|
||||||
|
/* need primary key columns */
|
||||||
|
uint roop_count;
|
||||||
|
KEY *key_info;
|
||||||
|
KEY_PART_INFO *key_part;
|
||||||
|
Field *field;
|
||||||
|
key_info = &table_share->key_info[table_share->primary_key];
|
||||||
|
key_part = key_info->key_part;
|
||||||
|
for (roop_count = 0;
|
||||||
|
roop_count < spider_user_defined_key_parts(key_info);
|
||||||
|
roop_count++)
|
||||||
|
{
|
||||||
|
field = key_part[roop_count].field;
|
||||||
|
spider_set_bit(minimum_select_bitmap, field->field_index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (field_p = table->field; *field_p; field_p++)
|
||||||
|
{
|
||||||
|
uint field_index = (*field_p)->field_index;
|
||||||
DBUG_PRINT("info",("spider field_index=%u", field_index));
|
DBUG_PRINT("info",("spider field_index=%u", field_index));
|
||||||
DBUG_PRINT("info",("spider ft_discard_bitmap=%s",
|
DBUG_PRINT("info",("spider ft_discard_bitmap=%s",
|
||||||
spider_bit_is_set(spider->ft_discard_bitmap, field_index) ?
|
spider_bit_is_set(spider->ft_discard_bitmap, field_index) ?
|
||||||
@@ -11084,14 +11127,30 @@ bool spider_mysql_handler::minimum_select_bit_is_set(
|
|||||||
DBUG_PRINT("info",("spider write_set=%s",
|
DBUG_PRINT("info",("spider write_set=%s",
|
||||||
bitmap_is_set(table->write_set, field_index) ?
|
bitmap_is_set(table->write_set, field_index) ?
|
||||||
"TRUE" : "FALSE"));
|
"TRUE" : "FALSE"));
|
||||||
DBUG_RETURN(
|
if (
|
||||||
spider_bit_is_set(spider->ft_discard_bitmap, field_index) &
|
spider_bit_is_set(spider->ft_discard_bitmap, field_index) &
|
||||||
(
|
(
|
||||||
spider_bit_is_set(spider->searched_bitmap, field_index) |
|
spider_bit_is_set(spider->searched_bitmap, field_index) |
|
||||||
bitmap_is_set(table->read_set, field_index) |
|
bitmap_is_set(table->read_set, field_index) |
|
||||||
bitmap_is_set(table->write_set, field_index)
|
bitmap_is_set(table->write_set, field_index)
|
||||||
)
|
)
|
||||||
);
|
) {
|
||||||
|
spider_set_bit(minimum_select_bitmap, field_index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DBUG_VOID_RETURN;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool spider_mysql_handler::minimum_select_bit_is_set(
|
||||||
|
uint field_index
|
||||||
|
) {
|
||||||
|
DBUG_ENTER("spider_mysql_handler::minimum_select_bit_is_set");
|
||||||
|
DBUG_PRINT("info",("spider this=%p", this));
|
||||||
|
DBUG_PRINT("info",("spider field_index=%u", field_index));
|
||||||
|
DBUG_PRINT("info",("spider minimum_select_bitmap=%s",
|
||||||
|
spider_bit_is_set(minimum_select_bitmap, field_index) ?
|
||||||
|
"TRUE" : "FALSE"));
|
||||||
|
DBUG_RETURN(spider_bit_is_set(minimum_select_bitmap, field_index));
|
||||||
}
|
}
|
||||||
|
|
||||||
void spider_mysql_handler::copy_minimum_select_bitmap(
|
void spider_mysql_handler::copy_minimum_select_bitmap(
|
||||||
@@ -11105,23 +11164,10 @@ void spider_mysql_handler::copy_minimum_select_bitmap(
|
|||||||
roop_count++)
|
roop_count++)
|
||||||
{
|
{
|
||||||
bitmap[roop_count] =
|
bitmap[roop_count] =
|
||||||
spider->ft_discard_bitmap[roop_count] &
|
minimum_select_bitmap[roop_count];
|
||||||
(
|
|
||||||
spider->searched_bitmap[roop_count] |
|
|
||||||
((uchar *) table->read_set->bitmap)[roop_count] |
|
|
||||||
((uchar *) table->write_set->bitmap)[roop_count]
|
|
||||||
);
|
|
||||||
DBUG_PRINT("info",("spider roop_count=%d", roop_count));
|
DBUG_PRINT("info",("spider roop_count=%d", roop_count));
|
||||||
DBUG_PRINT("info",("spider bitmap=%d",
|
DBUG_PRINT("info",("spider bitmap=%d",
|
||||||
bitmap[roop_count]));
|
bitmap[roop_count]));
|
||||||
DBUG_PRINT("info",("spider ft_discard_bitmap=%d",
|
|
||||||
spider->ft_discard_bitmap[roop_count]));
|
|
||||||
DBUG_PRINT("info",("spider searched_bitmap=%d",
|
|
||||||
spider->searched_bitmap[roop_count]));
|
|
||||||
DBUG_PRINT("info",("spider read_set=%d",
|
|
||||||
((uchar *) table->read_set->bitmap)[roop_count]));
|
|
||||||
DBUG_PRINT("info",("spider write_set=%d",
|
|
||||||
((uchar *) table->write_set->bitmap)[roop_count]));
|
|
||||||
}
|
}
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
@@ -542,6 +542,7 @@ class spider_mysql_handler: public spider_db_handler
|
|||||||
public:
|
public:
|
||||||
spider_mysql_share *mysql_share;
|
spider_mysql_share *mysql_share;
|
||||||
SPIDER_LINK_FOR_HASH *link_for_hash;
|
SPIDER_LINK_FOR_HASH *link_for_hash;
|
||||||
|
uchar *minimum_select_bitmap;
|
||||||
spider_mysql_handler(
|
spider_mysql_handler(
|
||||||
ha_spider *spider,
|
ha_spider *spider,
|
||||||
spider_mysql_share *share
|
spider_mysql_share *share
|
||||||
@@ -1287,6 +1288,7 @@ public:
|
|||||||
bool support_use_handler(
|
bool support_use_handler(
|
||||||
int use_handler
|
int use_handler
|
||||||
);
|
);
|
||||||
|
void minimum_select_bitmap_create();
|
||||||
bool minimum_select_bit_is_set(
|
bool minimum_select_bit_is_set(
|
||||||
uint field_index
|
uint field_index
|
||||||
);
|
);
|
||||||
|
@@ -4773,6 +4773,7 @@ int spider_oracle_handler::init()
|
|||||||
st_spider_share *share = spider->share;
|
st_spider_share *share = spider->share;
|
||||||
int init_sql_alloc_size =
|
int init_sql_alloc_size =
|
||||||
spider_param_init_sql_alloc_size(thd, share->init_sql_alloc_size);
|
spider_param_init_sql_alloc_size(thd, share->init_sql_alloc_size);
|
||||||
|
TABLE *table = spider->get_table();
|
||||||
DBUG_ENTER("spider_oracle_handler::init");
|
DBUG_ENTER("spider_oracle_handler::init");
|
||||||
DBUG_PRINT("info",("spider this=%p", this));
|
DBUG_PRINT("info",("spider this=%p", this));
|
||||||
sql.init_calc_mem(67);
|
sql.init_calc_mem(67);
|
||||||
@@ -4804,6 +4805,7 @@ int spider_oracle_handler::init()
|
|||||||
__func__, __FILE__, __LINE__, MYF(MY_WME | MY_ZEROFILL),
|
__func__, __FILE__, __LINE__, MYF(MY_WME | MY_ZEROFILL),
|
||||||
&link_for_hash,
|
&link_for_hash,
|
||||||
sizeof(SPIDER_LINK_FOR_HASH) * share->link_count,
|
sizeof(SPIDER_LINK_FOR_HASH) * share->link_count,
|
||||||
|
&minimum_select_bitmap, sizeof(uchar) * no_bytes_in_map(table->read_set),
|
||||||
NullS))
|
NullS))
|
||||||
) {
|
) {
|
||||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||||
@@ -6007,10 +6009,12 @@ int spider_oracle_handler::append_minimum_select(
|
|||||||
int field_length;
|
int field_length;
|
||||||
bool appended = FALSE;
|
bool appended = FALSE;
|
||||||
DBUG_ENTER("spider_oracle_handler::append_minimum_select");
|
DBUG_ENTER("spider_oracle_handler::append_minimum_select");
|
||||||
|
minimum_select_bitmap_create();
|
||||||
for (field = table->field; *field; field++)
|
for (field = table->field; *field; field++)
|
||||||
{
|
{
|
||||||
if (minimum_select_bit_is_set((*field)->field_index))
|
if (minimum_select_bit_is_set((*field)->field_index))
|
||||||
{
|
{
|
||||||
|
spider_set_bit(minimum_select_bitmap, (*field)->field_index);
|
||||||
field_length =
|
field_length =
|
||||||
oracle_share->column_name_str[(*field)->field_index].length();
|
oracle_share->column_name_str[(*field)->field_index].length();
|
||||||
if (str->reserve(field_length +
|
if (str->reserve(field_length +
|
||||||
@@ -6092,10 +6096,12 @@ int spider_oracle_handler::append_minimum_select_with_alias(
|
|||||||
int field_length;
|
int field_length;
|
||||||
bool appended = FALSE;
|
bool appended = FALSE;
|
||||||
DBUG_ENTER("spider_oracle_handler::append_minimum_select_with_alias");
|
DBUG_ENTER("spider_oracle_handler::append_minimum_select_with_alias");
|
||||||
|
minimum_select_bitmap_create();
|
||||||
for (field = table->field; *field; field++)
|
for (field = table->field; *field; field++)
|
||||||
{
|
{
|
||||||
if (minimum_select_bit_is_set((*field)->field_index))
|
if (minimum_select_bit_is_set((*field)->field_index))
|
||||||
{
|
{
|
||||||
|
spider_set_bit(minimum_select_bitmap, (*field)->field_index);
|
||||||
field_length =
|
field_length =
|
||||||
oracle_share->column_name_str[(*field)->field_index].length();
|
oracle_share->column_name_str[(*field)->field_index].length();
|
||||||
if (str->reserve(alias_length + field_length +
|
if (str->reserve(alias_length + field_length +
|
||||||
@@ -11597,16 +11603,68 @@ bool spider_oracle_handler::support_use_handler(
|
|||||||
DBUG_RETURN(FALSE);
|
DBUG_RETURN(FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool spider_oracle_handler::minimum_select_bit_is_set(
|
void spider_oracle_handler::minimum_select_bitmap_create()
|
||||||
uint field_index
|
{
|
||||||
) {
|
|
||||||
TABLE *table = spider->get_table();
|
TABLE *table = spider->get_table();
|
||||||
DBUG_ENTER("spider_oracle_handler::minimum_select_bit_is_set");
|
Field **field_p;
|
||||||
DBUG_RETURN(
|
DBUG_ENTER("spider_oracle_handler::minimum_select_bitmap_create");
|
||||||
|
memset(minimum_select_bitmap, 0, no_bytes_in_map(table->read_set));
|
||||||
|
if (
|
||||||
|
spider->has_clone_for_merge ||
|
||||||
|
#ifdef HA_CAN_BULK_ACCESS
|
||||||
|
(spider->is_clone && !spider->is_bulk_access_clone)
|
||||||
|
#else
|
||||||
|
spider->is_clone
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
|
/* need preparing for cmp_ref */
|
||||||
|
TABLE_SHARE *table_share = table->s;
|
||||||
|
if (
|
||||||
|
table_share->primary_key == MAX_KEY
|
||||||
|
) {
|
||||||
|
/* need all columns */
|
||||||
|
memset(minimum_select_bitmap, 0xFF, no_bytes_in_map(table->read_set));
|
||||||
|
DBUG_VOID_RETURN;
|
||||||
|
} else {
|
||||||
|
/* need primary key columns */
|
||||||
|
uint roop_count;
|
||||||
|
KEY *key_info;
|
||||||
|
KEY_PART_INFO *key_part;
|
||||||
|
Field *field;
|
||||||
|
key_info = &table_share->key_info[table_share->primary_key];
|
||||||
|
key_part = key_info->key_part;
|
||||||
|
for (roop_count = 0;
|
||||||
|
roop_count < spider_user_defined_key_parts(key_info);
|
||||||
|
roop_count++)
|
||||||
|
{
|
||||||
|
field = key_part[roop_count].field;
|
||||||
|
spider_set_bit(minimum_select_bitmap, field->field_index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (field_p = table->field; *field_p; field_p++)
|
||||||
|
{
|
||||||
|
uint field_index = (*field_p)->field_index;
|
||||||
|
if (
|
||||||
spider_bit_is_set(spider->searched_bitmap, field_index) |
|
spider_bit_is_set(spider->searched_bitmap, field_index) |
|
||||||
bitmap_is_set(table->read_set, field_index) |
|
bitmap_is_set(table->read_set, field_index) |
|
||||||
bitmap_is_set(table->write_set, field_index)
|
bitmap_is_set(table->write_set, field_index)
|
||||||
);
|
) {
|
||||||
|
spider_set_bit(minimum_select_bitmap, field_index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DBUG_VOID_RETURN;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool spider_oracle_handler::minimum_select_bit_is_set(
|
||||||
|
uint field_index
|
||||||
|
) {
|
||||||
|
DBUG_ENTER("spider_oracle_handler::minimum_select_bit_is_set");
|
||||||
|
DBUG_PRINT("info",("spider field_index=%u", field_index));
|
||||||
|
DBUG_PRINT("info",("spider minimum_select_bitmap=%s",
|
||||||
|
spider_bit_is_set(minimum_select_bitmap, field_index) ?
|
||||||
|
"TRUE" : "FALSE"));
|
||||||
|
DBUG_RETURN(spider_bit_is_set(minimum_select_bitmap, field_index));
|
||||||
}
|
}
|
||||||
|
|
||||||
void spider_oracle_handler::copy_minimum_select_bitmap(
|
void spider_oracle_handler::copy_minimum_select_bitmap(
|
||||||
@@ -11620,18 +11678,10 @@ void spider_oracle_handler::copy_minimum_select_bitmap(
|
|||||||
roop_count++)
|
roop_count++)
|
||||||
{
|
{
|
||||||
bitmap[roop_count] =
|
bitmap[roop_count] =
|
||||||
spider->searched_bitmap[roop_count] |
|
minimum_select_bitmap[roop_count];
|
||||||
((uchar *) table->read_set->bitmap)[roop_count] |
|
|
||||||
((uchar *) table->write_set->bitmap)[roop_count];
|
|
||||||
DBUG_PRINT("info",("spider roop_count=%d", roop_count));
|
DBUG_PRINT("info",("spider roop_count=%d", roop_count));
|
||||||
DBUG_PRINT("info",("spider bitmap=%d",
|
DBUG_PRINT("info",("spider bitmap=%d",
|
||||||
bitmap[roop_count]));
|
bitmap[roop_count]));
|
||||||
DBUG_PRINT("info",("spider searched_bitmap=%d",
|
|
||||||
spider->searched_bitmap[roop_count]));
|
|
||||||
DBUG_PRINT("info",("spider read_set=%d",
|
|
||||||
((uchar *) table->read_set->bitmap)[roop_count]));
|
|
||||||
DBUG_PRINT("info",("spider write_set=%d",
|
|
||||||
((uchar *) table->write_set->bitmap)[roop_count]));
|
|
||||||
}
|
}
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
@@ -622,6 +622,7 @@ class spider_oracle_handler: public spider_db_handler
|
|||||||
public:
|
public:
|
||||||
spider_oracle_share *oracle_share;
|
spider_oracle_share *oracle_share;
|
||||||
SPIDER_LINK_FOR_HASH *link_for_hash;
|
SPIDER_LINK_FOR_HASH *link_for_hash;
|
||||||
|
uchar *minimum_select_bitmap;
|
||||||
spider_oracle_handler(
|
spider_oracle_handler(
|
||||||
ha_spider *spider,
|
ha_spider *spider,
|
||||||
spider_oracle_share *share
|
spider_oracle_share *share
|
||||||
@@ -1370,6 +1371,7 @@ public:
|
|||||||
bool support_use_handler(
|
bool support_use_handler(
|
||||||
int use_handler
|
int use_handler
|
||||||
);
|
);
|
||||||
|
void minimum_select_bitmap_create();
|
||||||
bool minimum_select_bit_is_set(
|
bool minimum_select_bit_is_set(
|
||||||
uint field_index
|
uint field_index
|
||||||
);
|
);
|
||||||
|
@@ -7660,8 +7660,25 @@ bool spider_check_direct_order_limit(
|
|||||||
longlong select_limit;
|
longlong select_limit;
|
||||||
longlong offset_limit;
|
longlong offset_limit;
|
||||||
DBUG_ENTER("spider_check_direct_order_limit");
|
DBUG_ENTER("spider_check_direct_order_limit");
|
||||||
if (spider->sql_command != SQLCOM_HA_READ)
|
DBUG_PRINT("info",("spider SQLCOM_HA_READ=%s",
|
||||||
{
|
(spider->sql_command == SQLCOM_HA_READ) ? "TRUE" : "FALSE"));
|
||||||
|
DBUG_PRINT("info",("spider has_clone_for_merge=%s",
|
||||||
|
spider->has_clone_for_merge ? "TRUE" : "FALSE"));
|
||||||
|
DBUG_PRINT("info",("spider is_clone=%s",
|
||||||
|
spider->is_clone ? "TRUE" : "FALSE"));
|
||||||
|
#ifdef HA_CAN_BULK_ACCESS
|
||||||
|
DBUG_PRINT("info",("spider is_bulk_access_clone=%s",
|
||||||
|
spider->is_bulk_access_clone ? "TRUE" : "FALSE"));
|
||||||
|
#endif
|
||||||
|
if (
|
||||||
|
spider->sql_command != SQLCOM_HA_READ &&
|
||||||
|
!spider->has_clone_for_merge &&
|
||||||
|
#ifdef HA_CAN_BULK_ACCESS
|
||||||
|
(!spider->is_clone || spider->is_bulk_access_clone)
|
||||||
|
#else
|
||||||
|
!spider->is_clone
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
spider_get_select_limit(spider, &select_lex, &select_limit, &offset_limit);
|
spider_get_select_limit(spider, &select_lex, &select_limit, &offset_limit);
|
||||||
bool first_check = TRUE;
|
bool first_check = TRUE;
|
||||||
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
|
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
|
||||||
|
Reference in New Issue
Block a user