summaryrefslogtreecommitdiff
path: root/storage/spider
diff options
context:
space:
mode:
authorKentoku SHIBA <kentokushiba@gmail.com>2014-03-25 05:12:36 +0900
committerKentoku SHIBA <kentokushiba@gmail.com>2014-03-25 05:12:36 +0900
commit7d74d0f6d80475dd3d24c206305e372836eddde4 (patch)
tree54ea0c633d872e8e8862390cc1fb21bbcfb3979d /storage/spider
parent74195f40b49070b949822361deeba97c383cd0e7 (diff)
downloadmariadb-git-7d74d0f6d80475dd3d24c206305e372836eddde4.tar.gz
bgs for show records
Diffstat (limited to 'storage/spider')
-rw-r--r--storage/spider/ha_spider.cc33
-rw-r--r--storage/spider/ha_spider.h3
-rw-r--r--storage/spider/spd_conn.cc39
-rw-r--r--storage/spider/spd_conn.h7
-rw-r--r--storage/spider/spd_db_conn.cc36
-rw-r--r--storage/spider/spd_db_conn.h3
-rw-r--r--storage/spider/spd_db_mysql.cc2
-rw-r--r--storage/spider/spd_db_oracle.cc8
-rw-r--r--storage/spider/spd_include.h2
9 files changed, 114 insertions, 19 deletions
diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc
index 7d8ad886200..50b5fb587fe 100644
--- a/storage/spider/ha_spider.cc
+++ b/storage/spider/ha_spider.cc
@@ -101,6 +101,7 @@ ha_spider::ha_spider(
error_mode = 0;
use_spatial_index = FALSE;
use_pre_call = FALSE;
+ use_pre_records = FALSE;
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
do_direct_update = FALSE;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
@@ -203,6 +204,7 @@ ha_spider::ha_spider(
error_mode = 0;
use_spatial_index = FALSE;
use_pre_call = FALSE;
+ use_pre_records = FALSE;
#ifdef HANDLER_HAS_DIRECT_UPDATE_ROWS
do_direct_update = FALSE;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
@@ -1704,6 +1706,7 @@ int ha_spider::reset()
high_priority = FALSE;
insert_delayed = FALSE;
use_pre_call = FALSE;
+ use_pre_records = FALSE;
bulk_insert = FALSE;
clone_bitmap_init = FALSE;
result_list.tmp_table_join = FALSE;
@@ -8676,6 +8679,24 @@ int ha_spider::check_crd()
DBUG_RETURN(0);
}
+int ha_spider::pre_records()
+{
+ int error_num;
+ backup_error_status();
+ DBUG_ENTER("ha_spider::pre_records");
+ DBUG_PRINT("info",("spider this=%p", this));
+ if (sql_command == SQLCOM_ALTER_TABLE)
+ {
+ DBUG_RETURN(0);
+ }
+ if ((error_num = spider_db_show_records(this, search_link_idx, TRUE)))
+ {
+ DBUG_RETURN(check_error_mode(error_num));
+ }
+ use_pre_records = TRUE;
+ DBUG_RETURN(0);
+}
+
ha_rows ha_spider::records()
{
int error_num;
@@ -8684,14 +8705,18 @@ ha_rows ha_spider::records()
DBUG_PRINT("info",("spider this=%p", this));
if (sql_command == SQLCOM_ALTER_TABLE)
{
+ use_pre_records = FALSE;
DBUG_RETURN(0);
}
- if ((error_num = spider_db_show_records(this, search_link_idx)))
+ if ((error_num = spider_db_show_records(this, search_link_idx, FALSE)))
{
+ use_pre_records = FALSE;
check_error_mode(error_num);
DBUG_RETURN(HA_POS_ERROR);
}
- DBUG_RETURN(share->records);
+ use_pre_records = FALSE;
+ share->records = table_rows;
+ DBUG_RETURN(table_rows);
}
const char *ha_spider::table_type() const
@@ -9364,7 +9389,9 @@ int ha_spider::direct_update_rows_init(
bool sorted,
uchar *new_data
) {
+#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
int error_num;
+#endif
st_select_lex *select_lex;
longlong select_limit;
longlong offset_limit;
@@ -9658,7 +9685,9 @@ int ha_spider::direct_delete_rows_init(
uint range_count,
bool sorted
) {
+#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
int error_num;
+#endif
st_select_lex *select_lex;
longlong select_limit;
longlong offset_limit;
diff --git a/storage/spider/ha_spider.h b/storage/spider/ha_spider.h
index 79e3ebbe327..0af8127dca6 100644
--- a/storage/spider/ha_spider.h
+++ b/storage/spider/ha_spider.h
@@ -166,6 +166,7 @@ public:
bool high_priority;
bool insert_delayed;
bool use_pre_call;
+ bool use_pre_records;
enum thr_lock_type lock_type;
int lock_mode;
uint sql_command;
@@ -236,6 +237,7 @@ public:
SPIDER_ITEM_HLD *direct_aggregate_item_first;
SPIDER_ITEM_HLD *direct_aggregate_item_current;
#endif
+ ha_rows table_rows;
/* for fulltext search */
bool ft_init_and_first;
@@ -495,6 +497,7 @@ public:
key_range *end_key
);
int check_crd();
+ int pre_records();
ha_rows records();
const char *table_type() const;
ulonglong table_flags() const;
diff --git a/storage/spider/spd_conn.cc b/storage/spider/spd_conn.cc
index 6fbba3abf5c..8706633fa87 100644
--- a/storage/spider/spd_conn.cc
+++ b/storage/spider/spd_conn.cc
@@ -2096,18 +2096,38 @@ int spider_bg_conn_search(
void spider_bg_conn_simple_action(
SPIDER_CONN *conn,
- uint simple_action
+ uint simple_action,
+ bool caller_wait,
+ void *target,
+ uint link_idx,
+ int *error_num
) {
DBUG_ENTER("spider_bg_conn_simple_action");
pthread_mutex_lock(&conn->bg_conn_mutex);
- conn->bg_caller_wait = TRUE;
+ conn->bg_target = target;
+ conn->link_idx = link_idx;
conn->bg_simple_action = simple_action;
- pthread_mutex_lock(&conn->bg_conn_sync_mutex);
+ conn->bg_error_num = error_num;
+ if (caller_wait)
+ {
+ conn->bg_caller_wait = TRUE;
+ pthread_mutex_lock(&conn->bg_conn_sync_mutex);
+ } else {
+ conn->bg_caller_sync_wait = TRUE;
+ pthread_mutex_lock(&conn->bg_conn_sync_mutex);
+ }
pthread_cond_signal(&conn->bg_conn_cond);
pthread_mutex_unlock(&conn->bg_conn_mutex);
- pthread_cond_wait(&conn->bg_conn_sync_cond, &conn->bg_conn_sync_mutex);
- pthread_mutex_unlock(&conn->bg_conn_sync_mutex);
- conn->bg_caller_wait = FALSE;
+ if (caller_wait)
+ {
+ pthread_cond_wait(&conn->bg_conn_sync_cond, &conn->bg_conn_sync_mutex);
+ pthread_mutex_unlock(&conn->bg_conn_sync_mutex);
+ conn->bg_caller_wait = FALSE;
+ } else {
+ pthread_cond_wait(&conn->bg_conn_sync_cond, &conn->bg_conn_sync_mutex);
+ pthread_mutex_unlock(&conn->bg_conn_sync_mutex);
+ conn->bg_caller_sync_wait = FALSE;
+ }
DBUG_VOID_RETURN;
}
@@ -2450,6 +2470,13 @@ void *spider_bg_conn_action(
case SPIDER_BG_SIMPLE_DISCONNECT:
conn->db_conn->bg_disconnect();
break;
+ case SPIDER_BG_SIMPLE_RECORDS:
+ DBUG_PRINT("info",("spider bg simple records"));
+ spider = (ha_spider*) conn->bg_target;
+ *conn->bg_error_num =
+ spider->dbton_handler[conn->dbton_id]->
+ show_records(conn->link_idx);
+ break;
default:
break;
}
diff --git a/storage/spider/spd_conn.h b/storage/spider/spd_conn.h
index 9dc8f3495fd..044bc7c8ebf 100644
--- a/storage/spider/spd_conn.h
+++ b/storage/spider/spd_conn.h
@@ -20,6 +20,7 @@
#define SPIDER_BG_SIMPLE_NO_ACTION 0
#define SPIDER_BG_SIMPLE_CONNECT 1
#define SPIDER_BG_SIMPLE_DISCONNECT 2
+#define SPIDER_BG_SIMPLE_RECORDS 3
uchar *spider_conn_get_key(
SPIDER_CONN *conn,
@@ -220,7 +221,11 @@ int spider_bg_conn_search(
void spider_bg_conn_simple_action(
SPIDER_CONN *conn,
- uint simple_action
+ uint simple_action,
+ bool caller_wait,
+ void *target,
+ uint link_idx,
+ int *error_num
);
void *spider_bg_conn_action(
diff --git a/storage/spider/spd_db_conn.cc b/storage/spider/spd_db_conn.cc
index 23f487b9c56..2cb9408e233 100644
--- a/storage/spider/spd_db_conn.cc
+++ b/storage/spider/spd_db_conn.cc
@@ -5173,14 +5173,42 @@ int spider_db_show_table_status(
int spider_db_show_records(
ha_spider *spider,
- int link_idx
+ int link_idx,
+ bool pre_call
) {
int error_num;
SPIDER_CONN *conn = spider->conns[link_idx];
DBUG_ENTER("spider_db_show_records");
- error_num = spider->dbton_handler[conn->dbton_id]->show_records(
- link_idx
- );
+ if (pre_call)
+ {
+ if (spider_param_bgs_mode(spider->trx->thd, spider->share->bgs_mode))
+ {
+ if (!(error_num = spider_create_conn_thread(conn)))
+ {
+ spider_bg_conn_simple_action(conn, SPIDER_BG_SIMPLE_RECORDS, FALSE,
+ spider, link_idx, (int *) &spider->result_list.bgs_error);
+ }
+ } else {
+ error_num = spider->dbton_handler[conn->dbton_id]->show_records(
+ link_idx
+ );
+ }
+ } else {
+ if (spider->use_pre_records)
+ {
+ if (spider_param_bgs_mode(spider->trx->thd, spider->share->bgs_mode))
+ {
+ spider_bg_conn_wait(conn);
+ error_num = spider->result_list.bgs_error;
+ } else {
+ error_num = 0;
+ }
+ } else {
+ error_num = spider->dbton_handler[conn->dbton_id]->show_records(
+ link_idx
+ );
+ }
+ }
DBUG_RETURN(error_num);
}
diff --git a/storage/spider/spd_db_conn.h b/storage/spider/spd_db_conn.h
index 3a5cc1b6181..76ff567ba35 100644
--- a/storage/spider/spd_db_conn.h
+++ b/storage/spider/spd_db_conn.h
@@ -639,7 +639,8 @@ int spider_db_show_table_status(
int spider_db_show_records(
ha_spider *spider,
- int link_idx
+ int link_idx,
+ bool pre_call
);
void spider_db_set_cardinarity(
diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc
index 44f48495a67..ebb45e43a11 100644
--- a/storage/spider/spd_db_mysql.cc
+++ b/storage/spider/spd_db_mysql.cc
@@ -10454,7 +10454,7 @@ int spider_mysql_handler::show_records(
pthread_mutex_unlock(&conn->mta_conn_mutex);
error_num = res->fetch_table_records(
1,
- share->records
+ spider->table_rows
);
res->free_result();
delete res;
diff --git a/storage/spider/spd_db_oracle.cc b/storage/spider/spd_db_oracle.cc
index a2abc90fdaf..7ed0273a539 100644
--- a/storage/spider/spd_db_oracle.cc
+++ b/storage/spider/spd_db_oracle.cc
@@ -1311,7 +1311,8 @@ int spider_db_oracle::connect(
this->connect_retry_interval = connect_retry_interval;
if ((error_num = spider_create_conn_thread(conn)))
DBUG_RETURN(error_num);
- spider_bg_conn_simple_action(conn, SPIDER_BG_SIMPLE_CONNECT);
+ spider_bg_conn_simple_action(conn, SPIDER_BG_SIMPLE_CONNECT, TRUE, NULL,
+ 0, NULL);
if (stored_error_num)
{
@@ -1401,7 +1402,8 @@ void spider_db_oracle::disconnect()
DBUG_PRINT("info",("spider this=%p", this));
if (!conn->bg_init)
DBUG_VOID_RETURN;
- spider_bg_conn_simple_action(conn, SPIDER_BG_SIMPLE_DISCONNECT);
+ spider_bg_conn_simple_action(conn, SPIDER_BG_SIMPLE_DISCONNECT, TRUE, NULL,
+ 0, NULL);
DBUG_VOID_RETURN;
}
@@ -10779,7 +10781,7 @@ int spider_oracle_handler::show_records(
pthread_mutex_unlock(&conn->mta_conn_mutex);
error_num = res->fetch_table_records(
1,
- share->records
+ spider->table_rows
);
res->free_result();
delete res;
diff --git a/storage/spider/spd_include.h b/storage/spider/spd_include.h
index 060dabd3194..da6c16be53c 100644
--- a/storage/spider/spd_include.h
+++ b/storage/spider/spd_include.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.1.9"
+#define SPIDER_DETAIL_VERSION "3.1.11"
#define SPIDER_HEX_VERSION 0x0301
#if MYSQL_VERSION_ID < 50500