Commit 334c2cc2 authored by unknown's avatar unknown

Merge pilot.blaudden:/home/msvensson/mysql/mysql-5.0-maint

into  pilot.blaudden:/home/msvensson/mysql/mysql-5.1-maint


mysql-test/r/mysqltest.result:
  Auto merged
mysql-test/t/mysqltest.test:
  Auto merged
client/mysqltest.c:
  Use remote
parents 4aa3615c 4788e6df
...@@ -85,13 +85,12 @@ enum { ...@@ -85,13 +85,12 @@ enum {
OPT_SSL_CA, OPT_SSL_CAPATH, OPT_SSL_CIPHER, OPT_PS_PROTOCOL, OPT_SSL_CA, OPT_SSL_CAPATH, OPT_SSL_CIPHER, OPT_PS_PROTOCOL,
OPT_SP_PROTOCOL, OPT_CURSOR_PROTOCOL, OPT_VIEW_PROTOCOL, OPT_SP_PROTOCOL, OPT_CURSOR_PROTOCOL, OPT_VIEW_PROTOCOL,
OPT_SSL_VERIFY_SERVER_CERT, OPT_MAX_CONNECT_RETRIES, OPT_SSL_VERIFY_SERVER_CERT, OPT_MAX_CONNECT_RETRIES,
OPT_MARK_PROGRESS, OPT_CHARSETS_DIR, OPT_LOG_DIR, OPT_DEBUG_INFO OPT_MARK_PROGRESS, OPT_CHARSETS_DIR
}; };
static int record= 0, opt_sleep= -1; static int record= 0, opt_sleep= -1;
static char *opt_db= 0, *opt_pass= 0; static char *opt_db= 0, *opt_pass= 0;
const char *opt_user= 0, *opt_host= 0, *unix_sock= 0, *opt_basedir= "./"; const char *opt_user= 0, *opt_host= 0, *unix_sock= 0, *opt_basedir= "./";
const char *opt_logdir= "";
const char *opt_include= 0, *opt_charsets_dir; const char *opt_include= 0, *opt_charsets_dir;
static int opt_port= 0; static int opt_port= 0;
static int opt_max_connect_retries; static int opt_max_connect_retries;
...@@ -103,8 +102,8 @@ static my_bool sp_protocol= 0, sp_protocol_enabled= 0; ...@@ -103,8 +102,8 @@ static my_bool sp_protocol= 0, sp_protocol_enabled= 0;
static my_bool view_protocol= 0, view_protocol_enabled= 0; static my_bool view_protocol= 0, view_protocol_enabled= 0;
static my_bool cursor_protocol= 0, cursor_protocol_enabled= 0; static my_bool cursor_protocol= 0, cursor_protocol_enabled= 0;
static my_bool parsing_disabled= 0; static my_bool parsing_disabled= 0;
static my_bool info_flag; static my_bool display_result_vertically= FALSE,
static my_bool display_result_vertically= FALSE, display_metadata= FALSE; display_metadata= FALSE, display_result_sorted= FALSE;
static my_bool disable_query_log= 0, disable_result_log= 0; static my_bool disable_query_log= 0, disable_result_log= 0;
static my_bool disable_warnings= 0; static my_bool disable_warnings= 0;
static my_bool disable_info= 1; static my_bool disable_info= 1;
...@@ -271,7 +270,7 @@ enum enum_commands { ...@@ -271,7 +270,7 @@ enum enum_commands {
Q_EXEC, Q_DELIMITER, Q_EXEC, Q_DELIMITER,
Q_DISABLE_ABORT_ON_ERROR, Q_ENABLE_ABORT_ON_ERROR, Q_DISABLE_ABORT_ON_ERROR, Q_ENABLE_ABORT_ON_ERROR,
Q_DISPLAY_VERTICAL_RESULTS, Q_DISPLAY_HORIZONTAL_RESULTS, Q_DISPLAY_VERTICAL_RESULTS, Q_DISPLAY_HORIZONTAL_RESULTS,
Q_QUERY_VERTICAL, Q_QUERY_HORIZONTAL, Q_QUERY_VERTICAL, Q_QUERY_HORIZONTAL, Q_QUERY_SORTED,
Q_START_TIMER, Q_END_TIMER, Q_START_TIMER, Q_END_TIMER,
Q_CHARACTER_SET, Q_DISABLE_PS_PROTOCOL, Q_ENABLE_PS_PROTOCOL, Q_CHARACTER_SET, Q_DISABLE_PS_PROTOCOL, Q_ENABLE_PS_PROTOCOL,
Q_DISABLE_RECONNECT, Q_ENABLE_RECONNECT, Q_DISABLE_RECONNECT, Q_ENABLE_RECONNECT,
...@@ -341,6 +340,7 @@ const char *command_names[]= ...@@ -341,6 +340,7 @@ const char *command_names[]=
"horizontal_results", "horizontal_results",
"query_vertical", "query_vertical",
"query_horizontal", "query_horizontal",
"query_sorted",
"start_timer", "start_timer",
"end_timer", "end_timer",
"character_set", "character_set",
...@@ -358,6 +358,7 @@ const char *command_names[]= ...@@ -358,6 +358,7 @@ const char *command_names[]=
"copy_file", "copy_file",
"perl", "perl",
"die", "die",
/* Don't execute any more commands, compare result */ /* Don't execute any more commands, compare result */
"exit", "exit",
"skip", "skip",
...@@ -413,12 +414,10 @@ struct st_command ...@@ -413,12 +414,10 @@ struct st_command
TYPELIB command_typelib= {array_elements(command_names),"", TYPELIB command_typelib= {array_elements(command_names),"",
command_names, 0}; command_names, 0};
static DYNAMIC_STRING ds_res, ds_progress, ds_warning_messages; DYNAMIC_STRING ds_res, ds_progress, ds_warning_messages;
static DYNAMIC_STRING global_ds_warnings, global_eval_query;
char builtin_echo[FN_REFLEN]; char builtin_echo[FN_REFLEN];
void die(const char *fmt, ...) void die(const char *fmt, ...)
ATTRIBUTE_FORMAT(printf, 1, 2); ATTRIBUTE_FORMAT(printf, 1, 2);
void abort_not_supported_test(const char *fmt, ...) void abort_not_supported_test(const char *fmt, ...)
...@@ -488,6 +487,7 @@ void replace_dynstr_append_mem(DYNAMIC_STRING *ds, const char *val, ...@@ -488,6 +487,7 @@ 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 handle_error(struct st_command*, void handle_error(struct st_command*,
unsigned int err_errno, const char *err_error, unsigned int err_errno, const char *err_error,
...@@ -795,9 +795,6 @@ void free_used_memory() ...@@ -795,9 +795,6 @@ void free_used_memory()
dynstr_free(&ds_res); dynstr_free(&ds_res);
dynstr_free(&ds_progress); dynstr_free(&ds_progress);
dynstr_free(&ds_warning_messages); dynstr_free(&ds_warning_messages);
dynstr_free(&global_ds_warnings);
dynstr_free(&global_eval_query);
free_all_replace(); free_all_replace();
my_free(opt_pass,MYF(MY_ALLOW_ZERO_PTR)); my_free(opt_pass,MYF(MY_ALLOW_ZERO_PTR));
free_defaults(default_argv); free_defaults(default_argv);
...@@ -4262,16 +4259,12 @@ static struct my_option my_long_options[] = ...@@ -4262,16 +4259,12 @@ static struct my_option my_long_options[] =
{"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
#endif #endif
{"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", (gptr*) &info_flag,
(gptr*) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"host", 'h', "Connect to host.", (gptr*) &opt_host, (gptr*) &opt_host, 0, {"host", 'h', "Connect to host.", (gptr*) &opt_host, (gptr*) &opt_host, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"include", 'i', "Include SQL before each test case.", (gptr*) &opt_include, {"include", 'i', "Include SQL before each test case.", (gptr*) &opt_include,
(gptr*) &opt_include, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (gptr*) &opt_include, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"logdir", OPT_LOG_DIR, "Directory for log files", (gptr*) &opt_logdir,
(gptr*) &opt_logdir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"mark-progress", OPT_MARK_PROGRESS, {"mark-progress", OPT_MARK_PROGRESS,
"Write linenumber and elapsed time to <testname>.progress", "Write linenumber and elapsed time to <testname>.progress ",
(gptr*) &opt_mark_progress, (gptr*) &opt_mark_progress, 0, (gptr*) &opt_mark_progress, (gptr*) &opt_mark_progress, 0,
GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"max-connect-retries", OPT_MAX_CONNECT_RETRIES, {"max-connect-retries", OPT_MAX_CONNECT_RETRIES,
...@@ -4572,8 +4565,7 @@ void dump_result_to_reject_file(char *buf, int size) ...@@ -4572,8 +4565,7 @@ void dump_result_to_reject_file(char *buf, int size)
void dump_result_to_log_file(char *buf, int size) void dump_result_to_log_file(char *buf, int size)
{ {
char log_file[FN_REFLEN]; char log_file[FN_REFLEN];
str_to_file(fn_format(log_file, result_file_name, opt_logdir, ".log", str_to_file(fn_format(log_file, result_file_name, "", ".log",
*opt_logdir ? MY_REPLACE_DIR | MY_REPLACE_EXT:
MY_REPLACE_EXT), MY_REPLACE_EXT),
buf, size); buf, size);
} }
...@@ -4581,8 +4573,7 @@ void dump_result_to_log_file(char *buf, int size) ...@@ -4581,8 +4573,7 @@ void dump_result_to_log_file(char *buf, int size)
void dump_progress(void) void dump_progress(void)
{ {
char log_file[FN_REFLEN]; char log_file[FN_REFLEN];
str_to_file(fn_format(log_file, result_file_name, opt_logdir, ".progress", str_to_file(fn_format(log_file, result_file_name, "", ".progress",
*opt_logdir ? MY_REPLACE_DIR | MY_REPLACE_EXT:
MY_REPLACE_EXT), MY_REPLACE_EXT),
ds_progress.str, ds_progress.length); ds_progress.str, ds_progress.length);
} }
...@@ -5544,7 +5535,11 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags) ...@@ -5544,7 +5535,11 @@ 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 *ds;
DYNAMIC_STRING *save_ds= NULL;
DYNAMIC_STRING ds_result; DYNAMIC_STRING ds_result;
DYNAMIC_STRING ds_sorted;
DYNAMIC_STRING ds_warnings;
DYNAMIC_STRING eval_query;
char *query; char *query;
int query_len; int query_len;
my_bool view_created= 0, sp_created= 0; my_bool view_created= 0, sp_created= 0;
...@@ -5552,7 +5547,7 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags) ...@@ -5552,7 +5547,7 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags)
(flags & QUERY_REAP_FLAG)); (flags & QUERY_REAP_FLAG));
DBUG_ENTER("run_query"); DBUG_ENTER("run_query");
init_dynamic_string(&global_ds_warnings, NULL, 0, 256); init_dynamic_string(&ds_warnings, NULL, 0, 256);
/* Scan for warning before sendign to server */ /* Scan for warning before sendign to server */
scan_command_for_warnings(command); scan_command_for_warnings(command);
...@@ -5562,10 +5557,10 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags) ...@@ -5562,10 +5557,10 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags)
*/ */
if (command->type == Q_EVAL) if (command->type == Q_EVAL)
{ {
init_dynamic_string(&global_eval_query, "", command->query_len+256, 1024); init_dynamic_string(&eval_query, "", command->query_len+256, 1024);
do_eval(&global_eval_query, command->query, command->end, FALSE); do_eval(&eval_query, command->query, command->end, FALSE);
query = global_eval_query.str; query = eval_query.str;
query_len = global_eval_query.length; query_len = eval_query.length;
} }
else else
{ {
...@@ -5637,7 +5632,7 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags) ...@@ -5637,7 +5632,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(&global_ds_warnings, cur_con->util_mysql); append_warnings(&ds_warnings, cur_con->util_mysql);
} }
dynstr_free(&query_str); dynstr_free(&query_str);
...@@ -5684,6 +5679,18 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags) ...@@ -5684,6 +5679,18 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags)
dynstr_free(&query_str); dynstr_free(&query_str);
} }
if (display_result_sorted)
{
/*
Collect the query output in a separate string
that can be sorted before it's added to the
global result string
*/
init_dynamic_string(&ds_sorted, "", 1024, 1024);
save_ds= ds; /* Remember original ds */
ds= &ds_sorted;
}
/* /*
Find out how to run this query Find out how to run this query
...@@ -5696,10 +5703,18 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags) ...@@ -5696,10 +5703,18 @@ 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(mysql, command, query, query_len, ds, &global_ds_warnings); run_query_stmt(mysql, command, query, query_len, ds, &ds_warnings);
else else
run_query_normal(cn, command, flags, query, query_len, run_query_normal(cn, command, flags, query, query_len,
ds, &global_ds_warnings); ds, &ds_warnings);
if (display_result_sorted)
{
/* Sort the result set and append it to result */
dynstr_append_sorted(save_ds, &ds_sorted);
ds= save_ds;
dynstr_free(&ds_sorted);
}
if (sp_created) if (sp_created)
{ {
...@@ -5723,11 +5738,11 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags) ...@@ -5723,11 +5738,11 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags)
check_require(ds, command->require_file); check_require(ds, command->require_file);
} }
dynstr_free(&global_ds_warnings); dynstr_free(&ds_warnings);
if (ds == &ds_result) if (ds == &ds_result)
dynstr_free(&ds_result); dynstr_free(&ds_result);
if (command->type == Q_EVAL) if (command->type == Q_EVAL)
dynstr_free(&global_eval_query); dynstr_free(&eval_query);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -6147,37 +6162,24 @@ int main(int argc, char **argv) ...@@ -6147,37 +6162,24 @@ int main(int argc, char **argv)
case Q_EVAL_RESULT: case Q_EVAL_RESULT:
eval_result = 1; break; eval_result = 1; break;
case Q_EVAL: case Q_EVAL:
case Q_QUERY_VERTICAL:
case Q_QUERY_HORIZONTAL:
case Q_QUERY_SORTED:
if (command->query == command->query_buf) if (command->query == command->query_buf)
{ {
/* Skip the first part of command, i.e query_xxx */
command->query= command->first_argument; command->query= command->first_argument;
command->first_word_len= 0; command->first_word_len= 0;
} }
/* fall through */ /* fall through */
case Q_QUERY_VERTICAL:
case Q_QUERY_HORIZONTAL:
{
my_bool old_display_result_vertically= display_result_vertically;
/* Remove "query_*" if this is first iteration */
if (command->query == command->query_buf)
command->query= command->first_argument;
display_result_vertically= (command->type == Q_QUERY_VERTICAL);
if (save_file[0])
{
strmake(command->require_file, save_file, sizeof(save_file));
save_file[0]= 0;
}
run_query(cur_con, command, QUERY_REAP_FLAG|QUERY_SEND_FLAG);
display_result_vertically= old_display_result_vertically;
command->last_argument= command->end;
command_executed++;
break;
}
case Q_QUERY: case Q_QUERY:
case Q_REAP: case Q_REAP:
{ {
int flags; my_bool old_display_result_vertically= display_result_vertically;
my_bool old_display_result_sorted= display_result_sorted;
/* Default is full query, both reap and send */
int flags= QUERY_REAP_FLAG | QUERY_SEND_FLAG;
if (q_send_flag) if (q_send_flag)
{ {
/* Last command was an empty 'send' */ /* Last command was an empty 'send' */
...@@ -6188,11 +6190,10 @@ int main(int argc, char **argv) ...@@ -6188,11 +6190,10 @@ int main(int argc, char **argv)
{ {
flags= QUERY_REAP_FLAG; flags= QUERY_REAP_FLAG;
} }
else
{ /* Check for special property for this query */
/* full query, both reap and send */ display_result_vertically= (command->type == Q_QUERY_VERTICAL);
flags= QUERY_REAP_FLAG | QUERY_SEND_FLAG; display_result_sorted= (command->type == Q_QUERY_SORTED);
}
if (save_file[0]) if (save_file[0])
{ {
...@@ -6202,6 +6203,11 @@ int main(int argc, char **argv) ...@@ -6202,6 +6203,11 @@ int main(int argc, char **argv)
run_query(cur_con, command, flags); run_query(cur_con, command, flags);
command_executed++; command_executed++;
command->last_argument= command->end; command->last_argument= command->end;
/* Restore settings */
display_result_vertically= old_display_result_vertically;
display_result_sorted= old_display_result_sorted;
break; break;
} }
case Q_SEND: case Q_SEND:
...@@ -7087,7 +7093,7 @@ int reg_replace(char** buf_p, int* buf_len_p, char *pattern, ...@@ -7087,7 +7093,7 @@ int reg_replace(char** buf_p, int* buf_len_p, char *pattern,
if (back_ref_num >= 0 && back_ref_num <= (int)r.re_nsub) if (back_ref_num >= 0 && back_ref_num <= (int)r.re_nsub)
{ {
regoff_t start_off, end_off; regoff_t start_off, end_off;
if ((start_off= subs[back_ref_num].rm_so) > -1 && if ((start_off=subs[back_ref_num].rm_so) > -1 &&
(end_off=subs[back_ref_num].rm_eo) > -1) (end_off=subs[back_ref_num].rm_eo) > -1)
{ {
int block_len= (int) (end_off - start_off); int block_len= (int) (end_off - start_off);
...@@ -7812,3 +7818,73 @@ void replace_dynstr_append_uint(DYNAMIC_STRING *ds, uint val) ...@@ -7812,3 +7818,73 @@ void replace_dynstr_append_uint(DYNAMIC_STRING *ds, uint val)
char *end= longlong10_to_str(val, buff, 10); char *end= longlong10_to_str(val, buff, 10);
replace_dynstr_append_mem(ds, buff, end - buff); replace_dynstr_append_mem(ds, buff, end - buff);
} }
/*
Build a list of pointer to each line in ds_input, sort
the list and use the sorted list to append the strings
sorted to the output ds
SYNOPSIS
dynstr_append_sorted
ds - string where the sorted output will be appended
ds_input - string to be sorted
*/
static int comp_lines(const char **a, const char **b)
{
return (strcmp(*a,*b));
}
void dynstr_append_sorted(DYNAMIC_STRING* ds, DYNAMIC_STRING *ds_input)
{
unsigned i;
char *start= ds_input->str;
DYNAMIC_ARRAY lines;
DBUG_ENTER("dynstr_append_sorted");
if (!*start)
DBUG_VOID_RETURN; /* No input */
my_init_dynamic_array(&lines, sizeof(const char*), 32, 32);
/* First line is result header, skip past it */
while (*start && *start != '\n')
start++;
start++; /* Skip past \n */
dynstr_append_mem(ds, ds_input->str, start - ds_input->str);
/* Insert line(s) in array */
while (*start)
{
char* line_end= (char*)start;
/* Find end of line */
while (*line_end && *line_end != '\n')
line_end++;
*line_end= 0;
/* Insert pointer to the line in array */
if (insert_dynamic(&lines, (gptr) &start))
die("Out of memory inserting lines to sort");
start= line_end+1;
}
/* Sort array */
qsort(lines.buffer, lines.elements,
sizeof(char**), (qsort_cmp)comp_lines);
/* Create new result */
for (i= 0; i < lines.elements ; i++)
{
const char **line= dynamic_element(&lines, i, const char**);
dynstr_append(ds, *line);
dynstr_append(ds, "\n");
}
delete_dynamic(&lines);
DBUG_VOID_RETURN;
}
...@@ -541,4 +541,20 @@ hello ...@@ -541,4 +541,20 @@ hello
hello hello
mysqltest: At line 1: test of die mysqltest: At line 1: test of die
Some output Some output
create table t1( a int, b char(255), c timestamp);
insert into t1 values(1, 'Line 1', '2007-04-05'), (2, "Part 2", '2007-04-05');
insert into t1 values(1, 'Line 1', '2007-04-05'), (2, "Part 3", '2007-04-05');
select * from t1;
a b c
1 Line 1 2007-04-05 00:00:00
2 Part 2 2007-04-05 00:00:00
1 Line 1 2007-04-05 00:00:00
2 Part 3 2007-04-05 00:00:00
select * from t1;
a b c
1 Line 1 2007-04-05 00:00:00
1 Line 1 2007-04-05 00:00:00
2 Part 2 2007-04-05 00:00:00
2 Part 3 2007-04-05 00:00:00
select * from t1;
End of tests End of tests
...@@ -1739,6 +1739,24 @@ EOF ...@@ -1739,6 +1739,24 @@ EOF
--exec echo "echo Some output; exit; echo Not this;" | $MYSQL_TEST 2>&1 --exec echo "echo Some output; exit; echo Not this;" | $MYSQL_TEST 2>&1
# ----------------------------------------------------------------------------
# test for query_sorted
# ----------------------------------------------------------------------------
create table t1( a int, b char(255), c timestamp);
insert into t1 values(1, 'Line 1', '2007-04-05'), (2, "Part 2", '2007-04-05');
insert into t1 values(1, 'Line 1', '2007-04-05'), (2, "Part 3", '2007-04-05');
select * from t1;
query_sorted select * from t1;
disable_result_log;
query_sorted select * from t1;
enable_result_log;
query_sorted select '';
query_sorted select "h";
query_sorted select "he";
query_sorted select "hep";
query_sorted select "hepp";
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# Some coverage tests # Some coverage tests
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
......
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