From 33b6bab87177851b134da6b0c0596fdba2a906e8 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 26 Dec 2006 15:08:41 +0400 Subject: [PATCH 01/27] Fix for bug #23616: Week() changed behaviour between 5.0.22 and 5.0.24 Consider double values as legal date{time} function's arguments (i.e. allow dates in internal format YYYYMMDDHHMMSS.XXXXXX). mysql-test/r/func_sapdb.result: Fix for bug #23616: Week() changed behaviour between 5.0.22 and 5.0.24 - result adjusted. mysql-test/r/func_time.result: Fix for bug #23616: Week() changed behaviour between 5.0.22 and 5.0.24 - test result. mysql-test/t/func_time.test: Fix for bug #23616: Week() changed behaviour between 5.0.22 and 5.0.24 - test case. sql-common/my_time.c: Fix for bug #23616: Week() changed behaviour between 5.0.22 and 5.0.24 - consider '.' as an acceptable separator for dates like YYYYYMMDDHHMMSS.XXXXXX --- mysql-test/r/func_sapdb.result | 4 +--- mysql-test/r/func_time.result | 4 ++++ mysql-test/t/func_time.test | 7 +++++++ sql-common/my_time.c | 2 +- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/func_sapdb.result b/mysql-test/r/func_sapdb.result index 447cadb9898..7c46b966dab 100644 --- a/mysql-test/r/func_sapdb.result +++ b/mysql-test/r/func_sapdb.result @@ -229,9 +229,7 @@ a 10000 select microsecond(19971231235959.01) as a; a -0 -Warnings: -Warning 1292 Truncated incorrect time value: '19971231235959.01' +10000 select date_add("1997-12-31",INTERVAL "10.09" SECOND_MICROSECOND) as a; a 1997-12-31 00:00:10.090000 diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index fdfb42c878d..fc218067d29 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -854,4 +854,8 @@ H select last_day('0000-00-00'); last_day('0000-00-00') NULL +select isnull(week(now() + 0)), isnull(week(now() + 0.2)), +week(20061108), week(20061108.01), week(20061108085411.000002); +isnull(week(now() + 0)) isnull(week(now() + 0.2)) week(20061108) week(20061108.01) week(20061108085411.000002) +0 0 45 45 45 End of 4.1 tests diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index fa12c45db04..2fb5ea04a19 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -492,4 +492,11 @@ union select last_day('0000-00-00'); +# +# Bug 23616: datetime functions with double argumets +# + +select isnull(week(now() + 0)), isnull(week(now() + 0.2)), + week(20061108), week(20061108.01), week(20061108085411.000002); + --echo End of 4.1 tests diff --git a/sql-common/my_time.c b/sql-common/my_time.c index 2d3d71e646c..77226da3dc8 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -145,7 +145,7 @@ str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time, digits= (uint) (pos-str); start_loop= 0; /* Start of scan loop */ date_len[format_position[0]]= 0; /* Length of year field */ - if (pos == end) + if (pos == end || *pos == '.') { /* Found date in internal format (only numbers like YYYYMMDD) */ year_length= (digits == 4 || digits == 8 || digits >= 14) ? 4 : 2; From 772e03c2256f254330adbcc085ba4e1a7ee2f29e Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 7 Feb 2007 09:46:20 +0100 Subject: [PATCH 02/27] Bug#10777 ERROR File = sql_lex.cc, Line = 93 The identifier "symbols" is undefined. - Protect againt empty/corrupt lex_hash-h by writing output from gen_lex_hash to a temporary file first. sql/Makefile.am: Protect against empty lex_hash.h due to failed execution of gen_lex_hash by writing outpout to a tmp file first --- sql/Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/Makefile.am b/sql/Makefile.am index 43a7617df52..cf7bc0a1452 100644 --- a/sql/Makefile.am +++ b/sql/Makefile.am @@ -142,7 +142,8 @@ sql_yacc.o: sql_yacc.cc sql_yacc.h $(HEADERS) # this avoid the rebuild of the built files in a source dist lex_hash.h: gen_lex_hash.cc lex.h $(MAKE) $(AM_MAKEFLAGS) gen_lex_hash$(EXEEXT) - ./gen_lex_hash$(EXEEXT) > $@ + ./gen_lex_hash$(EXEEXT) > $@-t + $(MV) $@-t $@ # For testing of udf_example.so; Works on platforms with gcc # (This is not part of our build process but only provided as an example) From 4c4f50623896f43873420d6c8d8e2a320653d57a Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 9 Feb 2007 11:05:36 +0100 Subject: [PATCH 03/27] Bug#25126: Reference to non-existant column in UPDATE...ORDER BY... crashes server "update existingtable set anycolumn=nonexisting order by nonexisting" would crash the server. Though we would find the reference to a field, that doesn't mean we can then use it to set some values. It could be a reference to another field. If it is NULL, don't try to use it to set values in the Item_field and instead return an error. Over the previous patch, this signals an error at the location of the error, rather than letting the subsequent deref signal it. mysql-test/r/order_by.result: Verify that all permutations work. mysql-test/t/order_by.test: Verify that all permutations work. sql/item.cc: When the field is NULL, don't dereference it when we set_field(). Instead, raise an error. --- mysql-test/r/order_by.result | 24 ++++++++++++++++++++++++ mysql-test/t/order_by.test | 30 ++++++++++++++++++++++++++++++ sql/item.cc | 13 ++++++++++++- 3 files changed, 66 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result index 320bb89b62e..a20a715a325 100644 --- a/mysql-test/r/order_by.result +++ b/mysql-test/r/order_by.result @@ -847,3 +847,27 @@ num (select num + 2 FROM t1 LIMIT 1) SELECT a.a + 1 AS num FROM t1 a JOIN t1 b ON num = b.a; ERROR 42S22: Unknown column 'num' in 'on clause' DROP TABLE t1; +CREATE TABLE bug25126 ( +val int unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY +); +UPDATE bug25126 SET MissingCol = MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'field list' +UPDATE bug25126 SET val = val ORDER BY MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'order clause' +UPDATE bug25126 SET val = val ORDER BY val; +UPDATE bug25126 SET val = 1 ORDER BY val; +UPDATE bug25126 SET val = 1 ORDER BY MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'order clause' +UPDATE bug25126 SET val = 1 ORDER BY val, MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'order clause' +UPDATE bug25126 SET val = MissingCol ORDER BY MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'order clause' +UPDATE bug25126 SET MissingCol = 1 ORDER BY val, MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'order clause' +UPDATE bug25126 SET MissingCol = 1 ORDER BY MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'order clause' +UPDATE bug25126 SET MissingCol = val ORDER BY MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'order clause' +UPDATE bug25126 SET MissingCol = MissingCol ORDER BY MissingCol; +ERROR 42S22: Unknown column 'MissingCol' in 'order clause' +DROP TABLE bug25126; diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test index a8024be7032..bfca5ddd15d 100644 --- a/mysql-test/t/order_by.test +++ b/mysql-test/t/order_by.test @@ -575,4 +575,34 @@ SELECT a + 1 AS num, (select num + 2 FROM t1 LIMIT 1) FROM t1; SELECT a.a + 1 AS num FROM t1 a JOIN t1 b ON num = b.a; DROP TABLE t1; +# +# Bug#25126: Reference to non-existant column in UPDATE...ORDER BY... +# crashes server +# +CREATE TABLE bug25126 ( + val int unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY +); +--error 1054 +UPDATE bug25126 SET MissingCol = MissingCol; +--error 1054 +UPDATE bug25126 SET val = val ORDER BY MissingCol; +UPDATE bug25126 SET val = val ORDER BY val; +UPDATE bug25126 SET val = 1 ORDER BY val; +--error 1054 +UPDATE bug25126 SET val = 1 ORDER BY MissingCol; +--error 1054 +UPDATE bug25126 SET val = 1 ORDER BY val, MissingCol; +--error 1054 +UPDATE bug25126 SET val = MissingCol ORDER BY MissingCol; +--error 1054 +UPDATE bug25126 SET MissingCol = 1 ORDER BY val, MissingCol; +--error 1054 +UPDATE bug25126 SET MissingCol = 1 ORDER BY MissingCol; +--error 1054 +UPDATE bug25126 SET MissingCol = val ORDER BY MissingCol; +--error 1054 +UPDATE bug25126 SET MissingCol = MissingCol ORDER BY MissingCol; +DROP TABLE bug25126; + + # End of 4.1 tests diff --git a/sql/item.cc b/sql/item.cc index 45d7856b2c1..3b7fa10902e 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1771,7 +1771,18 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) use the field from the Item_field in the select list and leave the Item_field instance in place. */ - set_field((*((Item_field**)res))->field); + + Field *field= (*((Item_field**)res))->field; + + if (field == NULL) + { + /* The column to which we link isn't valid. */ + my_error(ER_BAD_FIELD_ERROR, MYF(0), (*res)->name, + current_thd->where); + return(1); + } + + set_field(field); return 0; } else From 089ce4e3ccbe1711be73ce6aa1020e0e0130b930 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 13 Feb 2007 16:59:58 +0100 Subject: [PATCH 04/27] Reset value of variable "escaped" in "default" label causing $variables not to be expanded in same cases client/mysqltest.c: Reset value of variable "escaped" in "default" label --- client/mysqltest.c | 1 + 1 file changed, 1 insertion(+) diff --git a/client/mysqltest.c b/client/mysqltest.c index 6f0a1ba3498..f02fae8d81b 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -578,6 +578,7 @@ void do_eval(DYNAMIC_STRING *query_eval, const char *query, dynstr_append_mem(query_eval, p, 1); break; default: + escaped= 0; dynstr_append_mem(query_eval, p, 1); break; } From 77ec64a33f3c2d2cd3a408e589765214b2e45e2f Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 13 Feb 2007 18:59:46 +0100 Subject: [PATCH 05/27] Write some debug info to result log file before dying in 'do_exec' --- client/mysqltest.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/client/mysqltest.c b/client/mysqltest.c index f02fae8d81b..7fa6d5b9161 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -415,6 +415,8 @@ void verbose_msg(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2); void warning_msg(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2); +void log_msg(const char *fmt, ...) + ATTRIBUTE_FORMAT(printf, 1, 2); VAR* var_from_env(const char *, const char *); VAR* var_init(VAR* v, const char *name, int name_len, const char *val, @@ -925,6 +927,25 @@ void warning_msg(const char *fmt, ...) } +void log_msg(const char *fmt, ...) +{ + va_list args; + char buff[512]; + size_t len; + DBUG_ENTER("log_msg"); + + memset(buff, 0, sizeof(buff)); + va_start(args, fmt); + len= vsnprintf(buff, sizeof(buff)-1, fmt, args); + va_end(args); + + dynstr_append_mem(&ds_res, buff, len); + dynstr_append(&ds_res, "\n"); + + DBUG_VOID_RETURN; +} + + /* Compare content of the string ds to content of file fname */ @@ -1597,7 +1618,11 @@ void do_exec(struct st_command *command) my_bool ok= 0; if (command->abort_on_error) + { + log_msg("exec of '%s failed, error: %d, status: %d, errno: %d", + ds_cmd.str, error, status, errno); die("command \"%s\" failed", command->first_argument); + } DBUG_PRINT("info", ("error: %d, status: %d", error, status)); @@ -1621,6 +1646,8 @@ void do_exec(struct st_command *command) command->expected_errors.err[0].code.errnum != 0) { /* Error code we wanted was != 0, i.e. not an expected success */ + log_msg("exec of '%s failed, error: %d, errno: %d", + ds_cmd.str, error, errno); die("command \"%s\" succeeded - should have failed with errno %d...", command->first_argument, command->expected_errors.err[0].code.errnum); } From 557f6169b9e4abd325e7d46cd523ac7012ce404d Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Feb 2007 16:49:41 +0100 Subject: [PATCH 06/27] Use my_vsnprintf instead of vsnprintf --- client/mysqltest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 7fa6d5b9161..99462d82f40 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -936,7 +936,7 @@ void log_msg(const char *fmt, ...) memset(buff, 0, sizeof(buff)); va_start(args, fmt); - len= vsnprintf(buff, sizeof(buff)-1, fmt, args); + len= my_vsnprintf(buff, sizeof(buff)-1, fmt, args); va_end(args); dynstr_append_mem(&ds_res, buff, len); From a843a05f92b962477ee338f26696e253ed23607f Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 16 Feb 2007 15:19:38 +0100 Subject: [PATCH 07/27] Workaround for problem where cygwin's bash/sh randomly fails with error 128 which mainly occurs on win2003 64bit. - Execute "exec" commands directly with cmd.exe and replace "--exec echo ..." with "--exec .\echo.exe ..." client/mysqltest.c: Workaround the problem with "echo" in windows not behaving like "echo" in Unix. - Replace "--exec echo ..." with "--exec \echo.exe" thus forcing use of our own echo implementation which baheves like on Unix. - The above change makes it possible to remove the need to execute all --exec's inside cygwin. Add ifdefs to only use use cygwin's bash conditionally mysql-test/lib/mtr_misc.pl: Add function for converting to the OS's native format mysql-test/mysql-test-run.pl: Convert path to executables to "windows native" (c:\\) instead of "mixed"(c:/) mode necessary for pipes and redirects to work properly in cmd.exe client/echo.c: New BitKeeper file ``client/echo.c'' --- client/echo.c | 45 +++++++++++++++++ client/mysqltest.c | 93 ++++++++++++++++++++++++++++++++---- mysql-test/lib/mtr_misc.pl | 11 +++++ mysql-test/mysql-test-run.pl | 34 ++++++++----- 4 files changed, 161 insertions(+), 22 deletions(-) create mode 100644 client/echo.c diff --git a/client/echo.c b/client/echo.c new file mode 100644 index 00000000000..4483eaad293 --- /dev/null +++ b/client/echo.c @@ -0,0 +1,45 @@ +/* Copyright (C) 2000 MySQL AB + + 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +/* + echo is a replacement for the "echo" command builtin to cmd.exe + on Windows, to get a Unix eqvivalent behaviour when running commands + like: + $> echo "hello" | mysql + + The windows "echo" would have sent "hello" to mysql while + Unix echo will send hello without the enclosing hyphens + + This is a very advanced high tech program so take care when + you change it and remember to valgrind it before production + use. + +*/ + +#include + +int main(int argc, char **argv) +{ + int i; + for (i= 1; i < argc; i++) + { + fprintf(stdout, "%s", argv[i]); + if (i < argc - 1) + fprintf(stdout, " "); + } + fprintf(stdout, "\n"); + return 0; +} diff --git a/client/mysqltest.c b/client/mysqltest.c index 6f0a1ba3498..44a060fbc40 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -407,6 +407,8 @@ TYPELIB command_typelib= {array_elements(command_names),"", DYNAMIC_STRING ds_res, ds_progress, ds_warning_messages; +char builtin_echo[FN_REFLEN]; + void die(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2); void abort_not_supported_test(const char *fmt, ...) @@ -913,10 +915,10 @@ void warning_msg(const char *fmt, ...) dynstr_append_mem(&ds_warning_messages, buff, len); } -#ifndef __WIN__ - len= vsnprintf(buff, sizeof(buff), fmt, args); + + len= my_vsnprintf(buff, sizeof(buff), fmt, args); dynstr_append_mem(&ds_warning_messages, buff, len); -#endif + dynstr_append(&ds_warning_messages, "\n"); va_end(args); @@ -1497,29 +1499,36 @@ void do_source(struct st_command *command) } -#ifdef __WIN__ +#if defined __WIN__ + +#ifdef USE_CYGWIN /* Variables used for temporary sh files used for emulating Unix on Windows */ char tmp_sh_name[64], tmp_sh_cmd[70]; +#endif void init_tmp_sh_file() { +#ifdef USE_CYGWIN /* Format a name for the tmp sh file that is unique for this process */ my_snprintf(tmp_sh_name, sizeof(tmp_sh_name), "tmp_%d.sh", getpid()); /* Format the command to execute in order to run the script */ my_snprintf(tmp_sh_cmd, sizeof(tmp_sh_cmd), "sh %s", tmp_sh_name); +#endif } void free_tmp_sh_file() { +#ifdef USE_CYGWIN my_delete(tmp_sh_name, MYF(0)); +#endif } #endif FILE* my_popen(DYNAMIC_STRING *ds_cmd, const char *mode) { -#ifdef __WIN__ +#if defined __WIN__ && defined USE_CYGWIN /* Dump the command into a sh script file and execute with popen */ str_to_file(tmp_sh_name, ds_cmd->str, ds_cmd->length); return popen(tmp_sh_cmd, mode); @@ -1529,6 +1538,64 @@ FILE* my_popen(DYNAMIC_STRING *ds_cmd, const char *mode) } +static void init_builtin_echo(void) +{ +#ifdef __WIN__ + + /* Look for "echo.exe" in same dir as mysqltest was started from */ + dirname_part(builtin_echo, my_progname); + fn_format(builtin_echo, ".\\echo.exe", + builtin_echo, "", MYF(MY_REPLACE_DIR)); + + /* Make sure echo.exe exists */ + if (access(builtin_echo, F_OK) != 0) + builtin_echo[0]= 0; + return; + +#else + + builtin_echo[0]= 0; + return; + +#endif +} + + +/* + Replace a substring + + SYNOPSIS + replace + ds_str The string to search and perform the replace in + search_str The string to search for + search_len Length of the string to search for + replace_str The string to replace with + replace_len Length of the string to replace with + + RETURN + 0 String replaced + 1 Could not find search_str in str +*/ + +static int replace(DYNAMIC_STRING *ds_str, + const char *search_str, ulong search_len, + const char *replace_str, ulong replace_len) +{ + DYNAMIC_STRING ds_tmp; + const char *start= strstr(ds_str->str, search_str); + if (!start) + return 1; + init_dynamic_string(&ds_tmp, "", + ds_str->length + replace_len, 256); + dynstr_append_mem(&ds_tmp, ds_str->str, start - ds_str->str); + dynstr_append_mem(&ds_tmp, replace_str, replace_len); + dynstr_append(&ds_tmp, start + search_len); + dynstr_set(ds_str, ds_tmp.str); + dynstr_free(&ds_tmp); + return 0; +} + + /* Execute given command. @@ -1547,13 +1614,13 @@ FILE* my_popen(DYNAMIC_STRING *ds_cmd, const char *mode) NOTE Although mysqltest is executed from cygwin shell, the command will be executed in "cmd.exe". Thus commands like "rm" etc can NOT be used, use - system for those commands. + mysqltest commmand(s) like "remove_file" for that */ void do_exec(struct st_command *command) { int error; - char buf[1024]; + char buf[512]; FILE *res_file; char *cmd= command->first_argument; DYNAMIC_STRING ds_cmd; @@ -1571,8 +1638,15 @@ void do_exec(struct st_command *command) /* Eval the command, thus replacing all environment variables */ do_eval(&ds_cmd, cmd, command->end, TRUE); + /* Check if echo should be replaced with "builtin" echo */ + if (builtin_echo[0] && strncmp(cmd, "echo", 4) == 0) + { + /* Replace echo with our "builtin" echo */ + replace(&ds_cmd, "echo", 4, builtin_echo, strlen(builtin_echo)); + } + DBUG_PRINT("info", ("Executing '%s' as '%s'", - command->first_argument, cmd)); + command->first_argument, ds_cmd.str)); if (!(res_file= my_popen(&ds_cmd, "r")) && command->abort_on_error) die("popen(\"%s\", \"r\") failed", command->first_argument); @@ -1690,7 +1764,7 @@ int do_modify_var(struct st_command *command, int my_system(DYNAMIC_STRING* ds_cmd) { -#ifdef __WIN__ +#if defined __WIN__ && defined USE_CYGWIN /* Dump the command into a sh script file and execute with system */ str_to_file(tmp_sh_name, ds_cmd->str, ds_cmd->length); return system(tmp_sh_cmd); @@ -5613,6 +5687,7 @@ int main(int argc, char **argv) parser.current_line= parser.read_lines= 0; memset(&var_reg, 0, sizeof(var_reg)); + init_builtin_echo(); #ifdef __WIN__ init_tmp_sh_file(); init_win_path_patterns(); diff --git a/mysql-test/lib/mtr_misc.pl b/mysql-test/lib/mtr_misc.pl index c016f3dc34f..880368be170 100644 --- a/mysql-test/lib/mtr_misc.pl +++ b/mysql-test/lib/mtr_misc.pl @@ -8,6 +8,7 @@ use strict; sub mtr_full_hostname (); sub mtr_short_hostname (); +sub mtr_native_path($); sub mtr_init_args ($); sub mtr_add_arg ($$@); sub mtr_path_exists(@); @@ -49,6 +50,16 @@ sub mtr_short_hostname () { return $hostname; } +# Convert path to OS native format +sub mtr_native_path($) +{ + my $path= shift; + $path=~ s/\//\\/g + if ($::glob_win32); + return $path; +} + + # FIXME move to own lib sub mtr_init_args ($) { diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index f53b470aaf4..fc0ad54c095 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -347,6 +347,7 @@ sub stop_all_servers (); sub run_mysqltest ($); sub usage ($); + ###################################################################### # # Main program @@ -1518,7 +1519,8 @@ sub executable_setup () { sub generate_cmdline_mysqldump ($) { my($mysqld) = @_; return - "$exe_mysqldump --no-defaults -uroot " . + mtr_native_path($exe_mysqldump) . + " --no-defaults -uroot " . "--port=$mysqld->{'port'} " . "--socket=$mysqld->{'path_sock'} --password="; } @@ -1721,9 +1723,10 @@ sub environment_setup () { # Setup env so childs can execute mysqlcheck # ---------------------------------------------------- my $cmdline_mysqlcheck= - "$exe_mysqlcheck --no-defaults -uroot " . - "--port=$master->[0]->{'port'} " . - "--socket=$master->[0]->{'path_sock'} --password="; + mtr_native_path($exe_mysqlcheck) . + " --no-defaults -uroot " . + "--port=$master->[0]->{'port'} " . + "--socket=$master->[0]->{'path_sock'} --password="; if ( $opt_debug ) { @@ -1755,7 +1758,8 @@ sub environment_setup () { if ( $exe_mysqlslap ) { my $cmdline_mysqlslap= - "$exe_mysqlslap -uroot " . + mtr_native_path($exe_mysqlslap) . + " -uroot " . "--port=$master->[0]->{'port'} " . "--socket=$master->[0]->{'path_sock'} --password= " . "--lock-directory=$opt_tmpdir"; @@ -1772,7 +1776,8 @@ sub environment_setup () { # Setup env so childs can execute mysqlimport # ---------------------------------------------------- my $cmdline_mysqlimport= - "$exe_mysqlimport -uroot " . + mtr_native_path($exe_mysqlimport) . + " -uroot " . "--port=$master->[0]->{'port'} " . "--socket=$master->[0]->{'path_sock'} --password="; @@ -1788,7 +1793,8 @@ sub environment_setup () { # Setup env so childs can execute mysqlshow # ---------------------------------------------------- my $cmdline_mysqlshow= - "$exe_mysqlshow -uroot " . + mtr_native_path($exe_mysqlshow) . + " -uroot " . "--port=$master->[0]->{'port'} " . "--socket=$master->[0]->{'path_sock'} --password="; @@ -1803,7 +1809,7 @@ sub environment_setup () { # Setup env so childs can execute mysqlbinlog # ---------------------------------------------------- my $cmdline_mysqlbinlog= - "$exe_mysqlbinlog" . + mtr_native_path($exe_mysqlbinlog) . " --no-defaults --local-load=$opt_tmpdir"; if ( $mysql_version_id >= 50000 ) { @@ -1821,7 +1827,8 @@ sub environment_setup () { # Setup env so childs can execute mysql # ---------------------------------------------------- my $cmdline_mysql= - "$exe_mysql --no-defaults --host=localhost --user=root --password= " . + mtr_native_path($exe_mysql) . + " --no-defaults --host=localhost --user=root --password= " . "--port=$master->[0]->{'port'} " . "--socket=$master->[0]->{'path_sock'} ". "--character-sets-dir=$path_charsetsdir"; @@ -1850,17 +1857,17 @@ sub environment_setup () { # ---------------------------------------------------- # Setup env so childs can execute my_print_defaults # ---------------------------------------------------- - $ENV{'MYSQL_MY_PRINT_DEFAULTS'}= $exe_my_print_defaults; + $ENV{'MYSQL_MY_PRINT_DEFAULTS'}= mtr_native_path($exe_my_print_defaults); # ---------------------------------------------------- # Setup env so childs can execute mysqladmin # ---------------------------------------------------- - $ENV{'MYSQLADMIN'}= $exe_mysqladmin; + $ENV{'MYSQLADMIN'}= mtr_native_path($exe_mysqladmin); # ---------------------------------------------------- # Setup env so childs can execute perror # ---------------------------------------------------- - $ENV{'MY_PERROR'}= $exe_perror; + $ENV{'MY_PERROR'}= mtr_native_path($exe_perror); # ---------------------------------------------------- # Add the path where mysqld will find udf_example.so @@ -4516,7 +4523,8 @@ sub run_mysqltest ($) { # ---------------------------------------------------------------------- # export MYSQL_TEST variable containing /mysqltest # ---------------------------------------------------------------------- - $ENV{'MYSQL_TEST'}= "$exe_mysqltest " . join(" ", @$args); + $ENV{'MYSQL_TEST'}= + mtr_native_path($exe_mysqltest) . " " . join(" ", @$args); # ---------------------------------------------------------------------- # Add arguments that should not go into the MYSQL_TEST env var From da21afb2196db83f9f8d8420bb61550c21861831 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 19 Feb 2007 12:00:17 +0100 Subject: [PATCH 08/27] Don't output escape char from 'do_eval' on windows. "It" won't know it's an escape char. Replace /dev/null with NUL Replace "closed stdout" with "not open fd" --- client/mysqltest.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index c7504aee9ef..23de45ed87c 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -103,7 +103,7 @@ static my_bool disable_query_log= 0, disable_result_log= 0; static my_bool disable_warnings= 0, disable_ps_warnings= 0; static my_bool disable_info= 1; static my_bool abort_on_error= 1; - +static my_bool is_windows= 0; static char **default_argv; static const char *load_default_groups[]= { "mysqltest", "client", 0 }; static char line_buffer[MAX_DELIMITER_LENGTH], *line_buffer_pos= line_buffer; @@ -1658,7 +1658,7 @@ void do_exec(struct st_command *command) init_dynamic_string(&ds_cmd, 0, command->query_len+256, 256); /* Eval the command, thus replacing all environment variables */ - do_eval(&ds_cmd, cmd, command->end, TRUE); + do_eval(&ds_cmd, cmd, command->end, !is_windows); /* Check if echo should be replaced with "builtin" echo */ if (builtin_echo[0] && strncmp(cmd, "echo", 4) == 0) @@ -1667,6 +1667,15 @@ void do_exec(struct st_command *command) replace(&ds_cmd, "echo", 4, builtin_echo, strlen(builtin_echo)); } +#ifdef __WIN__ + /* Replace /dev/null with NUL */ + while(replace(&ds_cmd, "/dev/null", 9, "NUL", 3) == 0) + ; + /* Replace "closed stdout" with non existing output fd */ + while(replace(&ds_cmd, ">&-", 3, ">&4", 3) == 0) + ; +#endif + DBUG_PRINT("info", ("Executing '%s' as '%s'", command->first_argument, ds_cmd.str)); @@ -1826,7 +1835,14 @@ void do_system(struct st_command *command) init_dynamic_string(&ds_cmd, 0, command->query_len + 64, 256); /* Eval the system command, thus replacing all environment variables */ - do_eval(&ds_cmd, command->first_argument, command->end, TRUE); + do_eval(&ds_cmd, command->first_argument, command->end, !is_windows); + +#ifdef __WIN__ + /* Replace /dev/null with NUL */ + while(replace(&ds_cmd, "/dev/null", 9, "NUL", 3) == 0) + ; +#endif + DBUG_PRINT("info", ("running system command '%s' as '%s'", command->first_argument, ds_cmd.str)); @@ -5717,6 +5733,7 @@ int main(int argc, char **argv) init_builtin_echo(); #ifdef __WIN__ + is_windows= 0; init_tmp_sh_file(); init_win_path_patterns(); #endif From d329b1f2039b4c00016609721bd414b0c1a6e160 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 19 Feb 2007 16:39:50 +0100 Subject: [PATCH 09/27] Add "append_file" command to mysqltest --- client/mysqltest.c | 142 +++++++++++++++++++++++++----------- mysql-test/t/mysqltest.test | 19 +++++ 2 files changed, 120 insertions(+), 41 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 23de45ed87c..86ef3525d1e 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -32,7 +32,7 @@ Holyfoot */ -#define MTEST_VERSION "3.1" +#define MTEST_VERSION "3.2" #include #include @@ -273,7 +273,7 @@ enum enum_commands { Q_DISABLE_PARSING, Q_ENABLE_PARSING, Q_REPLACE_REGEX, Q_REMOVE_FILE, Q_FILE_EXIST, Q_WRITE_FILE, Q_COPY_FILE, Q_PERL, Q_DIE, Q_EXIT, - Q_CHMOD_FILE, + Q_CHMOD_FILE, Q_APPEND_FILE, Q_UNKNOWN, /* Unknown command. */ Q_COMMENT, /* Comments, ignored. */ @@ -357,6 +357,7 @@ const char *command_names[]= /* Don't execute any more commands, compare result */ "exit", "chmod", + "append_file", 0 }; @@ -436,6 +437,7 @@ void dump_progress(); void do_eval(DYNAMIC_STRING *query_eval, const char *query, const char *query_end, my_bool pass_through_escape_chars); void str_to_file(const char *fname, char *str, int size); +void str_to_file2(const char *fname, char *str, int size, my_bool append); #ifdef __WIN__ void free_tmp_sh_file(); @@ -2063,6 +2065,38 @@ void read_until_delimiter(DYNAMIC_STRING *ds, } +void do_write_file_command(struct st_command *command, my_bool append) +{ + static DYNAMIC_STRING ds_content; + static DYNAMIC_STRING ds_filename; + static DYNAMIC_STRING ds_delimiter; + const struct command_arg write_file_args[] = { + "filename", ARG_STRING, TRUE, &ds_filename, "File to write to", + "delimiter", ARG_STRING, FALSE, &ds_delimiter, "Delimiter to read until" + }; + DBUG_ENTER("do_write_file"); + + check_command_args(command, + command->first_argument, + write_file_args, + sizeof(write_file_args)/sizeof(struct command_arg), + ' '); + + /* If no delimiter was provided, use EOF */ + if (ds_delimiter.length == 0) + dynstr_set(&ds_delimiter, "EOF"); + + init_dynamic_string(&ds_content, "", 1024, 1024); + read_until_delimiter(&ds_content, &ds_delimiter); + DBUG_PRINT("info", ("Writing to file: %s", ds_filename.str)); + str_to_file2(ds_filename.str, ds_content.str, ds_content.length, append); + dynstr_free(&ds_content); + dynstr_free(&ds_filename); + dynstr_free(&ds_delimiter); + DBUG_VOID_RETURN; +} + + /* SYNOPSIS do_write_file @@ -2092,33 +2126,38 @@ void read_until_delimiter(DYNAMIC_STRING *ds, void do_write_file(struct st_command *command) { - static DYNAMIC_STRING ds_content; - static DYNAMIC_STRING ds_filename; - static DYNAMIC_STRING ds_delimiter; - const struct command_arg write_file_args[] = { - "filename", ARG_STRING, TRUE, &ds_filename, "File to write to", - "delimiter", ARG_STRING, FALSE, &ds_delimiter, "Delimiter to read until" - }; - DBUG_ENTER("do_write_file"); + do_write_file_command(command, FALSE); +} - check_command_args(command, - command->first_argument, - write_file_args, - sizeof(write_file_args)/sizeof(struct command_arg), - ' '); - /* If no delimiter was provided, use EOF */ - if (ds_delimiter.length == 0) - dynstr_set(&ds_delimiter, "EOF"); +/* + SYNOPSIS + do_append_file + command called command - init_dynamic_string(&ds_content, "", 1024, 1024); - read_until_delimiter(&ds_content, &ds_delimiter); - DBUG_PRINT("info", ("Writing to file: %s", ds_filename.str)); - str_to_file(ds_filename.str, ds_content.str, ds_content.length); - dynstr_free(&ds_content); - dynstr_free(&ds_filename); - dynstr_free(&ds_delimiter); - DBUG_VOID_RETURN; + DESCRIPTION + append_file []; + + <...> + < what to write line n> + EOF + + --append_file ; + + <...> + < what to write line n> + EOF + + Append everything between the "append_file" command + and 'delimiter' to "file_name" + + Default is EOF + +*/ + +void do_append_file(struct st_command *command) +{ + do_write_file_command(command, TRUE); } @@ -4271,6 +4310,40 @@ int parse_args(int argc, char **argv) return 0; } +/* + Write the content of str into file + + SYNOPSIS + str_to_file2 + fname - name of file to truncate/create and write to + str - content to write to file + size - size of content witten to file + append - append to file instead of overwriting old file +*/ + +void str_to_file2(const char *fname, char *str, int size, my_bool append) +{ + int fd; + char buff[FN_REFLEN]; + int flags= O_WRONLY | O_CREAT; + if (!test_if_hard_path(fname)) + { + strxmov(buff, opt_basedir, fname, NullS); + fname= buff; + } + fn_format(buff, fname, "", "", MY_UNPACK_FILENAME); + + if (!append) + flags|= O_TRUNC; + if ((fd= my_open(buff, flags, + MYF(MY_WME | MY_FFNF))) < 0) + die("Could not open %s: errno = %d", buff, errno); + if (append && my_seek(fd, 0, SEEK_END, MYF(0)) == MY_FILEPOS_ERROR) + die("Could not find end of file %s: errno = %d", buff, errno); + if (my_write(fd, (byte*)str, size, MYF(MY_WME|MY_FNABP))) + die("write failed"); + my_close(fd, MYF(0)); +} /* Write the content of str into file @@ -4284,21 +4357,7 @@ int parse_args(int argc, char **argv) void str_to_file(const char *fname, char *str, int size) { - int fd; - char buff[FN_REFLEN]; - if (!test_if_hard_path(fname)) - { - strxmov(buff, opt_basedir, fname, NullS); - fname= buff; - } - fn_format(buff, fname, "", "", MY_UNPACK_FILENAME); - - if ((fd= my_open(buff, O_WRONLY | O_CREAT | O_TRUNC, - MYF(MY_WME | MY_FFNF))) < 0) - die("Could not open %s: errno = %d", buff, errno); - if (my_write(fd, (byte*)str, size, MYF(MY_WME|MY_FNABP))) - die("write failed"); - my_close(fd, MYF(0)); + str_to_file2(fname, str, size, FALSE); } @@ -5867,6 +5926,7 @@ int main(int argc, char **argv) case Q_REMOVE_FILE: do_remove_file(command); break; case Q_FILE_EXIST: do_file_exist(command); break; case Q_WRITE_FILE: do_write_file(command); break; + case Q_APPEND_FILE: do_append_file(command); break; case Q_COPY_FILE: do_copy_file(command); break; case Q_CHMOD_FILE: do_chmod_file(command); break; case Q_PERL: do_perl(command); break; diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index c06d51d9d49..2182ea6cb0b 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -1484,6 +1484,25 @@ END_DELIMITER file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp; remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp; +# ---------------------------------------------------------------------------- +# test for append_file +# ---------------------------------------------------------------------------- + +write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp; +Content for test_file1 +EOF +file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp; + +append_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp; +Appended text +EOF +file_exists $MYSQLTEST_VARDIR/tmp/test_file1.tmp; + +remove_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp; +append_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp; +Appended text on nonexisting file +EOF + # ---------------------------------------------------------------------------- # test for file_exist # ---------------------------------------------------------------------------- From 8d7e8d971580c4b35d49e9dcb7b27834ff29fd7e Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 19 Feb 2007 18:19:47 +0100 Subject: [PATCH 10/27] Add cat_file command to mysqltest --- client/mysqltest.c | 48 ++++++++++++++++++++++++++++++++++- mysql-test/r/mysqltest.result | 4 +++ mysql-test/t/mysqltest.test | 14 ++++++++++ 3 files changed, 65 insertions(+), 1 deletion(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 86ef3525d1e..04d1f59dd4c 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -273,7 +273,7 @@ enum enum_commands { Q_DISABLE_PARSING, Q_ENABLE_PARSING, Q_REPLACE_REGEX, Q_REMOVE_FILE, Q_FILE_EXIST, Q_WRITE_FILE, Q_COPY_FILE, Q_PERL, Q_DIE, Q_EXIT, - Q_CHMOD_FILE, Q_APPEND_FILE, + Q_CHMOD_FILE, Q_APPEND_FILE, Q_CAT_FILE, Q_UNKNOWN, /* Unknown command. */ Q_COMMENT, /* Comments, ignored. */ @@ -358,6 +358,7 @@ const char *command_names[]= "exit", "chmod", "append_file", + "cat_file", 0 }; @@ -2161,6 +2162,50 @@ void do_append_file(struct st_command *command) } +/* + SYNOPSIS + do_cat_file + command called command + + DESCRIPTION + cat_file ; + + Print the given file to result log + +*/ + +void do_cat_file(struct st_command *command) +{ + int fd; + uint len; + byte buff[512]; + static DYNAMIC_STRING ds_filename; + const struct command_arg cat_file_args[] = { + "filename", ARG_STRING, TRUE, &ds_filename, "File to read from" + }; + DBUG_ENTER("do_cat_file"); + + check_command_args(command, + command->first_argument, + cat_file_args, + sizeof(cat_file_args)/sizeof(struct command_arg), + ' '); + + DBUG_PRINT("info", ("Reading from, file: %s", ds_filename.str)); + + if ((fd= my_open(ds_filename.str, O_RDONLY, MYF(0))) < 0) + die("Failed to open file %s", ds_filename.str); + while((len= my_read(fd, &buff, + sizeof(buff), MYF(0))) > 0) + { + dynstr_append_mem(&ds_res, buff, len); + } + my_close(fd, MYF(0)); + dynstr_free(&ds_filename); + DBUG_VOID_RETURN; +} + + /* SYNOPSIS do_perl @@ -5927,6 +5972,7 @@ int main(int argc, char **argv) case Q_FILE_EXIST: do_file_exist(command); break; case Q_WRITE_FILE: do_write_file(command); break; case Q_APPEND_FILE: do_append_file(command); break; + case Q_CAT_FILE: do_cat_file(command); break; case Q_COPY_FILE: do_copy_file(command); break; case Q_CHMOD_FILE: do_chmod_file(command); break; case Q_PERL: do_perl(command); break; diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result index 3ddb82d4a8d..a8b5a5ef353 100644 --- a/mysql-test/r/mysqltest.result +++ b/mysql-test/r/mysqltest.result @@ -509,6 +509,10 @@ mysqltest: At line 1: Missing required argument 'filename' to command 'write_fil mysqltest: At line 1: End of file encountered before 'EOF' delimiter was found mysqltest: At line 1: End of line junk detected: "write_file filename "; " +Some data +for cat_file command +of mysqltest +mysqltest: At line 1: Failed to open file non_existing_file mysqltest: At line 1: Missing required argument 'filename' to command 'file_exists' mysqltest: At line 1: Missing required argument 'from_file' to command 'copy_file' mysqltest: At line 1: Missing required argument 'to_file' to command 'copy_file' diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index 2182ea6cb0b..f98389effa3 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -1503,6 +1503,20 @@ append_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp; Appended text on nonexisting file EOF +# ---------------------------------------------------------------------------- +# test for cat_file +# ---------------------------------------------------------------------------- + +--write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp +Some data +for cat_file command +of mysqltest +EOF +cat_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp; + +--error 1 +--exec echo "cat_file non_existing_file;" | $MYSQL_TEST 2>&1 + # ---------------------------------------------------------------------------- # test for file_exist # ---------------------------------------------------------------------------- From a8be1b932502013a552109adaf84062c4fdb4713 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 19 Feb 2007 18:23:59 +0100 Subject: [PATCH 11/27] Commment out two test's thats just confusing for cmd.exe --- mysql-test/r/mysqltest.result | 3 --- mysql-test/t/mysqltest.test | 8 ++++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result index a8b5a5ef353..71f1c7de4ed 100644 --- a/mysql-test/r/mysqltest.result +++ b/mysql-test/r/mysqltest.result @@ -210,7 +210,6 @@ source database "MySQL: The world's most popular ;open source database" echo message echo message -mysqltest: At line 1: Empty variable mysqltest: At line 1: command "false" failed mysqltest: At line 1: Missing argument in exec MySQL @@ -507,8 +506,6 @@ drop table t1; mysqltest: At line 1: Missing required argument 'filename' to command 'remove_file' mysqltest: At line 1: Missing required argument 'filename' to command 'write_file' mysqltest: At line 1: End of file encountered before 'EOF' delimiter was found -mysqltest: At line 1: End of line junk detected: "write_file filename "; -" Some data for cat_file command of mysqltest diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index f98389effa3..024b12a60e9 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -552,8 +552,8 @@ echo ; # Illegal use of echo ---error 1 ---exec echo "echo \$;" | $MYSQL_TEST 2>&1 +#--error 1 +#--exec echo "echo \$;" | $MYSQL_TEST 2>&1 # ---------------------------------------------------------------------------- @@ -1469,8 +1469,8 @@ remove_file non_existing_file; --error 1 --exec echo "write_file filename ;" | $MYSQL_TEST 2>&1 ---error 1 ---exec echo "write_file filename \";" | $MYSQL_TEST 2>&1 +#--error 1 +#--exec echo "write_file filename \";" | $MYSQL_TEST 2>&1 write_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp; Content for test_file1 From ca9944090771fb4a260d5ae5a222c11d4b48ab8c Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 19 Feb 2007 20:34:12 +0100 Subject: [PATCH 12/27] Turn the "is_windows" flag _on_ when compiled on windows --- client/mysqltest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 04d1f59dd4c..e1d793028a7 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -5837,7 +5837,7 @@ int main(int argc, char **argv) init_builtin_echo(); #ifdef __WIN__ - is_windows= 0; + is_windows= 1; init_tmp_sh_file(); init_win_path_patterns(); #endif From 1009e0d3044c77512908f14633349c143d4093ca Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 20 Feb 2007 14:20:49 +0100 Subject: [PATCH 13/27] New version of 'do_cat_file' that will trim cr/lf to lf --- client/mysqltest.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index e1d793028a7..1a8e14a7244 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -2178,7 +2178,7 @@ void do_cat_file(struct st_command *command) { int fd; uint len; - byte buff[512]; + char buff[512]; static DYNAMIC_STRING ds_filename; const struct command_arg cat_file_args[] = { "filename", ARG_STRING, TRUE, &ds_filename, "File to read from" @@ -2195,10 +2195,27 @@ void do_cat_file(struct st_command *command) if ((fd= my_open(ds_filename.str, O_RDONLY, MYF(0))) < 0) die("Failed to open file %s", ds_filename.str); - while((len= my_read(fd, &buff, + while((len= my_read(fd, (byte*)&buff, sizeof(buff), MYF(0))) > 0) { - dynstr_append_mem(&ds_res, buff, len); + char *p= buff, *start= buff; + while (p < buff+len) + { + /* Convert cr/lf to lf */ + if (*p == '\r' && *(p+1) && *(p+1)== '\n') + { + /* Add fake newline instead of cr and output the line */ + *p= '\n'; + p++; /* Step past the "fake" newline */ + dynstr_append_mem(&ds_res, start, p-start); + p++; /* Step past the "fake" newline */ + start= p; + } + else + p++; + } + /* Output any chars that migh be left */ + dynstr_append_mem(&ds_res, start, p-start); } my_close(fd, MYF(0)); dynstr_free(&ds_filename); From f10cfb055a493def16503e90bae31ad0e3077238 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 20 Feb 2007 18:20:58 +0100 Subject: [PATCH 14/27] Add "diff_files" command to mysqltest --- client/mysqltest.c | 76 ++++++++++++++++++++++++++++++++++++- mysql-test/t/mysqltest.test | 35 +++++++++++++++++ 2 files changed, 110 insertions(+), 1 deletion(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 1a8e14a7244..055577fc535 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -273,7 +273,7 @@ enum enum_commands { Q_DISABLE_PARSING, Q_ENABLE_PARSING, Q_REPLACE_REGEX, Q_REMOVE_FILE, Q_FILE_EXIST, Q_WRITE_FILE, Q_COPY_FILE, Q_PERL, Q_DIE, Q_EXIT, - Q_CHMOD_FILE, Q_APPEND_FILE, Q_CAT_FILE, + Q_CHMOD_FILE, Q_APPEND_FILE, Q_CAT_FILE, Q_DIFF_FILES, Q_UNKNOWN, /* Unknown command. */ Q_COMMENT, /* Comments, ignored. */ @@ -359,6 +359,7 @@ const char *command_names[]= "chmod", "append_file", "cat_file", + "diff_files", 0 }; @@ -2223,6 +2224,78 @@ void do_cat_file(struct st_command *command) } + +/* + SYNOPSIS + do_diff_files + command called command + + DESCRIPTION + diff_files ; + + Fails if the two files differ. + +*/ + +void do_diff_files(struct st_command *command) +{ + int error= 0; + int fd, fd2; + uint len, len2; + char buff[512], buff2[512]; + static DYNAMIC_STRING ds_filename; + static DYNAMIC_STRING ds_filename2; + const struct command_arg diff_file_args[] = { + "file1", ARG_STRING, TRUE, &ds_filename, "First file to diff", + "file2", ARG_STRING, TRUE, &ds_filename2, "Second file to diff" + }; + DBUG_ENTER("do_diff_files"); + + check_command_args(command, + command->first_argument, + diff_file_args, + sizeof(diff_file_args)/sizeof(struct command_arg), + ' '); + + if ((fd= my_open(ds_filename.str, O_RDONLY, MYF(0))) < 0) + die("Failed to open first file %s", ds_filename.str); + if ((fd2= my_open(ds_filename2.str, O_RDONLY, MYF(0))) < 0) + { + my_close(fd, MYF(0)); + die("Failed to open second file %s", ds_filename2.str); + } + while((len= my_read(fd, (byte*)&buff, + sizeof(buff), MYF(0))) > 0) + { + if ((len2= my_read(fd2, (byte*)&buff2, + sizeof(buff2), MYF(0))) != len) + { + /* File 2 was smaller */ + error= 1; + break; + } + if ((memcmp(buff, buff2, len))) + { + /* Content of this part differed */ + error= 1; + break; + } + } + if (my_read(fd2, (byte*)&buff2, + sizeof(buff2), MYF(0)) > 0) + { + /* File 1 was smaller */ + error= 1; + } + + my_close(fd, MYF(0)); + my_close(fd2, MYF(0)); + dynstr_free(&ds_filename); + dynstr_free(&ds_filename2); + handle_command_error(command, error); + DBUG_VOID_RETURN; +} + /* SYNOPSIS do_perl @@ -5989,6 +6062,7 @@ int main(int argc, char **argv) case Q_FILE_EXIST: do_file_exist(command); break; case Q_WRITE_FILE: do_write_file(command); break; case Q_APPEND_FILE: do_append_file(command); break; + case Q_DIFF_FILES: do_diff_files(command); break; case Q_CAT_FILE: do_cat_file(command); break; case Q_COPY_FILE: do_copy_file(command); break; case Q_CHMOD_FILE: do_chmod_file(command); break; diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index 024b12a60e9..221ad5d5c6e 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -1517,6 +1517,41 @@ cat_file $MYSQLTEST_VARDIR/tmp/test_file1.tmp; --error 1 --exec echo "cat_file non_existing_file;" | $MYSQL_TEST 2>&1 +# ---------------------------------------------------------------------------- +# test for diff_files +# ---------------------------------------------------------------------------- + +--write_file $MYSQLTEST_VARDIR/tmp/diff1.tmp +Some data +for diff_file command +of mysqltest +EOF + +--write_file $MYSQLTEST_VARDIR/tmp/diff2.tmp +Some data +for diff_file command +of mysqltest +EOF + +--write_file $MYSQLTEST_VARDIR/tmp/diff3.tmp +Some other data +for diff_file command +of mysqltest +EOF + +# Compare equal files +--diff_files $MYSQLTEST_VARDIR/tmp/diff1.tmp $MYSQLTEST_VARDIR/tmp/diff2.tmp +--diff_files $MYSQLTEST_VARDIR/tmp/diff2.tmp $MYSQLTEST_VARDIR/tmp/diff1.tmp + +# Compare files that differ +--error 1 +--diff_files $MYSQLTEST_VARDIR/tmp/diff3.tmp $MYSQLTEST_VARDIR/tmp/diff2.tmp +--error 1 +--diff_files $MYSQLTEST_VARDIR/tmp/diff1.tmp $MYSQLTEST_VARDIR/tmp/diff3.tmp + +# Compare equal files, again... +--diff_files $MYSQLTEST_VARDIR/tmp/diff1.tmp $MYSQLTEST_VARDIR/tmp/diff2.tmp + # ---------------------------------------------------------------------------- # test for file_exist # ---------------------------------------------------------------------------- From cbb38476e19e8c5582d7d14ce98a8889132110d4 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 21 Feb 2007 14:45:19 +0400 Subject: [PATCH 15/27] Fix for bug #26038: X() value of empty NOT NULL POINT is neither NULL nor NOT NULL Having maybe_null flag unset for geometry/spatial functions leads to wrong Item_func_isnull::val_int()'s results. Fix: set maybe_null flag and add is_null() methods. mysql-test/r/gis.result: Fix for bug #26038: X() value of empty NOT NULL POINT is neither NULL nor NOT NULL - test result. mysql-test/t/gis.test: Fix for bug #26038: X() value of empty NOT NULL POINT is neither NULL nor NOT NULL - test case. sql/item_geofunc.cc: Fix for bug #26038: X() value of empty NOT NULL POINT is neither NULL nor NOT NULL - set maybe_null flag for Item_geometry_func and Item_func_as_wkt. - moved length check to the beginnig of the Item_func_spatial_collection::val_str() to affect geometry collection objects at once. - changed Item_func_isempty::val_int() and Item_func_issimple::val_int() to properly handle null_value. sql/item_geofunc.h: Fix for bug #26038: X() value of empty NOT NULL POINT is neither NULL nor NOT NULL - set maybe_null flag for geometry/spatial functions. - added is_null() to Item_geometry_func and Item_func_spatial_rel classes. sql/spatial.cc: Fix for bug #26038: X() value of empty NOT NULL POINT is neither NULL nor NOT NULL - changed return type of Geometry::create_from_wkb() to be consistent with Geometry::create_from_wkt(), now it returns Geometry object or NULL in case of error. sql/spatial.h: Fix for bug #26038: X() value of empty NOT NULL POINT is neither NULL nor NOT NULL - changed return type of Geometry::create_from_wkb() to be consistent with Geometry::create_from_wkt(), now it returns Geometry object or NULL in case of error. --- mysql-test/r/gis.result | 44 ++++++++++++++++++++++++++++++++++++++++- mysql-test/t/gis.test | 36 ++++++++++++++++++++++++++++++++- sql/item_geofunc.cc | 29 ++++++++++++++++----------- sql/item_geofunc.h | 37 +++++++++++++++++++++++++++++----- sql/spatial.cc | 13 ++++++------ sql/spatial.h | 4 ++-- 6 files changed, 136 insertions(+), 27 deletions(-) diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result index ce2b5deadbd..de7e44ed7b2 100644 --- a/mysql-test/r/gis.result +++ b/mysql-test/r/gis.result @@ -578,7 +578,7 @@ create table t1 select POINT(1,3); show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `POINT(1,3)` longblob NOT NULL + `POINT(1,3)` longblob ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; CREATE TABLE `t1` (`object_id` bigint(20) unsigned NOT NULL default '0', `geo` @@ -677,3 +677,45 @@ load data infile '../../std_data/bad_gis_data.dat' into table t1; ERROR 01000: Data truncated; NULL supplied to NOT NULL column 'b' at row 1 alter table t1 enable keys; drop table t1; +create table t1 (a int, b blob); +insert into t1 values (1, ''), (2, NULL), (3, '1'); +select * from t1; +a b +1 +2 NULL +3 1 +select +geometryfromtext(b) IS NULL, geometryfromwkb(b) IS NULL, astext(b) IS NULL, +aswkb(b) IS NULL, geometrytype(b) IS NULL, centroid(b) IS NULL, +envelope(b) IS NULL, startpoint(b) IS NULL, endpoint(b) IS NULL, +exteriorring(b) IS NULL, pointn(b, 1) IS NULL, geometryn(b, 1) IS NULL, +interiorringn(b, 1) IS NULL, multipoint(b) IS NULL, isempty(b) IS NULL, +issimple(b) IS NULL, isclosed(b) IS NULL, dimension(b) IS NULL, +numgeometries(b) IS NULL, numinteriorrings(b) IS NULL, numpoints(b) IS NULL, +area(b) IS NULL, glength(b) IS NULL, srid(b) IS NULL, x(b) IS NULL, +y(b) IS NULL +from t1; +geometryfromtext(b) IS NULL geometryfromwkb(b) IS NULL astext(b) IS NULL aswkb(b) IS NULL geometrytype(b) IS NULL centroid(b) IS NULL envelope(b) IS NULL startpoint(b) IS NULL endpoint(b) IS NULL exteriorring(b) IS NULL pointn(b, 1) IS NULL geometryn(b, 1) IS NULL interiorringn(b, 1) IS NULL multipoint(b) IS NULL isempty(b) IS NULL issimple(b) IS NULL isclosed(b) IS NULL dimension(b) IS NULL numgeometries(b) IS NULL numinteriorrings(b) IS NULL numpoints(b) IS NULL area(b) IS NULL glength(b) IS NULL srid(b) IS NULL x(b) IS NULL y(b) IS NULL +1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 +select +within(b, b) IS NULL, contains(b, b) IS NULL, overlaps(b, b) IS NULL, +equals(b, b) IS NULL, disjoint(b, b) IS NULL, touches(b, b) IS NULL, +intersects(b, b) IS NULL, crosses(b, b) IS NULL +from t1; +within(b, b) IS NULL contains(b, b) IS NULL overlaps(b, b) IS NULL equals(b, b) IS NULL disjoint(b, b) IS NULL touches(b, b) IS NULL intersects(b, b) IS NULL crosses(b, b) IS NULL +1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 +select +point(b, b) IS NULL, linestring(b) IS NULL, polygon(b) IS NULL, multipoint(b) IS NULL, +multilinestring(b) IS NULL, multipolygon(b) IS NULL, +geometrycollection(b) IS NULL +from t1; +point(b, b) IS NULL linestring(b) IS NULL polygon(b) IS NULL multipoint(b) IS NULL multilinestring(b) IS NULL multipolygon(b) IS NULL geometrycollection(b) IS NULL +0 1 1 1 1 1 1 +1 1 1 1 1 1 1 +0 1 1 1 1 1 1 +drop table t1; +End of 4.1 tests diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test index 1ae4f0ae62f..6bd0db92152 100644 --- a/mysql-test/t/gis.test +++ b/mysql-test/t/gis.test @@ -377,4 +377,38 @@ load data infile '../../std_data/bad_gis_data.dat' into table t1; alter table t1 enable keys; drop table t1; -# End of 4.1 tests +# +# Bug #26038: is null and bad data +# + +create table t1 (a int, b blob); +insert into t1 values (1, ''), (2, NULL), (3, '1'); +select * from t1; + +select + geometryfromtext(b) IS NULL, geometryfromwkb(b) IS NULL, astext(b) IS NULL, + aswkb(b) IS NULL, geometrytype(b) IS NULL, centroid(b) IS NULL, + envelope(b) IS NULL, startpoint(b) IS NULL, endpoint(b) IS NULL, + exteriorring(b) IS NULL, pointn(b, 1) IS NULL, geometryn(b, 1) IS NULL, + interiorringn(b, 1) IS NULL, multipoint(b) IS NULL, isempty(b) IS NULL, + issimple(b) IS NULL, isclosed(b) IS NULL, dimension(b) IS NULL, + numgeometries(b) IS NULL, numinteriorrings(b) IS NULL, numpoints(b) IS NULL, + area(b) IS NULL, glength(b) IS NULL, srid(b) IS NULL, x(b) IS NULL, + y(b) IS NULL +from t1; + +select + within(b, b) IS NULL, contains(b, b) IS NULL, overlaps(b, b) IS NULL, + equals(b, b) IS NULL, disjoint(b, b) IS NULL, touches(b, b) IS NULL, + intersects(b, b) IS NULL, crosses(b, b) IS NULL +from t1; + +select + point(b, b) IS NULL, linestring(b) IS NULL, polygon(b) IS NULL, multipoint(b) IS NULL, + multilinestring(b) IS NULL, multipolygon(b) IS NULL, + geometrycollection(b) IS NULL +from t1; + +drop table t1; + +--echo End of 4.1 tests diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc index 6bd2e65632f..6cb8c790319 100644 --- a/sql/item_geofunc.cc +++ b/sql/item_geofunc.cc @@ -30,6 +30,7 @@ void Item_geometry_func::fix_length_and_dec() collation.set(&my_charset_bin); decimals=0; max_length=MAX_BLOB_WIDTH; + maybe_null= 1; } @@ -109,6 +110,7 @@ String *Item_func_as_wkt::val_str(String *str) void Item_func_as_wkt::fix_length_and_dec() { max_length=MAX_BLOB_WIDTH; + maybe_null= 1; } @@ -356,7 +358,8 @@ String *Item_func_spatial_collection::val_str(String *str) for (i= 0; i < arg_count; ++i) { String *res= args[i]->val_str(&arg_value); - if (args[i]->null_value) + uint32 len; + if (args[i]->null_value || ((len= res->length()) < WKB_HEADER_SIZE)) goto err; if (coll_type == Geometry::wkb_geometrycollection) @@ -365,13 +368,12 @@ String *Item_func_spatial_collection::val_str(String *str) In the case of GeometryCollection we don't need any checkings for item types, so just copy them into target collection */ - if (str->append(res->ptr(), res->length(), (uint32) 512)) + if (str->append(res->ptr(), len, (uint32) 512)) goto err; } else { enum Geometry::wkbType wkb_type; - uint32 len=res->length(); const char *data= res->ptr() + 1; /* @@ -379,8 +381,6 @@ String *Item_func_spatial_collection::val_str(String *str) are of specific type, let's do this checking now */ - if (len < 5) - goto err; wkb_type= (Geometry::wkbType) uint4korr(data); data+= 4; len-= 5; @@ -502,9 +502,13 @@ longlong Item_func_spatial_rel::val_int() longlong Item_func_isempty::val_int() { DBUG_ASSERT(fixed == 1); - String tmp; - null_value=0; - return args[0]->null_value ? 1 : 0; + String tmp; + String *swkb= args[0]->val_str(&tmp); + Geometry_buffer buffer; + + null_value= args[0]->null_value || + !(Geometry::construct(&buffer, swkb->ptr(), swkb->length())); + return null_value ? 1 : 0; } @@ -512,10 +516,11 @@ longlong Item_func_issimple::val_int() { DBUG_ASSERT(fixed == 1); String tmp; - String *wkb=args[0]->val_str(&tmp); - - if ((null_value= (!wkb || args[0]->null_value))) - return 0; + String *swkb= args[0]->val_str(&tmp); + Geometry_buffer buffer; + + null_value= args[0]->null_value || + !(Geometry::construct(&buffer, swkb->ptr(), swkb->length())); /* TODO: Ramil or Holyfoot, add real IsSimple calculation */ return 0; } diff --git a/sql/item_geofunc.h b/sql/item_geofunc.h index a466b606dc1..2719cbb0bab 100644 --- a/sql/item_geofunc.h +++ b/sql/item_geofunc.h @@ -33,6 +33,7 @@ public: Item_geometry_func(List &list) :Item_str_func(list) {} void fix_length_and_dec(); enum_field_types field_type() const { return MYSQL_TYPE_GEOMETRY; } + bool is_null() { (void) val_int(); return null_value; } }; class Item_func_geometry_from_text: public Item_geometry_func @@ -80,6 +81,7 @@ public: void fix_length_and_dec() { max_length=20; // "GeometryCollection" is the most long + maybe_null= 1; }; }; @@ -221,6 +223,8 @@ public: } } void print(String *str) { Item_func::print(str); } + void fix_length_and_dec() { maybe_null= 1; } + bool is_null() { (void) val_int(); return null_value; } }; class Item_func_isempty: public Item_bool_func @@ -230,6 +234,7 @@ public: longlong val_int(); optimize_type select_optimize() const { return OPTIMIZE_NONE; } const char *func_name() const { return "isempty"; } + void fix_length_and_dec() { maybe_null= 1; } }; class Item_func_issimple: public Item_bool_func @@ -239,6 +244,7 @@ public: longlong val_int(); optimize_type select_optimize() const { return OPTIMIZE_NONE; } const char *func_name() const { return "issimple"; } + void fix_length_and_dec() { maybe_null= 1; } }; class Item_func_isclosed: public Item_bool_func @@ -248,6 +254,7 @@ public: longlong val_int(); optimize_type select_optimize() const { return OPTIMIZE_NONE; } const char *func_name() const { return "isclosed"; } + void fix_length_and_dec() { maybe_null= 1; } }; class Item_func_dimension: public Item_int_func @@ -257,7 +264,7 @@ public: Item_func_dimension(Item *a): Item_int_func(a) {} longlong val_int(); const char *func_name() const { return "dimension"; } - void fix_length_and_dec() { max_length=10; } + void fix_length_and_dec() { max_length= 10; maybe_null= 1; } }; class Item_func_x: public Item_real_func @@ -267,6 +274,11 @@ public: Item_func_x(Item *a): Item_real_func(a) {} double val(); const char *func_name() const { return "x"; } + void fix_length_and_dec() + { + Item_real_func::fix_length_and_dec(); + maybe_null= 1; + } }; @@ -277,6 +289,11 @@ public: Item_func_y(Item *a): Item_real_func(a) {} double val(); const char *func_name() const { return "y"; } + void fix_length_and_dec() + { + Item_real_func::fix_length_and_dec(); + maybe_null= 1; + } }; @@ -287,7 +304,7 @@ public: Item_func_numgeometries(Item *a): Item_int_func(a) {} longlong val_int(); const char *func_name() const { return "numgeometries"; } - void fix_length_and_dec() { max_length=10; } + void fix_length_and_dec() { max_length= 10; maybe_null= 1; } }; @@ -298,7 +315,7 @@ public: Item_func_numinteriorring(Item *a): Item_int_func(a) {} longlong val_int(); const char *func_name() const { return "numinteriorrings"; } - void fix_length_and_dec() { max_length=10; } + void fix_length_and_dec() { max_length= 10; maybe_null= 1; } }; @@ -309,7 +326,7 @@ public: Item_func_numpoints(Item *a): Item_int_func(a) {} longlong val_int(); const char *func_name() const { return "numpoints"; } - void fix_length_and_dec() { max_length=10; } + void fix_length_and_dec() { max_length= 10; maybe_null= 1; } }; @@ -320,6 +337,11 @@ public: Item_func_area(Item *a): Item_real_func(a) {} double val(); const char *func_name() const { return "area"; } + void fix_length_and_dec() + { + Item_real_func::fix_length_and_dec(); + maybe_null= 1; + } }; @@ -330,6 +352,11 @@ public: Item_func_glength(Item *a): Item_real_func(a) {} double val(); const char *func_name() const { return "glength"; } + void fix_length_and_dec() + { + Item_real_func::fix_length_and_dec(); + maybe_null= 1; + } }; @@ -340,7 +367,7 @@ public: Item_func_srid(Item *a): Item_int_func(a) {} longlong val_int(); const char *func_name() const { return "srid"; } - void fix_length_and_dec() { max_length= 10; } + void fix_length_and_dec() { max_length= 10; maybe_null= 1; } }; #define GEOM_NEW(obj_constructor) new obj_constructor diff --git a/sql/spatial.cc b/sql/spatial.cc index 684f7e9ecf3..4e17e766090 100644 --- a/sql/spatial.cc +++ b/sql/spatial.cc @@ -210,23 +210,24 @@ static uint32 wkb_get_uint(const char *ptr, Geometry::wkbByteOrder bo) } -int Geometry::create_from_wkb(Geometry_buffer *buffer, - const char *wkb, uint32 len, String *res) +Geometry *Geometry::create_from_wkb(Geometry_buffer *buffer, + const char *wkb, uint32 len, String *res) { uint32 geom_type; Geometry *geom; if (len < WKB_HEADER_SIZE) - return 1; + return NULL; geom_type= wkb_get_uint(wkb+1, (wkbByteOrder)wkb[0]); if (!(geom= create_by_typeid(buffer, (int) geom_type)) || res->reserve(WKB_HEADER_SIZE, 512)) - return 1; + return NULL; res->q_append((char) wkb_ndr); res->q_append(geom_type); - return geom->init_from_wkb(wkb+WKB_HEADER_SIZE, len - WKB_HEADER_SIZE, - (wkbByteOrder) wkb[0], res); + + return geom->init_from_wkb(wkb + WKB_HEADER_SIZE, len - WKB_HEADER_SIZE, + (wkbByteOrder) wkb[0], res) ? geom : NULL; } diff --git a/sql/spatial.h b/sql/spatial.h index 378233a2156..553544d4c3f 100644 --- a/sql/spatial.h +++ b/sql/spatial.h @@ -244,8 +244,8 @@ public: static Geometry *create_from_wkt(Geometry_buffer *buffer, Gis_read_stream *trs, String *wkt, bool init_stream=1); - static int create_from_wkb(Geometry_buffer *buffer, - const char *wkb, uint32 len, String *res); + static Geometry *create_from_wkb(Geometry_buffer *buffer, const char *wkb, + uint32 len, String *res); int as_wkt(String *wkt, const char **end) { uint32 len= get_class_info()->m_name.length; From e7d8bde1da73339e333a4ae5894b121729a865a8 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 26 Feb 2007 14:52:51 +0100 Subject: [PATCH 16/27] Only allow a version number to be read from "/etc/debian_version" --- mysql-test/mysql-test-run.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index fc0ad54c095..ed26204d7cb 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1626,7 +1626,7 @@ sub environment_setup () { my $deb_version; if ( $opt_valgrind and -d $debug_libraries_path and (! -e '/etc/debian_version' or - ($deb_version= mtr_grab_file('/etc/debian_version')) == 0 or + ($deb_version= mtr_grab_file('/etc/debian_version')) !~ /^[0-9]+\.[0-9]$/ or $deb_version > 3.1 ) ) { push(@ld_library_paths, $debug_libraries_path); From d59d5f18c43e3165a1cdb56870702e7202a0a2b0 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 28 Feb 2007 09:10:38 +0100 Subject: [PATCH 17/27] Bug#19410 Test 'kill' fails on Windows + SCO - Use "mysql_stmt_field_count" to determine if there is a need to call "mysql_stmt_store_result" client/mysqltest.c: Only call 'mysql_stmt_store_result' if 'mysql_stmt_field_count' is greater than 0 indicating that this query has a result set. This change is mainly since if mysql_stmt_store_result fails the value returned by mysql_stmt_field_count will be reset. --- client/mysqltest.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 99462d82f40..4a89299e836 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -5048,8 +5048,9 @@ void run_query_stmt(MYSQL *mysql, struct st_command *command, /* If we got here the statement succeeded and was expected to do so, get data. Note that this can still give errors found during execution! + Store the result of the query if if will return any fields */ - if (mysql_stmt_store_result(stmt)) + if (mysql_stmt_field_count(stmt) && mysql_stmt_store_result(stmt)) { handle_error(command, mysql_stmt_errno(stmt), mysql_stmt_error(stmt), mysql_stmt_sqlstate(stmt), ds); From 8c5a862569a75c175882544fff1de45be07e076b Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 28 Feb 2007 10:05:51 +0100 Subject: [PATCH 18/27] Use cygwin for --exec and --system in mysqltest for MySQL before 5.0 --- client/mysqltest.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/client/mysqltest.c b/client/mysqltest.c index 055577fc535..0300afd980c 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -61,6 +61,11 @@ # endif #endif +/* Use cygwin for --exec and --system before 5.0 */ +#if MYSQL_VERSION_ID < 50000 +#define USE_CYGWIN +#endif + #define MAX_VAR_NAME_LENGTH 256 #define MAX_COLUMNS 256 #define MAX_EMBEDDED_SERVER_ARGS 64 From e40bcac08ed55c122b05bdbd04c273a665bea3b2 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 28 Feb 2007 10:37:32 +0100 Subject: [PATCH 19/27] Bug#26686 mysql-test-run.pl aborts when waitpid returns -1 - Add error handling for waitpid returns -1 for "simple run of command" mysql-test/lib/mtr_process.pl: - Add error handling for waitpid returns -1 when a simple command is run. - Add missing return - Add mtr_errors where the program should never come - Remove an else to improve program readability - Change mtr_debug to mtr_warning for "Got EAGAIN from fork()..." --- mysql-test/lib/mtr_process.pl | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl index 9cf013d4e9d..20dca4b6980 100644 --- a/mysql-test/lib/mtr_process.pl +++ b/mysql-test/lib/mtr_process.pl @@ -125,19 +125,18 @@ sub spawn_impl ($$$$$$$$) { { if ( $! == $!{EAGAIN} ) # See "perldoc Errno" { - mtr_debug("Got EAGAIN from fork(), sleep 1 second and redo"); + mtr_warning("Got EAGAIN from fork(), sleep 1 second and redo"); sleep(1); redo FORK; } - else - { - mtr_error("$path ($pid) can't be forked"); - } + + mtr_error("$path ($pid) can't be forked, error: $!"); + } if ( $pid ) { - spawn_parent_impl($pid,$mode,$path); + return spawn_parent_impl($pid,$mode,$path); } else { @@ -202,8 +201,11 @@ sub spawn_impl ($$$$$$$$) { { mtr_child_error("failed to execute \"$path\": $!"); } + mtr_error("Should never come here 1!"); } + mtr_error("Should never come here 2!"); } + mtr_error("Should never come here 3!"); } @@ -216,12 +218,21 @@ sub spawn_parent_impl { { if ( $mode eq 'run' ) { - # Simple run of command, we wait for it to return + # Simple run of command, wait blocking for it to return my $ret_pid= waitpid($pid,0); if ( $ret_pid != $pid ) { - mtr_error("waitpid($pid, 0) returned $ret_pid " . - "when waiting for '$path'"); + # The "simple" waitpid has failed, print debug info + # and try to handle the error + mtr_warning("waitpid($pid, 0) returned $ret_pid " . + "when waiting for '$path', error: '$!'"); + if ( $ret_pid == -1 ) + { + # waitpid returned -1, that would indicate the process + # no longer exist and waitpid couldn't wait for it. + return 1; + } + mtr_error("Error handling failed"); } return mtr_process_exit_status($?); From 4d49015bf9dafab0f08adada3a9011b6aeecf31c Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 28 Feb 2007 10:52:51 +0100 Subject: [PATCH 20/27] Bug#26416 mysql-test-run exits with "Hangup" when piped to grep - Thanks to Christian for the patch! mysql-test/lib/mtr_process.pl: Avoid printout of "Hangup" when script exits by using POSIX::kill --- mysql-test/lib/mtr_process.pl | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl index 20dca4b6980..e9e0dcce1b8 100644 --- a/mysql-test/lib/mtr_process.pl +++ b/mysql-test/lib/mtr_process.pl @@ -8,7 +8,7 @@ use Socket; use Errno; use strict; -use POSIX 'WNOHANG'; +use POSIX qw(WNOHANG SIGHUP); sub mtr_run ($$$$$$;$); sub mtr_spawn ($$$$$$;$); @@ -1100,12 +1100,6 @@ sub mtr_kill_processes ($) { # ############################################################################## -# FIXME something is wrong, we sometimes terminate with "Hangup" written -# to tty, and no STDERR output telling us why. - -# FIXME for some reason, setting HUP to 'IGNORE' will cause exit() to -# write out "Hangup", and maybe loose some output. We insert a sleep... - sub mtr_exit ($) { my $code= shift; mtr_timer_stop_all($::glob_timers); @@ -1117,7 +1111,7 @@ sub mtr_exit ($) { # set ourselves as the group leader at startup (with # POSIX::setpgrp(0,0)), but then care must be needed to always do # proper child process cleanup. - kill('HUP', -$$) if !$::glob_win32_perl and $$ == getpgrp(); + POSIX::kill(SIGHUP, -$$) if !$::glob_win32_perl and $$ == getpgrp(); exit($code); } From 7624028419147d656646c95b2bc11ea72aa3e419 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 28 Feb 2007 13:47:41 +0100 Subject: [PATCH 21/27] When using a --mem= the memdir must be removed to assure afresh start --- mysql-test/mysql-test-run.pl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index ed26204d7cb..21960d2bfcd 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -2025,6 +2025,16 @@ sub remove_stale_vardir () { mtr_verbose("Removing $opt_vardir/"); rmtree("$opt_vardir/"); } + + if ( $opt_mem ) + { + # A symlink from var/ to $opt_mem will be set up + # remove the $opt_mem dir to assure the symlink + # won't point at an old directory + mtr_verbose("Removing $opt_mem"); + rmtree($opt_mem); + } + } else { From 22cac737ca87dc9f2e58069f21066c88d57a3e2c Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 28 Feb 2007 15:03:47 +0100 Subject: [PATCH 22/27] Bug#20166 mysql-test-run.pl does not test system privilege tables creation - Build lib/init-db.sql from the output of mysql_create_system_tables - Remove mysql-test/init_db.sql and mysql-test/lib/init_db.sql - Leave netware/init_db.sql until 5.0 where we should soon have possibility to test with mysql-test-run.pl BitKeeper/deleted/.del-init_db.sql: Delete: mysql-test/init_db.sql BitKeeper/deleted/.del-init_db.sql~a77d572c39d5a1f8: Delete: mysql-test/lib/init_db.sql BitKeeper/etc/ignore: Added mysql-test/lib/init_db.sql to the ignore list mysql-test/Makefile.am: Build lib/init_db.sql from the output of mysql_create_system_tables --- .bzrignore | 1 + mysql-test/Makefile.am | 7 +- mysql-test/init_db.sql | 58 ----- mysql-test/lib/init_db.sql | 471 ------------------------------------- 4 files changed, 7 insertions(+), 530 deletions(-) delete mode 100644 mysql-test/init_db.sql delete mode 100644 mysql-test/lib/init_db.sql diff --git a/.bzrignore b/.bzrignore index 348093af390..0c666cc3ae0 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1067,3 +1067,4 @@ vio/viotest-ssl include/check_abi include/mysql_h.ic mysql-test/r/blackhole.log +mysql-test/lib/init_db.sql diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am index 5b0a8afe98e..02a1a801d36 100644 --- a/mysql-test/Makefile.am +++ b/mysql-test/Makefile.am @@ -35,7 +35,7 @@ testdir = $(benchdir_root)/mysql-test EXTRA_SCRIPTS = mysql-test-run-shell.sh install_test_db.sh \ valgrind.supp $(PRESCRIPTS) EXTRA_DIST = $(EXTRA_SCRIPTS) -GENSCRIPTS = mysql-test-run-shell mysql-test-run install_test_db mtr +GENSCRIPTS = mysql-test-run-shell mysql-test-run install_test_db mtr lib/init_db.sql PRESCRIPTS = mysql-test-run.pl test_SCRIPTS = $(GENSCRIPTS) $(PRESCRIPTS) test_DATA = std_data/client-key.pem \ @@ -119,6 +119,11 @@ mysql-test-run: $(RM) -f mysql-test-run $(LN_S) mysql-test-run.pl mysql-test-run +# Build init_db.sql by executing mysql_create_system_tables +lib/init_db.sql: + $(top_builddir)/scripts/mysql_create_system_tables \ + test . \@HOSTNAME\@ > lib/init_db.sql + SUFFIXES = .sh .sh: diff --git a/mysql-test/init_db.sql b/mysql-test/init_db.sql deleted file mode 100644 index 63483af00d6..00000000000 --- a/mysql-test/init_db.sql +++ /dev/null @@ -1,58 +0,0 @@ -CREATE DATABASE mysql; -CREATE DATABASE test; - -USE mysql; - - -CREATE TABLE db (Host char(60) binary DEFAULT '' NOT NULL,Db char(64) binary DEFAULT '' NOT NULL,User char(16) binary DEFAULT '' NOT NULL,Select_priv enum('N','Y') DEFAULT 'N' NOT NULL,Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL,Update_priv enum('N','Y') DEFAULT 'N' NOT NULL,Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL,Create_priv enum('N','Y') DEFAULT 'N' NOT NULL,Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL,Grant_priv enum('N','Y') DEFAULT 'N' NOT NULL,References_priv enum('N','Y') DEFAULT 'N' NOT NULL,Index_priv enum('N','Y') DEFAULT 'N' NOT NULL,Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL,Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL,PRIMARY KEY Host (Host,Db,User),KEY User (User)) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Database privileges'; - -INSERT INTO db VALUES ('%','test','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y'); -INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y'); - - -CREATE TABLE host (Host char(60) binary DEFAULT '' NOT NULL,Db char(64) binary DEFAULT '' NOT NULL,Select_priv enum('N','Y') DEFAULT 'N' NOT NULL,Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL,Update_priv enum('N','Y') DEFAULT 'N' NOT NULL,Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL,Create_priv enum('N','Y') DEFAULT 'N' NOT NULL,Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL,Grant_priv enum('N','Y') DEFAULT 'N' NOT NULL,References_priv enum('N','Y') DEFAULT 'N' NOT NULL,Index_priv enum('N','Y') DEFAULT 'N' NOT NULL,Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL,Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL,PRIMARY KEY Host (Host,Db)) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Host privileges; Merged with database privileges'; - -CREATE TABLE user (Host char(60) binary DEFAULT '' NOT NULL,User char(16) binary DEFAULT '' NOT NULL,Password char(41) binary DEFAULT '' NOT NULL,Select_priv enum('N','Y') DEFAULT 'N' NOT NULL,Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL,Update_priv enum('N','Y') DEFAULT 'N' NOT NULL,Delete_priv enum('N','Y') DEFAULT 'N' NOT NULL,Create_priv enum('N','Y') DEFAULT 'N' NOT NULL,Drop_priv enum('N','Y') DEFAULT 'N' NOT NULL,Reload_priv enum('N','Y') DEFAULT 'N' NOT NULL,Shutdown_priv enum('N','Y') DEFAULT 'N' NOT NULL,Process_priv enum('N','Y') DEFAULT 'N' NOT NULL,File_priv enum('N','Y') DEFAULT 'N' NOT NULL,Grant_priv enum('N','Y') DEFAULT 'N' NOT NULL,References_priv enum('N','Y') DEFAULT 'N' NOT NULL,Index_priv enum('N','Y') DEFAULT 'N' NOT NULL,Alter_priv enum('N','Y') DEFAULT 'N' NOT NULL,Show_db_priv enum('N','Y') DEFAULT 'N' NOT NULL,Super_priv enum('N','Y') DEFAULT 'N' NOT NULL,Create_tmp_table_priv enum('N','Y') DEFAULT 'N' NOT NULL,Lock_tables_priv enum('N','Y') DEFAULT 'N' NOT NULL,Execute_priv enum('N','Y') DEFAULT 'N' NOT NULL,Repl_slave_priv enum('N','Y') DEFAULT 'N' NOT NULL,Repl_client_priv enum('N','Y') DEFAULT 'N' NOT NULL,ssl_type enum('','ANY','X509', 'SPECIFIED') DEFAULT '' NOT NULL,ssl_cipher BLOB NOT NULL,x509_issuer BLOB NOT NULL,x509_subject BLOB NOT NULL,max_questions int(11) unsigned DEFAULT 0 NOT NULL,max_updates int(11) unsigned DEFAULT 0 NOT NULL,max_connections int(11) unsigned DEFAULT 0 NOT NULL,PRIMARY KEY Host (Host,User)) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Users and global privileges'; - -INSERT INTO user VALUES ('%','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0); -INSERT INTO user VALUES ('localhost','','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0); -INSERT INTO user VALUES ('%','','','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','','','','',0,0,0); - -CREATE TABLE func (name char(64) binary DEFAULT '' NOT NULL,ret tinyint(1) DEFAULT '0' NOT NULL,dl char(128) DEFAULT '' NOT NULL,type enum ('function','aggregate') NOT NULL,PRIMARY KEY (name)) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='User defined functions'; - -CREATE TABLE tables_priv (Host char(60) binary DEFAULT '' NOT NULL,Db char(64) binary DEFAULT '' NOT NULL,User char(16) binary DEFAULT '' NOT NULL,Table_name char(64) binary DEFAULT '' NOT NULL,Grantor char(77) DEFAULT '' NOT NULL,Timestamp timestamp(14),Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') DEFAULT '' NOT NULL,Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL,PRIMARY KEY (Host,Db,User,Table_name),KEY Grantor (Grantor)) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges'; - -CREATE TABLE columns_priv (Host char(60) binary DEFAULT '' NOT NULL,Db char(64) binary DEFAULT '' NOT NULL,User char(16) binary DEFAULT '' NOT NULL,Table_name char(64) binary DEFAULT '' NOT NULL,Column_name char(64) binary DEFAULT '' NOT NULL,Timestamp timestamp(14),Column_priv set('Select','Insert','Update','References') DEFAULT '' NOT NULL,PRIMARY KEY (Host,Db,User,Table_name,Column_name)) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Column privileges'; - -CREATE TABLE help_topic (help_topic_id int unsigned not null,name varchar(64) not null,help_category_id smallint unsigned not null,description text not null,example text not null,url varchar(128) not null,primary key (help_topic_id),unique index (name)) engine=MyISAM CHARACTER SET utf8 comment='help topics'; - -CREATE TABLE help_category (help_category_id smallint unsigned not null,name varchar(64) not null,parent_category_id smallint unsigned null,url varchar(128) not null,primary key (help_category_id),unique index (name)) engine=MyISAM CHARACTER SET utf8 comment='help categories'; - -CREATE TABLE help_keyword (help_keyword_id int unsigned not null,name varchar(64) not null,primary key (help_keyword_id),unique index (name)) engine=MyISAM CHARACTER SET utf8 comment='help keywords'; - -CREATE TABLE help_relation (help_topic_id int unsigned not null references help_topic,help_keyword_id int unsigned not null references help_keyword,primary key (help_keyword_id, help_topic_id)) engine=MyISAM CHARACTER SET utf8 comment='keyword-topic relation'; - -CREATE TABLE time_zone_name (Name char(64) NOT NULL,Time_zone_id int unsigned NOT NULL,PRIMARY KEY Name (Name)) engine=MyISAM CHARACTER SET utf8 comment='Time zone names'; - -INSERT INTO time_zone_name (Name, Time_Zone_id) VALUES ('MET', 1), ('UTC', 2), ('Universal', 2), ('Europe/Moscow',3), ('leap/Europe/Moscow',4), ('Japan', 5); - - -CREATE TABLE time_zone (Time_zone_id int unsigned NOT NULL auto_increment,Use_leap_seconds enum('Y','N') DEFAULT 'N' NOT NULL,PRIMARY KEY TzId (Time_zone_id)) engine=MyISAM CHARACTER SET utf8 comment='Time zones'; - -INSERT INTO time_zone (Time_zone_id, Use_leap_seconds) VALUES (1,'N'), (2,'N'), (3,'N'), (4,'Y'), (5,'N'); - - -CREATE TABLE time_zone_transition (Time_zone_id int unsigned NOT NULL,Transition_time bigint signed NOT NULL,Transition_type_id int unsigned NOT NULL,PRIMARY KEY TzIdTranTime (Time_zone_id, Transition_time)) engine=MyISAM CHARACTER SET utf8 comment='Time zone transitions'; - -INSERT INTO time_zone_transition (Time_zone_id, Transition_time, Transition_type_id) VALUES (1, -1693706400, 0) ,(1, -1680483600, 1),(1, -1663455600, 2) ,(1, -1650150000, 3),(1, -1632006000, 2) ,(1, -1618700400, 3),(1, -938905200, 2) ,(1, -857257200, 3),(1, -844556400, 2) ,(1, -828226800, 3),(1, -812502000, 2) ,(1, -796777200, 3),(1, 228877200, 2) ,(1, 243997200, 3),(1, 260326800, 2) ,(1, 276051600, 3),(1, 291776400, 2) ,(1, 307501200, 3),(1, 323830800, 2) ,(1, 338950800, 3),(1, 354675600, 2) ,(1, 370400400, 3),(1, 386125200, 2) ,(1, 401850000, 3),(1, 417574800, 2) ,(1, 433299600, 3),(1, 449024400, 2) ,(1, 465354000, 3),(1, 481078800, 2) ,(1, 496803600, 3),(1, 512528400, 2) ,(1, 528253200, 3),(1, 543978000, 2) ,(1, 559702800, 3),(1, 575427600, 2) ,(1, 591152400, 3),(1, 606877200, 2) ,(1, 622602000, 3),(1, 638326800, 2) ,(1, 654656400, 3),(1, 670381200, 2) ,(1, 686106000, 3),(1, 701830800, 2) ,(1, 717555600, 3),(1, 733280400, 2) ,(1, 749005200, 3),(1, 764730000, 2) ,(1, 780454800, 3),(1, 796179600, 2) ,(1, 811904400, 3),(1, 828234000, 2) ,(1, 846378000, 3),(1, 859683600, 2) ,(1, 877827600, 3),(1, 891133200, 2) ,(1, 909277200, 3),(1, 922582800, 2) ,(1, 941331600, 3),(1, 954032400, 2) ,(1, 972781200, 3),(1, 985482000, 2) ,(1, 1004230800, 3),(1, 1017536400, 2) ,(1, 1035680400, 3),(1, 1048986000, 2) ,(1, 1067130000, 3),(1, 1080435600, 2) ,(1, 1099184400, 3),(1, 1111885200, 2) ,(1, 1130634000, 3),(1, 1143334800, 2) ,(1, 1162083600, 3),(1, 1174784400, 2) ,(1, 1193533200, 3),(1, 1206838800, 2) ,(1, 1224982800, 3),(1, 1238288400, 2) ,(1, 1256432400, 3),(1, 1269738000, 2) ,(1, 1288486800, 3),(1, 1301187600, 2) ,(1, 1319936400, 3),(1, 1332637200, 2) ,(1, 1351386000, 3),(1, 1364691600, 2) ,(1, 1382835600, 3),(1, 1396141200, 2) ,(1, 1414285200, 3),(1, 1427590800, 2) ,(1, 1445734800, 3),(1, 1459040400, 2) ,(1, 1477789200, 3),(1, 1490490000, 2) ,(1, 1509238800, 3),(1, 1521939600, 2) ,(1, 1540688400, 3),(1, 1553994000, 2) ,(1, 1572138000, 3),(1, 1585443600, 2) ,(1, 1603587600, 3),(1, 1616893200, 2) ,(1, 1635642000, 3),(1, 1648342800, 2) ,(1, 1667091600, 3),(1, 1679792400, 2) ,(1, 1698541200, 3),(1, 1711846800, 2) ,(1, 1729990800, 3),(1, 1743296400, 2) ,(1, 1761440400, 3),(1, 1774746000, 2) ,(1, 1792890000, 3),(1, 1806195600, 2) ,(1, 1824944400, 3),(1, 1837645200, 2) ,(1, 1856394000, 3),(1, 1869094800, 2) ,(1, 1887843600, 3),(1, 1901149200, 2) ,(1, 1919293200, 3),(1, 1932598800, 2) ,(1, 1950742800, 3),(1, 1964048400, 2) ,(1, 1982797200, 3),(1, 1995498000, 2) ,(1, 2014246800, 3),(1, 2026947600, 2) ,(1, 2045696400, 3),(1, 2058397200, 2) ,(1, 2077146000, 3),(1, 2090451600, 2) ,(1, 2108595600, 3),(1, 2121901200, 2) ,(1, 2140045200, 3),(3, -1688265000, 2) ,(3, -1656819048, 1),(3, -1641353448, 2) ,(3, -1627965048, 3),(3, -1618716648, 1) ,(3, -1596429048, 3),(3, -1593829848, 5) ,(3, -1589860800, 4),(3, -1542427200, 5) ,(3, -1539493200, 6),(3, -1525323600, 5) ,(3, -1522728000, 4),(3, -1491188400, 7) ,(3, -1247536800, 4),(3, 354920400, 5) ,(3, 370728000, 4),(3, 386456400, 5) ,(3, 402264000, 4),(3, 417992400, 5) ,(3, 433800000, 4),(3, 449614800, 5) ,(3, 465346800, 8),(3, 481071600, 9) ,(3, 496796400, 8),(3, 512521200, 9) ,(3, 528246000, 8),(3, 543970800, 9) ,(3, 559695600, 8),(3, 575420400, 9) ,(3, 591145200, 8),(3, 606870000, 9) ,(3, 622594800, 8),(3, 638319600, 9) ,(3, 654649200, 8),(3, 670374000, 10) ,(3, 686102400, 11),(3, 695779200, 8) ,(3, 701812800, 5),(3, 717534000, 4) ,(3, 733273200, 9),(3, 748998000, 8) ,(3, 764722800, 9),(3, 780447600, 8) ,(3, 796172400, 9),(3, 811897200, 8) ,(3, 828226800, 9),(3, 846370800, 8) ,(3, 859676400, 9),(3, 877820400, 8) ,(3, 891126000, 9),(3, 909270000, 8) ,(3, 922575600, 9),(3, 941324400, 8) ,(3, 954025200, 9),(3, 972774000, 8) ,(3, 985474800, 9),(3, 1004223600, 8) ,(3, 1017529200, 9),(3, 1035673200, 8) ,(3, 1048978800, 9),(3, 1067122800, 8) ,(3, 1080428400, 9),(3, 1099177200, 8) ,(3, 1111878000, 9),(3, 1130626800, 8) ,(3, 1143327600, 9),(3, 1162076400, 8) ,(3, 1174777200, 9),(3, 1193526000, 8) ,(3, 1206831600, 9),(3, 1224975600, 8) ,(3, 1238281200, 9),(3, 1256425200, 8) ,(3, 1269730800, 9),(3, 1288479600, 8) ,(3, 1301180400, 9),(3, 1319929200, 8) ,(3, 1332630000, 9),(3, 1351378800, 8) ,(3, 1364684400, 9),(3, 1382828400, 8) ,(3, 1396134000, 9),(3, 1414278000, 8) ,(3, 1427583600, 9),(3, 1445727600, 8) ,(3, 1459033200, 9),(3, 1477782000, 8) ,(3, 1490482800, 9),(3, 1509231600, 8) ,(3, 1521932400, 9),(3, 1540681200, 8) ,(3, 1553986800, 9),(3, 1572130800, 8) ,(3, 1585436400, 9),(3, 1603580400, 8) ,(3, 1616886000, 9),(3, 1635634800, 8) ,(3, 1648335600, 9),(3, 1667084400, 8) ,(3, 1679785200, 9),(3, 1698534000, 8) ,(3, 1711839600, 9),(3, 1729983600, 8) ,(3, 1743289200, 9),(3, 1761433200, 8) ,(3, 1774738800, 9),(3, 1792882800, 8) ,(3, 1806188400, 9),(3, 1824937200, 8) ,(3, 1837638000, 9),(3, 1856386800, 8) ,(3, 1869087600, 9),(3, 1887836400, 8) ,(3, 1901142000, 9),(3, 1919286000, 8) ,(3, 1932591600, 9),(3, 1950735600, 8) ,(3, 1964041200, 9),(3, 1982790000, 8) ,(3, 1995490800, 9),(3, 2014239600, 8) ,(3, 2026940400, 9),(3, 2045689200, 8) ,(3, 2058390000, 9),(3, 2077138800, 8) ,(3, 2090444400, 9),(3, 2108588400, 8) ,(3, 2121894000, 9),(3, 2140038000, 8),(4, -1688265000, 2) ,(4, -1656819048, 1),(4, -1641353448, 2) ,(4, -1627965048, 3),(4, -1618716648, 1) ,(4, -1596429048, 3),(4, -1593829848, 5) ,(4, -1589860800, 4),(4, -1542427200, 5) ,(4, -1539493200, 6),(4, -1525323600, 5) ,(4, -1522728000, 4),(4, -1491188400, 7) ,(4, -1247536800, 4),(4, 354920409, 5) ,(4, 370728010, 4),(4, 386456410, 5) ,(4, 402264011, 4),(4, 417992411, 5) ,(4, 433800012, 4),(4, 449614812, 5) ,(4, 465346812, 8),(4, 481071612, 9) ,(4, 496796413, 8),(4, 512521213, 9) ,(4, 528246013, 8),(4, 543970813, 9) ,(4, 559695613, 8),(4, 575420414, 9) ,(4, 591145214, 8),(4, 606870014, 9) ,(4, 622594814, 8),(4, 638319615, 9) ,(4, 654649215, 8),(4, 670374016, 10) ,(4, 686102416, 11),(4, 695779216, 8) ,(4, 701812816, 5),(4, 717534017, 4) ,(4, 733273217, 9),(4, 748998018, 8) ,(4, 764722818, 9),(4, 780447619, 8) ,(4, 796172419, 9),(4, 811897219, 8) ,(4, 828226820, 9),(4, 846370820, 8) ,(4, 859676420, 9),(4, 877820421, 8) ,(4, 891126021, 9),(4, 909270021, 8) ,(4, 922575622, 9),(4, 941324422, 8) ,(4, 954025222, 9),(4, 972774022, 8) ,(4, 985474822, 9),(4, 1004223622, 8) ,(4, 1017529222, 9),(4, 1035673222, 8) ,(4, 1048978822, 9),(4, 1067122822, 8) ,(4, 1080428422, 9),(4, 1099177222, 8) ,(4, 1111878022, 9),(4, 1130626822, 8) ,(4, 1143327622, 9),(4, 1162076422, 8) ,(4, 1174777222, 9),(4, 1193526022, 8) ,(4, 1206831622, 9),(4, 1224975622, 8) ,(4, 1238281222, 9),(4, 1256425222, 8) ,(4, 1269730822, 9),(4, 1288479622, 8) ,(4, 1301180422, 9),(4, 1319929222, 8) ,(4, 1332630022, 9),(4, 1351378822, 8) ,(4, 1364684422, 9),(4, 1382828422, 8) ,(4, 1396134022, 9),(4, 1414278022, 8) ,(4, 1427583622, 9),(4, 1445727622, 8) ,(4, 1459033222, 9),(4, 1477782022, 8) ,(4, 1490482822, 9),(4, 1509231622, 8) ,(4, 1521932422, 9),(4, 1540681222, 8) ,(4, 1553986822, 9),(4, 1572130822, 8) ,(4, 1585436422, 9),(4, 1603580422, 8) ,(4, 1616886022, 9),(4, 1635634822, 8) ,(4, 1648335622, 9),(4, 1667084422, 8) ,(4, 1679785222, 9),(4, 1698534022, 8) ,(4, 1711839622, 9),(4, 1729983622, 8) ,(4, 1743289222, 9),(4, 1761433222, 8) ,(4, 1774738822, 9),(4, 1792882822, 8) ,(4, 1806188422, 9),(4, 1824937222, 8) ,(4, 1837638022, 9),(4, 1856386822, 8) ,(4, 1869087622, 9),(4, 1887836422, 8) ,(4, 1901142022, 9),(4, 1919286022, 8) ,(4, 1932591622, 9),(4, 1950735622, 8) ,(4, 1964041222, 9),(4, 1982790022, 8) ,(4, 1995490822, 9),(4, 2014239622, 8) ,(4, 2026940422, 9),(4, 2045689222, 8) ,(4, 2058390022, 9),(4, 2077138822, 8) ,(4, 2090444422, 9),(4, 2108588422, 8) ,(4, 2121894022, 9),(4, 2140038022, 8); - - -CREATE TABLE time_zone_transition_type (Time_zone_id int unsigned NOT NULL,Transition_type_id int unsigned NOT NULL,Offset int signed DEFAULT 0 NOT NULL,Is_DST tinyint unsigned DEFAULT 0 NOT NULL,Abbreviation char(8) DEFAULT '' NOT NULL,PRIMARY KEY TzIdTrTId (Time_zone_id, Transition_type_id)) engine=MyISAM CHARACTER SET utf8 comment='Time zone transition types'; - -INSERT INTO time_zone_transition_type (Time_zone_id,Transition_type_id, Offset, Is_DST, Abbreviation) VALUES (1, 0, 7200, 1, 'MEST') ,(1, 1, 3600, 0, 'MET') ,(1, 2, 7200, 1, 'MEST') ,(1, 3, 3600, 0, 'MET') ,(2, 0, 0, 0, 'UTC') ,(3, 0, 9000, 0, 'MMT') ,(3, 1, 12648, 1, 'MST') ,(3, 2, 9048, 0, 'MMT') ,(3, 3, 16248, 1, 'MDST') ,(3, 4, 10800, 0, 'MSK') ,(3, 5, 14400, 1, 'MSD') ,(3, 6, 18000, 1, 'MSD') ,(3, 7, 7200, 0, 'EET') ,(3, 8, 10800, 0, 'MSK') ,(3, 9, 14400, 1, 'MSD') ,(3, 10, 10800, 1, 'EEST') ,(3, 11, 7200, 0, 'EET') ,(4, 0, 9000, 0, 'MMT') ,(4, 1, 12648, 1, 'MST') ,(4, 2, 9048, 0, 'MMT') ,(4, 3, 16248, 1, 'MDST') ,(4, 4, 10800, 0, 'MSK') ,(4, 5, 14400, 1, 'MSD') ,(4, 6, 18000, 1, 'MSD') ,(4, 7, 7200, 0, 'EET') ,(4, 8, 10800, 0, 'MSK') ,(4, 9, 14400, 1, 'MSD') ,(4, 10, 10800, 1, 'EEST') ,(4, 11, 7200, 0, 'EET') ,(5, 0, 32400, 0, 'CJT') ,(5, 1, 32400, 0, 'JST'); - -CREATE TABLE time_zone_leap_second (Transition_time bigint signed NOT NULL,Correction int signed NOT NULL,PRIMARY KEY TranTime (Transition_time)) engine=MyISAM CHARACTER SET utf8 comment='Leap seconds information for time zones'; - -INSERT INTO time_zone_leap_second (Transition_time, Correction) VALUES (78796800, 1) ,(94694401, 2) ,(126230402, 3) ,(157766403, 4) ,(189302404, 5) ,(220924805, 6) ,(252460806, 7) ,(283996807, 8) ,(315532808, 9) ,(362793609, 10) ,(394329610, 11) ,(425865611, 12) ,(489024012, 13) ,(567993613, 14) ,(631152014, 15) ,(662688015, 16) ,(709948816, 17) ,(741484817, 18) ,(773020818, 19) ,(820454419, 20) ,(867715220, 21) ,(915148821, 22); - - diff --git a/mysql-test/lib/init_db.sql b/mysql-test/lib/init_db.sql deleted file mode 100644 index 6d5ec55a6ae..00000000000 --- a/mysql-test/lib/init_db.sql +++ /dev/null @@ -1,471 +0,0 @@ -use mysql; -set table_type=myisam; - -CREATE TABLE db ( - Host char(60) binary DEFAULT '' NOT NULL, - Db char(64) binary DEFAULT '' NOT NULL, - User char(16) binary DEFAULT '' NOT NULL, - Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - PRIMARY KEY Host (Host,Db,User), - KEY User (User) -) engine=MyISAM -CHARACTER SET utf8 COLLATE utf8_bin -comment='Database privileges'; - - -INSERT INTO db VALUES ('%','test' ,'','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y'); -INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y'); - - -CREATE TABLE host ( - Host char(60) binary DEFAULT '' NOT NULL, - Db char(64) binary DEFAULT '' NOT NULL, - Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - PRIMARY KEY Host (Host,Db) -) engine=MyISAM -CHARACTER SET utf8 COLLATE utf8_bin -comment='Host privileges; Merged with database privileges'; - - -CREATE TABLE user ( - Host char(60) binary DEFAULT '' NOT NULL, - User char(16) binary DEFAULT '' NOT NULL, - Password char(41) binary DEFAULT '' NOT NULL, - Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - Reload_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - Shutdown_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - Process_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - File_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - Show_db_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - Super_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - Repl_slave_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - Repl_client_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - ssl_type enum('','ANY','X509', 'SPECIFIED') COLLATE utf8_general_ci DEFAULT '' NOT NULL, - ssl_cipher BLOB NOT NULL, - x509_issuer BLOB NOT NULL, - x509_subject BLOB NOT NULL, - max_questions int(11) unsigned DEFAULT 0 NOT NULL, - max_updates int(11) unsigned DEFAULT 0 NOT NULL, - max_connections int(11) unsigned DEFAULT 0 NOT NULL, - PRIMARY KEY Host (Host,User) -) engine=MyISAM -CHARACTER SET utf8 COLLATE utf8_bin -comment='Users and global privileges'; - - -INSERT INTO user VALUES ('localhost' ,'root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0); -INSERT INTO user VALUES ('@HOSTNAME@%','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0); -REPLACE INTO user VALUES ('127.0.0.1' ,'root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0); -INSERT INTO user (host,user) VALUES ('localhost',''); -INSERT INTO user (host,user) VALUES ('@HOSTNAME@%',''); - - -CREATE TABLE func ( - name char(64) binary DEFAULT '' NOT NULL, - ret tinyint(1) DEFAULT '0' NOT NULL, - dl char(128) DEFAULT '' NOT NULL, - type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL, - PRIMARY KEY (name) -) engine=MyISAM -CHARACTER SET utf8 COLLATE utf8_bin -comment='User defined functions'; - - -CREATE TABLE tables_priv ( - Host char(60) binary DEFAULT '' NOT NULL, - Db char(64) binary DEFAULT '' NOT NULL, - User char(16) binary DEFAULT '' NOT NULL, - Table_name char(64) binary DEFAULT '' NOT NULL, - Grantor char(77) DEFAULT '' NOT NULL, - Timestamp timestamp(14), - Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') COLLATE utf8_general_ci DEFAULT '' NOT NULL, - Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, - PRIMARY KEY (Host,Db,User,Table_name),KEY Grantor (Grantor) -) engine=MyISAM -CHARACTER SET utf8 COLLATE utf8_bin -comment='Table privileges'; - - -CREATE TABLE columns_priv ( - Host char(60) binary DEFAULT '' NOT NULL, - Db char(64) binary DEFAULT '' NOT NULL, - User char(16) binary DEFAULT '' NOT NULL, - Table_name char(64) binary DEFAULT '' NOT NULL, - Column_name char(64) binary DEFAULT '' NOT NULL, - Timestamp timestamp(14), - Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, - PRIMARY KEY (Host,Db,User,Table_name,Column_name) -) engine=MyISAM -CHARACTER SET utf8 COLLATE utf8_bin -comment='Column privileges'; - - -CREATE TABLE help_topic ( - help_topic_id int unsigned not null, - name varchar(64) not null, - help_category_id smallint unsigned not null, - description text not null, - example text not null, - url varchar(128) not null, - primary key (help_topic_id), - unique index (name) -) engine=MyISAM -CHARACTER SET utf8 -comment='help topics'; - - -CREATE TABLE help_category ( - help_category_id smallint unsigned not null, - name varchar(64) not null, - parent_category_id smallint unsigned null, - url varchar(128) not null, - primary key (help_category_id),unique index (name) -) engine=MyISAM -CHARACTER SET utf8 -comment='help categories'; - - -CREATE TABLE help_keyword ( - help_keyword_id int unsigned not null, - name varchar(64) not null, - primary key (help_keyword_id),unique index (name) -) engine=MyISAM -CHARACTER SET utf8 -comment='help keywords'; - - -CREATE TABLE help_relation ( - help_topic_id int unsigned not null references help_topic, - help_keyword_id int unsigned not null references help_keyword, - primary key (help_keyword_id, help_topic_id) -) engine=MyISAM -CHARACTER SET utf8 -comment='keyword-topic relation'; - - -CREATE TABLE time_zone_name ( - Name char(64) NOT NULL, - Time_zone_id int unsigned NOT NULL, - PRIMARY KEY Name (Name) -) engine=MyISAM -CHARACTER SET utf8 -comment='Time zone names'; - - -INSERT INTO time_zone_name (Name, Time_Zone_id) VALUES - ('MET', 1), ('UTC', 2), ('Universal', 2), - ('Europe/Moscow',3), ('leap/Europe/Moscow',4), - ('Japan', 5); - - -CREATE TABLE time_zone ( - Time_zone_id int unsigned NOT NULL auto_increment, - Use_leap_seconds enum('Y','N') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - PRIMARY KEY TzId (Time_zone_id) -) engine=MyISAM -CHARACTER SET utf8 -comment='Time zones'; - - -INSERT INTO time_zone (Time_zone_id, Use_leap_seconds) - VALUES (1,'N'), (2,'N'), (3,'N'), (4,'Y'), (5,'N'); - - -CREATE TABLE time_zone_transition ( - Time_zone_id int unsigned NOT NULL, - Transition_time bigint signed NOT NULL, - Transition_type_id int unsigned NOT NULL, - PRIMARY KEY TzIdTranTime (Time_zone_id, Transition_time) -) engine=MyISAM -CHARACTER SET utf8 -comment='Time zone transitions'; - - -INSERT INTO time_zone_transition - (Time_zone_id, Transition_time, Transition_type_id) -VALUES - (1, -1693706400, 0) ,(1, -1680483600, 1) - ,(1, -1663455600, 2) ,(1, -1650150000, 3) - ,(1, -1632006000, 2) ,(1, -1618700400, 3) - ,(1, -938905200, 2) ,(1, -857257200, 3) - ,(1, -844556400, 2) ,(1, -828226800, 3) - ,(1, -812502000, 2) ,(1, -796777200, 3) - ,(1, 228877200, 2) ,(1, 243997200, 3) - ,(1, 260326800, 2) ,(1, 276051600, 3) - ,(1, 291776400, 2) ,(1, 307501200, 3) - ,(1, 323830800, 2) ,(1, 338950800, 3) - ,(1, 354675600, 2) ,(1, 370400400, 3) - ,(1, 386125200, 2) ,(1, 401850000, 3) - ,(1, 417574800, 2) ,(1, 433299600, 3) - ,(1, 449024400, 2) ,(1, 465354000, 3) - ,(1, 481078800, 2) ,(1, 496803600, 3) - ,(1, 512528400, 2) ,(1, 528253200, 3) - ,(1, 543978000, 2) ,(1, 559702800, 3) - ,(1, 575427600, 2) ,(1, 591152400, 3) - ,(1, 606877200, 2) ,(1, 622602000, 3) - ,(1, 638326800, 2) ,(1, 654656400, 3) - ,(1, 670381200, 2) ,(1, 686106000, 3) - ,(1, 701830800, 2) ,(1, 717555600, 3) - ,(1, 733280400, 2) ,(1, 749005200, 3) - ,(1, 764730000, 2) ,(1, 780454800, 3) - ,(1, 796179600, 2) ,(1, 811904400, 3) - ,(1, 828234000, 2) ,(1, 846378000, 3) - ,(1, 859683600, 2) ,(1, 877827600, 3) - ,(1, 891133200, 2) ,(1, 909277200, 3) - ,(1, 922582800, 2) ,(1, 941331600, 3) - ,(1, 954032400, 2) ,(1, 972781200, 3) - ,(1, 985482000, 2) ,(1, 1004230800, 3) - ,(1, 1017536400, 2) ,(1, 1035680400, 3) - ,(1, 1048986000, 2) ,(1, 1067130000, 3) - ,(1, 1080435600, 2) ,(1, 1099184400, 3) - ,(1, 1111885200, 2) ,(1, 1130634000, 3) - ,(1, 1143334800, 2) ,(1, 1162083600, 3) - ,(1, 1174784400, 2) ,(1, 1193533200, 3) - ,(1, 1206838800, 2) ,(1, 1224982800, 3) - ,(1, 1238288400, 2) ,(1, 1256432400, 3) - ,(1, 1269738000, 2) ,(1, 1288486800, 3) - ,(1, 1301187600, 2) ,(1, 1319936400, 3) - ,(1, 1332637200, 2) ,(1, 1351386000, 3) - ,(1, 1364691600, 2) ,(1, 1382835600, 3) - ,(1, 1396141200, 2) ,(1, 1414285200, 3) - ,(1, 1427590800, 2) ,(1, 1445734800, 3) - ,(1, 1459040400, 2) ,(1, 1477789200, 3) - ,(1, 1490490000, 2) ,(1, 1509238800, 3) - ,(1, 1521939600, 2) ,(1, 1540688400, 3) - ,(1, 1553994000, 2) ,(1, 1572138000, 3) - ,(1, 1585443600, 2) ,(1, 1603587600, 3) - ,(1, 1616893200, 2) ,(1, 1635642000, 3) - ,(1, 1648342800, 2) ,(1, 1667091600, 3) - ,(1, 1679792400, 2) ,(1, 1698541200, 3) - ,(1, 1711846800, 2) ,(1, 1729990800, 3) - ,(1, 1743296400, 2) ,(1, 1761440400, 3) - ,(1, 1774746000, 2) ,(1, 1792890000, 3) - ,(1, 1806195600, 2) ,(1, 1824944400, 3) - ,(1, 1837645200, 2) ,(1, 1856394000, 3) - ,(1, 1869094800, 2) ,(1, 1887843600, 3) - ,(1, 1901149200, 2) ,(1, 1919293200, 3) - ,(1, 1932598800, 2) ,(1, 1950742800, 3) - ,(1, 1964048400, 2) ,(1, 1982797200, 3) - ,(1, 1995498000, 2) ,(1, 2014246800, 3) - ,(1, 2026947600, 2) ,(1, 2045696400, 3) - ,(1, 2058397200, 2) ,(1, 2077146000, 3) - ,(1, 2090451600, 2) ,(1, 2108595600, 3) - ,(1, 2121901200, 2) ,(1, 2140045200, 3) - ,(3, -1688265000, 2) ,(3, -1656819048, 1) - ,(3, -1641353448, 2) ,(3, -1627965048, 3) - ,(3, -1618716648, 1) ,(3, -1596429048, 3) - ,(3, -1593829848, 5) ,(3, -1589860800, 4) - ,(3, -1542427200, 5) ,(3, -1539493200, 6) - ,(3, -1525323600, 5) ,(3, -1522728000, 4) - ,(3, -1491188400, 7) ,(3, -1247536800, 4) - ,(3, 354920400, 5) ,(3, 370728000, 4) - ,(3, 386456400, 5) ,(3, 402264000, 4) - ,(3, 417992400, 5) ,(3, 433800000, 4) - ,(3, 449614800, 5) ,(3, 465346800, 8) - ,(3, 481071600, 9) ,(3, 496796400, 8) - ,(3, 512521200, 9) ,(3, 528246000, 8) - ,(3, 543970800, 9) ,(3, 559695600, 8) - ,(3, 575420400, 9) ,(3, 591145200, 8) - ,(3, 606870000, 9) ,(3, 622594800, 8) - ,(3, 638319600, 9) ,(3, 654649200, 8) - ,(3, 670374000, 10) ,(3, 686102400, 11) - ,(3, 695779200, 8) ,(3, 701812800, 5) - ,(3, 717534000, 4) ,(3, 733273200, 9) - ,(3, 748998000, 8) ,(3, 764722800, 9) - ,(3, 780447600, 8) ,(3, 796172400, 9) - ,(3, 811897200, 8) ,(3, 828226800, 9) - ,(3, 846370800, 8) ,(3, 859676400, 9) - ,(3, 877820400, 8) ,(3, 891126000, 9) - ,(3, 909270000, 8) ,(3, 922575600, 9) - ,(3, 941324400, 8) ,(3, 954025200, 9) - ,(3, 972774000, 8) ,(3, 985474800, 9) - ,(3, 1004223600, 8) ,(3, 1017529200, 9) - ,(3, 1035673200, 8) ,(3, 1048978800, 9) - ,(3, 1067122800, 8) ,(3, 1080428400, 9) - ,(3, 1099177200, 8) ,(3, 1111878000, 9) - ,(3, 1130626800, 8) ,(3, 1143327600, 9) - ,(3, 1162076400, 8) ,(3, 1174777200, 9) - ,(3, 1193526000, 8) ,(3, 1206831600, 9) - ,(3, 1224975600, 8) ,(3, 1238281200, 9) - ,(3, 1256425200, 8) ,(3, 1269730800, 9) - ,(3, 1288479600, 8) ,(3, 1301180400, 9) - ,(3, 1319929200, 8) ,(3, 1332630000, 9) - ,(3, 1351378800, 8) ,(3, 1364684400, 9) - ,(3, 1382828400, 8) ,(3, 1396134000, 9) - ,(3, 1414278000, 8) ,(3, 1427583600, 9) - ,(3, 1445727600, 8) ,(3, 1459033200, 9) - ,(3, 1477782000, 8) ,(3, 1490482800, 9) - ,(3, 1509231600, 8) ,(3, 1521932400, 9) - ,(3, 1540681200, 8) ,(3, 1553986800, 9) - ,(3, 1572130800, 8) ,(3, 1585436400, 9) - ,(3, 1603580400, 8) ,(3, 1616886000, 9) - ,(3, 1635634800, 8) ,(3, 1648335600, 9) - ,(3, 1667084400, 8) ,(3, 1679785200, 9) - ,(3, 1698534000, 8) ,(3, 1711839600, 9) - ,(3, 1729983600, 8) ,(3, 1743289200, 9) - ,(3, 1761433200, 8) ,(3, 1774738800, 9) - ,(3, 1792882800, 8) ,(3, 1806188400, 9) - ,(3, 1824937200, 8) ,(3, 1837638000, 9) - ,(3, 1856386800, 8) ,(3, 1869087600, 9) - ,(3, 1887836400, 8) ,(3, 1901142000, 9) - ,(3, 1919286000, 8) ,(3, 1932591600, 9) - ,(3, 1950735600, 8) ,(3, 1964041200, 9) - ,(3, 1982790000, 8) ,(3, 1995490800, 9) - ,(3, 2014239600, 8) ,(3, 2026940400, 9) - ,(3, 2045689200, 8) ,(3, 2058390000, 9) - ,(3, 2077138800, 8) ,(3, 2090444400, 9) - ,(3, 2108588400, 8) ,(3, 2121894000, 9) - ,(3, 2140038000, 8) - ,(4, -1688265000, 2) ,(4, -1656819048, 1) - ,(4, -1641353448, 2) ,(4, -1627965048, 3) - ,(4, -1618716648, 1) ,(4, -1596429048, 3) - ,(4, -1593829848, 5) ,(4, -1589860800, 4) - ,(4, -1542427200, 5) ,(4, -1539493200, 6) - ,(4, -1525323600, 5) ,(4, -1522728000, 4) - ,(4, -1491188400, 7) ,(4, -1247536800, 4) - ,(4, 354920409, 5) ,(4, 370728010, 4) - ,(4, 386456410, 5) ,(4, 402264011, 4) - ,(4, 417992411, 5) ,(4, 433800012, 4) - ,(4, 449614812, 5) ,(4, 465346812, 8) - ,(4, 481071612, 9) ,(4, 496796413, 8) - ,(4, 512521213, 9) ,(4, 528246013, 8) - ,(4, 543970813, 9) ,(4, 559695613, 8) - ,(4, 575420414, 9) ,(4, 591145214, 8) - ,(4, 606870014, 9) ,(4, 622594814, 8) - ,(4, 638319615, 9) ,(4, 654649215, 8) - ,(4, 670374016, 10) ,(4, 686102416, 11) - ,(4, 695779216, 8) ,(4, 701812816, 5) - ,(4, 717534017, 4) ,(4, 733273217, 9) - ,(4, 748998018, 8) ,(4, 764722818, 9) - ,(4, 780447619, 8) ,(4, 796172419, 9) - ,(4, 811897219, 8) ,(4, 828226820, 9) - ,(4, 846370820, 8) ,(4, 859676420, 9) - ,(4, 877820421, 8) ,(4, 891126021, 9) - ,(4, 909270021, 8) ,(4, 922575622, 9) - ,(4, 941324422, 8) ,(4, 954025222, 9) - ,(4, 972774022, 8) ,(4, 985474822, 9) - ,(4, 1004223622, 8) ,(4, 1017529222, 9) - ,(4, 1035673222, 8) ,(4, 1048978822, 9) - ,(4, 1067122822, 8) ,(4, 1080428422, 9) - ,(4, 1099177222, 8) ,(4, 1111878022, 9) - ,(4, 1130626822, 8) ,(4, 1143327622, 9) - ,(4, 1162076422, 8) ,(4, 1174777222, 9) - ,(4, 1193526022, 8) ,(4, 1206831622, 9) - ,(4, 1224975622, 8) ,(4, 1238281222, 9) - ,(4, 1256425222, 8) ,(4, 1269730822, 9) - ,(4, 1288479622, 8) ,(4, 1301180422, 9) - ,(4, 1319929222, 8) ,(4, 1332630022, 9) - ,(4, 1351378822, 8) ,(4, 1364684422, 9) - ,(4, 1382828422, 8) ,(4, 1396134022, 9) - ,(4, 1414278022, 8) ,(4, 1427583622, 9) - ,(4, 1445727622, 8) ,(4, 1459033222, 9) - ,(4, 1477782022, 8) ,(4, 1490482822, 9) - ,(4, 1509231622, 8) ,(4, 1521932422, 9) - ,(4, 1540681222, 8) ,(4, 1553986822, 9) - ,(4, 1572130822, 8) ,(4, 1585436422, 9) - ,(4, 1603580422, 8) ,(4, 1616886022, 9) - ,(4, 1635634822, 8) ,(4, 1648335622, 9) - ,(4, 1667084422, 8) ,(4, 1679785222, 9) - ,(4, 1698534022, 8) ,(4, 1711839622, 9) - ,(4, 1729983622, 8) ,(4, 1743289222, 9) - ,(4, 1761433222, 8) ,(4, 1774738822, 9) - ,(4, 1792882822, 8) ,(4, 1806188422, 9) - ,(4, 1824937222, 8) ,(4, 1837638022, 9) - ,(4, 1856386822, 8) ,(4, 1869087622, 9) - ,(4, 1887836422, 8) ,(4, 1901142022, 9) - ,(4, 1919286022, 8) ,(4, 1932591622, 9) - ,(4, 1950735622, 8) ,(4, 1964041222, 9) - ,(4, 1982790022, 8) ,(4, 1995490822, 9) - ,(4, 2014239622, 8) ,(4, 2026940422, 9) - ,(4, 2045689222, 8) ,(4, 2058390022, 9) - ,(4, 2077138822, 8) ,(4, 2090444422, 9) - ,(4, 2108588422, 8) ,(4, 2121894022, 9) - ,(4, 2140038022, 8) - ,(5, -1009875600, 1); - - -CREATE TABLE time_zone_transition_type ( - Time_zone_id int unsigned NOT NULL, - Transition_type_id int unsigned NOT NULL, - Offset int signed DEFAULT 0 NOT NULL, - Is_DST tinyint unsigned DEFAULT 0 NOT NULL, - Abbreviation char(8) DEFAULT '' NOT NULL, - PRIMARY KEY TzIdTrTId (Time_zone_id, Transition_type_id) -) engine=MyISAM -CHARACTER SET utf8 -comment='Time zone transition types'; - - -INSERT INTO time_zone_transition_type ( - Time_zone_id,Transition_type_id, Offset, Is_DST, Abbreviation) VALUES - (1, 0, 7200, 1, 'MEST') ,(1, 1, 3600, 0, 'MET') - ,(1, 2, 7200, 1, 'MEST') ,(1, 3, 3600, 0, 'MET') - ,(2, 0, 0, 0, 'UTC') - ,(3, 0, 9000, 0, 'MMT') ,(3, 1, 12648, 1, 'MST') - ,(3, 2, 9048, 0, 'MMT') ,(3, 3, 16248, 1, 'MDST') - ,(3, 4, 10800, 0, 'MSK') ,(3, 5, 14400, 1, 'MSD') - ,(3, 6, 18000, 1, 'MSD') ,(3, 7, 7200, 0, 'EET') - ,(3, 8, 10800, 0, 'MSK') ,(3, 9, 14400, 1, 'MSD') - ,(3, 10, 10800, 1, 'EEST') ,(3, 11, 7200, 0, 'EET') - ,(4, 0, 9000, 0, 'MMT') ,(4, 1, 12648, 1, 'MST') - ,(4, 2, 9048, 0, 'MMT') ,(4, 3, 16248, 1, 'MDST') - ,(4, 4, 10800, 0, 'MSK') ,(4, 5, 14400, 1, 'MSD') - ,(4, 6, 18000, 1, 'MSD') ,(4, 7, 7200, 0, 'EET') - ,(4, 8, 10800, 0, 'MSK') ,(4, 9, 14400, 1, 'MSD') - ,(4, 10, 10800, 1, 'EEST') ,(4, 11, 7200, 0, 'EET') - ,(5, 0, 32400, 0, 'CJT') ,(5, 1, 32400, 0, 'JST'); - - -CREATE TABLE time_zone_leap_second ( - Transition_time bigint signed NOT NULL, - Correction int signed NOT NULL, - PRIMARY KEY TranTime (Transition_time) -) engine=MyISAM -CHARACTER SET utf8 -comment='Leap seconds information for time zones'; - - -INSERT INTO time_zone_leap_second ( - Transition_time, Correction) VALUES - (78796800, 1) ,(94694401, 2) ,(126230402, 3) - ,(157766403, 4) ,(189302404, 5) ,(220924805, 6) - ,(252460806, 7) ,(283996807, 8) ,(315532808, 9) - ,(362793609, 10) ,(394329610, 11) ,(425865611, 12) - ,(489024012, 13) ,(567993613, 14) ,(631152014, 15) - ,(662688015, 16) ,(709948816, 17) ,(741484817, 18) - ,(773020818, 19) ,(820454419, 20) ,(867715220, 21) - ,(915148821, 22); From 87eee8fcad9622058f4feeec2e9796ea896c4bfc Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 28 Feb 2007 16:37:50 +0100 Subject: [PATCH 23/27] Bug#24878 mysql server doesn't log incident time in "mysqld got signal 11" error messages - Add printout of current time when mysqld is killed by an unhandled signal sql/mysqld.cc: Add printout of current time before the "mysqld got signal %d" message Hopefully we don't crash in the calls to 'time' or 'localtime_r' but if that should start to happen we can move the printout of time further down. At least it's now below the check for segfault inside of segfault handler. --- sql/mysqld.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 460bf2e7308..0efc1339467 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1933,7 +1933,10 @@ static void check_data_home(const char *path) extern "C" sig_handler handle_segfault(int sig) { + time_t curr_time; + struct tm tm; THD *thd=current_thd; + /* Strictly speaking, one needs a mutex here but since we have got SIGSEGV already, things are a mess @@ -1947,11 +1950,17 @@ extern "C" sig_handler handle_segfault(int sig) } segfaulted = 1; + + curr_time= time(NULL); + localtime_r(&curr_time, &tm); + fprintf(stderr,"\ -mysqld got signal %d;\n\ +%02d%02d%02d %2d:%02d:%02d - mysqld got signal %d;\n\ This could be because you hit a bug. It is also possible that this binary\n\ or one of the libraries it was linked against is corrupt, improperly built,\n\ or misconfigured. This error can also be caused by malfunctioning hardware.\n", + tm.tm_year % 100, tm.tm_mon+1, tm.tm_mday, + tm.tm_hour, tm.tm_min, tm.tm_sec, sig); fprintf(stderr, "\ We will try our best to scrape up some info that will hopefully help diagnose\n\ From b40ef082c843a50992dbfefd214743f82d0ef481 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 1 Mar 2007 11:41:29 +0100 Subject: [PATCH 24/27] MySQL versions before 5.0 still use cygwin, no need to convert path --- mysql-test/lib/mtr_misc.pl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mysql-test/lib/mtr_misc.pl b/mysql-test/lib/mtr_misc.pl index 880368be170..ef7dda358f2 100644 --- a/mysql-test/lib/mtr_misc.pl +++ b/mysql-test/lib/mtr_misc.pl @@ -54,6 +54,12 @@ sub mtr_short_hostname () { sub mtr_native_path($) { my $path= shift; + + # MySQL version before 5.0 still use cygwin, no need + # to convert path + return $path + if ($::mysql_version_id < 50000); + $path=~ s/\//\\/g if ($::glob_win32); return $path; From a01e8043de80c166f739e7603aa9cebf19da0abd Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 1 Mar 2007 18:30:29 +0100 Subject: [PATCH 25/27] Don't set the "is_windows" flag if using cygwin --- client/mysqltest.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/mysqltest.c b/client/mysqltest.c index 9141f9c518e..f678eb98eec 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -5933,7 +5933,9 @@ int main(int argc, char **argv) init_builtin_echo(); #ifdef __WIN__ +#ifndef USE_CYGWIN is_windows= 1; +#endif init_tmp_sh_file(); init_win_path_patterns(); #endif From ec38bd7a32115f70280d9047026ee7395225ccfc Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 1 Mar 2007 18:31:09 +0100 Subject: [PATCH 26/27] Fix bug in mtr.pl where slave wes using same query log file as master --- mysql-test/mysql-test-run.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 21960d2bfcd..73396f2255b 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -3651,7 +3651,7 @@ sub mysqld_arguments ($$$$$) { if ( $mysql_version_id <= 50106 ) { # Force mysqld to use log files up until 5.1.6 - mtr_add_arg($args, "%s--log=%s", $prefix, $master->[0]->{'path_mylog'}); + mtr_add_arg($args, "%s--log=%s", $prefix, $slave->[0]->{'path_mylog'}); } else { From 115a299ff3ce27b85d62ebc1b836c77e6fa4b5de Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 1 Mar 2007 19:09:43 +0100 Subject: [PATCH 27/27] Add two more USE_CYGWIN ifdefs to mysqltest --- client/mysqltest.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/mysqltest.c b/client/mysqltest.c index f678eb98eec..d9f1f25e093 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -1677,12 +1677,14 @@ void do_exec(struct st_command *command) } #ifdef __WIN__ +#ifndef USE_CYGWIN /* Replace /dev/null with NUL */ while(replace(&ds_cmd, "/dev/null", 9, "NUL", 3) == 0) ; /* Replace "closed stdout" with non existing output fd */ while(replace(&ds_cmd, ">&-", 3, ">&4", 3) == 0) ; +#endif #endif DBUG_PRINT("info", ("Executing '%s' as '%s'", @@ -1847,10 +1849,12 @@ void do_system(struct st_command *command) do_eval(&ds_cmd, command->first_argument, command->end, !is_windows); #ifdef __WIN__ +#ifndef USE_CYGWIN /* Replace /dev/null with NUL */ while(replace(&ds_cmd, "/dev/null", 9, "NUL", 3) == 0) ; #endif +#endif DBUG_PRINT("info", ("running system command '%s' as '%s'",