mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 03:52:35 +01:00
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.
This commit is contained in:
parent
6f3baec4f5
commit
20d99f3f86
4 changed files with 169 additions and 323 deletions
|
@ -397,6 +397,19 @@ void spider_free_conn_from_trx(
|
|||
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_SHARE *share,
|
||||
ha_spider *spider,
|
||||
|
@ -474,106 +487,62 @@ SPIDER_CONN *spider_create_conn(
|
|||
#ifdef SPIDER_HAS_HASH_VALUE_TYPE
|
||||
conn->conn_key_hash_value = share->conn_keys_hash_value[link_idx];
|
||||
#endif
|
||||
conn->tgt_host_length = share->tgt_hosts_lengths[link_idx];
|
||||
conn->tgt_host = tmp_host;
|
||||
memcpy(conn->tgt_host, share->tgt_hosts[link_idx],
|
||||
share->tgt_hosts_lengths[link_idx]);
|
||||
|
||||
conn->tgt_username_length = share->tgt_usernames_lengths[link_idx];
|
||||
conn->tgt_username = tmp_username;
|
||||
if (conn->tgt_username_length)
|
||||
memcpy(conn->tgt_username, share->tgt_usernames[link_idx],
|
||||
share->tgt_usernames_lengths[link_idx]);
|
||||
|
||||
conn->tgt_password_length = share->tgt_passwords_lengths[link_idx];
|
||||
conn->tgt_password = tmp_password;
|
||||
if (conn->tgt_password_length)
|
||||
memcpy(conn->tgt_password, share->tgt_passwords[link_idx],
|
||||
share->tgt_passwords_lengths[link_idx]);
|
||||
|
||||
conn->tgt_socket_length = share->tgt_sockets_lengths[link_idx];
|
||||
conn->tgt_socket = tmp_socket;
|
||||
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]);
|
||||
spider_memcpy_or_null(&conn->tgt_host, tmp_host,
|
||||
share->tgt_hosts[link_idx], &conn->tgt_host_length,
|
||||
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]);
|
||||
spider_memcpy_or_null(&conn->tgt_password, tmp_password,
|
||||
share->tgt_passwords[link_idx],
|
||||
&conn->tgt_password_length,
|
||||
share->tgt_passwords_lengths[link_idx]);
|
||||
spider_memcpy_or_null(&conn->tgt_socket, tmp_socket,
|
||||
share->tgt_sockets[link_idx],
|
||||
&conn->tgt_socket_length,
|
||||
share->tgt_sockets_lengths[link_idx]);
|
||||
spider_memcpy_or_null(&conn->tgt_wrapper, tmp_wrapper,
|
||||
share->tgt_wrappers[link_idx],
|
||||
&conn->tgt_wrapper_length,
|
||||
share->tgt_wrappers_lengths[link_idx]);
|
||||
if (!tables_on_different_db_are_joinable)
|
||||
{
|
||||
conn->tgt_db_length = share->tgt_dbs_lengths[link_idx];
|
||||
conn->tgt_db = tmp_db;
|
||||
memcpy(conn->tgt_db, share->tgt_dbs[link_idx],
|
||||
share->tgt_dbs_lengths[link_idx]);
|
||||
spider_memcpy_or_null(&conn->tgt_db, tmp_db, share->tgt_dbs[link_idx],
|
||||
&conn->tgt_db_length,
|
||||
share->tgt_dbs_lengths[link_idx]);
|
||||
}
|
||||
conn->tgt_ssl_ca_length = share->tgt_ssl_cas_lengths[link_idx];
|
||||
if (conn->tgt_ssl_ca_length)
|
||||
{
|
||||
conn->tgt_ssl_ca = tmp_ssl_ca;
|
||||
memcpy(conn->tgt_ssl_ca, share->tgt_ssl_cas[link_idx],
|
||||
share->tgt_ssl_cas_lengths[link_idx]);
|
||||
} else
|
||||
conn->tgt_ssl_ca = NULL;
|
||||
conn->tgt_ssl_capath_length = share->tgt_ssl_capaths_lengths[link_idx];
|
||||
if (conn->tgt_ssl_capath_length)
|
||||
{
|
||||
conn->tgt_ssl_capath = tmp_ssl_capath;
|
||||
memcpy(conn->tgt_ssl_capath, share->tgt_ssl_capaths[link_idx],
|
||||
share->tgt_ssl_capaths_lengths[link_idx]);
|
||||
} else
|
||||
conn->tgt_ssl_capath = NULL;
|
||||
conn->tgt_ssl_cert_length = share->tgt_ssl_certs_lengths[link_idx];
|
||||
if (conn->tgt_ssl_cert_length)
|
||||
{
|
||||
conn->tgt_ssl_cert = tmp_ssl_cert;
|
||||
memcpy(conn->tgt_ssl_cert, share->tgt_ssl_certs[link_idx],
|
||||
share->tgt_ssl_certs_lengths[link_idx]);
|
||||
} else
|
||||
conn->tgt_ssl_cert = NULL;
|
||||
conn->tgt_ssl_cipher_length = share->tgt_ssl_ciphers_lengths[link_idx];
|
||||
if (conn->tgt_ssl_cipher_length)
|
||||
{
|
||||
conn->tgt_ssl_cipher = tmp_ssl_cipher;
|
||||
memcpy(conn->tgt_ssl_cipher, share->tgt_ssl_ciphers[link_idx],
|
||||
share->tgt_ssl_ciphers_lengths[link_idx]);
|
||||
} else
|
||||
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;
|
||||
spider_memcpy_or_null(&conn->tgt_ssl_ca, tmp_ssl_ca,
|
||||
share->tgt_ssl_cas[link_idx],
|
||||
&conn->tgt_ssl_ca_length,
|
||||
share->tgt_ssl_cas_lengths[link_idx]);
|
||||
spider_memcpy_or_null(&conn->tgt_ssl_capath, tmp_ssl_capath,
|
||||
share->tgt_ssl_capaths[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,
|
||||
share->tgt_ssl_certs[link_idx],
|
||||
&conn->tgt_ssl_cert_length,
|
||||
share->tgt_ssl_certs_lengths[link_idx]);
|
||||
spider_memcpy_or_null(&conn->tgt_ssl_cipher, tmp_ssl_cipher,
|
||||
share->tgt_ssl_ciphers[link_idx],
|
||||
&conn->tgt_ssl_cipher_length,
|
||||
share->tgt_ssl_ciphers_lengths[link_idx]);
|
||||
spider_memcpy_or_null(&conn->tgt_ssl_key, tmp_ssl_key,
|
||||
share->tgt_ssl_keys[link_idx],
|
||||
&conn->tgt_ssl_key_length,
|
||||
share->tgt_ssl_keys_lengths[link_idx]);
|
||||
spider_memcpy_or_null(&conn->tgt_default_file, tmp_default_file,
|
||||
share->tgt_default_files[link_idx],
|
||||
&conn->tgt_default_file_length,
|
||||
share->tgt_default_files_lengths[link_idx]);
|
||||
spider_memcpy_or_null(&conn->tgt_default_group, tmp_default_group,
|
||||
share->tgt_default_groups[link_idx],
|
||||
&conn->tgt_default_group_length,
|
||||
share->tgt_default_groups_lengths[link_idx]);
|
||||
spider_memcpy_or_null(&conn->tgt_dsn, tmp_dsn, share->tgt_dsns[link_idx],
|
||||
&conn->tgt_dsn_length,
|
||||
share->tgt_dsns_lengths[link_idx]);
|
||||
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];
|
||||
|
|
|
@ -219,23 +219,23 @@ int spider_udf_direct_sql_create_conn_key(
|
|||
tables_on_different_db_are_joinable();
|
||||
direct_sql->conn_key_length
|
||||
= 1
|
||||
+ direct_sql->tgt_wrapper_length + 1
|
||||
+ direct_sql->tgt_host_length + 1
|
||||
+ 5 + 1
|
||||
+ direct_sql->tgt_socket_length + 1
|
||||
+ (tables_on_different_db_are_joinable ?
|
||||
0 : direct_sql->tgt_default_db_name_length + 1)
|
||||
+ direct_sql->tgt_username_length + 1
|
||||
+ direct_sql->tgt_password_length + 1
|
||||
+ direct_sql->tgt_ssl_ca_length + 1
|
||||
+ direct_sql->tgt_ssl_capath_length + 1
|
||||
+ direct_sql->tgt_ssl_cert_length + 1
|
||||
+ direct_sql->tgt_ssl_cipher_length + 1
|
||||
+ direct_sql->tgt_ssl_key_length + 1
|
||||
+ 1 + 1
|
||||
+ direct_sql->tgt_default_file_length + 1
|
||||
+ direct_sql->tgt_default_group_length + 1
|
||||
+ direct_sql->tgt_dsn_length;
|
||||
+ (direct_sql->tgt_wrapper ? direct_sql->tgt_wrapper_length + 2 : 0)
|
||||
+ (direct_sql->tgt_host ? direct_sql->tgt_host_length + 2 : 0)
|
||||
+ 5 + 2
|
||||
+ (direct_sql->tgt_socket ? direct_sql->tgt_socket_length + 2 : 0)
|
||||
+ (!tables_on_different_db_are_joinable && direct_sql->tgt_default_db_name ?
|
||||
direct_sql->tgt_default_db_name_length + 2 : 0)
|
||||
+ (direct_sql->tgt_username ? direct_sql->tgt_username_length + 2 : 0)
|
||||
+ (direct_sql->tgt_password ? direct_sql->tgt_password_length + 2 : 0)
|
||||
+ (direct_sql->tgt_ssl_ca ? direct_sql->tgt_ssl_ca_length + 2 : 0)
|
||||
+ (direct_sql->tgt_ssl_capath ? direct_sql->tgt_ssl_capath_length + 2 : 0)
|
||||
+ (direct_sql->tgt_ssl_cert ? direct_sql->tgt_ssl_cert_length + 2 : 0)
|
||||
+ (direct_sql->tgt_ssl_cipher ? direct_sql->tgt_ssl_cipher_length + 2 : 0)
|
||||
+ (direct_sql->tgt_ssl_key ? direct_sql->tgt_ssl_key_length + 2 : 0)
|
||||
+ 1 + 2
|
||||
+ (direct_sql->tgt_default_file ? direct_sql->tgt_default_file_length + 2 : 0)
|
||||
+ (direct_sql->tgt_default_group ? direct_sql->tgt_default_group_length + 2 : 0)
|
||||
+ (direct_sql->tgt_dsn ? direct_sql->tgt_dsn_length + 2 : 0);
|
||||
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,
|
||||
MYF(MY_WME | MY_ZEROFILL)))
|
||||
|
@ -245,96 +245,36 @@ int spider_udf_direct_sql_create_conn_key(
|
|||
*direct_sql->conn_key = '0' + 48 - direct_sql->connection_channel;
|
||||
else
|
||||
*direct_sql->conn_key = '0' + direct_sql->connection_channel;
|
||||
DBUG_PRINT("info",("spider tgt_wrapper=%s", direct_sql->tgt_wrapper));
|
||||
tmp_name = strmov(direct_sql->conn_key + 1, direct_sql->tgt_wrapper);
|
||||
DBUG_PRINT("info",("spider tgt_host=%s", direct_sql->tgt_host));
|
||||
tmp_name = strmov(tmp_name + 1, direct_sql->tgt_host);
|
||||
int counter= 0;
|
||||
tmp_name= direct_sql->conn_key + 1;
|
||||
spider_create_conn_key_add_one(&counter, &tmp_name, direct_sql->tgt_wrapper);
|
||||
spider_create_conn_key_add_one(&counter, &tmp_name, direct_sql->tgt_host);
|
||||
my_sprintf(port_str, (port_str, "%05ld", direct_sql->tgt_port));
|
||||
DBUG_PRINT("info",("spider port_str=%s", port_str));
|
||||
tmp_name = strmov(tmp_name + 1, port_str);
|
||||
if (direct_sql->tgt_socket)
|
||||
spider_create_conn_key_add_one(&counter, &tmp_name, port_str);
|
||||
spider_create_conn_key_add_one(&counter, &tmp_name, 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 = strmov(tmp_name + 1, direct_sql->tgt_socket);
|
||||
} else
|
||||
*tmp_name= (char) counter;
|
||||
tmp_name = strmov(tmp_name + 1, direct_sql->tgt_default_db_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)
|
||||
{
|
||||
DBUG_PRINT("info",("spider tgt_username=%s", direct_sql->tgt_username));
|
||||
tmp_name = strmov(tmp_name + 1, direct_sql->tgt_username);
|
||||
} else
|
||||
tmp_name++;
|
||||
if (direct_sql->tgt_password)
|
||||
{
|
||||
DBUG_PRINT("info",("spider tgt_password=%s", direct_sql->tgt_password));
|
||||
tmp_name = strmov(tmp_name + 1, direct_sql->tgt_password);
|
||||
} else
|
||||
tmp_name++;
|
||||
if (direct_sql->tgt_ssl_ca)
|
||||
{
|
||||
DBUG_PRINT("info",("spider tgt_ssl_ca=%s", direct_sql->tgt_ssl_ca));
|
||||
tmp_name = strmov(tmp_name + 1, direct_sql->tgt_ssl_ca);
|
||||
} 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++;
|
||||
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);
|
||||
spider_create_conn_key_add_one(&counter, &tmp_name, direct_sql->tgt_ssl_ca);
|
||||
spider_create_conn_key_add_one(&counter, &tmp_name, direct_sql->tgt_ssl_capath);
|
||||
spider_create_conn_key_add_one(&counter, &tmp_name, direct_sql->tgt_ssl_cert);
|
||||
spider_create_conn_key_add_one(&counter, &tmp_name, direct_sql->tgt_ssl_cipher);
|
||||
spider_create_conn_key_add_one(&counter, &tmp_name, direct_sql->tgt_ssl_key);
|
||||
counter++;
|
||||
*tmp_name= (char) counter;
|
||||
tmp_name++;
|
||||
*tmp_name = '0' + ((char) direct_sql->tgt_ssl_vsc);
|
||||
tmp_name++;
|
||||
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);
|
||||
spider_create_conn_key_add_one(&counter, &tmp_name, direct_sql->tgt_dsn);
|
||||
tmp_name++;
|
||||
#ifdef SPIDER_HAS_HASH_VALUE_TYPE
|
||||
direct_sql->conn_key_hash_value = my_calc_hash(&spider_open_connections,
|
||||
(uchar*) direct_sql->conn_key, direct_sql->conn_key_length);
|
||||
|
@ -350,7 +290,7 @@ static inline void spider_maybe_memcpy_string(
|
|||
uint src_len)
|
||||
{
|
||||
*dest_len= src_len;
|
||||
if (src_len)
|
||||
if (src)
|
||||
{
|
||||
*dest= tmp;
|
||||
memcpy(*dest, src, src_len);
|
||||
|
@ -416,13 +356,12 @@ SPIDER_CONN *spider_udf_direct_sql_create_conn(
|
|||
conn->conn_key_length = direct_sql->conn_key_length;
|
||||
conn->conn_key = tmp_name;
|
||||
memcpy(conn->conn_key, direct_sql->conn_key, direct_sql->conn_key_length);
|
||||
conn->tgt_wrapper_length = direct_sql->tgt_wrapper_length;
|
||||
conn->tgt_wrapper = tmp_wrapper;
|
||||
memcpy(conn->tgt_wrapper, direct_sql->tgt_wrapper,
|
||||
direct_sql->tgt_wrapper_length);
|
||||
conn->tgt_host_length = direct_sql->tgt_host_length;
|
||||
conn->tgt_host = tmp_host;
|
||||
memcpy(conn->tgt_host, direct_sql->tgt_host, direct_sql->tgt_host_length);
|
||||
spider_maybe_memcpy_string(
|
||||
&conn->tgt_wrapper, direct_sql->tgt_wrapper, tmp_wrapper,
|
||||
&conn->tgt_wrapper_length, direct_sql->tgt_wrapper_length);
|
||||
spider_maybe_memcpy_string(
|
||||
&conn->tgt_host, direct_sql->tgt_host, tmp_host,
|
||||
&conn->tgt_host_length, direct_sql->tgt_host_length);
|
||||
conn->tgt_port = direct_sql->tgt_port;
|
||||
spider_maybe_memcpy_string(
|
||||
&conn->tgt_socket, direct_sql->tgt_socket, tmp_socket,
|
||||
|
|
|
@ -999,12 +999,7 @@ int spider_create_string_list(
|
|||
tmp_ptr = str;
|
||||
while (*tmp_ptr == ' ')
|
||||
tmp_ptr++;
|
||||
if (*tmp_ptr)
|
||||
*list_length = 1;
|
||||
else {
|
||||
*string_list = NULL;
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
*list_length= 1;
|
||||
|
||||
bool last_esc_flg = FALSE;
|
||||
while (TRUE)
|
||||
|
@ -3820,6 +3815,17 @@ void spider_print_keys(
|
|||
}
|
||||
#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(
|
||||
SPIDER_SHARE *share
|
||||
) {
|
||||
|
@ -3881,23 +3887,23 @@ int spider_create_conn_keys(
|
|||
}
|
||||
conn_keys_lengths[roop_count]
|
||||
= 1
|
||||
+ share->tgt_wrappers_lengths[roop_count] + 1
|
||||
+ share->tgt_hosts_lengths[roop_count] + 1
|
||||
+ 5 + 1
|
||||
+ share->tgt_sockets_lengths[roop_count] + 1
|
||||
+ (tables_on_different_db_are_joinable ?
|
||||
0 : share->tgt_dbs_lengths[roop_count] + 1)
|
||||
+ share->tgt_usernames_lengths[roop_count] + 1
|
||||
+ share->tgt_passwords_lengths[roop_count] + 1
|
||||
+ share->tgt_ssl_cas_lengths[roop_count] + 1
|
||||
+ share->tgt_ssl_capaths_lengths[roop_count] + 1
|
||||
+ share->tgt_ssl_certs_lengths[roop_count] + 1
|
||||
+ share->tgt_ssl_ciphers_lengths[roop_count] + 1
|
||||
+ share->tgt_ssl_keys_lengths[roop_count] + 1
|
||||
+ 1 + 1
|
||||
+ share->tgt_default_files_lengths[roop_count] + 1
|
||||
+ share->tgt_default_groups_lengths[roop_count] + 1
|
||||
+ share->tgt_dsns_lengths[roop_count];
|
||||
+ (share->tgt_wrappers[roop_count] ? share->tgt_wrappers_lengths[roop_count] + 2 : 0)
|
||||
+ (share->tgt_hosts[roop_count] ? share->tgt_hosts_lengths[roop_count] + 2 : 0)
|
||||
+ 5 + 2
|
||||
+ (share->tgt_sockets[roop_count] ? share->tgt_sockets_lengths[roop_count] + 2 : 0)
|
||||
+ (!tables_on_different_db_are_joinable && share->tgt_dbs[roop_count] ?
|
||||
share->tgt_dbs_lengths[roop_count] + 2 : 0)
|
||||
+ (share->tgt_usernames[roop_count] ? share->tgt_usernames_lengths[roop_count] + 2 : 0)
|
||||
+ (share->tgt_passwords[roop_count] ? share->tgt_passwords_lengths[roop_count] + 2 : 0)
|
||||
+ (share->tgt_ssl_cas[roop_count] ? share->tgt_ssl_cas_lengths[roop_count] + 2 : 0)
|
||||
+ (share->tgt_ssl_capaths[roop_count] ? share->tgt_ssl_capaths_lengths[roop_count] + 2 : 0)
|
||||
+ (share->tgt_ssl_certs[roop_count] ? share->tgt_ssl_certs_lengths[roop_count] + 2 : 0)
|
||||
+ (share->tgt_ssl_ciphers[roop_count] ? share->tgt_ssl_ciphers_lengths[roop_count] + 2 : 0)
|
||||
+ (share->tgt_ssl_keys[roop_count] ? share->tgt_ssl_keys_lengths[roop_count] + 2 : 0)
|
||||
+ 1 + 2
|
||||
+ (share->tgt_default_files[roop_count] ? share->tgt_default_files_lengths[roop_count] + 2 : 0)
|
||||
+ (share->tgt_default_groups[roop_count] ? share->tgt_default_groups_lengths[roop_count] + 2 : 0)
|
||||
+ (share->tgt_dsns[roop_count] ? share->tgt_dsns_lengths[roop_count] + 2 : 0);
|
||||
share->conn_keys_charlen += conn_keys_lengths[roop_count] + 2;
|
||||
}
|
||||
if (!(share->conn_keys = (char **)
|
||||
|
@ -3937,105 +3943,35 @@ int spider_create_conn_keys(
|
|||
|
||||
share->conn_keys[roop_count] = tmp_name;
|
||||
*tmp_name = '0';
|
||||
DBUG_PRINT("info",("spider tgt_wrappers[%d]=%s", roop_count,
|
||||
share->tgt_wrappers[roop_count]));
|
||||
tmp_name = strmov(tmp_name + 1, share->tgt_wrappers[roop_count]);
|
||||
DBUG_PRINT("info",("spider tgt_hosts[%d]=%s", roop_count,
|
||||
share->tgt_hosts[roop_count]));
|
||||
tmp_name = strmov(tmp_name + 1, share->tgt_hosts[roop_count]);
|
||||
tmp_name++;
|
||||
int counter= 0;
|
||||
spider_create_conn_key_add_one(&counter, &tmp_name, share->tgt_wrappers[roop_count]);
|
||||
spider_create_conn_key_add_one(&counter, &tmp_name, share->tgt_hosts[roop_count]);
|
||||
my_sprintf(port_str, (port_str, "%05ld", share->tgt_ports[roop_count]));
|
||||
DBUG_PRINT("info",("spider port_str=%s", port_str));
|
||||
tmp_name = strmov(tmp_name + 1, port_str);
|
||||
if (share->tgt_sockets[roop_count])
|
||||
spider_create_conn_key_add_one(&counter, &tmp_name, port_str);
|
||||
spider_create_conn_key_add_one(&counter, &tmp_name, 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,
|
||||
share->tgt_sockets[roop_count]));
|
||||
tmp_name = strmov(tmp_name + 1, share->tgt_sockets[roop_count]);
|
||||
} else
|
||||
*tmp_name= (char) counter;
|
||||
tmp_name = strmov(tmp_name + 1, share->tgt_dbs[roop_count]);
|
||||
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])
|
||||
{
|
||||
DBUG_PRINT("info",("spider tgt_usernames[%d]=%s", roop_count,
|
||||
share->tgt_usernames[roop_count]));
|
||||
tmp_name = strmov(tmp_name + 1, share->tgt_usernames[roop_count]);
|
||||
} else
|
||||
tmp_name++;
|
||||
if (share->tgt_passwords[roop_count])
|
||||
{
|
||||
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++;
|
||||
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]);
|
||||
spider_create_conn_key_add_one(&counter, &tmp_name, share->tgt_ssl_cas[roop_count]);
|
||||
spider_create_conn_key_add_one(&counter, &tmp_name, share->tgt_ssl_capaths[roop_count]);
|
||||
spider_create_conn_key_add_one(&counter, &tmp_name, share->tgt_ssl_certs[roop_count]);
|
||||
spider_create_conn_key_add_one(&counter, &tmp_name, share->tgt_ssl_ciphers[roop_count]);
|
||||
spider_create_conn_key_add_one(&counter, &tmp_name, share->tgt_ssl_keys[roop_count]);
|
||||
counter++;
|
||||
*tmp_name= (char) counter;
|
||||
tmp_name++;
|
||||
*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++;
|
||||
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++;
|
||||
#ifdef SPIDER_HAS_HASH_VALUE_TYPE
|
||||
share->conn_keys_hash_value[roop_count] = my_calc_hash(
|
||||
|
|
|
@ -169,6 +169,8 @@ void spider_print_keys(
|
|||
);
|
||||
#endif
|
||||
|
||||
void spider_create_conn_key_add_one(int* counter, char** target, char* src);
|
||||
|
||||
int spider_create_conn_keys(
|
||||
SPIDER_SHARE *share
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue