Commit da3c5c3c authored by Jacob Mathew's avatar Jacob Mathew

MDEV-15698: Spider ignores syntax errors in connection string in COMMENT field

When a comma separator is missing between COMMENT fields, Spider ignores the
parameter values that are beyond the last expected parameter value.  There are
also some error messages that Spider does generate on COMMENT fields that are
incorrectly formed.

I have introduced additional infrastructure in Spider to fix these problems.

Author:
  Jacob Mathew.

Reviewer:
  Kentoku Shiba.

Cherry-Picked:
  Commit c10da98b on branch bb-10.3-MDEV-15698
parent 8fdeb079
...@@ -85,13 +85,12 @@ int spider_udf_set_copy_tables_param_default( ...@@ -85,13 +85,12 @@ int spider_udf_set_copy_tables_param_default(
if (!copy_tables->param_name) \ if (!copy_tables->param_name) \
{ \ { \
if ((copy_tables->param_name = spider_get_string_between_quote( \ if ((copy_tables->param_name = spider_get_string_between_quote( \
start_ptr, TRUE))) \ start_ptr, TRUE, &param_string_parse))) \
copy_tables->SPIDER_PARAM_STR_LEN(param_name) = \ copy_tables->SPIDER_PARAM_STR_LEN(param_name) = \
strlen(copy_tables->param_name); \ strlen(copy_tables->param_name); \
else { \ else \
error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; \ { \
my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR, \ error_num = param_string_parse.print_param_error(); \
MYF(0), tmp_ptr); \
goto error; \ goto error; \
} \ } \
DBUG_PRINT("info",("spider " title_name "=%s", copy_tables->param_name)); \ DBUG_PRINT("info",("spider " title_name "=%s", copy_tables->param_name)); \
...@@ -111,9 +110,7 @@ int spider_udf_set_copy_tables_param_default( ...@@ -111,9 +110,7 @@ int spider_udf_set_copy_tables_param_default(
{ \ { \
if (hint_num < 0 || hint_num >= max_size) \ if (hint_num < 0 || hint_num >= max_size) \
{ \ { \
error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; \ error_num = param_string_parse.print_param_error(); \
my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR, \
MYF(0), tmp_ptr); \
goto error; \ goto error; \
} else if (copy_tables->param_name[hint_num] != -1) \ } else if (copy_tables->param_name[hint_num] != -1) \
break; \ break; \
...@@ -126,17 +123,13 @@ int spider_udf_set_copy_tables_param_default( ...@@ -126,17 +123,13 @@ int spider_udf_set_copy_tables_param_default(
else if (copy_tables->param_name[hint_num] > max_val) \ else if (copy_tables->param_name[hint_num] > max_val) \
copy_tables->param_name[hint_num] = max_val; \ copy_tables->param_name[hint_num] = max_val; \
} else { \ } else { \
error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; \ error_num = param_string_parse.print_param_error(); \
my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR, \
MYF(0), tmp_ptr); \
goto error; \ goto error; \
} \ } \
DBUG_PRINT("info",("spider " title_name "[%d]=%d", hint_num, \ DBUG_PRINT("info",("spider " title_name "[%d]=%d", hint_num, \
copy_tables->param_name[hint_num])); \ copy_tables->param_name[hint_num])); \
} else { \ } else { \
error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; \ error_num = param_string_parse.print_param_error(); \
my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR, \
MYF(0), tmp_ptr); \
goto error; \ goto error; \
} \ } \
break; \ break; \
...@@ -155,10 +148,11 @@ int spider_udf_set_copy_tables_param_default( ...@@ -155,10 +148,11 @@ int spider_udf_set_copy_tables_param_default(
copy_tables->param_name = min_val; \ copy_tables->param_name = min_val; \
else if (copy_tables->param_name > max_val) \ else if (copy_tables->param_name > max_val) \
copy_tables->param_name = max_val; \ copy_tables->param_name = max_val; \
param_string_parse.set_param_value(tmp_ptr2, \
tmp_ptr2 + \
strlen(tmp_ptr2) + 1); \
} else { \ } else { \
error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; \ error_num = param_string_parse.print_param_error(); \
my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR, \
MYF(0), tmp_ptr); \
goto error; \ goto error; \
} \ } \
DBUG_PRINT("info",("spider " title_name "=%d", copy_tables->param_name)); \ DBUG_PRINT("info",("spider " title_name "=%d", copy_tables->param_name)); \
...@@ -177,10 +171,11 @@ int spider_udf_set_copy_tables_param_default( ...@@ -177,10 +171,11 @@ int spider_udf_set_copy_tables_param_default(
copy_tables->param_name = atoi(tmp_ptr2); \ copy_tables->param_name = atoi(tmp_ptr2); \
if (copy_tables->param_name < min_val) \ if (copy_tables->param_name < min_val) \
copy_tables->param_name = min_val; \ copy_tables->param_name = min_val; \
param_string_parse.set_param_value(tmp_ptr2, \
tmp_ptr2 + \
strlen(tmp_ptr2) + 1); \
} else { \ } else { \
error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; \ error_num = param_string_parse.print_param_error(); \
my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR, \
MYF(0), tmp_ptr); \
goto error; \ goto error; \
} \ } \
DBUG_PRINT("info",("spider " title_name "=%d", copy_tables->param_name)); \ DBUG_PRINT("info",("spider " title_name "=%d", copy_tables->param_name)); \
...@@ -200,10 +195,11 @@ int spider_udf_set_copy_tables_param_default( ...@@ -200,10 +195,11 @@ int spider_udf_set_copy_tables_param_default(
my_strtoll10(tmp_ptr2, (char**) NULL, &error_num); \ my_strtoll10(tmp_ptr2, (char**) NULL, &error_num); \
if (copy_tables->param_name < min_val) \ if (copy_tables->param_name < min_val) \
copy_tables->param_name = min_val; \ copy_tables->param_name = min_val; \
param_string_parse.set_param_value(tmp_ptr2, \
tmp_ptr2 + \
strlen(tmp_ptr2) + 1); \
} else { \ } else { \
error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; \ error_num = param_string_parse.print_param_error(); \
my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR, \
MYF(0), tmp_ptr); \
goto error; \ goto error; \
} \ } \
DBUG_PRINT("info",("spider " title_name "=%lld", \ DBUG_PRINT("info",("spider " title_name "=%lld", \
...@@ -222,6 +218,7 @@ int spider_udf_parse_copy_tables_param( ...@@ -222,6 +218,7 @@ int spider_udf_parse_copy_tables_param(
char *sprit_ptr[2]; char *sprit_ptr[2];
char *tmp_ptr, *tmp_ptr2, *start_ptr; char *tmp_ptr, *tmp_ptr2, *start_ptr;
int title_length; int title_length;
SPIDER_PARAM_STRING_PARSE param_string_parse;
DBUG_ENTER("spider_udf_parse_copy_tables_param"); DBUG_ENTER("spider_udf_parse_copy_tables_param");
copy_tables->bulk_insert_interval = -1; copy_tables->bulk_insert_interval = -1;
copy_tables->bulk_insert_rows = -1; copy_tables->bulk_insert_rows = -1;
...@@ -246,6 +243,7 @@ int spider_udf_parse_copy_tables_param( ...@@ -246,6 +243,7 @@ int spider_udf_parse_copy_tables_param(
DBUG_PRINT("info",("spider param_string=%s", param_string)); DBUG_PRINT("info",("spider param_string=%s", param_string));
sprit_ptr[0] = param_string; sprit_ptr[0] = param_string;
param_string_parse.init(param_string, ER_SPIDER_INVALID_UDF_PARAM_NUM);
while (sprit_ptr[0]) while (sprit_ptr[0])
{ {
if ((sprit_ptr[1] = strchr(sprit_ptr[0], ','))) if ((sprit_ptr[1] = strchr(sprit_ptr[0], ',')))
...@@ -272,10 +270,14 @@ int spider_udf_parse_copy_tables_param( ...@@ -272,10 +270,14 @@ int spider_udf_parse_copy_tables_param(
title_length++; title_length++;
start_ptr++; start_ptr++;
} }
param_string_parse.set_param_title(tmp_ptr, tmp_ptr + title_length);
switch (title_length) switch (title_length)
{ {
case 0: case 0:
error_num = param_string_parse.print_param_error();
if (error_num)
goto error;
continue; continue;
case 3: case 3:
#ifndef WITHOUT_SPIDER_BG_SEARCH #ifndef WITHOUT_SPIDER_BG_SEARCH
...@@ -286,55 +288,43 @@ int spider_udf_parse_copy_tables_param( ...@@ -286,55 +288,43 @@ int spider_udf_parse_copy_tables_param(
SPIDER_PARAM_STR("dtb", database); SPIDER_PARAM_STR("dtb", database);
SPIDER_PARAM_INT_WITH_MAX("utc", use_table_charset, 0, 1); SPIDER_PARAM_INT_WITH_MAX("utc", use_table_charset, 0, 1);
SPIDER_PARAM_INT_WITH_MAX("utr", use_transaction, 0, 1); SPIDER_PARAM_INT_WITH_MAX("utr", use_transaction, 0, 1);
error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; error_num = param_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR,
MYF(0), tmp_ptr);
goto error; goto error;
#ifndef WITHOUT_SPIDER_BG_SEARCH #ifndef WITHOUT_SPIDER_BG_SEARCH
case 7: case 7:
SPIDER_PARAM_INT_WITH_MAX("bg_mode", bg_mode, 0, 1); SPIDER_PARAM_INT_WITH_MAX("bg_mode", bg_mode, 0, 1);
error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; error_num = param_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR,
MYF(0), tmp_ptr);
goto error; goto error;
#endif #endif
case 8: case 8:
SPIDER_PARAM_STR("database", database); SPIDER_PARAM_STR("database", database);
error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; error_num = param_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 15: case 15:
SPIDER_PARAM_INT_WITH_MAX("use_transaction", use_transaction, 0, 1); SPIDER_PARAM_INT_WITH_MAX("use_transaction", use_transaction, 0, 1);
error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; error_num = param_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 16: case 16:
SPIDER_PARAM_LONGLONG("bulk_insert_rows", bulk_insert_rows, 1); SPIDER_PARAM_LONGLONG("bulk_insert_rows", bulk_insert_rows, 1);
error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; error_num = param_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 17: case 17:
SPIDER_PARAM_INT_WITH_MAX( SPIDER_PARAM_INT_WITH_MAX(
"use_table_charset", use_table_charset, 0, 1); "use_table_charset", use_table_charset, 0, 1);
error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; error_num = param_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 20: case 20:
SPIDER_PARAM_INT("bulk_insert_interval", bulk_insert_interval, 0); SPIDER_PARAM_INT("bulk_insert_interval", bulk_insert_interval, 0);
error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; error_num = param_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR,
MYF(0), tmp_ptr);
goto error; goto error;
default: default:
error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; error_num = param_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR,
MYF(0), tmp_ptr);
goto error; goto error;
} }
/* Verify that the remainder of the parameter value is whitespace */
if ((error_num = param_string_parse.has_extra_parameter_values()))
goto error;
} }
set_default: set_default:
......
...@@ -916,13 +916,12 @@ int spider_udf_direct_sql_get_server( ...@@ -916,13 +916,12 @@ int spider_udf_direct_sql_get_server(
if (!direct_sql->param_name) \ if (!direct_sql->param_name) \
{ \ { \
if ((direct_sql->param_name = spider_get_string_between_quote( \ if ((direct_sql->param_name = spider_get_string_between_quote( \
start_ptr, TRUE))) \ start_ptr, TRUE, &param_string_parse))) \
direct_sql->SPIDER_PARAM_STR_LEN(param_name) = \ direct_sql->SPIDER_PARAM_STR_LEN(param_name) = \
strlen(direct_sql->param_name); \ strlen(direct_sql->param_name); \
else { \ else \
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ { \
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, \ error_num = param_string_parse.print_param_error(); \
MYF(0), tmp_ptr); \
goto error; \ goto error; \
} \ } \
DBUG_PRINT("info",("spider " title_name "=%s", direct_sql->param_name)); \ DBUG_PRINT("info",("spider " title_name "=%s", direct_sql->param_name)); \
...@@ -942,9 +941,7 @@ int spider_udf_direct_sql_get_server( ...@@ -942,9 +941,7 @@ int spider_udf_direct_sql_get_server(
{ \ { \
if (hint_num < 0 || hint_num >= max_size) \ if (hint_num < 0 || hint_num >= max_size) \
{ \ { \
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ error_num = param_string_parse.print_param_error(); \
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, \
MYF(0), tmp_ptr); \
goto error; \ goto error; \
} else if (direct_sql->param_name[hint_num] != -1) \ } else if (direct_sql->param_name[hint_num] != -1) \
break; \ break; \
...@@ -957,17 +954,13 @@ int spider_udf_direct_sql_get_server( ...@@ -957,17 +954,13 @@ int spider_udf_direct_sql_get_server(
else if (direct_sql->param_name[hint_num] > max_val) \ else if (direct_sql->param_name[hint_num] > max_val) \
direct_sql->param_name[hint_num] = max_val; \ direct_sql->param_name[hint_num] = max_val; \
} else { \ } else { \
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ error_num = param_string_parse.print_param_error(); \
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, \
MYF(0), tmp_ptr); \
goto error; \ goto error; \
} \ } \
DBUG_PRINT("info",("spider " title_name "[%d]=%d", hint_num, \ DBUG_PRINT("info",("spider " title_name "[%d]=%d", hint_num, \
direct_sql->param_name[hint_num])); \ direct_sql->param_name[hint_num])); \
} else { \ } else { \
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ error_num = param_string_parse.print_param_error(); \
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, \
MYF(0), tmp_ptr); \
goto error; \ goto error; \
} \ } \
break; \ break; \
...@@ -986,10 +979,11 @@ int spider_udf_direct_sql_get_server( ...@@ -986,10 +979,11 @@ int spider_udf_direct_sql_get_server(
direct_sql->param_name = min_val; \ direct_sql->param_name = min_val; \
else if (direct_sql->param_name > max_val) \ else if (direct_sql->param_name > max_val) \
direct_sql->param_name = max_val; \ direct_sql->param_name = max_val; \
param_string_parse.set_param_value(tmp_ptr2, \
tmp_ptr2 + \
strlen(tmp_ptr2) + 1); \
} else { \ } else { \
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ error_num = param_string_parse.print_param_error(); \
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, \
MYF(0), tmp_ptr); \
goto error; \ goto error; \
} \ } \
DBUG_PRINT("info",("spider " title_name "=%d", \ DBUG_PRINT("info",("spider " title_name "=%d", \
...@@ -1009,10 +1003,11 @@ int spider_udf_direct_sql_get_server( ...@@ -1009,10 +1003,11 @@ int spider_udf_direct_sql_get_server(
direct_sql->param_name = atoi(tmp_ptr2); \ direct_sql->param_name = atoi(tmp_ptr2); \
if (direct_sql->param_name < min_val) \ if (direct_sql->param_name < min_val) \
direct_sql->param_name = min_val; \ direct_sql->param_name = min_val; \
param_string_parse.set_param_value(tmp_ptr2, \
tmp_ptr2 + \
strlen(tmp_ptr2) + 1); \
} else { \ } else { \
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ error_num = param_string_parse.print_param_error(); \
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, \
MYF(0), tmp_ptr); \
goto error; \ goto error; \
} \ } \
DBUG_PRINT("info",("spider " title_name "=%d", direct_sql->param_name)); \ DBUG_PRINT("info",("spider " title_name "=%d", direct_sql->param_name)); \
...@@ -1032,10 +1027,11 @@ int spider_udf_direct_sql_get_server( ...@@ -1032,10 +1027,11 @@ int spider_udf_direct_sql_get_server(
my_strtoll10(tmp_ptr2, (char**) NULL, &error_num); \ my_strtoll10(tmp_ptr2, (char**) NULL, &error_num); \
if (direct_sql->param_name < min_val) \ if (direct_sql->param_name < min_val) \
direct_sql->param_name = min_val; \ direct_sql->param_name = min_val; \
param_string_parse.set_param_value(tmp_ptr2, \
tmp_ptr2 + \
strlen(tmp_ptr2) + 1); \
} else { \ } else { \
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ error_num = param_string_parse.print_param_error(); \
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, \
MYF(0), tmp_ptr); \
goto error; \ goto error; \
} \ } \
DBUG_PRINT("info",("spider " title_name "=%lld", \ DBUG_PRINT("info",("spider " title_name "=%lld", \
...@@ -1055,6 +1051,7 @@ int spider_udf_parse_direct_sql_param( ...@@ -1055,6 +1051,7 @@ int spider_udf_parse_direct_sql_param(
char *sprit_ptr[2]; char *sprit_ptr[2];
char *tmp_ptr, *tmp_ptr2, *start_ptr; char *tmp_ptr, *tmp_ptr2, *start_ptr;
int title_length; int title_length;
SPIDER_PARAM_STRING_PARSE param_string_parse;
DBUG_ENTER("spider_udf_parse_direct_sql_param"); DBUG_ENTER("spider_udf_parse_direct_sql_param");
direct_sql->tgt_port = -1; direct_sql->tgt_port = -1;
direct_sql->tgt_ssl_vsc = -1; direct_sql->tgt_ssl_vsc = -1;
...@@ -1091,6 +1088,7 @@ int spider_udf_parse_direct_sql_param( ...@@ -1091,6 +1088,7 @@ int spider_udf_parse_direct_sql_param(
DBUG_PRINT("info",("spider param_string=%s", param_string)); DBUG_PRINT("info",("spider param_string=%s", param_string));
sprit_ptr[0] = param_string; sprit_ptr[0] = param_string;
param_string_parse.init(param_string, ER_SPIDER_INVALID_UDF_PARAM_NUM);
while (sprit_ptr[0]) while (sprit_ptr[0])
{ {
if ((sprit_ptr[1] = strchr(sprit_ptr[0], ','))) if ((sprit_ptr[1] = strchr(sprit_ptr[0], ',')))
...@@ -1117,10 +1115,14 @@ int spider_udf_parse_direct_sql_param( ...@@ -1117,10 +1115,14 @@ int spider_udf_parse_direct_sql_param(
title_length++; title_length++;
start_ptr++; start_ptr++;
} }
param_string_parse.set_param_title(tmp_ptr, tmp_ptr + title_length);
switch (title_length) switch (title_length)
{ {
case 0: case 0:
error_num = param_string_parse.print_param_error();
if (error_num)
goto error;
continue; continue;
case 3: case 3:
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
...@@ -1146,120 +1148,92 @@ int spider_udf_parse_direct_sql_param( ...@@ -1146,120 +1148,92 @@ int spider_udf_parse_direct_sql_param(
SPIDER_PARAM_INT_WITH_MAX("urt", use_real_table, 0, 1); SPIDER_PARAM_INT_WITH_MAX("urt", use_real_table, 0, 1);
#endif #endif
SPIDER_PARAM_INT("wto", net_write_timeout, 0); SPIDER_PARAM_INT("wto", net_write_timeout, 0);
error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; error_num = param_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 4: case 4:
SPIDER_PARAM_INT_WITH_MAX("erwm", error_rw_mode, 0, 1); SPIDER_PARAM_INT_WITH_MAX("erwm", error_rw_mode, 0, 1);
SPIDER_PARAM_STR("host", tgt_host); SPIDER_PARAM_STR("host", tgt_host);
SPIDER_PARAM_INT_WITH_MAX("port", tgt_port, 0, 65535); SPIDER_PARAM_INT_WITH_MAX("port", tgt_port, 0, 65535);
SPIDER_PARAM_STR("user", tgt_username); SPIDER_PARAM_STR("user", tgt_username);
error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; error_num = param_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 6: case 6:
SPIDER_PARAM_STR("server", server_name); SPIDER_PARAM_STR("server", server_name);
SPIDER_PARAM_STR("socket", tgt_socket); SPIDER_PARAM_STR("socket", tgt_socket);
SPIDER_PARAM_HINT_WITH_MAX("iop", iop, 3, direct_sql->table_count, 0, 2); SPIDER_PARAM_HINT_WITH_MAX("iop", iop, 3, direct_sql->table_count, 0, 2);
SPIDER_PARAM_STR("ssl_ca", tgt_ssl_ca); SPIDER_PARAM_STR("ssl_ca", tgt_ssl_ca);
error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; error_num = param_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 7: case 7:
SPIDER_PARAM_STR("wrapper", tgt_wrapper); SPIDER_PARAM_STR("wrapper", tgt_wrapper);
SPIDER_PARAM_STR("ssl_key", tgt_ssl_key); SPIDER_PARAM_STR("ssl_key", tgt_ssl_key);
error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; error_num = param_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 8: case 8:
SPIDER_PARAM_STR("database", tgt_default_db_name); SPIDER_PARAM_STR("database", tgt_default_db_name);
SPIDER_PARAM_STR("password", tgt_password); SPIDER_PARAM_STR("password", tgt_password);
SPIDER_PARAM_LONGLONG("priority", priority, 0); SPIDER_PARAM_LONGLONG("priority", priority, 0);
SPIDER_PARAM_STR("ssl_cert", tgt_ssl_cert); SPIDER_PARAM_STR("ssl_cert", tgt_ssl_cert);
error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; error_num = param_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 10: case 10:
SPIDER_PARAM_STR("ssl_cipher", tgt_ssl_cipher); SPIDER_PARAM_STR("ssl_cipher", tgt_ssl_cipher);
SPIDER_PARAM_STR("ssl_capath", tgt_ssl_capath); SPIDER_PARAM_STR("ssl_capath", tgt_ssl_capath);
error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; error_num = param_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 11: case 11:
#if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET) #if defined(HS_HAS_SQLCOM) && defined(HAVE_HANDLERSOCKET)
SPIDER_PARAM_INT_WITH_MAX("access_mode", access_mode, 0, 2); SPIDER_PARAM_INT_WITH_MAX("access_mode", access_mode, 0, 2);
#endif #endif
error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; error_num = param_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 12: case 12:
SPIDER_PARAM_STR("default_file", tgt_default_file); SPIDER_PARAM_STR("default_file", tgt_default_file);
error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; error_num = param_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 13: case 13:
SPIDER_PARAM_STR("default_group", tgt_default_group); SPIDER_PARAM_STR("default_group", tgt_default_group);
SPIDER_PARAM_INT_WITH_MAX("error_rw_mode", error_rw_mode, 0, 1); SPIDER_PARAM_INT_WITH_MAX("error_rw_mode", error_rw_mode, 0, 1);
error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; error_num = param_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 14: case 14:
#if MYSQL_VERSION_ID < 50500 #if MYSQL_VERSION_ID < 50500
#else #else
SPIDER_PARAM_INT_WITH_MAX("use_real_table", use_real_table, 0, 1); SPIDER_PARAM_INT_WITH_MAX("use_real_table", use_real_table, 0, 1);
#endif #endif
error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; error_num = param_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 15: case 15:
SPIDER_PARAM_INT_WITH_MAX("table_loop_mode", table_loop_mode, 0, 2); SPIDER_PARAM_INT_WITH_MAX("table_loop_mode", table_loop_mode, 0, 2);
SPIDER_PARAM_INT("connect_timeout", connect_timeout, 0); SPIDER_PARAM_INT("connect_timeout", connect_timeout, 0);
error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; error_num = param_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 16: case 16:
SPIDER_PARAM_LONGLONG("bulk_insert_rows", bulk_insert_rows, 1); SPIDER_PARAM_LONGLONG("bulk_insert_rows", bulk_insert_rows, 1);
SPIDER_PARAM_INT("net_read_timeout", net_read_timeout, 0); SPIDER_PARAM_INT("net_read_timeout", net_read_timeout, 0);
error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; error_num = param_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 17: case 17:
SPIDER_PARAM_INT("net_write_timeout", net_write_timeout, 0); SPIDER_PARAM_INT("net_write_timeout", net_write_timeout, 0);
error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; error_num = param_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 18: case 18:
SPIDER_PARAM_INT_WITH_MAX( SPIDER_PARAM_INT_WITH_MAX(
"connection_channel", connection_channel, 0, 63); "connection_channel", connection_channel, 0, 63);
error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; error_num = param_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 22: case 22:
SPIDER_PARAM_INT_WITH_MAX("ssl_verify_server_cert", tgt_ssl_vsc, 0, 1); SPIDER_PARAM_INT_WITH_MAX("ssl_verify_server_cert", tgt_ssl_vsc, 0, 1);
error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; error_num = param_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR,
MYF(0), tmp_ptr);
goto error; goto error;
default: default:
error_num = ER_SPIDER_INVALID_UDF_PARAM_NUM; error_num = param_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR,
MYF(0), tmp_ptr);
goto error; goto error;
} }
/* Verify that the remainder of the parameter value is whitespace */
if ((error_num = param_string_parse.has_extra_parameter_values()))
goto error;
} }
set_default: set_default:
......
...@@ -925,7 +925,8 @@ void spider_free_tmp_share_alloc( ...@@ -925,7 +925,8 @@ void spider_free_tmp_share_alloc(
char *spider_get_string_between_quote( char *spider_get_string_between_quote(
char *ptr, char *ptr,
bool alloc bool alloc,
SPIDER_PARAM_STRING_PARSE *param_string_parse
) { ) {
char *start_ptr, *end_ptr, *tmp_ptr, *esc_ptr; char *start_ptr, *end_ptr, *tmp_ptr, *esc_ptr;
bool find_flg = FALSE, esc_flg = FALSE; bool find_flg = FALSE, esc_flg = FALSE;
...@@ -1016,6 +1017,10 @@ char *spider_get_string_between_quote( ...@@ -1016,6 +1017,10 @@ char *spider_get_string_between_quote(
strcpy(esc_ptr, esc_ptr + 1); strcpy(esc_ptr, esc_ptr + 1);
} }
} }
if (param_string_parse)
param_string_parse->set_param_value(start_ptr, start_ptr + strlen(start_ptr) + 1);
if (alloc) if (alloc)
{ {
DBUG_RETURN( DBUG_RETURN(
...@@ -1033,7 +1038,8 @@ int spider_create_string_list( ...@@ -1033,7 +1038,8 @@ int spider_create_string_list(
uint **string_length_list, uint **string_length_list,
uint *list_length, uint *list_length,
char *str, char *str,
uint length uint length,
SPIDER_PARAM_STRING_PARSE *param_string_parse
) { ) {
int roop_count; int roop_count;
char *tmp_ptr, *tmp_ptr2, *tmp_ptr3, *esc_ptr; char *tmp_ptr, *tmp_ptr2, *tmp_ptr3, *esc_ptr;
...@@ -1041,6 +1047,7 @@ int spider_create_string_list( ...@@ -1041,6 +1047,7 @@ int spider_create_string_list(
DBUG_ENTER("spider_create_string_list"); DBUG_ENTER("spider_create_string_list");
*list_length = 0; *list_length = 0;
param_string_parse->init_param_value();
if (!str) if (!str)
{ {
*string_list = NULL; *string_list = NULL;
...@@ -1151,6 +1158,10 @@ int spider_create_string_list( ...@@ -1151,6 +1158,10 @@ int spider_create_string_list(
my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM); my_error(ER_OUT_OF_RESOURCES, MYF(0), HA_ERR_OUT_OF_MEM);
DBUG_RETURN(HA_ERR_OUT_OF_MEM); DBUG_RETURN(HA_ERR_OUT_OF_MEM);
} }
param_string_parse->set_param_value(tmp_ptr3,
tmp_ptr3 + strlen(tmp_ptr3) + 1);
DBUG_PRINT("info",("spider string_list[%d]=%s", roop_count, DBUG_PRINT("info",("spider string_list[%d]=%s", roop_count,
(*string_list)[roop_count])); (*string_list)[roop_count]));
...@@ -1163,13 +1174,15 @@ int spider_create_long_list( ...@@ -1163,13 +1174,15 @@ int spider_create_long_list(
char *str, char *str,
uint length, uint length,
long min_val, long min_val,
long max_val long max_val,
SPIDER_PARAM_STRING_PARSE *param_string_parse
) { ) {
int roop_count; int roop_count;
char *tmp_ptr; char *tmp_ptr;
DBUG_ENTER("spider_create_long_list"); DBUG_ENTER("spider_create_long_list");
*list_length = 0; *list_length = 0;
param_string_parse->init_param_value();
if (!str) if (!str)
{ {
*long_list = NULL; *long_list = NULL;
...@@ -1225,6 +1238,9 @@ int spider_create_long_list( ...@@ -1225,6 +1238,9 @@ int spider_create_long_list(
(*long_list)[roop_count] = max_val; (*long_list)[roop_count] = max_val;
} }
param_string_parse->set_param_value(tmp_ptr,
tmp_ptr + strlen(tmp_ptr) + 1);
#ifndef DBUG_OFF #ifndef DBUG_OFF
for (roop_count = 0; roop_count < (int) *list_length; roop_count++) for (roop_count = 0; roop_count < (int) *list_length; roop_count++)
{ {
...@@ -1242,13 +1258,15 @@ int spider_create_longlong_list( ...@@ -1242,13 +1258,15 @@ int spider_create_longlong_list(
char *str, char *str,
uint length, uint length,
longlong min_val, longlong min_val,
longlong max_val longlong max_val,
SPIDER_PARAM_STRING_PARSE *param_string_parse
) { ) {
int error_num, roop_count; int error_num, roop_count;
char *tmp_ptr; char *tmp_ptr;
DBUG_ENTER("spider_create_longlong_list"); DBUG_ENTER("spider_create_longlong_list");
*list_length = 0; *list_length = 0;
param_string_parse->init_param_value();
if (!str) if (!str)
{ {
*longlong_list = NULL; *longlong_list = NULL;
...@@ -1305,6 +1323,9 @@ int spider_create_longlong_list( ...@@ -1305,6 +1323,9 @@ int spider_create_longlong_list(
(*longlong_list)[roop_count] = max_val; (*longlong_list)[roop_count] = max_val;
} }
param_string_parse->set_param_value(tmp_ptr,
tmp_ptr + strlen(tmp_ptr) + 1);
#ifndef DBUG_OFF #ifndef DBUG_OFF
for (roop_count = 0; roop_count < (int) *list_length; roop_count++) for (roop_count = 0; roop_count < (int) *list_length; roop_count++)
{ {
...@@ -1494,6 +1515,38 @@ static int spider_set_ll_value( ...@@ -1494,6 +1515,38 @@ static int spider_set_ll_value(
DBUG_RETURN(error_num); DBUG_RETURN(error_num);
} }
/**
Print a parameter string error message.
@return Error code.
*/
int st_spider_param_string_parse::print_param_error()
{
if (start_title_ptr)
{
/* Restore the input delimiter characters */
restore_delims();
/* Print the error message */
switch (error_num)
{
case ER_SPIDER_INVALID_UDF_PARAM_NUM:
my_printf_error(error_num, ER_SPIDER_INVALID_UDF_PARAM_STR,
MYF(0), start_title_ptr);
break;
case ER_SPIDER_INVALID_CONNECT_INFO_NUM:
default:
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR,
MYF(0), start_title_ptr);
}
return error_num;
}
else
return 0;
}
#define SPIDER_PARAM_STR_LEN(name) name ## _length #define SPIDER_PARAM_STR_LEN(name) name ## _length
#define SPIDER_PARAM_STR(title_name, param_name) \ #define SPIDER_PARAM_STR(title_name, param_name) \
if (!strncasecmp(tmp_ptr, title_name, title_length)) \ if (!strncasecmp(tmp_ptr, title_name, title_length)) \
...@@ -1502,12 +1555,11 @@ static int spider_set_ll_value( ...@@ -1502,12 +1555,11 @@ static int spider_set_ll_value(
if (!share->param_name) \ if (!share->param_name) \
{ \ { \
if ((share->param_name = spider_get_string_between_quote( \ if ((share->param_name = spider_get_string_between_quote( \
start_ptr, TRUE))) \ start_ptr, TRUE, &connect_string_parse))) \
share->SPIDER_PARAM_STR_LEN(param_name) = strlen(share->param_name); \ share->SPIDER_PARAM_STR_LEN(param_name) = strlen(share->param_name); \
else { \ else \
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ { \
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, \ error_num = connect_string_parse.print_param_error(); \
MYF(0), tmp_ptr); \
goto error; \ goto error; \
} \ } \
DBUG_PRINT("info",("spider " title_name "=%s", share->param_name)); \ DBUG_PRINT("info",("spider " title_name "=%s", share->param_name)); \
...@@ -1531,12 +1583,11 @@ static int spider_set_ll_value( ...@@ -1531,12 +1583,11 @@ static int spider_set_ll_value(
&share->SPIDER_PARAM_STR_LENS(param_name), \ &share->SPIDER_PARAM_STR_LENS(param_name), \
&share->SPIDER_PARAM_STR_LEN(param_name), \ &share->SPIDER_PARAM_STR_LEN(param_name), \
tmp_ptr2, \ tmp_ptr2, \
share->SPIDER_PARAM_STR_CHARLEN(param_name)))) \ share->SPIDER_PARAM_STR_CHARLEN(param_name), \
&connect_string_parse))) \
goto error; \ goto error; \
} else { \ } else { \
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ error_num = connect_string_parse.print_param_error(); \
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, \
MYF(0), tmp_ptr); \
goto error; \ goto error; \
} \ } \
} \ } \
...@@ -1554,9 +1605,7 @@ static int spider_set_ll_value( ...@@ -1554,9 +1605,7 @@ static int spider_set_ll_value(
{ \ { \
if (hint_num < 0 || hint_num >= max_size) \ if (hint_num < 0 || hint_num >= max_size) \
{ \ { \
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ error_num = connect_string_parse.print_param_error(); \
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, \
MYF(0), tmp_ptr); \
goto error; \ goto error; \
} else if (share->param_name[hint_num].length() > 0) \ } else if (share->param_name[hint_num].length() > 0) \
break; \ break; \
...@@ -1567,9 +1616,7 @@ static int spider_set_ll_value( ...@@ -1567,9 +1616,7 @@ static int spider_set_ll_value(
DBUG_PRINT("info",("spider " title_name "[%d]=%s", hint_num, \ DBUG_PRINT("info",("spider " title_name "[%d]=%s", hint_num, \
share->param_name[hint_num].ptr())); \ share->param_name[hint_num].ptr())); \
} else { \ } else { \
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ error_num = connect_string_parse.print_param_error(); \
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, \
MYF(0), tmp_ptr); \
goto error; \ goto error; \
} \ } \
break; \ break; \
...@@ -1586,9 +1633,7 @@ static int spider_set_ll_value( ...@@ -1586,9 +1633,7 @@ static int spider_set_ll_value(
{ \ { \
if (hint_num < 0 || hint_num >= max_size) \ if (hint_num < 0 || hint_num >= max_size) \
{ \ { \
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ error_num = connect_string_parse.print_param_error(); \
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, \
MYF(0), tmp_ptr); \
goto error; \ goto error; \
} else if (share->param_name[hint_num] != -1) \ } else if (share->param_name[hint_num] != -1) \
break; \ break; \
...@@ -1599,9 +1644,7 @@ static int spider_set_ll_value( ...@@ -1599,9 +1644,7 @@ static int spider_set_ll_value(
DBUG_PRINT("info",("spider " title_name "[%d]=%lld", hint_num, \ DBUG_PRINT("info",("spider " title_name "[%d]=%lld", hint_num, \
share->param_name[hint_num])); \ share->param_name[hint_num])); \
} else { \ } else { \
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ error_num = connect_string_parse.print_param_error(); \
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, \
MYF(0), tmp_ptr); \
goto error; \ goto error; \
} \ } \
break; \ break; \
...@@ -1622,12 +1665,11 @@ static int spider_set_ll_value( ...@@ -1622,12 +1665,11 @@ static int spider_set_ll_value(
&share->SPIDER_PARAM_LONG_LEN(param_name), \ &share->SPIDER_PARAM_LONG_LEN(param_name), \
tmp_ptr2, \ tmp_ptr2, \
strlen(tmp_ptr2), \ strlen(tmp_ptr2), \
min_val, max_val))) \ min_val, max_val, \
&connect_string_parse))) \
goto error; \ goto error; \
} else { \ } else { \
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ error_num = connect_string_parse.print_param_error(); \
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, \
MYF(0), tmp_ptr); \
goto error; \ goto error; \
} \ } \
} \ } \
...@@ -1649,12 +1691,11 @@ static int spider_set_ll_value( ...@@ -1649,12 +1691,11 @@ static int spider_set_ll_value(
&share->SPIDER_PARAM_LONGLONG_LEN(param_name), \ &share->SPIDER_PARAM_LONGLONG_LEN(param_name), \
tmp_ptr2, \ tmp_ptr2, \
strlen(tmp_ptr2), \ strlen(tmp_ptr2), \
min_val, max_val))) \ min_val, max_val, \
&connect_string_parse))) \
goto error; \ goto error; \
} else { \ } else { \
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ error_num = connect_string_parse.print_param_error(); \
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, \
MYF(0), tmp_ptr); \
goto error; \ goto error; \
} \ } \
} \ } \
...@@ -1674,10 +1715,11 @@ static int spider_set_ll_value( ...@@ -1674,10 +1715,11 @@ static int spider_set_ll_value(
share->param_name = min_val; \ share->param_name = min_val; \
else if (share->param_name > max_val) \ else if (share->param_name > max_val) \
share->param_name = max_val; \ share->param_name = max_val; \
connect_string_parse.set_param_value(tmp_ptr2, \
tmp_ptr2 + \
strlen(tmp_ptr2) + 1); \
} else { \ } else { \
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ error_num = connect_string_parse.print_param_error(); \
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, \
MYF(0), tmp_ptr); \
goto error; \ goto error; \
} \ } \
DBUG_PRINT("info",("spider " title_name "=%d", share->param_name)); \ DBUG_PRINT("info",("spider " title_name "=%d", share->param_name)); \
...@@ -1696,10 +1738,11 @@ static int spider_set_ll_value( ...@@ -1696,10 +1738,11 @@ static int spider_set_ll_value(
share->param_name = atoi(tmp_ptr2); \ share->param_name = atoi(tmp_ptr2); \
if (share->param_name < min_val) \ if (share->param_name < min_val) \
share->param_name = min_val; \ share->param_name = min_val; \
connect_string_parse.set_param_value(tmp_ptr2, \
tmp_ptr2 + \
strlen(tmp_ptr2) + 1); \
} else { \ } else { \
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ error_num = connect_string_parse.print_param_error(); \
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, \
MYF(0), tmp_ptr); \
goto error; \ goto error; \
} \ } \
DBUG_PRINT("info",("spider " title_name "=%d", share->param_name)); \ DBUG_PRINT("info",("spider " title_name "=%d", share->param_name)); \
...@@ -1718,10 +1761,11 @@ static int spider_set_ll_value( ...@@ -1718,10 +1761,11 @@ static int spider_set_ll_value(
share->param_name = my_atof(tmp_ptr2); \ share->param_name = my_atof(tmp_ptr2); \
if (share->param_name < min_val) \ if (share->param_name < min_val) \
share->param_name = min_val; \ share->param_name = min_val; \
connect_string_parse.set_param_value(tmp_ptr2, \
tmp_ptr2 + \
strlen(tmp_ptr2) + 1); \
} else { \ } else { \
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ error_num = connect_string_parse.print_param_error(); \
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, \
MYF(0), tmp_ptr); \
goto error; \ goto error; \
} \ } \
DBUG_PRINT("info",("spider " title_name "=%f", share->param_name)); \ DBUG_PRINT("info",("spider " title_name "=%f", share->param_name)); \
...@@ -1740,10 +1784,11 @@ static int spider_set_ll_value( ...@@ -1740,10 +1784,11 @@ static int spider_set_ll_value(
share->param_name = my_strtoll10(tmp_ptr2, (char**) NULL, &error_num); \ share->param_name = my_strtoll10(tmp_ptr2, (char**) NULL, &error_num); \
if (share->param_name < min_val) \ if (share->param_name < min_val) \
share->param_name = min_val; \ share->param_name = min_val; \
connect_string_parse.set_param_value(tmp_ptr2, \
tmp_ptr2 + \
strlen(tmp_ptr2) + 1); \
} else { \ } else { \
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; \ error_num = connect_string_parse.print_param_error(); \
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR, \
MYF(0), tmp_ptr); \
goto error; \ goto error; \
} \ } \
DBUG_PRINT("info",("spider " title_name "=%lld", share->param_name)); \ DBUG_PRINT("info",("spider " title_name "=%lld", share->param_name)); \
...@@ -1765,6 +1810,7 @@ int spider_parse_connect_info( ...@@ -1765,6 +1810,7 @@ int spider_parse_connect_info(
char *tmp_ptr, *tmp_ptr2, *start_ptr; char *tmp_ptr, *tmp_ptr2, *start_ptr;
int roop_count; int roop_count;
int title_length; int title_length;
SPIDER_PARAM_STRING_PARSE connect_string_parse;
SPIDER_ALTER_TABLE *share_alter; SPIDER_ALTER_TABLE *share_alter;
#ifdef WITH_PARTITION_STORAGE_ENGINE #ifdef WITH_PARTITION_STORAGE_ENGINE
partition_element *part_elem; partition_element *part_elem;
...@@ -1948,6 +1994,7 @@ int spider_parse_connect_info( ...@@ -1948,6 +1994,7 @@ int spider_parse_connect_info(
} }
sprit_ptr[0] = connect_string; sprit_ptr[0] = connect_string;
connect_string_parse.init(connect_string, ER_SPIDER_INVALID_CONNECT_INFO_NUM);
while (sprit_ptr[0]) while (sprit_ptr[0])
{ {
if ((sprit_ptr[1] = strchr(sprit_ptr[0], ','))) if ((sprit_ptr[1] = strchr(sprit_ptr[0], ',')))
...@@ -1974,10 +2021,14 @@ int spider_parse_connect_info( ...@@ -1974,10 +2021,14 @@ int spider_parse_connect_info(
title_length++; title_length++;
start_ptr++; start_ptr++;
} }
connect_string_parse.set_param_title(tmp_ptr, tmp_ptr + title_length);
switch (title_length) switch (title_length)
{ {
case 0: case 0:
error_num = connect_string_parse.print_param_error();
if (error_num)
goto error;
continue; continue;
case 3: case 3:
SPIDER_PARAM_LONG_LIST_WITH_MAX("abl", access_balances, 0, SPIDER_PARAM_LONG_LIST_WITH_MAX("abl", access_balances, 0,
...@@ -2111,23 +2162,17 @@ int spider_parse_connect_info( ...@@ -2111,23 +2162,17 @@ int spider_parse_connect_info(
#endif #endif
SPIDER_PARAM_INT_WITH_MAX("upu", use_pushdown_udf, 0, 1); SPIDER_PARAM_INT_WITH_MAX("upu", use_pushdown_udf, 0, 1);
SPIDER_PARAM_INT_WITH_MAX("utc", use_table_charset, 0, 1); SPIDER_PARAM_INT_WITH_MAX("utc", use_table_charset, 0, 1);
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; error_num = connect_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 4: case 4:
SPIDER_PARAM_STR_LIST("host", tgt_hosts); SPIDER_PARAM_STR_LIST("host", tgt_hosts);
SPIDER_PARAM_STR_LIST("user", tgt_usernames); SPIDER_PARAM_STR_LIST("user", tgt_usernames);
SPIDER_PARAM_LONG_LIST_WITH_MAX("port", tgt_ports, 0, 65535); SPIDER_PARAM_LONG_LIST_WITH_MAX("port", tgt_ports, 0, 65535);
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; error_num = connect_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 5: case 5:
SPIDER_PARAM_STR_LIST("table", tgt_table_names); SPIDER_PARAM_STR_LIST("table", tgt_table_names);
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; error_num = connect_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 6: case 6:
SPIDER_PARAM_STR_LIST("server", server_names); SPIDER_PARAM_STR_LIST("server", server_names);
...@@ -2137,17 +2182,13 @@ int spider_parse_connect_info( ...@@ -2137,17 +2182,13 @@ int spider_parse_connect_info(
SPIDER_PARAM_STR_LIST("ssl_ca", tgt_ssl_cas); SPIDER_PARAM_STR_LIST("ssl_ca", tgt_ssl_cas);
SPIDER_PARAM_NUMHINT("skc", static_key_cardinality, 3, SPIDER_PARAM_NUMHINT("skc", static_key_cardinality, 3,
(int) table_share->keys, spider_set_ll_value); (int) table_share->keys, spider_set_ll_value);
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; error_num = connect_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 7: case 7:
SPIDER_PARAM_STR_LIST("wrapper", tgt_wrappers); SPIDER_PARAM_STR_LIST("wrapper", tgt_wrappers);
SPIDER_PARAM_STR_LIST("ssl_key", tgt_ssl_keys); SPIDER_PARAM_STR_LIST("ssl_key", tgt_ssl_keys);
SPIDER_PARAM_STR_LIST("pk_name", tgt_pk_names); SPIDER_PARAM_STR_LIST("pk_name", tgt_pk_names);
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; error_num = connect_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 8: case 8:
SPIDER_PARAM_STR_LIST("database", tgt_dbs); SPIDER_PARAM_STR_LIST("database", tgt_dbs);
...@@ -2167,18 +2208,14 @@ int spider_parse_connect_info( ...@@ -2167,18 +2208,14 @@ int spider_parse_connect_info(
#endif #endif
SPIDER_PARAM_STR_LIST("ssl_cert", tgt_ssl_certs); SPIDER_PARAM_STR_LIST("ssl_cert", tgt_ssl_certs);
SPIDER_PARAM_INT_WITH_MAX("bka_mode", bka_mode, 0, 2); SPIDER_PARAM_INT_WITH_MAX("bka_mode", bka_mode, 0, 2);
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; error_num = connect_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 9: case 9:
SPIDER_PARAM_INT("max_order", max_order, 0); SPIDER_PARAM_INT("max_order", max_order, 0);
SPIDER_PARAM_INT("bulk_size", bulk_size, 0); SPIDER_PARAM_INT("bulk_size", bulk_size, 0);
SPIDER_PARAM_DOUBLE("scan_rate", scan_rate, 0); SPIDER_PARAM_DOUBLE("scan_rate", scan_rate, 0);
SPIDER_PARAM_DOUBLE("read_rate", read_rate, 0); SPIDER_PARAM_DOUBLE("read_rate", read_rate, 0);
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; error_num = connect_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 10: case 10:
SPIDER_PARAM_DOUBLE("crd_weight", crd_weight, 1); SPIDER_PARAM_DOUBLE("crd_weight", crd_weight, 1);
...@@ -2188,9 +2225,7 @@ int spider_parse_connect_info( ...@@ -2188,9 +2225,7 @@ int spider_parse_connect_info(
SPIDER_PARAM_STR_LIST("ssl_capath", tgt_ssl_capaths); SPIDER_PARAM_STR_LIST("ssl_capath", tgt_ssl_capaths);
SPIDER_PARAM_STR("bka_engine", bka_engine); SPIDER_PARAM_STR("bka_engine", bka_engine);
SPIDER_PARAM_LONGLONG("first_read", first_read, 0); SPIDER_PARAM_LONGLONG("first_read", first_read, 0);
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; error_num = connect_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 11: case 11:
SPIDER_PARAM_INT_WITH_MAX("query_cache", query_cache, 0, 2); SPIDER_PARAM_INT_WITH_MAX("query_cache", query_cache, 0, 2);
...@@ -2204,9 +2239,7 @@ int spider_parse_connect_info( ...@@ -2204,9 +2239,7 @@ int spider_parse_connect_info(
SPIDER_PARAM_LONG_LIST_WITH_MAX("use_hs_read", use_hs_reads, 0, 1); SPIDER_PARAM_LONG_LIST_WITH_MAX("use_hs_read", use_hs_reads, 0, 1);
#endif #endif
SPIDER_PARAM_INT_WITH_MAX("casual_read", casual_read, 0, 63); SPIDER_PARAM_INT_WITH_MAX("casual_read", casual_read, 0, 63);
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; error_num = connect_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 12: case 12:
SPIDER_PARAM_DOUBLE("sts_interval", sts_interval, 0); SPIDER_PARAM_DOUBLE("sts_interval", sts_interval, 0);
...@@ -2219,9 +2252,7 @@ int spider_parse_connect_info( ...@@ -2219,9 +2252,7 @@ int spider_parse_connect_info(
SPIDER_PARAM_LONG_LIST_WITH_MAX( SPIDER_PARAM_LONG_LIST_WITH_MAX(
"hs_read_port", hs_read_ports, 0, 65535); "hs_read_port", hs_read_ports, 0, 65535);
#endif #endif
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; error_num = connect_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 13: case 13:
SPIDER_PARAM_STR_LIST("default_group", tgt_default_groups); SPIDER_PARAM_STR_LIST("default_group", tgt_default_groups);
...@@ -2230,9 +2261,7 @@ int spider_parse_connect_info( ...@@ -2230,9 +2261,7 @@ int spider_parse_connect_info(
"hs_write_port", hs_write_ports, 0, 65535); "hs_write_port", hs_write_ports, 0, 65535);
#endif #endif
SPIDER_PARAM_STR_LIST("sequence_name", tgt_sequence_names); SPIDER_PARAM_STR_LIST("sequence_name", tgt_sequence_names);
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; error_num = connect_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 14: case 14:
SPIDER_PARAM_LONGLONG("internal_limit", internal_limit, 0); SPIDER_PARAM_LONGLONG("internal_limit", internal_limit, 0);
...@@ -2246,9 +2275,7 @@ int spider_parse_connect_info( ...@@ -2246,9 +2275,7 @@ int spider_parse_connect_info(
SPIDER_PARAM_INT_WITH_MAX("read_only_mode", read_only_mode, 0, 1); SPIDER_PARAM_INT_WITH_MAX("read_only_mode", read_only_mode, 0, 1);
SPIDER_PARAM_LONG_LIST_WITH_MAX("access_balance", access_balances, 0, SPIDER_PARAM_LONG_LIST_WITH_MAX("access_balance", access_balances, 0,
2147483647); 2147483647);
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; error_num = connect_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 15: case 15:
SPIDER_PARAM_LONGLONG("internal_offset", internal_offset, 0); SPIDER_PARAM_LONGLONG("internal_offset", internal_offset, 0);
...@@ -2268,9 +2295,7 @@ int spider_parse_connect_info( ...@@ -2268,9 +2295,7 @@ int spider_parse_connect_info(
SPIDER_PARAM_LONG_LIST_WITH_MAX("connect_timeout", connect_timeouts, SPIDER_PARAM_LONG_LIST_WITH_MAX("connect_timeout", connect_timeouts,
0, 2147483647); 0, 2147483647);
SPIDER_PARAM_INT_WITH_MAX("error_read_mode", error_read_mode, 0, 1); SPIDER_PARAM_INT_WITH_MAX("error_read_mode", error_read_mode, 0, 1);
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; error_num = connect_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 16: case 16:
SPIDER_PARAM_INT_WITH_MAX( SPIDER_PARAM_INT_WITH_MAX(
...@@ -2302,9 +2327,7 @@ int spider_parse_connect_info( ...@@ -2302,9 +2327,7 @@ int spider_parse_connect_info(
#endif #endif
SPIDER_PARAM_INT_WITH_MAX( SPIDER_PARAM_INT_WITH_MAX(
"query_cache_sync", query_cache_sync, 0, 3); "query_cache_sync", query_cache_sync, 0, 3);
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; error_num = connect_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 17: case 17:
SPIDER_PARAM_INT_WITH_MAX( SPIDER_PARAM_INT_WITH_MAX(
...@@ -2324,9 +2347,7 @@ int spider_parse_connect_info( ...@@ -2324,9 +2347,7 @@ int spider_parse_connect_info(
SPIDER_PARAM_INT_WITH_MAX( SPIDER_PARAM_INT_WITH_MAX(
"force_bulk_update", force_bulk_update, 0, 1); "force_bulk_update", force_bulk_update, 0, 1);
#endif #endif
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; error_num = connect_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 18: case 18:
SPIDER_PARAM_INT_WITH_MAX( SPIDER_PARAM_INT_WITH_MAX(
...@@ -2339,9 +2360,7 @@ int spider_parse_connect_info( ...@@ -2339,9 +2360,7 @@ int spider_parse_connect_info(
#endif #endif
SPIDER_PARAM_LONGLONG( SPIDER_PARAM_LONGLONG(
"direct_order_limit", direct_order_limit, 0); "direct_order_limit", direct_order_limit, 0);
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; error_num = connect_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 19: case 19:
SPIDER_PARAM_INT("init_sql_alloc_size", init_sql_alloc_size, 0); SPIDER_PARAM_INT("init_sql_alloc_size", init_sql_alloc_size, 0);
...@@ -2352,25 +2371,19 @@ int spider_parse_connect_info( ...@@ -2352,25 +2371,19 @@ int spider_parse_connect_info(
#endif #endif
SPIDER_PARAM_LONG_LIST_WITH_MAX("bka_table_name_type", SPIDER_PARAM_LONG_LIST_WITH_MAX("bka_table_name_type",
bka_table_name_types, 0, 1); bka_table_name_types, 0, 1);
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; error_num = connect_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 20: case 20:
SPIDER_PARAM_LONGLONG_LIST_WITH_MAX( SPIDER_PARAM_LONGLONG_LIST_WITH_MAX(
"monitoring_server_id", monitoring_sid, 0, 4294967295LL); "monitoring_server_id", monitoring_sid, 0, 4294967295LL);
SPIDER_PARAM_INT_WITH_MAX( SPIDER_PARAM_INT_WITH_MAX(
"delete_all_rows_type", delete_all_rows_type, 0, 1); "delete_all_rows_type", delete_all_rows_type, 0, 1);
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; error_num = connect_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 21: case 21:
SPIDER_PARAM_LONGLONG( SPIDER_PARAM_LONGLONG(
"semi_split_read_limit", semi_split_read_limit, 0); "semi_split_read_limit", semi_split_read_limit, 0);
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; error_num = connect_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 22: case 22:
SPIDER_PARAM_LONG_LIST_WITH_MAX( SPIDER_PARAM_LONG_LIST_WITH_MAX(
...@@ -2383,39 +2396,33 @@ int spider_parse_connect_info( ...@@ -2383,39 +2396,33 @@ int spider_parse_connect_info(
"skip_default_condition", skip_default_condition, 0, 1); "skip_default_condition", skip_default_condition, 0, 1);
SPIDER_PARAM_LONGLONG( SPIDER_PARAM_LONGLONG(
"static_mean_rec_length", static_mean_rec_length, 0); "static_mean_rec_length", static_mean_rec_length, 0);
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; error_num = connect_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 23: case 23:
SPIDER_PARAM_INT_WITH_MAX( SPIDER_PARAM_INT_WITH_MAX(
"internal_optimize_local", internal_optimize_local, 0, 1); "internal_optimize_local", internal_optimize_local, 0, 1);
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; error_num = connect_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 25: case 25:
SPIDER_PARAM_LONGLONG("static_records_for_status", SPIDER_PARAM_LONGLONG("static_records_for_status",
static_records_for_status, 0); static_records_for_status, 0);
SPIDER_PARAM_NUMHINT("static_key_cardinality", static_key_cardinality, SPIDER_PARAM_NUMHINT("static_key_cardinality", static_key_cardinality,
3, (int) table_share->keys, spider_set_ll_value); 3, (int) table_share->keys, spider_set_ll_value);
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; error_num = connect_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR,
MYF(0), tmp_ptr);
goto error; goto error;
case 26: case 26:
SPIDER_PARAM_INT_WITH_MAX( SPIDER_PARAM_INT_WITH_MAX(
"semi_table_lock_connection", semi_table_lock_conn, 0, 1); "semi_table_lock_connection", semi_table_lock_conn, 0, 1);
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; error_num = connect_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR,
MYF(0), tmp_ptr);
goto error; goto error;
default: default:
error_num = ER_SPIDER_INVALID_CONNECT_INFO_NUM; error_num = connect_string_parse.print_param_error();
my_printf_error(error_num, ER_SPIDER_INVALID_CONNECT_INFO_STR,
MYF(0), tmp_ptr);
goto error; goto error;
} }
/* Verify that the remainder of the parameter value is whitespace */
if ((error_num = connect_string_parse.has_extra_parameter_values()))
goto error;
} }
} }
......
...@@ -13,6 +13,210 @@ ...@@ -13,6 +13,210 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */
/*
Structure used to manage Spider parameter string parsing. Types of
parameters include:
- connection strings
- UDF parameters
A parameter string consists of one or more parameter definitions using
the following syntax:
<parameter title> <parameter value>
A comma is the separator character between multiple parameter definitions.
Parameter titles must not be quoted. Parameter values must be quoted with
single or double quotes.
*/
typedef struct st_spider_param_string_parse
{
char *start_ptr; /* Pointer to the start of the parameter string */
char *end_ptr; /* Pointer to the end of the parameter string */
char *start_title_ptr; /* Pointer to the start of the current parameter
title */
char *end_title_ptr; /* Pointer to the end of the current parameter
title */
char *start_value_ptr; /* Pointer to the start of the current parameter
value */
char *end_value_ptr; /* Pointer to the end of the current parameter
value */
int error_num; /* Error code of the error message to print when
an error is detected */
uint delim_title_len; /* Length of the paramater title's delimiter */
uint delim_value_len; /* Length of the paramater value's delimiter */
char delim_title; /* Current parameter title's delimiter character */
char delim_value; /* Current parameter value's delimiter character */
/**
Initialize the parameter string parse information.
@param param_string Pointer to the parameter string being parsed.
@param error_code Error code of the error message to print when
an error is detected.
*/
inline void init(char *param_string, int error_code)
{
start_ptr = param_string;
end_ptr = start_ptr + strlen(start_ptr);
init_param_title();
init_param_value();
error_num = error_code;
}
/**
Initialize the current parameter title.
*/
inline void init_param_title()
{
start_title_ptr = end_title_ptr = NULL;
delim_title_len = 0;
delim_title = '\0';
}
/**
Save pointers to the start and end positions of the current parameter
title in the parameter string. Also save the parameter title's
delimiter character.
@param start_value Pointer to the start position of the current
parameter title.
@param end_value Pointer to the end position of the current
parameter title.
*/
inline void set_param_title(char *start_title, char *end_title)
{
start_title_ptr = start_title;
end_title_ptr = end_title;
if (*start_title == '"' ||
*start_title == '\'')
{
delim_title = *start_title;
if (start_title >= start_ptr && *--start_title == '\\')
delim_title_len = 2;
else
delim_title_len = 1;
}
}
/**
Initialize the current parameter value.
*/
inline void init_param_value()
{
start_value_ptr = end_value_ptr = NULL;
delim_value_len = 0;
delim_value = '\0';
}
/**
Save pointers to the start and end positions of the current parameter
value in the parameter string. Also save the parameter value's
delimiter character.
@param start_value Pointer to the start position of the current
parameter value.
@param end_value Pointer to the end position of the current
parameter value.
*/
inline void set_param_value(char *start_value, char *end_value)
{
start_value_ptr = start_value--;
end_value_ptr = end_value;
if (*start_value == '"' ||
*start_value == '\'')
{
delim_value = *start_value;
if (*--start_value == '\\')
delim_value_len = 2;
else
delim_value_len = 1;
}
}
/**
Determine whether the current parameter in the parameter string has
extra parameter values.
@return 0 Current parameter value in the parameter string
does not have extra parameter values.
<> 0 Error code indicating that the current parameter
value in the parameter string has extra
parameter values.
*/
inline int has_extra_parameter_values()
{
int error_num = 0;
DBUG_ENTER("has_extra_parameter_values");
if (end_value_ptr)
{
/* There is a current parameter value */
char *end_param_ptr = end_value_ptr;
while (end_param_ptr < end_ptr &&
(*end_param_ptr == ' ' || *end_param_ptr == '\r' ||
*end_param_ptr == '\n' || *end_param_ptr == '\t'))
end_param_ptr++;
if (end_param_ptr < end_ptr && *end_param_ptr != '\0')
{
/* Extra values in parameter definition */
error_num = print_param_error();
}
}
DBUG_RETURN(error_num);
}
/**
Restore the current parameter's input delimiter characters in the
parameter string. They were NULLed during parameter parsing.
*/
inline void restore_delims()
{
char *end = end_title_ptr - 1;
switch (delim_title_len)
{
case 2:
*end++ = '\\';
/* Fall through */
case 1:
*end = delim_title;
}
end = end_value_ptr - 1;
switch (delim_value_len)
{
case 2:
*end++ = '\\';
/* Fall through */
case 1:
*end = delim_value;
}
}
/**
Print a parameter string error message.
@return Error code.
*/
int print_param_error();
} SPIDER_PARAM_STRING_PARSE;
uchar *spider_tbl_get_key( uchar *spider_tbl_get_key(
SPIDER_SHARE *share, SPIDER_SHARE *share,
size_t *length, size_t *length,
...@@ -60,7 +264,8 @@ void spider_free_tmp_share_alloc( ...@@ -60,7 +264,8 @@ void spider_free_tmp_share_alloc(
char *spider_get_string_between_quote( char *spider_get_string_between_quote(
char *ptr, char *ptr,
bool alloc bool alloc,
SPIDER_PARAM_STRING_PARSE *param_string_parse = NULL
); );
int spider_create_string_list( int spider_create_string_list(
...@@ -68,7 +273,8 @@ int spider_create_string_list( ...@@ -68,7 +273,8 @@ int spider_create_string_list(
uint **string_length_list, uint **string_length_list,
uint *list_length, uint *list_length,
char *str, char *str,
uint length uint length,
SPIDER_PARAM_STRING_PARSE *param_string_parse
); );
int spider_create_long_list( int spider_create_long_list(
...@@ -77,7 +283,8 @@ int spider_create_long_list( ...@@ -77,7 +283,8 @@ int spider_create_long_list(
char *str, char *str,
uint length, uint length,
long min_val, long min_val,
long max_val long max_val,
SPIDER_PARAM_STRING_PARSE *param_string_parse
); );
int spider_create_longlong_list( int spider_create_longlong_list(
...@@ -86,7 +293,8 @@ int spider_create_longlong_list( ...@@ -86,7 +293,8 @@ int spider_create_longlong_list(
char *str, char *str,
uint length, uint length,
longlong min_val, longlong min_val,
longlong max_val longlong max_val,
SPIDER_PARAM_STRING_PARSE *param_string_parse
); );
int spider_increase_string_list( int spider_increase_string_list(
......
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