Skip to content

Commit 84df8d7

Browse files
MDEV-34716 spider: some trivial cleanups and documentation
- document tmp_share, which are temporary spider shares with only one link (no ha) - simplify spider_get_sys_tables_connect_info() where link_idx is always 0
1 parent 13cd8ad commit 84df8d7

File tree

5 files changed

+116
-110
lines changed

5 files changed

+116
-110
lines changed

storage/spider/spd_copy_tables.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ int spider_udf_get_copy_tgt_tables(
245245
char table_key[MAX_KEY_LENGTH];
246246
SPIDER_COPY_TABLE_CONN *table_conn = NULL, *src_table_conn_prev = NULL,
247247
*dst_table_conn_prev = NULL;
248+
/* This share has only one link. */
248249
SPIDER_SHARE *tmp_share;
249250
char **tmp_connect_info;
250251
uint *tmp_connect_info_length;

storage/spider/spd_include.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,6 +1449,7 @@ typedef struct st_spider_mon_table_result
14491449

14501450
typedef struct st_spider_table_mon
14511451
{
1452+
/* This share has only one link. */
14521453
SPIDER_SHARE *share;
14531454
uint32 server_id;
14541455
st_spider_table_mon_list *parent;
@@ -1475,6 +1476,7 @@ typedef struct st_spider_table_mon_list
14751476
SPIDER_TABLE_MON *current;
14761477
volatile int mon_status;
14771478

1479+
/* This share has only one link */
14781480
SPIDER_SHARE *share;
14791481

14801482
pthread_mutex_t caller_mutex;
@@ -1488,6 +1490,7 @@ typedef struct st_spider_table_mon_list
14881490

14891491
typedef struct st_spider_copy_table_conn
14901492
{
1493+
/* This share has only one link. */
14911494
SPIDER_SHARE *share;
14921495
int link_idx;
14931496
SPIDER_CONN *conn;

storage/spider/spd_sys_table.cc

Lines changed: 105 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -2160,9 +2160,7 @@ int spider_get_sys_tables_connect_info(
21602160
) {
21612161
char *ptr;
21622162
int error_num = 0;
2163-
const int link_idx= 0;
21642163
DBUG_ENTER("spider_get_sys_tables_connect_info");
2165-
DBUG_PRINT("info",("spider link_idx:%d", link_idx));
21662164
if ((ptr = get_field(mem_root, table->field[SPIDER_TABLES_PRIORITY_POS])))
21672165
{
21682166
share->priority = my_strtoll10(ptr, (char**) NULL, &error_num);
@@ -2173,245 +2171,245 @@ int spider_get_sys_tables_connect_info(
21732171
!table->field[SPIDER_TABLES_SERVER_POS]->is_null() &&
21742172
(ptr = get_field(mem_root, table->field[SPIDER_TABLES_SERVER_POS]))
21752173
) {
2176-
share->server_names_lengths[link_idx] = strlen(ptr);
2177-
share->server_names[link_idx] =
2178-
spider_create_string(ptr, share->server_names_lengths[link_idx]);
2174+
share->server_names_lengths[0] = strlen(ptr);
2175+
share->server_names[0] =
2176+
spider_create_string(ptr, share->server_names_lengths[0]);
21792177
DBUG_PRINT("info",("spider server_name:%s",
2180-
share->server_names[link_idx]));
2178+
share->server_names[0]));
21812179
} else {
2182-
share->server_names_lengths[link_idx] = 0;
2183-
share->server_names[link_idx] = NULL;
2180+
share->server_names_lengths[0] = 0;
2181+
share->server_names[0] = NULL;
21842182
DBUG_PRINT("info",("spider server_name is NULL"));
21852183
}
21862184
if (
21872185
!table->field[SPIDER_TABLES_SCHEME_POS]->is_null() &&
21882186
(ptr = get_field(mem_root, table->field[SPIDER_TABLES_SCHEME_POS]))
21892187
) {
2190-
share->tgt_wrappers_lengths[link_idx] = strlen(ptr);
2191-
share->tgt_wrappers[link_idx] =
2192-
spider_create_string(ptr, share->tgt_wrappers_lengths[link_idx]);
2188+
share->tgt_wrappers_lengths[0] = strlen(ptr);
2189+
share->tgt_wrappers[0] =
2190+
spider_create_string(ptr, share->tgt_wrappers_lengths[0]);
21932191
DBUG_PRINT("info",("spider tgt_wrapper:%s",
2194-
share->tgt_wrappers[link_idx]));
2192+
share->tgt_wrappers[0]));
21952193
} else {
2196-
share->tgt_wrappers_lengths[link_idx] = 0;
2197-
share->tgt_wrappers[link_idx] = NULL;
2194+
share->tgt_wrappers_lengths[0] = 0;
2195+
share->tgt_wrappers[0] = NULL;
21982196
DBUG_PRINT("info",("spider tgt_wrapper is NULL"));
21992197
}
22002198
if (
22012199
!table->field[SPIDER_TABLES_HOST_POS]->is_null() &&
22022200
(ptr = get_field(mem_root, table->field[SPIDER_TABLES_HOST_POS]))
22032201
) {
2204-
share->tgt_hosts_lengths[link_idx] = strlen(ptr);
2205-
share->tgt_hosts[link_idx] =
2206-
spider_create_string(ptr, share->tgt_hosts_lengths[link_idx]);
2202+
share->tgt_hosts_lengths[0] = strlen(ptr);
2203+
share->tgt_hosts[0] =
2204+
spider_create_string(ptr, share->tgt_hosts_lengths[0]);
22072205
DBUG_PRINT("info",("spider tgt_host:%s",
2208-
share->tgt_hosts[link_idx]));
2206+
share->tgt_hosts[0]));
22092207
} else {
2210-
share->tgt_hosts_lengths[link_idx] = 0;
2211-
share->tgt_hosts[link_idx] = NULL;
2208+
share->tgt_hosts_lengths[0] = 0;
2209+
share->tgt_hosts[0] = NULL;
22122210
DBUG_PRINT("info",("spider tgt_host is NULL"));
22132211
}
22142212
if (
22152213
!table->field[SPIDER_TABLES_PORT_POS]->is_null() &&
22162214
(ptr = get_field(mem_root, table->field[SPIDER_TABLES_PORT_POS]))
22172215
) {
2218-
share->tgt_ports[link_idx] = atol(ptr);
2216+
share->tgt_ports[0] = atol(ptr);
22192217
} else {
2220-
share->tgt_ports[link_idx] = -1;
2218+
share->tgt_ports[0] = -1;
22212219
}
2222-
DBUG_PRINT("info",("spider port:%ld", share->tgt_ports[link_idx]));
2220+
DBUG_PRINT("info",("spider port:%ld", share->tgt_ports[0]));
22232221
if (
22242222
!table->field[SPIDER_TABLES_SOCKET_POS]->is_null() &&
22252223
(ptr = get_field(mem_root, table->field[SPIDER_TABLES_SOCKET_POS]))
22262224
) {
2227-
share->tgt_sockets_lengths[link_idx] = strlen(ptr);
2228-
share->tgt_sockets[link_idx] =
2229-
spider_create_string(ptr, share->tgt_sockets_lengths[link_idx]);
2225+
share->tgt_sockets_lengths[0] = strlen(ptr);
2226+
share->tgt_sockets[0] =
2227+
spider_create_string(ptr, share->tgt_sockets_lengths[0]);
22302228
} else {
2231-
share->tgt_sockets_lengths[link_idx] = 0;
2232-
share->tgt_sockets[link_idx] = NULL;
2229+
share->tgt_sockets_lengths[0] = 0;
2230+
share->tgt_sockets[0] = NULL;
22332231
}
22342232
if (
22352233
!table->field[SPIDER_TABLES_USERNAME_POS]->is_null() &&
22362234
(ptr = get_field(mem_root, table->field[SPIDER_TABLES_USERNAME_POS]))
22372235
) {
2238-
share->tgt_usernames_lengths[link_idx] = strlen(ptr);
2239-
share->tgt_usernames[link_idx] =
2240-
spider_create_string(ptr, share->tgt_usernames_lengths[link_idx]);
2236+
share->tgt_usernames_lengths[0] = strlen(ptr);
2237+
share->tgt_usernames[0] =
2238+
spider_create_string(ptr, share->tgt_usernames_lengths[0]);
22412239
} else {
2242-
share->tgt_usernames_lengths[link_idx] = 0;
2243-
share->tgt_usernames[link_idx] = NULL;
2240+
share->tgt_usernames_lengths[0] = 0;
2241+
share->tgt_usernames[0] = NULL;
22442242
}
22452243
if (
22462244
!table->field[SPIDER_TABLES_PASSWORD_POS]->is_null() &&
22472245
(ptr = get_field(mem_root, table->field[SPIDER_TABLES_PASSWORD_POS]))
22482246
) {
2249-
share->tgt_passwords_lengths[link_idx] = strlen(ptr);
2250-
share->tgt_passwords[link_idx] =
2251-
spider_create_string(ptr, share->tgt_passwords_lengths[link_idx]);
2247+
share->tgt_passwords_lengths[0] = strlen(ptr);
2248+
share->tgt_passwords[0] =
2249+
spider_create_string(ptr, share->tgt_passwords_lengths[0]);
22522250
} else {
2253-
share->tgt_passwords_lengths[link_idx] = 0;
2254-
share->tgt_passwords[link_idx] = NULL;
2251+
share->tgt_passwords_lengths[0] = 0;
2252+
share->tgt_passwords[0] = NULL;
22552253
}
22562254
if (
22572255
!table->field[SPIDER_TABLES_SSL_CA_POS]->is_null() &&
22582256
(ptr = get_field(mem_root, table->field[SPIDER_TABLES_SSL_CA_POS]))
22592257
) {
2260-
share->tgt_ssl_cas_lengths[link_idx] = strlen(ptr);
2261-
share->tgt_ssl_cas[link_idx] =
2262-
spider_create_string(ptr, share->tgt_ssl_cas_lengths[link_idx]);
2258+
share->tgt_ssl_cas_lengths[0] = strlen(ptr);
2259+
share->tgt_ssl_cas[0] =
2260+
spider_create_string(ptr, share->tgt_ssl_cas_lengths[0]);
22632261
} else {
2264-
share->tgt_ssl_cas_lengths[link_idx] = 0;
2265-
share->tgt_ssl_cas[link_idx] = NULL;
2262+
share->tgt_ssl_cas_lengths[0] = 0;
2263+
share->tgt_ssl_cas[0] = NULL;
22662264
}
22672265
if (
22682266
!table->field[SPIDER_TABLES_SSL_CAPATH_POS]->is_null() &&
22692267
(ptr = get_field(mem_root, table->field[SPIDER_TABLES_SSL_CAPATH_POS]))
22702268
) {
2271-
share->tgt_ssl_capaths_lengths[link_idx] = strlen(ptr);
2272-
share->tgt_ssl_capaths[link_idx] =
2273-
spider_create_string(ptr, share->tgt_ssl_capaths_lengths[link_idx]);
2269+
share->tgt_ssl_capaths_lengths[0] = strlen(ptr);
2270+
share->tgt_ssl_capaths[0] =
2271+
spider_create_string(ptr, share->tgt_ssl_capaths_lengths[0]);
22742272
} else {
2275-
share->tgt_ssl_capaths_lengths[link_idx] = 0;
2276-
share->tgt_ssl_capaths[link_idx] = NULL;
2273+
share->tgt_ssl_capaths_lengths[0] = 0;
2274+
share->tgt_ssl_capaths[0] = NULL;
22772275
}
22782276
if (
22792277
!table->field[SPIDER_TABLES_SSL_CERT_POS]->is_null() &&
22802278
(ptr = get_field(mem_root, table->field[SPIDER_TABLES_SSL_CERT_POS]))
22812279
) {
2282-
share->tgt_ssl_certs_lengths[link_idx] = strlen(ptr);
2283-
share->tgt_ssl_certs[link_idx] =
2284-
spider_create_string(ptr, share->tgt_ssl_certs_lengths[link_idx]);
2280+
share->tgt_ssl_certs_lengths[0] = strlen(ptr);
2281+
share->tgt_ssl_certs[0] =
2282+
spider_create_string(ptr, share->tgt_ssl_certs_lengths[0]);
22852283
} else {
2286-
share->tgt_ssl_certs_lengths[link_idx] = 0;
2287-
share->tgt_ssl_certs[link_idx] = NULL;
2284+
share->tgt_ssl_certs_lengths[0] = 0;
2285+
share->tgt_ssl_certs[0] = NULL;
22882286
}
22892287
if (
22902288
!table->field[SPIDER_TABLES_SSL_CIPHER_POS]->is_null() &&
22912289
(ptr = get_field(mem_root, table->field[SPIDER_TABLES_SSL_CIPHER_POS]))
22922290
) {
2293-
share->tgt_ssl_ciphers_lengths[link_idx] = strlen(ptr);
2294-
share->tgt_ssl_ciphers[link_idx] =
2295-
spider_create_string(ptr, share->tgt_ssl_ciphers_lengths[link_idx]);
2291+
share->tgt_ssl_ciphers_lengths[0] = strlen(ptr);
2292+
share->tgt_ssl_ciphers[0] =
2293+
spider_create_string(ptr, share->tgt_ssl_ciphers_lengths[0]);
22962294
} else {
2297-
share->tgt_ssl_ciphers_lengths[link_idx] = 0;
2298-
share->tgt_ssl_ciphers[link_idx] = NULL;
2295+
share->tgt_ssl_ciphers_lengths[0] = 0;
2296+
share->tgt_ssl_ciphers[0] = NULL;
22992297
}
23002298
if (
23012299
!table->field[SPIDER_TABLES_SSL_KEY_POS]->is_null() &&
23022300
(ptr = get_field(mem_root, table->field[SPIDER_TABLES_SSL_KEY_POS]))
23032301
) {
2304-
share->tgt_ssl_keys_lengths[link_idx] = strlen(ptr);
2305-
share->tgt_ssl_keys[link_idx] =
2306-
spider_create_string(ptr, share->tgt_ssl_keys_lengths[link_idx]);
2302+
share->tgt_ssl_keys_lengths[0] = strlen(ptr);
2303+
share->tgt_ssl_keys[0] =
2304+
spider_create_string(ptr, share->tgt_ssl_keys_lengths[0]);
23072305
} else {
2308-
share->tgt_ssl_keys_lengths[link_idx] = 0;
2309-
share->tgt_ssl_keys[link_idx] = NULL;
2306+
share->tgt_ssl_keys_lengths[0] = 0;
2307+
share->tgt_ssl_keys[0] = NULL;
23102308
}
23112309
if (
23122310
!table->field[SPIDER_TABLES_SSL_VERIFY_SERVER_CERT_POS]->is_null() &&
23132311
(ptr = get_field(mem_root,
23142312
table->field[SPIDER_TABLES_SSL_VERIFY_SERVER_CERT_POS]))
23152313
) {
2316-
share->tgt_ssl_vscs[link_idx] = atol(ptr);
2314+
share->tgt_ssl_vscs[0] = atol(ptr);
23172315
} else
2318-
share->tgt_ssl_vscs[link_idx] = -1;
2316+
share->tgt_ssl_vscs[0] = -1;
23192317
if (
23202318
!table->field[SPIDER_TABLES_MONITORING_BINLOG_POS_AT_FAILING_POS]->
23212319
is_null() &&
23222320
(ptr = get_field(mem_root, table->
23232321
field[SPIDER_TABLES_MONITORING_BINLOG_POS_AT_FAILING_POS]))
23242322
) {
2325-
share->monitoring_binlog_pos_at_failing[link_idx] = atol(ptr);
2323+
share->monitoring_binlog_pos_at_failing[0] = atol(ptr);
23262324
} else
2327-
share->monitoring_binlog_pos_at_failing[link_idx] = 0;
2325+
share->monitoring_binlog_pos_at_failing[0] = 0;
23282326
if (
23292327
!table->field[SPIDER_TABLES_DEFAULT_FILE_POS]->is_null() &&
23302328
(ptr = get_field(mem_root, table->field[SPIDER_TABLES_DEFAULT_FILE_POS]))
23312329
) {
2332-
share->tgt_default_files_lengths[link_idx] = strlen(ptr);
2333-
share->tgt_default_files[link_idx] =
2334-
spider_create_string(ptr, share->tgt_default_files_lengths[link_idx]);
2330+
share->tgt_default_files_lengths[0] = strlen(ptr);
2331+
share->tgt_default_files[0] =
2332+
spider_create_string(ptr, share->tgt_default_files_lengths[0]);
23352333
} else {
2336-
share->tgt_default_files_lengths[link_idx] = 0;
2337-
share->tgt_default_files[link_idx] = NULL;
2334+
share->tgt_default_files_lengths[0] = 0;
2335+
share->tgt_default_files[0] = NULL;
23382336
}
23392337
if (
23402338
!table->field[SPIDER_TABLES_DEFAULT_GROUP_POS]->is_null() &&
23412339
(ptr = get_field(mem_root, table->field[SPIDER_TABLES_DEFAULT_GROUP_POS]))
23422340
) {
2343-
share->tgt_default_groups_lengths[link_idx] = strlen(ptr);
2344-
share->tgt_default_groups[link_idx] =
2345-
spider_create_string(ptr, share->tgt_default_groups_lengths[link_idx]);
2341+
share->tgt_default_groups_lengths[0] = strlen(ptr);
2342+
share->tgt_default_groups[0] =
2343+
spider_create_string(ptr, share->tgt_default_groups_lengths[0]);
23462344
} else {
2347-
share->tgt_default_groups_lengths[link_idx] = 0;
2348-
share->tgt_default_groups[link_idx] = NULL;
2345+
share->tgt_default_groups_lengths[0] = 0;
2346+
share->tgt_default_groups[0] = NULL;
23492347
}
23502348
if (
23512349
!table->field[SPIDER_TABLES_DSN_POS]->is_null() &&
23522350
(ptr = get_field(mem_root, table->field[SPIDER_TABLES_DSN_POS]))
23532351
) {
2354-
share->tgt_dsns_lengths[link_idx] = strlen(ptr);
2355-
share->tgt_dsns[link_idx] =
2356-
spider_create_string(ptr, share->tgt_dsns_lengths[link_idx]);
2352+
share->tgt_dsns_lengths[0] = strlen(ptr);
2353+
share->tgt_dsns[0] =
2354+
spider_create_string(ptr, share->tgt_dsns_lengths[0]);
23572355
} else {
2358-
share->tgt_dsns_lengths[link_idx] = 0;
2359-
share->tgt_dsns[link_idx] = NULL;
2356+
share->tgt_dsns_lengths[0] = 0;
2357+
share->tgt_dsns[0] = NULL;
23602358
}
23612359
if (
23622360
!table->field[SPIDER_TABLES_FILEDSN_POS]->is_null() &&
23632361
(ptr = get_field(mem_root, table->field[SPIDER_TABLES_FILEDSN_POS]))
23642362
) {
2365-
share->tgt_filedsns_lengths[link_idx] = strlen(ptr);
2366-
share->tgt_filedsns[link_idx] =
2367-
spider_create_string(ptr, share->tgt_filedsns_lengths[link_idx]);
2363+
share->tgt_filedsns_lengths[0] = strlen(ptr);
2364+
share->tgt_filedsns[0] =
2365+
spider_create_string(ptr, share->tgt_filedsns_lengths[0]);
23682366
} else {
2369-
share->tgt_filedsns_lengths[link_idx] = 0;
2370-
share->tgt_filedsns[link_idx] = NULL;
2367+
share->tgt_filedsns_lengths[0] = 0;
2368+
share->tgt_filedsns[0] = NULL;
23712369
}
23722370
if (
23732371
!table->field[SPIDER_TABLES_DRIVER_POS]->is_null() &&
23742372
(ptr = get_field(mem_root, table->field[SPIDER_TABLES_DRIVER_POS]))
23752373
) {
2376-
share->tgt_drivers_lengths[link_idx] = strlen(ptr);
2377-
share->tgt_drivers[link_idx] =
2378-
spider_create_string(ptr, share->tgt_drivers_lengths[link_idx]);
2374+
share->tgt_drivers_lengths[0] = strlen(ptr);
2375+
share->tgt_drivers[0] =
2376+
spider_create_string(ptr, share->tgt_drivers_lengths[0]);
23792377
} else {
2380-
share->tgt_drivers_lengths[link_idx] = 0;
2381-
share->tgt_drivers[link_idx] = NULL;
2378+
share->tgt_drivers_lengths[0] = 0;
2379+
share->tgt_drivers[0] = NULL;
23822380
}
23832381
if (
23842382
!table->field[SPIDER_TABLES_TGT_DB_NAME_POS]->is_null() &&
23852383
(ptr = get_field(mem_root, table->field[SPIDER_TABLES_TGT_DB_NAME_POS]))
23862384
) {
2387-
share->tgt_dbs_lengths[link_idx] = strlen(ptr);
2388-
share->tgt_dbs[link_idx] =
2389-
spider_create_string(ptr, share->tgt_dbs_lengths[link_idx]);
2385+
share->tgt_dbs_lengths[0] = strlen(ptr);
2386+
share->tgt_dbs[0] =
2387+
spider_create_string(ptr, share->tgt_dbs_lengths[0]);
23902388
} else {
2391-
share->tgt_dbs_lengths[link_idx] = 0;
2392-
share->tgt_dbs[link_idx] = NULL;
2389+
share->tgt_dbs_lengths[0] = 0;
2390+
share->tgt_dbs[0] = NULL;
23932391
}
23942392
if (
23952393
!table->field[SPIDER_TABLES_TGT_TABLE_NAME_POS]->is_null() &&
23962394
(ptr = get_field(mem_root, table->field[SPIDER_TABLES_TGT_TABLE_NAME_POS]))
23972395
) {
2398-
share->tgt_table_names_lengths[link_idx] = strlen(ptr);
2399-
share->tgt_table_names[link_idx] =
2400-
spider_create_string(ptr, share->tgt_table_names_lengths[link_idx]);
2396+
share->tgt_table_names_lengths[0] = strlen(ptr);
2397+
share->tgt_table_names[0] =
2398+
spider_create_string(ptr, share->tgt_table_names_lengths[0]);
24012399
} else {
2402-
share->tgt_table_names_lengths[link_idx] = 0;
2403-
share->tgt_table_names[link_idx] = NULL;
2400+
share->tgt_table_names_lengths[0] = 0;
2401+
share->tgt_table_names[0] = NULL;
24042402
}
24052403
if (
24062404
!table->field[SPIDER_TABLES_STATIC_LINK_ID_POS]->is_null() &&
24072405
(ptr = get_field(mem_root, table->field[SPIDER_TABLES_STATIC_LINK_ID_POS]))
24082406
) {
2409-
share->static_link_ids_lengths[link_idx] = strlen(ptr);
2410-
share->static_link_ids[link_idx] =
2411-
spider_create_string(ptr, share->static_link_ids_lengths[link_idx]);
2407+
share->static_link_ids_lengths[0] = strlen(ptr);
2408+
share->static_link_ids[0] =
2409+
spider_create_string(ptr, share->static_link_ids_lengths[0]);
24122410
} else {
2413-
share->static_link_ids_lengths[link_idx] = 0;
2414-
share->static_link_ids[link_idx] = NULL;
2411+
share->static_link_ids_lengths[0] = 0;
2412+
share->static_link_ids[0] = NULL;
24152413
}
24162414
DBUG_RETURN(error_num);
24172415
}

0 commit comments

Comments
 (0)