Commit a148cf7f authored by Michael Widenius's avatar Michael Widenius

Fixed that --sorted-result in mysql-test-run also works for exec

mysql-test/r/information_schema_all_engines.result:
  Update result
mysql-test/t/information_schema_all_engines.test:
  Added --sorted-results as tables in information_schema are not sorted.
parent cf86abff
/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. /* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
Copyright (c) 2009-2011 Monty Program Ab. Copyright (c) 2009-2012 Monty Program Ab.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -732,7 +732,8 @@ void replace_dynstr_append_mem(DYNAMIC_STRING *ds, const char *val, ...@@ -732,7 +732,8 @@ void replace_dynstr_append_mem(DYNAMIC_STRING *ds, const char *val,
int len); int len);
void replace_dynstr_append(DYNAMIC_STRING *ds, const char *val); void replace_dynstr_append(DYNAMIC_STRING *ds, const char *val);
void replace_dynstr_append_uint(DYNAMIC_STRING *ds, uint val); void replace_dynstr_append_uint(DYNAMIC_STRING *ds, uint val);
void dynstr_append_sorted(DYNAMIC_STRING* ds, DYNAMIC_STRING* ds_input); void dynstr_append_sorted(DYNAMIC_STRING* ds, DYNAMIC_STRING* ds_input,
bool keep_header);
static int match_expected_error(struct st_command *command, static int match_expected_error(struct st_command *command,
unsigned int err_errno, unsigned int err_errno,
...@@ -2790,6 +2791,7 @@ void do_exec(struct st_command *command) ...@@ -2790,6 +2791,7 @@ void do_exec(struct st_command *command)
FILE *res_file; FILE *res_file;
char *cmd= command->first_argument; char *cmd= command->first_argument;
DYNAMIC_STRING ds_cmd; DYNAMIC_STRING ds_cmd;
DYNAMIC_STRING ds_sorted, *ds_result;
DBUG_ENTER("do_exec"); DBUG_ENTER("do_exec");
DBUG_PRINT("enter", ("cmd: '%s'", cmd)); DBUG_PRINT("enter", ("cmd: '%s'", cmd));
...@@ -2835,6 +2837,13 @@ void do_exec(struct st_command *command) ...@@ -2835,6 +2837,13 @@ void do_exec(struct st_command *command)
die("popen(\"%s\", \"r\") failed", command->first_argument); die("popen(\"%s\", \"r\") failed", command->first_argument);
} }
ds_result= &ds_res;
if (display_result_sorted)
{
init_dynamic_string(&ds_sorted, "", 1024, 1024);
ds_result= &ds_sorted;
}
while (fgets(buf, sizeof(buf), res_file)) while (fgets(buf, sizeof(buf), res_file))
{ {
if (disable_result_log) if (disable_result_log)
...@@ -2844,10 +2853,17 @@ void do_exec(struct st_command *command) ...@@ -2844,10 +2853,17 @@ void do_exec(struct st_command *command)
} }
else else
{ {
replace_dynstr_append(&ds_res, buf); replace_dynstr_append(ds_result, buf);
} }
} }
error= pclose(res_file); error= pclose(res_file);
if (display_result_sorted)
{
dynstr_append_sorted(&ds_res, &ds_sorted, 0);
dynstr_free(&ds_sorted);
}
if (error > 0) if (error > 0)
{ {
uint status= WEXITSTATUS(error); uint status= WEXITSTATUS(error);
...@@ -7743,7 +7759,7 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags) ...@@ -7743,7 +7759,7 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags)
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); dynstr_append_sorted(save_ds, &ds_sorted, 1);
ds= save_ds; ds= save_ds;
dynstr_free(&ds_sorted); dynstr_free(&ds_sorted);
} }
...@@ -10125,17 +10141,16 @@ void replace_dynstr_append_uint(DYNAMIC_STRING *ds, uint val) ...@@ -10125,17 +10141,16 @@ void replace_dynstr_append_uint(DYNAMIC_STRING *ds, uint val)
} }
/* /*
Build a list of pointer to each line in ds_input, sort Build a list of pointer to each line in ds_input, sort
the list and use the sorted list to append the strings the list and use the sorted list to append the strings
sorted to the output ds sorted to the output ds
SYNOPSIS SYNOPSIS
dynstr_append_sorted dynstr_append_sorted()
ds - string where the sorted output will be appended ds string where the sorted output will be appended
ds_input - string to be sorted ds_input string to be sorted
keep_header If header should not be sorted
*/ */
static int comp_lines(const char **a, const char **b) static int comp_lines(const char **a, const char **b)
...@@ -10143,7 +10158,8 @@ static int comp_lines(const char **a, const char **b) ...@@ -10143,7 +10158,8 @@ static int comp_lines(const char **a, const char **b)
return (strcmp(*a,*b)); return (strcmp(*a,*b));
} }
void dynstr_append_sorted(DYNAMIC_STRING* ds, DYNAMIC_STRING *ds_input) void dynstr_append_sorted(DYNAMIC_STRING* ds, DYNAMIC_STRING *ds_input,
bool keep_header)
{ {
unsigned i; unsigned i;
char *start= ds_input->str; char *start= ds_input->str;
...@@ -10155,11 +10171,14 @@ void dynstr_append_sorted(DYNAMIC_STRING* ds, DYNAMIC_STRING *ds_input) ...@@ -10155,11 +10171,14 @@ void dynstr_append_sorted(DYNAMIC_STRING* ds, DYNAMIC_STRING *ds_input)
my_init_dynamic_array(&lines, sizeof(const char*), 32, 32); my_init_dynamic_array(&lines, sizeof(const char*), 32, 32);
/* First line is result header, skip past it */ if (keep_header)
while (*start && *start != '\n') {
start++; /* First line is result header, skip past it */
start++; /* Skip past \n */ while (*start && *start != '\n')
dynstr_append_mem(ds, ds_input->str, start - ds_input->str); start++;
start++; /* Skip past \n */
dynstr_append_mem(ds, ds_input->str, start - ds_input->str);
}
/* Insert line(s) in array */ /* Insert line(s) in array */
while (*start) while (*start)
...@@ -10237,4 +10256,3 @@ char *mysql_authentication_dialog_ask(MYSQL *mysql, int type, ...@@ -10237,4 +10256,3 @@ char *mysql_authentication_dialog_ask(MYSQL *mysql, int type,
return buf; return buf;
} }
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
use INFORMATION_SCHEMA; use INFORMATION_SCHEMA;
--replace_result Tables_in_INFORMATION_SCHEMA Tables_in_information_schema --replace_result Tables_in_INFORMATION_SCHEMA Tables_in_information_schema
--sorted_result
show tables; show tables;
# #
...@@ -28,7 +29,7 @@ SELECT t.table_name, c1.column_name ...@@ -28,7 +29,7 @@ SELECT t.table_name, c1.column_name
WHERE c2.table_schema = t.table_schema AND WHERE c2.table_schema = t.table_schema AND
c2.table_name = t.table_name AND c2.table_name = t.table_name AND
c2.column_name LIKE '%SCHEMA%' c2.column_name LIKE '%SCHEMA%'
); ) order by t.table_name;
SELECT t.table_name, c1.column_name SELECT t.table_name, c1.column_name
FROM information_schema.tables t FROM information_schema.tables t
INNER JOIN INNER JOIN
...@@ -42,7 +43,7 @@ SELECT t.table_name, c1.column_name ...@@ -42,7 +43,7 @@ SELECT t.table_name, c1.column_name
WHERE c2.table_schema = 'information_schema' AND WHERE c2.table_schema = 'information_schema' AND
c2.table_name = t.table_name AND c2.table_name = t.table_name AND
c2.column_name LIKE '%SCHEMA%' c2.column_name LIKE '%SCHEMA%'
); ) order by t.table_name;
# #
# Bug#24630 Subselect query crashes mysqld # Bug#24630 Subselect query crashes mysqld
...@@ -70,8 +71,11 @@ group by t.table_name order by num1, t.table_name; ...@@ -70,8 +71,11 @@ group by t.table_name order by num1, t.table_name;
# #
# Bug #19147: mysqlshow INFORMATION_SCHEMA does not work # Bug #19147: mysqlshow INFORMATION_SCHEMA does not work
# #
--sorted_result
--exec $MYSQL_SHOW information_schema --exec $MYSQL_SHOW information_schema
--sorted_result
--exec $MYSQL_SHOW INFORMATION_SCHEMA --exec $MYSQL_SHOW INFORMATION_SCHEMA
--sorted_result
--exec $MYSQL_SHOW inf_rmation_schema --exec $MYSQL_SHOW inf_rmation_schema
# #
......
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