Commit 0ad48394 authored by Oleksandr Byelkin's avatar Oleksandr Byelkin

Rename variables to make operation comprehansive

parent ff0bade2
...@@ -8991,11 +8991,14 @@ int util_query(MYSQL* org_mysql, const char* query){ ...@@ -8991,11 +8991,14 @@ int util_query(MYSQL* org_mysql, const char* query){
void run_query(struct st_connection *cn, struct st_command *command, int flags) void run_query(struct st_connection *cn, struct st_command *command, int flags)
{ {
MYSQL *mysql= cn->mysql; MYSQL *mysql= cn->mysql;
DYNAMIC_STRING *ds; DYNAMIC_STRING *rs_output; /* where to put results */
DYNAMIC_STRING *save_ds= NULL; DYNAMIC_STRING rs_cmp_result; /* here we put results to compare with
DYNAMIC_STRING ds_result; pre-recrded file */
DYNAMIC_STRING ds_sorted; DYNAMIC_STRING rs_unsorted; /* if we need sorted results, here we store
DYNAMIC_STRING ds_warnings; results before sorting them */
DYNAMIC_STRING *rs_sorted_save= NULL; /* here we store where to put sorted
result if needed */
DYNAMIC_STRING rs_warnings;
char *query; char *query;
size_t query_len; size_t query_len;
my_bool view_created= 0, sp_created= 0; my_bool view_created= 0, sp_created= 0;
...@@ -9009,8 +9012,8 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags) ...@@ -9009,8 +9012,8 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags)
if (!(flags & QUERY_SEND_FLAG) && !cn->pending) if (!(flags & QUERY_SEND_FLAG) && !cn->pending)
die("Cannot reap on a connection without pending send"); die("Cannot reap on a connection without pending send");
init_dynamic_string(&ds_warnings, NULL, 0, 256); init_dynamic_string(&rs_warnings, NULL, 0, 256);
ds_warn= &ds_warnings; ds_warn= &rs_warnings;
/* /*
Evaluate query if this is an eval command Evaluate query if this is an eval command
...@@ -9041,11 +9044,11 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags) ...@@ -9041,11 +9044,11 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags)
*/ */
if (command->require_file) if (command->require_file)
{ {
init_dynamic_string(&ds_result, "", 1024, 1024); init_dynamic_string(&rs_cmp_result, "", 1024, 1024);
ds= &ds_result; rs_output= &rs_cmp_result;
} }
else else
ds= &ds_res; rs_output= &ds_res; // will be shown to colsole
/* /*
Log the query into the output buffer Log the query into the output buffer
...@@ -9059,9 +9062,9 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags) ...@@ -9059,9 +9062,9 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags)
print_query= command->query; print_query= command->query;
print_len= (int)(command->end - command->query); print_len= (int)(command->end - command->query);
} }
replace_dynstr_append_mem(ds, print_query, print_len); replace_dynstr_append_mem(rs_output, print_query, print_len);
dynstr_append_mem(ds, delimiter, delimiter_length); dynstr_append_mem(rs_output, delimiter, delimiter_length);
dynstr_append_mem(ds, "\n", 1); dynstr_append_mem(rs_output, "\n", 1);
} }
/* We're done with this flag */ /* We're done with this flag */
...@@ -9116,7 +9119,7 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags) ...@@ -9116,7 +9119,7 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags)
Collect warnings from create of the view that should otherwise Collect warnings from create of the view that should otherwise
have been produced when the SELECT was executed have been produced when the SELECT was executed
*/ */
append_warnings(&ds_warnings, append_warnings(&rs_warnings,
service_connection_enabled ? service_connection_enabled ?
cur_con->util_mysql : cur_con->util_mysql :
mysql); mysql);
...@@ -9172,9 +9175,9 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags) ...@@ -9172,9 +9175,9 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags)
that can be sorted before it's added to the that can be sorted before it's added to the
global result string global result string
*/ */
init_dynamic_string(&ds_sorted, "", 1024, 1024); init_dynamic_string(&rs_unsorted, "", 1024, 1024);
save_ds= ds; /* Remember original ds */ rs_sorted_save= rs_output; /* Remember original ds */
ds= &ds_sorted; rs_output= &rs_unsorted;
} }
/* /*
...@@ -9189,20 +9192,20 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags) ...@@ -9189,20 +9192,20 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags)
if (ps_protocol_enabled && if (ps_protocol_enabled &&
complete_query && complete_query &&
match_re(&ps_re, query)) match_re(&ps_re, query))
run_query_stmt(cn, command, query, query_len, ds, &ds_warnings); run_query_stmt(cn, command, query, query_len, rs_output, &rs_warnings);
else else
run_query_normal(cn, command, flags, query, query_len, run_query_normal(cn, command, flags, query, query_len,
ds, &ds_warnings); rs_output, &rs_warnings);
dynstr_free(&ds_warnings); dynstr_free(&rs_warnings);
ds_warn= 0; ds_warn= 0;
if (display_result_sorted) if (display_result_sorted)
{ {
/* Sort the result set and append it to result */ /* Sort the result set and append it to result */
dynstr_append_sorted(save_ds, &ds_sorted, 1); dynstr_append_sorted(rs_sorted_save, &rs_unsorted, 1);
ds= save_ds; rs_output= rs_sorted_save;
dynstr_free(&ds_sorted); dynstr_free(&rs_unsorted);
} }
if (sp_created) if (sp_created)
...@@ -9225,11 +9228,11 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags) ...@@ -9225,11 +9228,11 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags)
and the output should be checked against an already and the output should be checked against an already
existing file which has been specified using --require or --result existing file which has been specified using --require or --result
*/ */
check_require(ds, command->require_file); check_require(rs_output, command->require_file);
} }
if (ds == &ds_result) if (rs_output == &rs_cmp_result)
dynstr_free(&ds_result); dynstr_free(&rs_cmp_result);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
......
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