Commit 793b84b8 authored by Kentoku SHIBA's avatar Kentoku SHIBA

add a table parameter "dsn" to Spider

parent 932baa94
......@@ -566,6 +566,7 @@ SPIDER_CONN *spider_create_conn(
char *tmp_name, *tmp_host, *tmp_username, *tmp_password, *tmp_socket;
char *tmp_wrapper, *tmp_db, *tmp_ssl_ca, *tmp_ssl_capath, *tmp_ssl_cert;
char *tmp_ssl_cipher, *tmp_ssl_key, *tmp_default_file, *tmp_default_group;
char *tmp_dsn;
DBUG_ENTER("spider_create_conn");
if (unlikely(!UTC))
......@@ -615,6 +616,8 @@ SPIDER_CONN *spider_create_conn(
(uint) (share->tgt_default_files_lengths[link_idx] + 1),
&tmp_default_group,
(uint) (share->tgt_default_groups_lengths[link_idx] + 1),
&tmp_dsn,
(uint) (share->tgt_dsns_lengths[link_idx] + 1),
&need_mon, (uint) (sizeof(int)),
NullS))
) {
......@@ -714,6 +717,15 @@ SPIDER_CONN *spider_create_conn(
share->tgt_default_groups_lengths[link_idx]);
} else
conn->tgt_default_group = NULL;
conn->tgt_dsn_length =
share->tgt_dsns_lengths[link_idx];
if (conn->tgt_dsn_length)
{
conn->tgt_dsn = tmp_dsn;
memcpy(conn->tgt_dsn, share->tgt_dsns[link_idx],
share->tgt_dsns_lengths[link_idx]);
} else
conn->tgt_dsn = NULL;
conn->tgt_port = share->tgt_ports[link_idx];
conn->tgt_ssl_vsc = share->tgt_ssl_vscs[link_idx];
conn->dbton_id = share->sql_dbton_ids[link_idx];
......
......@@ -288,7 +288,8 @@ int spider_udf_direct_sql_create_conn_key(
+ direct_sql->tgt_ssl_key_length + 1
+ 1 + 1
+ direct_sql->tgt_default_file_length + 1
+ direct_sql->tgt_default_group_length;
+ direct_sql->tgt_default_group_length + 1
+ direct_sql->tgt_dsn_length;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
} else {
direct_sql->conn_key_length
......@@ -395,6 +396,13 @@ int spider_udf_direct_sql_create_conn_key(
tmp_name = strmov(tmp_name + 1, direct_sql->tgt_default_group);
} else
tmp_name++;
if (direct_sql->tgt_dsn)
{
DBUG_PRINT("info",("spider tgt_dsn=%s",
direct_sql->tgt_dsn));
tmp_name = strmov(tmp_name + 1, direct_sql->tgt_dsn);
} else
tmp_name++;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
}
#endif
......@@ -414,6 +422,7 @@ SPIDER_CONN *spider_udf_direct_sql_create_conn(
char *tmp_name, *tmp_host, *tmp_username, *tmp_password, *tmp_socket;
char *tmp_wrapper, *tmp_db, *tmp_ssl_ca, *tmp_ssl_capath, *tmp_ssl_cert;
char *tmp_ssl_cipher, *tmp_ssl_key, *tmp_default_file, *tmp_default_group;
char *tmp_dsn;
int *need_mon;
bool tables_on_different_db_are_joinable = TRUE;
DBUG_ENTER("spider_udf_direct_sql_create_conn");
......@@ -452,6 +461,8 @@ SPIDER_CONN *spider_udf_direct_sql_create_conn(
(uint) (direct_sql->tgt_default_file_length + 1),
&tmp_default_group,
(uint) (direct_sql->tgt_default_group_length + 1),
&tmp_dsn,
(uint) (direct_sql->tgt_dsn_length + 1),
&need_mon, (uint) (sizeof(int)),
NullS))
) {
......@@ -568,6 +579,14 @@ SPIDER_CONN *spider_udf_direct_sql_create_conn(
direct_sql->tgt_default_group_length);
} else
conn->tgt_default_group = NULL;
conn->tgt_dsn_length = direct_sql->tgt_dsn_length;
if (conn->tgt_dsn_length)
{
conn->tgt_dsn = tmp_dsn;
memcpy(conn->tgt_dsn, direct_sql->tgt_dsn,
direct_sql->tgt_dsn_length);
} else
conn->tgt_dsn = NULL;
conn->tgt_ssl_vsc = direct_sql->tgt_ssl_vsc;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
} else {
......@@ -1238,6 +1257,7 @@ int spider_udf_parse_direct_sql_param(
SPIDER_PARAM_INT("cto", connect_timeout, 0);
SPIDER_PARAM_STR("dff", tgt_default_file);
SPIDER_PARAM_STR("dfg", tgt_default_group);
SPIDER_PARAM_STR("dsn", tgt_dsn);
SPIDER_PARAM_LONGLONG("prt", priority, 0);
SPIDER_PARAM_INT("rto", net_read_timeout, 0);
SPIDER_PARAM_STR("sca", tgt_ssl_ca);
......@@ -1661,6 +1681,10 @@ void spider_udf_free_direct_sql_alloc(
{
spider_free(spider_current_trx, direct_sql->tgt_default_group, MYF(0));
}
if (direct_sql->tgt_dsn)
{
spider_free(spider_current_trx, direct_sql->tgt_dsn, MYF(0));
}
if (direct_sql->conn_key)
{
spider_free(spider_current_trx, direct_sql->conn_key, MYF(0));
......
......@@ -256,8 +256,8 @@ const char SPIDER_empty_string = "";
#define SPIDER_LINK_MON_DRAW_FEW_MON 1
#define SPIDER_LINK_MON_DRAW 2
#define SPIDER_TMP_SHARE_CHAR_PTR_COUNT 20
#define SPIDER_TMP_SHARE_UINT_COUNT 17
#define SPIDER_TMP_SHARE_CHAR_PTR_COUNT 21
#define SPIDER_TMP_SHARE_UINT_COUNT SPIDER_TMP_SHARE_CHAR_PTR_COUNT
#define SPIDER_TMP_SHARE_LONG_COUNT 19
#define SPIDER_TMP_SHARE_LONGLONG_COUNT 3
......@@ -351,6 +351,7 @@ typedef struct st_spider_alter_table
char **tmp_tgt_ssl_keys;
char **tmp_tgt_default_files;
char **tmp_tgt_default_groups;
char **tmp_tgt_dsns;
char **tmp_static_link_ids;
long *tmp_tgt_ports;
long *tmp_tgt_ssl_vscs;
......@@ -372,6 +373,7 @@ typedef struct st_spider_alter_table
uint *tmp_tgt_ssl_keys_lengths;
uint *tmp_tgt_default_files_lengths;
uint *tmp_tgt_default_groups_lengths;
uint *tmp_tgt_dsns_lengths;
uint *tmp_static_link_ids_lengths;
uint tmp_server_names_charlen;
......@@ -389,6 +391,7 @@ typedef struct st_spider_alter_table
uint tmp_tgt_ssl_keys_charlen;
uint tmp_tgt_default_files_charlen;
uint tmp_tgt_default_groups_charlen;
uint tmp_tgt_dsns_charlen;
uint tmp_static_link_ids_charlen;
uint tmp_server_names_length;
......@@ -406,6 +409,7 @@ typedef struct st_spider_alter_table
uint tmp_tgt_ssl_keys_length;
uint tmp_tgt_default_files_length;
uint tmp_tgt_default_groups_length;
uint tmp_tgt_dsns_length;
uint tmp_static_link_ids_length;
uint tmp_tgt_ports_length;
uint tmp_tgt_ssl_vscs_length;
......@@ -490,6 +494,7 @@ typedef struct st_spider_conn
char *tgt_ssl_key;
char *tgt_default_file;
char *tgt_default_group;
char *tgt_dsn;
long tgt_port;
long tgt_ssl_vsc;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
......@@ -510,6 +515,7 @@ typedef struct st_spider_conn
uint tgt_ssl_key_length;
uint tgt_default_file_length;
uint tgt_default_group_length;
uint tgt_dsn_length;
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
uint hs_sock_length;
#endif
......@@ -1119,6 +1125,7 @@ typedef struct st_spider_share
char **tgt_ssl_keys;
char **tgt_default_files;
char **tgt_default_groups;
char **tgt_dsns;
char **static_link_ids;
char **tgt_pk_names;
char **tgt_sequence_names;
......@@ -1173,6 +1180,7 @@ typedef struct st_spider_share
uint *tgt_ssl_keys_lengths;
uint *tgt_default_files_lengths;
uint *tgt_default_groups_lengths;
uint *tgt_dsns_lengths;
uint *static_link_ids_lengths;
uint *tgt_pk_names_lengths;
uint *tgt_sequence_names_lengths;
......@@ -1203,6 +1211,7 @@ typedef struct st_spider_share
uint tgt_ssl_keys_charlen;
uint tgt_default_files_charlen;
uint tgt_default_groups_charlen;
uint tgt_dsns_charlen;
uint static_link_ids_charlen;
uint tgt_pk_names_charlen;
uint tgt_sequence_names_charlen;
......@@ -1229,6 +1238,7 @@ typedef struct st_spider_share
uint tgt_ssl_keys_length;
uint tgt_default_files_length;
uint tgt_default_groups_length;
uint tgt_dsns_length;
uint static_link_ids_length;
uint tgt_pk_names_length;
uint tgt_sequence_names_length;
......@@ -1363,6 +1373,7 @@ typedef struct st_spider_direct_sql
char *tgt_ssl_key;
char *tgt_default_file;
char *tgt_default_group;
char *tgt_dsn;
char *conn_key;
long tgt_port;
long tgt_ssl_vsc;
......@@ -1381,6 +1392,7 @@ typedef struct st_spider_direct_sql
uint tgt_ssl_key_length;
uint tgt_default_file_length;
uint tgt_default_group_length;
uint tgt_dsn_length;
uint conn_key_length;
uint dbton_id;
#ifdef SPIDER_HAS_HASH_VALUE_TYPE
......
......@@ -51,6 +51,7 @@ static LEX_STRING spider_init_queries[] = {
" ssl_verify_server_cert tinyint not null default 0,"
" default_file text,"
" default_group char(64) default null,"
" dsn char(64) default null,"
" key idx1 (data, format_id, gtrid_length, host)"
") engine=MyISAM default charset=utf8 collate=utf8_bin"
)},
......@@ -74,6 +75,7 @@ static LEX_STRING spider_init_queries[] = {
" ssl_verify_server_cert tinyint not null default 0,"
" default_file text,"
" default_group char(64) default null,"
" dsn char(64) default null,"
" thread_id int default null,"
" status char(8) not null default '',"
" failed_time timestamp not null default current_timestamp,"
......@@ -102,6 +104,7 @@ static LEX_STRING spider_init_queries[] = {
" monitoring_binlog_pos_at_failing tinyint not null default 0,"
" default_file text,"
" default_group char(64) default null,"
" dsn char(64) default null,"
" tgt_db_name char(64) default null,"
" tgt_table_name char(64) default null,"
" link_status tinyint not null default 1,"
......@@ -133,6 +136,7 @@ static LEX_STRING spider_init_queries[] = {
" ssl_verify_server_cert tinyint not null default 0,"
" default_file text,"
" default_group char(64) default null,"
" dsn char(64) default null,"
" primary key (db_name, table_name, link_id, sid)"
") engine=MyISAM default charset=utf8 collate=utf8_bin"
)},
......@@ -595,6 +599,21 @@ static LEX_STRING spider_init_queries[] = {
" primary key (db_name, table_name, table_id, partition_id)"
" ) engine=Aria transactional=1 default charset=utf8 collate=utf8_bin;"
" end if;"
/*
Fix for version 3.4
*/
" call mysql.spider_fix_one_table('spider_link_mon_servers', 'dsn',"
" 'alter table mysql.spider_link_mon_servers"
" add column dsn char(64) default null after default_group');"
" call mysql.spider_fix_one_table('spider_tables', 'dsn',"
" 'alter table mysql.spider_tables"
" add column dsn char(64) default null after default_group');"
" call mysql.spider_fix_one_table('spider_xa_failed_log', 'dsn',"
" 'alter table mysql.spider_xa_failed_log"
" add column dsn char(64) default null after default_group');"
" call mysql.spider_fix_one_table('spider_xa_member', 'dsn',"
" 'alter table mysql.spider_xa_member"
" add column dsn char(64) default null after default_group');"
"end;"
)},
{C_STRING_WITH_LEN(
......
This diff is collapsed.
......@@ -51,15 +51,15 @@
#define SPIDER_SYS_XA_COL_CNT 5
#define SPIDER_SYS_XA_PK_COL_CNT 3
#define SPIDER_SYS_XA_IDX1_COL_CNT 1
#define SPIDER_SYS_XA_MEMBER_COL_CNT 18
#define SPIDER_SYS_XA_MEMBER_COL_CNT 19
#define SPIDER_SYS_XA_MEMBER_PK_COL_CNT 6
#define SPIDER_SYS_TABLES_COL_CNT 25
#define SPIDER_SYS_TABLES_COL_CNT 26
#define SPIDER_SYS_TABLES_PK_COL_CNT 3
#define SPIDER_SYS_TABLES_IDX1_COL_CNT 1
#define SPIDER_SYS_TABLES_UIDX1_COL_CNT 3
#define SPIDER_SYS_LINK_MON_TABLE_COL_CNT 19
#define SPIDER_SYS_LINK_MON_TABLE_COL_CNT 20
#define SPIDER_SYS_LINK_FAILED_TABLE_COL_CNT 4
#define SPIDER_SYS_XA_FAILED_TABLE_COL_CNT 21
#define SPIDER_SYS_XA_FAILED_TABLE_COL_CNT 22
#define SPIDER_SYS_POS_FOR_RECOVERY_TABLE_COL_CNT 7
#define SPIDER_SYS_TABLE_STS_COL_CNT 11
#define SPIDER_SYS_TABLE_STS_PK_COL_CNT 2
......@@ -274,11 +274,6 @@ void spider_store_tables_link_status(
long link_status
);
void spider_store_link_chk_server_id(
TABLE *table,
uint32 server_id
);
void spider_store_binlog_pos_failed_link_idx(
TABLE *table,
int failed_link_idx
......
This diff is collapsed.
......@@ -505,6 +505,7 @@ int spider_create_trx_alter_table(
char **tmp_tgt_ssl_keys;
char **tmp_tgt_default_files;
char **tmp_tgt_default_groups;
char **tmp_tgt_dsns;
char **tmp_static_link_ids;
uint *tmp_server_names_lengths;
uint *tmp_tgt_table_names_lengths;
......@@ -521,6 +522,7 @@ int spider_create_trx_alter_table(
uint *tmp_tgt_ssl_keys_lengths;
uint *tmp_tgt_default_files_lengths;
uint *tmp_tgt_default_groups_lengths;
uint *tmp_tgt_dsns_lengths;
uint *tmp_static_link_ids_lengths;
long *tmp_tgt_ports;
long *tmp_tgt_ssl_vscs;
......@@ -541,6 +543,7 @@ int spider_create_trx_alter_table(
char *tmp_tgt_ssl_keys_char;
char *tmp_tgt_default_files_char;
char *tmp_tgt_default_groups_char;
char *tmp_tgt_dsns_char;
char *tmp_static_link_ids_char;
uint old_elements;
......@@ -567,6 +570,7 @@ int spider_create_trx_alter_table(
&tmp_tgt_ssl_keys, (uint) (sizeof(char *) * share->all_link_count),
&tmp_tgt_default_files, (uint) (sizeof(char *) * share->all_link_count),
&tmp_tgt_default_groups, (uint) (sizeof(char *) * share->all_link_count),
&tmp_tgt_dsns, (uint) (sizeof(char *) * share->all_link_count),
&tmp_static_link_ids, (uint) (sizeof(char *) * share->all_link_count),
&tmp_server_names_lengths, (uint) (sizeof(uint) * share->all_link_count),
......@@ -592,6 +596,7 @@ int spider_create_trx_alter_table(
(uint) (sizeof(uint) * share->all_link_count),
&tmp_tgt_default_groups_lengths,
(uint) (sizeof(uint) * share->all_link_count),
&tmp_tgt_dsns_lengths, (uint) (sizeof(uint) * share->all_link_count),
&tmp_static_link_ids_lengths,
(uint) (sizeof(uint) * share->all_link_count),
......@@ -631,6 +636,8 @@ int spider_create_trx_alter_table(
(share_alter->tmp_tgt_default_files_charlen + 1)),
&tmp_tgt_default_groups_char, (uint) (sizeof(char) *
(share_alter->tmp_tgt_default_groups_charlen + 1)),
&tmp_tgt_dsns_char, (uint) (sizeof(char) *
(share_alter->tmp_tgt_dsns_charlen + 1)),
&tmp_static_link_ids_char, (uint) (sizeof(char) *
(share_alter->tmp_static_link_ids_charlen + 1)),
NullS))
......@@ -666,6 +673,7 @@ int spider_create_trx_alter_table(
alter_table->tmp_tgt_ssl_keys = tmp_tgt_ssl_keys;
alter_table->tmp_tgt_default_files = tmp_tgt_default_files;
alter_table->tmp_tgt_default_groups = tmp_tgt_default_groups;
alter_table->tmp_tgt_dsns = tmp_tgt_dsns;
alter_table->tmp_static_link_ids = tmp_static_link_ids;
alter_table->tmp_tgt_ports = tmp_tgt_ports;
......@@ -689,6 +697,7 @@ int spider_create_trx_alter_table(
alter_table->tmp_tgt_ssl_keys_lengths = tmp_tgt_ssl_keys_lengths;
alter_table->tmp_tgt_default_files_lengths = tmp_tgt_default_files_lengths;
alter_table->tmp_tgt_default_groups_lengths = tmp_tgt_default_groups_lengths;
alter_table->tmp_tgt_dsns_lengths = tmp_tgt_dsns_lengths;
alter_table->tmp_static_link_ids_lengths = tmp_static_link_ids_lengths;
for(roop_count = 0; roop_count < (int) share->all_link_count; roop_count++)
......@@ -789,6 +798,12 @@ int spider_create_trx_alter_table(
tmp_tgt_default_groups_char +=
share_alter->tmp_tgt_default_groups_lengths[roop_count] + 1;
tmp_tgt_dsns[roop_count] = tmp_tgt_dsns_char;
memcpy(tmp_tgt_dsns_char, share_alter->tmp_tgt_dsns[roop_count],
sizeof(char) * share_alter->tmp_tgt_dsns_lengths[roop_count]);
tmp_tgt_dsns_char +=
share_alter->tmp_tgt_dsns_lengths[roop_count] + 1;
if (share_alter->tmp_static_link_ids[roop_count])
{
tmp_static_link_ids[roop_count] = tmp_static_link_ids_char;
......@@ -842,6 +857,8 @@ int spider_create_trx_alter_table(
memcpy(tmp_tgt_default_groups_lengths,
share_alter->tmp_tgt_default_groups_lengths,
sizeof(uint) * share->all_link_count);
memcpy(tmp_tgt_dsns_lengths, share_alter->tmp_tgt_dsns_lengths,
sizeof(uint) * share->all_link_count);
memcpy(tmp_static_link_ids_lengths,
share_alter->tmp_static_link_ids_lengths,
sizeof(uint) * share->all_link_count);
......@@ -876,6 +893,8 @@ int spider_create_trx_alter_table(
share_alter->tmp_tgt_default_files_length;
alter_table->tmp_tgt_default_groups_length =
share_alter->tmp_tgt_default_groups_length;
alter_table->tmp_tgt_dsns_length =
share_alter->tmp_tgt_dsns_length;
alter_table->tmp_static_link_ids_length =
share_alter->tmp_static_link_ids_length;
alter_table->tmp_tgt_ports_length =
......@@ -1079,6 +1098,16 @@ bool spider_cmp_trx_alter_table(
cmp2->tmp_tgt_default_groups[roop_count])
)
) ||
(
cmp1->tmp_tgt_dsns[roop_count] !=
cmp2->tmp_tgt_dsns[roop_count] &&
(
!cmp1->tmp_tgt_dsns[roop_count] ||
!cmp2->tmp_tgt_dsns[roop_count] ||
strcmp(cmp1->tmp_tgt_dsns[roop_count],
cmp2->tmp_tgt_dsns[roop_count])
)
) ||
(
cmp1->tmp_static_link_ids[roop_count] !=
cmp2->tmp_static_link_ids[roop_count] &&
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment