summaryrefslogtreecommitdiff
path: root/storage/spider/ha_spider.cc
diff options
context:
space:
mode:
authorKentoku <kentokushiba@gmail.com>2018-11-20 00:21:36 +0900
committerSachin <sachin.setiya@mariadb.com>2019-02-03 15:58:45 +0530
commit4a28a79e48c29b4938188136178e6f2ebd6ff7fe (patch)
tree1db038e1e7f7e3d62c621f829c7637971175fa14 /storage/spider/ha_spider.cc
parent74eb4fc9fc80a2836375b5ee380e55100e2cd1d3 (diff)
downloadmariadb-git-4a28a79e48c29b4938188136178e6f2ebd6ff7fe.tar.gz
Update Spider to version 3.3.14. Add direct left outer join/right outer join/inner join feature
Diffstat (limited to 'storage/spider/ha_spider.cc')
-rw-r--r--storage/spider/ha_spider.cc193
1 files changed, 148 insertions, 45 deletions
diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc
index 92b7d2c2ac1..92d195a7563 100644
--- a/storage/spider/ha_spider.cc
+++ b/storage/spider/ha_spider.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008-2017 Kentoku Shiba
+/* Copyright (C) 2008-2018 Kentoku Shiba
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -64,6 +64,9 @@ extern HASH spider_open_tables;
#endif
extern pthread_mutex_t spider_lgtm_tblhnd_share_mutex;
+/* UTC time zone for timestamp columns */
+extern Time_zone *UTC;
+
ha_spider::ha_spider(
) : handler(spider_hton_ptr, NULL)
{
@@ -7963,7 +7966,7 @@ int ha_spider::cmp_ref(
if ((ret = (*field)->cmp_binary_offset((uint) ptr_diff)))
{
DBUG_PRINT("info",("spider different at %s",
- (*field)->field_name.str));
+ SPIDER_field_name_str(*field)));
break;
}
}
@@ -9959,21 +9962,38 @@ int ha_spider::end_bulk_update(
DBUG_RETURN(0);
}
+#ifdef SPIDER_UPDATE_ROW_HAS_CONST_NEW_DATA
int ha_spider::bulk_update_row(
const uchar *old_data,
const uchar *new_data,
ha_rows *dup_key_found
-) {
+)
+#else
+int ha_spider::bulk_update_row(
+ const uchar *old_data,
+ uchar *new_data,
+ ha_rows *dup_key_found
+)
+#endif
+{
DBUG_ENTER("ha_spider::bulk_update_row");
DBUG_PRINT("info",("spider this=%p", this));
*dup_key_found = 0;
DBUG_RETURN(update_row(old_data, new_data));
}
+#ifdef SPIDER_UPDATE_ROW_HAS_CONST_NEW_DATA
int ha_spider::update_row(
const uchar *old_data,
const uchar *new_data
-) {
+)
+#else
+int ha_spider::update_row(
+ const uchar *old_data,
+ uchar *new_data
+)
+#endif
+{
int error_num;
THD *thd = ha_thd();
backup_error_status();
@@ -10064,10 +10084,24 @@ int ha_spider::update_row(
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS
-int ha_spider::direct_update_rows_init(List<Item> *update_fields, uint mode,
- KEY_MULTI_RANGE *ranges,
- uint range_count, bool sorted,
- const uchar *new_data)
+#ifdef SPIDER_MDEV_16246
+int ha_spider::direct_update_rows_init(
+ List<Item> *update_fields,
+ uint mode,
+ KEY_MULTI_RANGE *ranges,
+ uint range_count,
+ bool sorted,
+ uchar *new_data
+)
+#else
+int ha_spider::direct_update_rows_init(
+ uint mode,
+ KEY_MULTI_RANGE *ranges,
+ uint range_count,
+ bool sorted,
+ uchar *new_data
+)
+#endif
{
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
int error_num;
@@ -10095,8 +10129,13 @@ int ha_spider::direct_update_rows_init(List<Item> *update_fields, uint mode,
pre_direct_init_result));
DBUG_RETURN(pre_direct_init_result);
}
+#ifdef SPIDER_MDEV_16246
DBUG_RETURN(bulk_access_link_exec_tgt->spider->direct_update_rows_init(
update_fields, mode, ranges, range_count, sorted, new_data));
+#else
+ DBUG_RETURN(bulk_access_link_exec_tgt->spider->direct_update_rows_init(
+ mode, ranges, range_count, sorted, new_data));
+#endif
}
#endif
direct_update_init(
@@ -10200,6 +10239,7 @@ int ha_spider::direct_update_rows_init(List<Item> *update_fields, uint mode,
DBUG_RETURN(HA_ERR_WRONG_COMMAND);
}
#else
+#ifdef SPIDER_MDEV_16246
/**
Perform initialization for a direct update request.
@@ -10209,37 +10249,43 @@ int ha_spider::direct_update_rows_init(List<Item> *update_fields, uint mode,
0 Success.
*/
-int ha_spider::direct_update_rows_init(List<Item> *update_fields)
+int ha_spider::direct_update_rows_init(
+ List<Item> *update_fields
+)
+#else
+int ha_spider::direct_update_rows_init()
+#endif
{
st_select_lex *select_lex;
longlong select_limit;
longlong offset_limit;
- List_iterator<Item> it(*update_fields);
+ List_iterator<Item> it(*direct_update_fields);
Item *item;
Field *field;
THD *thd = trx->thd;
DBUG_ENTER("ha_spider::direct_update_rows_init");
DBUG_PRINT("info",("spider this=%p", this));
-
- while ((item = it++))
+ if (thd->variables.time_zone != UTC)
{
- if (item->type() == Item::FIELD_ITEM)
+ while ((item = it++))
{
- field = ((Item_field *)item)->field;
-
- if (field->type() == FIELD_TYPE_TIMESTAMP &&
- field->flags & UNIQUE_KEY_FLAG)
+ if (item->type() == Item::FIELD_ITEM)
{
- /*
- Spider cannot perform direct update on unique timestamp fields.
- To avoid false duplicate key errors, the table needs to be
- updated one row at a time.
- */
- DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+ field = ((Item_field *)item)->field;
+
+ if (field->type() == FIELD_TYPE_TIMESTAMP &&
+ field->flags & UNIQUE_KEY_FLAG)
+ {
+ /*
+ Spider cannot perform direct update on unique timestamp fields.
+ To avoid false duplicate key errors, the table needs to be
+ updated one row at a time.
+ */
+ DBUG_RETURN(HA_ERR_WRONG_COMMAND);
+ }
}
}
}
-
#ifdef HA_CAN_BULK_ACCESS
if (
bulk_access_executing &&
@@ -10257,8 +10303,12 @@ int ha_spider::direct_update_rows_init(List<Item> *update_fields)
pre_direct_init_result));
DBUG_RETURN(pre_direct_init_result);
}
+#ifdef SPIDER_MDEV_16246
DBUG_RETURN(bulk_access_link_exec_tgt->spider->
- direct_update_rows_init(List<Item> *update_fields));
+ direct_update_rows_init(update_fields));
+#else
+ DBUG_RETURN(bulk_access_link_exec_tgt->spider->direct_update_rows_init());
+#endif
}
#endif
direct_update_init(
@@ -10329,30 +10379,54 @@ int ha_spider::direct_update_rows_init(List<Item> *update_fields)
#ifdef HA_CAN_BULK_ACCESS
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS_WITH_HS
-int ha_spider::pre_direct_update_rows_init(List<Item> *update_fields,
- uint mode,
- KEY_MULTI_RANGE *ranges,
- uint range_count, bool sorted,
- const uchar *new_data)
+#ifdef SPIDER_MDEV_16246
+int ha_spider::pre_direct_update_rows_init(
+ List<Item> *update_fields,
+ uint mode,
+ KEY_MULTI_RANGE *ranges,
+ uint range_count,
+ bool sorted,
+ uchar *new_data
+)
+#else
+int ha_spider::pre_direct_update_rows_init(
+ uint mode,
+ KEY_MULTI_RANGE *ranges,
+ uint range_count,
+ bool sorted,
+ uchar *new_data
+)
+#endif
{
int error_num;
DBUG_ENTER("ha_spider::pre_direct_update_rows_init");
DBUG_PRINT("info",("spider this=%p", this));
if (bulk_access_started)
{
+#ifdef SPIDER_MDEV_16246
error_num = bulk_access_link_current->spider->
- pre_direct_update_rows_init(update_fields, mode, ranges, range_count,
- sorted, new_data);
+ pre_direct_update_rows_init(
+ update_fields, mode, ranges, range_count, sorted, new_data);
+#else
+ error_num = bulk_access_link_current->spider->
+ pre_direct_update_rows_init(
+ mode, ranges, range_count, sorted, new_data);
+#endif
bulk_access_link_current->spider->bulk_access_pre_called = TRUE;
bulk_access_link_current->called = TRUE;
DBUG_RETURN(error_num);
}
- pre_direct_init_result = direct_update_rows_init(update_fields, mode,
- ranges, range_count,
- sorted, new_data);
+#ifdef SPIDER_MDEV_16246
+ pre_direct_init_result = direct_update_rows_init(
+ update_fields, mode, ranges, range_count, sorted, new_data);
+#else
+ pre_direct_init_result = direct_update_rows_init(
+ mode, ranges, range_count, sorted, new_data);
+#endif
DBUG_RETURN(pre_direct_init_result);
}
#else
+#ifdef SPIDER_MDEV_16246
/**
Do initialization for performing parallel direct update
for a handlersocket update request.
@@ -10363,20 +10437,34 @@ int ha_spider::pre_direct_update_rows_init(List<Item> *update_fields,
0 Success.
*/
-int ha_spider::pre_direct_update_rows_init(List<Item> *update_fields)
+int ha_spider::pre_direct_update_rows_init(
+ List<Item> *update_fields
+)
+#else
+int ha_spider::pre_direct_update_rows_init()
+#endif
{
int error_num;
DBUG_ENTER("ha_spider::pre_direct_update_rows_init");
DBUG_PRINT("info",("spider this=%p", this));
if (bulk_access_started)
{
+#ifdef SPIDER_MDEV_16246
error_num = bulk_access_link_current->spider->
- pre_direct_update_rows_init(update_fields);
+ pre_direct_update_rows_init(update_fields);
+#else
+ error_num = bulk_access_link_current->spider->
+ pre_direct_update_rows_init();
+#endif
bulk_access_link_current->spider->bulk_access_pre_called = TRUE;
bulk_access_link_current->called = TRUE;
DBUG_RETURN(error_num);
}
+#ifdef SPIDER_MDEV_16246
pre_direct_init_result = direct_update_rows_init(update_fields);
+#else
+ pre_direct_init_result = direct_update_rows_init();
+#endif
DBUG_RETURN(pre_direct_init_result);
}
#endif
@@ -11305,7 +11393,7 @@ int ha_spider::create(
DBUG_PRINT("info",
("spider alter_info.flags: %llu alter_info.partition_flags: %lu",
- thd->lex->alter_info.flags, thd->lex->alter_info.partition_flags));
+ 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 |
@@ -11501,7 +11589,7 @@ int ha_spider::rename_table(
DBUG_PRINT("info",
("spider alter_info.flags: %llu alter_info.partition_flags: %lu",
- thd->lex->alter_info.flags, thd->lex->alter_info.partition_flags));
+ thd->lex->alter_info.flags, thd->lex->alter_info.partition_flags));
if (
(thd->lex->alter_info.partition_flags &
(
@@ -11697,7 +11785,7 @@ int ha_spider::delete_table(
DBUG_PRINT("info",
("spider alter_info.flags: %llu alter_info.partition_flags: %lu",
- thd->lex->alter_info.flags, thd->lex->alter_info.partition_flags));
+ thd->lex->alter_info.flags, thd->lex->alter_info.partition_flags));
if (
sql_command == SQLCOM_ALTER_TABLE &&
(thd->lex->alter_info.partition_flags &
@@ -13514,6 +13602,7 @@ void ha_spider::check_pre_call(
bool use_parallel
) {
THD* thd = ha_thd();
+ LEX *lex = thd->lex;
st_select_lex *select_lex = spider_get_select_lex(this);
int skip_parallel_search =
spider_param_skip_parallel_search(thd, share->skip_parallel_search);
@@ -13522,11 +13611,15 @@ void ha_spider::check_pre_call(
if (
(
(skip_parallel_search & 1) &&
- thd->lex && thd->lex->sql_command != SQLCOM_SELECT // such like insert .. select ..
+ lex->sql_command != SQLCOM_SELECT // such like insert .. select ..
) ||
(
(skip_parallel_search & 2) &&
- thd->lex->sql_cache == LEX::SQL_NO_CACHE // for mysqldump
+#ifdef SPIDER_SQL_CACHE_IS_IN_LEX
+ lex->sql_cache == LEX::SQL_NO_CACHE // for mysqldump
+#else
+ select_lex && select_lex->sql_cache == SELECT_LEX::SQL_NO_CACHE // for mysqldump
+#endif
)
) {
use_pre_call = FALSE;
@@ -15672,12 +15765,23 @@ 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] &&
+ !(tmp_table[roop_count] = spider_mk_sys_tmp_table(
+ trx->thd, table, &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(
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;
}
@@ -15775,8 +15879,7 @@ int ha_spider::print_item_type(
if (
dbton_hdl->first_link_idx >= 0 &&
(error_num = spider_db_print_item_type(item, NULL, this, str,
- alias, alias_length, dbton_id,
- FALSE, NULL))
+ alias, alias_length, dbton_id, FALSE, NULL))
) {
DBUG_RETURN(error_num);
}