mirror of
https://github.com/MariaDB/server.git
synced 2025-01-31 11:01:52 +01:00
merge 10.0-spider
This commit is contained in:
commit
77e6e74a26
19 changed files with 272 additions and 67 deletions
|
@ -18,7 +18,6 @@
|
|||
#endif
|
||||
|
||||
#define MYSQL_SERVER 1
|
||||
#include <my_global.h>
|
||||
#include "mysql_version.h"
|
||||
#if MYSQL_VERSION_ID < 50500
|
||||
#include "mysql_priv.h"
|
||||
|
@ -28,6 +27,9 @@
|
|||
#include "probes_mysql.h"
|
||||
#include "sql_class.h"
|
||||
#include "key.h"
|
||||
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
|
||||
#include "sql_select.h"
|
||||
#endif
|
||||
#endif
|
||||
#include "ha_partition.h"
|
||||
#include "spd_param.h"
|
||||
|
@ -92,7 +94,7 @@ ha_spider::ha_spider(
|
|||
mrr_key_buff = NULL;
|
||||
#endif
|
||||
append_tblnm_alias = NULL;
|
||||
has_clone_for_merge = FALSE;
|
||||
use_index_merge = FALSE;
|
||||
is_clone = FALSE;
|
||||
clone_bitmap_init = FALSE;
|
||||
pt_clone_source_handler = NULL;
|
||||
|
@ -162,6 +164,7 @@ ha_spider::ha_spider(
|
|||
result_list.direct_distinct = FALSE;
|
||||
result_list.casual_read = NULL;
|
||||
result_list.use_both_key = FALSE;
|
||||
result_list.in_cmp_ref = FALSE;
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
@ -199,7 +202,7 @@ ha_spider::ha_spider(
|
|||
mrr_key_buff = NULL;
|
||||
#endif
|
||||
append_tblnm_alias = NULL;
|
||||
has_clone_for_merge = FALSE;
|
||||
use_index_merge = FALSE;
|
||||
is_clone = FALSE;
|
||||
clone_bitmap_init = FALSE;
|
||||
pt_clone_source_handler = NULL;
|
||||
|
@ -269,6 +272,7 @@ ha_spider::ha_spider(
|
|||
result_list.direct_distinct = FALSE;
|
||||
result_list.casual_read = NULL;
|
||||
result_list.use_both_key = FALSE;
|
||||
result_list.in_cmp_ref = FALSE;
|
||||
ref_length = sizeof(SPIDER_POSITION);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
@ -300,7 +304,7 @@ handler *ha_spider::clone(
|
|||
HA_OPEN_IGNORE_IF_LOCKED))
|
||||
DBUG_RETURN(NULL);
|
||||
spider->sync_from_clone_source_base(this);
|
||||
has_clone_for_merge = TRUE;
|
||||
use_index_merge = TRUE;
|
||||
|
||||
DBUG_RETURN((handler *) spider);
|
||||
}
|
||||
|
@ -1735,7 +1739,8 @@ int ha_spider::reset()
|
|||
result_list.use_both_key = FALSE;
|
||||
pt_clone_last_searcher = NULL;
|
||||
conn_kinds = SPIDER_CONN_KIND_MYSQL;
|
||||
has_clone_for_merge = FALSE;
|
||||
use_index_merge = FALSE;
|
||||
init_rnd_handler = FALSE;
|
||||
while (condition)
|
||||
{
|
||||
tmp_cond = condition->next;
|
||||
|
@ -1853,6 +1858,35 @@ int ha_spider::extra(
|
|||
if (!(trx = spider_get_trx(ha_thd(), TRUE, &error_num)))
|
||||
DBUG_RETURN(error_num);
|
||||
break;
|
||||
#endif
|
||||
#ifdef HA_EXTRA_HAS_HA_EXTRA_USE_CMP_REF
|
||||
case HA_EXTRA_USE_CMP_REF:
|
||||
DBUG_PRINT("info",("spider HA_EXTRA_USE_CMP_REF"));
|
||||
if (table_share->primary_key != MAX_KEY)
|
||||
{
|
||||
DBUG_PRINT("info",("spider need primary key columns"));
|
||||
KEY *key_info = &table->key_info[table->s->primary_key];
|
||||
KEY_PART_INFO *key_part;
|
||||
uint part_num;
|
||||
for (
|
||||
key_part = key_info->key_part, part_num = 0;
|
||||
part_num < spider_user_defined_key_parts(key_info);
|
||||
key_part++, part_num++
|
||||
) {
|
||||
spider_set_bit(searched_bitmap, key_part->field->field_index);
|
||||
}
|
||||
} else {
|
||||
DBUG_PRINT("info",("spider need all columns"));
|
||||
Field **field;
|
||||
for (
|
||||
field = table->field;
|
||||
*field;
|
||||
field++
|
||||
) {
|
||||
spider_set_bit(searched_bitmap, (*field)->field_index);
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
|
@ -4437,6 +4471,7 @@ int ha_spider::read_multi_range_first_internal(
|
|||
result_list.keyread = TRUE;
|
||||
else
|
||||
result_list.keyread = FALSE;
|
||||
mrr_with_cnt = FALSE;
|
||||
if (
|
||||
(error_num = spider_db_append_select(this)) ||
|
||||
(error_num = spider_db_append_select_columns(this))
|
||||
|
@ -7649,6 +7684,7 @@ int ha_spider::cmp_ref(
|
|||
DBUG_PRINT("info",("spider this=%p", this));
|
||||
DBUG_PRINT("info",("spider ref1=%p", ref1));
|
||||
DBUG_PRINT("info",("spider ref2=%p", ref2));
|
||||
result_list.in_cmp_ref = TRUE;
|
||||
if (table_share->primary_key < MAX_KEY)
|
||||
{
|
||||
uchar table_key[MAX_KEY_LENGTH];
|
||||
|
@ -7680,6 +7716,7 @@ int ha_spider::cmp_ref(
|
|||
}
|
||||
}
|
||||
}
|
||||
result_list.in_cmp_ref = FALSE;
|
||||
DBUG_PRINT("info",("spider ret=%d", ret));
|
||||
DBUG_RETURN(ret);
|
||||
}
|
||||
|
@ -8685,7 +8722,7 @@ ha_rows ha_spider::records_in_range(
|
|||
key_part_map end_key_part_map;
|
||||
key_part_map tgt_key_part_map;
|
||||
KEY_PART_INFO *key_part;
|
||||
Field *field;
|
||||
Field *field = NULL;
|
||||
double rows = (double) share->records;
|
||||
double weight, rate;
|
||||
DBUG_PRINT("info",("spider rows1=%f", rows));
|
||||
|
@ -10967,7 +11004,11 @@ bool ha_spider::is_crashed() const
|
|||
DBUG_RETURN(FALSE);
|
||||
}
|
||||
|
||||
bool ha_spider::auto_repair(int) const
|
||||
#ifdef SPIDER_HANDLER_AUTO_REPAIR_HAS_ERROR
|
||||
bool ha_spider::auto_repair(int error) const
|
||||
#else
|
||||
bool ha_spider::auto_repair() const
|
||||
#endif
|
||||
{
|
||||
DBUG_ENTER("ha_spider::auto_repair");
|
||||
DBUG_PRINT("info",("spider this=%p", this));
|
||||
|
@ -11452,6 +11493,16 @@ TABLE *ha_spider::get_table()
|
|||
DBUG_RETURN(table);
|
||||
}
|
||||
|
||||
TABLE *ha_spider::get_top_table()
|
||||
{
|
||||
DBUG_ENTER("ha_spider::get_top_table");
|
||||
#ifdef HANDLER_HAS_TOP_TABLE_FIELDS
|
||||
if (set_top_table_fields)
|
||||
DBUG_RETURN(top_table);
|
||||
#endif
|
||||
DBUG_RETURN(table);
|
||||
}
|
||||
|
||||
void ha_spider::set_ft_discard_bitmap()
|
||||
{
|
||||
DBUG_ENTER("ha_spider::set_ft_discard_bitmap");
|
||||
|
@ -13819,6 +13870,18 @@ int ha_spider::append_key_order_for_merge_with_alias_sql_part(
|
|||
uint roop_count, dbton_id;
|
||||
spider_db_handler *dbton_hdl;
|
||||
DBUG_ENTER("ha_spider::append_key_order_for_merge_with_alias_sql_part");
|
||||
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
|
||||
if (result_list.direct_aggregate)
|
||||
{
|
||||
st_select_lex *select_lex = spider_get_select_lex(this);
|
||||
ORDER *group = (ORDER *) select_lex->group_list.first;
|
||||
if (!group && *(select_lex->join->sum_funcs))
|
||||
{
|
||||
DBUG_PRINT("info",("spider skip order by"));
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++)
|
||||
{
|
||||
dbton_id = share->use_sql_dbton_ids[roop_count];
|
||||
|
@ -13868,6 +13931,18 @@ int ha_spider::append_key_order_with_alias_sql_part(
|
|||
uint roop_count, dbton_id;
|
||||
spider_db_handler *dbton_hdl;
|
||||
DBUG_ENTER("ha_spider::append_key_order_with_alias_sql_part");
|
||||
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
|
||||
if (result_list.direct_aggregate)
|
||||
{
|
||||
st_select_lex *select_lex = spider_get_select_lex(this);
|
||||
ORDER *group = (ORDER *) select_lex->group_list.first;
|
||||
if (!group && *(select_lex->join->sum_funcs))
|
||||
{
|
||||
DBUG_PRINT("info",("spider skip order by"));
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
for (roop_count = 0; roop_count < share->use_sql_dbton_count; roop_count++)
|
||||
{
|
||||
dbton_id = share->use_sql_dbton_ids[roop_count];
|
||||
|
|
|
@ -125,7 +125,7 @@ public:
|
|||
bool clone_bitmap_init;
|
||||
ha_spider *pt_clone_source_handler;
|
||||
ha_spider *pt_clone_last_searcher;
|
||||
bool has_clone_for_merge;
|
||||
bool use_index_merge;
|
||||
|
||||
bool init_index_handler;
|
||||
bool init_rnd_handler;
|
||||
|
@ -682,7 +682,11 @@ public:
|
|||
const char *name
|
||||
);
|
||||
bool is_crashed() const;
|
||||
bool auto_repair(int) const;
|
||||
#ifdef SPIDER_HANDLER_AUTO_REPAIR_HAS_ERROR
|
||||
bool auto_repair(int error) const;
|
||||
#else
|
||||
bool auto_repair() const;
|
||||
#endif
|
||||
int disable_indexes(
|
||||
uint mode
|
||||
);
|
||||
|
@ -730,6 +734,7 @@ public:
|
|||
void return_record_by_parent();
|
||||
#endif
|
||||
TABLE *get_table();
|
||||
TABLE *get_top_table();
|
||||
void set_ft_discard_bitmap();
|
||||
void set_searched_bitmap();
|
||||
void set_clone_searched_bitmap();
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#define MYSQL_SERVER 1
|
||||
#include <my_global.h>
|
||||
#include "mysql_version.h"
|
||||
#if MYSQL_VERSION_ID < 50500
|
||||
#include "mysql_priv.h"
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#define MYSQL_SERVER 1
|
||||
#include <my_global.h>
|
||||
#include "mysql_version.h"
|
||||
#if MYSQL_VERSION_ID < 50500
|
||||
#include "mysql_priv.h"
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#define MYSQL_SERVER 1
|
||||
#include <my_global.h>
|
||||
#include "mysql_version.h"
|
||||
#if MYSQL_VERSION_ID < 50500
|
||||
#include "mysql_priv.h"
|
||||
|
@ -515,6 +514,7 @@ int spider_db_before_query(
|
|||
int *need_mon
|
||||
) {
|
||||
int error_num;
|
||||
bool tmp_mta_conn_mutex_lock_already;
|
||||
DBUG_ENTER("spider_db_before_query");
|
||||
DBUG_ASSERT(need_mon);
|
||||
#ifndef WITHOUT_SPIDER_BG_SEARCH
|
||||
|
@ -529,11 +529,15 @@ int spider_db_before_query(
|
|||
conn->need_mon = need_mon;
|
||||
}
|
||||
DBUG_ASSERT(conn->mta_conn_mutex_file_pos.file_name);
|
||||
tmp_mta_conn_mutex_lock_already = conn->mta_conn_mutex_lock_already;
|
||||
conn->mta_conn_mutex_lock_already = TRUE;
|
||||
if ((error_num = spider_db_conn_queue_action(conn)))
|
||||
{
|
||||
conn->in_before_query = FALSE;
|
||||
conn->mta_conn_mutex_lock_already = tmp_mta_conn_mutex_lock_already;
|
||||
DBUG_RETURN(error_num);
|
||||
}
|
||||
conn->mta_conn_mutex_lock_already = tmp_mta_conn_mutex_lock_already;
|
||||
if (conn->server_lost)
|
||||
{
|
||||
conn->in_before_query = FALSE;
|
||||
|
@ -2564,7 +2568,11 @@ int spider_db_fetch_for_item_sum_func(
|
|||
{
|
||||
Item *free_list = thd->free_list;
|
||||
spider->direct_aggregate_item_current->item =
|
||||
#ifdef SPIDER_ITEM_STRING_WITHOUT_SET_STR_WITH_COPY
|
||||
new Item_string("", 0, share->access_charset);
|
||||
#else
|
||||
new Item_string(share->access_charset);
|
||||
#endif
|
||||
if (!spider->direct_aggregate_item_current->item)
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
thd->free_list = free_list;
|
||||
|
@ -2575,7 +2583,12 @@ int spider_db_fetch_for_item_sum_func(
|
|||
(Item_string *) spider->direct_aggregate_item_current->item;
|
||||
if (row->is_null())
|
||||
{
|
||||
#ifdef SPIDER_ITEM_STRING_WITHOUT_SET_STR_WITH_COPY
|
||||
item->val_str(NULL)->length(0);
|
||||
item->append(NULL, 0);
|
||||
#else
|
||||
item->set_str_with_copy(NULL, 0);
|
||||
#endif
|
||||
item->null_value = TRUE;
|
||||
} else {
|
||||
char buf[MAX_FIELD_WIDTH];
|
||||
|
@ -2584,7 +2597,12 @@ int spider_db_fetch_for_item_sum_func(
|
|||
tmp_str.length(0);
|
||||
if ((error_num = row->append_to_str(&tmp_str)))
|
||||
DBUG_RETURN(error_num);
|
||||
#ifdef SPIDER_ITEM_STRING_WITHOUT_SET_STR_WITH_COPY
|
||||
item->val_str(NULL)->length(0);
|
||||
item->append((char *) tmp_str.ptr(), tmp_str.length());
|
||||
#else
|
||||
item->set_str_with_copy(tmp_str.ptr(), tmp_str.length());
|
||||
#endif
|
||||
item->null_value = FALSE;
|
||||
}
|
||||
item_hybrid->direct_add(item);
|
||||
|
@ -3279,8 +3297,11 @@ void spider_db_free_one_result(
|
|||
if (result->result)
|
||||
{
|
||||
result->result->free_result();
|
||||
delete result->result;
|
||||
result->result = NULL;
|
||||
if (!result->tmp_tbl_use_position)
|
||||
{
|
||||
delete result->result;
|
||||
result->result = NULL;
|
||||
}
|
||||
}
|
||||
if (!result->tmp_tbl_use_position)
|
||||
{
|
||||
|
@ -4964,11 +4985,14 @@ int spider_db_seek_tmp_table(
|
|||
|
||||
DBUG_PRINT("info", ("spider row=%p", row));
|
||||
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
|
||||
DBUG_PRINT("info", ("spider direct_aggregate=%s",
|
||||
pos->direct_aggregate ? "TRUE" : "FALSE"));
|
||||
spider->result_list.snap_mrr_with_cnt = pos->mrr_with_cnt;
|
||||
spider->result_list.snap_direct_aggregate = pos->direct_aggregate;
|
||||
spider->result_list.snap_row = row;
|
||||
if (!spider->result_list.in_cmp_ref)
|
||||
{
|
||||
DBUG_PRINT("info", ("spider direct_aggregate=%s",
|
||||
pos->direct_aggregate ? "TRUE" : "FALSE"));
|
||||
spider->result_list.snap_mrr_with_cnt = pos->mrr_with_cnt;
|
||||
spider->result_list.snap_direct_aggregate = pos->direct_aggregate;
|
||||
spider->result_list.snap_row = row;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* for mrr */
|
||||
|
@ -5052,11 +5076,14 @@ int spider_db_seek_tmp_key(
|
|||
|
||||
DBUG_PRINT("info", ("spider row=%p", row));
|
||||
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
|
||||
DBUG_PRINT("info", ("spider direct_aggregate=%s",
|
||||
pos->direct_aggregate ? "TRUE" : "FALSE"));
|
||||
spider->result_list.snap_mrr_with_cnt = pos->mrr_with_cnt;
|
||||
spider->result_list.snap_direct_aggregate = pos->direct_aggregate;
|
||||
spider->result_list.snap_row = row;
|
||||
if (!spider->result_list.in_cmp_ref)
|
||||
{
|
||||
DBUG_PRINT("info", ("spider direct_aggregate=%s",
|
||||
pos->direct_aggregate ? "TRUE" : "FALSE"));
|
||||
spider->result_list.snap_mrr_with_cnt = pos->mrr_with_cnt;
|
||||
spider->result_list.snap_direct_aggregate = pos->direct_aggregate;
|
||||
spider->result_list.snap_row = row;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* for mrr */
|
||||
|
@ -5133,11 +5160,14 @@ int spider_db_seek_tmp_minimum_columns(
|
|||
|
||||
DBUG_PRINT("info", ("spider row=%p", row));
|
||||
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
|
||||
DBUG_PRINT("info", ("spider direct_aggregate=%s",
|
||||
pos->direct_aggregate ? "TRUE" : "FALSE"));
|
||||
spider->result_list.snap_mrr_with_cnt = pos->mrr_with_cnt;
|
||||
spider->result_list.snap_direct_aggregate = pos->direct_aggregate;
|
||||
spider->result_list.snap_row = row;
|
||||
if (!spider->result_list.in_cmp_ref)
|
||||
{
|
||||
DBUG_PRINT("info", ("spider direct_aggregate=%s",
|
||||
pos->direct_aggregate ? "TRUE" : "FALSE"));
|
||||
spider->result_list.snap_mrr_with_cnt = pos->mrr_with_cnt;
|
||||
spider->result_list.snap_direct_aggregate = pos->direct_aggregate;
|
||||
spider->result_list.snap_row = row;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* for mrr */
|
||||
|
@ -8088,19 +8118,24 @@ int spider_db_open_item_string(
|
|||
spider_string tmp_str(tmp_buf, MAX_FIELD_WIDTH, str->charset());
|
||||
String *tmp_str2;
|
||||
tmp_str.init_calc_mem(126);
|
||||
if (
|
||||
!(tmp_str2 = item->val_str(tmp_str.get_str())) ||
|
||||
str->reserve(SPIDER_SQL_VALUE_QUOTE_LEN * 2 + tmp_str2->length() * 2)
|
||||
)
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
tmp_str.mem_calc();
|
||||
str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN);
|
||||
if (
|
||||
str->append_for_single_quote(tmp_str2) ||
|
||||
str->reserve(SPIDER_SQL_VALUE_QUOTE_LEN)
|
||||
)
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN);
|
||||
if (!(tmp_str2 = item->val_str(tmp_str.get_str())))
|
||||
{
|
||||
if (str->reserve(SPIDER_SQL_NULL_LEN))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
str->q_append(SPIDER_SQL_NULL_STR, SPIDER_SQL_NULL_LEN);
|
||||
} else {
|
||||
if (str->reserve(SPIDER_SQL_VALUE_QUOTE_LEN * 2 +
|
||||
tmp_str2->length() * 2))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
tmp_str.mem_calc();
|
||||
str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN);
|
||||
if (
|
||||
str->append_for_single_quote(tmp_str2) ||
|
||||
str->reserve(SPIDER_SQL_VALUE_QUOTE_LEN)
|
||||
)
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
str->q_append(SPIDER_SQL_VALUE_QUOTE_STR, SPIDER_SQL_VALUE_QUOTE_LEN);
|
||||
}
|
||||
}
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#define MYSQL_SERVER 1
|
||||
#include <my_global.h>
|
||||
#include "mysql_version.h"
|
||||
#if MYSQL_VERSION_ID < 50500
|
||||
#include "mysql_priv.h"
|
||||
|
@ -5543,7 +5542,7 @@ void spider_handlersocket_handler::minimum_select_bitmap_create()
|
|||
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 ||
|
||||
spider->use_index_merge ||
|
||||
#ifdef HA_CAN_BULK_ACCESS
|
||||
(spider->is_clone && !spider->is_bulk_access_clone)
|
||||
#else
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
#define SPIDER_HAS_DISCOVER_TABLE_STRUCTURE
|
||||
#define SPIDER_HAS_APPEND_FOR_SINGLE_QUOTE
|
||||
#define SPIDER_HAS_SHOW_SIMPLE_FUNC
|
||||
#define SPIDER_HAS_JT_HASH_INDEX_MERGE
|
||||
#else
|
||||
#define SPIDER_NEED_CHECK_CONDITION_AT_CHECKING_DIRECT_ORDER_LIMIT
|
||||
#endif
|
||||
|
||||
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100007
|
||||
|
@ -36,8 +39,13 @@
|
|||
#define SPIDER_HAS_DECIMAL_OPERATION_RESULTS_VALUE_TYPE
|
||||
#endif
|
||||
|
||||
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100014
|
||||
#define SPIDER_ITEM_STRING_WITHOUT_SET_STR_WITH_COPY
|
||||
#endif
|
||||
|
||||
#if defined(MARIADB_BASE_VERSION)
|
||||
#define SPIDER_ITEM_GEOFUNC_NAME_HAS_MBR
|
||||
#define SPIDER_HANDLER_AUTO_REPAIR_HAS_ERROR
|
||||
#endif
|
||||
|
||||
class spider_db_conn;
|
||||
|
@ -1649,6 +1657,7 @@ typedef struct st_spider_result_list
|
|||
bool snap_direct_aggregate;
|
||||
SPIDER_DB_ROW *snap_row;
|
||||
#endif
|
||||
bool in_cmp_ref;
|
||||
bool set_split_read;
|
||||
bool insert_dup_update_pushdown;
|
||||
longlong split_read_base;
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#define MYSQL_SERVER 1
|
||||
#include <my_global.h>
|
||||
#include "mysql_version.h"
|
||||
#if MYSQL_VERSION_ID < 50500
|
||||
#include "mysql_priv.h"
|
||||
|
@ -7269,11 +7268,16 @@ int spider_mysql_handler::append_update_where(
|
|||
Field **field;
|
||||
SPIDER_SHARE *share = spider->share;
|
||||
DBUG_ENTER("spider_mysql_handler::append_update_where");
|
||||
DBUG_PRINT("info", ("spider table->s->primary_key=%s",
|
||||
table->s->primary_key != MAX_KEY ? "TRUE" : "FALSE"));
|
||||
if (str->reserve(SPIDER_SQL_WHERE_LEN))
|
||||
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
|
||||
str->q_append(SPIDER_SQL_WHERE_STR, SPIDER_SQL_WHERE_LEN);
|
||||
for (field = table->field; *field; field++)
|
||||
{
|
||||
DBUG_PRINT("info", ("spider bitmap=%s",
|
||||
bitmap_is_set(table->read_set, (*field)->field_index) ?
|
||||
"TRUE" : "FALSE"));
|
||||
if (
|
||||
table->s->primary_key == MAX_KEY ||
|
||||
bitmap_is_set(table->read_set, (*field)->field_index)
|
||||
|
@ -11444,7 +11448,7 @@ void spider_mysql_handler::minimum_select_bitmap_create()
|
|||
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 ||
|
||||
spider->use_index_merge ||
|
||||
#ifdef HA_CAN_BULK_ACCESS
|
||||
(spider->is_clone && !spider->is_bulk_access_clone)
|
||||
#else
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#define MYSQL_SERVER 1
|
||||
#include <my_global.h>
|
||||
#include "mysql_version.h"
|
||||
#if MYSQL_VERSION_ID < 50500
|
||||
#include "mysql_priv.h"
|
||||
|
@ -11647,7 +11646,7 @@ void spider_oracle_handler::minimum_select_bitmap_create()
|
|||
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 ||
|
||||
spider->use_index_merge ||
|
||||
#ifdef HA_CAN_BULK_ACCESS
|
||||
(spider->is_clone && !spider->is_bulk_access_clone)
|
||||
#else
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#define MYSQL_SERVER 1
|
||||
#include <my_global.h>
|
||||
#include "mysql_version.h"
|
||||
#if MYSQL_VERSION_ID < 50500
|
||||
#include "mysql_priv.h"
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#define MYSQL_SERVER 1
|
||||
#include <my_global.h>
|
||||
#include "mysql_version.h"
|
||||
#if MYSQL_VERSION_ID < 50500
|
||||
#include "mysql_priv.h"
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#define SPIDER_DETAIL_VERSION "3.2.11"
|
||||
#define SPIDER_DETAIL_VERSION "3.2.18"
|
||||
#define SPIDER_HEX_VERSION 0x0302
|
||||
|
||||
#if MYSQL_VERSION_ID < 50500
|
||||
|
@ -70,6 +70,7 @@
|
|||
#define spider_stmt_da_message(A) thd_get_error_message(A)
|
||||
#define spider_stmt_da_sql_errno(A) thd_get_error_number(A)
|
||||
#define spider_user_defined_key_parts(A) (A)->user_defined_key_parts
|
||||
#define spider_join_table_count(A) (A)->table_count
|
||||
#define SPIDER_CAN_BG_UPDATE (1LL << 39)
|
||||
#define SPIDER_ALTER_ADD_PARTITION Alter_info::ALTER_ADD_PARTITION
|
||||
#define SPIDER_ALTER_DROP_PARTITION Alter_info::ALTER_DROP_PARTITION
|
||||
|
@ -94,6 +95,7 @@
|
|||
#endif
|
||||
#endif
|
||||
#define spider_user_defined_key_parts(A) (A)->key_parts
|
||||
#define spider_join_table_count(A) (A)->tables
|
||||
#define SPIDER_ALTER_ADD_PARTITION ALTER_ADD_PARTITION
|
||||
#define SPIDER_ALTER_DROP_PARTITION ALTER_DROP_PARTITION
|
||||
#define SPIDER_ALTER_COALESCE_PARTITION ALTER_COALESCE_PARTITION
|
||||
|
@ -105,6 +107,10 @@
|
|||
#define SPIDER_THD_KILL_CONNECTION THD::KILL_CONNECTION
|
||||
#endif
|
||||
|
||||
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100005
|
||||
#define SPIDER_HAS_EXPLAIN_QUERY
|
||||
#endif
|
||||
|
||||
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100009
|
||||
#define SPIDER_TEST(A) MY_TEST(A)
|
||||
#else
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#define MYSQL_SERVER 1
|
||||
#include <my_global.h>
|
||||
#include "mysql_version.h"
|
||||
#if MYSQL_VERSION_ID < 50500
|
||||
#include "mysql_priv.h"
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#define MYSQL_SERVER 1
|
||||
#include <my_global.h>
|
||||
#include "mysql_version.h"
|
||||
#if MYSQL_VERSION_ID < 50500
|
||||
#include "mysql_priv.h"
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#define MYSQL_SERVER 1
|
||||
#include <my_global.h>
|
||||
#include "mysql_version.h"
|
||||
#if MYSQL_VERSION_ID < 50500
|
||||
#include "mysql_priv.h"
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#define MYSQL_SERVER 1
|
||||
#include <my_global.h>
|
||||
#include "mysql_version.h"
|
||||
#if MYSQL_VERSION_ID < 50500
|
||||
#include "mysql_priv.h"
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#define MYSQL_SERVER 1
|
||||
#include <my_global.h>
|
||||
#include "mysql_version.h"
|
||||
#if MYSQL_VERSION_ID < 50500
|
||||
#include "mysql_priv.h"
|
||||
|
@ -7730,6 +7729,7 @@ longlong spider_split_read_param(
|
|||
DBUG_RETURN(result_list->semi_split_read_base);
|
||||
}
|
||||
spider_get_select_limit(spider, &select_lex, &select_limit, &offset_limit);
|
||||
DBUG_PRINT("info",("spider result_list->set_split_read=%s", result_list->set_split_read ? "TRUE" : "FALSE"));
|
||||
if (!result_list->set_split_read)
|
||||
{
|
||||
int bulk_update_mode = spider_param_bulk_update_mode(thd,
|
||||
|
@ -7803,6 +7803,7 @@ longlong spider_split_read_param(
|
|||
result_list->set_split_read = TRUE;
|
||||
DBUG_RETURN(9223372036854775807LL);
|
||||
}
|
||||
#ifdef SPIDER_HAS_EXPLAIN_QUERY
|
||||
Explain_query *explain = thd->lex->explain;
|
||||
bool filesort = FALSE;
|
||||
if (explain)
|
||||
|
@ -7827,18 +7828,23 @@ longlong spider_split_read_param(
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
result_list->split_read_base =
|
||||
spider_param_split_read(thd, share->split_read);
|
||||
#ifdef SPIDER_HAS_EXPLAIN_QUERY
|
||||
if (filesort)
|
||||
{
|
||||
result_list->semi_split_read = 0;
|
||||
result_list->semi_split_read_limit = 9223372036854775807LL;
|
||||
} else {
|
||||
#endif
|
||||
result_list->semi_split_read =
|
||||
spider_param_semi_split_read(thd, share->semi_split_read);
|
||||
result_list->semi_split_read_limit =
|
||||
spider_param_semi_split_read_limit(thd, share->semi_split_read_limit);
|
||||
#ifdef SPIDER_HAS_EXPLAIN_QUERY
|
||||
}
|
||||
#endif
|
||||
result_list->first_read =
|
||||
spider_param_first_read(thd, share->first_read);
|
||||
result_list->second_read =
|
||||
|
@ -7846,6 +7852,11 @@ longlong spider_split_read_param(
|
|||
result_list->semi_split_read_base = 0;
|
||||
result_list->set_split_read = TRUE;
|
||||
}
|
||||
DBUG_PRINT("info",("spider result_list->semi_split_read=%f", result_list->semi_split_read));
|
||||
DBUG_PRINT("info",("spider select_lex->explicit_limit=%d", select_lex ? select_lex->explicit_limit : 0));
|
||||
DBUG_PRINT("info",("spider OPTION_FOUND_ROWS=%s", select_lex && (select_lex->options & OPTION_FOUND_ROWS) ? "TRUE" : "FALSE"));
|
||||
DBUG_PRINT("info",("spider select_lex->group_list.elements=%u", select_lex ? select_lex->group_list.elements : 0));
|
||||
DBUG_PRINT("info",("spider select_lex->with_sum_func=%s", select_lex && select_lex->with_sum_func ? "TRUE" : "FALSE"));
|
||||
if (
|
||||
result_list->semi_split_read > 0 &&
|
||||
select_lex && select_lex->explicit_limit &&
|
||||
|
@ -7932,12 +7943,18 @@ bool spider_check_direct_order_limit(
|
|||
longlong select_limit;
|
||||
longlong offset_limit;
|
||||
DBUG_ENTER("spider_check_direct_order_limit");
|
||||
if (spider_check_index_merge(spider->get_top_table(),
|
||||
spider_get_select_lex(spider)))
|
||||
{
|
||||
DBUG_PRINT("info",("spider set use_index_merge"));
|
||||
spider->use_index_merge = TRUE;
|
||||
}
|
||||
DBUG_PRINT("info",("spider SQLCOM_HA_READ=%s",
|
||||
(spider->sql_command == SQLCOM_HA_READ) ? "TRUE" : "FALSE"));
|
||||
DBUG_PRINT("info",("spider sql_kinds with SPIDER_SQL_KIND_HANDLER=%s",
|
||||
(spider->sql_kinds & SPIDER_SQL_KIND_HANDLER) ? "TRUE" : "FALSE"));
|
||||
DBUG_PRINT("info",("spider has_clone_for_merge=%s",
|
||||
spider->has_clone_for_merge ? "TRUE" : "FALSE"));
|
||||
DBUG_PRINT("info",("spider use_index_merge=%s",
|
||||
spider->use_index_merge ? "TRUE" : "FALSE"));
|
||||
DBUG_PRINT("info",("spider is_clone=%s",
|
||||
spider->is_clone ? "TRUE" : "FALSE"));
|
||||
#ifdef HA_CAN_BULK_ACCESS
|
||||
|
@ -7946,7 +7963,7 @@ bool spider_check_direct_order_limit(
|
|||
#endif
|
||||
if (
|
||||
spider->sql_command != SQLCOM_HA_READ &&
|
||||
!spider->has_clone_for_merge &&
|
||||
!spider->use_index_merge &&
|
||||
#ifdef HA_CAN_BULK_ACCESS
|
||||
(!spider->is_clone || spider->is_bulk_access_clone)
|
||||
#else
|
||||
|
@ -7958,10 +7975,10 @@ bool spider_check_direct_order_limit(
|
|||
DBUG_PRINT("info",("spider select_lex=%p", select_lex));
|
||||
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000
|
||||
DBUG_PRINT("info",("spider leaf_tables.elements=%u",
|
||||
select_lex->leaf_tables.elements));
|
||||
select_lex ? select_lex->leaf_tables.elements : 0));
|
||||
#endif
|
||||
|
||||
if (select_lex->options & SELECT_DISTINCT)
|
||||
if (select_lex && (select_lex->options & SELECT_DISTINCT))
|
||||
{
|
||||
DBUG_PRINT("info",("spider with distinct"));
|
||||
spider->result_list.direct_distinct = TRUE;
|
||||
|
@ -7977,6 +7994,9 @@ bool spider_check_direct_order_limit(
|
|||
#else
|
||||
!(thd->variables.optimizer_switch &
|
||||
OPTIMIZER_SWITCH_ENGINE_CONDITION_PUSHDOWN) ||
|
||||
#endif
|
||||
#ifdef SPIDER_NEED_CHECK_CONDITION_AT_CHECKING_DIRECT_ORDER_LIMIT
|
||||
!spider->condition ||
|
||||
#endif
|
||||
!select_lex ||
|
||||
#if defined(MARIADB_BASE_VERSION) && MYSQL_VERSION_ID >= 100000
|
||||
|
@ -8044,19 +8064,19 @@ bool spider_check_direct_order_limit(
|
|||
DBUG_PRINT("info",("spider first_check=%s",
|
||||
first_check ? "TRUE" : "FALSE"));
|
||||
DBUG_PRINT("info",("spider (select_lex->options & OPTION_FOUND_ROWS)=%s",
|
||||
(select_lex->options & OPTION_FOUND_ROWS) ? "TRUE" : "FALSE"));
|
||||
select_lex && (select_lex->options & OPTION_FOUND_ROWS) ? "TRUE" : "FALSE"));
|
||||
#ifdef HANDLER_HAS_DIRECT_AGGREGATE
|
||||
DBUG_PRINT("info",("spider direct_aggregate=%s",
|
||||
spider->result_list.direct_aggregate ? "TRUE" : "FALSE"));
|
||||
#endif
|
||||
DBUG_PRINT("info",("spider select_lex->group_list.elements=%u",
|
||||
select_lex->group_list.elements));
|
||||
select_lex ? select_lex->group_list.elements : 0));
|
||||
DBUG_PRINT("info",("spider select_lex->with_sum_func=%s",
|
||||
select_lex->with_sum_func ? "TRUE" : "FALSE"));
|
||||
select_lex && select_lex->with_sum_func ? "TRUE" : "FALSE"));
|
||||
DBUG_PRINT("info",("spider select_lex->having=%s",
|
||||
select_lex->having ? "TRUE" : "FALSE"));
|
||||
select_lex && select_lex->having ? "TRUE" : "FALSE"));
|
||||
DBUG_PRINT("info",("spider select_lex->order_list.elements=%u",
|
||||
select_lex->order_list.elements));
|
||||
select_lex ? select_lex->order_list.elements : 0));
|
||||
if (
|
||||
!first_check ||
|
||||
!select_lex->explicit_limit ||
|
||||
|
@ -8098,6 +8118,63 @@ bool spider_check_direct_order_limit(
|
|||
DBUG_RETURN(FALSE);
|
||||
}
|
||||
|
||||
bool spider_check_index_merge(
|
||||
TABLE *table,
|
||||
st_select_lex *select_lex
|
||||
) {
|
||||
uint roop_count;
|
||||
JOIN *join;
|
||||
DBUG_ENTER("spider_check_index_merge");
|
||||
if (!select_lex)
|
||||
{
|
||||
DBUG_PRINT("info",("spider select_lex is null"));
|
||||
DBUG_RETURN(FALSE);
|
||||
}
|
||||
join = select_lex->join;
|
||||
if (!join)
|
||||
{
|
||||
DBUG_PRINT("info",("spider join is null"));
|
||||
DBUG_RETURN(FALSE);
|
||||
}
|
||||
for (roop_count = 0; roop_count < spider_join_table_count(join); ++roop_count)
|
||||
{
|
||||
JOIN_TAB *join_tab = &join->join_tab[roop_count];
|
||||
if (join_tab && join_tab->table == table)
|
||||
{
|
||||
DBUG_PRINT("info",("spider join_tab->type=%u", join_tab->type));
|
||||
if (
|
||||
#ifdef SPIDER_HAS_JT_HASH_INDEX_MERGE
|
||||
join_tab->type == JT_HASH_INDEX_MERGE ||
|
||||
#endif
|
||||
join_tab->type == JT_INDEX_MERGE
|
||||
) {
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
/*
|
||||
DBUG_PRINT("info",("spider join_tab->quick->get_type()=%u",
|
||||
join_tab->quick ? join_tab->quick->get_type() : 0));
|
||||
if (
|
||||
join_tab->quick &&
|
||||
join_tab->quick->get_type() == QUICK_SELECT_I::QS_TYPE_INDEX_MERGE
|
||||
) {
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
*/
|
||||
DBUG_PRINT("info",("spider join_tab->select->quick->get_type()=%u",
|
||||
join_tab->select && join_tab->select->quick ? join_tab->select->quick->get_type() : 0));
|
||||
if (
|
||||
join_tab->select &&
|
||||
join_tab->select->quick &&
|
||||
join_tab->select->quick->get_type() == QUICK_SELECT_I::QS_TYPE_INDEX_MERGE
|
||||
) {
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
DBUG_RETURN(FALSE);
|
||||
}
|
||||
|
||||
int spider_compare_for_sort(
|
||||
SPIDER_SORT *a,
|
||||
SPIDER_SORT *b
|
||||
|
|
|
@ -414,6 +414,11 @@ bool spider_check_direct_order_limit(
|
|||
ha_spider *spider
|
||||
);
|
||||
|
||||
bool spider_check_index_merge(
|
||||
TABLE *table,
|
||||
st_select_lex *select_lex
|
||||
);
|
||||
|
||||
int spider_compare_for_sort(
|
||||
SPIDER_SORT *a,
|
||||
SPIDER_SORT *b
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
||||
|
||||
#define MYSQL_SERVER 1
|
||||
#include <my_global.h>
|
||||
#include "mysql_version.h"
|
||||
#if MYSQL_VERSION_ID < 50500
|
||||
#include "mysql_priv.h"
|
||||
|
|
Loading…
Add table
Reference in a new issue