Commit 20d99f3f authored by Yuchen Pei's avatar Yuchen Pei

MDEV-32627 Distinguish between absence of a keyword and empty value for the keyword

Distinguish them in two place:

when constructing connection key in create_conn_key and
spider_create_conn for both ordinary queries and spider_direct_sql

For spider_create_conn and spider_udf_direct_sql_create_conn, the
created conn gets assigned a field from the source object if and only
if source->field is non-null.

For spider_create_conn_keys and spider_udf_direct_sql_create_conn_key,
we update the encoding so that absence of keyword and keyword with an
empty value result in different keys. More specifically, if the i-th
keyword has a value, the corresponding part in the conn key begins
with the char \i, followed by the possibly empty value and ends with a
\0. If the i-th keyword is not specified, then it does not get a
mention in the conn key.

As part of this change, we also update table param / option parsing to
recognise a singleton empty string when creating an string list,
instead of writing it off as NULL.
parent 6f3baec4
...@@ -397,6 +397,19 @@ void spider_free_conn_from_trx( ...@@ -397,6 +397,19 @@ void spider_free_conn_from_trx(
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
static inline void spider_memcpy_or_null(char **dest, char *alloced,
char *src, uint *dest_len,
uint tgt_len)
{
*dest_len= tgt_len;
if (src)
{
*dest= alloced;
memcpy(*dest, src, tgt_len);
} else
*dest= NULL;
}
SPIDER_CONN *spider_create_conn( SPIDER_CONN *spider_create_conn(
SPIDER_SHARE *share, SPIDER_SHARE *share,
ha_spider *spider, ha_spider *spider,
...@@ -474,106 +487,62 @@ SPIDER_CONN *spider_create_conn( ...@@ -474,106 +487,62 @@ SPIDER_CONN *spider_create_conn(
#ifdef SPIDER_HAS_HASH_VALUE_TYPE #ifdef SPIDER_HAS_HASH_VALUE_TYPE
conn->conn_key_hash_value = share->conn_keys_hash_value[link_idx]; conn->conn_key_hash_value = share->conn_keys_hash_value[link_idx];
#endif #endif
conn->tgt_host_length = share->tgt_hosts_lengths[link_idx]; spider_memcpy_or_null(&conn->tgt_host, tmp_host,
conn->tgt_host = tmp_host; share->tgt_hosts[link_idx], &conn->tgt_host_length,
memcpy(conn->tgt_host, share->tgt_hosts[link_idx], share->tgt_hosts_lengths[link_idx]);
share->tgt_hosts_lengths[link_idx]); spider_memcpy_or_null(&conn->tgt_username, tmp_username,
share->tgt_usernames[link_idx],
conn->tgt_username_length = share->tgt_usernames_lengths[link_idx]; &conn->tgt_username_length,
conn->tgt_username = tmp_username; share->tgt_usernames_lengths[link_idx]);
if (conn->tgt_username_length) spider_memcpy_or_null(&conn->tgt_password, tmp_password,
memcpy(conn->tgt_username, share->tgt_usernames[link_idx], share->tgt_passwords[link_idx],
share->tgt_usernames_lengths[link_idx]); &conn->tgt_password_length,
share->tgt_passwords_lengths[link_idx]);
conn->tgt_password_length = share->tgt_passwords_lengths[link_idx]; spider_memcpy_or_null(&conn->tgt_socket, tmp_socket,
conn->tgt_password = tmp_password; share->tgt_sockets[link_idx],
if (conn->tgt_password_length) &conn->tgt_socket_length,
memcpy(conn->tgt_password, share->tgt_passwords[link_idx], share->tgt_sockets_lengths[link_idx]);
share->tgt_passwords_lengths[link_idx]); spider_memcpy_or_null(&conn->tgt_wrapper, tmp_wrapper,
share->tgt_wrappers[link_idx],
conn->tgt_socket_length = share->tgt_sockets_lengths[link_idx]; &conn->tgt_wrapper_length,
conn->tgt_socket = tmp_socket; share->tgt_wrappers_lengths[link_idx]);
if (conn->tgt_socket_length)
memcpy(conn->tgt_socket, share->tgt_sockets[link_idx],
share->tgt_sockets_lengths[link_idx]);
conn->tgt_wrapper_length = share->tgt_wrappers_lengths[link_idx];
conn->tgt_wrapper = tmp_wrapper;
memcpy(conn->tgt_wrapper, share->tgt_wrappers[link_idx],
share->tgt_wrappers_lengths[link_idx]);
if (!tables_on_different_db_are_joinable) if (!tables_on_different_db_are_joinable)
{ {
conn->tgt_db_length = share->tgt_dbs_lengths[link_idx]; spider_memcpy_or_null(&conn->tgt_db, tmp_db, share->tgt_dbs[link_idx],
conn->tgt_db = tmp_db; &conn->tgt_db_length,
memcpy(conn->tgt_db, share->tgt_dbs[link_idx], share->tgt_dbs_lengths[link_idx]);
share->tgt_dbs_lengths[link_idx]);
} }
conn->tgt_ssl_ca_length = share->tgt_ssl_cas_lengths[link_idx]; spider_memcpy_or_null(&conn->tgt_ssl_ca, tmp_ssl_ca,
if (conn->tgt_ssl_ca_length) share->tgt_ssl_cas[link_idx],
{ &conn->tgt_ssl_ca_length,
conn->tgt_ssl_ca = tmp_ssl_ca; share->tgt_ssl_cas_lengths[link_idx]);
memcpy(conn->tgt_ssl_ca, share->tgt_ssl_cas[link_idx], spider_memcpy_or_null(&conn->tgt_ssl_capath, tmp_ssl_capath,
share->tgt_ssl_cas_lengths[link_idx]); share->tgt_ssl_capaths[link_idx],
} else &conn->tgt_ssl_capath_length,
conn->tgt_ssl_ca = NULL; share->tgt_ssl_capaths_lengths[link_idx]);
conn->tgt_ssl_capath_length = share->tgt_ssl_capaths_lengths[link_idx]; spider_memcpy_or_null(&conn->tgt_ssl_cert, tmp_ssl_cert,
if (conn->tgt_ssl_capath_length) share->tgt_ssl_certs[link_idx],
{ &conn->tgt_ssl_cert_length,
conn->tgt_ssl_capath = tmp_ssl_capath; share->tgt_ssl_certs_lengths[link_idx]);
memcpy(conn->tgt_ssl_capath, share->tgt_ssl_capaths[link_idx], spider_memcpy_or_null(&conn->tgt_ssl_cipher, tmp_ssl_cipher,
share->tgt_ssl_capaths_lengths[link_idx]); share->tgt_ssl_ciphers[link_idx],
} else &conn->tgt_ssl_cipher_length,
conn->tgt_ssl_capath = NULL; share->tgt_ssl_ciphers_lengths[link_idx]);
conn->tgt_ssl_cert_length = share->tgt_ssl_certs_lengths[link_idx]; spider_memcpy_or_null(&conn->tgt_ssl_key, tmp_ssl_key,
if (conn->tgt_ssl_cert_length) share->tgt_ssl_keys[link_idx],
{ &conn->tgt_ssl_key_length,
conn->tgt_ssl_cert = tmp_ssl_cert; share->tgt_ssl_keys_lengths[link_idx]);
memcpy(conn->tgt_ssl_cert, share->tgt_ssl_certs[link_idx], spider_memcpy_or_null(&conn->tgt_default_file, tmp_default_file,
share->tgt_ssl_certs_lengths[link_idx]); share->tgt_default_files[link_idx],
} else &conn->tgt_default_file_length,
conn->tgt_ssl_cert = NULL; share->tgt_default_files_lengths[link_idx]);
conn->tgt_ssl_cipher_length = share->tgt_ssl_ciphers_lengths[link_idx]; spider_memcpy_or_null(&conn->tgt_default_group, tmp_default_group,
if (conn->tgt_ssl_cipher_length) share->tgt_default_groups[link_idx],
{ &conn->tgt_default_group_length,
conn->tgt_ssl_cipher = tmp_ssl_cipher; share->tgt_default_groups_lengths[link_idx]);
memcpy(conn->tgt_ssl_cipher, share->tgt_ssl_ciphers[link_idx], spider_memcpy_or_null(&conn->tgt_dsn, tmp_dsn, share->tgt_dsns[link_idx],
share->tgt_ssl_ciphers_lengths[link_idx]); &conn->tgt_dsn_length,
} else share->tgt_dsns_lengths[link_idx]);
conn->tgt_ssl_cipher = NULL;
conn->tgt_ssl_key_length = share->tgt_ssl_keys_lengths[link_idx];
if (conn->tgt_ssl_key_length)
{
conn->tgt_ssl_key = tmp_ssl_key;
memcpy(conn->tgt_ssl_key, share->tgt_ssl_keys[link_idx],
share->tgt_ssl_keys_lengths[link_idx]);
} else
conn->tgt_ssl_key = NULL;
conn->tgt_default_file_length = share->tgt_default_files_lengths[link_idx];
if (conn->tgt_default_file_length)
{
conn->tgt_default_file = tmp_default_file;
memcpy(conn->tgt_default_file, share->tgt_default_files[link_idx],
share->tgt_default_files_lengths[link_idx]);
} else
conn->tgt_default_file = NULL;
conn->tgt_default_group_length =
share->tgt_default_groups_lengths[link_idx];
if (conn->tgt_default_group_length)
{
conn->tgt_default_group = tmp_default_group;
memcpy(conn->tgt_default_group, share->tgt_default_groups[link_idx],
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_port = share->tgt_ports[link_idx];
conn->tgt_ssl_vsc = share->tgt_ssl_vscs[link_idx]; conn->tgt_ssl_vsc = share->tgt_ssl_vscs[link_idx];
conn->dbton_id = share->sql_dbton_ids[link_idx]; conn->dbton_id = share->sql_dbton_ids[link_idx];
......
...@@ -219,23 +219,23 @@ int spider_udf_direct_sql_create_conn_key( ...@@ -219,23 +219,23 @@ int spider_udf_direct_sql_create_conn_key(
tables_on_different_db_are_joinable(); tables_on_different_db_are_joinable();
direct_sql->conn_key_length direct_sql->conn_key_length
= 1 = 1
+ direct_sql->tgt_wrapper_length + 1 + (direct_sql->tgt_wrapper ? direct_sql->tgt_wrapper_length + 2 : 0)
+ direct_sql->tgt_host_length + 1 + (direct_sql->tgt_host ? direct_sql->tgt_host_length + 2 : 0)
+ 5 + 1 + 5 + 2
+ direct_sql->tgt_socket_length + 1 + (direct_sql->tgt_socket ? direct_sql->tgt_socket_length + 2 : 0)
+ (tables_on_different_db_are_joinable ? + (!tables_on_different_db_are_joinable && direct_sql->tgt_default_db_name ?
0 : direct_sql->tgt_default_db_name_length + 1) direct_sql->tgt_default_db_name_length + 2 : 0)
+ direct_sql->tgt_username_length + 1 + (direct_sql->tgt_username ? direct_sql->tgt_username_length + 2 : 0)
+ direct_sql->tgt_password_length + 1 + (direct_sql->tgt_password ? direct_sql->tgt_password_length + 2 : 0)
+ direct_sql->tgt_ssl_ca_length + 1 + (direct_sql->tgt_ssl_ca ? direct_sql->tgt_ssl_ca_length + 2 : 0)
+ direct_sql->tgt_ssl_capath_length + 1 + (direct_sql->tgt_ssl_capath ? direct_sql->tgt_ssl_capath_length + 2 : 0)
+ direct_sql->tgt_ssl_cert_length + 1 + (direct_sql->tgt_ssl_cert ? direct_sql->tgt_ssl_cert_length + 2 : 0)
+ direct_sql->tgt_ssl_cipher_length + 1 + (direct_sql->tgt_ssl_cipher ? direct_sql->tgt_ssl_cipher_length + 2 : 0)
+ direct_sql->tgt_ssl_key_length + 1 + (direct_sql->tgt_ssl_key ? direct_sql->tgt_ssl_key_length + 2 : 0)
+ 1 + 1 + 1 + 2
+ direct_sql->tgt_default_file_length + 1 + (direct_sql->tgt_default_file ? direct_sql->tgt_default_file_length + 2 : 0)
+ direct_sql->tgt_default_group_length + 1 + (direct_sql->tgt_default_group ? direct_sql->tgt_default_group_length + 2 : 0)
+ direct_sql->tgt_dsn_length; + (direct_sql->tgt_dsn ? direct_sql->tgt_dsn_length + 2 : 0);
if (!(direct_sql->conn_key = (char *) if (!(direct_sql->conn_key = (char *)
spider_malloc(spider_current_trx, SPD_MID_UDF_DIRECT_SQL_CREATE_CONN_KEY_1, direct_sql->conn_key_length + 1, spider_malloc(spider_current_trx, SPD_MID_UDF_DIRECT_SQL_CREATE_CONN_KEY_1, direct_sql->conn_key_length + 1,
MYF(MY_WME | MY_ZEROFILL))) MYF(MY_WME | MY_ZEROFILL)))
...@@ -245,96 +245,36 @@ int spider_udf_direct_sql_create_conn_key( ...@@ -245,96 +245,36 @@ int spider_udf_direct_sql_create_conn_key(
*direct_sql->conn_key = '0' + 48 - direct_sql->connection_channel; *direct_sql->conn_key = '0' + 48 - direct_sql->connection_channel;
else else
*direct_sql->conn_key = '0' + direct_sql->connection_channel; *direct_sql->conn_key = '0' + direct_sql->connection_channel;
DBUG_PRINT("info",("spider tgt_wrapper=%s", direct_sql->tgt_wrapper)); int counter= 0;
tmp_name = strmov(direct_sql->conn_key + 1, direct_sql->tgt_wrapper); tmp_name= direct_sql->conn_key + 1;
DBUG_PRINT("info",("spider tgt_host=%s", direct_sql->tgt_host)); spider_create_conn_key_add_one(&counter, &tmp_name, direct_sql->tgt_wrapper);
tmp_name = strmov(tmp_name + 1, direct_sql->tgt_host); spider_create_conn_key_add_one(&counter, &tmp_name, direct_sql->tgt_host);
my_sprintf(port_str, (port_str, "%05ld", direct_sql->tgt_port)); my_sprintf(port_str, (port_str, "%05ld", direct_sql->tgt_port));
DBUG_PRINT("info",("spider port_str=%s", port_str)); spider_create_conn_key_add_one(&counter, &tmp_name, port_str);
tmp_name = strmov(tmp_name + 1, port_str); spider_create_conn_key_add_one(&counter, &tmp_name, direct_sql->tgt_socket);
if (direct_sql->tgt_socket) counter++;
if (!tables_on_different_db_are_joinable && direct_sql->tgt_default_db_name)
{ {
DBUG_PRINT("info",("spider tgt_socket=%s", direct_sql->tgt_socket)); *tmp_name= (char) counter;
tmp_name = strmov(tmp_name + 1, direct_sql->tgt_socket); tmp_name = strmov(tmp_name + 1, direct_sql->tgt_default_db_name);
} else
tmp_name++; tmp_name++;
if (!tables_on_different_db_are_joinable)
{
if (direct_sql->tgt_default_db_name)
{
DBUG_PRINT("info",("spider tgt_default_db_name=%s",
direct_sql->tgt_default_db_name));
tmp_name = strmov(tmp_name + 1, direct_sql->tgt_default_db_name);
} else
tmp_name++;
} }
if (direct_sql->tgt_username) spider_create_conn_key_add_one(&counter, &tmp_name, direct_sql->tgt_username);
{ spider_create_conn_key_add_one(&counter, &tmp_name, direct_sql->tgt_password);
DBUG_PRINT("info",("spider tgt_username=%s", direct_sql->tgt_username)); spider_create_conn_key_add_one(&counter, &tmp_name, direct_sql->tgt_ssl_ca);
tmp_name = strmov(tmp_name + 1, direct_sql->tgt_username); spider_create_conn_key_add_one(&counter, &tmp_name, direct_sql->tgt_ssl_capath);
} else spider_create_conn_key_add_one(&counter, &tmp_name, direct_sql->tgt_ssl_cert);
tmp_name++; spider_create_conn_key_add_one(&counter, &tmp_name, direct_sql->tgt_ssl_cipher);
if (direct_sql->tgt_password) spider_create_conn_key_add_one(&counter, &tmp_name, direct_sql->tgt_ssl_key);
{ counter++;
DBUG_PRINT("info",("spider tgt_password=%s", direct_sql->tgt_password)); *tmp_name= (char) counter;
tmp_name = strmov(tmp_name + 1, direct_sql->tgt_password); tmp_name++;
} else *tmp_name = '0' + ((char) direct_sql->tgt_ssl_vsc);
tmp_name++; tmp_name++;
if (direct_sql->tgt_ssl_ca) spider_create_conn_key_add_one(&counter, &tmp_name, direct_sql->tgt_default_file);
{ spider_create_conn_key_add_one(&counter, &tmp_name, direct_sql->tgt_default_group);
DBUG_PRINT("info",("spider tgt_ssl_ca=%s", direct_sql->tgt_ssl_ca)); spider_create_conn_key_add_one(&counter, &tmp_name, direct_sql->tgt_dsn);
tmp_name = strmov(tmp_name + 1, direct_sql->tgt_ssl_ca); tmp_name++;
} else
tmp_name++;
if (direct_sql->tgt_ssl_capath)
{
DBUG_PRINT("info",("spider tgt_ssl_capath=%s",
direct_sql->tgt_ssl_capath));
tmp_name = strmov(tmp_name + 1, direct_sql->tgt_ssl_capath);
} else
tmp_name++;
if (direct_sql->tgt_ssl_cert)
{
DBUG_PRINT("info",("spider tgt_ssl_cert=%s", direct_sql->tgt_ssl_cert));
tmp_name = strmov(tmp_name + 1, direct_sql->tgt_ssl_cert);
} else
tmp_name++;
if (direct_sql->tgt_ssl_cipher)
{
DBUG_PRINT("info",("spider tgt_ssl_cipher=%s",
direct_sql->tgt_ssl_cipher));
tmp_name = strmov(tmp_name + 1, direct_sql->tgt_ssl_cipher);
} else
tmp_name++;
if (direct_sql->tgt_ssl_key)
{
DBUG_PRINT("info",("spider tgt_ssl_key=%s", direct_sql->tgt_ssl_key));
tmp_name = strmov(tmp_name + 1, direct_sql->tgt_ssl_key);
} else
tmp_name++;
tmp_name++;
*tmp_name = '0' + ((char) direct_sql->tgt_ssl_vsc);
if (direct_sql->tgt_default_file)
{
DBUG_PRINT("info",("spider tgt_default_file=%s",
direct_sql->tgt_default_file));
tmp_name = strmov(tmp_name + 1, direct_sql->tgt_default_file);
} else
tmp_name++;
if (direct_sql->tgt_default_group)
{
DBUG_PRINT("info",("spider tgt_default_group=%s",
direct_sql->tgt_default_group));
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++;
#ifdef SPIDER_HAS_HASH_VALUE_TYPE #ifdef SPIDER_HAS_HASH_VALUE_TYPE
direct_sql->conn_key_hash_value = my_calc_hash(&spider_open_connections, direct_sql->conn_key_hash_value = my_calc_hash(&spider_open_connections,
(uchar*) direct_sql->conn_key, direct_sql->conn_key_length); (uchar*) direct_sql->conn_key, direct_sql->conn_key_length);
...@@ -350,7 +290,7 @@ static inline void spider_maybe_memcpy_string( ...@@ -350,7 +290,7 @@ static inline void spider_maybe_memcpy_string(
uint src_len) uint src_len)
{ {
*dest_len= src_len; *dest_len= src_len;
if (src_len) if (src)
{ {
*dest= tmp; *dest= tmp;
memcpy(*dest, src, src_len); memcpy(*dest, src, src_len);
...@@ -416,13 +356,12 @@ SPIDER_CONN *spider_udf_direct_sql_create_conn( ...@@ -416,13 +356,12 @@ SPIDER_CONN *spider_udf_direct_sql_create_conn(
conn->conn_key_length = direct_sql->conn_key_length; conn->conn_key_length = direct_sql->conn_key_length;
conn->conn_key = tmp_name; conn->conn_key = tmp_name;
memcpy(conn->conn_key, direct_sql->conn_key, direct_sql->conn_key_length); memcpy(conn->conn_key, direct_sql->conn_key, direct_sql->conn_key_length);
conn->tgt_wrapper_length = direct_sql->tgt_wrapper_length; spider_maybe_memcpy_string(
conn->tgt_wrapper = tmp_wrapper; &conn->tgt_wrapper, direct_sql->tgt_wrapper, tmp_wrapper,
memcpy(conn->tgt_wrapper, direct_sql->tgt_wrapper, &conn->tgt_wrapper_length, direct_sql->tgt_wrapper_length);
direct_sql->tgt_wrapper_length); spider_maybe_memcpy_string(
conn->tgt_host_length = direct_sql->tgt_host_length; &conn->tgt_host, direct_sql->tgt_host, tmp_host,
conn->tgt_host = tmp_host; &conn->tgt_host_length, direct_sql->tgt_host_length);
memcpy(conn->tgt_host, direct_sql->tgt_host, direct_sql->tgt_host_length);
conn->tgt_port = direct_sql->tgt_port; conn->tgt_port = direct_sql->tgt_port;
spider_maybe_memcpy_string( spider_maybe_memcpy_string(
&conn->tgt_socket, direct_sql->tgt_socket, tmp_socket, &conn->tgt_socket, direct_sql->tgt_socket, tmp_socket,
......
...@@ -999,12 +999,7 @@ int spider_create_string_list( ...@@ -999,12 +999,7 @@ int spider_create_string_list(
tmp_ptr = str; tmp_ptr = str;
while (*tmp_ptr == ' ') while (*tmp_ptr == ' ')
tmp_ptr++; tmp_ptr++;
if (*tmp_ptr) *list_length= 1;
*list_length = 1;
else {
*string_list = NULL;
DBUG_RETURN(0);
}
bool last_esc_flg = FALSE; bool last_esc_flg = FALSE;
while (TRUE) while (TRUE)
...@@ -3820,6 +3815,17 @@ void spider_print_keys( ...@@ -3820,6 +3815,17 @@ void spider_print_keys(
} }
#endif #endif
void spider_create_conn_key_add_one(int* counter, char** target, char* src)
{
(*counter)++;
if (src)
{
**target= (char) *counter;
*target= strmov(*target + 1, src);
(*target)++;
}
}
int spider_create_conn_keys( int spider_create_conn_keys(
SPIDER_SHARE *share SPIDER_SHARE *share
) { ) {
...@@ -3881,23 +3887,23 @@ int spider_create_conn_keys( ...@@ -3881,23 +3887,23 @@ int spider_create_conn_keys(
} }
conn_keys_lengths[roop_count] conn_keys_lengths[roop_count]
= 1 = 1
+ share->tgt_wrappers_lengths[roop_count] + 1 + (share->tgt_wrappers[roop_count] ? share->tgt_wrappers_lengths[roop_count] + 2 : 0)
+ share->tgt_hosts_lengths[roop_count] + 1 + (share->tgt_hosts[roop_count] ? share->tgt_hosts_lengths[roop_count] + 2 : 0)
+ 5 + 1 + 5 + 2
+ share->tgt_sockets_lengths[roop_count] + 1 + (share->tgt_sockets[roop_count] ? share->tgt_sockets_lengths[roop_count] + 2 : 0)
+ (tables_on_different_db_are_joinable ? + (!tables_on_different_db_are_joinable && share->tgt_dbs[roop_count] ?
0 : share->tgt_dbs_lengths[roop_count] + 1) share->tgt_dbs_lengths[roop_count] + 2 : 0)
+ share->tgt_usernames_lengths[roop_count] + 1 + (share->tgt_usernames[roop_count] ? share->tgt_usernames_lengths[roop_count] + 2 : 0)
+ share->tgt_passwords_lengths[roop_count] + 1 + (share->tgt_passwords[roop_count] ? share->tgt_passwords_lengths[roop_count] + 2 : 0)
+ share->tgt_ssl_cas_lengths[roop_count] + 1 + (share->tgt_ssl_cas[roop_count] ? share->tgt_ssl_cas_lengths[roop_count] + 2 : 0)
+ share->tgt_ssl_capaths_lengths[roop_count] + 1 + (share->tgt_ssl_capaths[roop_count] ? share->tgt_ssl_capaths_lengths[roop_count] + 2 : 0)
+ share->tgt_ssl_certs_lengths[roop_count] + 1 + (share->tgt_ssl_certs[roop_count] ? share->tgt_ssl_certs_lengths[roop_count] + 2 : 0)
+ share->tgt_ssl_ciphers_lengths[roop_count] + 1 + (share->tgt_ssl_ciphers[roop_count] ? share->tgt_ssl_ciphers_lengths[roop_count] + 2 : 0)
+ share->tgt_ssl_keys_lengths[roop_count] + 1 + (share->tgt_ssl_keys[roop_count] ? share->tgt_ssl_keys_lengths[roop_count] + 2 : 0)
+ 1 + 1 + 1 + 2
+ share->tgt_default_files_lengths[roop_count] + 1 + (share->tgt_default_files[roop_count] ? share->tgt_default_files_lengths[roop_count] + 2 : 0)
+ share->tgt_default_groups_lengths[roop_count] + 1 + (share->tgt_default_groups[roop_count] ? share->tgt_default_groups_lengths[roop_count] + 2 : 0)
+ share->tgt_dsns_lengths[roop_count]; + (share->tgt_dsns[roop_count] ? share->tgt_dsns_lengths[roop_count] + 2 : 0);
share->conn_keys_charlen += conn_keys_lengths[roop_count] + 2; share->conn_keys_charlen += conn_keys_lengths[roop_count] + 2;
} }
if (!(share->conn_keys = (char **) if (!(share->conn_keys = (char **)
...@@ -3937,105 +3943,35 @@ int spider_create_conn_keys( ...@@ -3937,105 +3943,35 @@ int spider_create_conn_keys(
share->conn_keys[roop_count] = tmp_name; share->conn_keys[roop_count] = tmp_name;
*tmp_name = '0'; *tmp_name = '0';
DBUG_PRINT("info",("spider tgt_wrappers[%d]=%s", roop_count, tmp_name++;
share->tgt_wrappers[roop_count])); int counter= 0;
tmp_name = strmov(tmp_name + 1, share->tgt_wrappers[roop_count]); spider_create_conn_key_add_one(&counter, &tmp_name, share->tgt_wrappers[roop_count]);
DBUG_PRINT("info",("spider tgt_hosts[%d]=%s", roop_count, spider_create_conn_key_add_one(&counter, &tmp_name, share->tgt_hosts[roop_count]);
share->tgt_hosts[roop_count]));
tmp_name = strmov(tmp_name + 1, share->tgt_hosts[roop_count]);
my_sprintf(port_str, (port_str, "%05ld", share->tgt_ports[roop_count])); my_sprintf(port_str, (port_str, "%05ld", share->tgt_ports[roop_count]));
DBUG_PRINT("info",("spider port_str=%s", port_str)); spider_create_conn_key_add_one(&counter, &tmp_name, port_str);
tmp_name = strmov(tmp_name + 1, port_str); spider_create_conn_key_add_one(&counter, &tmp_name, share->tgt_sockets[roop_count]);
if (share->tgt_sockets[roop_count]) counter++;
if (!tables_on_different_db_are_joinable && share->tgt_dbs[roop_count])
{ {
DBUG_PRINT("info",("spider tgt_sockets[%d]=%s", roop_count, *tmp_name= (char) counter;
share->tgt_sockets[roop_count])); tmp_name = strmov(tmp_name + 1, share->tgt_dbs[roop_count]);
tmp_name = strmov(tmp_name + 1, share->tgt_sockets[roop_count]);
} else
tmp_name++; tmp_name++;
if (!tables_on_different_db_are_joinable)
{
if (share->tgt_dbs[roop_count])
{
DBUG_PRINT("info",("spider tgt_dbs[%d]=%s", roop_count,
share->tgt_dbs[roop_count]));
tmp_name = strmov(tmp_name + 1, share->tgt_dbs[roop_count]);
} else
tmp_name++;
} }
if (share->tgt_usernames[roop_count]) spider_create_conn_key_add_one(&counter, &tmp_name, share->tgt_usernames[roop_count]);
{ spider_create_conn_key_add_one(&counter, &tmp_name, share->tgt_passwords[roop_count]);
DBUG_PRINT("info",("spider tgt_usernames[%d]=%s", roop_count, spider_create_conn_key_add_one(&counter, &tmp_name, share->tgt_ssl_cas[roop_count]);
share->tgt_usernames[roop_count])); spider_create_conn_key_add_one(&counter, &tmp_name, share->tgt_ssl_capaths[roop_count]);
tmp_name = strmov(tmp_name + 1, share->tgt_usernames[roop_count]); spider_create_conn_key_add_one(&counter, &tmp_name, share->tgt_ssl_certs[roop_count]);
} else spider_create_conn_key_add_one(&counter, &tmp_name, share->tgt_ssl_ciphers[roop_count]);
tmp_name++; spider_create_conn_key_add_one(&counter, &tmp_name, share->tgt_ssl_keys[roop_count]);
if (share->tgt_passwords[roop_count]) counter++;
{ *tmp_name= (char) counter;
DBUG_PRINT("info",("spider tgt_passwords[%d]=%s", roop_count,
share->tgt_passwords[roop_count]));
tmp_name = strmov(tmp_name + 1, share->tgt_passwords[roop_count]);
} else
tmp_name++;
if (share->tgt_ssl_cas[roop_count])
{
DBUG_PRINT("info",("spider tgt_ssl_cas[%d]=%s", roop_count,
share->tgt_ssl_cas[roop_count]));
tmp_name = strmov(tmp_name + 1, share->tgt_ssl_cas[roop_count]);
} else
tmp_name++;
if (share->tgt_ssl_capaths[roop_count])
{
DBUG_PRINT("info",("spider tgt_ssl_capaths[%d]=%s", roop_count,
share->tgt_ssl_capaths[roop_count]));
tmp_name = strmov(tmp_name + 1, share->tgt_ssl_capaths[roop_count]);
} else
tmp_name++;
if (share->tgt_ssl_certs[roop_count])
{
DBUG_PRINT("info",("spider tgt_ssl_certs[%d]=%s", roop_count,
share->tgt_ssl_certs[roop_count]));
tmp_name = strmov(tmp_name + 1, share->tgt_ssl_certs[roop_count]);
} else
tmp_name++;
if (share->tgt_ssl_ciphers[roop_count])
{
DBUG_PRINT("info",("spider tgt_ssl_ciphers[%d]=%s", roop_count,
share->tgt_ssl_ciphers[roop_count]));
tmp_name = strmov(tmp_name + 1, share->tgt_ssl_ciphers[roop_count]);
} else
tmp_name++;
if (share->tgt_ssl_keys[roop_count])
{
DBUG_PRINT("info",("spider tgt_ssl_keys[%d]=%s", roop_count,
share->tgt_ssl_keys[roop_count]));
tmp_name = strmov(tmp_name + 1, share->tgt_ssl_keys[roop_count]);
} else
tmp_name++;
tmp_name++; tmp_name++;
*tmp_name = '0' + ((char) share->tgt_ssl_vscs[roop_count]); *tmp_name = '0' + ((char) share->tgt_ssl_vscs[roop_count]);
if (share->tgt_default_files[roop_count])
{
DBUG_PRINT("info",("spider tgt_default_files[%d]=%s", roop_count,
share->tgt_default_files[roop_count]));
tmp_name = strmov(tmp_name + 1, share->tgt_default_files[roop_count]);
} else
tmp_name++;
if (share->tgt_default_groups[roop_count])
{
DBUG_PRINT("info",("spider tgt_default_groups[%d]=%s", roop_count,
share->tgt_default_groups[roop_count]));
tmp_name = strmov(tmp_name + 1, share->tgt_default_groups[roop_count]);
} else
tmp_name++;
if (share->tgt_dsns[roop_count])
{
DBUG_PRINT("info",("spider tgt_dsns[%d]=%s", roop_count,
share->tgt_dsns[roop_count]));
tmp_name = strmov(tmp_name + 1, share->tgt_dsns[roop_count]);
} else
tmp_name++;
tmp_name++; tmp_name++;
spider_create_conn_key_add_one(&counter, &tmp_name, share->tgt_default_files[roop_count]);
spider_create_conn_key_add_one(&counter, &tmp_name, share->tgt_default_groups[roop_count]);
spider_create_conn_key_add_one(&counter, &tmp_name, share->tgt_dsns[roop_count]);
tmp_name++; tmp_name++;
#ifdef SPIDER_HAS_HASH_VALUE_TYPE #ifdef SPIDER_HAS_HASH_VALUE_TYPE
share->conn_keys_hash_value[roop_count] = my_calc_hash( share->conn_keys_hash_value[roop_count] = my_calc_hash(
......
...@@ -169,6 +169,8 @@ void spider_print_keys( ...@@ -169,6 +169,8 @@ void spider_print_keys(
); );
#endif #endif
void spider_create_conn_key_add_one(int* counter, char** target, char* src);
int spider_create_conn_keys( int spider_create_conn_keys(
SPIDER_SHARE *share SPIDER_SHARE *share
); );
......
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