Commit 86ef70e9 authored by unknown's avatar unknown

Merge pilot.blaudden:/home/msvensson/mysql/mysql-5.1

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


mysql-test/r/create.result:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
parents 37feda25 a2aa6503
...@@ -85,7 +85,7 @@ enum { ...@@ -85,7 +85,7 @@ 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;
...@@ -103,8 +103,8 @@ static my_bool sp_protocol= 0, sp_protocol_enabled= 0; ...@@ -103,8 +103,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,14 +271,14 @@ enum enum_commands { ...@@ -271,14 +271,14 @@ 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,
Q_IF, Q_IF,
Q_DISABLE_PARSING, Q_ENABLE_PARSING, Q_DISABLE_PARSING, Q_ENABLE_PARSING,
Q_REPLACE_REGEX, Q_REMOVE_FILE, Q_FILE_EXIST, Q_REPLACE_REGEX, Q_REMOVE_FILE, Q_FILE_EXIST,
Q_WRITE_FILE, Q_COPY_FILE, Q_PERL, Q_DIE, Q_EXIT, Q_WRITE_FILE, Q_COPY_FILE, Q_PERL, Q_DIE, Q_EXIT, Q_SKIP,
Q_CHMOD_FILE, Q_APPEND_FILE, Q_CAT_FILE, Q_DIFF_FILES, Q_CHMOD_FILE, Q_APPEND_FILE, Q_CAT_FILE, Q_DIFF_FILES,
Q_UNKNOWN, /* Unknown command. */ Q_UNKNOWN, /* Unknown command. */
...@@ -341,6 +341,7 @@ const char *command_names[]= ...@@ -341,6 +341,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,8 +359,10 @@ const char *command_names[]= ...@@ -358,8 +359,10 @@ 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",
"chmod", "chmod",
"append_file", "append_file",
"cat_file", "cat_file",
...@@ -412,12 +415,10 @@ struct st_command ...@@ -412,12 +415,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, ...)
...@@ -487,6 +488,7 @@ void replace_dynstr_append_mem(DYNAMIC_STRING *ds, const char *val, ...@@ -487,6 +488,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,
...@@ -794,9 +796,6 @@ void free_used_memory() ...@@ -794,9 +796,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);
...@@ -815,27 +814,65 @@ void free_used_memory() ...@@ -815,27 +814,65 @@ void free_used_memory()
} }
static void cleanup_and_exit(int exit_code)
{
free_used_memory();
my_end(MY_CHECK_ERROR);
if (!silent)
{
switch (exit_code)
{
case 1:
printf("not ok\n");
break;
case 0:
printf("ok\n");
break;
case 62:
printf("skipped\n");
break;
default:
printf("unknown exit code: %d\n", exit_code);
DBUG_ASSERT(0);
}
}
exit(exit_code);
}
void die(const char *fmt, ...) void die(const char *fmt, ...)
{ {
static int dying= 0;
va_list args; va_list args;
DBUG_ENTER("die"); DBUG_ENTER("die");
DBUG_PRINT("enter", ("start_lineno: %d", start_lineno)); DBUG_PRINT("enter", ("start_lineno: %d", start_lineno));
/*
Protect against dying twice
first time 'die' is called, try to write log files
second time, just exit
*/
if (dying)
cleanup_and_exit(1);
/* Print the error message */ /* Print the error message */
va_start(args, fmt); fprintf(stderr, "mysqltest: ");
if (cur_file && cur_file != file_stack)
fprintf(stderr, "In included file \"%s\": ",
cur_file->file_name);
if (start_lineno > 0)
fprintf(stderr, "At line %u: ", start_lineno);
if (fmt) if (fmt)
{ {
fprintf(stderr, "mysqltest: "); va_start(args, fmt);
if (cur_file && cur_file != file_stack)
fprintf(stderr, "In included file \"%s\": ",
cur_file->file_name);
if (start_lineno > 0)
fprintf(stderr, "At line %u: ", start_lineno);
vfprintf(stderr, fmt, args); vfprintf(stderr, fmt, args);
fprintf(stderr, "\n"); va_end(args);
fflush(stderr);
} }
va_end(args); else
fprintf(stderr, "unknown error");
fprintf(stderr, "\n");
fflush(stderr);
/* Dump the result that has been accumulated so far to .log file */ /* Dump the result that has been accumulated so far to .log file */
if (result_file_name && ds_res.length) if (result_file_name && ds_res.length)
...@@ -845,14 +882,7 @@ void die(const char *fmt, ...) ...@@ -845,14 +882,7 @@ void die(const char *fmt, ...)
if (result_file_name && ds_warning_messages.length) if (result_file_name && ds_warning_messages.length)
dump_warning_messages(); dump_warning_messages();
/* Clean up and exit */ cleanup_and_exit(1);
free_used_memory();
my_end(info_flag ? MY_CHECK_ERROR | MY_GIVE_INFO : MY_CHECK_ERROR);
if (!silent)
printf("not ok\n");
exit(1);
} }
...@@ -885,14 +915,7 @@ void abort_not_supported_test(const char *fmt, ...) ...@@ -885,14 +915,7 @@ void abort_not_supported_test(const char *fmt, ...)
} }
va_end(args); va_end(args);
/* Clean up and exit */ cleanup_and_exit(62);
free_used_memory();
my_end(info_flag ? MY_CHECK_ERROR | MY_GIVE_INFO : MY_CHECK_ERROR);
if (!silent)
printf("skipped\n");
exit(62);
} }
...@@ -1352,6 +1375,7 @@ void var_query_set(VAR *var, const char *query, const char** query_end) ...@@ -1352,6 +1375,7 @@ void var_query_set(VAR *var, const char *query, const char** query_end)
MYSQL_RES *res; MYSQL_RES *res;
MYSQL_ROW row; MYSQL_ROW row;
MYSQL* mysql = &cur_con->mysql; MYSQL* mysql = &cur_con->mysql;
DYNAMIC_STRING ds_query;
DBUG_ENTER("var_query_set"); DBUG_ENTER("var_query_set");
LINT_INIT(res); LINT_INIT(res);
...@@ -1361,13 +1385,17 @@ void var_query_set(VAR *var, const char *query, const char** query_end) ...@@ -1361,13 +1385,17 @@ void var_query_set(VAR *var, const char *query, const char** query_end)
die("Syntax error in query, missing '`'"); die("Syntax error in query, missing '`'");
++query; ++query;
if (mysql_real_query(mysql, query, (int)(end - query)) || /* Eval the query, thus replacing all environment variables */
init_dynamic_string(&ds_query, 0, (end - query) + 32, 256);
do_eval(&ds_query, query, end, FALSE);
if (mysql_real_query(mysql, ds_query.str, ds_query.length) ||
!(res = mysql_store_result(mysql))) !(res = mysql_store_result(mysql)))
{ {
*end = 0; die("Error running query '%s': %d %s", ds_query.str,
die("Error running query '%s': %d %s", query,
mysql_errno(mysql), mysql_error(mysql)); mysql_errno(mysql), mysql_error(mysql));
} }
dynstr_free(&ds_query);
if ((row = mysql_fetch_row(res)) && row[0]) if ((row = mysql_fetch_row(res)) && row[0])
{ {
...@@ -4232,16 +4260,14 @@ static struct my_option my_long_options[] = ...@@ -4232,16 +4260,14 @@ 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, {"logdir", 0, "Directory for log files", (gptr*) &opt_logdir,
(gptr*) &opt_logdir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (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,
...@@ -4543,17 +4569,18 @@ void dump_result_to_log_file(char *buf, int size) ...@@ -4543,17 +4569,18 @@ 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, opt_logdir, ".log",
*opt_logdir ? MY_REPLACE_DIR | MY_REPLACE_EXT: *opt_logdir ? MY_REPLACE_DIR | MY_REPLACE_EXT :
MY_REPLACE_EXT), MY_REPLACE_EXT),
buf, size); buf, size);
} }
void dump_progress(void) void dump_progress(void)
{ {
char log_file[FN_REFLEN]; char progress_file[FN_REFLEN];
str_to_file(fn_format(log_file, result_file_name, opt_logdir, ".progress", str_to_file(fn_format(progress_file, result_file_name,
*opt_logdir ? MY_REPLACE_DIR | MY_REPLACE_EXT: opt_logdir, ".progress",
MY_REPLACE_EXT), *opt_logdir ? MY_REPLACE_DIR | MY_REPLACE_EXT :
MY_REPLACE_EXT),
ds_progress.str, ds_progress.length); ds_progress.str, ds_progress.length);
} }
...@@ -4561,7 +4588,8 @@ void dump_warning_messages(void) ...@@ -4561,7 +4588,8 @@ void dump_warning_messages(void)
{ {
char warn_file[FN_REFLEN]; char warn_file[FN_REFLEN];
str_to_file(fn_format(warn_file, result_file_name, "", ".warnings", str_to_file(fn_format(warn_file, result_file_name, opt_logdir, ".warnings",
*opt_logdir ? MY_REPLACE_DIR | MY_REPLACE_EXT :
MY_REPLACE_EXT), MY_REPLACE_EXT),
ds_warning_messages.str, ds_warning_messages.length); ds_warning_messages.str, ds_warning_messages.length);
} }
...@@ -5514,7 +5542,11 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags) ...@@ -5514,7 +5542,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;
...@@ -5522,7 +5554,7 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags) ...@@ -5522,7 +5554,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);
...@@ -5532,10 +5564,10 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags) ...@@ -5532,10 +5564,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
{ {
...@@ -5607,7 +5639,7 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags) ...@@ -5607,7 +5639,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);
...@@ -5654,6 +5686,18 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags) ...@@ -5654,6 +5686,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
...@@ -5666,10 +5710,18 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags) ...@@ -5666,10 +5710,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)
{ {
...@@ -5693,11 +5745,11 @@ void run_query(struct st_connection *cn, struct st_command *command, int flags) ...@@ -5693,11 +5745,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;
} }
...@@ -6117,37 +6169,24 @@ int main(int argc, char **argv) ...@@ -6117,37 +6169,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' */
...@@ -6158,11 +6197,10 @@ int main(int argc, char **argv) ...@@ -6158,11 +6197,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])
{ {
...@@ -6172,6 +6210,11 @@ int main(int argc, char **argv) ...@@ -6172,6 +6210,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:
...@@ -6287,6 +6330,9 @@ int main(int argc, char **argv) ...@@ -6287,6 +6330,9 @@ int main(int argc, char **argv)
/* Stop processing any more commands */ /* Stop processing any more commands */
abort_flag= 1; abort_flag= 1;
break; break;
case Q_SKIP:
abort_not_supported_test("%s", command->first_argument);
break;
case Q_RESULT: case Q_RESULT:
die("result, deprecated command"); die("result, deprecated command");
...@@ -6398,14 +6444,9 @@ int main(int argc, char **argv) ...@@ -6398,14 +6444,9 @@ int main(int argc, char **argv)
dump_warning_messages(); dump_warning_messages();
timer_output(); timer_output();
free_used_memory();
my_end(info_flag ? MY_CHECK_ERROR | MY_GIVE_INFO : MY_CHECK_ERROR);
/* Yes, if we got this far the test has suceeded! Sakila smiles */ /* Yes, if we got this far the test has suceeded! Sakila smiles */
if (!silent) cleanup_and_exit(0);
printf("ok\n"); return 0; /* Keep compiler happy too */
exit(0);
return 0; /* Keep compiler happy */
} }
...@@ -7059,7 +7100,7 @@ int reg_replace(char** buf_p, int* buf_len_p, char *pattern, ...@@ -7059,7 +7100,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);
...@@ -7784,3 +7825,73 @@ void replace_dynstr_append_uint(DYNAMIC_STRING *ds, uint val) ...@@ -7784,3 +7825,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;
}
...@@ -296,6 +296,18 @@ sub mtr_report_stats ($) { ...@@ -296,6 +296,18 @@ sub mtr_report_stats ($) {
} }
} }
} }
if ( $::opt_check_testcases )
{
# Look for warnings produced by mysqltest in testname.warnings
foreach my $test_warning_file
( glob("$::glob_mysql_test_dir/r/*.warnings") )
{
$found_problems= 1;
print WARN "Check myqltest warnings in $test_warning_file\n";
}
}
if ( $found_problems ) if ( $found_problems )
{ {
mtr_warning("Got errors/warnings while running tests, please examine", mtr_warning("Got errors/warnings while running tests, please examine",
......
...@@ -725,8 +725,6 @@ sub command_line_setup () { ...@@ -725,8 +725,6 @@ sub command_line_setup () {
{ {
$mysqld_variables{'port'}= 3306; $mysqld_variables{'port'}= 3306;
$mysqld_variables{'master-port'}= 3306; $mysqld_variables{'master-port'}= 3306;
$opt_skip_ndbcluster= 1;
$opt_skip_im= 1;
} }
if ( $opt_comment ) if ( $opt_comment )
...@@ -1073,7 +1071,7 @@ sub command_line_setup () { ...@@ -1073,7 +1071,7 @@ sub command_line_setup () {
# On some operating systems, there is a limit to the length of a # On some operating systems, there is a limit to the length of a
# UNIX domain socket's path far below PATH_MAX, so try to avoid long # UNIX domain socket's path far below PATH_MAX, so try to avoid long
# socket path names. # socket path names.
$sockdir = tempdir(CLEANUP => 0) if ( length($sockdir) > 80 ); $sockdir = tempdir(CLEANUP => 0) if ( length($sockdir) >= 80 );
$master->[0]= $master->[0]=
{ {
...@@ -1236,6 +1234,7 @@ sub command_line_setup () { ...@@ -1236,6 +1234,7 @@ sub command_line_setup () {
{ {
# Turn off features not supported when running with extern server # Turn off features not supported when running with extern server
$opt_skip_rpl= 1; $opt_skip_rpl= 1;
$opt_skip_ndbcluster= 1;
# Setup master->[0] with the settings for the extern server # Setup master->[0] with the settings for the extern server
$master->[0]->{'path_sock'}= $opt_socket ? $opt_socket : "/tmp/mysql.sock"; $master->[0]->{'path_sock'}= $opt_socket ? $opt_socket : "/tmp/mysql.sock";
...@@ -2031,10 +2030,7 @@ sub environment_setup () { ...@@ -2031,10 +2030,7 @@ sub environment_setup () {
$ENV{'MYSQL_FIX_SYSTEM_TABLES'}= $cmdline_mysql_fix_system_tables; $ENV{'MYSQL_FIX_SYSTEM_TABLES'}= $cmdline_mysql_fix_system_tables;
} }
if (!$opt_extern) $ENV{'MYSQL_FIX_PRIVILEGE_TABLES'}= $file_mysql_fix_privilege_tables;
{
$ENV{'MYSQL_FIX_PRIVILEGE_TABLES'}= $file_mysql_fix_privilege_tables;
}
# ---------------------------------------------------- # ----------------------------------------------------
# Setup env so childs can execute my_print_defaults # Setup env so childs can execute my_print_defaults
......
...@@ -277,6 +277,9 @@ let $A = changed value of A; ...@@ -277,6 +277,9 @@ let $A = changed value of A;
# Content of $B is: initial value of B # Content of $B is: initial value of B
let $B = changed value of B; let $B = changed value of B;
# Content of $A is: changed value of A # Content of $A is: changed value of A
var2: content of variable 1
var3: content of variable 1 content of variable 1
length of var3 is longer than 0
mysqltest: At line 1: Missing required argument 'filename' to command 'source' mysqltest: At line 1: Missing required argument 'filename' to command 'source'
mysqltest: At line 1: Could not open file ./non_existingFile mysqltest: At line 1: Could not open file ./non_existingFile
mysqltest: In included file "MYSQLTEST_VARDIR/tmp/recursive.sql": At line 1: Source directives are nesting too deep mysqltest: In included file "MYSQLTEST_VARDIR/tmp/recursive.sql": At line 1: Source directives are nesting too deep
...@@ -538,4 +541,20 @@ hello ...@@ -538,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
# Embedded server doesn't support external clients # Embedded server doesn't support external clients
--source include/not_embedded.inc --source include/not_embedded.inc
# Don't run this test if $MYSQL_FIX_PRIVILEGE_TABLES isn't set
# to the location of mysql_fix_privilege_tables.sql
if (`SELECT LENGTH("$MYSQL_FIX_PRIVILEGE_TABLES") <= 0`)
{
skip Test need MYSQL_FIX_PRIVILEGE_TABLES;
}
# #
# This is the test for mysql_fix_privilege_tables # This is the test for mysql_fix_privilege_tables
# It checks that a system tables from mysql 4.1.23 # It checks that a system tables from mysql 4.1.23
......
...@@ -718,6 +718,21 @@ let $A = changed value of A; ...@@ -718,6 +718,21 @@ let $A = changed value of A;
let $B = changed value of B; let $B = changed value of B;
--echo # Content of \$A is: $A --echo # Content of \$A is: $A
# ----------------------------------------------------------------------------
# Test let from query with $variable
# let $<var_name>=`<query with $variable>`;
# ----------------------------------------------------------------------------
let $var1=content of variable 1;
let $var2= `select "$var1"`;
let $var3= `select concat("$var1", " ", "$var2")`;
echo var2: $var2;
echo var3: $var3;
if (`select length("$var3") > 0`)
{
echo length of var3 is longer than 0;
}
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# Test to assign let from query # Test to assign let from query
# let $<var_name>=`<query>`; # let $<var_name>=`<query>`;
...@@ -1724,6 +1739,24 @@ EOF ...@@ -1724,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
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
......
# Embedded server doesn't support external clients # Embedded server doesn't support external clients
--source include/not_embedded.inc --source include/not_embedded.inc
# Windows doesn't support execution of shell scripts (to fix!!) # Don't run this test if $MYSQL_FIX_SYSTEM_TABLES isn't set
--source include/not_windows.inc # to the location of mysql_fix_privilege_tables.sql
if (`SELECT LENGTH("$MYSQL_FIX_SYSTEM_TABLES") <= 0`)
{
skip Test need MYSQL_FIX_SYSTEM_TABLES;
}
# check that CSV engine was compiled in, as the test relies on the presence # check that CSV engine was compiled in, as the test relies on the presence
# of the log tables (which are CSV-based) # of the log tables (which are CSV-based)
--source include/have_csv.inc --source include/have_csv.inc
......
# Embedded server doesn't support external clients # Embedded server doesn't support external clients
--source include/not_embedded.inc --source include/not_embedded.inc
# Don't run this test if $MYSQL_FIX_PRIVILEGE_TABLES isn't set
# to the location of mysql_fix_privilege_tables.sql
if (`SELECT LENGTH("$MYSQL_FIX_PRIVILEGE_TABLES") <= 0`)
{
skip Test need MYSQL_FIX_PRIVILEGE_TABLES;
}
# #
# This is the test for mysql_fix_privilege_tables # This is the test for mysql_fix_privilege_tables
# It checks that a system tables from mysql 4.1.23 # It checks that a system tables from mysql 4.1.23
......
...@@ -21,8 +21,7 @@ MYSQLBASEdir= $(prefix) ...@@ -21,8 +21,7 @@ MYSQLBASEdir= $(prefix)
MYSQLLIBdir= $(pkglibdir) MYSQLLIBdir= $(pkglibdir)
INCLUDES = @ZLIB_INCLUDES@ \ INCLUDES = @ZLIB_INCLUDES@ \
-I$(top_builddir)/include -I$(top_srcdir)/include \ -I$(top_builddir)/include -I$(top_srcdir)/include \
-I$(top_srcdir)/regex -I$(srcdir) \ -I$(top_srcdir)/regex -I$(srcdir) $(openssl_includes)
$(openssl_includes)
WRAPLIBS= @WRAPLIBS@ WRAPLIBS= @WRAPLIBS@
SUBDIRS = share SUBDIRS = share
libexec_PROGRAMS = mysqld libexec_PROGRAMS = mysqld
......
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