bgs for show records

This commit is contained in:
Kentoku SHIBA 2014-03-25 05:12:36 +09:00
parent 74195f40b4
commit 7d74d0f6d8
9 changed files with 114 additions and 19 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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;
}

View file

@ -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(

View file

@ -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);
}

View file

@ -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(

View file

@ -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;

View file

@ -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;

View file

@ -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