From d3a67330ff9f200bdb20c89cadd9cc2003dd403d Mon Sep 17 00:00:00 2001 From: "jpipes@shakedown.(none)" <> Date: Mon, 25 Sep 2006 14:58:10 -0400 Subject: [PATCH 001/131] Fix for Bug #21466: INET_ATON() returns signed int, not unsigned --- mysql-test/r/func_misc.result | 7 +++++++ mysql-test/t/func_misc.test | 7 +++++++ sql/item_func.h | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result index f0262acd71e..6b6277ea649 100644 --- a/mysql-test/r/func_misc.result +++ b/mysql-test/r/func_misc.result @@ -134,4 +134,11 @@ timediff(b, a) >= '00:00:03' drop table t2; drop table t1; set global query_cache_size=default; +create table t1 select INET_ATON('255.255.0.1') as `a`; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bigint(21) unsigned default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; End of 5.0 tests diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test index 52a5512d070..5cac6c45f65 100644 --- a/mysql-test/t/func_misc.test +++ b/mysql-test/t/func_misc.test @@ -125,4 +125,11 @@ drop table t2; drop table t1; set global query_cache_size=default; +# +# Bug #21466: INET_ATON() returns signed, not unsigned +# + +create table t1 select INET_ATON('255.255.0.1') as `a`; +show create table t1; +drop table t1; --echo End of 5.0 tests diff --git a/sql/item_func.h b/sql/item_func.h index 177daf0311f..0a821733a29 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -1289,7 +1289,7 @@ public: Item_func_inet_aton(Item *a) :Item_int_func(a) {} longlong val_int(); const char *func_name() const { return "inet_aton"; } - void fix_length_and_dec() { decimals = 0; max_length = 21; maybe_null=1;} + void fix_length_and_dec() { decimals = 0; max_length = 21; maybe_null=1;unsigned_flag=1;} }; From b57051381a4dbd7c7f933b28582c496047e2f139 Mon Sep 17 00:00:00 2001 From: "jpipes@shakedown.(none)" <> Date: Mon, 2 Oct 2006 11:45:48 -0400 Subject: [PATCH 002/131] Fix for Bug #21412 (client allows DELIMITER with backslash character) --- .bzrignore | 3 +++ client/mysql.cc | 27 ++++++++++++++++++++++++--- mysql-test/r/mysql.result | 4 ++++ mysql-test/t/mysql.test | 18 ++++++++++++++++++ 4 files changed, 49 insertions(+), 3 deletions(-) diff --git a/.bzrignore b/.bzrignore index 7e6c6985e23..810b2f2d03c 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1318,3 +1318,6 @@ win/vs71cache.txt win/vs8cache.txt zlib/*.ds? zlib/*.vcproj +mysql-test/t/tmp.test +mysql-test/r/tmp.result +client/tmp.diff diff --git a/client/mysql.cc b/client/mysql.cc index 5e09c309917..95336f4579f 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -800,10 +800,23 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), default_charset_used= 1; break; case OPT_DELIMITER: - if (argument == disabled_my_option) + if (argument == disabled_my_option) + { strmov(delimiter, DEFAULT_DELIMITER); - else - strmake(delimiter, argument, sizeof(delimiter) - 1); + } + else + { + /* Check that delimiter does not contain a backslash */ + if (!strstr(argument, "\\")) + { + strmake(delimiter, argument, sizeof(delimiter) - 1); + } + else + { + put_info("DELIMITER cannot contain a backslash character", INFO_ERROR); + return 0; + } + } delimiter_length= (uint)strlen(delimiter); delimiter_str= delimiter; break; @@ -3011,6 +3024,14 @@ com_delimiter(String *buffer __attribute__((unused)), char *line) INFO_ERROR); return 0; } + else + { + if (strstr(tmp, "\\")) + { + put_info("DELIMITER cannot contain a backslash character", INFO_ERROR); + return 0; + } + } strmake(delimiter, tmp, sizeof(delimiter) - 1); delimiter_length= (int)strlen(delimiter); delimiter_str= delimiter; diff --git a/mysql-test/r/mysql.result b/mysql-test/r/mysql.result index 7dbff4beca5..7df5b72513f 100644 --- a/mysql-test/r/mysql.result +++ b/mysql-test/r/mysql.result @@ -139,4 +139,8 @@ ERROR at line 1: USE must be followed by a database name \\ '; '; +1 +1 +ERROR at line 1: DELIMITER cannot contain a backslash character +ERROR at line 1: DELIMITER cannot contain a backslash character End of 5.0 tests diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test index 9e3eabf474b..a2e5c348c60 100644 --- a/mysql-test/t/mysql.test +++ b/mysql-test/t/mysql.test @@ -147,4 +147,22 @@ drop table t1; --exec echo "SELECT '\';';" >> $MYSQLTEST_VARDIR/tmp/bug20103.sql --exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug20103.sql 2>&1 +# +# Bug #21412: mysql cmdline client allows backslash(es) +# as delimiter but can't recognize them +# + +# This should work just fine... +--exec echo "DELIMITER /" > $MYSQLTEST_VARDIR/tmp/bug21412.sql +--exec echo "SELECT 1/" >> $MYSQLTEST_VARDIR/tmp/bug21412.sql +--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug21412.sql 2>&1 + +# This should give an error... +--exec echo "DELIMITER \\" > $MYSQLTEST_VARDIR/tmp/bug21412.sql +--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug21412.sql 2>&1 + +# As should this... +--exec echo "DELIMITER \\\\" > $MYSQLTEST_VARDIR/tmp/bug21412.sql +--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug21412.sql 2>&1 + --echo End of 5.0 tests From ce433e9e44c7870885d72b567e1c33f7a933f3cb Mon Sep 17 00:00:00 2001 From: "ramil/ram@mysql.com/myoffice.izhnet.ru" <> Date: Wed, 4 Oct 2006 16:00:44 +0500 Subject: [PATCH 003/131] Fix for bug #21789: DATETIME with 0000-00-00 11:22:33 should be invalid, but is accepted Reject '0000-00-00 01:01:01' dates. --- mysql-test/r/date_formats.result | 57 ++++++++++++++++++++++---------- sql-common/my_time.c | 5 ++- 2 files changed, 43 insertions(+), 19 deletions(-) diff --git a/mysql-test/r/date_formats.result b/mysql-test/r/date_formats.result index 035d98d2b74..0baecb34583 100644 --- a/mysql-test/r/date_formats.result +++ b/mysql-test/r/date_formats.result @@ -181,12 +181,12 @@ date format datetime 2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 2003-01-02 02:11:12.123450 2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 2003-01-02 00:11:12.123450 2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 2003-01-02 23:11:12 -10:20:10 %H:%i:%s 0000-00-00 10:20:10 -10:20:10 %h:%i:%s.%f 0000-00-00 10:20:10 -10:20:10 %T 0000-00-00 10:20:10 -10:20:10AM %h:%i:%s%p 0000-00-00 10:20:10 -10:20:10AM %r 0000-00-00 10:20:10 -10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 10:20:10.440000 +10:20:10 %H:%i:%s 0000-00-00 00:00:00 +10:20:10 %h:%i:%s.%f 0000-00-00 00:00:00 +10:20:10 %T 0000-00-00 00:00:00 +10:20:10AM %h:%i:%s%p 0000-00-00 00:00:00 +10:20:10AM %r 0000-00-00 00:00:00 +10:20:10.44AM %h:%i:%s.%f%p 0000-00-00 00:00:00 15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 2001-01-15 12:59:58 15 September 2001 %d %M %Y 2001-09-15 00:00:00 15 SEPTEMB 2001 %d %M %Y 2001-09-15 00:00:00 @@ -203,6 +203,13 @@ Tuesday 52 2001 %W %V %X 2002-01-01 00:00:00 15-01-2001 %d-%m-%Y %H:%i:%S 2001-01-15 00:00:00 15-01-20 %d-%m-%y 2020-01-15 00:00:00 15-2001-1 %d-%Y-%c 2001-01-15 00:00:00 +Warnings: +Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:20:10.440000' select date,format,DATE(str_to_date(date, format)) as date2 from t1; date format date2 2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 @@ -243,12 +250,12 @@ date format time 2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 02:11:12.123450 2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 00:11:12.123450 2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 23:11:12 -10:20:10 %H:%i:%s 10:20:10 -10:20:10 %h:%i:%s.%f 10:20:10 -10:20:10 %T 10:20:10 -10:20:10AM %h:%i:%s%p 10:20:10 -10:20:10AM %r 10:20:10 -10:20:10.44AM %h:%i:%s.%f%p 10:20:10.440000 +10:20:10 %H:%i:%s NULL +10:20:10 %h:%i:%s.%f NULL +10:20:10 %T NULL +10:20:10AM %h:%i:%s%p NULL +10:20:10AM %r NULL +10:20:10.44AM %h:%i:%s.%f%p NULL 15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 12:59:58 15 September 2001 %d %M %Y 00:00:00 15 SEPTEMB 2001 %d %M %Y 00:00:00 @@ -265,6 +272,13 @@ Tuesday 52 2001 %W %V %X 00:00:00 15-01-2001 %d-%m-%Y %H:%i:%S 00:00:00 15-01-20 %d-%m-%y 00:00:00 15-2001-1 %d-%Y-%c 00:00:00 +Warnings: +Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10.440000' select date,format,concat(TIME(str_to_date(date, format))) as time2 from t1; date format time2 2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 10:11:12 @@ -274,12 +288,12 @@ date format time2 2003-01-02 02:11:12.12345AM %Y-%m-%d %h:%i:%S.%f %p 02:11:12.123450 2003-01-02 12:11:12.12345 am %Y-%m-%d %h:%i:%S.%f%p 00:11:12.123450 2003-01-02 11:11:12Pm %Y-%m-%d %h:%i:%S%p 23:11:12 -10:20:10 %H:%i:%s 10:20:10 -10:20:10 %h:%i:%s.%f 10:20:10 -10:20:10 %T 10:20:10 -10:20:10AM %h:%i:%s%p 10:20:10 -10:20:10AM %r 10:20:10 -10:20:10.44AM %h:%i:%s.%f%p 10:20:10.440000 +10:20:10 %H:%i:%s NULL +10:20:10 %h:%i:%s.%f NULL +10:20:10 %T NULL +10:20:10AM %h:%i:%s%p NULL +10:20:10AM %r NULL +10:20:10.44AM %h:%i:%s.%f%p NULL 15-01-2001 12:59:58 %d-%m-%Y %H:%i:%S 12:59:58 15 September 2001 %d %M %Y 00:00:00 15 SEPTEMB 2001 %d %M %Y 00:00:00 @@ -296,6 +310,13 @@ Tuesday 52 2001 %W %V %X 00:00:00 15-01-2001 %d-%m-%Y %H:%i:%S 00:00:00 15-01-20 %d-%m-%y 00:00:00 15-2001-1 %d-%Y-%c 00:00:00 +Warnings: +Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10' +Warning 1292 Truncated incorrect time value: '0000-00-00 10:20:10.440000' select concat('',str_to_date('8:11:2.123456 03-01-02','%H:%i:%S.%f %y-%m-%d')); concat('',str_to_date('8:11:2.123456 03-01-02','%H:%i:%S.%f %y-%m-%d')) 2003-01-02 08:11:02.123456 diff --git a/sql-common/my_time.c b/sql-common/my_time.c index 3c46a944ba9..e98831ecace 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -350,7 +350,10 @@ str_to_datetime(const char *str, uint length, MYSQL_TIME *l_time, l_time->year > 9999 || l_time->month > 12 || l_time->day > 31 || l_time->hour > 23 || l_time->minute > 59 || l_time->second > 59 || - (!(flags & TIME_FUZZY_DATE) && (l_time->month == 0 || l_time->day == 0))) + (!(flags & TIME_FUZZY_DATE) && + (l_time->month == 0 || l_time->day == 0)) || + (l_time->year == 0 && l_time->month == 0 && l_time->day == 0 && + (l_time->hour != 0 || l_time->minute != 0 || l_time->second != 0))) { /* Only give warning for a zero date if there is some garbage after */ if (!not_zero_date) /* If zero date */ From 5df9ec9a59b25e72604cc562368331001d7cc2d3 Mon Sep 17 00:00:00 2001 From: "ramil/ram@mysql.com/myoffice.izhnet.ru" <> Date: Thu, 5 Oct 2006 15:29:00 +0500 Subject: [PATCH 004/131] Fix for bug #22029: str_to_date returning NULL, while date_format works using identical format. The problem appears when we have a space followed by a non-format symbol. Fix: properly skip spaces. --- mysql-test/r/date_formats.result | 9 +++++++++ mysql-test/t/date_formats.test | 8 ++++++++ sql/item_timefunc.cc | 8 ++++---- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/date_formats.result b/mysql-test/r/date_formats.result index 035d98d2b74..07cc37fe6bc 100644 --- a/mysql-test/r/date_formats.result +++ b/mysql-test/r/date_formats.result @@ -530,4 +530,13 @@ DATE_FORMAT('%Y-%m-%d %H:%i:%s', 1151414896) NULL Warnings: Warning 1292 Truncated incorrect datetime value: '%Y-%m-%d %H:%i:%s' +select str_to_date('04 /30/2004', '%m /%d/%Y'); +str_to_date('04 /30/2004', '%m /%d/%Y') +2004-04-30 +select str_to_date('04/30 /2004', '%m /%d /%Y'); +str_to_date('04/30 /2004', '%m /%d /%Y') +2004-04-30 +select str_to_date('04/30/2004 ', '%m/%d/%Y '); +str_to_date('04/30/2004 ', '%m/%d/%Y ') +2004-04-30 "End of 4.1 tests" diff --git a/mysql-test/t/date_formats.test b/mysql-test/t/date_formats.test index 922d047eac8..7e74c128dee 100644 --- a/mysql-test/t/date_formats.test +++ b/mysql-test/t/date_formats.test @@ -317,4 +317,12 @@ SELECT TIME_FORMAT("25:00:00", '%l %p'); # SELECT DATE_FORMAT('%Y-%m-%d %H:%i:%s', 1151414896); +# +# Bug #22029: str_to_date returning NULL +# + +select str_to_date('04 /30/2004', '%m /%d/%Y'); +select str_to_date('04/30 /2004', '%m /%d /%Y'); +select str_to_date('04/30/2004 ', '%m/%d/%Y '); + --echo "End of 4.1 tests" diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 2da0e8956c2..b2036999d88 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -171,15 +171,15 @@ static bool extract_date_time(DATE_TIME_FORMAT *format, for (; ptr != end && val != val_end; ptr++) { + /* Skip pre-space between each argument */ + while (val != val_end && my_isspace(cs, *val)) + val++; + if (*ptr == '%' && ptr+1 != end) { int val_len; char *tmp; - /* Skip pre-space between each argument */ - while (val != val_end && my_isspace(cs, *val)) - val++; - val_len= (uint) (val_end - val); switch (*++ptr) { /* Year */ From d39a01244191a16263c89267d7b810beaa2fc16e Mon Sep 17 00:00:00 2001 From: "ramil/ram@mysql.com/myoffice.izhnet.ru" <> Date: Tue, 17 Oct 2006 16:30:49 +0500 Subject: [PATCH 005/131] Fix for bug #22229: Bug in DATE_ADD() From the manual: date arithmetic operations require complete dates and do not work with incomplete dates such as '2006-07-00' or badly malformed dates. --- mysql-test/r/func_time.result | 3 +++ mysql-test/t/func_time.test | 6 ++++++ sql/item_timefunc.cc | 4 +++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index 25c910a711a..9b843858d3f 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -1076,3 +1076,6 @@ fmtddate field2 Sep-4 12:00AM abcd DROP TABLE testBug8868; SET NAMES DEFAULT; +select str_to_date('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE; +str_to_date('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE +NULL diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index 2b3fb86829d..1692da3cefe 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -620,3 +620,9 @@ SELECT DATE_FORMAT(field1,'%b-%e %l:%i%p') as fmtddate, field2 FROM testBug8868; DROP TABLE testBug8868; SET NAMES DEFAULT; + +# +# Bug #22229: bug in DATE_ADD() +# + +select str_to_date('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE; diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 48d6458bd88..5b6f238b85f 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -3193,7 +3193,9 @@ bool Item_func_str_to_date::get_date(TIME *ltime, uint fuzzy_date) date_time_format.format.str= (char*) format->ptr(); date_time_format.format.length= format->length(); if (extract_date_time(&date_time_format, val->ptr(), val->length(), - ltime, cached_timestamp_type, 0, "datetime")) + ltime, cached_timestamp_type, 0, "datetime") || + ((fuzzy_date & TIME_NO_ZERO_DATE) && + (ltime->year == 0 || ltime->month == 0 || ltime->day == 0))) goto null_date; if (cached_timestamp_type == MYSQL_TIMESTAMP_TIME && ltime->day) { From 1d5abe60ff880feca03ce29de063650b0149bcbd Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Mon, 30 Oct 2006 15:59:47 +0100 Subject: [PATCH 006/131] Bug#22958 Com_create_user missing within 5.0 - Add Com_create_user to SHOW STATUS command --- sql/mysqld.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index c84e1f7ee56..feeba03b921 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -6023,6 +6023,7 @@ struct show_var_st status_vars[]= { {"Com_create_function", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CREATE_FUNCTION]), SHOW_LONG_STATUS}, {"Com_create_index", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CREATE_INDEX]), SHOW_LONG_STATUS}, {"Com_create_table", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CREATE_TABLE]), SHOW_LONG_STATUS}, + {"Com_create_user", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CREATE_USER]), SHOW_LONG_STATUS}, {"Com_dealloc_sql", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_DEALLOCATE_PREPARE]), SHOW_LONG_STATUS}, {"Com_delete", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_DELETE]), SHOW_LONG_STATUS}, {"Com_delete_multi", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_DELETE_MULTI]), SHOW_LONG_STATUS}, From 06c321d068e3a012c32daba90ab459c0f7b73722 Mon Sep 17 00:00:00 2001 From: "kaa@polly.local" <> Date: Wed, 8 Nov 2006 19:07:21 +0300 Subject: [PATCH 007/131] Removed the underflow check (bug #22129) --- mysql-test/r/type_float.result | 2 +- strings/strtod.c | 20 ++++---------------- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/mysql-test/r/type_float.result b/mysql-test/r/type_float.result index 95050163787..f157bbc602d 100644 --- a/mysql-test/r/type_float.result +++ b/mysql-test/r/type_float.result @@ -274,7 +274,7 @@ a double 0 drop table t1,t2,t3; select 1e-308, 1.00000001e-300, 100000000e-300; 1e-308 1.00000001e-300 100000000e-300 -0 1.00000001e-300 1e-292 +1e-308 1.00000001e-300 1e-292 select 10e307; 10e307 1e+308 diff --git a/strings/strtod.c b/strings/strtod.c index f298e265d7f..79ba458c009 100644 --- a/strings/strtod.c +++ b/strings/strtod.c @@ -31,7 +31,6 @@ #define MAX_DBL_EXP 308 #define MAX_RESULT_FOR_MAX_EXP 1.7976931348623157 -#define MIN_RESULT_FOR_MIN_EXP 2.225073858507202 static double scaler10[] = { 1.0, 1e10, 1e20, 1e30, 1e40, 1e50, 1e60, 1e70, 1e80, 1e90 }; @@ -161,26 +160,15 @@ double my_strtod(const char *str, char **end_ptr, int *error) order= exp + (neg_exp ? -1 : 1) * (ndigits - 1); if (order < 0) order= -order; - if (order >= MAX_DBL_EXP && result) + if (order >= MAX_DBL_EXP && !neg_exp && result) { double c; /* Compute modulus of C (see comment above) */ c= result / scaler * 10.0; - if (neg_exp) + if (order > MAX_DBL_EXP || c > MAX_RESULT_FOR_MAX_EXP) { - if (order > MAX_DBL_EXP || c < MIN_RESULT_FOR_MIN_EXP) - { - result= 0.0; - goto done; - } - } - else - { - if (order > MAX_DBL_EXP || c > MAX_RESULT_FOR_MAX_EXP) - { - overflow= 1; - goto done; - } + overflow= 1; + goto done; } } From 023c0d03e68b44857f8673970ae8526a1e6fdbc6 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Thu, 9 Nov 2006 09:48:50 +0100 Subject: [PATCH 008/131] Fix problem when running mysql_client_test in "binary dist", path should include the binary name --- 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 9bf0f8df632..d788140dd4a 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1484,7 +1484,7 @@ sub executable_setup () { mtr_exe_maybe_exists("$glob_basedir/tests/mysql_client_test", "$glob_basedir/tests/release/mysql_client_test", "$glob_basedir/tests/debug/mysql_client_test", - "$glob_basedir/bin"); + "$glob_basedir/bin/mysql_client_test"); } } From 4c26bf9c1dc32bc2cbd5aa3bf032f7b77b999857 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Thu, 9 Nov 2006 12:00:27 +0100 Subject: [PATCH 009/131] Bug#19371 VARBINARY() have trailing zeros after upgrade from 4.1 - Detect if a table has field of type MYSQL_TYPE_VAR_STRING while running "CHECK TABLE t FOR UPGRADE" and indicate it need to be fixed with "REPAIR TABLE t". - When running a "REPAIR TABLE t" or "ALTER TABLE t FORCE" on the above table, install a special copy function to trim off the trailing spaces which we safely can say that the pre 5.0 mysqld didn't put there. --- mysql-test/r/varbinary.result | 52 +++++++++++++++++++++++++++++++ mysql-test/std_data/bug19371.MYD | Bin 0 -> 40 bytes mysql-test/std_data/bug19371.MYI | Bin 0 -> 1024 bytes mysql-test/std_data/bug19371.frm | Bin 0 -> 8578 bytes mysql-test/t/varbinary.test | 40 ++++++++++++++++++++++++ sql/field_conv.cc | 24 ++++++++++++++ sql/handler.cc | 4 +++ 7 files changed, 120 insertions(+) create mode 100644 mysql-test/std_data/bug19371.MYD create mode 100644 mysql-test/std_data/bug19371.MYI create mode 100644 mysql-test/std_data/bug19371.frm diff --git a/mysql-test/r/varbinary.result b/mysql-test/r/varbinary.result index e62051df5cd..2b8a9c625a5 100644 --- a/mysql-test/r/varbinary.result +++ b/mysql-test/r/varbinary.result @@ -26,3 +26,55 @@ select x,xx from t1; x xx 1 2 drop table t1; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varbinary(255) default NULL, + `b` varchar(255) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select length(a), length(b) from t1; +length(a) length(b) +255 3 +255 3 +CHECK TABLE t1 FOR UPGRADE; +Table Op Msg_type Msg_text +test.t1 check error Table upgrade required. Please do "REPAIR TABLE `t1`" to fix it! +REPAIR TABLE t1; +Table Op Msg_type Msg_text +test.t1 repair status OK +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varbinary(255) default NULL, + `b` varchar(255) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +select length(a), length(b) from t1; +length(a) length(b) +3 3 +3 3 +insert into t1 values("ccc", "ddd"); +select length(a), length(b) from t1; +length(a) length(b) +3 3 +3 3 +3 3 +select hex(a), hex(b) from t1; +hex(a) hex(b) +616161 636363 +626262 646464 +636363 646464 +select concat("'", a, "'"), concat("'", b, "'") from t1; +concat("'", a, "'") concat("'", b, "'") +'aaa' 'ccc' +'bbb' 'ddd' +'ccc' 'ddd' +drop table t1; +create table t1(a varbinary(255)); +insert into t1 values("aaa "); +select length(a) from t1; +length(a) +6 +alter table t1 modify a varchar(255); +select length(a) from t1; +length(a) +6 diff --git a/mysql-test/std_data/bug19371.MYD b/mysql-test/std_data/bug19371.MYD new file mode 100644 index 0000000000000000000000000000000000000000..1b58a70832fd265c905eb935049ff73af5cf51ef GIT binary patch literal 40 jcmZQ(;9_I`!Jal>86jF)%@C7{&A-3LpY3FmVkS12=7U4Jao9m4}<_ z>LrwctOuQsEC*r3?ZlKq5n%-S0fZTV8kj)#f$U}mVn!A)31l%aK)efP!U;wYi;>|! Thz3${r@|GCGDbsSID`NI%jguS literal 0 HcmV?d00001 diff --git a/mysql-test/std_data/bug19371.frm b/mysql-test/std_data/bug19371.frm new file mode 100644 index 0000000000000000000000000000000000000000..7be45d6f8da3d128b42f6b4fe863f559cab9d694 GIT binary patch literal 8578 zcmeI&u?~VT5XSMZ2N>8Gj5Dhf&MZEGiLU@pVtj8o4?~$9jr?!9>kV!5OQ*JTYMMf7 zlXQtBk75n0)vRTmdu=Xq?t7`r12O^#Abtmp.set_quick(buff,sizeof(buff),copy->tmp.charset()); + copy->from_field->val_str(©->tmp); + + /* Use the same function as in 4.1 to trim trailing spaces */ + uint length= my_lengthsp_8bit(&my_charset_bin, copy->tmp.c_ptr_quick(), + copy->from_field->field_length); + + copy->to_field->store(copy->tmp.c_ptr_quick(), length, + copy->tmp.charset()); +} + + static void do_field_int(Copy_field *copy) { longlong value= copy->from_field->val_int(); @@ -570,6 +585,15 @@ void (*Copy_field::get_copy_func(Field *to,Field *from))(Copy_field*) // Check if identical fields if (from->result_type() == STRING_RESULT) { + /* + Detect copy from pre 5.0 varbinary to varbinary as of 5.0 and + use special copy function that removes trailing spaces and thus + repairs data. + */ + if (from->type() == MYSQL_TYPE_VAR_STRING && !from->has_charset() && + to->type() == MYSQL_TYPE_VARCHAR && !to->has_charset()) + return do_field_varbinary_pre50; + /* If we are copying date or datetime's we have to check the dates if we don't allow 'all' dates. diff --git a/sql/handler.cc b/sql/handler.cc index 4accc746664..09e83247bb5 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1972,6 +1972,10 @@ int handler::check_old_types() { return HA_ADMIN_NEEDS_ALTER; } + if ((*field)->type() == MYSQL_TYPE_VAR_STRING) + { + return HA_ADMIN_NEEDS_ALTER; + } } } return 0; From 4b823e045fb89b19f2f2591c0d1d6575e74313c1 Mon Sep 17 00:00:00 2001 From: "ramil/ram@mysql.com/myoffice.izhnet.ru" <> Date: Thu, 9 Nov 2006 16:17:50 +0400 Subject: [PATCH 010/131] Fix for bug #23653: Crash if last_day('0000-00-00') As get_arg0_date() in the Item_func_last_day::get_date() returns 0000-00-00 date sometimes, we have to check ltime->month for 0 after the call. --- mysql-test/r/func_time.result | 3 +++ mysql-test/t/func_time.test | 6 ++++++ sql/item_timefunc.cc | 3 ++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index 5b2deeada55..ef95e0bd558 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -815,4 +815,7 @@ union (select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%k') As H); H 5 +select last_day('0000-00-00'); +last_day('0000-00-00') +NULL End of 4.1 tests diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index 066a059483c..a9b6be0cc72 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -446,4 +446,10 @@ union union (select time_format(timediff(now(), DATE_SUB(now(),INTERVAL 5 HOUR)),'%k') As H); +# +# Bug #23653: crash if last_day('0000-00-00') +# + +select last_day('0000-00-00'); + --echo End of 4.1 tests diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index c1bca7afc60..ec424910f54 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -3058,7 +3058,8 @@ String *Item_func_str_to_date::val_str(String *str) bool Item_func_last_day::get_date(TIME *ltime, uint fuzzy_date) { - if (get_arg0_date(ltime, fuzzy_date & ~TIME_FUZZY_DATE)) + if (get_arg0_date(ltime, fuzzy_date & ~TIME_FUZZY_DATE) || + (ltime->month == 0)) return 1; uint month_idx= ltime->month-1; ltime->day= days_in_month[month_idx]; From 92e0b319785195b00724f280b4b00cca6b366f48 Mon Sep 17 00:00:00 2001 From: "cmiller@zippy.cornsilk.net" <> Date: Thu, 9 Nov 2006 18:33:58 -0500 Subject: [PATCH 011/131] Bug#20691: DATETIME col (NOT NULL, NO DEFAULT) may insert garbage when \ specifying DEFAULT This was not specific to datetime. When there is no default value for a column, and the user inserted DEFAULT, we would write uninitialized memory to the table. Now, insist on writing a default value, a zero-ish value, the same one that comes from inserting NULL into a not-NULL field. (This is, at best, really strange behavior that comes from allowing sloppy usage, and serves as a good reason always to run one's server in a strict SQL mode.) --- mysql-test/r/default.result | 92 +++++++++++++++++++++++++++++++++++++ mysql-test/t/default.test | 58 +++++++++++++++++++++++ sql/item.cc | 1 + 3 files changed, 151 insertions(+) diff --git a/mysql-test/r/default.result b/mysql-test/r/default.result index aef49af6c62..e2aa3b4a3cc 100644 --- a/mysql-test/r/default.result +++ b/mysql-test/r/default.result @@ -104,3 +104,95 @@ a b c d e f g h i j k l m n o p q r s t u v w x y z a1 b1 1 0000 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL drop table t1; drop table t2; +create table bug20691 (i int, d datetime NOT NULL, dn datetime not null default '0000-00-00 00:00:00'); +insert into bug20691 values (1, DEFAULT, DEFAULT), (1, '1975-07-10 07:10:03', '1978-01-13 14:08:51'), (1, DEFAULT, DEFAULT); +Warnings: +Warning 1364 Field 'd' doesn't have a default value +Warning 1364 Field 'd' doesn't have a default value +insert into bug20691 (i) values (2); +Warnings: +Warning 1364 Field 'd' doesn't have a default value +desc bug20691; +Field Type Null Key Default Extra +i int(11) YES NULL +d datetime NO +dn datetime NO 0000-00-00 00:00:00 +insert into bug20691 values (3, DEFAULT, DEFAULT), (3, '1975-07-10 07:10:03', '1978-01-13 14:08:51'), (3, DEFAULT, DEFAULT); +Warnings: +Warning 1364 Field 'd' doesn't have a default value +Warning 1364 Field 'd' doesn't have a default value +insert into bug20691 (i) values (4); +Warnings: +Warning 1364 Field 'd' doesn't have a default value +insert into bug20691 values (5, DEFAULT, DEFAULT), (5, '1975-07-10 07:10:03', '1978-01-13 14:08:51'), (5, DEFAULT, DEFAULT); +Warnings: +Warning 1364 Field 'd' doesn't have a default value +Warning 1364 Field 'd' doesn't have a default value +SET sql_mode = 'ALLOW_INVALID_DATES'; +insert into bug20691 values (6, DEFAULT, DEFAULT), (6, '1975-07-10 07:10:03', '1978-01-13 14:08:51'), (6, DEFAULT, DEFAULT); +Warnings: +Warning 1364 Field 'd' doesn't have a default value +Warning 1364 Field 'd' doesn't have a default value +SET sql_mode = 'STRICT_ALL_TABLES'; +insert into bug20691 values (7, DEFAULT, DEFAULT), (7, '1975-07-10 07:10:03', '1978-01-13 14:08:51'), (7, DEFAULT, DEFAULT); +ERROR HY000: Field 'd' doesn't have a default value +select * from bug20691 order by i asc; +i d dn +1 0000-00-00 00:00:00 0000-00-00 00:00:00 +1 1975-07-10 07:10:03 1978-01-13 14:08:51 +1 0000-00-00 00:00:00 0000-00-00 00:00:00 +2 0000-00-00 00:00:00 0000-00-00 00:00:00 +3 0000-00-00 00:00:00 0000-00-00 00:00:00 +3 1975-07-10 07:10:03 1978-01-13 14:08:51 +3 0000-00-00 00:00:00 0000-00-00 00:00:00 +4 0000-00-00 00:00:00 0000-00-00 00:00:00 +5 0000-00-00 00:00:00 0000-00-00 00:00:00 +5 1975-07-10 07:10:03 1978-01-13 14:08:51 +5 0000-00-00 00:00:00 0000-00-00 00:00:00 +6 0000-00-00 00:00:00 0000-00-00 00:00:00 +6 1975-07-10 07:10:03 1978-01-13 14:08:51 +6 0000-00-00 00:00:00 0000-00-00 00:00:00 +drop table bug20691; +SET sql_mode = ''; +create table bug20691 ( +a set('one', 'two', 'three') not null, +b enum('small', 'medium', 'large', 'enormous', 'ellisonego') not null, +c time not null, +d date not null, +e int not null, +f long not null, +g blob not null, +h datetime not null, +i decimal not null, +x int); +insert into bug20691 values (2, 3, 5, '0007-01-01', 11, 13, 17, '0019-01-01 00:00:00', 23, 1); +insert into bug20691 (x) values (2); +Warnings: +Warning 1364 Field 'a' doesn't have a default value +Warning 1364 Field 'c' doesn't have a default value +Warning 1364 Field 'd' doesn't have a default value +Warning 1364 Field 'e' doesn't have a default value +Warning 1364 Field 'f' doesn't have a default value +Warning 1364 Field 'g' doesn't have a default value +Warning 1364 Field 'h' doesn't have a default value +Warning 1364 Field 'i' doesn't have a default value +insert into bug20691 values (2, 3, 5, '0007-01-01', 11, 13, 17, '0019-01-01 00:00:00', 23, 3); +insert into bug20691 values (DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, 4); +Warnings: +Warning 1364 Field 'a' doesn't have a default value +Warning 1364 Field 'b' doesn't have a default value +Warning 1364 Field 'c' doesn't have a default value +Warning 1364 Field 'd' doesn't have a default value +Warning 1364 Field 'e' doesn't have a default value +Warning 1364 Field 'f' doesn't have a default value +Warning 1364 Field 'g' doesn't have a default value +Warning 1364 Field 'h' doesn't have a default value +Warning 1364 Field 'i' doesn't have a default value +select * from bug20691 order by x asc; +a b c d e f g h i x +two large 00:00:05 0007-01-01 11 13 17 0019-01-01 00:00:00 23 1 + small 00:00:00 0000-00-00 0 0000-00-00 00:00:00 0 2 +two large 00:00:05 0007-01-01 11 13 17 0019-01-01 00:00:00 23 3 + small 00:00:00 0000-00-00 0 0000-00-00 00:00:00 0 4 +drop table bug20691; +End of 5.0 tests. diff --git a/mysql-test/t/default.test b/mysql-test/t/default.test index b5522394d2d..225ddbc3ee2 100644 --- a/mysql-test/t/default.test +++ b/mysql-test/t/default.test @@ -82,3 +82,61 @@ SELECT * from t2; drop table t1; drop table t2; + +# +# Bug#20691: DATETIME col (NOT NULL, NO DEFAULT) may insert garbage when specifying DEFAULT +# +# From the docs: +# If the column can take NULL as a value, the column is defined with an +# explicit DEFAULT NULL clause. This is the same as before 5.0.2. +# +# If the column cannot take NULL as the value, MySQL defines the column with +# no explicit DEFAULT clause. For data entry, if an INSERT or REPLACE +# statement includes no value for the column, MySQL handles the column +# according to the SQL mode in effect at the time: +# +# * If strict SQL mode is not enabled, MySQL sets the column to the +# implicit default value for the column data type. +# +# * If strict mode is enabled, an error occurs for transactional tables and +# the statement is rolled back. For non-transactional tables, an error +# occurs, but if this happens for the second or subsequent row of a +# multiple-row statement, the preceding rows will have been inserted. +# +create table bug20691 (i int, d datetime NOT NULL, dn datetime not null default '0000-00-00 00:00:00'); +insert into bug20691 values (1, DEFAULT, DEFAULT), (1, '1975-07-10 07:10:03', '1978-01-13 14:08:51'), (1, DEFAULT, DEFAULT); +insert into bug20691 (i) values (2); +desc bug20691; +insert into bug20691 values (3, DEFAULT, DEFAULT), (3, '1975-07-10 07:10:03', '1978-01-13 14:08:51'), (3, DEFAULT, DEFAULT); +insert into bug20691 (i) values (4); +insert into bug20691 values (5, DEFAULT, DEFAULT), (5, '1975-07-10 07:10:03', '1978-01-13 14:08:51'), (5, DEFAULT, DEFAULT); +SET sql_mode = 'ALLOW_INVALID_DATES'; +insert into bug20691 values (6, DEFAULT, DEFAULT), (6, '1975-07-10 07:10:03', '1978-01-13 14:08:51'), (6, DEFAULT, DEFAULT); +SET sql_mode = 'STRICT_ALL_TABLES'; +--error 1364 +insert into bug20691 values (7, DEFAULT, DEFAULT), (7, '1975-07-10 07:10:03', '1978-01-13 14:08:51'), (7, DEFAULT, DEFAULT); +select * from bug20691 order by i asc; +drop table bug20691; + +SET sql_mode = ''; +create table bug20691 ( + a set('one', 'two', 'three') not null, + b enum('small', 'medium', 'large', 'enormous', 'ellisonego') not null, + c time not null, + d date not null, + e int not null, + f long not null, + g blob not null, + h datetime not null, + i decimal not null, + x int); +insert into bug20691 values (2, 3, 5, '0007-01-01', 11, 13, 17, '0019-01-01 00:00:00', 23, 1); +insert into bug20691 (x) values (2); +insert into bug20691 values (2, 3, 5, '0007-01-01', 11, 13, 17, '0019-01-01 00:00:00', 23, 3); +insert into bug20691 values (DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, 4); +select * from bug20691 order by x asc; +drop table bug20691; + +### +--echo End of 5.0 tests. + diff --git a/sql/item.cc b/sql/item.cc index d56ca95093b..d181edb4ecd 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -5379,6 +5379,7 @@ int Item_default_value::save_in_field(Field *field_arg, bool no_conversions) ER(ER_NO_DEFAULT_FOR_FIELD), field_arg->field_name); } + field_arg->set_default(); return 1; } field_arg->set_default(); From 7c935a99643bf3f066fec2dbafab3e3997d9b7a2 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Fri, 10 Nov 2006 13:25:10 +0100 Subject: [PATCH 012/131] Bug#10608 mysqladmin breaks on "database" variable in my.cnf - Add printout of "Warning" or "Note" for non error messages in default_reporter - Add test for the above in new mysqladmin.test --- mysql-test/mysql-test-run.pl | 4 ++++ mysql-test/r/mysqladmin.result | 4 ++++ mysql-test/t/mysqladmin.test | 32 ++++++++++++++++++++++++++++++++ mysys/my_getopt.c | 6 +++++- 4 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 mysql-test/r/mysqladmin.result create mode 100644 mysql-test/t/mysqladmin.test diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index d788140dd4a..fe125d1e126 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1818,6 +1818,10 @@ sub environment_setup () { # ---------------------------------------------------- $ENV{'MYSQL_MY_PRINT_DEFAULTS'}= $exe_my_print_defaults; + # ---------------------------------------------------- + # Setup env so childs can execute mysqladmin + # ---------------------------------------------------- + $ENV{'MYSQLADMIN'}= $exe_mysqladmin; # ---------------------------------------------------- # Setup env so childs can execute perror diff --git a/mysql-test/r/mysqladmin.result b/mysql-test/r/mysqladmin.result new file mode 100644 index 00000000000..57927f8aa67 --- /dev/null +++ b/mysql-test/r/mysqladmin.result @@ -0,0 +1,4 @@ +mysqld is alive +mysqladmin: unknown variable 'database=db1' +Warning: mysqladmin: unknown variable 'loose-database=db2' +mysqld is alive diff --git a/mysql-test/t/mysqladmin.test b/mysql-test/t/mysqladmin.test new file mode 100644 index 00000000000..7c016fd7416 --- /dev/null +++ b/mysql-test/t/mysqladmin.test @@ -0,0 +1,32 @@ +# +# Test "mysqladmin ping" +# + +--exec $MYSQLADMIN --no-defaults -S $MASTER_MYSOCK -P $MASTER_MYPORT -u root --password= ping 2>&1 + + +# +# Bug#10608 mysqladmin breaks on "database" variable in my.cnf +# + +# When mysqladmin finds database in .cnf file it shall fail +--write_file $MYSQLTEST_VARDIR/tmp/bug10608.cnf +[client] +database=db1 +EOF + +--replace_regex /\/.*mysqladmin/mysqladmin/ +--error 7 +--exec $MYSQLADMIN --defaults-file=$MYSQLTEST_VARDIR/tmp/bug10608.cnf -S $MASTER_MYSOCK -P $MASTER_MYPORT -u root --password= ping 2>&1 + + +# When mysqladmin finds "loose-database" in .cnf file it shall print +# a warning and continue +--write_file $MYSQLTEST_VARDIR/tmp/bug10608.cnf +[client] +loose-database=db2 +EOF + +--replace_regex /Warning: .*mysqladmin/Warning: mysqladmin/ +--exec $MYSQLADMIN --defaults-file=$MYSQLTEST_VARDIR/tmp/bug10608.cnf -S $MASTER_MYSOCK -P $MASTER_MYPORT -u root --password= ping 2>&1 + diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index dfc3fb3d39c..3f87186ccc3 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -59,11 +59,15 @@ char *disabled_my_option= (char*) "0"; my_bool my_getopt_print_errors= 1; -static void default_reporter(enum loglevel level __attribute__((unused)), +static void default_reporter(enum loglevel level, const char *format, ...) { va_list args; va_start(args, format); + if (level == WARNING_LEVEL) + fprintf(stderr, "%s", "Warning: "); + else if (level == INFORMATION_LEVEL) + fprintf(stderr, "%s", "Info: "); vfprintf(stderr, format, args); va_end(args); } From 43ef5e6a0ca593d463f226b321213066aff6914a Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Fri, 10 Nov 2006 15:58:38 +0100 Subject: [PATCH 013/131] Look for "mysqlmanager" also in "bin" directory Improve log message --- mysql-test/mysql-test-run.pl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index d788140dd4a..7809f582ef9 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1328,7 +1328,8 @@ sub executable_setup_im () { $exe_im= mtr_exe_maybe_exists( "$glob_basedir/server-tools/instance-manager/mysqlmanager", - "$glob_basedir/libexec/mysqlmanager"); + "$glob_basedir/libexec/mysqlmanager", + "$glob_basedir/bin/mysqlmanager"); return ($exe_im eq ""); } @@ -3040,7 +3041,7 @@ sub run_testcase ($) { # ------------------------------------------------------- $ENV{'TZ'}= $tinfo->{'timezone'}; - mtr_verbose("Starting server with timezone: $tinfo->{'timezone'}"); + mtr_verbose("Setting timezone: $tinfo->{'timezone'}"); my $master_restart= run_testcase_need_master_restart($tinfo); my $slave_restart= run_testcase_need_slave_restart($tinfo); From b6eef630819c38af7a3db1de7699667fdddb773b Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Fri, 10 Nov 2006 16:07:27 +0100 Subject: [PATCH 014/131] remove remnants of abi-check.ic --- include/abi_check.ic | 914 ------------------------------------------- 1 file changed, 914 deletions(-) delete mode 100644 include/abi_check.ic diff --git a/include/abi_check.ic b/include/abi_check.ic deleted file mode 100644 index 30ef44a1ccb..00000000000 --- a/include/abi_check.ic +++ /dev/null @@ -1,914 +0,0 @@ -struct rand_struct; -struct st_list; -struct st_mem_root; -struct st_mysql; -struct st_mysql_bind; -struct st_mysql_data; -struct st_mysql_field; -struct st_mysql_manager; -struct st_mysql_methods; -struct st_mysql_options; -struct st_mysql_parameters; -struct st_mysql_res; -struct st_mysql_rows; -struct st_mysql_stmt; -struct st_mysql_time; -struct st_net; -struct st_typelib; -struct st_udf_args; -struct st_udf_init; -struct st_used_mem; -enum Item_result; -enum enum_field_types; -enum enum_mysql_set_option; -enum enum_mysql_stmt_state; -enum enum_mysql_timestamp_type; -enum enum_server_command; -enum enum_stmt_attr_type; -enum mysql_enum_shutdown_level; -enum mysql_option; -enum mysql_protocol_type; -enum mysql_rpl_type; -enum mysql_status; -# 131 "mysql.h" -typedef struct st_mysql_rows MYSQL_ROWS; -# 24 "my_list.h" -typedef struct st_list LIST; -# 232 "mysql.h" -typedef struct st_mysql MYSQL; -# 571 "mysql.h" -typedef struct st_mysql_bind MYSQL_BIND; -# 93 "mysql.h" -typedef struct st_mysql_field MYSQL_FIELD; -# 117 "mysql.h" -typedef unsigned int MYSQL_FIELD_OFFSET; -# 323 "mysql.h" -typedef struct st_mysql_manager MYSQL_MANAGER; -# 337 "mysql.h" -typedef struct st_mysql_parameters MYSQL_PARAMETERS; -# 292 "mysql.h" -typedef struct st_mysql_res MYSQL_RES; -# 116 "mysql.h" -typedef char * * MYSQL_ROW; -# 137 "mysql.h" -typedef MYSQL_ROWS * MYSQL_ROW_OFFSET; -# 596 "mysql.h" -typedef struct st_mysql_stmt MYSQL_STMT; -# 151 "mysql_com.h" -typedef struct st_net NET; -# 21 "typelib.h" -typedef struct st_typelib TYPELIB; -# 141 "mysql_com.h" -typedef struct st_vio Vio; -# 57 "mysql.h" -typedef char * gptr; -# 29 "my_list.h" -typedef int (* list_walk_action)(void *, void *); -# 48 "mysql.h" -typedef char my_bool; -# 63 "mysql.h" -typedef int my_socket; -# 125 "mysql.h" -typedef unsigned long long int my_ulonglong; -# 35 "my_alloc.h" -typedef struct st_mem_root MEM_ROOT; -# 141 "mysql.h" -typedef struct st_mysql_data MYSQL_DATA; -# 648 "mysql.h" -typedef struct st_mysql_methods MYSQL_METHODS; -# 48 "mysql_time.h" -typedef struct st_mysql_time MYSQL_TIME; -# 315 "mysql_com.h" -typedef struct st_udf_args UDF_ARGS; -# 326 "mysql_com.h" -typedef struct st_udf_init UDF_INIT; -# 27 "my_alloc.h" -typedef struct st_used_mem USED_MEM; -# 302 "mysql_com.h" -struct __attribute__((aligned(__alignof__(unsigned long int)), aligned(__alignof__(double)))) rand_struct - { - unsigned long int seed1; - unsigned long int seed2; - unsigned long int max_value; - double max_value_dbl; - }; -# 24 "my_list.h" -struct __attribute__((aligned(__alignof__(void *)))) st_list - { - struct st_list * prev; - struct st_list * next; - void * data; - }; -# 35 "my_alloc.h" -struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned int)))) st_mem_root - { - USED_MEM * free; - USED_MEM * used; - USED_MEM * pre_alloc; - unsigned int min_malloc; - unsigned int block_size; - unsigned int block_num; - unsigned int first_block_usage; - void (* error_handler)(void); - }; -# 232 "mysql.h" -struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned long long int)))) st_mysql - { - NET net; - gptr connector_fd; - char * host; - char * user; - char * passwd; - char * unix_socket; - char * server_version; - char * host_info; - char * info; - char * db; - struct charset_info_st * charset; - MYSQL_FIELD * fields; - MEM_ROOT field_alloc; - my_ulonglong affected_rows; - my_ulonglong insert_id; - my_ulonglong extra_info; - unsigned long int thread_id; - unsigned long int packet_length; - unsigned int port; - unsigned long int client_flag; - unsigned long int server_capabilities; - unsigned int protocol_version; - unsigned int field_count; - unsigned int server_status; - unsigned int server_language; - unsigned int warning_count; - struct st_mysql_options options; - enum mysql_status status; - my_bool free_me; - my_bool reconnect; - char scramble[(20 + 1)]; - my_bool rpl_pivot; - struct st_mysql * master; - struct st_mysql * next_slave; - struct st_mysql * last_used_slave; - struct st_mysql * last_used_con; - LIST * stmts; - struct st_mysql_methods const * methods; - void * thd; - my_bool * unbuffered_fetch_owner; - struct st_mysql_stmt * current_stmt; - }; -# 571 "mysql.h" -struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned long int)))) st_mysql_bind - { - unsigned long int * length; - my_bool * is_null; - void * buffer; - enum enum_field_types buffer_type; - unsigned long int buffer_length; - unsigned char * inter_buffer; - unsigned long int offset; - unsigned long int internal_length; - unsigned int param_number; - unsigned int pack_length; - my_bool is_unsigned; - my_bool long_data_used; - my_bool internal_is_null; - void (* store_param_func)(NET * net, struct st_mysql_bind * param); - void (* fetch_result)(struct st_mysql_bind *, unsigned char * * row); - void (* skip_result)(struct st_mysql_bind *, MYSQL_FIELD *, unsigned char * * row); - }; -# 141 "mysql.h" -struct __attribute__((aligned(__alignof__(unsigned long long int)), aligned(__alignof__(void *)))) st_mysql_data - { - my_ulonglong rows; - unsigned int fields; - MYSQL_ROWS * data; - MEM_ROOT alloc; - MYSQL_ROWS * * prev_ptr; - }; -# 93 "mysql.h" -struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned long int)))) st_mysql_field - { - char * name; - char * org_name; - char * table; - char * org_table; - char * db; - char * catalog; - char * def; - unsigned long int length; - unsigned long int max_length; - unsigned int name_length; - unsigned int org_name_length; - unsigned int table_length; - unsigned int org_table_length; - unsigned int db_length; - unsigned int catalog_length; - unsigned int def_length; - unsigned int flags; - unsigned int decimals; - unsigned int charsetnr; - enum enum_field_types type; - }; -# 323 "mysql.h" -struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned long int)))) st_mysql_manager - { - NET net; - char * host; - char * user; - char * passwd; - unsigned int port; - my_bool free_me; - my_bool eof; - int cmd_status; - int last_errno; - char * net_buf; - char * net_buf_pos; - char * net_data_end; - int net_buf_size; - char last_error[256]; - }; -# 648 "mysql.h" -struct __attribute__((aligned(__alignof__(void *)))) st_mysql_methods - { - my_bool (* read_query_result)(MYSQL * mysql); - my_bool (* advanced_command)(MYSQL * mysql, enum enum_server_command, char const * header, unsigned long int, char const * arg, unsigned long int, my_bool, MYSQL_STMT * stmt); - MYSQL_DATA * (* read_rows)(MYSQL * mysql, MYSQL_FIELD * mysql_fields, unsigned int); - MYSQL_RES * (* use_result)(MYSQL * mysql); - void (* fetch_lengths)(unsigned long int * to, MYSQL_ROW, unsigned int); - void (* flush_use_result)(MYSQL * mysql); - MYSQL_FIELD * (* list_fields)(MYSQL * mysql); - my_bool (* read_prepare_result)(MYSQL * mysql, MYSQL_STMT * stmt); - int (* stmt_execute)(MYSQL_STMT * stmt); - int (* read_binary_rows)(MYSQL_STMT * stmt); - int (* unbuffered_fetch)(MYSQL * mysql, char * * row); - void (* free_embedded_thd)(MYSQL * mysql); - char const * (* read_statistics)(MYSQL * mysql); - my_bool (* next_result)(MYSQL * mysql); - int (* read_change_user_result)(MYSQL * mysql, char * buff, char const * passwd); - }; -# 162 "mysql.h" -struct __attribute__((aligned(__alignof__(unsigned long int)), aligned(__alignof__(void *)))) st_mysql_options - { - unsigned int connect_timeout; - unsigned int read_timeout; - unsigned int write_timeout; - unsigned int port; - unsigned int protocol; - unsigned long int client_flag; - char * host; - char * user; - char * password; - char * unix_socket; - char * db; - struct st_dynamic_array * init_commands; - char * my_cnf_file; - char * my_cnf_group; - char * charset_dir; - char * charset_name; - char * ssl_key; - char * ssl_cert; - char * ssl_ca; - char * ssl_capath; - char * ssl_cipher; - char * shared_memory_base_name; - unsigned long int max_allowed_packet; - my_bool use_ssl; - my_bool compress; - my_bool named_pipe; - my_bool rpl_probe; - my_bool rpl_parse; - my_bool no_master_reads; - my_bool separate_thread; - enum mysql_option methods_to_use; - char * client_ip; - my_bool secure_auth; - int (* local_infile_init)(void * *, char const *, void *); - int (* local_infile_read)(void *, char *, unsigned int); - void (* local_infile_end)(void); - int (* local_infile_error)(void *, char *, unsigned int); - void * local_infile_userdata; - }; -# 337 "mysql.h" -struct __attribute__((aligned(__alignof__(void *)))) st_mysql_parameters - { - unsigned long int * p_max_allowed_packet; - unsigned long int * p_net_buffer_length; - }; -# 292 "mysql.h" -struct __attribute__((aligned(__alignof__(unsigned long long int)), aligned(__alignof__(void *)))) st_mysql_res - { - my_ulonglong row_count; - MYSQL_FIELD * fields; - MYSQL_DATA * data; - MYSQL_ROWS * data_cursor; - unsigned long int * lengths; - MYSQL * handle; - MEM_ROOT field_alloc; - unsigned int field_count; - unsigned int current_field; - MYSQL_ROW row; - MYSQL_ROW current_row; - my_bool eof; - my_bool unbuffered_fetch_cancelled; - struct st_mysql_methods const * methods; - }; -# 131 "mysql.h" -struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned long int)))) st_mysql_rows - { - struct st_mysql_rows * next; - MYSQL_ROW data; - unsigned long int length; - }; -# 596 "mysql.h" -struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned long long int)))) st_mysql_stmt - { - MEM_ROOT mem_root; - LIST list; - MYSQL * mysql; - MYSQL_BIND * params; - MYSQL_BIND * bind; - MYSQL_FIELD * fields; - MYSQL_DATA result; - MYSQL_ROWS * data_cursor; - my_ulonglong affected_rows; - my_ulonglong insert_id; - int (* read_row_func)(struct st_mysql_stmt * stmt, unsigned char * * row); - unsigned long int stmt_id; - unsigned int last_errno; - unsigned int param_count; - unsigned int field_count; - enum enum_mysql_stmt_state state; - char last_error[512]; - char sqlstate[(5 + 1)]; - my_bool send_types_to_server; - my_bool bind_param_done; - my_bool bind_result_done; - my_bool unbuffered_fetch_cancelled; - my_bool update_max_length; - }; -# 48 "mysql_time.h" -struct __attribute__((aligned(__alignof__(unsigned long int)))) st_mysql_time - { - unsigned int year; - unsigned int month; - unsigned int day; - unsigned int hour; - unsigned int minute; - unsigned int second; - unsigned long int second_part; - my_bool neg; - enum enum_mysql_timestamp_type time_type; - }; -# 151 "mysql_com.h" -struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned long int)))) st_net - { - Vio * vio; - unsigned char * buff; - unsigned char * buff_end; - unsigned char * write_pos; - unsigned char * read_pos; - my_socket fd; - unsigned long int max_packet; - unsigned long int max_packet_size; - unsigned int pkt_nr; - unsigned int compress_pkt_nr; - unsigned int write_timeout; - unsigned int read_timeout; - unsigned int retry_count; - int fcntl; - my_bool compress; - unsigned long int remain_in_buf; - unsigned long int length; - unsigned long int buf_length; - unsigned long int where_b; - unsigned int * return_status; - unsigned char reading_or_writing; - char save_char; - my_bool no_send_ok; - char last_error[512]; - char sqlstate[(5 + 1)]; - unsigned int last_errno; - unsigned char error; - gptr query_cache_query; - my_bool report_error; - my_bool return_errno; - }; -# 21 "typelib.h" -struct __attribute__((aligned(__alignof__(unsigned int)), aligned(__alignof__(void *)))) st_typelib - { - unsigned int count; - char const * name; - char const * * type_names; - unsigned int * type_lengths; - }; -# 315 "mysql_com.h" -struct __attribute__((aligned(__alignof__(unsigned int)), aligned(__alignof__(void *)))) st_udf_args - { - unsigned int arg_count; - enum Item_result * arg_type; - char * * args; - unsigned long int * lengths; - char * maybe_null; - }; -# 326 "mysql_com.h" -struct __attribute__((aligned(__alignof__(unsigned long int)), aligned(__alignof__(void *)))) st_udf_init - { - my_bool maybe_null; - unsigned int decimals; - unsigned long int max_length; - char * ptr; - my_bool const_item; - }; -# 27 "my_alloc.h" -struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned int)))) st_used_mem - { - struct st_used_mem * next; - unsigned int left; - unsigned int size; - }; -# 313 "mysql_com.h" -enum Item_result - { - STRING_RESULT = 0, - REAL_RESULT = 1, - INT_RESULT = 2, - ROW_RESULT = 3, - }; -# 186 "mysql_com.h" -enum enum_field_types - { - MYSQL_TYPE_DECIMAL = 0, - MYSQL_TYPE_TINY = 1, - MYSQL_TYPE_SHORT = 2, - MYSQL_TYPE_LONG = 3, - MYSQL_TYPE_FLOAT = 4, - MYSQL_TYPE_DOUBLE = 5, - MYSQL_TYPE_NULL = 6, - MYSQL_TYPE_TIMESTAMP = 7, - MYSQL_TYPE_LONGLONG = 8, - MYSQL_TYPE_INT24 = 9, - MYSQL_TYPE_DATE = 10, - MYSQL_TYPE_TIME = 11, - MYSQL_TYPE_DATETIME = 12, - MYSQL_TYPE_YEAR = 13, - MYSQL_TYPE_NEWDATE = 14, - MYSQL_TYPE_ENUM = 247, - MYSQL_TYPE_SET = 248, - MYSQL_TYPE_TINY_BLOB = 249, - MYSQL_TYPE_MEDIUM_BLOB = 250, - MYSQL_TYPE_LONG_BLOB = 251, - MYSQL_TYPE_BLOB = 252, - MYSQL_TYPE_VAR_STRING = 253, - MYSQL_TYPE_STRING = 254, - MYSQL_TYPE_GEOMETRY = 255, - }; -# 269 "mysql_com.h" -enum enum_mysql_set_option - { - MYSQL_OPTION_MULTI_STATEMENTS_ON = 0, - MYSQL_OPTION_MULTI_STATEMENTS_OFF = 1, - }; -# 563 "mysql.h" -enum enum_mysql_stmt_state - { - MYSQL_STMT_INIT_DONE = 1, - MYSQL_STMT_PREPARE_DONE = 2, - MYSQL_STMT_EXECUTE_DONE = 3, - MYSQL_STMT_FETCH_DONE = 4, - }; -# 29 "mysql_time.h" -enum enum_mysql_timestamp_type - { - MYSQL_TIMESTAMP_NONE = -(2), - MYSQL_TIMESTAMP_ERROR = -(1), - MYSQL_TIMESTAMP_DATE = 0, - MYSQL_TIMESTAMP_DATETIME = 1, - MYSQL_TIMESTAMP_TIME = 2, - }; -# 39 "mysql_com.h" -enum enum_server_command - { - COM_SLEEP = 0, - COM_QUIT = 1, - COM_INIT_DB = 2, - COM_QUERY = 3, - COM_FIELD_LIST = 4, - COM_CREATE_DB = 5, - COM_DROP_DB = 6, - COM_REFRESH = 7, - COM_SHUTDOWN = 8, - COM_STATISTICS = 9, - COM_PROCESS_INFO = 10, - COM_CONNECT = 11, - COM_PROCESS_KILL = 12, - COM_DEBUG = 13, - COM_PING = 14, - COM_TIME = 15, - COM_DELAYED_INSERT = 16, - COM_CHANGE_USER = 17, - COM_BINLOG_DUMP = 18, - COM_TABLE_DUMP = 19, - COM_CONNECT_OUT = 20, - COM_REGISTER_SLAVE = 21, - COM_PREPARE = 22, - COM_EXECUTE = 23, - COM_LONG_DATA = 24, - COM_CLOSE_STMT = 25, - COM_RESET_STMT = 26, - COM_SET_OPTION = 27, - COM_END = 28, - }; -# 635 "mysql.h" -enum enum_stmt_attr_type - { - STMT_ATTR_UPDATE_MAX_LENGTH = 0, - }; -# 244 "mysql_com.h" -enum mysql_enum_shutdown_level - { - SHUTDOWN_DEFAULT = 0, - SHUTDOWN_WAIT_CONNECTIONS = (unsigned char)((1 << 0)), - SHUTDOWN_WAIT_TRANSACTIONS = (unsigned char)((1 << 1)), - SHUTDOWN_WAIT_UPDATES = (unsigned char)((1 << 3)), - SHUTDOWN_WAIT_ALL_BUFFERS = ((unsigned char)((1 << 3)) << 1), - SHUTDOWN_WAIT_CRITICAL_BUFFERS = (((unsigned char)((1 << 3)) << 1) + 1), - KILL_CONNECTION = 255, - }; -# 151 "mysql.h" -enum mysql_option - { - MYSQL_OPT_CONNECT_TIMEOUT = 0, - MYSQL_OPT_COMPRESS = 1, - MYSQL_OPT_NAMED_PIPE = 2, - MYSQL_INIT_COMMAND = 3, - MYSQL_READ_DEFAULT_FILE = 4, - MYSQL_READ_DEFAULT_GROUP = 5, - MYSQL_SET_CHARSET_DIR = 6, - MYSQL_SET_CHARSET_NAME = 7, - MYSQL_OPT_LOCAL_INFILE = 8, - MYSQL_OPT_PROTOCOL = 9, - MYSQL_SHARED_MEMORY_BASE_NAME = 10, - MYSQL_OPT_READ_TIMEOUT = 11, - MYSQL_OPT_WRITE_TIMEOUT = 12, - MYSQL_OPT_USE_RESULT = 13, - MYSQL_OPT_USE_REMOTE_CONNECTION = 14, - MYSQL_OPT_USE_EMBEDDED_CONNECTION = 15, - MYSQL_OPT_GUESS_CONNECTION = 16, - MYSQL_SET_CLIENT_IP = 17, - MYSQL_SECURE_AUTH = 18, - }; -# 214 "mysql.h" -enum mysql_protocol_type - { - MYSQL_PROTOCOL_DEFAULT = 0, - MYSQL_PROTOCOL_TCP = 1, - MYSQL_PROTOCOL_SOCKET = 2, - MYSQL_PROTOCOL_PIPE = 3, - MYSQL_PROTOCOL_MEMORY = 4, - }; -# 224 "mysql.h" -enum mysql_rpl_type - { - MYSQL_RPL_MASTER = 0, - MYSQL_RPL_SLAVE = 1, - MYSQL_RPL_ADMIN = 2, - }; -# 209 "mysql.h" -enum mysql_status - { - MYSQL_STATUS_READY = 0, - MYSQL_STATUS_GET_RESULT = 1, - MYSQL_STATUS_USE_RESULT = 2, - }; -# 365 "mysql_com.h" -extern my_bool check_scramble(char const * reply, char const * message, unsigned char const * hash_stage2); -# 358 "mysql_com.h" -extern my_bool check_scramble_323(char const *, char const * message, unsigned long int * salt); -# 353 "mysql_com.h" -extern void create_random_string(char * to, unsigned int, struct rand_struct * rand_st); -# 28 "typelib.h" -extern int find_type(char * x, TYPELIB * typelib, unsigned int); -# 367 "mysql_com.h" -extern void get_salt_from_password(unsigned char * res, char const * password); -# 360 "mysql_com.h" -extern void get_salt_from_password_323(unsigned long int * res, char const * password); -# 372 "mysql_com.h" -extern char * get_tty_password(char * opt_message); -# 30 "typelib.h" -extern char const * get_type(TYPELIB * typelib, unsigned int); -# 355 "mysql_com.h" -extern void hash_password(unsigned long int * to, char const * password, unsigned int); -# 31 "my_list.h" -extern LIST * list_add(LIST * root, LIST * element); -# 33 "my_list.h" -extern LIST * list_cons(void * data, LIST * root); -# 32 "my_list.h" -extern LIST * list_delete(LIST * root, LIST * element); -# 35 "my_list.h" -extern void list_free(LIST * root, unsigned int); -# 36 "my_list.h" -extern unsigned int list_length(LIST *); -# 34 "my_list.h" -extern LIST * list_reverse(LIST * root); -# 37 "my_list.h" -extern int list_walk(LIST *, list_walk_action, gptr); -# 378 "mysql_com.h" -extern int load_defaults(char const * conf_file, char const * * groups, int * argc, char * * * argv); -# 368 "mysql_com.h" -extern void make_password_from_salt(char * to, unsigned char const * hash_stage2); -# 361 "mysql_com.h" -extern void make_password_from_salt_323(char * to, unsigned long int const * salt); -# 363 "mysql_com.h" -extern void make_scrambled_password(char * to, char const * password); -# 356 "mysql_com.h" -extern void make_scrambled_password_323(char * to, char const * password); -# 29 "typelib.h" -extern void make_type(char * to, unsigned int, TYPELIB * typelib); -# 299 "mysql_com.h" -extern int my_connect(my_socket, struct sockaddr const * name, unsigned int, unsigned int); -# 377 "mysql_com.h" -extern my_bool my_init(void); -# 281 "mysql_com.h" -extern my_bool my_net_init(NET * net, Vio * vio); -# 282 "mysql_com.h" -extern void my_net_local_init(NET * net); -# 292 "mysql_com.h" -extern unsigned long int my_net_read(NET * net); -# 287 "mysql_com.h" -extern my_bool my_net_write(NET * net, char const * packet, unsigned long int); -# 352 "mysql_com.h" -extern double my_rnd(struct rand_struct *); -# 381 "mysql_com.h" -extern void my_thread_end(void); -# 380 "mysql_com.h" -extern my_bool my_thread_init(void); -# 539 "mysql.h" -extern void myodbc_remove_escape(MYSQL * mysql, char * name); -# 481 "mysql.h" -extern int mysql_add_slave(MYSQL * mysql, char const * host, unsigned int, char const * user, char const * passwd); -# 393 "mysql.h" -extern my_ulonglong mysql_affected_rows(MYSQL * mysql); -# 720 "mysql.h" -extern my_bool mysql_autocommit(MYSQL * mysql, my_bool); -# 408 "mysql.h" -extern my_bool mysql_change_user(MYSQL * mysql, char const * user, char const * passwd, char const * db); -# 401 "mysql.h" -extern char const * mysql_character_set_name(MYSQL * mysql); -# 723 "mysql.h" -extern void mysql_close(MYSQL * sock); -# 718 "mysql.h" -extern my_bool mysql_commit(MYSQL * mysql); -# 510 "mysql.h" -extern void mysql_data_seek(MYSQL_RES * result, my_ulonglong); -# 528 "mysql.h" -extern void mysql_debug(char const * debug); -# 467 "mysql.h" -extern void mysql_disable_reads_from_master(MYSQL * mysql); -# 461 "mysql.h" -extern void mysql_disable_rpl_parse(MYSQL * mysql); -# 489 "mysql.h" -extern int mysql_dump_debug_info(MYSQL * mysql); -# 541 "mysql.h" -extern my_bool mysql_embedded(void); -# 466 "mysql.h" -extern void mysql_enable_reads_from_master(MYSQL * mysql); -# 460 "mysql.h" -extern void mysql_enable_rpl_parse(MYSQL * mysql); -# 385 "mysql.h" -extern my_bool mysql_eof(MYSQL_RES * res); -# 395 "mysql.h" -extern unsigned int mysql_errno(MYSQL * mysql); -# 373 "mysql_com.h" -extern char const * mysql_errno_to_sqlstate(unsigned int); -# 396 "mysql.h" -extern char const * mysql_error(MYSQL * mysql); -# 521 "mysql.h" -extern unsigned long int mysql_escape_string(char * to, char const * from, unsigned long int); -# 518 "mysql.h" -extern MYSQL_FIELD * mysql_fetch_field(MYSQL_RES * result); -# 386 "mysql.h" -extern MYSQL_FIELD * mysql_fetch_field_direct(MYSQL_RES * res, unsigned int); -# 388 "mysql.h" -extern MYSQL_FIELD * mysql_fetch_fields(MYSQL_RES * res); -# 517 "mysql.h" -extern unsigned long int * mysql_fetch_lengths(MYSQL_RES * result); -# 516 "mysql.h" -extern MYSQL_ROW mysql_fetch_row(MYSQL_RES * result); -# 392 "mysql.h" -extern unsigned int mysql_field_count(MYSQL * mysql); -# 514 "mysql.h" -extern MYSQL_FIELD_OFFSET mysql_field_seek(MYSQL_RES * result, MYSQL_FIELD_OFFSET); -# 390 "mysql.h" -extern MYSQL_FIELD_OFFSET mysql_field_tell(MYSQL_RES * res); -# 509 "mysql.h" -extern void mysql_free_result(MYSQL_RES * result); -# 499 "mysql.h" -extern char const * mysql_get_client_info(void); -# 500 "mysql.h" -extern unsigned long int mysql_get_client_version(void); -# 501 "mysql.h" -extern char const * mysql_get_host_info(MYSQL * mysql); -# 367 "mysql.h" -extern MYSQL_PARAMETERS * mysql_get_parameters(void); -# 503 "mysql.h" -extern unsigned int mysql_get_proto_info(MYSQL * mysql); -# 498 "mysql.h" -extern char const * mysql_get_server_info(MYSQL * mysql); -# 502 "mysql.h" -extern unsigned long int mysql_get_server_version(MYSQL * mysql); -# 523 "mysql.h" -extern unsigned long int mysql_hex_string(char * to, char const * from, unsigned long int); -# 399 "mysql.h" -extern char const * mysql_info(MYSQL * mysql); -# 404 "mysql.h" -extern MYSQL * mysql_init(MYSQL * mysql); -# 394 "mysql.h" -extern my_ulonglong mysql_insert_id(MYSQL * mysql); -# 492 "mysql.h" -extern int mysql_kill(MYSQL * mysql, unsigned long int); -# 504 "mysql.h" -extern MYSQL_RES * mysql_list_dbs(MYSQL * mysql, char const * wild); -# 519 "mysql.h" -extern MYSQL_RES * mysql_list_fields(MYSQL * mysql, char const * table, char const * wild); -# 506 "mysql.h" -extern MYSQL_RES * mysql_list_processes(MYSQL * mysql); -# 505 "mysql.h" -extern MYSQL_RES * mysql_list_tables(MYSQL * mysql, char const * wild); -# 548 "mysql.h" -extern void mysql_manager_close(MYSQL_MANAGER * con); -# 549 "mysql.h" -extern int mysql_manager_command(MYSQL_MANAGER * con, char const * cmd, int); -# 543 "mysql.h" -extern MYSQL_MANAGER * mysql_manager_connect(MYSQL_MANAGER * con, char const * host, char const * user, char const * passwd, unsigned int); -# 551 "mysql.h" -extern int mysql_manager_fetch_line(MYSQL_MANAGER * con, char * res_buf, int); -# 542 "mysql.h" -extern MYSQL_MANAGER * mysql_manager_init(MYSQL_MANAGER * con); -# 427 "mysql.h" -extern my_bool mysql_master_query(MYSQL * mysql, char const * q, unsigned long int); -# 429 "mysql.h" -extern my_bool mysql_master_send_query(MYSQL * mysql, char const * q, unsigned long int); -# 721 "mysql.h" -extern my_bool mysql_more_results(MYSQL * mysql); -# 722 "mysql.h" -extern int mysql_next_result(MYSQL * mysql); -# 384 "mysql.h" -extern unsigned int mysql_num_fields(MYSQL_RES * res); -# 383 "mysql.h" -extern my_ulonglong mysql_num_rows(MYSQL_RES * res); -# 529 "mysql.h" -extern char * mysql_odbc_escape_string(MYSQL * mysql, char * to, unsigned long int, char const * from, unsigned long int, void * param, char * (* extend_buffer)(void *, char * to, unsigned long int * length)); -# 507 "mysql.h" -extern int mysql_options(MYSQL * mysql, enum mysql_option, char const * arg); -# 496 "mysql.h" -extern int mysql_ping(MYSQL * mysql); -# 75 "mysql.h" -extern unsigned int mysql_port; -# 418 "mysql.h" -extern int mysql_query(MYSQL * mysql, char const * q); -# 554 "mysql.h" -extern my_bool mysql_read_query_result(MYSQL * mysql); -# 469 "mysql.h" -extern my_bool mysql_reads_from_master_enabled(MYSQL * mysql); -# 410 "mysql.h" -extern MYSQL * mysql_real_connect(MYSQL * mysql, char const * host, char const * user, char const * passwd, char const * db, unsigned int, char const * unix_socket, unsigned long int); -# 525 "mysql.h" -extern unsigned long int mysql_real_escape_string(MYSQL * mysql, char * to, char const * from, unsigned long int); -# 421 "mysql.h" -extern int mysql_real_query(MYSQL * mysql, char const * q, unsigned long int); -# 490 "mysql.h" -extern int mysql_refresh(MYSQL * mysql, unsigned int); -# 719 "mysql.h" -extern my_bool mysql_rollback(MYSQL * mysql); -# 512 "mysql.h" -extern MYSQL_ROW_OFFSET mysql_row_seek(MYSQL_RES * result, MYSQL_ROW_OFFSET); -# 389 "mysql.h" -extern MYSQL_ROW_OFFSET mysql_row_tell(MYSQL_RES * res); -# 463 "mysql.h" -extern int mysql_rpl_parse_enabled(MYSQL * mysql); -# 474 "mysql.h" -extern my_bool mysql_rpl_probe(MYSQL * mysql); -# 471 "mysql.h" -extern enum mysql_rpl_type mysql_rpl_query_type(char const * q, int); -# 417 "mysql.h" -extern int mysql_select_db(MYSQL * mysql, char const * db); -# 419 "mysql.h" -extern int mysql_send_query(MYSQL * mysql, char const * q, unsigned long int); -# 354 "mysql.h" -extern void mysql_server_end(void); -# 353 "mysql.h" -extern int mysql_server_init(int, char * * argv, char * * groups); -# 402 "mysql.h" -extern int mysql_set_character_set(MYSQL * mysql, char const * csname); -# 452 "mysql.h" -extern void mysql_set_local_infile_default(MYSQL * mysql); -# 441 "mysql.h" -extern void mysql_set_local_infile_handler(MYSQL * mysql, int (* local_infile_init)(void * *, char const *, void *), int (* local_infile_read)(void *, char *, unsigned int), void (* local_infile_end)(void), int (* local_infile_error)(void *, char *, unsigned int), void *); -# 477 "mysql.h" -extern int mysql_set_master(MYSQL * mysql, char const * host, unsigned int, char const * user, char const * passwd); -# 493 "mysql.h" -extern int mysql_set_server_option(MYSQL * mysql, enum enum_mysql_set_option); -# 486 "mysql.h" -extern int mysql_shutdown(MYSQL * mysql, enum mysql_enum_shutdown_level); -# 432 "mysql.h" -extern my_bool mysql_slave_query(MYSQL * mysql, char const * q, unsigned long int); -# 434 "mysql.h" -extern my_bool mysql_slave_send_query(MYSQL * mysql, char const * q, unsigned long int); -# 397 "mysql.h" -extern char const * mysql_sqlstate(MYSQL * mysql); -# 405 "mysql.h" -extern my_bool mysql_ssl_set(MYSQL * mysql, char const * key, char const * cert, char const * ca, char const * capath, char const * cipher); -# 497 "mysql.h" -extern char const * mysql_stat(MYSQL * mysql); -# 714 "mysql.h" -extern my_ulonglong mysql_stmt_affected_rows(MYSQL_STMT * stmt); -# 692 "mysql.h" -extern my_bool mysql_stmt_attr_get(MYSQL_STMT * stmt, enum enum_stmt_attr_type, void * attr); -# 689 "mysql.h" -extern my_bool mysql_stmt_attr_set(MYSQL_STMT * stmt, enum enum_stmt_attr_type, void const * attr); -# 695 "mysql.h" -extern my_bool mysql_stmt_bind_param(MYSQL_STMT * stmt, MYSQL_BIND * bnd); -# 696 "mysql.h" -extern my_bool mysql_stmt_bind_result(MYSQL_STMT * stmt, MYSQL_BIND * bnd); -# 697 "mysql.h" -extern my_bool mysql_stmt_close(MYSQL_STMT * stmt); -# 712 "mysql.h" -extern void mysql_stmt_data_seek(MYSQL_STMT * stmt, my_ulonglong); -# 706 "mysql.h" -extern unsigned int mysql_stmt_errno(MYSQL_STMT * stmt); -# 707 "mysql.h" -extern char const * mysql_stmt_error(MYSQL_STMT * stmt); -# 682 "mysql.h" -extern int mysql_stmt_execute(MYSQL_STMT * stmt); -# 683 "mysql.h" -extern int mysql_stmt_fetch(MYSQL_STMT * stmt); -# 684 "mysql.h" -extern int mysql_stmt_fetch_column(MYSQL_STMT * stmt, MYSQL_BIND * bind, unsigned int, unsigned long int); -# 716 "mysql.h" -extern unsigned int mysql_stmt_field_count(MYSQL_STMT * stmt); -# 699 "mysql.h" -extern my_bool mysql_stmt_free_result(MYSQL_STMT * stmt); -# 679 "mysql.h" -extern MYSQL_STMT * mysql_stmt_init(MYSQL * mysql); -# 715 "mysql.h" -extern my_ulonglong mysql_stmt_insert_id(MYSQL_STMT * stmt); -# 713 "mysql.h" -extern my_ulonglong mysql_stmt_num_rows(MYSQL_STMT * stmt); -# 688 "mysql.h" -extern unsigned long int mysql_stmt_param_count(MYSQL_STMT * stmt); -# 705 "mysql.h" -extern MYSQL_RES * mysql_stmt_param_metadata(MYSQL_STMT * stmt); -# 680 "mysql.h" -extern int mysql_stmt_prepare(MYSQL_STMT * stmt, char const * query, unsigned long int); -# 698 "mysql.h" -extern my_bool mysql_stmt_reset(MYSQL_STMT * stmt); -# 704 "mysql.h" -extern MYSQL_RES * mysql_stmt_result_metadata(MYSQL_STMT * stmt); -# 709 "mysql.h" -extern MYSQL_ROW_OFFSET mysql_stmt_row_seek(MYSQL_STMT * stmt, MYSQL_ROW_OFFSET); -# 711 "mysql.h" -extern MYSQL_ROW_OFFSET mysql_stmt_row_tell(MYSQL_STMT * stmt); -# 700 "mysql.h" -extern my_bool mysql_stmt_send_long_data(MYSQL_STMT * stmt, unsigned int, char const * data, unsigned long int); -# 708 "mysql.h" -extern char const * mysql_stmt_sqlstate(MYSQL_STMT * stmt); -# 687 "mysql.h" -extern int mysql_stmt_store_result(MYSQL_STMT * stmt); -# 423 "mysql.h" -extern MYSQL_RES * mysql_store_result(MYSQL * mysql); -# 376 "mysql.h" -extern void mysql_thread_end(void); -# 400 "mysql.h" -extern unsigned long int mysql_thread_id(MYSQL * mysql); -# 375 "mysql.h" -extern my_bool mysql_thread_init(void); -# 540 "mysql.h" -extern unsigned int mysql_thread_safe(void); -# 76 "mysql.h" -extern char * mysql_unix_port; -# 424 "mysql.h" -extern MYSQL_RES * mysql_use_result(MYSQL * mysql); -# 398 "mysql.h" -extern unsigned int mysql_warning_count(MYSQL * mysql); -# 284 "mysql_com.h" -extern void net_clear(NET * net); -# 283 "mysql_com.h" -extern void net_end(NET * net); -# 286 "mysql_com.h" -extern my_bool net_flush(NET * net); -# 291 "mysql_com.h" -extern int net_real_write(NET * net, char const * packet, unsigned long int); -# 285 "mysql_com.h" -extern my_bool net_realloc(NET * net, unsigned long int); -# 751 "mysql.h" -extern unsigned long int net_safe_read(MYSQL * mysql); -# 288 "mysql_com.h" -extern my_bool net_write_command(NET * net, unsigned char, char const * header, unsigned long int, char const * packet, unsigned long int); -# 350 "mysql_com.h" -extern void randominit(struct rand_struct *, unsigned long int, unsigned long int); -# 364 "mysql_com.h" -extern void scramble(char * to, char const * message, char const * password); -# 357 "mysql_com.h" -extern void scramble_323(char * to, char const * message, char const * password); -# 32 "typelib.h" -extern TYPELIB sql_protocol_typelib; From 73ff367be3b8e38d7e58830f8496f9c9033c1ab5 Mon Sep 17 00:00:00 2001 From: "iggy@rolltop.ignatz42.dyndns.org" <> Date: Fri, 10 Nov 2006 15:47:11 -0500 Subject: [PATCH 015/131] Test Suite failing on Windows because the $opt_report_features variable was not defined before use. --- mysql-test/mysql-test-run.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 9bf0f8df632..5fedf1f8b40 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -215,6 +215,7 @@ our $opt_ndbcluster_port_slave; our $opt_ndbconnectstring_slave; our $opt_record; +our $opt_report_features; our $opt_check_testcases; our $opt_skip; From 72dfd02634ad7eb076548a739784d83972f7a661 Mon Sep 17 00:00:00 2001 From: "cmiller@zippy.cornsilk.net" <> Date: Fri, 10 Nov 2006 16:36:08 -0500 Subject: [PATCH 016/131] Bug #22860: Option --memlock should be revisited Support says that memlock doesn't work on OSes other than Solaris. Add a warning about --memlock to the crash monologue. --- BitKeeper/etc/collapsed | 2 ++ sql/mysqld.cc | 27 +++++++++++++++++++-------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/BitKeeper/etc/collapsed b/BitKeeper/etc/collapsed index 37c2793cc12..3b45bb4f30c 100644 --- a/BitKeeper/etc/collapsed +++ b/BitKeeper/etc/collapsed @@ -1,3 +1,5 @@ 452a92d0-31-8wSzSfZi165fcGcXPA 454a7ef8gdvE_ddMlJyghvOAkKPNOQ 454f8960jsVT_kMKJtZ9OCgXoba0xQ +4554a95d7txO1DuO9G3nAizI3SkFAA +4554b3722d71SbPiI2Gx-RhbZjmuIQ diff --git a/sql/mysqld.cc b/sql/mysqld.cc index dbb1838c3d7..6571717b61d 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -274,7 +274,7 @@ bool opt_disable_networking=0, opt_skip_show_db=0; bool opt_character_set_client_handshake= 1; bool lower_case_table_names_used= 0; bool server_id_supplied = 0; -bool opt_endinfo,using_udf_functions, locked_in_memory; +bool opt_endinfo, using_udf_functions, locked_in_memory; bool opt_using_transactions, using_update_log; bool volatile abort_loop, select_thread_in_use, signal_thread_in_use; bool volatile ready_to_exit, shutdown_in_progress, grant_option; @@ -2015,13 +2015,24 @@ later when used with nscd), disable LDAP in your nsswitch.conf, or use a\n\ mysqld that is not statically linked.\n"); #endif - if (test_flags & TEST_CORE_ON_SIGNAL) - { - fprintf(stderr, "Writing a core file\n"); - fflush(stderr); - write_core(sig); - } - exit(1); + if (locked_in_memory) + { + fprintf(stderr, "\n\ +The \"--memlock\" argument, which was enabled, uses system calls that are\n\ +unreliable and unstable on some operating systems and operating-system\n\ +versions (notably, some versions of Linux). This crash could be due to use\n\ +of those buggy OS calls. You should consider whether you really need the\n\ +\"--memlock\" parameter and/or consult the OS distributer about \"mlockall\"\n\ +bugs.\n"); + } + + if (test_flags & TEST_CORE_ON_SIGNAL) + { + fprintf(stderr, "Writing a core file\n"); + fflush(stderr); + write_core(sig); + } + exit(1); } #ifndef SA_RESETHAND From 716621db3f3055781e24f561325cec6eac181717 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 13 Nov 2006 12:44:12 +0100 Subject: [PATCH 017/131] Make --mem a pure flag. If there is need to specifically set the location use MTR_MEM environment variable --- mysql-test/mysql-test-run.pl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 7809f582ef9..7758d5ee5a6 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -667,7 +667,7 @@ sub command_line_setup () { 'tmpdir=s' => \$opt_tmpdir, 'vardir=s' => \$opt_vardir, 'benchdir=s' => \$glob_mysql_bench_dir, - 'mem:s' => \$opt_mem, + 'mem' => \$opt_mem, # Misc 'comment=s' => \$opt_comment, @@ -4632,9 +4632,9 @@ Options to control directories to use vardir=DIR The directory where files generated from the test run is stored (default: ./var). Specifying a ramdisk or tmpfs will speed up tests. - mem[=DIR] Run testsuite in "memory" using tmpfs or ramdisk - Attempts to use DIR first if specified else - uses as builtin list of standard locations + mem Run testsuite in "memory" using tmpfs or ramdisk + Attempts to find a suitable location + using a builtin list of standard locations for tmpfs (/dev/shm) The option can also be set using environment variable MTR_MEM=[DIR] From 0ef85c5d8d260d208a5eb2f03b3eb8f94eacf8df Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 13 Nov 2006 13:32:39 +0100 Subject: [PATCH 018/131] Remove the tmp file produced when checking abi --- include/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/include/Makefile.am b/include/Makefile.am index a17ef377e78..3a3b319505c 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -69,6 +69,7 @@ abi_check: mysql.h mysql_version.h mysql_com.h mysql_time.h my_list.h \ if [ @ICHECK@ != no ] ; then \ @ICHECK@ --canonify --skip-from-re /usr/ -o $@.ic mysql.h; \ @ICHECK@ --compare mysql_h.ic $@.ic; \ + $(RM) -f $@.ic; \ fi; \ touch abi_check; From 4a28dcecea06a749a9fa1d6df52b59cadf640f85 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 13 Nov 2006 13:36:07 +0100 Subject: [PATCH 019/131] Bug#23984 mysqltest on HP-UX - Cleanup the Makefile for client - Don't link mysqltest with mysys as it's been compiled with different flags. --- client/Makefile.am | 83 +++++++++++++++++++++++++++++----------------- 1 file changed, 53 insertions(+), 30 deletions(-) diff --git a/client/Makefile.am b/client/Makefile.am index 7d48e34b37b..48dc68ff704 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -1,15 +1,15 @@ # Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult 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 @@ -28,57 +28,81 @@ else LIBMYSQLCLIENT_LA = $(top_builddir)/libmysql/libmysqlclient.la endif -#AUTOMAKE_OPTIONS = nostdinc INCLUDES = -I$(top_builddir)/include \ -I$(top_srcdir)/include \ -I$(top_srcdir)/regex \ $(openssl_includes) + LIBS = @CLIENT_LIBS@ + LDADD= @CLIENT_EXTRA_LDFLAGS@ $(CLIENT_THREAD_LIBS) \ $(top_builddir)/libmysql/libmysqlclient.la -bin_PROGRAMS = mysql mysqladmin mysqlcheck mysqlshow \ - mysqldump mysqlimport mysqltest mysqlbinlog \ - mysqlslap mysql_upgrade + noinst_HEADERS = sql_string.h completion_hash.h my_readline.h \ client_priv.h -mysql_SOURCES = mysql.cc readline.cc sql_string.cc completion_hash.cc -mysqladmin_SOURCES = mysqladmin.cc -mysql_LDADD = @readline_link@ @TERMCAP_LIB@ $(LDADD) $(CXXLDFLAGS) -mysqltest_SOURCES= mysqltest.c $(top_srcdir)/mysys/my_getsystime.c \ - $(yassl_dummy_link_fix) -mysqltest_LDADD = $(top_builddir)/regex/libregex.a $(LDADD) \ - $(top_builddir)/mysys/libmysys.a -mysqlbinlog_SOURCES = mysqlbinlog.cc $(top_srcdir)/mysys/mf_tempdir.c \ + +EXTRA_DIST = get_password.c CMakeLists.txt + +bin_PROGRAMS = mysql \ + mysqladmin \ + mysqlbinlog \ + mysqlcheck \ + mysqldump \ + mysqlimport \ + mysqlshow \ + mysqlslap \ + mysqltest \ + mysql_upgrade + +mysql_SOURCES = mysql.cc readline.cc sql_string.cc \ + completion_hash.cc +mysql_LDADD = @readline_link@ @TERMCAP_LIB@ \ + $(LDADD) $(CXXLDFLAGS) + +mysqlbinlog_SOURCES = mysqlbinlog.cc \ + $(top_srcdir)/mysys/mf_tempdir.c \ $(top_srcdir)/mysys/my_new.cc \ $(top_srcdir)/mysys/my_bit.c \ $(top_srcdir)/mysys/my_bitmap.c \ $(top_srcdir)/mysys/my_vle.c \ $(top_srcdir)/mysys/base64.c mysqlbinlog_LDADD = $(LDADD) $(CXXLDFLAGS) -mysqlslap_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \ - @CLIENT_EXTRA_LDFLAGS@ \ - $(LIBMYSQLCLIENT_LA) \ - $(top_builddir)/mysys/libmysys.a + +mysqldump_SOURCES= mysqldump.c \ + my_user.c \ + $(top_srcdir)/mysys/mf_getdate.c \ + $(yassl_dummy_link_fix) + +mysqlimport_SOURCES= mysqlimport.c $(yassl_dummy_link_fix) + mysqlimport_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \ @CLIENT_EXTRA_LDFLAGS@ \ $(LIBMYSQLCLIENT_LA) \ - $(top_builddir)/mysys/libmysys.a -mysqlcheck_SOURCES= mysqlcheck.c $(yassl_dummy_link_fix) + $(top_builddir)/mysys/libmysys.a + mysqlshow_SOURCES= mysqlshow.c $(yassl_dummy_link_fix) + mysqlslap_SOURCES= mysqlslap.c $(yassl_dummy_link_fix) -mysqldump_SOURCES= mysqldump.c my_user.c \ - $(top_srcdir)/mysys/mf_getdate.c \ - $(yassl_dummy_link_fix) -mysqlimport_SOURCES= mysqlimport.c $(yassl_dummy_link_fix) +mysqlslap_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \ + @CLIENT_EXTRA_LDFLAGS@ \ + $(LIBMYSQLCLIENT_LA) \ + $(top_builddir)/mysys/libmysys.a + +mysqltest_SOURCES= mysqltest.c \ + $(top_srcdir)/mysys/my_getsystime.c \ + $(top_srcdir)/mysys/my_copy.c \ + $(yassl_dummy_link_fix) +mysqltest_LDADD = $(top_builddir)/regex/libregex.a $(LDADD) + mysql_upgrade_SOURCES= mysql_upgrade.c $(yassl_dummy_link_fix) -sql_src=log_event.h mysql_priv.h log_event.cc my_decimal.h my_decimal.cc -strings_src=decimal.c # Fix for mit-threads DEFS = -DUNDEF_THREADS_HACK \ -DDEFAULT_MYSQL_HOME="\"$(prefix)\"" \ - -DDATADIR="\"$(localstatedir)\"" -EXTRA_DIST = get_password.c CMakeLists.txt + -DDATADIR="\"$(localstatedir)\"" + +sql_src=log_event.h mysql_priv.h log_event.cc my_decimal.h my_decimal.cc +strings_src=decimal.c link_sources: for f in $(sql_src) ; do \ @@ -92,6 +116,5 @@ link_sources: rm -f $(srcdir)/my_user.c; \ @LN_CP_F@ $(top_srcdir)/sql-common/my_user.c my_user.c; - # Don't update the files from bitkeeper %::SCCS/s.% From 5110d91ec34b877a8302ad76797f61188534a48d Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 13 Nov 2006 13:39:49 +0100 Subject: [PATCH 020/131] Make it possible for .test suites to run "mysql_upgrade" Add new test file mysql_upgrade.test --- client/mysql_upgrade.c | 4 +- include/abi_check.ic | 914 ------------------------------ mysql-test/mysql-test-run.pl | 54 +- mysql-test/r/mysql_upgrade.result | 127 +++++ mysql-test/t/mysql_upgrade.test | 20 + 5 files changed, 198 insertions(+), 921 deletions(-) delete mode 100644 include/abi_check.ic create mode 100644 mysql-test/r/mysql_upgrade.result create mode 100644 mysql-test/t/mysql_upgrade.test diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index b8344606448..deeeb47851d 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -546,7 +546,7 @@ int main(int argc, char **argv) } if (find_file(mysqlcheck_name, basedir, MYF(0), path, sizeof(path), - "bin", NullS)) + "bin", "client", NullS)) { ret= 1; printf("Can't find program '%s'\n", mysqlcheck_name); @@ -583,7 +583,7 @@ int main(int argc, char **argv) fix_priv_tables: if (find_file(mysql_name, basedir, MYF(0), path, sizeof(path), - "bin", NullS)) + "bin", "client", NullS)) { ret= 1; puts("Could not find MySQL command-line client (mysql).\n" diff --git a/include/abi_check.ic b/include/abi_check.ic deleted file mode 100644 index 30ef44a1ccb..00000000000 --- a/include/abi_check.ic +++ /dev/null @@ -1,914 +0,0 @@ -struct rand_struct; -struct st_list; -struct st_mem_root; -struct st_mysql; -struct st_mysql_bind; -struct st_mysql_data; -struct st_mysql_field; -struct st_mysql_manager; -struct st_mysql_methods; -struct st_mysql_options; -struct st_mysql_parameters; -struct st_mysql_res; -struct st_mysql_rows; -struct st_mysql_stmt; -struct st_mysql_time; -struct st_net; -struct st_typelib; -struct st_udf_args; -struct st_udf_init; -struct st_used_mem; -enum Item_result; -enum enum_field_types; -enum enum_mysql_set_option; -enum enum_mysql_stmt_state; -enum enum_mysql_timestamp_type; -enum enum_server_command; -enum enum_stmt_attr_type; -enum mysql_enum_shutdown_level; -enum mysql_option; -enum mysql_protocol_type; -enum mysql_rpl_type; -enum mysql_status; -# 131 "mysql.h" -typedef struct st_mysql_rows MYSQL_ROWS; -# 24 "my_list.h" -typedef struct st_list LIST; -# 232 "mysql.h" -typedef struct st_mysql MYSQL; -# 571 "mysql.h" -typedef struct st_mysql_bind MYSQL_BIND; -# 93 "mysql.h" -typedef struct st_mysql_field MYSQL_FIELD; -# 117 "mysql.h" -typedef unsigned int MYSQL_FIELD_OFFSET; -# 323 "mysql.h" -typedef struct st_mysql_manager MYSQL_MANAGER; -# 337 "mysql.h" -typedef struct st_mysql_parameters MYSQL_PARAMETERS; -# 292 "mysql.h" -typedef struct st_mysql_res MYSQL_RES; -# 116 "mysql.h" -typedef char * * MYSQL_ROW; -# 137 "mysql.h" -typedef MYSQL_ROWS * MYSQL_ROW_OFFSET; -# 596 "mysql.h" -typedef struct st_mysql_stmt MYSQL_STMT; -# 151 "mysql_com.h" -typedef struct st_net NET; -# 21 "typelib.h" -typedef struct st_typelib TYPELIB; -# 141 "mysql_com.h" -typedef struct st_vio Vio; -# 57 "mysql.h" -typedef char * gptr; -# 29 "my_list.h" -typedef int (* list_walk_action)(void *, void *); -# 48 "mysql.h" -typedef char my_bool; -# 63 "mysql.h" -typedef int my_socket; -# 125 "mysql.h" -typedef unsigned long long int my_ulonglong; -# 35 "my_alloc.h" -typedef struct st_mem_root MEM_ROOT; -# 141 "mysql.h" -typedef struct st_mysql_data MYSQL_DATA; -# 648 "mysql.h" -typedef struct st_mysql_methods MYSQL_METHODS; -# 48 "mysql_time.h" -typedef struct st_mysql_time MYSQL_TIME; -# 315 "mysql_com.h" -typedef struct st_udf_args UDF_ARGS; -# 326 "mysql_com.h" -typedef struct st_udf_init UDF_INIT; -# 27 "my_alloc.h" -typedef struct st_used_mem USED_MEM; -# 302 "mysql_com.h" -struct __attribute__((aligned(__alignof__(unsigned long int)), aligned(__alignof__(double)))) rand_struct - { - unsigned long int seed1; - unsigned long int seed2; - unsigned long int max_value; - double max_value_dbl; - }; -# 24 "my_list.h" -struct __attribute__((aligned(__alignof__(void *)))) st_list - { - struct st_list * prev; - struct st_list * next; - void * data; - }; -# 35 "my_alloc.h" -struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned int)))) st_mem_root - { - USED_MEM * free; - USED_MEM * used; - USED_MEM * pre_alloc; - unsigned int min_malloc; - unsigned int block_size; - unsigned int block_num; - unsigned int first_block_usage; - void (* error_handler)(void); - }; -# 232 "mysql.h" -struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned long long int)))) st_mysql - { - NET net; - gptr connector_fd; - char * host; - char * user; - char * passwd; - char * unix_socket; - char * server_version; - char * host_info; - char * info; - char * db; - struct charset_info_st * charset; - MYSQL_FIELD * fields; - MEM_ROOT field_alloc; - my_ulonglong affected_rows; - my_ulonglong insert_id; - my_ulonglong extra_info; - unsigned long int thread_id; - unsigned long int packet_length; - unsigned int port; - unsigned long int client_flag; - unsigned long int server_capabilities; - unsigned int protocol_version; - unsigned int field_count; - unsigned int server_status; - unsigned int server_language; - unsigned int warning_count; - struct st_mysql_options options; - enum mysql_status status; - my_bool free_me; - my_bool reconnect; - char scramble[(20 + 1)]; - my_bool rpl_pivot; - struct st_mysql * master; - struct st_mysql * next_slave; - struct st_mysql * last_used_slave; - struct st_mysql * last_used_con; - LIST * stmts; - struct st_mysql_methods const * methods; - void * thd; - my_bool * unbuffered_fetch_owner; - struct st_mysql_stmt * current_stmt; - }; -# 571 "mysql.h" -struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned long int)))) st_mysql_bind - { - unsigned long int * length; - my_bool * is_null; - void * buffer; - enum enum_field_types buffer_type; - unsigned long int buffer_length; - unsigned char * inter_buffer; - unsigned long int offset; - unsigned long int internal_length; - unsigned int param_number; - unsigned int pack_length; - my_bool is_unsigned; - my_bool long_data_used; - my_bool internal_is_null; - void (* store_param_func)(NET * net, struct st_mysql_bind * param); - void (* fetch_result)(struct st_mysql_bind *, unsigned char * * row); - void (* skip_result)(struct st_mysql_bind *, MYSQL_FIELD *, unsigned char * * row); - }; -# 141 "mysql.h" -struct __attribute__((aligned(__alignof__(unsigned long long int)), aligned(__alignof__(void *)))) st_mysql_data - { - my_ulonglong rows; - unsigned int fields; - MYSQL_ROWS * data; - MEM_ROOT alloc; - MYSQL_ROWS * * prev_ptr; - }; -# 93 "mysql.h" -struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned long int)))) st_mysql_field - { - char * name; - char * org_name; - char * table; - char * org_table; - char * db; - char * catalog; - char * def; - unsigned long int length; - unsigned long int max_length; - unsigned int name_length; - unsigned int org_name_length; - unsigned int table_length; - unsigned int org_table_length; - unsigned int db_length; - unsigned int catalog_length; - unsigned int def_length; - unsigned int flags; - unsigned int decimals; - unsigned int charsetnr; - enum enum_field_types type; - }; -# 323 "mysql.h" -struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned long int)))) st_mysql_manager - { - NET net; - char * host; - char * user; - char * passwd; - unsigned int port; - my_bool free_me; - my_bool eof; - int cmd_status; - int last_errno; - char * net_buf; - char * net_buf_pos; - char * net_data_end; - int net_buf_size; - char last_error[256]; - }; -# 648 "mysql.h" -struct __attribute__((aligned(__alignof__(void *)))) st_mysql_methods - { - my_bool (* read_query_result)(MYSQL * mysql); - my_bool (* advanced_command)(MYSQL * mysql, enum enum_server_command, char const * header, unsigned long int, char const * arg, unsigned long int, my_bool, MYSQL_STMT * stmt); - MYSQL_DATA * (* read_rows)(MYSQL * mysql, MYSQL_FIELD * mysql_fields, unsigned int); - MYSQL_RES * (* use_result)(MYSQL * mysql); - void (* fetch_lengths)(unsigned long int * to, MYSQL_ROW, unsigned int); - void (* flush_use_result)(MYSQL * mysql); - MYSQL_FIELD * (* list_fields)(MYSQL * mysql); - my_bool (* read_prepare_result)(MYSQL * mysql, MYSQL_STMT * stmt); - int (* stmt_execute)(MYSQL_STMT * stmt); - int (* read_binary_rows)(MYSQL_STMT * stmt); - int (* unbuffered_fetch)(MYSQL * mysql, char * * row); - void (* free_embedded_thd)(MYSQL * mysql); - char const * (* read_statistics)(MYSQL * mysql); - my_bool (* next_result)(MYSQL * mysql); - int (* read_change_user_result)(MYSQL * mysql, char * buff, char const * passwd); - }; -# 162 "mysql.h" -struct __attribute__((aligned(__alignof__(unsigned long int)), aligned(__alignof__(void *)))) st_mysql_options - { - unsigned int connect_timeout; - unsigned int read_timeout; - unsigned int write_timeout; - unsigned int port; - unsigned int protocol; - unsigned long int client_flag; - char * host; - char * user; - char * password; - char * unix_socket; - char * db; - struct st_dynamic_array * init_commands; - char * my_cnf_file; - char * my_cnf_group; - char * charset_dir; - char * charset_name; - char * ssl_key; - char * ssl_cert; - char * ssl_ca; - char * ssl_capath; - char * ssl_cipher; - char * shared_memory_base_name; - unsigned long int max_allowed_packet; - my_bool use_ssl; - my_bool compress; - my_bool named_pipe; - my_bool rpl_probe; - my_bool rpl_parse; - my_bool no_master_reads; - my_bool separate_thread; - enum mysql_option methods_to_use; - char * client_ip; - my_bool secure_auth; - int (* local_infile_init)(void * *, char const *, void *); - int (* local_infile_read)(void *, char *, unsigned int); - void (* local_infile_end)(void); - int (* local_infile_error)(void *, char *, unsigned int); - void * local_infile_userdata; - }; -# 337 "mysql.h" -struct __attribute__((aligned(__alignof__(void *)))) st_mysql_parameters - { - unsigned long int * p_max_allowed_packet; - unsigned long int * p_net_buffer_length; - }; -# 292 "mysql.h" -struct __attribute__((aligned(__alignof__(unsigned long long int)), aligned(__alignof__(void *)))) st_mysql_res - { - my_ulonglong row_count; - MYSQL_FIELD * fields; - MYSQL_DATA * data; - MYSQL_ROWS * data_cursor; - unsigned long int * lengths; - MYSQL * handle; - MEM_ROOT field_alloc; - unsigned int field_count; - unsigned int current_field; - MYSQL_ROW row; - MYSQL_ROW current_row; - my_bool eof; - my_bool unbuffered_fetch_cancelled; - struct st_mysql_methods const * methods; - }; -# 131 "mysql.h" -struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned long int)))) st_mysql_rows - { - struct st_mysql_rows * next; - MYSQL_ROW data; - unsigned long int length; - }; -# 596 "mysql.h" -struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned long long int)))) st_mysql_stmt - { - MEM_ROOT mem_root; - LIST list; - MYSQL * mysql; - MYSQL_BIND * params; - MYSQL_BIND * bind; - MYSQL_FIELD * fields; - MYSQL_DATA result; - MYSQL_ROWS * data_cursor; - my_ulonglong affected_rows; - my_ulonglong insert_id; - int (* read_row_func)(struct st_mysql_stmt * stmt, unsigned char * * row); - unsigned long int stmt_id; - unsigned int last_errno; - unsigned int param_count; - unsigned int field_count; - enum enum_mysql_stmt_state state; - char last_error[512]; - char sqlstate[(5 + 1)]; - my_bool send_types_to_server; - my_bool bind_param_done; - my_bool bind_result_done; - my_bool unbuffered_fetch_cancelled; - my_bool update_max_length; - }; -# 48 "mysql_time.h" -struct __attribute__((aligned(__alignof__(unsigned long int)))) st_mysql_time - { - unsigned int year; - unsigned int month; - unsigned int day; - unsigned int hour; - unsigned int minute; - unsigned int second; - unsigned long int second_part; - my_bool neg; - enum enum_mysql_timestamp_type time_type; - }; -# 151 "mysql_com.h" -struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned long int)))) st_net - { - Vio * vio; - unsigned char * buff; - unsigned char * buff_end; - unsigned char * write_pos; - unsigned char * read_pos; - my_socket fd; - unsigned long int max_packet; - unsigned long int max_packet_size; - unsigned int pkt_nr; - unsigned int compress_pkt_nr; - unsigned int write_timeout; - unsigned int read_timeout; - unsigned int retry_count; - int fcntl; - my_bool compress; - unsigned long int remain_in_buf; - unsigned long int length; - unsigned long int buf_length; - unsigned long int where_b; - unsigned int * return_status; - unsigned char reading_or_writing; - char save_char; - my_bool no_send_ok; - char last_error[512]; - char sqlstate[(5 + 1)]; - unsigned int last_errno; - unsigned char error; - gptr query_cache_query; - my_bool report_error; - my_bool return_errno; - }; -# 21 "typelib.h" -struct __attribute__((aligned(__alignof__(unsigned int)), aligned(__alignof__(void *)))) st_typelib - { - unsigned int count; - char const * name; - char const * * type_names; - unsigned int * type_lengths; - }; -# 315 "mysql_com.h" -struct __attribute__((aligned(__alignof__(unsigned int)), aligned(__alignof__(void *)))) st_udf_args - { - unsigned int arg_count; - enum Item_result * arg_type; - char * * args; - unsigned long int * lengths; - char * maybe_null; - }; -# 326 "mysql_com.h" -struct __attribute__((aligned(__alignof__(unsigned long int)), aligned(__alignof__(void *)))) st_udf_init - { - my_bool maybe_null; - unsigned int decimals; - unsigned long int max_length; - char * ptr; - my_bool const_item; - }; -# 27 "my_alloc.h" -struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned int)))) st_used_mem - { - struct st_used_mem * next; - unsigned int left; - unsigned int size; - }; -# 313 "mysql_com.h" -enum Item_result - { - STRING_RESULT = 0, - REAL_RESULT = 1, - INT_RESULT = 2, - ROW_RESULT = 3, - }; -# 186 "mysql_com.h" -enum enum_field_types - { - MYSQL_TYPE_DECIMAL = 0, - MYSQL_TYPE_TINY = 1, - MYSQL_TYPE_SHORT = 2, - MYSQL_TYPE_LONG = 3, - MYSQL_TYPE_FLOAT = 4, - MYSQL_TYPE_DOUBLE = 5, - MYSQL_TYPE_NULL = 6, - MYSQL_TYPE_TIMESTAMP = 7, - MYSQL_TYPE_LONGLONG = 8, - MYSQL_TYPE_INT24 = 9, - MYSQL_TYPE_DATE = 10, - MYSQL_TYPE_TIME = 11, - MYSQL_TYPE_DATETIME = 12, - MYSQL_TYPE_YEAR = 13, - MYSQL_TYPE_NEWDATE = 14, - MYSQL_TYPE_ENUM = 247, - MYSQL_TYPE_SET = 248, - MYSQL_TYPE_TINY_BLOB = 249, - MYSQL_TYPE_MEDIUM_BLOB = 250, - MYSQL_TYPE_LONG_BLOB = 251, - MYSQL_TYPE_BLOB = 252, - MYSQL_TYPE_VAR_STRING = 253, - MYSQL_TYPE_STRING = 254, - MYSQL_TYPE_GEOMETRY = 255, - }; -# 269 "mysql_com.h" -enum enum_mysql_set_option - { - MYSQL_OPTION_MULTI_STATEMENTS_ON = 0, - MYSQL_OPTION_MULTI_STATEMENTS_OFF = 1, - }; -# 563 "mysql.h" -enum enum_mysql_stmt_state - { - MYSQL_STMT_INIT_DONE = 1, - MYSQL_STMT_PREPARE_DONE = 2, - MYSQL_STMT_EXECUTE_DONE = 3, - MYSQL_STMT_FETCH_DONE = 4, - }; -# 29 "mysql_time.h" -enum enum_mysql_timestamp_type - { - MYSQL_TIMESTAMP_NONE = -(2), - MYSQL_TIMESTAMP_ERROR = -(1), - MYSQL_TIMESTAMP_DATE = 0, - MYSQL_TIMESTAMP_DATETIME = 1, - MYSQL_TIMESTAMP_TIME = 2, - }; -# 39 "mysql_com.h" -enum enum_server_command - { - COM_SLEEP = 0, - COM_QUIT = 1, - COM_INIT_DB = 2, - COM_QUERY = 3, - COM_FIELD_LIST = 4, - COM_CREATE_DB = 5, - COM_DROP_DB = 6, - COM_REFRESH = 7, - COM_SHUTDOWN = 8, - COM_STATISTICS = 9, - COM_PROCESS_INFO = 10, - COM_CONNECT = 11, - COM_PROCESS_KILL = 12, - COM_DEBUG = 13, - COM_PING = 14, - COM_TIME = 15, - COM_DELAYED_INSERT = 16, - COM_CHANGE_USER = 17, - COM_BINLOG_DUMP = 18, - COM_TABLE_DUMP = 19, - COM_CONNECT_OUT = 20, - COM_REGISTER_SLAVE = 21, - COM_PREPARE = 22, - COM_EXECUTE = 23, - COM_LONG_DATA = 24, - COM_CLOSE_STMT = 25, - COM_RESET_STMT = 26, - COM_SET_OPTION = 27, - COM_END = 28, - }; -# 635 "mysql.h" -enum enum_stmt_attr_type - { - STMT_ATTR_UPDATE_MAX_LENGTH = 0, - }; -# 244 "mysql_com.h" -enum mysql_enum_shutdown_level - { - SHUTDOWN_DEFAULT = 0, - SHUTDOWN_WAIT_CONNECTIONS = (unsigned char)((1 << 0)), - SHUTDOWN_WAIT_TRANSACTIONS = (unsigned char)((1 << 1)), - SHUTDOWN_WAIT_UPDATES = (unsigned char)((1 << 3)), - SHUTDOWN_WAIT_ALL_BUFFERS = ((unsigned char)((1 << 3)) << 1), - SHUTDOWN_WAIT_CRITICAL_BUFFERS = (((unsigned char)((1 << 3)) << 1) + 1), - KILL_CONNECTION = 255, - }; -# 151 "mysql.h" -enum mysql_option - { - MYSQL_OPT_CONNECT_TIMEOUT = 0, - MYSQL_OPT_COMPRESS = 1, - MYSQL_OPT_NAMED_PIPE = 2, - MYSQL_INIT_COMMAND = 3, - MYSQL_READ_DEFAULT_FILE = 4, - MYSQL_READ_DEFAULT_GROUP = 5, - MYSQL_SET_CHARSET_DIR = 6, - MYSQL_SET_CHARSET_NAME = 7, - MYSQL_OPT_LOCAL_INFILE = 8, - MYSQL_OPT_PROTOCOL = 9, - MYSQL_SHARED_MEMORY_BASE_NAME = 10, - MYSQL_OPT_READ_TIMEOUT = 11, - MYSQL_OPT_WRITE_TIMEOUT = 12, - MYSQL_OPT_USE_RESULT = 13, - MYSQL_OPT_USE_REMOTE_CONNECTION = 14, - MYSQL_OPT_USE_EMBEDDED_CONNECTION = 15, - MYSQL_OPT_GUESS_CONNECTION = 16, - MYSQL_SET_CLIENT_IP = 17, - MYSQL_SECURE_AUTH = 18, - }; -# 214 "mysql.h" -enum mysql_protocol_type - { - MYSQL_PROTOCOL_DEFAULT = 0, - MYSQL_PROTOCOL_TCP = 1, - MYSQL_PROTOCOL_SOCKET = 2, - MYSQL_PROTOCOL_PIPE = 3, - MYSQL_PROTOCOL_MEMORY = 4, - }; -# 224 "mysql.h" -enum mysql_rpl_type - { - MYSQL_RPL_MASTER = 0, - MYSQL_RPL_SLAVE = 1, - MYSQL_RPL_ADMIN = 2, - }; -# 209 "mysql.h" -enum mysql_status - { - MYSQL_STATUS_READY = 0, - MYSQL_STATUS_GET_RESULT = 1, - MYSQL_STATUS_USE_RESULT = 2, - }; -# 365 "mysql_com.h" -extern my_bool check_scramble(char const * reply, char const * message, unsigned char const * hash_stage2); -# 358 "mysql_com.h" -extern my_bool check_scramble_323(char const *, char const * message, unsigned long int * salt); -# 353 "mysql_com.h" -extern void create_random_string(char * to, unsigned int, struct rand_struct * rand_st); -# 28 "typelib.h" -extern int find_type(char * x, TYPELIB * typelib, unsigned int); -# 367 "mysql_com.h" -extern void get_salt_from_password(unsigned char * res, char const * password); -# 360 "mysql_com.h" -extern void get_salt_from_password_323(unsigned long int * res, char const * password); -# 372 "mysql_com.h" -extern char * get_tty_password(char * opt_message); -# 30 "typelib.h" -extern char const * get_type(TYPELIB * typelib, unsigned int); -# 355 "mysql_com.h" -extern void hash_password(unsigned long int * to, char const * password, unsigned int); -# 31 "my_list.h" -extern LIST * list_add(LIST * root, LIST * element); -# 33 "my_list.h" -extern LIST * list_cons(void * data, LIST * root); -# 32 "my_list.h" -extern LIST * list_delete(LIST * root, LIST * element); -# 35 "my_list.h" -extern void list_free(LIST * root, unsigned int); -# 36 "my_list.h" -extern unsigned int list_length(LIST *); -# 34 "my_list.h" -extern LIST * list_reverse(LIST * root); -# 37 "my_list.h" -extern int list_walk(LIST *, list_walk_action, gptr); -# 378 "mysql_com.h" -extern int load_defaults(char const * conf_file, char const * * groups, int * argc, char * * * argv); -# 368 "mysql_com.h" -extern void make_password_from_salt(char * to, unsigned char const * hash_stage2); -# 361 "mysql_com.h" -extern void make_password_from_salt_323(char * to, unsigned long int const * salt); -# 363 "mysql_com.h" -extern void make_scrambled_password(char * to, char const * password); -# 356 "mysql_com.h" -extern void make_scrambled_password_323(char * to, char const * password); -# 29 "typelib.h" -extern void make_type(char * to, unsigned int, TYPELIB * typelib); -# 299 "mysql_com.h" -extern int my_connect(my_socket, struct sockaddr const * name, unsigned int, unsigned int); -# 377 "mysql_com.h" -extern my_bool my_init(void); -# 281 "mysql_com.h" -extern my_bool my_net_init(NET * net, Vio * vio); -# 282 "mysql_com.h" -extern void my_net_local_init(NET * net); -# 292 "mysql_com.h" -extern unsigned long int my_net_read(NET * net); -# 287 "mysql_com.h" -extern my_bool my_net_write(NET * net, char const * packet, unsigned long int); -# 352 "mysql_com.h" -extern double my_rnd(struct rand_struct *); -# 381 "mysql_com.h" -extern void my_thread_end(void); -# 380 "mysql_com.h" -extern my_bool my_thread_init(void); -# 539 "mysql.h" -extern void myodbc_remove_escape(MYSQL * mysql, char * name); -# 481 "mysql.h" -extern int mysql_add_slave(MYSQL * mysql, char const * host, unsigned int, char const * user, char const * passwd); -# 393 "mysql.h" -extern my_ulonglong mysql_affected_rows(MYSQL * mysql); -# 720 "mysql.h" -extern my_bool mysql_autocommit(MYSQL * mysql, my_bool); -# 408 "mysql.h" -extern my_bool mysql_change_user(MYSQL * mysql, char const * user, char const * passwd, char const * db); -# 401 "mysql.h" -extern char const * mysql_character_set_name(MYSQL * mysql); -# 723 "mysql.h" -extern void mysql_close(MYSQL * sock); -# 718 "mysql.h" -extern my_bool mysql_commit(MYSQL * mysql); -# 510 "mysql.h" -extern void mysql_data_seek(MYSQL_RES * result, my_ulonglong); -# 528 "mysql.h" -extern void mysql_debug(char const * debug); -# 467 "mysql.h" -extern void mysql_disable_reads_from_master(MYSQL * mysql); -# 461 "mysql.h" -extern void mysql_disable_rpl_parse(MYSQL * mysql); -# 489 "mysql.h" -extern int mysql_dump_debug_info(MYSQL * mysql); -# 541 "mysql.h" -extern my_bool mysql_embedded(void); -# 466 "mysql.h" -extern void mysql_enable_reads_from_master(MYSQL * mysql); -# 460 "mysql.h" -extern void mysql_enable_rpl_parse(MYSQL * mysql); -# 385 "mysql.h" -extern my_bool mysql_eof(MYSQL_RES * res); -# 395 "mysql.h" -extern unsigned int mysql_errno(MYSQL * mysql); -# 373 "mysql_com.h" -extern char const * mysql_errno_to_sqlstate(unsigned int); -# 396 "mysql.h" -extern char const * mysql_error(MYSQL * mysql); -# 521 "mysql.h" -extern unsigned long int mysql_escape_string(char * to, char const * from, unsigned long int); -# 518 "mysql.h" -extern MYSQL_FIELD * mysql_fetch_field(MYSQL_RES * result); -# 386 "mysql.h" -extern MYSQL_FIELD * mysql_fetch_field_direct(MYSQL_RES * res, unsigned int); -# 388 "mysql.h" -extern MYSQL_FIELD * mysql_fetch_fields(MYSQL_RES * res); -# 517 "mysql.h" -extern unsigned long int * mysql_fetch_lengths(MYSQL_RES * result); -# 516 "mysql.h" -extern MYSQL_ROW mysql_fetch_row(MYSQL_RES * result); -# 392 "mysql.h" -extern unsigned int mysql_field_count(MYSQL * mysql); -# 514 "mysql.h" -extern MYSQL_FIELD_OFFSET mysql_field_seek(MYSQL_RES * result, MYSQL_FIELD_OFFSET); -# 390 "mysql.h" -extern MYSQL_FIELD_OFFSET mysql_field_tell(MYSQL_RES * res); -# 509 "mysql.h" -extern void mysql_free_result(MYSQL_RES * result); -# 499 "mysql.h" -extern char const * mysql_get_client_info(void); -# 500 "mysql.h" -extern unsigned long int mysql_get_client_version(void); -# 501 "mysql.h" -extern char const * mysql_get_host_info(MYSQL * mysql); -# 367 "mysql.h" -extern MYSQL_PARAMETERS * mysql_get_parameters(void); -# 503 "mysql.h" -extern unsigned int mysql_get_proto_info(MYSQL * mysql); -# 498 "mysql.h" -extern char const * mysql_get_server_info(MYSQL * mysql); -# 502 "mysql.h" -extern unsigned long int mysql_get_server_version(MYSQL * mysql); -# 523 "mysql.h" -extern unsigned long int mysql_hex_string(char * to, char const * from, unsigned long int); -# 399 "mysql.h" -extern char const * mysql_info(MYSQL * mysql); -# 404 "mysql.h" -extern MYSQL * mysql_init(MYSQL * mysql); -# 394 "mysql.h" -extern my_ulonglong mysql_insert_id(MYSQL * mysql); -# 492 "mysql.h" -extern int mysql_kill(MYSQL * mysql, unsigned long int); -# 504 "mysql.h" -extern MYSQL_RES * mysql_list_dbs(MYSQL * mysql, char const * wild); -# 519 "mysql.h" -extern MYSQL_RES * mysql_list_fields(MYSQL * mysql, char const * table, char const * wild); -# 506 "mysql.h" -extern MYSQL_RES * mysql_list_processes(MYSQL * mysql); -# 505 "mysql.h" -extern MYSQL_RES * mysql_list_tables(MYSQL * mysql, char const * wild); -# 548 "mysql.h" -extern void mysql_manager_close(MYSQL_MANAGER * con); -# 549 "mysql.h" -extern int mysql_manager_command(MYSQL_MANAGER * con, char const * cmd, int); -# 543 "mysql.h" -extern MYSQL_MANAGER * mysql_manager_connect(MYSQL_MANAGER * con, char const * host, char const * user, char const * passwd, unsigned int); -# 551 "mysql.h" -extern int mysql_manager_fetch_line(MYSQL_MANAGER * con, char * res_buf, int); -# 542 "mysql.h" -extern MYSQL_MANAGER * mysql_manager_init(MYSQL_MANAGER * con); -# 427 "mysql.h" -extern my_bool mysql_master_query(MYSQL * mysql, char const * q, unsigned long int); -# 429 "mysql.h" -extern my_bool mysql_master_send_query(MYSQL * mysql, char const * q, unsigned long int); -# 721 "mysql.h" -extern my_bool mysql_more_results(MYSQL * mysql); -# 722 "mysql.h" -extern int mysql_next_result(MYSQL * mysql); -# 384 "mysql.h" -extern unsigned int mysql_num_fields(MYSQL_RES * res); -# 383 "mysql.h" -extern my_ulonglong mysql_num_rows(MYSQL_RES * res); -# 529 "mysql.h" -extern char * mysql_odbc_escape_string(MYSQL * mysql, char * to, unsigned long int, char const * from, unsigned long int, void * param, char * (* extend_buffer)(void *, char * to, unsigned long int * length)); -# 507 "mysql.h" -extern int mysql_options(MYSQL * mysql, enum mysql_option, char const * arg); -# 496 "mysql.h" -extern int mysql_ping(MYSQL * mysql); -# 75 "mysql.h" -extern unsigned int mysql_port; -# 418 "mysql.h" -extern int mysql_query(MYSQL * mysql, char const * q); -# 554 "mysql.h" -extern my_bool mysql_read_query_result(MYSQL * mysql); -# 469 "mysql.h" -extern my_bool mysql_reads_from_master_enabled(MYSQL * mysql); -# 410 "mysql.h" -extern MYSQL * mysql_real_connect(MYSQL * mysql, char const * host, char const * user, char const * passwd, char const * db, unsigned int, char const * unix_socket, unsigned long int); -# 525 "mysql.h" -extern unsigned long int mysql_real_escape_string(MYSQL * mysql, char * to, char const * from, unsigned long int); -# 421 "mysql.h" -extern int mysql_real_query(MYSQL * mysql, char const * q, unsigned long int); -# 490 "mysql.h" -extern int mysql_refresh(MYSQL * mysql, unsigned int); -# 719 "mysql.h" -extern my_bool mysql_rollback(MYSQL * mysql); -# 512 "mysql.h" -extern MYSQL_ROW_OFFSET mysql_row_seek(MYSQL_RES * result, MYSQL_ROW_OFFSET); -# 389 "mysql.h" -extern MYSQL_ROW_OFFSET mysql_row_tell(MYSQL_RES * res); -# 463 "mysql.h" -extern int mysql_rpl_parse_enabled(MYSQL * mysql); -# 474 "mysql.h" -extern my_bool mysql_rpl_probe(MYSQL * mysql); -# 471 "mysql.h" -extern enum mysql_rpl_type mysql_rpl_query_type(char const * q, int); -# 417 "mysql.h" -extern int mysql_select_db(MYSQL * mysql, char const * db); -# 419 "mysql.h" -extern int mysql_send_query(MYSQL * mysql, char const * q, unsigned long int); -# 354 "mysql.h" -extern void mysql_server_end(void); -# 353 "mysql.h" -extern int mysql_server_init(int, char * * argv, char * * groups); -# 402 "mysql.h" -extern int mysql_set_character_set(MYSQL * mysql, char const * csname); -# 452 "mysql.h" -extern void mysql_set_local_infile_default(MYSQL * mysql); -# 441 "mysql.h" -extern void mysql_set_local_infile_handler(MYSQL * mysql, int (* local_infile_init)(void * *, char const *, void *), int (* local_infile_read)(void *, char *, unsigned int), void (* local_infile_end)(void), int (* local_infile_error)(void *, char *, unsigned int), void *); -# 477 "mysql.h" -extern int mysql_set_master(MYSQL * mysql, char const * host, unsigned int, char const * user, char const * passwd); -# 493 "mysql.h" -extern int mysql_set_server_option(MYSQL * mysql, enum enum_mysql_set_option); -# 486 "mysql.h" -extern int mysql_shutdown(MYSQL * mysql, enum mysql_enum_shutdown_level); -# 432 "mysql.h" -extern my_bool mysql_slave_query(MYSQL * mysql, char const * q, unsigned long int); -# 434 "mysql.h" -extern my_bool mysql_slave_send_query(MYSQL * mysql, char const * q, unsigned long int); -# 397 "mysql.h" -extern char const * mysql_sqlstate(MYSQL * mysql); -# 405 "mysql.h" -extern my_bool mysql_ssl_set(MYSQL * mysql, char const * key, char const * cert, char const * ca, char const * capath, char const * cipher); -# 497 "mysql.h" -extern char const * mysql_stat(MYSQL * mysql); -# 714 "mysql.h" -extern my_ulonglong mysql_stmt_affected_rows(MYSQL_STMT * stmt); -# 692 "mysql.h" -extern my_bool mysql_stmt_attr_get(MYSQL_STMT * stmt, enum enum_stmt_attr_type, void * attr); -# 689 "mysql.h" -extern my_bool mysql_stmt_attr_set(MYSQL_STMT * stmt, enum enum_stmt_attr_type, void const * attr); -# 695 "mysql.h" -extern my_bool mysql_stmt_bind_param(MYSQL_STMT * stmt, MYSQL_BIND * bnd); -# 696 "mysql.h" -extern my_bool mysql_stmt_bind_result(MYSQL_STMT * stmt, MYSQL_BIND * bnd); -# 697 "mysql.h" -extern my_bool mysql_stmt_close(MYSQL_STMT * stmt); -# 712 "mysql.h" -extern void mysql_stmt_data_seek(MYSQL_STMT * stmt, my_ulonglong); -# 706 "mysql.h" -extern unsigned int mysql_stmt_errno(MYSQL_STMT * stmt); -# 707 "mysql.h" -extern char const * mysql_stmt_error(MYSQL_STMT * stmt); -# 682 "mysql.h" -extern int mysql_stmt_execute(MYSQL_STMT * stmt); -# 683 "mysql.h" -extern int mysql_stmt_fetch(MYSQL_STMT * stmt); -# 684 "mysql.h" -extern int mysql_stmt_fetch_column(MYSQL_STMT * stmt, MYSQL_BIND * bind, unsigned int, unsigned long int); -# 716 "mysql.h" -extern unsigned int mysql_stmt_field_count(MYSQL_STMT * stmt); -# 699 "mysql.h" -extern my_bool mysql_stmt_free_result(MYSQL_STMT * stmt); -# 679 "mysql.h" -extern MYSQL_STMT * mysql_stmt_init(MYSQL * mysql); -# 715 "mysql.h" -extern my_ulonglong mysql_stmt_insert_id(MYSQL_STMT * stmt); -# 713 "mysql.h" -extern my_ulonglong mysql_stmt_num_rows(MYSQL_STMT * stmt); -# 688 "mysql.h" -extern unsigned long int mysql_stmt_param_count(MYSQL_STMT * stmt); -# 705 "mysql.h" -extern MYSQL_RES * mysql_stmt_param_metadata(MYSQL_STMT * stmt); -# 680 "mysql.h" -extern int mysql_stmt_prepare(MYSQL_STMT * stmt, char const * query, unsigned long int); -# 698 "mysql.h" -extern my_bool mysql_stmt_reset(MYSQL_STMT * stmt); -# 704 "mysql.h" -extern MYSQL_RES * mysql_stmt_result_metadata(MYSQL_STMT * stmt); -# 709 "mysql.h" -extern MYSQL_ROW_OFFSET mysql_stmt_row_seek(MYSQL_STMT * stmt, MYSQL_ROW_OFFSET); -# 711 "mysql.h" -extern MYSQL_ROW_OFFSET mysql_stmt_row_tell(MYSQL_STMT * stmt); -# 700 "mysql.h" -extern my_bool mysql_stmt_send_long_data(MYSQL_STMT * stmt, unsigned int, char const * data, unsigned long int); -# 708 "mysql.h" -extern char const * mysql_stmt_sqlstate(MYSQL_STMT * stmt); -# 687 "mysql.h" -extern int mysql_stmt_store_result(MYSQL_STMT * stmt); -# 423 "mysql.h" -extern MYSQL_RES * mysql_store_result(MYSQL * mysql); -# 376 "mysql.h" -extern void mysql_thread_end(void); -# 400 "mysql.h" -extern unsigned long int mysql_thread_id(MYSQL * mysql); -# 375 "mysql.h" -extern my_bool mysql_thread_init(void); -# 540 "mysql.h" -extern unsigned int mysql_thread_safe(void); -# 76 "mysql.h" -extern char * mysql_unix_port; -# 424 "mysql.h" -extern MYSQL_RES * mysql_use_result(MYSQL * mysql); -# 398 "mysql.h" -extern unsigned int mysql_warning_count(MYSQL * mysql); -# 284 "mysql_com.h" -extern void net_clear(NET * net); -# 283 "mysql_com.h" -extern void net_end(NET * net); -# 286 "mysql_com.h" -extern my_bool net_flush(NET * net); -# 291 "mysql_com.h" -extern int net_real_write(NET * net, char const * packet, unsigned long int); -# 285 "mysql_com.h" -extern my_bool net_realloc(NET * net, unsigned long int); -# 751 "mysql.h" -extern unsigned long int net_safe_read(MYSQL * mysql); -# 288 "mysql_com.h" -extern my_bool net_write_command(NET * net, unsigned char, char const * header, unsigned long int, char const * packet, unsigned long int); -# 350 "mysql_com.h" -extern void randominit(struct rand_struct *, unsigned long int, unsigned long int); -# 364 "mysql_com.h" -extern void scramble(char * to, char const * message, char const * password); -# 357 "mysql_com.h" -extern void scramble_323(char * to, char const * message, char const * password); -# 32 "typelib.h" -extern TYPELIB sql_protocol_typelib; diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index ba9f788494a..5b8df86d73a 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -142,6 +142,7 @@ our $opt_verbose= 0; # Verbose output, enable with --verbose our $exe_master_mysqld; our $exe_mysql; our $exe_mysqladmin; +our $exe_mysql_upgrade; our $exe_mysqlbinlog; our $exe_mysql_client_test; our $exe_mysqld; @@ -1403,7 +1404,15 @@ sub executable_setup () { $exe_mysql= mtr_exe_exists("$path_client_bindir/mysql"); if ( $mysql_version_id >= 50100 ) { - $exe_mysqlslap= mtr_exe_exists("$path_client_bindir/mysqlslap"); + $exe_mysqlslap= mtr_exe_exists("$path_client_bindir/mysqlslap"); + } + if ( $mysql_version_id >= 50000 and !$glob_use_embedded_server ) + { + $exe_mysql_upgrade= mtr_exe_exists("$path_client_bindir/mysql_upgrade") + } + else + { + $exe_mysql_upgrade= ""; } if ( ! $glob_win32 ) @@ -1444,13 +1453,13 @@ sub executable_setup () { if ( $glob_use_embedded_server ) { $exe_mysqltest= - mtr_exe_exists(vs_config_dirs('libmysqld/examples', 'mysqltest_embedded'), - "$glob_basedir/libmysqld/examples/mysqltest_embedded", + mtr_exe_exists(vs_config_dirs('libmysqld/examples','mysqltest_embedded'), + "$glob_basedir/libmysqld/examples/mysqltest_embedded", "$path_client_bindir/mysqltest_embedded"); } else { - $exe_mysqltest= mtr_exe_exists("$path_client_bindir/mysqltest"); + $exe_mysqltest= mtr_exe_exists("$path_client_bindir/mysqltest"); } # Look for mysql_client_test executable which may _not_ exist in @@ -1467,7 +1476,7 @@ sub executable_setup () { $exe_mysql_client_test= mtr_exe_maybe_exists(vs_config_dirs('tests', 'mysql_client_test'), "$glob_basedir/tests/mysql_client_test", - "$glob_basedir/bin"); + "$glob_basedir/bin/mysql_client_test"); } } @@ -1529,6 +1538,33 @@ sub mysql_client_test_arguments() return join(" ", $exe, @$args); } +sub mysql_upgrade_arguments() +{ + my $exe= $exe_mysql_upgrade; + + my $args; + mtr_init_args(\$args); +# if ( $opt_valgrind_mysql_ugrade ) +# { +# valgrind_arguments($args, \$exe); +# } + + mtr_add_arg($args, "--no-defaults"); + mtr_add_arg($args, "--user=root"); + mtr_add_arg($args, "--port=$master->[0]->{'port'}"); + mtr_add_arg($args, "--socket=$master->[0]->{'path_sock'}"); + mtr_add_arg($args, "--datadir=$master->[0]->{'path_myddir'}"); + mtr_add_arg($args, "--basedir=$glob_basedir"); + + if ( $opt_debug ) + { + mtr_add_arg($args, + "--debug=d:t:A,$path_vardir_trace/log/mysql_upgrade.trace"); + } + + return join(" ", $exe, @$args); +} + # Note that some env is setup in spawn/run, in "mtr_process.pl" sub environment_setup () { @@ -1788,6 +1824,14 @@ sub environment_setup () { # ---------------------------------------------------- $ENV{'MYSQL_CLIENT_TEST'}= mysql_client_test_arguments(); + # ---------------------------------------------------- + # Setup env so childs can execute mysql_upgrade + # ---------------------------------------------------- + if ( $mysql_version_id >= 50000 ) + { + $ENV{'MYSQL_UPGRADE'}= mysql_upgrade_arguments(); + } + # ---------------------------------------------------- # Setup env so childs can execute mysql_fix_system_tables # ---------------------------------------------------- diff --git a/mysql-test/r/mysql_upgrade.result b/mysql-test/r/mysql_upgrade.result new file mode 100644 index 00000000000..1f93d727561 --- /dev/null +++ b/mysql-test/r/mysql_upgrade.result @@ -0,0 +1,127 @@ +Run mysql_upgrade once +mysql.columns_priv OK +mysql.db OK +mysql.func OK +mysql.help_category OK +mysql.help_keyword OK +mysql.help_relation OK +mysql.help_topic OK +mysql.host OK +mysql.proc OK +mysql.procs_priv OK +mysql.tables_priv OK +mysql.time_zone OK +mysql.time_zone_leap_second OK +mysql.time_zone_name OK +mysql.time_zone_transition OK +mysql.time_zone_transition_type OK +mysql.user OK +@hadGrantPriv:=1 +1 +1 +1 +1 +1 +@hadShowDbPriv:=1 +1 +1 +1 +1 +1 +@hadCreateViewPriv:=1 +1 +1 +1 +1 +1 +@hadCreateRoutinePriv:=1 +1 +1 +1 +1 +1 +@hadCreateUserPriv:=1 +1 +1 +1 +1 +1 +Run it again - should say already completed +@hadGrantPriv:=1 +1 +1 +1 +1 +1 +@hadShowDbPriv:=1 +1 +1 +1 +1 +1 +@hadCreateViewPriv:=1 +1 +1 +1 +1 +1 +@hadCreateRoutinePriv:=1 +1 +1 +1 +1 +1 +@hadCreateUserPriv:=1 +1 +1 +1 +1 +1 +Force should run it regardless of wheter it's been run before +mysql.columns_priv OK +mysql.db OK +mysql.func OK +mysql.help_category OK +mysql.help_keyword OK +mysql.help_relation OK +mysql.help_topic OK +mysql.host OK +mysql.proc OK +mysql.procs_priv OK +mysql.tables_priv OK +mysql.time_zone OK +mysql.time_zone_leap_second OK +mysql.time_zone_name OK +mysql.time_zone_transition OK +mysql.time_zone_transition_type OK +mysql.user OK +@hadGrantPriv:=1 +1 +1 +1 +1 +1 +@hadShowDbPriv:=1 +1 +1 +1 +1 +1 +@hadCreateViewPriv:=1 +1 +1 +1 +1 +1 +@hadCreateRoutinePriv:=1 +1 +1 +1 +1 +1 +@hadCreateUserPriv:=1 +1 +1 +1 +1 +1 diff --git a/mysql-test/t/mysql_upgrade.test b/mysql-test/t/mysql_upgrade.test new file mode 100644 index 00000000000..50d316a0767 --- /dev/null +++ b/mysql-test/t/mysql_upgrade.test @@ -0,0 +1,20 @@ +# Only run test if "mysql_upgrade" is found +--require r/have_mysql_upgrade.inc +--disable_query_log +select LENGTH("$MYSQL_UPGRADE")>0 as have_mysql_upgrade; +--enable_query_log + +# +# Basic test thta we can run mysql_upgrde and that it finds the +# expected binaries it uses. +# +--echo Run mysql_upgrade once +--exec $MYSQL_UPGRADE 2> $MYSQLTEST_VARDIR/log/mysql_upgrade.err + +--echo Run it again - should say already completed +--exec $MYSQL_UPGRADE 2> $MYSQLTEST_VARDIR/log/mysql_upgrade.err + +--echo Force should run it regardless of wheter it's been run before +--exec $MYSQL_UPGRADE --force 2> $MYSQLTEST_VARDIR/log/mysql_upgrade.err + + From 68a7d45a0a32047aca52ca96765172c03a6f5db1 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 13 Nov 2006 13:45:40 +0100 Subject: [PATCH 021/131] Use same type for function declaration and definition --- sql-common/my_time.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-common/my_time.c b/sql-common/my_time.c index 2dd40c112de..003442e9330 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -780,7 +780,7 @@ long calc_daynr(uint year,uint month,uint day) */ my_time_t my_system_gmt_sec(const MYSQL_TIME *t_src, long *my_timezone, - bool *in_dst_time_gap) + my_bool *in_dst_time_gap) { uint loop; time_t tmp= 0; From 375eaecf6d24730643a613ff3d9af7529d68dd62 Mon Sep 17 00:00:00 2001 From: "guilhem@gbichot3.local" <> Date: Mon, 13 Nov 2006 16:54:47 +0100 Subject: [PATCH 022/131] Fix for a compilation failure: mysqladmin_SOURCES is a needed line in Makefile.am. --- client/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/client/Makefile.am b/client/Makefile.am index 48dc68ff704..736c4db005d 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -58,6 +58,7 @@ mysql_SOURCES = mysql.cc readline.cc sql_string.cc \ completion_hash.cc mysql_LDADD = @readline_link@ @TERMCAP_LIB@ \ $(LDADD) $(CXXLDFLAGS) +mysqladmin_SOURCES = mysqladmin.cc mysqlbinlog_SOURCES = mysqlbinlog.cc \ $(top_srcdir)/mysys/mf_tempdir.c \ From 91518b335eba98b3d258cefb32e61ca632030470 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 13 Nov 2006 16:55:05 +0100 Subject: [PATCH 023/131] Expect the file "have_mysql_upgrade.result" to contain the result from "require mysql_upgrade" --- mysql-test/r/have_mysql_upgrade.result | 2 ++ mysql-test/t/mysql_upgrade.test | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 mysql-test/r/have_mysql_upgrade.result diff --git a/mysql-test/r/have_mysql_upgrade.result b/mysql-test/r/have_mysql_upgrade.result new file mode 100644 index 00000000000..952bea420f9 --- /dev/null +++ b/mysql-test/r/have_mysql_upgrade.result @@ -0,0 +1,2 @@ +have_mysql_upgrade +1 diff --git a/mysql-test/t/mysql_upgrade.test b/mysql-test/t/mysql_upgrade.test index 50d316a0767..4200ba844f7 100644 --- a/mysql-test/t/mysql_upgrade.test +++ b/mysql-test/t/mysql_upgrade.test @@ -1,5 +1,5 @@ # Only run test if "mysql_upgrade" is found ---require r/have_mysql_upgrade.inc +--require r/have_mysql_upgrade.result --disable_query_log select LENGTH("$MYSQL_UPGRADE")>0 as have_mysql_upgrade; --enable_query_log From bf020e5ea6ada0f2b3e141b6126c23a57db45000 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 13 Nov 2006 17:16:37 +0100 Subject: [PATCH 024/131] Bug#19817 error when try to compile PHP5.1 with mysql 5.0.21 static libs - Most likely caused by linking with libmysqlclient using gcc and not g++. - Removing our "yassl_dummy_link_fix" hacks so some test programs are linked with gcc - Remove build of non working test programs in vio --- client/Makefile.am | 30 +++++++++++++----------------- tests/Makefile.am | 14 +++----------- tools/Makefile.am | 11 ++++------- vio/Makefile.am | 38 ++++++++++++-------------------------- 4 files changed, 32 insertions(+), 61 deletions(-) diff --git a/client/Makefile.am b/client/Makefile.am index 29624f2017f..df6e38223d4 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -16,11 +16,6 @@ # This file is public domain and comes with NO WARRANTY of any kind -if HAVE_YASSL - yassl_dummy_link_fix= $(top_srcdir)/extra/yassl/src/dummy.cpp -else - yassl_dummy_link_fix= -endif #AUTOMAKE_OPTIONS = nostdinc INCLUDES = -I$(top_builddir)/include \ -I$(top_srcdir)/include \ @@ -40,27 +35,28 @@ mysqladmin_SOURCES = mysqladmin.cc mysql_LDADD = @readline_link@ @TERMCAP_LIB@ $(LDADD) $(CXXLDFLAGS) mysqltest_SOURCES= mysqltest.c \ $(top_srcdir)/mysys/my_getsystime.c \ - $(top_srcdir)/mysys/my_copy.c \ - $(yassl_dummy_link_fix) + $(top_srcdir)/mysys/my_copy.c + mysqltest_LDADD = $(top_builddir)/regex/libregex.a $(LDADD) -mysqlbinlog_SOURCES = mysqlbinlog.cc $(top_srcdir)/mysys/mf_tempdir.c $(top_srcdir)/mysys/my_new.cc +mysqlbinlog_SOURCES = mysqlbinlog.cc \ + $(top_srcdir)/mysys/mf_tempdir.c \ + $(top_srcdir)/mysys/my_new.cc mysqlbinlog_LDADD = $(LDADD) $(CXXLDFLAGS) -mysqltestmanager_pwgen_SOURCES = mysqlmanager-pwgen.c -mysqltestmanagerc_SOURCES= mysqlmanagerc.c $(yassl_dummy_link_fix) -mysqlcheck_SOURCES= mysqlcheck.c $(yassl_dummy_link_fix) -mysqlshow_SOURCES= mysqlshow.c $(yassl_dummy_link_fix) +mysqltestmanager_pwgen_SOURCES = mysqlmanager-pwgen.c +mysqltestmanagerc_SOURCES= mysqlmanagerc.c +mysqlcheck_SOURCES= mysqlcheck.c +mysqlshow_SOURCES= mysqlshow.c mysqldump_SOURCES= mysqldump.c my_user.c \ - $(top_srcdir)/mysys/mf_getdate.c \ - $(yassl_dummy_link_fix) -mysqlimport_SOURCES= mysqlimport.c $(yassl_dummy_link_fix) -mysql_upgrade_SOURCES= mysql_upgrade.c $(yassl_dummy_link_fix) + $(top_srcdir)/mysys/mf_getdate.c +mysqlimport_SOURCES= mysqlimport.c +mysql_upgrade_SOURCES= mysql_upgrade.c sql_src=log_event.h mysql_priv.h log_event.cc my_decimal.h my_decimal.cc strings_src=decimal.c # Fix for mit-threads DEFS = -DUNDEF_THREADS_HACK \ -DDEFAULT_MYSQL_HOME="\"$(prefix)\"" \ - -DDATADIR="\"$(localstatedir)\"" + -DDATADIR="\"$(localstatedir)\"" EXTRA_DIST = get_password.c CMakeLists.txt diff --git a/tests/Makefile.am b/tests/Makefile.am index 9f143173827..79c7535f7ba 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -17,11 +17,6 @@ ## Process this file with automake to create Makefile.in -if HAVE_YASSL - yassl_dummy_link_fix= $(top_srcdir)/extra/yassl/src/dummy.cpp -else - yassl_dummy_link_fix= -endif EXTRA_DIST = auto_increment.res auto_increment.tst \ function.res function.tst lock_test.pl lock_test.res \ export.pl big_record.pl \ @@ -35,9 +30,6 @@ EXTRA_DIST = auto_increment.res auto_increment.tst \ bin_PROGRAMS = mysql_client_test noinst_PROGRAMS = insert_test select_test thread_test -# -# C Test for 4.1 protocol -# INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \ $(openssl_includes) LIBS = @CLIENT_LIBS@ @@ -45,11 +37,11 @@ LDADD = @CLIENT_EXTRA_LDFLAGS@ \ $(top_builddir)/libmysql/libmysqlclient.la mysql_client_test_LDADD= $(LDADD) $(CXXLDFLAGS) -mysql_client_test_SOURCES= mysql_client_test.c $(yassl_dummy_link_fix) \ +mysql_client_test_SOURCES= mysql_client_test.c\ $(top_srcdir)/mysys/my_memmem.c -insert_test_SOURCES= insert_test.c $(yassl_dummy_link_fix) -select_test_SOURCES= select_test.c $(yassl_dummy_link_fix) +insert_test_SOURCES= insert_test.c +select_test_SOURCES= select_test.c insert_test_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES) select_test_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES) diff --git a/tools/Makefile.am b/tools/Makefile.am index 61b9a612dc5..845ad7cd7dc 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -15,18 +15,15 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Process this file with automake to create Makefile.in -if HAVE_YASSL - yassl_dummy_link_fix= $(top_srcdir)/extra/yassl/src/dummy.cpp -else - yassl_dummy_link_fix= -endif INCLUDES= -I$(top_builddir)/include -I$(top_srcdir)/include \ $(openssl_includes) + LDADD= @CLIENT_EXTRA_LDFLAGS@ \ $(top_builddir)/libmysql_r/libmysqlclient_r.la \ - @openssl_libs@ @yassl_libs@ @ZLIB_LIBS@ + @openssl_libs@ @yassl_libs@ @ZLIB_LIBS@ + bin_PROGRAMS= mysqltestmanager -mysqltestmanager_SOURCES= mysqlmanager.c $(yassl_dummy_link_fix) +mysqltestmanager_SOURCES= mysqlmanager.c mysqltestmanager_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES) DEF= -DUNDEF_THREADS_HACK diff --git a/vio/Makefile.am b/vio/Makefile.am index cb70501046e..1f16894f4c1 100644 --- a/vio/Makefile.am +++ b/vio/Makefile.am @@ -1,43 +1,29 @@ # Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult 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 -if HAVE_YASSL - yassl_dummy_link_fix= $(top_srcdir)/extra/yassl/src/dummy.cpp -else - yassl_dummy_link_fix= -endif -INCLUDES= -I$(top_builddir)/include -I$(top_srcdir)/include \ +INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \ $(openssl_includes) -LDADD= @CLIENT_EXTRA_LDFLAGS@ $(openssl_libs) $(yassl_libs) -pkglib_LIBRARIES= libvio.a -noinst_PROGRAMS = test-ssl test-sslserver test-sslclient -noinst_HEADERS= vio_priv.h -test_ssl_SOURCES= test-ssl.c $(yassl_dummy_link_fix) -test_ssl_LDADD= @CLIENT_EXTRA_LDFLAGS@ ../dbug/libdbug.a libvio.a \ - ../mysys/libmysys.a ../strings/libmystrings.a \ - $(openssl_libs) $(yassl_libs) -test_sslserver_SOURCES= test-sslserver.c $(yassl_dummy_link_fix) -test_sslserver_LDADD= @CLIENT_EXTRA_LDFLAGS@ ../dbug/libdbug.a libvio.a \ - ../mysys/libmysys.a ../strings/libmystrings.a \ - $(openssl_libs) $(yassl_libs) -test_sslclient_SOURCES= test-sslclient.c $(yassl_dummy_link_fix) -test_sslclient_LDADD= @CLIENT_EXTRA_LDFLAGS@ ../dbug/libdbug.a libvio.a \ - ../mysys/libmysys.a ../strings/libmystrings.a \ - $(openssl_libs) $(yassl_libs) -libvio_a_SOURCES= vio.c viosocket.c viossl.c viosslfactories.c +LDADD = @CLIENT_EXTRA_LDFLAGS@ $(openssl_libs) $(yassl_libs) +pkglib_LIBRARIES = libvio.a + +noinst_HEADERS = vio_priv.h + +libvio_a_SOURCES = vio.c viosocket.c viossl.c viosslfactories.c + EXTRA_DIST= CMakeLists.txt + # Don't update the files from bitkeeper %::SCCS/s.% From 31f50324eae56cb6a5e5208cbb7ab3a2f26bd199 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 13 Nov 2006 18:06:05 +0100 Subject: [PATCH 025/131] Remove "yassl_dummy_link_fix" in 5.1 as well --- client/Makefile.am | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/client/Makefile.am b/client/Makefile.am index 736c4db005d..07f81d19b56 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -16,12 +16,6 @@ # This file is public domain and comes with NO WARRANTY of any kind -if HAVE_YASSL - yassl_dummy_link_fix= $(top_srcdir)/extra/yassl/src/dummy.cpp -else - yassl_dummy_link_fix= -endif - if THREAD_SAFE_CLIENT LIBMYSQLCLIENT_LA = $(top_builddir)/libmysql_r/libmysqlclient_r.la else @@ -71,19 +65,18 @@ mysqlbinlog_LDADD = $(LDADD) $(CXXLDFLAGS) mysqldump_SOURCES= mysqldump.c \ my_user.c \ - $(top_srcdir)/mysys/mf_getdate.c \ - $(yassl_dummy_link_fix) + $(top_srcdir)/mysys/mf_getdate.c -mysqlimport_SOURCES= mysqlimport.c $(yassl_dummy_link_fix) +mysqlimport_SOURCES= mysqlimport.c mysqlimport_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \ @CLIENT_EXTRA_LDFLAGS@ \ $(LIBMYSQLCLIENT_LA) \ $(top_builddir)/mysys/libmysys.a -mysqlshow_SOURCES= mysqlshow.c $(yassl_dummy_link_fix) +mysqlshow_SOURCES= mysqlshow.c -mysqlslap_SOURCES= mysqlslap.c $(yassl_dummy_link_fix) +mysqlslap_SOURCES= mysqlslap.c mysqlslap_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \ @CLIENT_EXTRA_LDFLAGS@ \ $(LIBMYSQLCLIENT_LA) \ @@ -91,11 +84,10 @@ mysqlslap_LDADD = $(CXXLDFLAGS) $(CLIENT_THREAD_LIBS) \ mysqltest_SOURCES= mysqltest.c \ $(top_srcdir)/mysys/my_getsystime.c \ - $(top_srcdir)/mysys/my_copy.c \ - $(yassl_dummy_link_fix) + $(top_srcdir)/mysys/my_copy.c mysqltest_LDADD = $(top_builddir)/regex/libregex.a $(LDADD) -mysql_upgrade_SOURCES= mysql_upgrade.c $(yassl_dummy_link_fix) +mysql_upgrade_SOURCES= mysql_upgrade.c # Fix for mit-threads DEFS = -DUNDEF_THREADS_HACK \ From 29d1e3230b2792815c9d036cf8948582cf785307 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 13 Nov 2006 19:12:34 +0100 Subject: [PATCH 026/131] Use mysql-test-run.pl --- mysql-test/Makefile.am | 20 ++++++++++++------- ...ql-test-run.sh => mysql-test-run-shell.sh} | 0 2 files changed, 13 insertions(+), 7 deletions(-) rename mysql-test/{mysql-test-run.sh => mysql-test-run-shell.sh} (100%) diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am index 1e6eb12f7b2..3307b870c66 100644 --- a/mysql-test/Makefile.am +++ b/mysql-test/Makefile.am @@ -33,19 +33,20 @@ endif benchdir_root= $(prefix) testdir = $(benchdir_root)/mysql-test EXTRA_SCRIPTS = mysql-test-run.sh install_test_db.sh $(PRESCRIPTS) -EXTRA_DIST = $(EXTRA_SCRIPTS) -GENSCRIPTS = mysql-test-run install_test_db mtr +EXTRA_DIST = $(EXTRA_SCRIPTS) +GENSCRIPTS = mysql-test-run-shell mysql-test-run install_test_db mtr PRESCRIPTS = mysql-test-run.pl test_SCRIPTS = $(GENSCRIPTS) $(PRESCRIPTS) -test_DATA = std_data/client-key.pem std_data/client-cert.pem std_data/cacert.pem \ - std_data/server-cert.pem std_data/server-key.pem +test_DATA = std_data/client-key.pem \ + std_data/client-cert.pem \ + std_data/cacert.pem \ + std_data/server-cert.pem \ + std_data/server-key.pem CLEANFILES = $(GENSCRIPTS) $(test_DATA) INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include -I.. -EXTRA_PROGRAMS = mysql_test_run_new -noinst_HEADERS = my_manage.h -mysql_test_run_new_SOURCES= mysql_test_run_new.c my_manage.c my_create_tables.c +noinst_HEADERS = my_manage.h dist-hook: mkdir -p $(distdir)/t $(distdir)/r $(distdir)/include \ @@ -110,6 +111,11 @@ mtr: $(RM) -f mtr $(LN_S) mysql-test-run.pl mtr +# mysql-test-run - a shortcut for executing mysql-test-run.pl +mysql-test-run: + $(RM) -f mysql-test-run + $(LN_S) mysql-test-run.pl mysql-test-run + SUFFIXES = .sh .sh: diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run-shell.sh similarity index 100% rename from mysql-test/mysql-test-run.sh rename to mysql-test/mysql-test-run-shell.sh From 8471897fbc01520bfdf93a7105019e17cdbca89e Mon Sep 17 00:00:00 2001 From: "cmiller@zippy.cornsilk.net" <> Date: Mon, 13 Nov 2006 13:13:44 -0500 Subject: [PATCH 027/131] Bug#18761: constant expression as UDF parameters not passed in as constant The code that set up data to be passed to user-defined functions was very old and analyzed the "Type" of the data that was passed into the UDF, when it really should analyze the "return_type", which is hard-coded for simple Items and works correctly for complex ones like functions. --- Added test at Sergei's behest. --- BitKeeper/etc/collapsed | 8 ++++++ mysql-test/r/udf.result | 35 +++++++++++++++++++++++ mysql-test/t/udf.test | 37 ++++++++++++++++++++++++ sql/item_func.cc | 62 +++++++++++++++++++++++------------------ sql/udf_example.c | 30 ++++++++++++++++++++ 5 files changed, 145 insertions(+), 27 deletions(-) diff --git a/BitKeeper/etc/collapsed b/BitKeeper/etc/collapsed index 311c3813abf..357e2c84566 100644 --- a/BitKeeper/etc/collapsed +++ b/BitKeeper/etc/collapsed @@ -15,3 +15,11 @@ 45214442pBGT9KuZEGixBH71jTzbOA 45214a07hVsIGwvwa-WrO-jpeaSwVw 452a92d0-31-8wSzSfZi165fcGcXPA +454bb488ijVLOUK_GFjcoISE0GxPUA +454bb9a8AwlGRC_wWLS2sNMoRBMRGw +454c946ciQoR4dfTBZ0RTBmGJKp6lw +454f6e7eAnfLD9OCbGr5X9KiKvfKcQ +454f704bJiJy0_Nx2drY9P5kK3uOzg +454fa71cxshxszXJQYa9jbo0-_hAHw +4550b0ceIcozdgQhWFUTAtWkN196lA +4558b3d73Cxjlb7Wv1oytdSTthxDfw diff --git a/mysql-test/r/udf.result b/mysql-test/r/udf.result index 8e37cca6aa9..8501b82fcdf 100644 --- a/mysql-test/r/udf.result +++ b/mysql-test/r/udf.result @@ -115,3 +115,38 @@ DROP FUNCTION sequence; DROP FUNCTION lookup; DROP FUNCTION reverse_lookup; DROP FUNCTION avgcost; +CREATE FUNCTION is_const RETURNS STRING SONAME "UDF_EXAMPLE_LIB"; +select +is_const(3) as const, +is_const(3.14) as const, +is_const('fnord') as const, +is_const(2+3) as const, +is_const(rand()) as 'nc rand()', +is_const(sin(3.14)) as const, +is_const(upper('test')) as const; +const const const const nc rand() const const +const const const const not const const const +create table bug18761 (n int); +insert into bug18761 values (null),(2); +select +is_const(3) as const, +is_const(3.14) as const, +is_const('fnord') as const, +is_const(2+3) as const, +is_const(2+n) as 'nc 2+n ', +is_const(sin(n)) as 'nc sin(n)', +is_const(sin(3.14)) as const, +is_const(upper('test')) as const, +is_const(rand()) as 'nc rand()', +is_const(n) as 'nc n ', +is_const(is_const(n)) as 'nc ic?(n)', +is_const(is_const('c')) as const +from +bug18761; +const const const const nc 2+n nc sin(n) const const nc rand() nc n nc ic?(n) const +const const const const not const not const const const not const not const not const const +const const const const not const not const const const not const not const not const const +drop table bug18761; +select is_const((1,2,3)); +ERROR 21000: Operand should contain 1 column(s) +drop function if exists is_const; diff --git a/mysql-test/t/udf.test b/mysql-test/t/udf.test index 96e559f5c05..c62d7829b05 100644 --- a/mysql-test/t/udf.test +++ b/mysql-test/t/udf.test @@ -143,4 +143,41 @@ DROP FUNCTION lookup; DROP FUNCTION reverse_lookup; DROP FUNCTION avgcost; +# +# Bug#18761: constant expression as UDF parameters not passed in as constant +# +--replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB +eval CREATE FUNCTION is_const RETURNS STRING SONAME "$UDF_EXAMPLE_LIB"; +select + is_const(3) as const, + is_const(3.14) as const, + is_const('fnord') as const, + is_const(2+3) as const, + is_const(rand()) as 'nc rand()', + is_const(sin(3.14)) as const, + is_const(upper('test')) as const; + +create table bug18761 (n int); +insert into bug18761 values (null),(2); +select + is_const(3) as const, + is_const(3.14) as const, + is_const('fnord') as const, + is_const(2+3) as const, + is_const(2+n) as 'nc 2+n ', + is_const(sin(n)) as 'nc sin(n)', + is_const(sin(3.14)) as const, + is_const(upper('test')) as const, + is_const(rand()) as 'nc rand()', + is_const(n) as 'nc n ', + is_const(is_const(n)) as 'nc ic?(n)', + is_const(is_const('c')) as const +from + bug18761; +drop table bug18761; + +--error 1241 +select is_const((1,2,3)); + +drop function if exists is_const; diff --git a/sql/item_func.cc b/sql/item_func.cc index a294bbd7a71..8e6b4d82b1d 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2683,39 +2683,47 @@ udf_handler::fix_fields(THD *thd, Item_result_field *func, char *to=num_buffer; for (uint i=0; i < arg_count; i++) { - f_args.args[i]=0; + /* + For a constant argument i, args->args[i] points to the argument value. + For non-constant, args->args[i] is NULL. + */ + f_args.args[i]= NULL; /* Non-const unless updated below. */ + f_args.lengths[i]= arguments[i]->max_length; f_args.maybe_null[i]= (char) arguments[i]->maybe_null; f_args.attributes[i]= arguments[i]->name; f_args.attribute_lengths[i]= arguments[i]->name_length; - switch(arguments[i]->type()) { - case Item::STRING_ITEM: // Constant string ! + if (arguments[i]->const_item()) { - String *res=arguments[i]->val_str(&buffers[i]); - if (arguments[i]->null_value) - continue; - f_args.args[i]= (char*) res->ptr(); - break; - } - case Item::INT_ITEM: - *((longlong*) to) = arguments[i]->val_int(); - if (!arguments[i]->null_value) - { - f_args.args[i]=to; - to+= ALIGN_SIZE(sizeof(longlong)); - } - break; - case Item::REAL_ITEM: - *((double*) to)= arguments[i]->val_real(); - if (!arguments[i]->null_value) - { - f_args.args[i]=to; - to+= ALIGN_SIZE(sizeof(double)); - } - break; - default: // Skip these - break; + if (arguments[i]->null_value) + continue; + + switch (arguments[i]->result_type()) + { + case STRING_RESULT: + case DECIMAL_RESULT: + { + String *res= arguments[i]->val_str(&buffers[i]); + f_args.args[i]= (char*) res->ptr(); + break; + } + case INT_RESULT: + *((longlong*) to)= arguments[i]->val_int(); + f_args.args[i]= to; + to+= ALIGN_SIZE(sizeof(longlong)); + break; + case REAL_RESULT: + *((double*) to)= arguments[i]->val_real(); + f_args.args[i]= to; + to+= ALIGN_SIZE(sizeof(double)); + break; + case ROW_RESULT: + default: + // This case should never be chosen + DBUG_ASSERT(0); + break; + } } } thd->net.last_error[0]=0; diff --git a/sql/udf_example.c b/sql/udf_example.c index 2fa7474eb16..a4f7eddd302 100644 --- a/sql/udf_example.c +++ b/sql/udf_example.c @@ -165,6 +165,9 @@ void avgcost_reset( UDF_INIT* initid, UDF_ARGS* args, char* is_null, char *error void avgcost_clear( UDF_INIT* initid, char* is_null, char *error ); void avgcost_add( UDF_INIT* initid, UDF_ARGS* args, char* is_null, char *error ); double avgcost( UDF_INIT* initid, UDF_ARGS* args, char* is_null, char *error ); +my_bool is_const_init(UDF_INIT *initid, UDF_ARGS *args, char *message); +char *is_const(UDF_INIT *initid, UDF_ARGS *args, char *result, unsigned long + *length, char *is_null, char *error); /************************************************************************* @@ -1075,4 +1078,31 @@ char *myfunc_argument_name(UDF_INIT *initid __attribute__((unused)), return result; } + + +my_bool is_const_init(UDF_INIT *initid, UDF_ARGS *args, char *message) +{ + if (args->arg_count != 1) + { + strmov(message, "IS_CONST accepts only one argument"); + return 1; + } + initid->ptr= (args->args[0] != NULL) ? 1 : 0; + return 0; +} + +char * is_const(UDF_INIT *initid, UDF_ARGS *args, char *result, unsigned long + *length, char *is_null, char *error) +{ + if (initid->ptr != 0) { + sprintf(result, "const"); + } else { + sprintf(result, "not const"); + } + *is_null= 0; + *length= strlen(result); + return result; +} + + #endif /* HAVE_DLOPEN */ From e09df84aa58890c9030d1f77bc8ded40edd30b0f Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 13 Nov 2006 19:16:23 +0100 Subject: [PATCH 028/131] Remove test-force-pl-mem and add test-force-mem --- Makefile.am | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Makefile.am b/Makefile.am index 8d0746e6a64..ab9a7a33a44 100644 --- a/Makefile.am +++ b/Makefile.am @@ -114,6 +114,12 @@ test-force: ./mysql-test-run --force && \ ./mysql-test-run --ps-protocol --force +test-force-mem: + cd mysql-test; \ + ./mysql-test-run --force --mem && \ + ./mysql-test-run --ps-protocol --force --mem + + # We are testing a new Perl version of the test script test-pl: cd mysql-test; \ @@ -125,7 +131,3 @@ test-force-pl: ./mysql-test-run.pl --force && \ ./mysql-test-run.pl --ps-protocol --force -test-force-pl-mem: - cd mysql-test; \ - ./mysql-test-run.pl --force --mem && \ - ./mysql-test-run.pl --ps-protocol --force --mem From 94ea2ef88ccc8669d74b90dbd210bf2fe979d22a Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 14 Nov 2006 09:42:01 +0100 Subject: [PATCH 029/131] Fix "make dist" --- mysql-test/Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am index 3307b870c66..4afab8b0281 100644 --- a/mysql-test/Makefile.am +++ b/mysql-test/Makefile.am @@ -32,7 +32,8 @@ endif benchdir_root= $(prefix) testdir = $(benchdir_root)/mysql-test -EXTRA_SCRIPTS = mysql-test-run.sh install_test_db.sh $(PRESCRIPTS) +EXTRA_SCRIPTS = mysql-test-run-shell.sh install_test_db.sh \ + $(PRESCRIPTS) EXTRA_DIST = $(EXTRA_SCRIPTS) GENSCRIPTS = mysql-test-run-shell mysql-test-run install_test_db mtr PRESCRIPTS = mysql-test-run.pl From 9299fd671586c731056dcfbfc44a8a0028eec4f4 Mon Sep 17 00:00:00 2001 From: "andrey@example.com" <> Date: Tue, 14 Nov 2006 18:40:11 +0100 Subject: [PATCH 030/131] Fix for bug#23760 ROW_COUNT() and store procedure not owrking together The problem was that THD::row_count_func was zeroed too. It was zeroed as a fix for bug 4905 "Stored procedure doesn't clear for "Rows affected" However, the proper solution is not to zero, because THD::row_count_func has been set to -1 already in mysql_execute_command(), a later fix, which obsoletes the incorrect fix of #4095 --- mysql-test/r/sp.result | 85 +++++++++++++++++++++++++++++++++++++++++- mysql-test/t/sp.test | 77 ++++++++++++++++++++++++++++++++++++++ sql/sql_parse.cc | 2 - 3 files changed, 160 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 31aa96ab05d..1d540e2a10e 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -2705,11 +2705,11 @@ row_count() call bug4905()| select row_count()| row_count() -0 +-1 call bug4905()| select row_count()| row_count() -0 +-1 select * from t3| s1 1 @@ -5471,4 +5471,85 @@ CHF DROP FUNCTION bug21493| DROP TABLE t3,t4| End of 5.0 tests +DROP TABLE IF EXISTS bug23760| +DROP TABLE IF EXISTS bug23760_log| +DROP PROCEDURE IF EXISTS bug23760_update_log| +DROP PROCEDURE IF EXISTS bug23760_test_row_count| +DROP FUNCTION IF EXISTS bug23760_rc_test| +CREATE TABLE bug23760 ( +id INT NOT NULL AUTO_INCREMENT , +num INT NOT NULL , +PRIMARY KEY ( id ) +)| +CREATE TABLE bug23760_log ( +id INT NOT NULL AUTO_INCREMENT , +reason VARCHAR(50)NULL , +ammount INT NOT NULL , +PRIMARY KEY ( id ) +)| +CREATE PROCEDURE bug23760_update_log(r Varchar(50), a INT) +BEGIN +INSERT INTO bug23760_log (reason, ammount) VALUES(r, a); +END| +CREATE PROCEDURE bug23760_test_row_count() +BEGIN +UPDATE bug23760 SET num = num + 1; +CALL bug23760_update_log('Test is working', ROW_COUNT()); +UPDATE bug23760 SET num = num - 1; +END| +CREATE PROCEDURE bug23760_test_row_count2(level INT) +BEGIN +IF level THEN +UPDATE bug23760 SET num = num + 1; +CALL bug23760_update_log('Test2 is working', ROW_COUNT()); +CALL bug23760_test_row_count2(level - 1); +END IF; +END| +CREATE FUNCTION bug23760_rc_test(in_var INT) RETURNS INT RETURN in_var| +INSERT INTO bug23760 (num) VALUES (0), (1), (1), (2), (3), (5), (8)| +SELECT ROW_COUNT()| +ROW_COUNT() +7 +CALL bug23760_test_row_count()| +SELECT * FROM bug23760_log ORDER BY id| +id reason ammount +1 Test is working 7 +SET @save_max_sp_recursion= @@max_sp_recursion_depth| +SELECT @save_max_sp_recursion| +@save_max_sp_recursion +0 +SET max_sp_recursion_depth= 5| +SELECT @@max_sp_recursion_depth| +@@max_sp_recursion_depth +5 +CALL bug23760_test_row_count2(2)| +SELECT ROW_COUNT()| +ROW_COUNT() +1 +SELECT * FROM bug23760_log ORDER BY id| +id reason ammount +1 Test is working 7 +2 Test2 is working 7 +3 Test2 is working 7 +SELECT * FROM bug23760 ORDER by ID| +id num +1 2 +2 3 +3 3 +4 4 +5 5 +6 7 +7 10 +SET max_sp_recursion_depth= @save_max_sp_recursion| +SELECT bug23760_rc_test(123)| +bug23760_rc_test(123) +123 +INSERT INTO bug23760 (num) VALUES (13), (21), (34), (55)| +SELECT bug23760_rc_test(ROW_COUNT())| +bug23760_rc_test(ROW_COUNT()) +4 +DROP TABLE bug23760, bug23760_log| +DROP PROCEDURE bug23760_update_log| +DROP PROCEDURE bug23760_test_row_count| +DROP FUNCTION bug23760_rc_test| drop table t1,t2; diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index a6f64161c0f..137bd7f4c23 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -6426,6 +6426,83 @@ DROP TABLE t3,t4| --echo End of 5.0 tests +# +# BUG#23760: ROW_COUNT() and store procedure not owrking together +# +--disable_warnings +DROP TABLE IF EXISTS bug23760| +DROP TABLE IF EXISTS bug23760_log| +DROP PROCEDURE IF EXISTS bug23760_update_log| +DROP PROCEDURE IF EXISTS bug23760_test_row_count| +DROP FUNCTION IF EXISTS bug23760_rc_test| +--enable_warnings +CREATE TABLE bug23760 ( + id INT NOT NULL AUTO_INCREMENT , + num INT NOT NULL , + PRIMARY KEY ( id ) +)| + +CREATE TABLE bug23760_log ( + id INT NOT NULL AUTO_INCREMENT , + reason VARCHAR(50)NULL , + ammount INT NOT NULL , + PRIMARY KEY ( id ) +)| + +CREATE PROCEDURE bug23760_update_log(r Varchar(50), a INT) +BEGIN + INSERT INTO bug23760_log (reason, ammount) VALUES(r, a); +END| + +CREATE PROCEDURE bug23760_test_row_count() +BEGIN + UPDATE bug23760 SET num = num + 1; + CALL bug23760_update_log('Test is working', ROW_COUNT()); + UPDATE bug23760 SET num = num - 1; +END| + + +CREATE PROCEDURE bug23760_test_row_count2(level INT) +BEGIN + IF level THEN + UPDATE bug23760 SET num = num + 1; + CALL bug23760_update_log('Test2 is working', ROW_COUNT()); + CALL bug23760_test_row_count2(level - 1); + END IF; +END| + +CREATE FUNCTION bug23760_rc_test(in_var INT) RETURNS INT RETURN in_var| + +INSERT INTO bug23760 (num) VALUES (0), (1), (1), (2), (3), (5), (8)| +SELECT ROW_COUNT()| + +CALL bug23760_test_row_count()| +SELECT * FROM bug23760_log ORDER BY id| + +SET @save_max_sp_recursion= @@max_sp_recursion_depth| +SELECT @save_max_sp_recursion| +SET max_sp_recursion_depth= 5| +SELECT @@max_sp_recursion_depth| +CALL bug23760_test_row_count2(2)| +SELECT ROW_COUNT()| +SELECT * FROM bug23760_log ORDER BY id| +SELECT * FROM bug23760 ORDER by ID| +SET max_sp_recursion_depth= @save_max_sp_recursion| + +SELECT bug23760_rc_test(123)| +INSERT INTO bug23760 (num) VALUES (13), (21), (34), (55)| +SELECT bug23760_rc_test(ROW_COUNT())| + +DROP TABLE bug23760, bug23760_log| +DROP PROCEDURE bug23760_update_log| +DROP PROCEDURE bug23760_test_row_count| +DROP FUNCTION bug23760_rc_test| + +# +# NOTE: The delimiter is `|`, and not `;`. It is changed to `;` +# at the end of the file! +# + # # BUG#NNNN: New bug synopsis # diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 4992d2514c9..fd8fc98aed6 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4456,8 +4456,6 @@ end_with_restore_list: select_limit= thd->variables.select_limit; thd->variables.select_limit= HA_POS_ERROR; - thd->row_count_func= 0; - /* We never write CALL statements into binlog: - If the mode is non-prelocked, each statement will be logged From c674b88bfc484580aaa950951c0c58ada1eda362 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 14 Nov 2006 19:45:52 +0100 Subject: [PATCH 031/131] Update test cases after run with --check-testcases --- mysql-test/r/limit.result | 1 + mysql-test/r/lowercase_fs_off.result | 1 + mysql-test/t/limit.test | 2 +- mysql-test/t/lowercase_fs_off.test | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/limit.result b/mysql-test/r/limit.result index be2776ef533..ac96ac8ff17 100644 --- a/mysql-test/r/limit.result +++ b/mysql-test/r/limit.result @@ -90,3 +90,4 @@ id select_type table type possible_keys key key_len ref rows Extra select sum(a) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3; c 28 +drop table t1; diff --git a/mysql-test/r/lowercase_fs_off.result b/mysql-test/r/lowercase_fs_off.result index f610b959a47..ecb21261987 100644 --- a/mysql-test/r/lowercase_fs_off.result +++ b/mysql-test/r/lowercase_fs_off.result @@ -8,4 +8,5 @@ create database d2; ERROR 42000: Access denied for user 'sample'@'localhost' to database 'd2' create database D1; ERROR 42000: Access denied for user 'sample'@'localhost' to database 'D1' +drop user 'sample'@'localhost'; drop database if exists d1; diff --git a/mysql-test/t/limit.test b/mysql-test/t/limit.test index cf7789428b2..0c18a65bfd6 100644 --- a/mysql-test/t/limit.test +++ b/mysql-test/t/limit.test @@ -69,5 +69,5 @@ explain select count(*) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3; select count(*) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3; explain select sum(a) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3; select sum(a) c FROM t1 WHERE a > 0 ORDER BY c LIMIT 3; - +drop table t1; # End of 4.1 tests diff --git a/mysql-test/t/lowercase_fs_off.test b/mysql-test/t/lowercase_fs_off.test index 883315994fe..414027cb485 100644 --- a/mysql-test/t/lowercase_fs_off.test +++ b/mysql-test/t/lowercase_fs_off.test @@ -21,6 +21,7 @@ create database D1; disconnect sample; connection master; +drop user 'sample'@'localhost'; drop database if exists d1; disconnect master; connection default; From ea3bf1b2479f788ebb2e0d35cd8ae9d9c0dd192b Mon Sep 17 00:00:00 2001 From: "tnurnberg@salvation.intern.azundris.com" <> Date: Wed, 15 Nov 2006 01:27:39 +0100 Subject: [PATCH 032/131] Bug#16456 "RBR: rpl_sp.test expects query to fail, but passes in RBR" calling (rather than defining) non-deterministic SP in SBR (as opposed to RBR or mixed) will throw an error now. require mixed mode for tests now. SBR will now fail when calling non-deter SPs and SFs (as it should), and RBR already failed by virtue of giving different results for "show binlog" than the results-file has. also test for 16456 now. lastly make amends because one of the tests fails with a new error # now as code was added to sql_trigger.cc while test was disabled. --- mysql-test/mysql-test-run.pl | 6 +++++- mysql-test/r/func_time.result | 2 +- mysql-test/r/rpl_sp.result | 32 ++++++++++++++++++++++++++------ mysql-test/t/disabled.def | 1 - mysql-test/t/rpl_sp.test | 33 ++++++++++++++++++++++++++++++++- sql/item_func.cc | 12 ++++++++++++ sql/sql_parse.cc | 12 ++++++++++++ 7 files changed, 88 insertions(+), 10 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 0c46bbeac79..c36ceb4589d 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -709,13 +709,17 @@ sub command_line_setup () { # Find out type of logging that are being used # -------------------------------------------------------------------------- # NOTE if the default binlog format is changed, this has to be changed - $used_binlog_format= "stmt"; + $used_binlog_format= "mixed"; foreach my $arg ( @opt_extra_mysqld_opt ) { if ( defined mtr_match_substring($arg,"binlog-format=row")) { $used_binlog_format= "row"; } + elsif ( defined mtr_match_substring($arg,"binlog-format=statement")) + { + $used_binlog_format= "stmt"; + } } mtr_report("Using binlog format '$used_binlog_format'"); diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index 7cafd641dd6..2932cd4cfec 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -981,7 +981,7 @@ CREATE TABLE t1(f1 TIME); INSERT INTO t1 VALUES('916:00:00 a'); Warnings: Warning 1265 Data truncated for column 'f1' at row 1 -Warning 1264 Out of range value adjusted for column 'f1' at row 1 +Warning 1264 Out of range value for column 'f1' at row 1 SELECT * FROM t1; f1 838:59:59 diff --git a/mysql-test/r/rpl_sp.result b/mysql-test/r/rpl_sp.result index 261e7cb072c..acad2975055 100644 --- a/mysql-test/r/rpl_sp.result +++ b/mysql-test/r/rpl_sp.result @@ -104,10 +104,10 @@ begin insert into t2 values(20),(20); end| call foo4(); -ERROR 23000: Duplicate entry '20' for key 1 +ERROR 23000: Duplicate entry '20' for key 'a' show warnings; Level Code Message -Error 1062 Duplicate entry '20' for key 1 +Error 1062 Duplicate entry '20' for key 'a' select * from t2; a 20 @@ -124,6 +124,9 @@ select * from mysql.proc where name="foo4" and db='mysqltest1'; db name type specific_name language sql_data_access is_deterministic security_type param_list returns body definer created modified sql_mode comment select * from mysql.proc where name="foo4" and db='mysqltest1'; db name type specific_name language sql_data_access is_deterministic security_type param_list returns body definer created modified sql_mode comment +set binlog_format=STATEMENT; +call foo(); +ERROR HY000: Slave running with --log-slave-updates must use row-based binary logging to be able to replicate row-based binary log events drop procedure foo; drop procedure foo2; drop procedure foo3; @@ -181,7 +184,7 @@ end| ERROR HY000: You do not have the SUPER privilege and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable) set global log_bin_trust_routine_creators=1; Warnings: -Warning 1287 'log_bin_trust_routine_creators' is deprecated; use 'log_bin_trust_function_creators' instead +Warning 1541 The syntax 'log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use 'log_bin_trust_function_creators' instead set global log_bin_trust_function_creators=0; set global log_bin_trust_function_creators=1; set global log_bin_trust_function_creators=1; @@ -241,9 +244,9 @@ return 10; end| do fn1(100); Warnings: -Error 1062 Duplicate entry '100' for key 1 +Error 1062 Duplicate entry '100' for key 'a' select fn1(20); -ERROR 23000: Duplicate entry '20' for key 1 +ERROR 23000: Duplicate entry '20' for key 'a' select * from t2; a 20 @@ -252,8 +255,17 @@ select * from t2; a 20 100 +set binlog_format=STATEMENT; +create function fn16456() +returns int +begin +return unix_timestamp(); +end| +select fn16456(); +ERROR HY000: Slave running with --log-slave-updates must use row-based binary logging to be able to replicate row-based binary log events +drop function fn16456; create trigger trg before insert on t1 for each row set new.a= 10; -ERROR 42000: Access denied; you need the SUPER privilege for this operation +ERROR 42000: TRIGGER command denied to user 'zedjzlcsjhd'@'localhost' for table 't1' delete from t1; create trigger trg before insert on t1 for each row set new.a= 10; insert into t1 values (1); @@ -364,6 +376,12 @@ return 10; end master-bin.000001 # Query 1 # use `mysqltest1`; SELECT `fn1`(100) master-bin.000001 # Query 1 # use `mysqltest1`; SELECT `fn1`(20) +master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` function fn16456() +returns int +begin +return unix_timestamp(); +end +master-bin.000001 # Query 1 # use `mysqltest1`; drop function fn16456 master-bin.000001 # Query 1 # use `mysqltest1`; delete from t1 master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` trigger trg before insert on t1 for each row set new.a= 10 master-bin.000001 # Query 1 # use `mysqltest1`; insert into t1 values (1) @@ -465,3 +483,5 @@ RETURN 0 DROP PROCEDURE p1; DROP FUNCTION f1; drop table t1; +End of 5.0 tests +End of 5.1 tests diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index 6af71e32cc4..b9a0f83b8b7 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -23,7 +23,6 @@ rpl_ndb_ddl : BUG#18946 result file needs update + test needs to ch rpl_ndb_innodb2ndb : Bug #19710 Cluster replication to partition table fails on DELETE FROM statement rpl_ndb_myisam2ndb : Bug #19710 Cluster replication to partition table fails on DELETE FROM statement rpl_row_blob_innodb : BUG#18980 2006-04-10 kent Test fails randomly -rpl_sp : BUG#16456 2006-02-16 jmiller rpl_multi_engine : BUG#22583 2006-09-23 lars # the below testcase have been reworked to avoid the bug, test contains comment, keep bug open diff --git a/mysql-test/t/rpl_sp.test b/mysql-test/t/rpl_sp.test index 22ab72df104..7066a77b70e 100644 --- a/mysql-test/t/rpl_sp.test +++ b/mysql-test/t/rpl_sp.test @@ -8,6 +8,7 @@ # still accepted (this test also checks that the new name is # accepted). The old name could be removed in 5.1 or 6.0. +source include/have_binlog_format_mixed.inc; source include/master-slave.inc; # we need a db != test, where we don't have automatic grants @@ -172,6 +173,15 @@ select * from mysql.proc where name="foo4" and db='mysqltest1'; sync_slave_with_master; select * from mysql.proc where name="foo4" and db='mysqltest1'; +# fail if non-deterministic SP is called in SBR, bug#16456 +let $oblf=`select @@SESSION.BINLOG_FORMAT`; +set binlog_format=STATEMENT; +--error ER_BINLOG_ROW_RBR_TO_SBR +call foo(); +--disable_query_log +eval set binlog_format=$oblf; +--enable_query_log + # ********************** PART 2 : FUNCTIONS *************** connection master; @@ -316,10 +326,31 @@ sync_slave_with_master; # check that this failed-in-the-middle replicated right: select * from t2; +# fail if non-deterministic SF is called in SBR, bug#16456 +connection master; +let $oblf=`select @@SESSION.BINLOG_FORMAT`; +set binlog_format=STATEMENT; +delimiter |; +create function fn16456() + returns int +begin + return unix_timestamp(); +end| +delimiter ;| +--error ER_BINLOG_ROW_RBR_TO_SBR +select fn16456(); +--disable_query_log +eval set binlog_format=$oblf; +--enable_query_log +drop function fn16456; + + # ********************** PART 3 : TRIGGERS *************** connection con1; ---error 1227 +# now fails due to missing trigger grant (err 1142 i/o 1227) due to new +# check in sql_trigger.cc (v1.44) by anozdrin on 2006/02/01 --azundris +--error ER_TABLEACCESS_DENIED_ERROR create trigger trg before insert on t1 for each row set new.a= 10; connection master; diff --git a/sql/item_func.cc b/sql/item_func.cc index 4a069e662f9..760b36b4983 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -4974,6 +4974,18 @@ Item_func_sp::execute_impl(THD *thd, Field *return_value_fld) if (find_and_check_access(thd)) goto error; + /* + Throw an error if a non-deterministic function is called while + statement-based replication (SBR) is active. + */ + if (!m_sp->m_chistics->detistic && + (mysql_bin_log.is_open() && + thd->variables.binlog_format == BINLOG_FORMAT_STMT)) + { + my_error(ER_BINLOG_ROW_RBR_TO_SBR, MYF(0)); + goto error; + } + /* Disable the binlogging if this is not a SELECT statement. If this is a SELECT, leave binlogging on, so execute_function() code writes the diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index a3772e3709a..a1e4b84341c 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4546,6 +4546,18 @@ end_with_restore_list: goto error; } + /* + Throw an error if a non-deterministic procedure is called while + statement-based replication (SBR) is active. + */ + if (!sp->m_chistics->detistic && + (mysql_bin_log.is_open() && + thd->variables.binlog_format == BINLOG_FORMAT_STMT)) + { + my_error(ER_BINLOG_ROW_RBR_TO_SBR, MYF(0)); + goto error; + } + my_bool nsok= thd->net.no_send_ok; thd->net.no_send_ok= TRUE; if (sp->m_flags & sp_head::MULTI_RESULTS) From 15c3ed7517aeb7cc89277afc8beaf3d610cf02f8 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Wed, 15 Nov 2006 10:23:27 +0100 Subject: [PATCH 033/131] Cleanup after test cases --- mysql-test/r/init_connect.result | 2 +- mysql-test/r/key_cache.result | 4 ++++ mysql-test/r/mysqldump.result | 6 +++--- mysql-test/r/rpl_deadlock.result | 2 ++ mysql-test/r/rpl_drop_db.result | 2 ++ mysql-test/r/rpl_ignore_revoke.result | 1 + mysql-test/r/rpl_init_slave.result | 3 +++ mysql-test/r/rpl_max_relay_size.result | 2 ++ mysql-test/r/rpl_sp.result | 2 ++ mysql-test/r/rpl_timezone.result | 2 ++ mysql-test/r/rpl_variables.result | 2 ++ mysql-test/r/view_grant.result | 14 +++++++------- mysql-test/t/init_connect.test | 4 +++- mysql-test/t/key_cache.test | 7 ++++++- mysql-test/t/mysqldump.test | 6 +++--- mysql-test/t/rpl_deadlock.test | 3 ++- mysql-test/t/rpl_drop_db.test | 7 ++++++- mysql-test/t/rpl_ignore_revoke.test | 4 ++++ mysql-test/t/rpl_init_slave.test | 6 ++++++ mysql-test/t/rpl_max_relay_size.test | 5 +++++ mysql-test/t/rpl_sp.test | 6 ++++++ mysql-test/t/rpl_timezone.test | 7 +++++++ mysql-test/t/rpl_variables.test | 6 ++++++ mysql-test/t/view_grant.test | 16 ++++++++-------- 24 files changed, 93 insertions(+), 26 deletions(-) diff --git a/mysql-test/r/init_connect.result b/mysql-test/r/init_connect.result index f90ee5913a1..f5ec0bdc932 100644 --- a/mysql-test/r/init_connect.result +++ b/mysql-test/r/init_connect.result @@ -132,7 +132,7 @@ x 17 19 drop trigger trg1; -set global init_connect=default; +set global init_connect="set @a='a\\0c'"; revoke all privileges, grant option from mysqltest1@localhost; drop user mysqltest1@localhost; drop table t1, t2; diff --git a/mysql-test/r/key_cache.result b/mysql-test/r/key_cache.result index 406a92b9a08..a1bf3d0e128 100644 --- a/mysql-test/r/key_cache.result +++ b/mysql-test/r/key_cache.result @@ -284,12 +284,15 @@ insert t1 values ('aaabbb'); check table t1; Table Op Msg_type Msg_text test.t1 check status OK +set @my_key_cache_block_size= @@global.key_cache_block_size; set GLOBAL key_cache_block_size=2048; check table t1; Table Op Msg_type Msg_text test.t1 check status OK drop table t1; +set global key_cache_block_size= @my_key_cache_block_size; CREATE TABLE t1(a int NOT NULL AUTO_INCREMENT PRIMARY KEY); +SET @my_key_cache_block_size= @@global.key_cache_block_size; SET GLOBAL key_cache_block_size=1536; INSERT INTO t1 VALUES (1); SELECT @@key_cache_block_size; @@ -331,6 +334,7 @@ CHECK TABLE t1; Table Op Msg_type Msg_text test.t1 check status OK DROP TABLE t1,t2; +set global key_cache_block_size= @my_key_cache_block_size; set @@global.key_buffer_size=0; Warnings: Warning 1438 Cannot drop default keycache diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index 54583febbc8..35a79d6a805 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -3089,7 +3089,7 @@ drop user mysqltest_1@localhost; # create database mysqldump_myDB; use mysqldump_myDB; -create user myDB_User; +create user myDB_User@localhost; grant create, create view, select, insert on mysqldump_myDB.* to myDB_User@localhost; create table t1 (c1 int); insert into t1 values (3); @@ -3102,7 +3102,7 @@ drop view v1; drop table t1; drop table u1; revoke all privileges on mysqldump_myDB.* from myDB_User@localhost; -drop user myDB_User; +drop user myDB_User@localhost; drop database mysqldump_myDB; flush privileges; # Bug #21424 continues from here. @@ -3120,7 +3120,7 @@ drop view v1; drop table t1; drop table u1; revoke all privileges on mysqldump_myDB.* from myDB_User@localhost; -drop user myDB_User; +drop user myDB_User@localhost; drop database mysqldump_myDB; use test; # diff --git a/mysql-test/r/rpl_deadlock.result b/mysql-test/r/rpl_deadlock.result index 541e12b806f..63b15bc1a1f 100644 --- a/mysql-test/r/rpl_deadlock.result +++ b/mysql-test/r/rpl_deadlock.result @@ -126,6 +126,7 @@ Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # +set @my_max_relay_log_size= @@global.max_relay_log_size; set global max_relay_log_size=0; stop slave; change master to master_log_pos=532; @@ -178,3 +179,4 @@ Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master # drop table t1,t2,t3,t4; +set global max_relay_log_size= @my_max_relay_log_size; diff --git a/mysql-test/r/rpl_drop_db.result b/mysql-test/r/rpl_drop_db.result index ce9d39e87f6..97a24d980b6 100644 --- a/mysql-test/r/rpl_drop_db.result +++ b/mysql-test/r/rpl_drop_db.result @@ -33,3 +33,5 @@ n 1234 drop table t1; stop slave; +drop database mysqltest1; +drop database mysqltest1; diff --git a/mysql-test/r/rpl_ignore_revoke.result b/mysql-test/r/rpl_ignore_revoke.result index 42625119f28..b1ccd2f0442 100644 --- a/mysql-test/r/rpl_ignore_revoke.result +++ b/mysql-test/r/rpl_ignore_revoke.result @@ -27,3 +27,4 @@ select_priv Y revoke select on *.* FROM 'user_foo'; delete from mysql.user where user="user_foo"; +delete from mysql.user where user="user_foo"; diff --git a/mysql-test/r/rpl_init_slave.result b/mysql-test/r/rpl_init_slave.result index 83d0a3289a2..f92fb9b4c1d 100644 --- a/mysql-test/r/rpl_init_slave.result +++ b/mysql-test/r/rpl_init_slave.result @@ -17,8 +17,11 @@ init_slave show variables like 'max_connections'; Variable_name Value max_connections 100 +set @my_global_init_connect= @@global.init_connect; set global init_connect="set @c=1"; show variables like 'init_connect'; Variable_name Value init_connect set @c=1 stop slave; +set global init_connect= @my_global_init_connect; +set global max_connections= default; diff --git a/mysql-test/r/rpl_max_relay_size.result b/mysql-test/r/rpl_max_relay_size.result index 1fa49db6013..95c9ae79d05 100644 --- a/mysql-test/r/rpl_max_relay_size.result +++ b/mysql-test/r/rpl_max_relay_size.result @@ -14,6 +14,7 @@ reset slave; # # Test 1 # +set @my_max_binlog_size= @@global.max_binlog_size; set global max_binlog_size=8192; set global max_relay_log_size=8192-1; select @@global.max_relay_log_size; @@ -266,6 +267,7 @@ File master-bin.000002 Position 98 Binlog_Do_DB Binlog_Ignore_DB +set global max_binlog_size= @my_max_binlog_size; # # End of 4.1 tests # diff --git a/mysql-test/r/rpl_sp.result b/mysql-test/r/rpl_sp.result index 7b096b27733..7f152862373 100644 --- a/mysql-test/r/rpl_sp.result +++ b/mysql-test/r/rpl_sp.result @@ -465,3 +465,5 @@ RETURN 0 DROP PROCEDURE p1; DROP FUNCTION f1; drop table t1; +set global log_bin_trust_function_creators=0; +set global log_bin_trust_function_creators=0; diff --git a/mysql-test/r/rpl_timezone.result b/mysql-test/r/rpl_timezone.result index 96a892f00fc..fde8709843e 100644 --- a/mysql-test/r/rpl_timezone.result +++ b/mysql-test/r/rpl_timezone.result @@ -4,6 +4,7 @@ reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; +set @my_time_zone= @@global.time_zone; set timestamp=100000000; create table t1 (t timestamp); create table t2 (t char(32)); @@ -126,3 +127,4 @@ t 2003-12-31 23:00:00 2005-01-01 08:00:00 drop table t1, t2; +set global time_zone= @my_time_zone; diff --git a/mysql-test/r/rpl_variables.result b/mysql-test/r/rpl_variables.result index 25b5ca13f77..6c532e33983 100644 --- a/mysql-test/r/rpl_variables.result +++ b/mysql-test/r/rpl_variables.result @@ -4,6 +4,7 @@ reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; +set @my_slave_net_timeout =@@global.slave_net_timeout; set global slave_net_timeout=100; set global sql_slave_skip_counter=100; show variables like 'slave_compressed_protocol'; @@ -15,3 +16,4 @@ slave_load_tmpdir SLAVE_LOAD_TMPDIR show variables like 'slave_skip_errors'; Variable_name Value slave_skip_errors 3,100,137,643,1752 +set global slave_net_timeout =@my_slave_net_timeout; diff --git a/mysql-test/r/view_grant.result b/mysql-test/r/view_grant.result index 35e7afc0a7b..cf9ba1c604d 100644 --- a/mysql-test/r/view_grant.result +++ b/mysql-test/r/view_grant.result @@ -544,13 +544,13 @@ CREATE SQL SECURITY DEFINER VIEW mysqltest1.v_tu AS SELECT * FROM mysqltest1.t1; CREATE SQL SECURITY DEFINER VIEW mysqltest1.v_tus AS SELECT * FROM mysqltest1.t1; CREATE SQL SECURITY DEFINER VIEW mysqltest1.v_td AS SELECT * FROM mysqltest1.t1; CREATE SQL SECURITY DEFINER VIEW mysqltest1.v_tds AS SELECT * FROM mysqltest1.t1; -GRANT SELECT, INSERT, UPDATE, DELETE ON mysqltest1.v_t1 TO readonly; -GRANT SELECT ON mysqltest1.v_ts TO readonly; -GRANT INSERT ON mysqltest1.v_ti TO readonly; -GRANT UPDATE ON mysqltest1.v_tu TO readonly; -GRANT UPDATE,SELECT ON mysqltest1.v_tus TO readonly; -GRANT DELETE ON mysqltest1.v_td TO readonly; -GRANT DELETE,SELECT ON mysqltest1.v_tds TO readonly; +GRANT SELECT, INSERT, UPDATE, DELETE ON mysqltest1.v_t1 TO readonly@localhost; +GRANT SELECT ON mysqltest1.v_ts TO readonly@localhost; +GRANT INSERT ON mysqltest1.v_ti TO readonly@localhost; +GRANT UPDATE ON mysqltest1.v_tu TO readonly@localhost; +GRANT UPDATE,SELECT ON mysqltest1.v_tus TO readonly@localhost; +GRANT DELETE ON mysqltest1.v_td TO readonly@localhost; +GRANT DELETE,SELECT ON mysqltest1.v_tds TO readonly@localhost; SELECT * FROM mysqltest1.v_t1; ERROR HY000: View 'mysqltest1.v_t1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them INSERT INTO mysqltest1.v_t1 VALUES(4); diff --git a/mysql-test/t/init_connect.test b/mysql-test/t/init_connect.test index 31a98df33df..cf98f608982 100644 --- a/mysql-test/t/init_connect.test +++ b/mysql-test/t/init_connect.test @@ -232,7 +232,9 @@ connection con0; disconnect con1; drop trigger trg1; -set global init_connect=default; +# Set init connect back to the value provided in init_connect-master.opt +# doesn't matter as server will be restarted +set global init_connect="set @a='a\\0c'"; revoke all privileges, grant option from mysqltest1@localhost; drop user mysqltest1@localhost; diff --git a/mysql-test/t/key_cache.test b/mysql-test/t/key_cache.test index 4001e0df4af..3044964ebc3 100644 --- a/mysql-test/t/key_cache.test +++ b/mysql-test/t/key_cache.test @@ -164,16 +164,19 @@ create table t1 (mytext text, FULLTEXT (mytext)); insert t1 values ('aaabbb'); check table t1; +set @my_key_cache_block_size= @@global.key_cache_block_size; set GLOBAL key_cache_block_size=2048; check table t1; - drop table t1; +# Restore the changed variable value +set global key_cache_block_size= @my_key_cache_block_size; # # Bug #19079: corrupted index when key_cache_block_size is not multiple of # myisam_block_size CREATE TABLE t1(a int NOT NULL AUTO_INCREMENT PRIMARY KEY); +SET @my_key_cache_block_size= @@global.key_cache_block_size; SET GLOBAL key_cache_block_size=1536; INSERT INTO t1 VALUES (1); SELECT @@key_cache_block_size; @@ -206,6 +209,8 @@ SELECT COUNT(*) FROM t1; SELECT @@key_cache_block_size; CHECK TABLE t1; DROP TABLE t1,t2; +# Restore changed variables +set global key_cache_block_size= @my_key_cache_block_size; # # Bug#10473 - Can't set 'key_buffer_size' system variable to ZERO diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 72aad395ec0..5e604061744 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -1341,7 +1341,7 @@ connect (root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK); connection root; create database mysqldump_myDB; use mysqldump_myDB; -create user myDB_User; +create user myDB_User@localhost; grant create, create view, select, insert on mysqldump_myDB.* to myDB_User@localhost; create table t1 (c1 int); insert into t1 values (3); @@ -1364,7 +1364,7 @@ drop view v1; drop table t1; drop table u1; revoke all privileges on mysqldump_myDB.* from myDB_User@localhost; -drop user myDB_User; +drop user myDB_User@localhost; drop database mysqldump_myDB; flush privileges; @@ -1389,7 +1389,7 @@ drop view v1; drop table t1; drop table u1; revoke all privileges on mysqldump_myDB.* from myDB_User@localhost; -drop user myDB_User; +drop user myDB_User@localhost; drop database mysqldump_myDB; use test; diff --git a/mysql-test/t/rpl_deadlock.test b/mysql-test/t/rpl_deadlock.test index 684cb54611c..1a48e4d417c 100644 --- a/mysql-test/t/rpl_deadlock.test +++ b/mysql-test/t/rpl_deadlock.test @@ -92,7 +92,7 @@ show slave status; # Now we repeat 2), but with BEGIN in the same relay log as # COMMIT (to see if seeking into hot log is ok). - +set @my_max_relay_log_size= @@global.max_relay_log_size; set global max_relay_log_size=0; # This is really copy-paste of 2) of above @@ -115,5 +115,6 @@ show slave status; connection master; drop table t1,t2,t3,t4; sync_slave_with_master; +set global max_relay_log_size= @my_max_relay_log_size; # End of 4.1 tests diff --git a/mysql-test/t/rpl_drop_db.test b/mysql-test/t/rpl_drop_db.test index 3ac0d593fee..f14c9bc0164 100644 --- a/mysql-test/t/rpl_drop_db.test +++ b/mysql-test/t/rpl_drop_db.test @@ -53,5 +53,10 @@ sync_slave_with_master; #cleanup connection slave; stop slave; -system rm -rf $MYSQLTEST_VARDIR/master-data/mysqltest1; +drop database mysqltest1; + +connection master; +# Remove the "extra" file created above +--remove_file $MYSQLTEST_VARDIR/master-data/mysqltest1/f1.txt +drop database mysqltest1; diff --git a/mysql-test/t/rpl_ignore_revoke.test b/mysql-test/t/rpl_ignore_revoke.test index cdeb40df069..00171605a92 100644 --- a/mysql-test/t/rpl_ignore_revoke.test +++ b/mysql-test/t/rpl_ignore_revoke.test @@ -45,3 +45,7 @@ revoke select on *.* FROM 'user_foo'; connection master; delete from mysql.user where user="user_foo"; sync_slave_with_master; + +# Since changes to mysql.* are ignored, the revoke need to +# be done on slave as well +delete from mysql.user where user="user_foo"; diff --git a/mysql-test/t/rpl_init_slave.test b/mysql-test/t/rpl_init_slave.test index cefb04a7b75..139b4902e12 100644 --- a/mysql-test/t/rpl_init_slave.test +++ b/mysql-test/t/rpl_init_slave.test @@ -17,6 +17,8 @@ show variables like 'max_connections'; save_master_pos; connection slave; sync_with_master; +# Save variable value +set @my_global_init_connect= @@global.init_connect; set global init_connect="set @c=1"; show variables like 'init_connect'; connection master; @@ -25,4 +27,8 @@ connection slave; sync_with_master; stop slave; +# Restore changed global variable +set global init_connect= @my_global_init_connect; +set global max_connections= default; + # End of 4.1 tests diff --git a/mysql-test/t/rpl_max_relay_size.test b/mysql-test/t/rpl_max_relay_size.test index be1fbf172fc..e5278ff5727 100644 --- a/mysql-test/t/rpl_max_relay_size.test +++ b/mysql-test/t/rpl_max_relay_size.test @@ -32,6 +32,7 @@ reset slave; --echo # Test 1 --echo # +set @my_max_binlog_size= @@global.max_binlog_size; set global max_binlog_size=8192; set global max_relay_log_size=8192-1; # mapped to 4096 select @@global.max_relay_log_size; @@ -127,6 +128,10 @@ connection master; flush logs; show master status; +# Restore max_binlog_size +connection slave; +set global max_binlog_size= @my_max_binlog_size; + --echo # --echo # End of 4.1 tests --echo # diff --git a/mysql-test/t/rpl_sp.test b/mysql-test/t/rpl_sp.test index 7479794eded..b2a34a63735 100644 --- a/mysql-test/t/rpl_sp.test +++ b/mysql-test/t/rpl_sp.test @@ -519,3 +519,9 @@ DROP FUNCTION f1; connection master; drop table t1; sync_slave_with_master; + +# Restore log_bin_trust_function_creators to original value +set global log_bin_trust_function_creators=0; +connection master; +set global log_bin_trust_function_creators=0; + diff --git a/mysql-test/t/rpl_timezone.test b/mysql-test/t/rpl_timezone.test index 0f35c9dc0b6..6ed5b21ace0 100644 --- a/mysql-test/t/rpl_timezone.test +++ b/mysql-test/t/rpl_timezone.test @@ -12,6 +12,9 @@ source include/master-slave.inc; +# Save original timezone +set @my_time_zone= @@global.time_zone; + # Some preparations let $VERSION=`select version()`; set timestamp=100000000; # for fixed output of mysqlbinlog @@ -124,3 +127,7 @@ drop table t1, t2; sync_slave_with_master; # End of 4.1 tests + +# Restore original timezone +connection master; +set global time_zone= @my_time_zone; diff --git a/mysql-test/t/rpl_variables.test b/mysql-test/t/rpl_variables.test index 57ae2b9c3c4..d0801e524e4 100644 --- a/mysql-test/t/rpl_variables.test +++ b/mysql-test/t/rpl_variables.test @@ -1,5 +1,8 @@ source include/master-slave.inc; +# Init for rstore of variable values +set @my_slave_net_timeout =@@global.slave_net_timeout; + set global slave_net_timeout=100; set global sql_slave_skip_counter=100; @@ -12,3 +15,6 @@ show variables like 'slave_load_tmpdir'; # We just set some arbitrary values in variables-master.opt so we can test # that a list of values works correctly show variables like 'slave_skip_errors'; + +# Restore touched values +set global slave_net_timeout =@my_slave_net_timeout; diff --git a/mysql-test/t/view_grant.test b/mysql-test/t/view_grant.test index 8bc34cfe148..9a4b75add13 100644 --- a/mysql-test/t/view_grant.test +++ b/mysql-test/t/view_grant.test @@ -727,13 +727,13 @@ CREATE SQL SECURITY DEFINER VIEW mysqltest1.v_tu AS SELECT * FROM mysqltest1.t1; CREATE SQL SECURITY DEFINER VIEW mysqltest1.v_tus AS SELECT * FROM mysqltest1.t1; CREATE SQL SECURITY DEFINER VIEW mysqltest1.v_td AS SELECT * FROM mysqltest1.t1; CREATE SQL SECURITY DEFINER VIEW mysqltest1.v_tds AS SELECT * FROM mysqltest1.t1; -GRANT SELECT, INSERT, UPDATE, DELETE ON mysqltest1.v_t1 TO readonly; -GRANT SELECT ON mysqltest1.v_ts TO readonly; -GRANT INSERT ON mysqltest1.v_ti TO readonly; -GRANT UPDATE ON mysqltest1.v_tu TO readonly; -GRANT UPDATE,SELECT ON mysqltest1.v_tus TO readonly; -GRANT DELETE ON mysqltest1.v_td TO readonly; -GRANT DELETE,SELECT ON mysqltest1.v_tds TO readonly; +GRANT SELECT, INSERT, UPDATE, DELETE ON mysqltest1.v_t1 TO readonly@localhost; +GRANT SELECT ON mysqltest1.v_ts TO readonly@localhost; +GRANT INSERT ON mysqltest1.v_ti TO readonly@localhost; +GRANT UPDATE ON mysqltest1.v_tu TO readonly@localhost; +GRANT UPDATE,SELECT ON mysqltest1.v_tus TO readonly@localhost; +GRANT DELETE ON mysqltest1.v_td TO readonly@localhost; +GRANT DELETE,SELECT ON mysqltest1.v_tds TO readonly@localhost; CONNECT (n1,localhost,readonly,,); CONNECTION n1; @@ -791,7 +791,7 @@ DROP VIEW mysqltest1.v_ti; DROP VIEW mysqltest1.v_ts; DROP VIEW mysqltest1.v_t1; DROP TABLE mysqltest1.t1; -DROP USER readonly@localhost; +DROP USER readonly@localhost; DROP DATABASE mysqltest1; # From 460e90a1c130657f325dc6c3dc416dd4c34cbb35 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Wed, 15 Nov 2006 10:26:14 +0100 Subject: [PATCH 034/131] Fix spelling error --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index a58f71e22c2..18fe2a6ce87 100644 --- a/configure.in +++ b/configure.in @@ -2428,7 +2428,7 @@ then sql_client_dirs="libmysql_r $sql_client_dirs" linked_client_targets="$linked_client_targets linked_libmysql_r_sources" AC_CONFIG_FILES(libmysql_r/Makefile) - AC_DEFINE([THREAD_SAFE_CLIENT], [1], [Should be client be thread safe]) + AC_DEFINE([THREAD_SAFE_CLIENT], [1], [Should the client be thread safe]) fi CLIENT_LIBS="$NON_THREADED_LIBS $openssl_libs $ZLIB_LIBS $STATIC_NSS_FLAGS" From c9b4603f907157ff05608e52227d8f8698977309 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Wed, 15 Nov 2006 13:22:38 +0100 Subject: [PATCH 035/131] Update result file for mysql_upgrade as we have more tables that is checked in 5.1 Fix merge errors --- mysql-test/r/mysql_upgrade.result | 46 ++++++++++++++++++++++ mysql-test/r/mysqldump.result | 1 - mysql-test/r/rpl_drop_db.result | 1 - mysql-test/r/rpl_row_max_relay_size.result | 2 + mysql-test/t/rpl_drop_db.test | 5 --- 5 files changed, 48 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/mysql_upgrade.result b/mysql-test/r/mysql_upgrade.result index 1f93d727561..e65b511fc41 100644 --- a/mysql-test/r/mysql_upgrade.result +++ b/mysql-test/r/mysql_upgrade.result @@ -1,14 +1,19 @@ Run mysql_upgrade once +cluster.binlog_index OK mysql.columns_priv OK mysql.db OK +mysql.event OK mysql.func OK +mysql.general_log OK mysql.help_category OK mysql.help_keyword OK mysql.help_relation OK mysql.help_topic OK mysql.host OK +mysql.plugin OK mysql.proc OK mysql.procs_priv OK +mysql.slow_log OK mysql.tables_priv OK mysql.time_zone OK mysql.time_zone_leap_second OK @@ -46,6 +51,18 @@ mysql.user OK 1 1 1 +@hadEventPriv :=1 +1 +1 +1 +1 +1 +@hadTriggerPriv :=1 +1 +1 +1 +1 +1 Run it again - should say already completed @hadGrantPriv:=1 1 @@ -77,17 +94,34 @@ Run it again - should say already completed 1 1 1 +@hadEventPriv :=1 +1 +1 +1 +1 +1 +@hadTriggerPriv :=1 +1 +1 +1 +1 +1 Force should run it regardless of wheter it's been run before +cluster.binlog_index OK mysql.columns_priv OK mysql.db OK +mysql.event OK mysql.func OK +mysql.general_log OK mysql.help_category OK mysql.help_keyword OK mysql.help_relation OK mysql.help_topic OK mysql.host OK +mysql.plugin OK mysql.proc OK mysql.procs_priv OK +mysql.slow_log OK mysql.tables_priv OK mysql.time_zone OK mysql.time_zone_leap_second OK @@ -125,3 +159,15 @@ mysql.user OK 1 1 1 +@hadEventPriv :=1 +1 +1 +1 +1 +1 +@hadTriggerPriv :=1 +1 +1 +1 +1 +1 diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index 54c195900f4..4ac1dfc938f 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -3122,7 +3122,6 @@ revoke all privileges on mysqldump_myDB.* from myDB_User@localhost; drop user myDB_User@localhost; drop database mysqldump_myDB; use test; - # # BUG#13926: --order-by-primary fails if PKEY contains quote character # diff --git a/mysql-test/r/rpl_drop_db.result b/mysql-test/r/rpl_drop_db.result index 89b33ea262e..c0efdf5290d 100644 --- a/mysql-test/r/rpl_drop_db.result +++ b/mysql-test/r/rpl_drop_db.result @@ -31,7 +31,6 @@ use test; select * from t1; n 1234 -DROP DATABASE mysqltest1; stop slave; drop database mysqltest1; drop database mysqltest1; diff --git a/mysql-test/r/rpl_row_max_relay_size.result b/mysql-test/r/rpl_row_max_relay_size.result index 163e8231de5..8bb10ffb080 100644 --- a/mysql-test/r/rpl_row_max_relay_size.result +++ b/mysql-test/r/rpl_row_max_relay_size.result @@ -16,6 +16,7 @@ reset slave; # # Test 1 # +set @my_max_binlog_size= @@global.max_binlog_size; set global max_binlog_size=8192; set global max_relay_log_size=8192-1; select @@global.max_relay_log_size; @@ -268,6 +269,7 @@ File master-bin.000002 Position 102 Binlog_Do_DB Binlog_Ignore_DB +set global max_binlog_size= @my_max_binlog_size; # # End of 4.1 tests # diff --git a/mysql-test/t/rpl_drop_db.test b/mysql-test/t/rpl_drop_db.test index 40b8520a601..7f4a7843c4a 100644 --- a/mysql-test/t/rpl_drop_db.test +++ b/mysql-test/t/rpl_drop_db.test @@ -46,11 +46,6 @@ show tables; use test; select * from t1; -system rm $MYSQLTEST_VARDIR/master-data/mysqltest1/f1.txt; -connection master; -DROP DATABASE mysqltest1; -sync_slave_with_master; - #cleanup connection slave; stop slave; From 3ebd031e00dd176528d2b82d7c58fa38b7d99716 Mon Sep 17 00:00:00 2001 From: "cmiller@zippy.cornsilk.net" <> Date: Wed, 15 Nov 2006 09:54:54 -0500 Subject: [PATCH 036/131] Bug#17700: mysql_fix_privilege_tables cannot handle a password \ with embedded spaces Problem: Original code written assuming password contains no spaces. Further, because of how sh interprets characters in variables, you cannot do the "simple solution". Solution: Move the "was a password provided" check to the end. This allows us to correctly quote the password argument when passed to the mysql client program. Addendum: Put this check inside of a shell fn to simplify the code. --- scripts/mysql_fix_privilege_tables.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/scripts/mysql_fix_privilege_tables.sh b/scripts/mysql_fix_privilege_tables.sh index 56807a81d7c..361affae247 100644 --- a/scripts/mysql_fix_privilege_tables.sh +++ b/scripts/mysql_fix_privilege_tables.sh @@ -120,9 +120,6 @@ then fi cmd="$bindir/mysql --no-defaults --force --user=$user --host=$host" -if test ! -z "$password" ; then - cmd="$cmd --password=$password" -fi if test ! -z "$port"; then cmd="$cmd --port=$port" fi @@ -178,11 +175,22 @@ then s_echo "" fi +run_cmd() { + # Password argument is added here to allow for spaces in password. + + if test ! -z "$password" + then + cat $sql_file | $cmd --password="$password" + else + cat $sql_file | $cmd + fi +} + if test $verbose = 0 then - cat $sql_file | $cmd > /dev/null 2>&1 + run_cmd > /dev/null 2>&1 else - cat $sql_file | $cmd > /dev/null + run_cmd > /dev/null fi if test $? = 0 then From 53b97915c6c2f34259126732d90e6fe7f7f484df Mon Sep 17 00:00:00 2001 From: "tnurnberg@salvation.intern.azundris.com" <> Date: Wed, 15 Nov 2006 16:08:47 +0100 Subject: [PATCH 037/131] manual merge for 16456 --- mysql-test/r/rpl_sp.result | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/rpl_sp.result b/mysql-test/r/rpl_sp.result index 87af3cc622b..803472c8bc5 100644 --- a/mysql-test/r/rpl_sp.result +++ b/mysql-test/r/rpl_sp.result @@ -104,10 +104,10 @@ begin insert into t2 values(20),(20); end| call foo4(); -ERROR 23000: Duplicate entry '20' for key 1 +ERROR 23000: Duplicate entry '20' for key 'a' show warnings; Level Code Message -Error 1062 Duplicate entry '20' for key 1 +Error 1062 Duplicate entry '20' for key 'a' select * from t2; a 20 @@ -124,6 +124,9 @@ select * from mysql.proc where name="foo4" and db='mysqltest1'; db name type specific_name language sql_data_access is_deterministic security_type param_list returns body definer created modified sql_mode comment select * from mysql.proc where name="foo4" and db='mysqltest1'; db name type specific_name language sql_data_access is_deterministic security_type param_list returns body definer created modified sql_mode comment +set binlog_format=STATEMENT; +call foo(); +ERROR HY000: Slave running with --log-slave-updates must use row-based binary logging to be able to replicate row-based binary log events drop procedure foo; drop procedure foo2; drop procedure foo3; @@ -181,7 +184,7 @@ end| ERROR HY000: You do not have the SUPER privilege and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable) set global log_bin_trust_routine_creators=1; Warnings: -Warning 1287 'log_bin_trust_routine_creators' is deprecated; use 'log_bin_trust_function_creators' instead +Warning 1541 The syntax 'log_bin_trust_routine_creators' is deprecated and will be removed in MySQL 5.2. Please use 'log_bin_trust_function_creators' instead set global log_bin_trust_function_creators=0; set global log_bin_trust_function_creators=1; set global log_bin_trust_function_creators=1; @@ -241,9 +244,9 @@ return 10; end| do fn1(100); Warnings: -Error 1062 Duplicate entry '100' for key 1 +Error 1062 Duplicate entry '100' for key 'a' select fn1(20); -ERROR 23000: Duplicate entry '20' for key 1 +ERROR 23000: Duplicate entry '20' for key 'a' select * from t2; a 20 @@ -252,8 +255,17 @@ select * from t2; a 20 100 +set binlog_format=STATEMENT; +create function fn16456() +returns int +begin +return unix_timestamp(); +end| +select fn16456(); +ERROR HY000: Slave running with --log-slave-updates must use row-based binary logging to be able to replicate row-based binary log events +drop function fn16456; create trigger trg before insert on t1 for each row set new.a= 10; -ERROR 42000: Access denied; you need the SUPER privilege for this operation +ERROR 42000: TRIGGER command denied to user 'zedjzlcsjhd'@'localhost' for table 't1' delete from t1; create trigger trg before insert on t1 for each row set new.a= 10; insert into t1 values (1); @@ -364,6 +376,12 @@ return 10; end master-bin.000001 # Query 1 # use `mysqltest1`; SELECT `fn1`(100) master-bin.000001 # Query 1 # use `mysqltest1`; SELECT `fn1`(20) +master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` function fn16456() +returns int +begin +return unix_timestamp(); +end +master-bin.000001 # Query 1 # use `mysqltest1`; drop function fn16456 master-bin.000001 # Query 1 # use `mysqltest1`; delete from t1 master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` trigger trg before insert on t1 for each row set new.a= 10 master-bin.000001 # Query 1 # use `mysqltest1`; insert into t1 values (1) @@ -467,3 +485,5 @@ DROP FUNCTION f1; drop table t1; set global log_bin_trust_function_creators=0; set global log_bin_trust_function_creators=0; +End of 5.0 tests +End of 5.1 tests From 5d4c57b900c164345f8635d13e66070e98208a29 Mon Sep 17 00:00:00 2001 From: "cmiller@zippy.cornsilk.net" <> Date: Wed, 15 Nov 2006 12:23:07 -0500 Subject: [PATCH 038/131] Bug#19955: unsigned bigint used as signed with MOD function Problem: When we have a really large number (between 2^63 and 2^64) as the left side of the mod operator, it gets improperly corerced into a signed value. Solution: Added check to see if the "negative" number is really positive, and if so, cast it. --- mysql-test/r/bigint.result | 11 +++++++++++ mysql-test/t/bigint.test | 9 +++++++++ sql/item_func.cc | 4 ++++ 3 files changed, 24 insertions(+) diff --git a/mysql-test/r/bigint.result b/mysql-test/r/bigint.result index edc18319603..541a15561e2 100644 --- a/mysql-test/r/bigint.result +++ b/mysql-test/r/bigint.result @@ -341,3 +341,14 @@ select * from t1 where bigint_col='17666000000000000000'; bigint_col 17666000000000000000 drop table t1; + +bug 19955 -- mod is signed with bigint +select cast(10000002383263201056 as unsigned) mod 50 as result; +result +6 +create table t1 (c1 bigint unsigned); +insert into t1 values (10000002383263201056); +select c1 mod 50 as result from t1; +result +6 +drop table t1; diff --git a/mysql-test/t/bigint.test b/mysql-test/t/bigint.test index 35cda11646a..6c1229db83f 100644 --- a/mysql-test/t/bigint.test +++ b/mysql-test/t/bigint.test @@ -278,4 +278,13 @@ select * from t1 where bigint_col=17666000000000000000; select * from t1 where bigint_col='17666000000000000000'; drop table t1; +--echo +--echo bug 19955 -- mod is signed with bigint + +select cast(10000002383263201056 as unsigned) mod 50 as result; + +create table t1 (c1 bigint unsigned); +insert into t1 values (10000002383263201056); +select c1 mod 50 as result from t1; +drop table t1; diff --git a/sql/item_func.cc b/sql/item_func.cc index 8e6b4d82b1d..a68c85ad658 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1326,6 +1326,10 @@ longlong Item_func_mod::int_op() signal_divide_by_null(); return 0; } + + if (args[0]->unsigned_flag) + return ((ulonglong) value) % val2; + return value % val2; } From 85da10fa2af654e8ade4dd5256eef17c56762458 Mon Sep 17 00:00:00 2001 From: "andrey@example.com" <> Date: Wed, 15 Nov 2006 20:42:13 +0100 Subject: [PATCH 039/131] post-merge fix --- mysql-test/r/sp.result | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 2dd7030caed..0ac2e2522c2 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -4802,22 +4802,6 @@ i 0 drop table t3| drop procedure bug16887| -create table t3 (f1 int, f2 varchar(3), primary key(f1)) engine=innodb| -insert into t3 values (1,'aaa'),(2,'bbb'),(3,'ccc')| -CREATE FUNCTION bug13575 ( p1 integer ) -returns varchar(3) -BEGIN -DECLARE v1 VARCHAR(10) DEFAULT null; -SELECT f2 INTO v1 FROM t3 WHERE f1 = p1; -RETURN v1; -END| -select distinct f1, bug13575(f1) from t3 order by f1| -f1 bug13575(f1) -1 aaa -2 bbb -3 ccc -drop function bug13575; -drop table t3| drop procedure if exists bug16474_1| drop procedure if exists bug16474_2| delete from t1| From de904f54bf6b7ea165604ae9931cbadc7a1c5bdc Mon Sep 17 00:00:00 2001 From: "andrey@example.com" <> Date: Thu, 16 Nov 2006 13:18:37 +0100 Subject: [PATCH 040/131] Fix for bug#24219 ALTER TABLE ... RENAME TO ... , DISABLE KEYS leads to crash There was an improper order of doing chained operations. To the documentor: ENABLE|DISABLE KEYS combined with RENAME TO, and no other ALTER TABLE clause, leads to server crash independent of the presence of indices and data in the table. --- mysql-test/r/alter_table.result | 11 +++++++ mysql-test/t/alter_table.test | 18 +++++++++++ sql/sql_table.cc | 53 +++++++++++++++++++-------------- 3 files changed, 59 insertions(+), 23 deletions(-) diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result index e9c9c873750..eade19e85df 100644 --- a/mysql-test/r/alter_table.result +++ b/mysql-test/r/alter_table.result @@ -543,3 +543,14 @@ ERROR 3D000: No database selected alter table test.t1 rename test.t1; use test; drop table t1; +DROP TABLE IF EXISTS bug24219; +DROP TABLE IF EXISTS bug24219_2; +CREATE TABLE bug24219 (a INT, INDEX(a)); +SHOW INDEX FROM bug24219; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +bug24219 1 a 1 a A NULL NULL NULL YES BTREE +ALTER TABLE bug24219 RENAME TO bug24219_2, DISABLE KEYS; +SHOW INDEX FROM bug24219_2; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +bug24219_2 1 a 1 a A NULL NULL NULL YES BTREE disabled +DROP TABLE bug24219_2; diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test index 9bd34c2a610..eba456982c8 100644 --- a/mysql-test/t/alter_table.test +++ b/mysql-test/t/alter_table.test @@ -392,4 +392,22 @@ alter table test.t1 rename test.t1; use test; drop table t1; +# +# Bug#24219 - ALTER TABLE ... RENAME TO ... , DISABLE KEYS leads to crash +# +--disable_warnings +DROP TABLE IF EXISTS bug24219; +DROP TABLE IF EXISTS bug24219_2; +--enable_warnings + +CREATE TABLE bug24219 (a INT, INDEX(a)); + +SHOW INDEX FROM bug24219; + +ALTER TABLE bug24219 RENAME TO bug24219_2, DISABLE KEYS; + +SHOW INDEX FROM bug24219_2; + +DROP TABLE bug24219_2; + # End of 4.1 tests diff --git a/sql/sql_table.cc b/sql/sql_table.cc index da66b556b5e..256b9281e9f 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2949,8 +2949,35 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, thd->proc_info="setup"; if (alter_info->is_simple && !table->tmp_table) { - error=0; - if (new_name != table_name || new_db != db) + switch (alter_info->keys_onoff) { + case LEAVE_AS_IS: + error= 0; + break; + case ENABLE: + VOID(pthread_mutex_lock(&LOCK_open)); + wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN); + VOID(pthread_mutex_unlock(&LOCK_open)); + error= table->file->enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE); + /* COND_refresh will be signaled in close_thread_tables() */ + break; + case DISABLE: + VOID(pthread_mutex_lock(&LOCK_open)); + wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN); + VOID(pthread_mutex_unlock(&LOCK_open)); + error= table->file->disable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE); + /* COND_refresh will be signaled in close_thread_tables() */ + break; + } + + if (error == HA_ERR_WRONG_COMMAND) + { + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, + ER_ILLEGAL_HA, ER(ER_ILLEGAL_HA), + table->table_name); + error= 0; + } + + if (!error && (new_name != table_name || new_db != db)) { thd->proc_info="rename"; VOID(pthread_mutex_lock(&LOCK_open)); @@ -2971,27 +2998,6 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, VOID(pthread_mutex_unlock(&LOCK_open)); } - if (!error) - { - switch (alter_info->keys_onoff) { - case LEAVE_AS_IS: - break; - case ENABLE: - VOID(pthread_mutex_lock(&LOCK_open)); - wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN); - VOID(pthread_mutex_unlock(&LOCK_open)); - error= table->file->enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE); - /* COND_refresh will be signaled in close_thread_tables() */ - break; - case DISABLE: - VOID(pthread_mutex_lock(&LOCK_open)); - wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN); - VOID(pthread_mutex_unlock(&LOCK_open)); - error=table->file->disable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE); - /* COND_refresh will be signaled in close_thread_tables() */ - break; - } - } if (error == HA_ERR_WRONG_COMMAND) { push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, @@ -2999,6 +3005,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, table->table_name); error=0; } + if (!error) { mysql_update_log.write(thd, thd->query, thd->query_length); From 5bf475376e21770af7ca6aae242e78e64cc9ce34 Mon Sep 17 00:00:00 2001 From: "andrey@example.com" <> Date: Thu, 16 Nov 2006 14:01:51 +0100 Subject: [PATCH 041/131] Fix for bug#24219 ALTER TABLE ... RENAME TO ... , DISABLE KEYS leads to crash (this is the 5.0 patch, because 4.1 differs) There was an improper order of doing chained operations. To the documentor: ENABLE|DISABLE KEYS combined with RENAME TO, and no other ALTER TABLE clause, leads to server crash independent of the presence of indices and data in the table. --- mysql-test/r/alter_table.result | 42 +++++++++++++-------------- sql/sql_table.cc | 51 ++++++++++++++++++--------------- 2 files changed, 49 insertions(+), 44 deletions(-) diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result index a8d7b917f37..ba8c11efbe1 100644 --- a/mysql-test/r/alter_table.result +++ b/mysql-test/r/alter_table.result @@ -428,42 +428,42 @@ t1 MyISAM 10 Fixed 1 37 X X X X X X X X latin1_swedish_ci NULL drop table t1; set names koi8r; create table t1 (a char(10) character set koi8r); -insert into t1 values ('ÔÅÓÔ'); +insert into t1 values ('ÔÅÓÔ'); select a,hex(a) from t1; a hex(a) -ÔÅÓÔ D4C5D3D4 +ÔÅÓÔ D4C5D3D4 alter table t1 change a a char(10) character set cp1251; select a,hex(a) from t1; a hex(a) -ÔÅÓÔ F2E5F1F2 +ÔÅÓÔ F2E5F1F2 alter table t1 change a a binary(4); select a,hex(a) from t1; a hex(a) -òåñò F2E5F1F2 +òåñò F2E5F1F2 alter table t1 change a a char(10) character set cp1251; select a,hex(a) from t1; a hex(a) -ÔÅÓÔ F2E5F1F2 +ÔÅÓÔ F2E5F1F2 alter table t1 change a a char(10) character set koi8r; select a,hex(a) from t1; a hex(a) -ÔÅÓÔ D4C5D3D4 +ÔÅÓÔ D4C5D3D4 alter table t1 change a a varchar(10) character set cp1251; select a,hex(a) from t1; a hex(a) -ÔÅÓÔ F2E5F1F2 +ÔÅÓÔ F2E5F1F2 alter table t1 change a a char(10) character set koi8r; select a,hex(a) from t1; a hex(a) -ÔÅÓÔ D4C5D3D4 +ÔÅÓÔ D4C5D3D4 alter table t1 change a a text character set cp1251; select a,hex(a) from t1; a hex(a) -ÔÅÓÔ F2E5F1F2 +ÔÅÓÔ F2E5F1F2 alter table t1 change a a char(10) character set koi8r; select a,hex(a) from t1; a hex(a) -ÔÅÓÔ D4C5D3D4 +ÔÅÓÔ D4C5D3D4 delete from t1; show create table t1; Table Create Table @@ -528,7 +528,7 @@ ALTER TABLE T12207 DISCARD TABLESPACE; ERROR HY000: Table storage engine for 'T12207' doesn't have this option DROP TABLE T12207; create table t1 (a text) character set koi8r; -insert into t1 values (_koi8r'ÔÅÓÔ'); +insert into t1 values (_koi8r'ÔÅÓÔ'); select hex(a) from t1; hex(a) D4C5D3D4 @@ -556,16 +556,6 @@ ERROR 3D000: No database selected alter table test.t1 rename test.t1; use test; drop table t1; -create table t1 (mycol int(10) not null); -alter table t1 alter column mycol set default 0; -desc t1; -Field Type Null Key Default Extra -mycol int(10) NO 0 -drop table t1; -create table t1 (t varchar(255) default null, key t (t(80))) -engine=myisam default charset=latin1; -alter table t1 change t t text; -drop table t1; DROP TABLE IF EXISTS bug24219; DROP TABLE IF EXISTS bug24219_2; CREATE TABLE bug24219 (a INT, INDEX(a)); @@ -577,3 +567,13 @@ SHOW INDEX FROM bug24219_2; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment bug24219_2 1 a 1 a A NULL NULL NULL YES BTREE disabled DROP TABLE bug24219_2; +create table t1 (mycol int(10) not null); +alter table t1 alter column mycol set default 0; +desc t1; +Field Type Null Key Default Extra +mycol int(10) NO 0 +drop table t1; +create table t1 (t varchar(255) default null, key t (t(80))) +engine=myisam default charset=latin1; +alter table t1 change t t text; +drop table t1; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index c76ebe7ef49..e7e08837b65 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -3300,13 +3300,35 @@ view_err: if (!(alter_info->flags & ~(ALTER_RENAME | ALTER_KEYS_ONOFF)) && !table->s->tmp_table) // no need to touch frm { - error=0; VOID(pthread_mutex_lock(&LOCK_open)); - if (new_name != table_name || new_db != db) + + switch (alter_info->keys_onoff) { + case LEAVE_AS_IS: + error= 0; + break; + case ENABLE: + wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN); + error= table->file->enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE); + /* COND_refresh will be signaled in close_thread_tables() */ + break; + case DISABLE: + wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN); + error=table->file->disable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE); + /* COND_refresh will be signaled in close_thread_tables() */ + break; + } + if (error == HA_ERR_WRONG_COMMAND) + { + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, + ER_ILLEGAL_HA, ER(ER_ILLEGAL_HA), + table->alias); + error= 0; + } + + if (!error && (new_name != table_name || new_db != db)) { thd->proc_info="rename"; /* Then do a 'simple' rename of the table */ - error=0; if (!access(new_name_buff,F_OK)) { my_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_name); @@ -3328,31 +3350,14 @@ view_err: } } - if (!error) - { - switch (alter_info->keys_onoff) { - case LEAVE_AS_IS: - break; - case ENABLE: - wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN); - error= table->file->enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE); - /* COND_refresh will be signaled in close_thread_tables() */ - break; - case DISABLE: - wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN); - error=table->file->disable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE); - /* COND_refresh will be signaled in close_thread_tables() */ - break; - } - } - if (error == HA_ERR_WRONG_COMMAND) { push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, ER_ILLEGAL_HA, ER(ER_ILLEGAL_HA), table->alias); - error=0; + error= 0; } + if (!error) { if (mysql_bin_log.is_open()) @@ -3370,7 +3375,7 @@ view_err: error= -1; } VOID(pthread_mutex_unlock(&LOCK_open)); - table_list->table=0; // For query cache + table_list->table= NULL; // For query cache query_cache_invalidate3(thd, table_list, 0); DBUG_RETURN(error); } From f701fc54fce512d2dab941fc03777c219812b3f9 Mon Sep 17 00:00:00 2001 From: "ramil/ram@mysql.com/myoffice.izhnet.ru" <> Date: Thu, 16 Nov 2006 18:09:34 +0400 Subject: [PATCH 042/131] after-merge fixup. - have to explicitly set null_value. --- sql/item_timefunc.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index db526050bfd..0bba00cbeec 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -3371,7 +3371,11 @@ bool Item_func_last_day::get_date(TIME *ltime, uint fuzzy_date) { if (get_arg0_date(ltime, fuzzy_date & ~TIME_FUZZY_DATE) || (ltime->month == 0)) + { + null_value= 1; return 1; + } + null_value= 0; uint month_idx= ltime->month-1; ltime->day= days_in_month[month_idx]; if ( month_idx == 1 && calc_days_in_year(ltime->year) == 366) From 81c81296dfef2ba40d99c0490fd526951387ccf8 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Thu, 16 Nov 2006 15:23:13 +0100 Subject: [PATCH 043/131] Put more spcific paths at the top of list to search for binaries --- mysql-test/mysql-test-run.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 61724dd57a7..6d897f4af41 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -668,9 +668,9 @@ sub command_line_setup () { # # Look for the client binaries - $path_client_bindir= mtr_path_exists(vs_config_dirs('client', ''), - "$glob_basedir/client_release", + $path_client_bindir= mtr_path_exists("$glob_basedir/client_release", "$glob_basedir/client_debug", + vs_config_dirs('client', ''), "$glob_basedir/client"); $exe_mysqld= mtr_exe_exists (vs_config_dirs('sql', 'mysqld'), From dd773b1a98ff0c3e7c9254cfb1832f66178257cf Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Thu, 16 Nov 2006 16:19:29 +0100 Subject: [PATCH 044/131] Add the two new functions to udf_example.def so they will be exported by dll's --- sql/udf_example.def | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sql/udf_example.def b/sql/udf_example.def index d3081ca7768..ee107d58e51 100644 --- a/sql/udf_example.def +++ b/sql/udf_example.def @@ -22,3 +22,5 @@ EXPORTS avgcost_add avgcost_clear avgcost + is_const + is_const_init From f4e097420a474d5d18a8f6122d1e06d5bd7bcd7f Mon Sep 17 00:00:00 2001 From: "hartmut@walhalla.site" <> Date: Thu, 16 Nov 2006 23:39:02 +0100 Subject: [PATCH 045/131] This command is not portable, as POSIX does not require it; use . instead. (Bug #24294) --- support-files/mysql.server.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support-files/mysql.server.sh b/support-files/mysql.server.sh index d5041f30c0a..f5fa4e9ed9a 100644 --- a/support-files/mysql.server.sh +++ b/support-files/mysql.server.sh @@ -82,7 +82,7 @@ datadir_set= # lsb_functions="/lib/lsb/init-functions" if test -f $lsb_functions ; then - source $lsb_functions + . $lsb_functions else log_success_msg() { From d032660b5feaaea8574b8c092e76d85e424646af Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Fri, 17 Nov 2006 10:46:21 +0100 Subject: [PATCH 046/131] Bug#24354 option "--extern" of mysql-test-run.pl does not work anymore - Dont require restart when using extern and there is no record of master being started(pid is not known) --- mysql-test/mysql-test-run.pl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index f04d252e049..e78b899cd46 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -3868,8 +3868,16 @@ sub run_testcase_need_master_restart($) } elsif( ! $master->[0]->{'pid'} ) { - $do_restart= 1; - mtr_verbose("Restart master: master is not started"); + if ( $opt_extern ) + { + $do_restart= 0; + mtr_verbose("No restart: using extern master"); + } + else + { + $do_restart= 1; + mtr_verbose("Restart master: master is not started"); + } } return $do_restart; From dbdd10752cca93f25e029a8ef347696f3eb27f8f Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Fri, 17 Nov 2006 11:01:09 +0100 Subject: [PATCH 047/131] Bug#24274 option "--big-test" of mysql-test-run.pl does not work anymore - Set environment variable BIG_TEST when using --big-test - Skip comment lines when looking for features a test case supports. --- mysql-test/lib/mtr_cases.pl | 3 +++ mysql-test/mysql-test-run.pl | 20 +++++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/mysql-test/lib/mtr_cases.pl b/mysql-test/lib/mtr_cases.pl index d270d72d526..283e728fdaf 100644 --- a/mysql-test/lib/mtr_cases.pl +++ b/mysql-test/lib/mtr_cases.pl @@ -593,6 +593,9 @@ sub mtr_options_from_test_file($$) { while ( my $line= <$F> ) { + # Skip line if it start's with # + next if ( $line =~ /^#/ ); + # Match this line against tag in "tags" array foreach my $tag (@tags) { diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index e78b899cd46..0ac3054d7c7 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -164,7 +164,7 @@ our $exe_libtool; our $opt_bench= 0; our $opt_small_bench= 0; -our $opt_big_test= 0; # Send --big-test to mysqltest +our $opt_big_test= 0; our @opt_extra_mysqld_opt; @@ -919,6 +919,14 @@ sub command_line_setup () { $opt_sleep_time_after_restart= $opt_sleep; } + # -------------------------------------------------------------------------- + # Big test flags + # -------------------------------------------------------------------------- + if ( $opt_big_test ) + { + $ENV{'BIG_TEST'}= 1; + } + # -------------------------------------------------------------------------- # Gcov flag # -------------------------------------------------------------------------- @@ -4370,11 +4378,6 @@ sub run_mysqltest ($) { mtr_add_arg($args, "--timer-file=%s/log/timer", $opt_vardir); } - if ( $opt_big_test ) - { - mtr_add_arg($args, "--big-test"); - } - if ( $opt_compress ) { mtr_add_arg($args, "--compress"); @@ -4765,9 +4768,8 @@ Options to control what test suites or cases to run skip-rpl Skip the replication test cases. skip-im Don't start IM, and skip the IM test cases skip-test=PREFIX Skip test cases which name are prefixed with PREFIX - big-test Pass "--big-test" to mysqltest which will set the - environment variable BIG_TEST, which can be checked - from test cases. + big-test Set the environment variable BIG_TEST, which can be + checked from test cases. Options that specify ports From b3a5d6196ff481fa2fe40d2771a930fccb643a95 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Fri, 17 Nov 2006 13:10:54 +0100 Subject: [PATCH 048/131] remove junk comment --- mysql-test/mysql-test-run.pl | 5 ----- 1 file changed, 5 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 6d897f4af41..fed15b946a3 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -97,11 +97,6 @@ $Devel::Trace::TRACE= 1; # ############################################################################## -# We are to use handle_options() in "mysys/my_getopt.c" for the C version -# -# In the C version we want to use structs and, in some cases, arrays of -# structs. We let each struct be a separate hash. - # Misc global variables our $mysql_version_id; our $glob_mysql_test_dir= undef; From 770a4f7c680628b4ab6ed24833115026c17a7886 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Fri, 17 Nov 2006 13:14:07 +0100 Subject: [PATCH 049/131] BUG#24274 option "--big-test" of mysql-test-run.pl does not work anymore --- mysql-test/lib/mtr_cases.pl | 4 ++++ mysql-test/mysql-test-run.pl | 20 +++++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/mysql-test/lib/mtr_cases.pl b/mysql-test/lib/mtr_cases.pl index d270d72d526..9e943fec9ef 100644 --- a/mysql-test/lib/mtr_cases.pl +++ b/mysql-test/lib/mtr_cases.pl @@ -593,6 +593,10 @@ sub mtr_options_from_test_file($$) { while ( my $line= <$F> ) { + + # Skip line if it start's with # + next if ( $line =~ /^#/ ); + # Match this line against tag in "tags" array foreach my $tag (@tags) { diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index fed15b946a3..6cbf5789ed8 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -163,7 +163,7 @@ our $exe_libtool; our $opt_bench= 0; our $opt_small_bench= 0; -our $opt_big_test= 0; # Send --big-test to mysqltest +our $opt_big_test= 0; our @opt_extra_mysqld_opt; @@ -912,6 +912,14 @@ sub command_line_setup () { $opt_sleep_time_after_restart= $opt_sleep; } + # -------------------------------------------------------------------------- + # Big test flags + # -------------------------------------------------------------------------- + if ( $opt_big_test ) + { + $ENV{'BIG_TEST'}= 1; + } + # -------------------------------------------------------------------------- # Gcov flag # -------------------------------------------------------------------------- @@ -4269,11 +4277,6 @@ sub run_mysqltest ($) { mtr_add_arg($args, "--timer-file=%s/log/timer", $opt_vardir); } - if ( $opt_big_test ) - { - mtr_add_arg($args, "--big-test"); - } - if ( $opt_compress ) { mtr_add_arg($args, "--compress"); @@ -4662,9 +4665,8 @@ Options to control what test suites or cases to run skip-rpl Skip the replication test cases. skip-im Don't start IM, and skip the IM test cases skip-test=PREFIX Skip test cases which name are prefixed with PREFIX - big-test Pass "--big-test" to mysqltest which will set the - environment variable BIG_TEST, which can be checked - from test cases. + big-test Set the environment variable BIG_TEST, which can be + checked from test cases. Options that specify ports From 3f2c3f04bfaf2ffd68fb4ddb414326ea284928eb Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Fri, 17 Nov 2006 13:20:48 +0100 Subject: [PATCH 050/131] BUG#24354 option "--extern" of mysql-test-run.pl does not work anymore --- mysql-test/mysql-test-run.pl | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 6cbf5789ed8..103481a491d 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -3820,10 +3820,17 @@ sub run_testcase_need_master_restart($) } elsif( ! $master->[0]->{'pid'} ) { - $do_restart= 1; - mtr_verbose("Restart master: master is not started"); + if ( $opt_extern ) + { + $do_restart= 0; + mtr_verbose("No restart: using extern master"); + } + else + { + $do_restart= 1; + mtr_verbose("Restart master: master is not started"); + } } - return $do_restart; } From d98ffb2ccfc7d8b0e9aef14d563eb938c4c6705d Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Fri, 17 Nov 2006 13:30:42 +0100 Subject: [PATCH 051/131] Cleanup --extern implementation, remove some unused variables and check arguments --- mysql-test/mysql-test-run.pl | 46 ++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 103481a491d..f6f8b359736 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -104,7 +104,6 @@ our $glob_mysql_bench_dir= undef; our $glob_hostname= undef; our $glob_scriptname= undef; our $glob_timers= undef; -our $glob_use_running_server= 0; our $glob_use_running_ndbcluster= 0; our $glob_use_running_ndbcluster_slave= 0; our $glob_use_embedded_server= 0; @@ -180,7 +179,10 @@ our $opt_debug; our $opt_do_test; our @opt_cases; # The test cases names in argv our $opt_embedded_server; -our $opt_extern; + +our $opt_extern= 0; +our $opt_socket; + our $opt_fast; our $opt_force; our $opt_reorder= 0; @@ -238,8 +240,6 @@ our $opt_suite_timeout; my $default_testcase_timeout= 15; # 15 min max my $default_suite_timeout= 180; # 3 hours max -our $opt_socket; - our $opt_source_dist; our $opt_start_and_exit; @@ -800,14 +800,6 @@ sub command_line_setup () { $opt_tmpdir= "$opt_vardir/tmp" unless $opt_tmpdir; $opt_tmpdir =~ s,/+$,,; # Remove ending slash if any - # -------------------------------------------------------------------------- - # Set socket - # -------------------------------------------------------------------------- - if (!$opt_socket) - { - $opt_socket= $mysqld_variables{'socket'}; - } - # -------------------------------------------------------------------------- # Check im suport # -------------------------------------------------------------------------- @@ -1013,7 +1005,7 @@ sub command_line_setup () { if ( ! $opt_user ) { - if ( $glob_use_running_server ) + if ( $opt_extern ) { $opt_user= "test"; } @@ -1195,9 +1187,16 @@ sub command_line_setup () { if ( $opt_extern ) { - $glob_use_running_server= 1; - $opt_skip_rpl= 1; # We don't run rpl test cases - $master->[0]->{'path_sock'}= $opt_socket; + # Turn off features not supported when running with extern server + $opt_skip_rpl= 1; + + # Setup master->[0] with the settings for the extern server + $master->[0]->{'path_sock'}= $opt_socket if $opt_socket; + } + else + { + mtr_error("--socket can only be used in combination with --extern") + if $opt_socket; } $path_timefile= "$opt_vardir/log/mysqltest-time"; @@ -1607,7 +1606,7 @@ sub environment_setup () { $ENV{'UMASK'}= "0660"; # The octal *string* $ENV{'UMASK_DIR'}= "0770"; # The octal *string* $ENV{'LC_COLLATE'}= "C"; - $ENV{'USE_RUNNING_SERVER'}= $glob_use_running_server; + $ENV{'USE_RUNNING_SERVER'}= $opt_extern; $ENV{'MYSQL_TEST_DIR'}= $glob_mysql_test_dir; $ENV{'MYSQLTEST_VARDIR'}= $opt_vardir; $ENV{'MYSQL_TMP_DIR'}= $opt_tmpdir; @@ -2502,7 +2501,7 @@ sub run_suite () { mtr_print_line(); if ( ! $glob_debugger and - ! $glob_use_running_server and + ! $opt_extern and ! $glob_use_embedded_server ) { stop_all_servers(); @@ -2533,7 +2532,7 @@ sub initialize_servers () { datadir_setup(); - if ( ! $glob_use_running_server ) + if ( ! $opt_extern ) { kill_running_servers(); @@ -3065,7 +3064,7 @@ sub run_testcase ($) { if ($master_restart or $slave_restart) { # Can't restart a running server that may be in use - if ( $glob_use_running_server ) + if ( $opt_extern ) { mtr_report_test_name($tinfo); $tinfo->{comment}= "Can't restart a running server"; @@ -3244,7 +3243,7 @@ sub report_failure_and_restart ($) { print "Aborting: $tinfo->{'name'} failed in $test_mode mode. "; print "To continue, re-run with '--force'.\n"; if ( ! $glob_debugger and - ! $glob_use_running_server and + ! $opt_extern and ! $glob_use_embedded_server ) { stop_all_servers(); @@ -4696,7 +4695,8 @@ Options to run test on running server extern Use running server for tests FIXME DANGEROUS ndb-connectstring=STR Use running cluster, and connect using STR ndb-connectstring-slave=STR Use running slave cluster, and connect using STR - user=USER User for connect to server + user=USER User for connection to extern server + socket=PATH Socket for connection to extern server Options for debugging the product @@ -4756,7 +4756,7 @@ Options not yet described, or that I want to look into more local netware sleep=SECONDS - socket=PATH + user-test=s wait-timeout=SECONDS warnings From f0d89307a8a98e1e5dce626a6ec39ec2df059950 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Fri, 17 Nov 2006 13:36:10 +0100 Subject: [PATCH 052/131] Remove unused variables/options that does not have any effect Update usage description --- mysql-test/mysql-test-run.pl | 37 +++--------------------------------- 1 file changed, 3 insertions(+), 34 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index f6f8b359736..a028c94a2c5 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -233,8 +233,6 @@ our $opt_skip_im; our $opt_sleep; -our $opt_sleep_time_after_restart= 1; -our $opt_sleep_time_for_delete= 10; our $opt_testcase_timeout; our $opt_suite_timeout; my $default_testcase_timeout= 15; # 15 min max @@ -251,7 +249,6 @@ our $opt_strace_client; our $opt_timer= 1; our $opt_user; -our $opt_user_test; our $opt_valgrind= 0; our $opt_valgrind_mysqld= 0; @@ -273,7 +270,6 @@ our $opt_stress_test_file= ""; our $opt_wait_for_master; our $opt_wait_for_slave; -our $opt_wait_timeout= 10; our $opt_warnings; @@ -608,9 +604,7 @@ sub command_line_setup () { 'start-and-exit' => \$opt_start_and_exit, 'timer!' => \$opt_timer, 'unified-diff|udiff' => \$opt_udiff, - 'user-test=s' => \$opt_user_test, 'user=s' => \$opt_user, - 'wait-timeout=i' => \$opt_wait_timeout, 'testcase-timeout=i' => \$opt_testcase_timeout, 'suite-timeout=i' => \$opt_suite_timeout, 'warnings|log-warnings' => \$opt_warnings, @@ -896,14 +890,6 @@ sub command_line_setup () { $opt_bench= 1; } - # -------------------------------------------------------------------------- - # Sleep flag - # -------------------------------------------------------------------------- - if ( $opt_sleep ) - { - $opt_sleep_time_after_restart= $opt_sleep; - } - # -------------------------------------------------------------------------- # Big test flags # -------------------------------------------------------------------------- @@ -929,8 +915,6 @@ sub command_line_setup () { { # Indicate that we are using debugger $glob_debugger= 1; - # Increase timeouts - $opt_wait_timeout= 300; if ( $opt_extern ) { mtr_error("Can't use --extern when using debugger"); @@ -996,13 +980,6 @@ sub command_line_setup () { $opt_suite_timeout*= 6 if $opt_valgrind; } - # Increase times to wait for executables to start if using valgrind - if ( $opt_valgrind ) - { - $opt_sleep_time_after_restart= 10; - $opt_sleep_time_for_delete= 60; - } - if ( ! $opt_user ) { if ( $opt_extern ) @@ -4745,23 +4722,15 @@ Misc options unified-diff | udiff When presenting differences, use unified diff testcase-timeout=MINUTES Max test case run time (default $default_testcase_timeout) - suite-timeout=MINUTES Max test suite run time (default $default_suite_timeout) + suite-timeout=MINUTES Max test suite run time (default $default_suite_timeout) + warnings | log-warnings Pass --log-warnings to mysqld + sleep=SECONDS Passed to mysqltest, will be used as fixed sleep time Deprecated options with-openssl Deprecated option for ssl -Options not yet described, or that I want to look into more - local - netware - sleep=SECONDS - - user-test=s - wait-timeout=SECONDS - warnings - log-warnings - HERE mtr_exit(1); From 655056d32f8679df3d8e3715de6aa993d07720b5 Mon Sep 17 00:00:00 2001 From: "tnurnberg@salvation.intern.azundris.com" <> Date: Fri, 17 Nov 2006 21:30:28 +0100 Subject: [PATCH 053/131] Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR Fix tests for new behaviour: an error is thrown if a NON DETERMINISTIC stored function (SF) is called during statement-based replication (SBR). --- mysql-test/r/func_time.result | 2 + mysql-test/r/gis.result | 3 +- mysql-test/r/grant2.result | 6 +- mysql-test/r/innodb_notembedded.result | 2 + mysql-test/r/ps.result | 4 +- mysql-test/r/query_cache.result | 2 + mysql-test/r/query_cache_notembedded.result | 2 + mysql-test/r/rpl_sf.result | 23 +++++++ mysql-test/r/rpl_sp.result | 18 ------ mysql-test/r/rpl_sp_effects.result | 2 + mysql-test/r/sp.result | 18 +----- mysql-test/r/timezone2.result | 2 + mysql-test/t/func_time.test | 4 ++ mysql-test/t/gis.test | 2 +- mysql-test/t/grant2.test | 9 ++- mysql-test/t/innodb_notembedded.test | 2 + mysql-test/t/ps.test | 4 +- mysql-test/t/query_cache.test | 2 + mysql-test/t/query_cache_notembedded.test | 3 + mysql-test/t/rpl_sf.test | 68 +++++++++++++++++++++ mysql-test/t/rpl_sp.test | 30 +-------- mysql-test/t/rpl_sp_effects.test | 4 ++ mysql-test/t/sp.test | 2 +- mysql-test/t/timezone2.test | 4 ++ sql/item_func.cc | 2 +- sql/sql_parse.cc | 12 ---- 26 files changed, 143 insertions(+), 89 deletions(-) create mode 100644 mysql-test/r/rpl_sf.result create mode 100644 mysql-test/t/rpl_sf.test diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index d7f65e84462..9635af18c57 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -1057,6 +1057,7 @@ Note 1003 select timestampdiff(WEEK,_latin1'2001-02-01',_latin1'2001-05-01') AS select time_format('100:00:00', '%H %k %h %I %l'); time_format('100:00:00', '%H %k %h %I %l') 100 100 04 04 4 +SET GLOBAL log_bin_trust_function_creators = 1; create table t1 (a timestamp default '2005-05-05 01:01:01', b timestamp default '2005-05-05 01:01:01'); drop function if exists t_slow_sysdate; @@ -1080,6 +1081,7 @@ a != b drop trigger t_before; drop function t_slow_sysdate; drop table t1; +SET GLOBAL log_bin_trust_function_creators = 0; create table t1 (a datetime, i int, b datetime); insert into t1 select sysdate(), sleep(1), sysdate() from dual; select a != b from t1; diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result index 6a90ad27625..3848368fedd 100644 --- a/mysql-test/r/gis.result +++ b/mysql-test/r/gis.result @@ -679,10 +679,11 @@ insert into t1 values (null,null); ERROR 23000: Column 's1' cannot be null drop table t1; drop procedure if exists fn3; -create function fn3 () returns point return GeomFromText("point(1 1)"); +create function fn3 () returns point deterministic return GeomFromText("point(1 1)"); show create function fn3; Function sql_mode Create Function fn3 CREATE DEFINER=`root`@`localhost` FUNCTION `fn3`() RETURNS point + DETERMINISTIC return GeomFromText("point(1 1)") select astext(fn3()); astext(fn3()) diff --git a/mysql-test/r/grant2.result b/mysql-test/r/grant2.result index 4b089c1d5e9..03019bd5c1f 100644 --- a/mysql-test/r/grant2.result +++ b/mysql-test/r/grant2.result @@ -365,13 +365,14 @@ insert into mysql.user select * from t1; drop table t1, t2; drop database TESTDB; flush privileges; +SET GLOBAL log_bin_trust_function_creators = 1; grant all privileges on test.* to `a@`@localhost; grant execute on * to `a@`@localhost; create table t2 (s1 int); insert into t2 values (1); drop function if exists f2; -create function f2 () returns int begin declare v int; select s1 from t2 -into v; return v; end// +create function f2 () returns int +begin declare v int; select s1 from t2 into v; return v; end// select f2(); f2() 1 @@ -379,3 +380,4 @@ drop function f2; drop table t2; REVOKE ALL PRIVILEGES, GRANT OPTION FROM `a@`@localhost; drop user `a@`@localhost; +SET GLOBAL log_bin_trust_function_creators = 0; diff --git a/mysql-test/r/innodb_notembedded.result b/mysql-test/r/innodb_notembedded.result index cc13a429dfc..36714eb62fb 100644 --- a/mysql-test/r/innodb_notembedded.result +++ b/mysql-test/r/innodb_notembedded.result @@ -1,4 +1,5 @@ drop table if exists t1; +SET GLOBAL log_bin_trust_function_creators = 1; create table t1 (col1 integer primary key, col2 integer) engine=innodb; insert t1 values (1,100); create function f1 () returns integer begin @@ -18,3 +19,4 @@ rollback; rollback; drop table t1; drop function f1; +SET GLOBAL log_bin_trust_function_creators = 0; diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index 617e289d30d..062d9428f43 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -1500,9 +1500,9 @@ create procedure proc_1() reset query cache; call proc_1(); call proc_1(); call proc_1(); -create function func_1() returns int begin reset query cache; return 1; end| +create function func_1() returns int deterministic begin reset query cache; return 1; end| ERROR 0A000: RESET is not allowed in stored function or trigger -create function func_1() returns int begin call proc_1(); return 1; end| +create function func_1() returns int deterministic begin call proc_1(); return 1; end| select func_1(), func_1(), func_1() from dual; ERROR 0A000: RESET is not allowed in stored function or trigger drop function func_1; diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result index d5996ee8163..39cc8f84085 100644 --- a/mysql-test/r/query_cache.result +++ b/mysql-test/r/query_cache.result @@ -1077,10 +1077,12 @@ create procedure `p1`() begin select a, f1() from t1; end// +SET GLOBAL log_bin_trust_function_creators = 1; call p1()// a f1() 1 2 2 2 +SET GLOBAL log_bin_trust_function_creators = 0; drop procedure p1// drop function f1// drop table t1// diff --git a/mysql-test/r/query_cache_notembedded.result b/mysql-test/r/query_cache_notembedded.result index 8e5df012cfb..05ef28a3180 100644 --- a/mysql-test/r/query_cache_notembedded.result +++ b/mysql-test/r/query_cache_notembedded.result @@ -314,6 +314,7 @@ drop procedure f2; drop procedure f3; drop procedure f4; drop table t1; +SET GLOBAL log_bin_trust_function_creators = 1; reset query cache; drop function if exists f1; create table t1 (id int); @@ -345,3 +346,4 @@ id drop table t1; drop function f1; set GLOBAL query_cache_size=0; +SET GLOBAL log_bin_trust_function_creators = 0; diff --git a/mysql-test/r/rpl_sf.result b/mysql-test/r/rpl_sf.result new file mode 100644 index 00000000000..46defc6908a --- /dev/null +++ b/mysql-test/r/rpl_sf.result @@ -0,0 +1,23 @@ +set global log_bin_trust_function_creators=0; +set binlog_format=STATEMENT; +create function fn16456() +returns int +begin +return unix_timestamp(); +end| +ERROR HY000: This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable) +set global log_bin_trust_function_creators=1; +create function fn16456() +returns int +begin +return unix_timestamp(); +end| +set global log_bin_trust_function_creators=0; +set binlog_format=ROW; +select fn16456(); +fn16456() +timestamp +set binlog_format=STATEMENT; +select fn16456(); +ERROR HY000: Slave running with --log-slave-updates must use row-based binary logging to be able to replicate row-based binary log events +drop function fn16456; diff --git a/mysql-test/r/rpl_sp.result b/mysql-test/r/rpl_sp.result index 803472c8bc5..dd85d932c66 100644 --- a/mysql-test/r/rpl_sp.result +++ b/mysql-test/r/rpl_sp.result @@ -124,9 +124,6 @@ select * from mysql.proc where name="foo4" and db='mysqltest1'; db name type specific_name language sql_data_access is_deterministic security_type param_list returns body definer created modified sql_mode comment select * from mysql.proc where name="foo4" and db='mysqltest1'; db name type specific_name language sql_data_access is_deterministic security_type param_list returns body definer created modified sql_mode comment -set binlog_format=STATEMENT; -call foo(); -ERROR HY000: Slave running with --log-slave-updates must use row-based binary logging to be able to replicate row-based binary log events drop procedure foo; drop procedure foo2; drop procedure foo3; @@ -255,15 +252,6 @@ select * from t2; a 20 100 -set binlog_format=STATEMENT; -create function fn16456() -returns int -begin -return unix_timestamp(); -end| -select fn16456(); -ERROR HY000: Slave running with --log-slave-updates must use row-based binary logging to be able to replicate row-based binary log events -drop function fn16456; create trigger trg before insert on t1 for each row set new.a= 10; ERROR 42000: TRIGGER command denied to user 'zedjzlcsjhd'@'localhost' for table 't1' delete from t1; @@ -376,12 +364,6 @@ return 10; end master-bin.000001 # Query 1 # use `mysqltest1`; SELECT `fn1`(100) master-bin.000001 # Query 1 # use `mysqltest1`; SELECT `fn1`(20) -master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` function fn16456() -returns int -begin -return unix_timestamp(); -end -master-bin.000001 # Query 1 # use `mysqltest1`; drop function fn16456 master-bin.000001 # Query 1 # use `mysqltest1`; delete from t1 master-bin.000001 # Query 1 # use `mysqltest1`; CREATE DEFINER=`root`@`localhost` trigger trg before insert on t1 for each row set new.a= 10 master-bin.000001 # Query 1 # use `mysqltest1`; insert into t1 values (1) diff --git a/mysql-test/r/rpl_sp_effects.result b/mysql-test/r/rpl_sp_effects.result index b42fe64e603..c2c44b06972 100644 --- a/mysql-test/r/rpl_sp_effects.result +++ b/mysql-test/r/rpl_sp_effects.result @@ -10,6 +10,7 @@ drop function if exists f1; drop table if exists t1,t2; drop view if exists v1; create table t1 (a int); +SET GLOBAL log_bin_trust_function_creators = 1; create procedure p1() begin declare spv int default 0; @@ -234,3 +235,4 @@ drop table t1; drop function f1; drop function f2; drop procedure p1; +SET GLOBAL log_bin_trust_function_creators = 0; diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 2dd7030caed..7a28201823e 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -243,7 +243,7 @@ set x = (select sum(t.i) from test.t2 t); insert into test.t1 values (id, x); end| drop procedure if exists sub3| -create function sub3(i int) returns int +create function sub3(i int) returns int deterministic return i+1| call sub1("sub1a", (select 7))| call sub1("sub1b", (select max(i) from t2))| @@ -4802,22 +4802,6 @@ i 0 drop table t3| drop procedure bug16887| -create table t3 (f1 int, f2 varchar(3), primary key(f1)) engine=innodb| -insert into t3 values (1,'aaa'),(2,'bbb'),(3,'ccc')| -CREATE FUNCTION bug13575 ( p1 integer ) -returns varchar(3) -BEGIN -DECLARE v1 VARCHAR(10) DEFAULT null; -SELECT f2 INTO v1 FROM t3 WHERE f1 = p1; -RETURN v1; -END| -select distinct f1, bug13575(f1) from t3 order by f1| -f1 bug13575(f1) -1 aaa -2 bbb -3 ccc -drop function bug13575; -drop table t3| drop procedure if exists bug16474_1| drop procedure if exists bug16474_2| delete from t1| diff --git a/mysql-test/r/timezone2.result b/mysql-test/r/timezone2.result index 6fd67d00259..f7631e9657a 100644 --- a/mysql-test/r/timezone2.result +++ b/mysql-test/r/timezone2.result @@ -269,6 +269,7 @@ select * from t1; convert_tz(NULL, NULL, NULL) NULL drop table t1; +SET GLOBAL log_bin_trust_function_creators = 1; create table t1 (ldt datetime, udt datetime); create function f1(i datetime) returns datetime return convert_tz(i, 'UTC', 'Europe/Moscow'); @@ -283,3 +284,4 @@ ldt ldt2 2006-04-19 16:30:00 2006-04-19 16:30:00 drop table t1; drop function f1; +SET GLOBAL log_bin_trust_function_creators = 0; diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index a6cbca61b84..b124ae905b3 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -580,6 +580,8 @@ select time_format('100:00:00', '%H %k %h %I %l'); # Bug #12562: Make SYSDATE behave like it does in Oracle: always the current # time, regardless of magic to make NOW() always the same for the # entirety of a statement. +SET GLOBAL log_bin_trust_function_creators = 1; + create table t1 (a timestamp default '2005-05-05 01:01:01', b timestamp default '2005-05-05 01:01:01'); delimiter //; @@ -609,6 +611,8 @@ drop trigger t_before; drop function t_slow_sysdate; drop table t1; +SET GLOBAL log_bin_trust_function_creators = 0; + create table t1 (a datetime, i int, b datetime); insert into t1 select sysdate(), sleep(1), sysdate() from dual; select a != b from t1; diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test index 7bba34be3ff..4e5a21c6789 100644 --- a/mysql-test/t/gis.test +++ b/mysql-test/t/gis.test @@ -393,7 +393,7 @@ drop table t1; --disable_warnings drop procedure if exists fn3; --enable_warnings -create function fn3 () returns point return GeomFromText("point(1 1)"); +create function fn3 () returns point deterministic return GeomFromText("point(1 1)"); show create function fn3; select astext(fn3()); drop function fn3; diff --git a/mysql-test/t/grant2.test b/mysql-test/t/grant2.test index 99da1fa1ee7..a533af995dc 100644 --- a/mysql-test/t/grant2.test +++ b/mysql-test/t/grant2.test @@ -484,6 +484,8 @@ flush privileges; # BUG#13310 incorrect user parsing by SP # +SET GLOBAL log_bin_trust_function_creators = 1; + grant all privileges on test.* to `a@`@localhost; grant execute on * to `a@`@localhost; connect (bug13310,localhost,'a@',,test); @@ -494,11 +496,10 @@ insert into t2 values (1); drop function if exists f2; --enable_warnings delimiter //; -create function f2 () returns int begin declare v int; select s1 from t2 -into v; return v; end// +create function f2 () returns int +begin declare v int; select s1 from t2 into v; return v; end// delimiter ;// select f2(); - drop function f2; drop table t2; disconnect bug13310; @@ -506,3 +507,5 @@ disconnect bug13310; connection default; REVOKE ALL PRIVILEGES, GRANT OPTION FROM `a@`@localhost; drop user `a@`@localhost; + +SET GLOBAL log_bin_trust_function_creators = 0; diff --git a/mysql-test/t/innodb_notembedded.test b/mysql-test/t/innodb_notembedded.test index 53332d9fda4..2731f8e33ed 100644 --- a/mysql-test/t/innodb_notembedded.test +++ b/mysql-test/t/innodb_notembedded.test @@ -13,6 +13,7 @@ connect (b,localhost,root,,); # BUG#11238 - in prelocking mode SELECT .. FOR UPDATE is changed to # non-blocking SELECT # +SET GLOBAL log_bin_trust_function_creators = 1; create table t1 (col1 integer primary key, col2 integer) engine=innodb; insert t1 values (1,100); delimiter |; @@ -38,3 +39,4 @@ drop table t1; drop function f1; disconnect a; disconnect b; +SET GLOBAL log_bin_trust_function_creators = 0; diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test index 1a19355406a..ce8bc12db49 100644 --- a/mysql-test/t/ps.test +++ b/mysql-test/t/ps.test @@ -1559,8 +1559,8 @@ call proc_1(); call proc_1(); delimiter |; --error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG -create function func_1() returns int begin reset query cache; return 1; end| -create function func_1() returns int begin call proc_1(); return 1; end| +create function func_1() returns int deterministic begin reset query cache; return 1; end| +create function func_1() returns int deterministic begin call proc_1(); return 1; end| delimiter ;| --error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG select func_1(), func_1(), func_1() from dual; diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test index 67c4c4cb20b..55a638e18e9 100644 --- a/mysql-test/t/query_cache.test +++ b/mysql-test/t/query_cache.test @@ -788,7 +788,9 @@ create procedure `p1`() begin select a, f1() from t1; end// +SET GLOBAL log_bin_trust_function_creators = 1; call p1()// +SET GLOBAL log_bin_trust_function_creators = 0; drop procedure p1// drop function f1// diff --git a/mysql-test/t/query_cache_notembedded.test b/mysql-test/t/query_cache_notembedded.test index 97be9f9f7ca..802022d061b 100644 --- a/mysql-test/t/query_cache_notembedded.test +++ b/mysql-test/t/query_cache_notembedded.test @@ -183,6 +183,8 @@ drop table t1; # # bug#14767: INSERT in SF + concurrent SELECT with query cache # +SET GLOBAL log_bin_trust_function_creators = 1; + reset query cache; --disable_warnings drop function if exists f1; @@ -222,3 +224,4 @@ disconnect con2; connection default; set GLOBAL query_cache_size=0; +SET GLOBAL log_bin_trust_function_creators = 0; diff --git a/mysql-test/t/rpl_sf.test b/mysql-test/t/rpl_sf.test new file mode 100644 index 00000000000..2b1e0350f1b --- /dev/null +++ b/mysql-test/t/rpl_sf.test @@ -0,0 +1,68 @@ +# Bug#16456 RBR: rpl_sp.test expects query to fail, but passes in RBR + +# save status + +let $oblf=`select @@SESSION.BINLOG_FORMAT`; +let $otfc=`select @@log_bin_trust_function_creators`; + +set global log_bin_trust_function_creators=0; + + + +# fail *on definition* + +set binlog_format=STATEMENT; + +delimiter |; +--error ER_BINLOG_UNSAFE_ROUTINE +create function fn16456() + returns int +begin + return unix_timestamp(); +end| +delimiter ;| + + + +# force in definition, so we can see whether we fail on call + +set global log_bin_trust_function_creators=1; + +delimiter |; +create function fn16456() + returns int +begin + return unix_timestamp(); +end| +delimiter ;| + +set global log_bin_trust_function_creators=0; + + + +# allow funcall in RBR + +set binlog_format=ROW; + +--replace_column 1 timestamp +select fn16456(); + + + +# fail funcall in SBR + +set binlog_format=STATEMENT; + +--error ER_BINLOG_ROW_RBR_TO_SBR +select fn16456(); + + + +# restore status + +drop function fn16456; + +--disable_query_log +eval set binlog_format=$oblf; +eval set global log_bin_trust_function_creators=$otfc; +--enable_query_log diff --git a/mysql-test/t/rpl_sp.test b/mysql-test/t/rpl_sp.test index 877c03af513..4ee3338ad01 100644 --- a/mysql-test/t/rpl_sp.test +++ b/mysql-test/t/rpl_sp.test @@ -173,15 +173,6 @@ select * from mysql.proc where name="foo4" and db='mysqltest1'; sync_slave_with_master; select * from mysql.proc where name="foo4" and db='mysqltest1'; -# fail if non-deterministic SP is called in SBR, bug#16456 -let $oblf=`select @@SESSION.BINLOG_FORMAT`; -set binlog_format=STATEMENT; ---error ER_BINLOG_ROW_RBR_TO_SBR -call foo(); ---disable_query_log -eval set binlog_format=$oblf; ---enable_query_log - # ********************** PART 2 : FUNCTIONS *************** connection master; @@ -326,25 +317,6 @@ sync_slave_with_master; # check that this failed-in-the-middle replicated right: select * from t2; -# fail if non-deterministic SF is called in SBR, bug#16456 -connection master; -let $oblf=`select @@SESSION.BINLOG_FORMAT`; -set binlog_format=STATEMENT; -delimiter |; -create function fn16456() - returns int -begin - return unix_timestamp(); -end| -delimiter ;| ---error ER_BINLOG_ROW_RBR_TO_SBR -select fn16456(); ---disable_query_log -eval set binlog_format=$oblf; ---enable_query_log -drop function fn16456; - - # ********************** PART 3 : TRIGGERS *************** connection con1; @@ -555,5 +527,5 @@ set global log_bin_trust_function_creators=0; connection master; set global log_bin_trust_function_creators=0; --echo End of 5.0 tests ---echo End of 5.1 tests +--echo End of 5.1 tests diff --git a/mysql-test/t/rpl_sp_effects.test b/mysql-test/t/rpl_sp_effects.test index e1746682b76..027bfd69f36 100644 --- a/mysql-test/t/rpl_sp_effects.test +++ b/mysql-test/t/rpl_sp_effects.test @@ -20,6 +20,8 @@ drop view if exists v1; --enable_warnings create table t1 (a int); +SET GLOBAL log_bin_trust_function_creators = 1; + # 1. Test simple variables use. delimiter //; create procedure p1() @@ -205,3 +207,5 @@ drop function f1; drop function f2; drop procedure p1; sync_slave_with_master; + +SET GLOBAL log_bin_trust_function_creators = 0; diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index f8d540b4750..0fdee9406a8 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -358,7 +358,7 @@ end| --disable_warnings drop procedure if exists sub3| --enable_warnings -create function sub3(i int) returns int +create function sub3(i int) returns int deterministic return i+1| call sub1("sub1a", (select 7))| diff --git a/mysql-test/t/timezone2.test b/mysql-test/t/timezone2.test index 862b9cc58d1..5e1f74d388f 100644 --- a/mysql-test/t/timezone2.test +++ b/mysql-test/t/timezone2.test @@ -228,6 +228,8 @@ drop table t1; # Test for bug #11081 "Using a CONVERT_TZ function in a stored function # or trigger fails". # +SET GLOBAL log_bin_trust_function_creators = 1; + create table t1 (ldt datetime, udt datetime); create function f1(i datetime) returns datetime return convert_tz(i, 'UTC', 'Europe/Moscow'); @@ -241,4 +243,6 @@ select ldt, f1(udt) as ldt2 from t1; drop table t1; drop function f1; +SET GLOBAL log_bin_trust_function_creators = 0; + # End of 5.0 tests diff --git a/sql/item_func.cc b/sql/item_func.cc index 645cdcbbfa4..e8d3b539142 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -5003,7 +5003,7 @@ Item_func_sp::execute_impl(THD *thd, Field *return_value_fld) Throw an error if a non-deterministic function is called while statement-based replication (SBR) is active. */ - if (!m_sp->m_chistics->detistic && + if (!m_sp->m_chistics->detistic && !trust_function_creators && (mysql_bin_log.is_open() && thd->variables.binlog_format == BINLOG_FORMAT_STMT)) { diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 78c4b895eb3..2a45520af81 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4576,18 +4576,6 @@ end_with_restore_list: goto error; } - /* - Throw an error if a non-deterministic procedure is called while - statement-based replication (SBR) is active. - */ - if (!sp->m_chistics->detistic && - (mysql_bin_log.is_open() && - thd->variables.binlog_format == BINLOG_FORMAT_STMT)) - { - my_error(ER_BINLOG_ROW_RBR_TO_SBR, MYF(0)); - goto error; - } - my_bool nsok= thd->net.no_send_ok; thd->net.no_send_ok= TRUE; if (sp->m_flags & sp_head::MULTI_RESULTS) From 5c5b24a1140d27d27db0ff9680851e56453e7520 Mon Sep 17 00:00:00 2001 From: "iggy/Administrator@amd64." <> Date: Fri, 17 Nov 2006 16:52:41 -0500 Subject: [PATCH 054/131] Bug#23983 ps.test fails to open shared library. - When a shared library argument is supplied, it's checked for an OS specific directory separator. The expected error is different depending on the separator used. Created OS specific versions of these tests. --- mysql-test/r/ps.result | 14 -------------- mysql-test/r/ps_not_windows.result | 14 ++++++++++++++ mysql-test/r/windows.result | 16 ++++++++++++++++ mysql-test/t/ps.test | 14 -------------- mysql-test/t/ps_not_windows.test | 23 +++++++++++++++++++++++ mysql-test/t/windows.test | 23 +++++++++++++++++++++++ 6 files changed, 76 insertions(+), 28 deletions(-) create mode 100644 mysql-test/r/ps_not_windows.result create mode 100644 mysql-test/t/ps_not_windows.test diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index 617e289d30d..694a934f8b7 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -2090,14 +2090,6 @@ v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VI deallocate prepare abc; drop view v1; drop table t1; -create procedure proc_1() install plugin my_plug soname '/root/some_plugin.so'; -call proc_1(); -ERROR HY000: No paths allowed for shared library -call proc_1(); -ERROR HY000: No paths allowed for shared library -call proc_1(); -ERROR HY000: No paths allowed for shared library -drop procedure proc_1; create procedure proc_1() install plugin my_plug soname 'some_plugin.so'; call proc_1(); ERROR HY000: Can't open shared library @@ -2112,12 +2104,6 @@ select func_1(), func_1(), func_1() from dual; ERROR 42000: FUNCTION test.func_1 does not exist drop function func_1; ERROR 42000: FUNCTION test.func_1 does not exist -prepare abc from "install plugin my_plug soname '/root/some_plugin.so'"; -execute abc; -ERROR HY000: No paths allowed for shared library -execute abc; -ERROR HY000: No paths allowed for shared library -deallocate prepare abc; prepare abc from "install plugin my_plug soname 'some_plugin.so'"; deallocate prepare abc; create procedure proc_1() uninstall plugin my_plug; diff --git a/mysql-test/r/ps_not_windows.result b/mysql-test/r/ps_not_windows.result new file mode 100644 index 00000000000..e58b6ec5cad --- /dev/null +++ b/mysql-test/r/ps_not_windows.result @@ -0,0 +1,14 @@ +create procedure proc_1() install plugin my_plug soname '/root/some_plugin.so'; +call proc_1(); +ERROR HY000: No paths allowed for shared library +call proc_1(); +ERROR HY000: No paths allowed for shared library +call proc_1(); +ERROR HY000: No paths allowed for shared library +drop procedure proc_1; +prepare abc from "install plugin my_plug soname '/root/some_plugin.so'"; +execute abc; +ERROR HY000: No paths allowed for shared library +execute abc; +ERROR HY000: No paths allowed for shared library +deallocate prepare abc; diff --git a/mysql-test/r/windows.result b/mysql-test/r/windows.result index 039c5b1476e..19f92415cc9 100644 --- a/mysql-test/r/windows.result +++ b/mysql-test/r/windows.result @@ -6,3 +6,19 @@ use prn; ERROR 42000: Unknown database 'prn' create table nu (a int); drop table nu; +create procedure proc_1() install plugin my_plug soname '\\root\\some_plugin.dll'; +call proc_1(); +ERROR HY000: No paths allowed for shared library +call proc_1(); +ERROR HY000: No paths allowed for shared library +call proc_1(); +ERROR HY000: No paths allowed for shared library +drop procedure proc_1; +create procedure proc_1() install plugin my_plug soname '\\root\\some_plugin.dll'; +call proc_1(); +ERROR HY000: No paths allowed for shared library +call proc_1(); +ERROR HY000: No paths allowed for shared library +call proc_1(); +ERROR HY000: No paths allowed for shared library +drop procedure proc_1; diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test index 1a19355406a..827f46664bf 100644 --- a/mysql-test/t/ps.test +++ b/mysql-test/t/ps.test @@ -2092,14 +2092,6 @@ drop view v1; drop table t1; -create procedure proc_1() install plugin my_plug soname '/root/some_plugin.so'; ---error ER_UDF_NO_PATHS -call proc_1(); ---error ER_UDF_NO_PATHS -call proc_1(); ---error ER_UDF_NO_PATHS -call proc_1(); -drop procedure proc_1; create procedure proc_1() install plugin my_plug soname 'some_plugin.so'; --replace_regex /(Can\'t open shared library).*$/\1/ --error ER_CANT_OPEN_LIBRARY @@ -2119,12 +2111,6 @@ delimiter ;| select func_1(), func_1(), func_1() from dual; --error ER_SP_DOES_NOT_EXIST drop function func_1; -prepare abc from "install plugin my_plug soname '/root/some_plugin.so'"; ---error ER_UDF_NO_PATHS -execute abc; ---error ER_UDF_NO_PATHS -execute abc; -deallocate prepare abc; prepare abc from "install plugin my_plug soname 'some_plugin.so'"; deallocate prepare abc; diff --git a/mysql-test/t/ps_not_windows.test b/mysql-test/t/ps_not_windows.test new file mode 100644 index 00000000000..0d97df96285 --- /dev/null +++ b/mysql-test/t/ps_not_windows.test @@ -0,0 +1,23 @@ +# Non-windows specific ps tests. +--source include/not_windows.inc + +# +# Bug #20665: All commands supported in Stored Procedures should work in +# Prepared Statements +# + +create procedure proc_1() install plugin my_plug soname '/root/some_plugin.so'; +--error ER_UDF_NO_PATHS +call proc_1(); +--error ER_UDF_NO_PATHS +call proc_1(); +--error ER_UDF_NO_PATHS +call proc_1(); +drop procedure proc_1; + +prepare abc from "install plugin my_plug soname '/root/some_plugin.so'"; +--error ER_UDF_NO_PATHS +execute abc; +--error ER_UDF_NO_PATHS +execute abc; +deallocate prepare abc; diff --git a/mysql-test/t/windows.test b/mysql-test/t/windows.test index d6bcfeb8cb3..d668a3f4411 100644 --- a/mysql-test/t/windows.test +++ b/mysql-test/t/windows.test @@ -18,3 +18,26 @@ create table nu (a int); drop table nu; # End of 4.1 tests + +# +# Bug #20665: All commands supported in Stored Procedures should work in +# Prepared Statements +# + +create procedure proc_1() install plugin my_plug soname '\\root\\some_plugin.dll'; +--error ER_UDF_NO_PATHS +call proc_1(); +--error ER_UDF_NO_PATHS +call proc_1(); +--error ER_UDF_NO_PATHS +call proc_1(); +drop procedure proc_1; + +create procedure proc_1() install plugin my_plug soname '\\root\\some_plugin.dll'; +--error ER_UDF_NO_PATHS +call proc_1(); +--error ER_UDF_NO_PATHS +call proc_1(); +--error ER_UDF_NO_PATHS +call proc_1(); +drop procedure proc_1; From 346033a5dab56766dbe2a5bb060f4235844d6c16 Mon Sep 17 00:00:00 2001 From: "kaa@polly.local" <> Date: Mon, 20 Nov 2006 17:35:23 +0300 Subject: [PATCH 055/131] Fix for bug #22077 "DROP TEMPORARY TABLE fails with wrong error if read_only is set" Do not issue a 'read-only' error in case of DROP TEMPORARY TABLE on a non-existing temporary table. Instead produce the correct "Unknown table" error or warning (in cases when the IF EXISTS clause was specified). To a documentor: the part of the manual describing the 'read_only' system variable should be clarified to state the following: "When the read_only variable is set to ON, all operations which create/update/drop tables are rejected with the exceptions for: 1. Any operation performed by the replication thread on a slave server 2. Any operation performed by a user that have the SUPER privilege 3. Any operation that creates/updates/drops only temporary tables" --- mysql-test/r/read_only.result | 5 +++++ mysql-test/t/read_only.test | 12 ++++++++++++ sql/sql_parse.cc | 13 +++++++------ 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/read_only.result b/mysql-test/r/read_only.result index 1a1991a6255..69d25fbef6f 100644 --- a/mysql-test/r/read_only.result +++ b/mysql-test/r/read_only.result @@ -39,6 +39,11 @@ delete t1 from t1,t3 where t1.a=t3.a; drop table t1; insert into t1 values(1); ERROR HY000: The MySQL server is running with the --read-only option so it cannot execute this statement +drop temporary table ttt; +ERROR 42S02: Unknown table 'ttt' +drop temporary table if exists ttt; +Warnings: +Note 1051 Unknown table 'ttt' drop table t1,t2; drop user test@localhost; set global read_only=0; diff --git a/mysql-test/t/read_only.test b/mysql-test/t/read_only.test index 175a5bba6fa..8e14b310f4c 100644 --- a/mysql-test/t/read_only.test +++ b/mysql-test/t/read_only.test @@ -101,6 +101,18 @@ drop table t1; --error 1290 insert into t1 values(1); +# +# BUG #22077 "DROP TEMPORARY TABLE fails with wrong error if read_only is set" +# +# check if DROP TEMPORARY on a non-existing temporary table returns the right +# error + +--error ER_BAD_TABLE_ERROR +drop temporary table ttt; + +# check if DROP TEMPORARY TABLE IF EXISTS produces a warning with read_only set +drop temporary table if exists ttt; + connection default; drop table t1,t2; drop user test@localhost; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 4992d2514c9..eda58f6d798 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2515,12 +2515,13 @@ mysql_execute_command(THD *thd) tables. Except for the replication thread and the 'super' users. */ if (opt_readonly && - !(thd->security_ctx->master_access & SUPER_ACL) && - uc_update_queries[lex->sql_command] && - !((lex->sql_command == SQLCOM_CREATE_TABLE) && - (lex->create_info.options & HA_LEX_CREATE_TMP_TABLE)) && - ((lex->sql_command != SQLCOM_UPDATE_MULTI) && - some_non_temp_table_to_be_updated(thd, all_tables))) + !(thd->security_ctx->master_access & SUPER_ACL) && + uc_update_queries[lex->sql_command] && + !((lex->sql_command == SQLCOM_CREATE_TABLE) && + (lex->create_info.options & HA_LEX_CREATE_TMP_TABLE)) && + !((lex->sql_command == SQLCOM_DROP_TABLE) && lex->drop_temporary) && + ((lex->sql_command != SQLCOM_UPDATE_MULTI) && + some_non_temp_table_to_be_updated(thd, all_tables))) { my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--read-only"); DBUG_RETURN(-1); From fc556abe104dcefa57a63efea31c0278aeb1a06b Mon Sep 17 00:00:00 2001 From: "iggy/Administrator@amd64." <> Date: Mon, 20 Nov 2006 14:11:12 -0500 Subject: [PATCH 056/131] Bug#23983 ps.test fails to open shared library. - Corrected mistake in Windows only test. --- mysql-test/r/windows.result | 10 ++++------ mysql-test/t/windows.test | 10 ++++------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/mysql-test/r/windows.result b/mysql-test/r/windows.result index 19f92415cc9..e8c3c81a44e 100644 --- a/mysql-test/r/windows.result +++ b/mysql-test/r/windows.result @@ -14,11 +14,9 @@ ERROR HY000: No paths allowed for shared library call proc_1(); ERROR HY000: No paths allowed for shared library drop procedure proc_1; -create procedure proc_1() install plugin my_plug soname '\\root\\some_plugin.dll'; -call proc_1(); +prepare abc from "install plugin my_plug soname '\\\\root\\\\some_plugin.dll'"; +execute abc; ERROR HY000: No paths allowed for shared library -call proc_1(); +execute abc; ERROR HY000: No paths allowed for shared library -call proc_1(); -ERROR HY000: No paths allowed for shared library -drop procedure proc_1; +deallocate prepare abc; diff --git a/mysql-test/t/windows.test b/mysql-test/t/windows.test index d668a3f4411..d979c001454 100644 --- a/mysql-test/t/windows.test +++ b/mysql-test/t/windows.test @@ -33,11 +33,9 @@ call proc_1(); call proc_1(); drop procedure proc_1; -create procedure proc_1() install plugin my_plug soname '\\root\\some_plugin.dll'; +prepare abc from "install plugin my_plug soname '\\\\root\\\\some_plugin.dll'"; --error ER_UDF_NO_PATHS -call proc_1(); +execute abc; --error ER_UDF_NO_PATHS -call proc_1(); ---error ER_UDF_NO_PATHS -call proc_1(); -drop procedure proc_1; +execute abc; +deallocate prepare abc; From 3b57cf0f74047ee9c9b3bddc4acaf7fa46c56f09 Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Mon, 20 Nov 2006 21:03:40 +0100 Subject: [PATCH 057/131] Fix mysqltest to automatically replace \ with / also in $MYSQLTEST_VARDIR, for usage of vardir=e:/var on windows --- client/mysqltest.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 9ad2f3df5de..ca36abb8f67 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -4138,8 +4138,9 @@ void init_win_path_patterns() /* List of string patterns to match in order to find paths */ const char* paths[] = { "$MYSQL_TEST_DIR", "$MYSQL_TMP_DIR", - "./test/", 0 }; - int num_paths= 3; + "$MYSQLTEST_VARDIR", + "./test/" }; + int num_paths= sizeof(paths)/sizeof(char*), int i; char* p; @@ -4159,6 +4160,13 @@ void init_win_path_patterns() else p= my_strdup(paths[i], MYF(MY_FAE)); + /* Don't insert zero length strings in patterns array */ + if (strlen(p) == 0) + { + my_free(p, MYF(0)); + continue; + } + if (insert_dynamic(&patterns, (gptr) &p)) die(NullS); @@ -4208,7 +4216,7 @@ void fix_win_paths(const char *val, int len) { const char** pattern= dynamic_element(&patterns, i, const char**); DBUG_PRINT("info", ("pattern: %s", *pattern)); - if (strlen(*pattern) == 0) continue; + /* Search for the path in string */ while ((p= strstr(val, *pattern))) { From b24d39c9e78195f10b66988cf0dba5939d0bd242 Mon Sep 17 00:00:00 2001 From: "cmiller@zippy.cornsilk.net" <> Date: Mon, 20 Nov 2006 15:37:22 -0500 Subject: [PATCH 058/131] Change collation for ALTER-omitted ENUMs from utf8_bin (where "y" and "Y" are different) to utf8_general_ci (where same). --- scripts/mysql_fix_privilege_tables.sql | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/scripts/mysql_fix_privilege_tables.sql b/scripts/mysql_fix_privilege_tables.sql index 41d468fd3cf..ee92e4cf33b 100644 --- a/scripts/mysql_fix_privilege_tables.sql +++ b/scripts/mysql_fix_privilege_tables.sql @@ -179,6 +179,11 @@ ALTER TABLE user MODIFY Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, MODIFY Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, MODIFY Repl_slave_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, + MODIFY Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, + MODIFY Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, + MODIFY Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, + MODIFY Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, + MODIFY Create_user_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, MODIFY Repl_client_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, MODIFY ssl_type enum('','ANY','X509', 'SPECIFIED') COLLATE utf8_general_ci DEFAULT '' NOT NULL; ALTER TABLE db @@ -198,6 +203,11 @@ ALTER TABLE db MODIFY Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, MODIFY Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, MODIFY Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, + MODIFY Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, + MODIFY Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, + MODIFY Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, + MODIFY Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, + MODIFY Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, MODIFY Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL; ALTER TABLE host MODIFY Host char(60) NOT NULL default '', @@ -215,6 +225,11 @@ ALTER TABLE host MODIFY Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, MODIFY Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, MODIFY Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, + MODIFY Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, + MODIFY Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, + MODIFY Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, + MODIFY Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, + MODIFY Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, MODIFY Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL; ALTER TABLE func ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin; From fc144204da82981f907edb24159b93959006fe31 Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Tue, 21 Nov 2006 00:46:13 +0100 Subject: [PATCH 059/131] Port mysql_upgrade to be tested on windows --- client/mysql_upgrade.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index 849cef2287c..37cbeb81e1d 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -31,10 +31,12 @@ const char *mysqlcheck_name= "mysqlcheck.exe"; const char *mysql_name= "mysql.exe"; const char *mysqld_name= "mysqld.exe"; +#define EXTRA_CLIENT_PATHS "client/release", "client/debug" #else const char *mysqlcheck_name= "mysqlcheck"; const char *mysql_name= "mysql"; const char *mysqld_name= "mysqld"; +#define EXTRA_CLIENT_PATHS "client" #endif /*__WIN__*/ extern TYPELIB sql_protocol_typelib; @@ -497,8 +499,9 @@ int main(int argc, char **argv) "mysql", NullS)) { ret= 1; - puts("Can't find data directory. Please restart with" - " --datadir=path-to-writable-data-dir"); + fprintf(stderr, + "Can't find data directory. Please restart with" + " --datadir=path-to-writable-data-dir"); goto error; } @@ -541,11 +544,13 @@ int main(int argc, char **argv) } if (find_file(mysqlcheck_name, basedir, MYF(0), path, sizeof(path), - "bin", "client", NullS)) + "bin", EXTRA_CLIENT_PATHS, NullS)) { ret= 1; - printf("Can't find program '%s'\n", mysqlcheck_name); - puts("Please restart with --basedir=mysql-install-directory"); + fprintf(stderr, + "Can't find program '%s'\n" + "Please restart with --basedir=mysql-install-directory", + mysqlcheck_name); goto error; } else @@ -567,7 +572,7 @@ int main(int argc, char **argv) ret= system(cmdline.str); if (ret) { - printf("Error executing '%s'\n", cmdline.str); + fprintf(stderr, "Error executing '%s'\n", cmdline.str); goto error; } @@ -578,12 +583,13 @@ int main(int argc, char **argv) fix_priv_tables: if (find_file(mysql_name, basedir, MYF(0), path, sizeof(path), - "bin", "client", NullS)) + "bin", EXTRA_CLIENT_PATHS, NullS)) { ret= 1; - puts("Could not find MySQL command-line client (mysql).\n" - "Please use --basedir to specify the directory" - " where MySQL is installed."); + fprintf(stderr, + "Could not find MySQL command-line client (mysql).\n" + "Please use --basedir to specify the directory" + " where MySQL is installed."); goto error; } else @@ -598,9 +604,10 @@ fix_priv_tables: "share/mysql", NullS)) { ret= 1; - puts("Could not find file " MYSQL_FIX_PRIV_TABLES_NAME "\n" - "Please use --basedir to specify the directory" - " where MySQL is installed"); + fprintf(stderr, + "Could not find file " MYSQL_FIX_PRIV_TABLES_NAME "\n" + "Please use --basedir to specify the directory" + " where MySQL is installed"); goto error; } else @@ -621,7 +628,7 @@ fix_priv_tables: ret= system(cmdline.str); if (ret) - printf("Error executing '%s'\n", cmdline.str); + fprintf(stderr, "Error executing '%s'\n", cmdline.str); error: dynstr_free(&cmdline); From a9eb1b709a422dea47912626fa527ee98ecbaff5 Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Tue, 21 Nov 2006 09:36:29 +0100 Subject: [PATCH 060/131] Add missing semicolon --- client/mysqltest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index ca36abb8f67..241e0dc4738 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -4140,7 +4140,7 @@ void init_win_path_patterns() "$MYSQL_TMP_DIR", "$MYSQLTEST_VARDIR", "./test/" }; - int num_paths= sizeof(paths)/sizeof(char*), + int num_paths= sizeof(paths)/sizeof(char*); int i; char* p; From 0b89340a0b8f5361f59eaf07fcf5b26a262d5b00 Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Tue, 21 Nov 2006 11:59:25 +0100 Subject: [PATCH 061/131] Updates for gethostname and gethostbyname_r usage --- configure.in | 14 +++++++------- sql/sql_parse.cc | 4 ---- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/configure.in b/configure.in index d0c2cd87381..4e205ad64a2 100644 --- a/configure.in +++ b/configure.in @@ -2031,7 +2031,7 @@ fi # Check definition of gethostbyname_r (glibc2.0.100 is different from Solaris) ac_save_CXXFLAGS="$CXXFLAGS" -AC_CACHE_CHECK([style of gethostname_r routines], mysql_cv_gethostname_style, +AC_CACHE_CHECK([style of gethostbyname_r routines], mysql_cv_gethostbyname_style, AC_LANG_SAVE AC_LANG_CPLUSPLUS if test "$ac_cv_prog_gxx" = "yes" -a "$with_other_libc" = "no" @@ -2053,10 +2053,10 @@ AC_TRY_COMPILE( skr = gethostbyname_r((const char *) 0, (struct hostent*) 0, (char*) 0, 0, (struct hostent **) 0, &skr);], -mysql_cv_gethostname_style=glibc2, mysql_cv_gethostname_style=other)) +mysql_cv_gethostbyname_style=glibc2, mysql_cv_gethostbyname_style=other)) AC_LANG_RESTORE CXXFLAGS="$ac_save_CXXFLAGS" -if test "$mysql_cv_gethostname_style" = "glibc2" +if test "$mysql_cv_gethostbyname_style" = "glibc2" then AC_DEFINE([HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE], [1], [Solaris define gethostbyname_r with 5 arguments. glibc2 defines this with 6 arguments]) @@ -2064,7 +2064,7 @@ fi # Check 3rd argument of getthostbyname_r ac_save_CXXFLAGS="$CXXFLAGS" -AC_CACHE_CHECK([3 argument to gethostname_r routines], mysql_cv_gethostname_arg, +AC_CACHE_CHECK([3 argument to gethostbyname_r routines], mysql_cv_gethostbyname_arg, AC_LANG_SAVE AC_LANG_CPLUSPLUS if test "$ac_cv_prog_gxx" = "yes" -a "$with_other_libc" = "no" @@ -2085,13 +2085,13 @@ AC_TRY_COMPILE( [int skr; skr = gethostbyname_r((const char *) 0, (struct hostent*) 0, (struct hostent_data*) 0);], -mysql_cv_gethostname_arg=hostent_data, mysql_cv_gethostname_arg=char)) +mysql_cv_gethostbyname_arg=hostent_data, mysql_cv_gethostbyname_arg=char)) AC_LANG_RESTORE CXXFLAGS="$ac_save_CXXFLAGS" -if test "$mysql_cv_gethostname_arg" = "hostent_data" +if test "$mysql_cv_gethostbyname_arg" = "hostent_data" then AC_DEFINE([HAVE_GETHOSTBYNAME_R_RETURN_INT], [1], - [In OSF 4.0f the 3'd argument to gethostname_r is hostent_data *]) + [In OSF 4.0f the 3'd argument to gethostbyname_r is hostent_data *]) fi diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index e3734026858..b703a0159f2 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -62,10 +62,6 @@ (LP)->sql_command == SQLCOM_DROP_FUNCTION ? \ "FUNCTION" : "PROCEDURE") -#ifdef SOLARIS -extern "C" int gethostname(char *name, int namelen); -#endif - static void time_out_user_resource_limits(THD *thd, USER_CONN *uc); #ifndef NO_EMBEDDED_ACCESS_CHECKS static int check_for_max_user_connections(THD *thd, USER_CONN *uc); From a14ae73f5512b97a517f0695aa563685ad454f4b Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 21 Nov 2006 15:16:12 +0100 Subject: [PATCH 062/131] Get name for .reject and .log files from result file name --- mysql-test/lib/mtr_report.pl | 7 ++++++- mysql-test/mysql-test-run.pl | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/mysql-test/lib/mtr_report.pl b/mysql-test/lib/mtr_report.pl index 8d7de9d1a4b..758e98984b8 100644 --- a/mysql-test/lib/mtr_report.pl +++ b/mysql-test/lib/mtr_report.pl @@ -34,7 +34,12 @@ sub mtr_verbose (@); # We can't use diff -u or diff -a as these are not portable sub mtr_show_failed_diff ($) { - my $tname= shift; + my $result_file_name= shift; + + # The reject and log files have been dumped to + # to filenames based on the result_file's name + my $tname= basename($result_file_name); + $tname=~ s/\..*$//; my $reject_file= "r/$tname.reject"; my $result_file= "r/$tname.result"; diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index a028c94a2c5..9b1dc1c9c0a 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -3203,7 +3203,7 @@ sub report_failure_and_restart ($) { my $tinfo= shift; mtr_report_test_failed($tinfo); - mtr_show_failed_diff($tinfo->{'name'}); + mtr_show_failed_diff($tinfo->{'result_file'}); print "\n"; if ( $opt_force ) { From 7cf226de110a57a501938f19dbd91da8a0f71e6e Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 21 Nov 2006 15:31:11 +0100 Subject: [PATCH 063/131] Rename system_mysql_db_fix.test to system_mysql_db_fix30020 as it tests mysql_fix_privilege_tables.s's ability to convert the system tables as of 3.20 to current system table format Add similar test for 4.1.23 tables - but use "mysql < mysql_fix_privilege_tables.sql" so it can be run on any platform. --- mysql-test/mysql-test-run.pl | 5 ++ ...pt => system_mysql_db_fix30020-master.opt} | 0 ...fix.test => system_mysql_db_fix30020.test} | 6 +- .../t/system_mysql_db_fix40123-master.opt | 1 + mysql-test/t/system_mysql_db_fix40123.test | 79 +++++++++++++++++++ 5 files changed, 89 insertions(+), 2 deletions(-) rename mysql-test/t/{system_mysql_db_fix-master.opt => system_mysql_db_fix30020-master.opt} (100%) rename mysql-test/t/{system_mysql_db_fix.test => system_mysql_db_fix30020.test} (92%) create mode 100644 mysql-test/t/system_mysql_db_fix40123-master.opt create mode 100644 mysql-test/t/system_mysql_db_fix40123.test diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index feb3500ba42..e6f3c0cc9d3 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -151,6 +151,7 @@ our $exe_mysqlslap; our $exe_mysqlimport; our $exe_mysqlshow; our $exe_mysql_fix_system_tables; +our $file_mysql_fix_privilege_tables; our $exe_mysqltest; our $exe_ndbd; our $exe_ndb_mgmd; @@ -1414,6 +1415,9 @@ sub executable_setup () { "$path_client_bindir/mysql_fix_privilege_tables"); } + # Look for mysql_fix_privilege_tables.sql script + $file_mysql_fix_privilege_tables= + mtr_file_exists("$glob_basedir/scripts/mysql_fix_privilege_tables.sql"); if ( ! $opt_skip_ndbcluster and executable_setup_ndb()) { @@ -1836,6 +1840,7 @@ sub environment_setup () { "--socket=$master->[0]->{'path_sock'}"; $ENV{'MYSQL_FIX_SYSTEM_TABLES'}= $cmdline_mysql_fix_system_tables; } + $ENV{'MYSQL_FIX_PRIVILEGE_TABLES'}= $file_mysql_fix_privilege_tables; # ---------------------------------------------------- # Setup env so childs can execute my_print_defaults diff --git a/mysql-test/t/system_mysql_db_fix-master.opt b/mysql-test/t/system_mysql_db_fix30020-master.opt similarity index 100% rename from mysql-test/t/system_mysql_db_fix-master.opt rename to mysql-test/t/system_mysql_db_fix30020-master.opt diff --git a/mysql-test/t/system_mysql_db_fix.test b/mysql-test/t/system_mysql_db_fix30020.test similarity index 92% rename from mysql-test/t/system_mysql_db_fix.test rename to mysql-test/t/system_mysql_db_fix30020.test index c50b641b7e2..b71ae6c2204 100644 --- a/mysql-test/t/system_mysql_db_fix.test +++ b/mysql-test/t/system_mysql_db_fix30020.test @@ -6,9 +6,11 @@ # # This is the test for mysql_fix_privilege_tables +# It checks that a system tables from mysql 3.20 +# can be upgraded to current system table format # # Note: If this test fails, don't be confused about the errors reported -# by mysql-test-run; This shows warnings from generated by +# by mysql-test-run This shows warnings generated by # mysql_fix_system_tables which should be ignored. # Instead, concentrate on the errors in r/system_mysql_db.reject @@ -81,7 +83,7 @@ INSERT INTO user VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y',' INSERT INTO user VALUES ('localhost','', '','N','N','N','N','N','N','N','N','N'); # Call the "shell script" $MYSQL_FIX_SYSTEM_TABLES using system --- system $MYSQL_FIX_SYSTEM_TABLES --database=test > /dev/null +-- system $MYSQL_FIX_SYSTEM_TABLES --database=test > $MYSQLTEST_VARDIR/log/system_mysql_db_fix30020.log 2>&1 -- enable_query_log -- enable_result_log diff --git a/mysql-test/t/system_mysql_db_fix40123-master.opt b/mysql-test/t/system_mysql_db_fix40123-master.opt new file mode 100644 index 00000000000..7e4fa9a3ee8 --- /dev/null +++ b/mysql-test/t/system_mysql_db_fix40123-master.opt @@ -0,0 +1 @@ +--result-file=system_mysql_db diff --git a/mysql-test/t/system_mysql_db_fix40123.test b/mysql-test/t/system_mysql_db_fix40123.test new file mode 100644 index 00000000000..471598625d4 --- /dev/null +++ b/mysql-test/t/system_mysql_db_fix40123.test @@ -0,0 +1,79 @@ +# Embedded server doesn't support external clients +--source include/not_embedded.inc + +# +# This is the test for mysql_fix_privilege_tables +# It checks that a system tables from mysql 4.1.23 +# can be upgraded to current system table format +# +# Note: If this test fails, don't be confused about the errors reported +# by mysql-test-run This shows warnings generated by +# mysql_fix_system_tables which should be ignored. +# Instead, concentrate on the errors in r/system_mysql_db.reject + +--disable_warnings +drop table if exists t1,t1aa,t2aa; +--enable_warnings + +-- disable_result_log +-- disable_query_log + +use test; + +# create system tables as in mysql-4.1.23 +# created by executing "./mysql_create_system_tables real ." + +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 ('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); + +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_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 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 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'; + +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'; + +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'; + +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'; + +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'; + + +# Run the mysql_fix_privilege_tables.sql using "mysql --force" +--exec $MYSQL --force test < $MYSQL_FIX_PRIVILEGE_TABLES > $MYSQLTEST_VARDIR/log/system_mysql_db_fix40123.log 2>&1 + +-- enable_query_log +-- enable_result_log + +# Dump the tables that should be compared +-- source include/system_db_struct.inc + +-- disable_query_log + +# Drop all tables created by this test +DROP TABLE db, host, user, func, tables_priv, columns_priv, procs_priv, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type; + +-- enable_query_log + +# check that we dropped all system tables +show tables; + +# End of 4.1 tests From 13b5e6275ac81900f3d6f5812e519369811b9204 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 21 Nov 2006 16:31:44 +0100 Subject: [PATCH 064/131] Add ALTER TABLE MODIFY statements in addition to the ALTER TABLE ADD for new columns to make sure they both exist and have the intended type --- scripts/mysql_fix_privilege_tables.sql | 42 +++++++++++++++++--------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/scripts/mysql_fix_privilege_tables.sql b/scripts/mysql_fix_privilege_tables.sql index ee92e4cf33b..3044e51a4fd 100644 --- a/scripts/mysql_fix_privilege_tables.sql +++ b/scripts/mysql_fix_privilege_tables.sql @@ -179,13 +179,9 @@ ALTER TABLE user MODIFY Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, MODIFY Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, MODIFY Repl_slave_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - MODIFY Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - MODIFY Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - MODIFY Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - MODIFY Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - MODIFY Create_user_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, MODIFY Repl_client_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, MODIFY ssl_type enum('','ANY','X509', 'SPECIFIED') COLLATE utf8_general_ci DEFAULT '' NOT NULL; + ALTER TABLE db MODIFY Host char(60) NOT NULL default '', MODIFY Db char(64) NOT NULL default '', @@ -203,12 +199,8 @@ ALTER TABLE db MODIFY Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, MODIFY Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, MODIFY Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - MODIFY Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - MODIFY Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - MODIFY Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - MODIFY Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - MODIFY Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, MODIFY Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL; + ALTER TABLE host MODIFY Host char(60) NOT NULL default '', MODIFY Db char(64) NOT NULL default '', @@ -225,12 +217,8 @@ ALTER TABLE host MODIFY Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, MODIFY Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, MODIFY Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - MODIFY Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - MODIFY Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - MODIFY Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - MODIFY Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, - MODIFY Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, MODIFY Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL; + ALTER TABLE func ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin; ALTER TABLE func @@ -265,15 +253,25 @@ SELECT @hadCreateViewPriv:=1 FROM user WHERE Create_view_priv LIKE '%'; # Create VIEWs privileges (v5.0) # ALTER TABLE db ADD Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Lock_tables_priv; +ALTER TABLE db MODIFY Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Lock_tables_priv; + ALTER TABLE host ADD Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Lock_tables_priv; +ALTER TABLE host MODIFY Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Lock_tables_priv; + ALTER TABLE user ADD Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Repl_client_priv; +ALTER TABLE user MODIFY Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Repl_client_priv; # # Show VIEWs privileges (v5.0) # ALTER TABLE db ADD Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv; +ALTER TABLE db MODIFY Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv; + ALTER TABLE host ADD Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv; +ALTER TABLE host MODIFY Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv; + ALTER TABLE user ADD Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv; +ALTER TABLE user MODIFY Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv; # # Show/Create views table privileges (v5.0) @@ -295,18 +293,31 @@ SELECT @hadCreateRoutinePriv:=1 FROM user WHERE Create_routine_priv LIKE '%'; # Create PROCEDUREs privileges (v5.0) # ALTER TABLE db ADD Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Show_view_priv; +ALTER TABLE db MODIFY Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Show_view_priv; + ALTER TABLE host ADD Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Show_view_priv; +ALTER TABLE host MODIFY Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Show_view_priv; + ALTER TABLE user ADD Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Show_view_priv; +ALTER TABLE user MODIFY Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Show_view_priv; # # Alter PROCEDUREs privileges (v5.0) # ALTER TABLE db ADD Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_routine_priv; +ALTER TABLE db MODIFY Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_routine_priv; + ALTER TABLE host ADD Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_routine_priv; +ALTER TABLE host MODIFY Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_routine_priv; + ALTER TABLE user ADD Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_routine_priv; +ALTER TABLE user MODIFY Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_routine_priv; ALTER TABLE db ADD Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Alter_routine_priv; +ALTER TABLE db MODIFY Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Alter_routine_priv; + ALTER TABLE host ADD Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Alter_routine_priv; +ALTER TABLE host MODIFY Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Alter_routine_priv; # # Assign create/alter routine privileges to people who have create privileges @@ -328,6 +339,7 @@ SET @hadCreateUserPriv:=0; SELECT @hadCreateUserPriv:=1 FROM user WHERE Create_user_priv LIKE '%'; ALTER TABLE user ADD Create_user_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Alter_routine_priv; +ALTER TABLE user MODIFY Create_user_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Alter_routine_priv; UPDATE user LEFT JOIN db USING (Host,User) SET Create_user_priv='Y' WHERE @hadCreateUserPriv = 0 AND (user.Grant_priv = 'Y' OR db.Grant_priv = 'Y'); From 9594462f72d97f2840177b4e1be01f8a46ff763e Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 21 Nov 2006 16:34:10 +0100 Subject: [PATCH 065/131] Remove unused variable --- client/mysqltest.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 9ad2f3df5de..d233497a960 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -6448,7 +6448,7 @@ int reg_replace(char** buf_p, int* buf_len_p, char *pattern, { my_regex_t r; my_regmatch_t *subs; - char *buf_end, *replace_end; + char *replace_end; char *buf= *buf_p; int len; int buf_len, need_buf_len; @@ -6468,8 +6468,6 @@ int reg_replace(char** buf_p, int* buf_len_p, char *pattern, SECURE_REG_BUF - buf_end= buf + buf_len; - if (icase) cflags|= REG_ICASE; From 7673a2d415c1e681d7cffa307df2c56faa38337f Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 21 Nov 2006 17:44:43 +0100 Subject: [PATCH 066/131] Update mysql_fix_privilege_tables.sql to handle upgrade from 5.0 while retaining old upgrade behaviour. Add test for upgrade from 5.0.30 --- mysql-test/t/system_mysql_db_fix40123.test | 2 +- .../t/system_mysql_db_fix50030-master.opt | 1 + mysql-test/t/system_mysql_db_fix50030.test | 82 +++++++++++++++++++ scripts/mysql_fix_privilege_tables.sql | 14 +++- 4 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 mysql-test/t/system_mysql_db_fix50030-master.opt create mode 100644 mysql-test/t/system_mysql_db_fix50030.test diff --git a/mysql-test/t/system_mysql_db_fix40123.test b/mysql-test/t/system_mysql_db_fix40123.test index 471598625d4..5adefc2e966 100644 --- a/mysql-test/t/system_mysql_db_fix40123.test +++ b/mysql-test/t/system_mysql_db_fix40123.test @@ -69,7 +69,7 @@ CREATE TABLE time_zone_leap_second ( Transition_time bigint signed NOT NULL, -- disable_query_log # Drop all tables created by this test -DROP TABLE db, host, user, func, tables_priv, columns_priv, procs_priv, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type; +DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event; -- enable_query_log diff --git a/mysql-test/t/system_mysql_db_fix50030-master.opt b/mysql-test/t/system_mysql_db_fix50030-master.opt new file mode 100644 index 00000000000..7e4fa9a3ee8 --- /dev/null +++ b/mysql-test/t/system_mysql_db_fix50030-master.opt @@ -0,0 +1 @@ +--result-file=system_mysql_db diff --git a/mysql-test/t/system_mysql_db_fix50030.test b/mysql-test/t/system_mysql_db_fix50030.test new file mode 100644 index 00000000000..724786febaf --- /dev/null +++ b/mysql-test/t/system_mysql_db_fix50030.test @@ -0,0 +1,82 @@ +# Embedded server doesn't support external clients +--source include/not_embedded.inc + +# +# This is the test for mysql_fix_privilege_tables +# It checks that a system tables from mysql 5.0.30 +# can be upgraded to current system table format +# +# Note: If this test fails, don't be confused about the errors reported +# by mysql-test-run This shows warnings generated by +# mysql_fix_system_tables which should be ignored. +# Instead, concentrate on the errors in r/system_mysql_db.reject + +--disable_warnings +drop table if exists t1,t1aa,t2aa; +--enable_warnings + +-- disable_result_log +-- disable_query_log + +use test; + +# create system tables as in mysql-5.0.30 +# created by executing "./mysql_create_system_tables real ." + +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, Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_routine_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, 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','Y','Y','Y','N','N'); +INSERT INTO db VALUES ('%','test\_%','','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','Y','Y','Y','Y','N','N'); + +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, Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_routine_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, 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) character set latin1 collate latin1_bin 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, Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_user_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, max_user_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','Y','Y','Y','Y','Y','','','','',0,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','Y','Y','Y','Y','Y','','','','',0,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') 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','Create View','Show view') 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 char(64) not null, help_category_id smallint unsigned not null, description text not null, example text not null, url char(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 char(64) not null, parent_category_id smallint unsigned null, url char(128) not null, primary key (help_category_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8 comment='help categories'; +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 help_keyword ( help_keyword_id int unsigned not null, name char(64) not null, primary key (help_keyword_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8 comment='help keywords'; + +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'; + +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'; + +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'; + +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'; + +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'; + +CREATE TABLE proc ( db char(64) collate utf8_bin DEFAULT '' NOT NULL, name char(64) DEFAULT '' NOT NULL, type enum('FUNCTION','PROCEDURE') NOT NULL, specific_name char(64) DEFAULT '' NOT NULL, language enum('SQL') DEFAULT 'SQL' NOT NULL, sql_data_access enum('CONTAINS_SQL', 'NO_SQL', 'READS_SQL_DATA', 'MODIFIES_SQL_DATA' ) DEFAULT 'CONTAINS_SQL' NOT NULL, is_deterministic enum('YES','NO') DEFAULT 'NO' NOT NULL, security_type enum('INVOKER','DEFINER') DEFAULT 'DEFINER' NOT NULL, param_list blob DEFAULT '' NOT NULL, returns char(64) DEFAULT '' NOT NULL, body longblob DEFAULT '' NOT NULL, definer char(77) collate utf8_bin DEFAULT '' NOT NULL, created timestamp, modified timestamp, sql_mode set( 'REAL_AS_FLOAT', 'PIPES_AS_CONCAT', 'ANSI_QUOTES', 'IGNORE_SPACE', 'NOT_USED', 'ONLY_FULL_GROUP_BY', 'NO_UNSIGNED_SUBTRACTION', 'NO_DIR_IN_CREATE', 'POSTGRESQL', 'ORACLE', 'MSSQL', 'DB2', 'MAXDB', 'NO_KEY_OPTIONS', 'NO_TABLE_OPTIONS', 'NO_FIELD_OPTIONS', 'MYSQL323', 'MYSQL40', 'ANSI', 'NO_AUTO_VALUE_ON_ZERO', 'NO_BACKSLASH_ESCAPES', 'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES', 'NO_ZERO_IN_DATE', 'NO_ZERO_DATE', 'INVALID_DATES', 'ERROR_FOR_DIVISION_BY_ZERO', 'TRADITIONAL', 'NO_AUTO_CREATE_USER', 'HIGH_NOT_PRECEDENCE' ) DEFAULT '' NOT NULL, comment char(64) collate utf8_bin DEFAULT '' NOT NULL, PRIMARY KEY (db,name,type) ) engine=MyISAM character set utf8 comment='Stored Procedures'; + +CREATE TABLE procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) binary DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp(14), PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges'; + + +# Run the mysql_fix_privilege_tables.sql using "mysql --force" +--exec $MYSQL --force test < $MYSQL_FIX_PRIVILEGE_TABLES > $MYSQLTEST_VARDIR/log/system_mysql_db_fix50030.log 2>&1 + +-- enable_query_log +-- enable_result_log + +# Dump the tables that should be compared +-- source include/system_db_struct.inc + +-- disable_query_log + +# Drop all tables created by this test +DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event; + +-- enable_query_log + +# check that we dropped all system tables +show tables; + +# End of 4.1 tests diff --git a/scripts/mysql_fix_privilege_tables.sql b/scripts/mysql_fix_privilege_tables.sql index 3c23d35f91c..aea44e84fef 100644 --- a/scripts/mysql_fix_privilege_tables.sql +++ b/scripts/mysql_fix_privilege_tables.sql @@ -440,7 +440,7 @@ PRIMARY KEY TranTime (Transition_time) # -# Create proc table if it doesn't exists +# Create proc table if it does not exists # CREATE TABLE IF NOT EXISTS proc ( @@ -661,7 +661,11 @@ SET @hadEventPriv := 0; SELECT @hadEventPriv :=1 FROM user WHERE Event_priv LIKE '%'; ALTER TABLE user add Event_priv enum('N','Y') character set utf8 DEFAULT 'N' NOT NULL AFTER Create_user_priv; +ALTER TABLE user MODIFY Event_priv enum('N','Y') character set utf8 DEFAULT 'N' NOT NULL AFTER Create_user_priv; + ALTER TABLE db add Event_priv enum('N','Y') character set utf8 DEFAULT 'N' NOT NULL; +ALTER TABLE db MODIFY Event_priv enum('N','Y') character set utf8 DEFAULT 'N' NOT NULL; + ALTER TABLE event DROP PRIMARY KEY; ALTER TABLE event ADD PRIMARY KEY(db, name); ALTER TABLE event ADD sql_mode @@ -708,8 +712,14 @@ SET @hadTriggerPriv := 0; SELECT @hadTriggerPriv :=1 FROM user WHERE Trigger_priv LIKE '%'; ALTER TABLE user ADD Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Event_priv; +ALTER TABLE user MODIFY Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Event_priv; + ALTER TABLE host ADD Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL; -ALTER TABLE db ADD Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL; +ALTER TABLE host MODIFY Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL; + +ALTER TABLE db ADD Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL; +ALTER TABLE db MODIFY Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL; + ALTER TABLE tables_priv MODIFY Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') COLLATE utf8_general_ci DEFAULT '' NOT NULL; UPDATE user SET Trigger_priv=Super_priv WHERE @hadTriggerPriv = 0; From d89db5edf8bc49d1df9ddec7caa2d7f903378d7f Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 21 Nov 2006 21:39:37 +0100 Subject: [PATCH 067/131] When runnig from binary dist the .sql files are found in share/ directory --- mysql-test/mysql-test-run.pl | 3 ++- scripts/mysql_fix_privilege_tables.sql | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 0da28d79e56..73bde3b3e57 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1417,7 +1417,8 @@ sub executable_setup () { # Look for mysql_fix_privilege_tables.sql script $file_mysql_fix_privilege_tables= - mtr_file_exists("$glob_basedir/scripts/mysql_fix_privilege_tables.sql"); + mtr_file_exists("$glob_basedir/scripts/mysql_fix_privilege_tables.sql", + "$path_share/mysql_fix_privilege_tables.sql"); if ( ! $opt_skip_ndbcluster and executable_setup_ndb()) { diff --git a/scripts/mysql_fix_privilege_tables.sql b/scripts/mysql_fix_privilege_tables.sql index 3044e51a4fd..28c9aced618 100644 --- a/scripts/mysql_fix_privilege_tables.sql +++ b/scripts/mysql_fix_privilege_tables.sql @@ -435,7 +435,7 @@ PRIMARY KEY TranTime (Transition_time) # -# Create proc table if it doesn't exists +# Create proc table if it does not exists # CREATE TABLE IF NOT EXISTS proc ( From bface97eccb59026abe425dc753b61aece72b7dd Mon Sep 17 00:00:00 2001 From: "iggy@rolltop.ignatz42.dyndns.org" <> Date: Tue, 21 Nov 2006 21:10:02 -0500 Subject: [PATCH 068/131] Bug#19799 delimiter command not working correctly when sourcing a sql file - Client side readline functions unconditionally search for Unix '\n' line endings. In this case, the delimiter statement was set to '//\r' instead of the intended '//'. When removing the '\n' check for and remove preceeding '\r' character as well. --- client/readline.cc | 3 ++- mysql-test/r/mysql.result | 4 ++++ mysql-test/t/mysql_delimiter.sql | 9 +++++++++ mysql-test/t/mysql_delimiter_19799.sql | 1 + 4 files changed, 16 insertions(+), 1 deletion(-) create mode 100755 mysql-test/t/mysql_delimiter_19799.sql diff --git a/client/readline.cc b/client/readline.cc index 3d524633d69..52abe1045b7 100644 --- a/client/readline.cc +++ b/client/readline.cc @@ -51,7 +51,8 @@ char *batch_readline(LINE_BUFFER *line_buff) if (!(pos=intern_read_line(line_buff,&out_length))) return 0; if (out_length && pos[out_length-1] == '\n') - out_length--; /* Remove '\n' */ + if (--out_length && pos[out_length-1] == '\r') /* Remove '\n' */ + out_length--; /* Remove '\r' */ line_buff->read_length=out_length; pos[out_length]=0; return pos; diff --git a/mysql-test/r/mysql.result b/mysql-test/r/mysql.result index 14267afc27e..b76b2c1e3b7 100644 --- a/mysql-test/r/mysql.result +++ b/mysql-test/r/mysql.result @@ -36,6 +36,10 @@ Tables_in_test t1 t2 t3 +Database +information_schema +mysql +test _ Test delimiter : from command line a diff --git a/mysql-test/t/mysql_delimiter.sql b/mysql-test/t/mysql_delimiter.sql index fa80c980b29..67075091c01 100644 --- a/mysql-test/t/mysql_delimiter.sql +++ b/mysql-test/t/mysql_delimiter.sql @@ -49,3 +49,12 @@ delimiter ; # Reset delimiter # Bug #11523: \d works differently than delimiter # source t/mysql_delimiter_source.sql +delimiter ; # Reset delimiter + +# +# Bug #19799: delimiter command not working correctly when sourcing a sql file +# with Windows style line endings. +# +source t/mysql_delimiter_19799.sql +show databases// +delimiter ; # Reset delimiter diff --git a/mysql-test/t/mysql_delimiter_19799.sql b/mysql-test/t/mysql_delimiter_19799.sql new file mode 100755 index 00000000000..2a3d4378492 --- /dev/null +++ b/mysql-test/t/mysql_delimiter_19799.sql @@ -0,0 +1 @@ +delimiter // From 26e05951ab263804fcc618d080976a7953515cde Mon Sep 17 00:00:00 2001 From: "iggy@rolltop.ignatz42.dyndns.org" <> Date: Wed, 22 Nov 2006 00:52:32 -0500 Subject: [PATCH 069/131] Bug#19799 delimiter command not working correctly when sourcing a sql file - Post Merge Fix. --- mysql-test/r/mysql.result | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/r/mysql.result b/mysql-test/r/mysql.result index b76b2c1e3b7..deade31233f 100644 --- a/mysql-test/r/mysql.result +++ b/mysql-test/r/mysql.result @@ -38,6 +38,7 @@ t2 t3 Database information_schema +cluster mysql test _ From e2a6759c4a9e9c20adbbb09dcc2da749498e48b1 Mon Sep 17 00:00:00 2001 From: "iggy@rolltop.ignatz42.dyndns.org" <> Date: Wed, 22 Nov 2006 01:27:06 -0500 Subject: [PATCH 070/131] Bug#19799 delimiter command not working correctly when sourcing a sql file - Use more appropriate test case. --- mysql-test/r/mysql.result | 7 ++----- mysql-test/t/mysql_delimiter.sql | 3 ++- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/mysql.result b/mysql-test/r/mysql.result index deade31233f..7fd55351880 100644 --- a/mysql-test/r/mysql.result +++ b/mysql-test/r/mysql.result @@ -36,11 +36,8 @@ Tables_in_test t1 t2 t3 -Database -information_schema -cluster -mysql -test +Tables_in_test +t1 _ Test delimiter : from command line a diff --git a/mysql-test/t/mysql_delimiter.sql b/mysql-test/t/mysql_delimiter.sql index 67075091c01..db679c3b06b 100644 --- a/mysql-test/t/mysql_delimiter.sql +++ b/mysql-test/t/mysql_delimiter.sql @@ -56,5 +56,6 @@ delimiter ; # Reset delimiter # with Windows style line endings. # source t/mysql_delimiter_19799.sql -show databases// +use test// +show tables// delimiter ; # Reset delimiter From 0a27881be523165d133edbb55f317b4e09926318 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Wed, 22 Nov 2006 09:52:31 +0100 Subject: [PATCH 071/131] Bug #20589 Missing some table level privileges after upgrade - Update comments to reflect correct version --- scripts/mysql_fix_privilege_tables.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/mysql_fix_privilege_tables.sql b/scripts/mysql_fix_privilege_tables.sql index a72bd2799aa..8e3d1845571 100644 --- a/scripts/mysql_fix_privilege_tables.sql +++ b/scripts/mysql_fix_privilege_tables.sql @@ -1,5 +1,5 @@ -- This script converts any old privilege tables to privilege tables suitable --- for MySQL 4.0. +-- for MySQL 4.1 -- You can safely ignore all 'Duplicate column' and 'Unknown column' errors" -- because these just mean that your tables are already up to date. @@ -93,7 +93,7 @@ ALTER TABLE columns_priv change Type Column_priv set('Select','Insert','Update', ALTER TABLE func add type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL; -- --- Change the user,db and host tables to MySQL 4.0 format +-- Change the user,db and host tables to current format -- # Detect whether we had Show_db_priv From 35238085d6248212cd1cd4e956816cd5535d34c1 Mon Sep 17 00:00:00 2001 From: "andrey@example.com" <> Date: Wed, 22 Nov 2006 14:06:59 +0100 Subject: [PATCH 072/131] fix for bug#24396 --- mysql-test/t/events_bugs.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/t/events_bugs.test b/mysql-test/t/events_bugs.test index 6223395bfd9..605eaa431d0 100644 --- a/mysql-test/t/events_bugs.test +++ b/mysql-test/t/events_bugs.test @@ -280,7 +280,7 @@ create event e22830_3 on schedule every 1 hour do alter event e22830_3 on schedu create event e22830_4 on schedule every 1 hour do alter event e22830_4 on schedule every (select f22830() from dual) hour; select event_name, event_definition, interval_value, interval_field from information_schema.events order by event_name; set global event_scheduler=on; ---sleep 0.7 +--sleep 2.4 set global event_scheduler=off; select event_name, event_definition, interval_value, interval_field from information_schema.events order by event_name; drop function f22830; From d6f06d424592e5e9303a8d70f2323ab3e6cf3785 Mon Sep 17 00:00:00 2001 From: "ramil/ram@mysql.com/myoffice.izhnet.ru" <> Date: Wed, 22 Nov 2006 17:59:46 +0400 Subject: [PATCH 073/131] after-merge fix-up. --- mysql-test/r/date_formats.result | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/date_formats.result b/mysql-test/r/date_formats.result index 4b5efbd83ca..cf3495ef26d 100644 --- a/mysql-test/r/date_formats.result +++ b/mysql-test/r/date_formats.result @@ -212,12 +212,12 @@ Tuesday 52 2001 %W %V %X 2002-01-01 00:00:00 15-01-20 %d-%m-%y 2020-01-15 00:00:00 15-2001-1 %d-%Y-%c 2001-01-15 00:00:00 Warnings: -Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:20:10' -Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:20:10' -Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:20:10' -Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:20:10' -Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:20:10' -Warning 1292 Truncated incorrect datetime value: '0000-00-00 10:20:10.440000' +Warning 1292 Incorrect datetime value: '0000-00-00 10:20:10' +Warning 1292 Incorrect datetime value: '0000-00-00 10:20:10' +Warning 1292 Incorrect datetime value: '0000-00-00 10:20:10' +Warning 1292 Incorrect datetime value: '0000-00-00 10:20:10' +Warning 1292 Incorrect datetime value: '0000-00-00 10:20:10' +Warning 1292 Incorrect datetime value: '0000-00-00 10:20:10.440000' select date,format,DATE(str_to_date(date, format)) as date2 from t1; date format date2 2003-01-02 10:11:12 %Y-%m-%d %H:%i:%S 2003-01-02 From 176313a6797f17b8021a3f6b21ac5d92ac03a3d6 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Thu, 23 Nov 2006 11:56:05 +0100 Subject: [PATCH 074/131] mysql_upgrade should look for .sql script also in share/ directory --- client/mysql_upgrade.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index 37cbeb81e1d..0e228c257d1 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -597,7 +597,7 @@ fix_priv_tables: if (find_file(MYSQL_FIX_PRIV_TABLES_NAME, basedir, MYF(0), path, sizeof(path), - "support_files", "share/mysql", "scripts", + "support_files", "share", "share/mysql", "scripts", NullS) && find_file(MYSQL_FIX_PRIV_TABLES_NAME, "/usr/local/mysql", MYF(0), path, sizeof(path), From 7053ef84bf03002f864f5985f9915116de756fda Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Thu, 23 Nov 2006 17:23:29 +0100 Subject: [PATCH 075/131] Rework my_getpagesize function - Put 'my_getpagesize' in it's own .c file - Map the call 'my_getpagesize' directly to 'getpagesize' if it exists - Add default implementation for 'my_getpagesize' to be used if no platform specfic function exists --- include/my_sys.h | 14 +++++++------- mysys/CMakeLists.txt | 3 ++- mysys/Makefile.am | 2 +- mysys/my_getpagesize.c | 41 +++++++++++++++++++++++++++++++++++++++++ mysys/my_mmap.c | 7 ------- 5 files changed, 51 insertions(+), 16 deletions(-) create mode 100644 mysys/my_getpagesize.c diff --git a/include/my_sys.h b/include/my_sys.h index ebb518314b2..d19091a85e8 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -842,12 +842,6 @@ my_bool my_gethwaddr(uchar *to); #endif #define my_mmap(a,b,c,d,e,f) mmap(a,b,c,d,e,f) -#ifdef HAVE_GETPAGESIZE -#define my_getpagesize() getpagesize() -#else -/* qnx ? */ -#define my_getpagesize() 8192 -#endif #define my_munmap(a,b) munmap((a),(b)) #else @@ -863,11 +857,17 @@ my_bool my_gethwaddr(uchar *to); #define HAVE_MMAP #endif -int my_getpagesize(void); void *my_mmap(void *, size_t, int, int, int, my_off_t); int my_munmap(void *, size_t); #endif +/* my_getpagesize */ +#ifdef HAVE_GETPAGESIZE +#define my_getpagesize() getpagesize() +#else +int my_getpagesize(void); +#endif + int my_msync(int, void *, size_t, int); /* character sets */ diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt index 7926cb916c1..b1a3e7441fb 100755 --- a/mysys/CMakeLists.txt +++ b/mysys/CMakeLists.txt @@ -26,4 +26,5 @@ ADD_LIBRARY(mysys array.c charset-def.c charset.c checksum.c default.c default_m my_static.c my_symlink.c my_symlink2.c my_sync.c my_thr_init.c my_wincond.c my_windac.c my_winsem.c my_winthread.c my_write.c ptr_cmp.c queues.c rijndael.c safemalloc.c sha1.c string.c thr_alarm.c thr_lock.c thr_mutex.c - thr_rwlock.c tree.c typelib.c base64.c my_memmem.c) + thr_rwlock.c tree.c typelib.c base64.c my_memmem.c + my_getpagesize.c) diff --git a/mysys/Makefile.am b/mysys/Makefile.am index 041130fdf5c..47480e8f363 100644 --- a/mysys/Makefile.am +++ b/mysys/Makefile.am @@ -29,7 +29,7 @@ noinst_HEADERS = mysys_priv.h my_static.h \ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \ mf_path.c mf_loadpath.c my_file.c \ my_open.c my_create.c my_dup.c my_seek.c my_read.c \ - my_pread.c my_write.c \ + my_pread.c my_write.c my_getpagesize.c \ mf_keycache.c mf_keycaches.c my_crc32.c \ mf_iocache.c mf_iocache2.c mf_cache.c mf_tempfile.c \ mf_tempdir.c my_lock.c mf_brkhant.c my_alarm.c \ diff --git a/mysys/my_getpagesize.c b/mysys/my_getpagesize.c new file mode 100644 index 00000000000..ac4bd775ba9 --- /dev/null +++ b/mysys/my_getpagesize.c @@ -0,0 +1,41 @@ +/* Copyright (C) 2000-2003 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 */ + +#include "mysys_priv.h" + +#ifndef HAVE_GETPAGESIZE + +#if defined __WIN__ + +int my_getpagesize(void) +{ + SYSTEM_INFO si; + GetSystemInfo(&si); + return si.dwPageSize; +} + +#else + +/* Default implementation */ +int my_getpagesize(void) +{ + return (int)8192; +} + +#endif + +#endif + diff --git a/mysys/my_mmap.c b/mysys/my_mmap.c index 21bfddae46c..eb74aaeaae4 100644 --- a/mysys/my_mmap.c +++ b/mysys/my_mmap.c @@ -33,13 +33,6 @@ int my_msync(int fd, void *addr, size_t len, int flags) static SECURITY_ATTRIBUTES mmap_security_attributes= {sizeof(SECURITY_ATTRIBUTES), 0, TRUE}; -int my_getpagesize(void) -{ - SYSTEM_INFO si; - GetSystemInfo(&si); - return si.dwPageSize; -} - void *my_mmap(void *addr, size_t len, int prot, int flags, int fd, my_off_t offset) { From 8f85eaf925cc8c8cf33704c955c543f0de156c43 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Thu, 23 Nov 2006 17:26:06 +0100 Subject: [PATCH 076/131] Remove duplicate "$report_features" --- mysql-test/mysql-test-run.pl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 3c855fb0499..e7d269e143b 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -223,9 +223,8 @@ our $opt_ndbcluster_port_slave; our $opt_ndbconnectstring_slave; our $opt_record; -our $opt_report_features; +my $opt_report_features; our $opt_check_testcases; -my $opt_report_features; our $opt_skip; our $opt_skip_rpl; From cdbc79b500af5e24eff8781e695a981b22956c19 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Thu, 23 Nov 2006 17:30:32 +0100 Subject: [PATCH 077/131] Make source_dist a "local" global variable And it's not an "opt" --- mysql-test/mysql-test-run.pl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 9b1dc1c9c0a..aa650d3bf02 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -238,8 +238,6 @@ our $opt_suite_timeout; my $default_testcase_timeout= 15; # 15 min max my $default_suite_timeout= 180; # 3 hours max -our $opt_source_dist; - our $opt_start_and_exit; our $opt_start_dirty; our $opt_start_from; @@ -299,6 +297,8 @@ our $glob_tot_real_time= 0; our %mysqld_variables; +my $source_dist= 0; + ###################################################################### # @@ -627,7 +627,7 @@ sub command_line_setup () { if ( -d "../sql" ) { - $opt_source_dist= 1; + $source_dist= 1; } $glob_hostname= mtr_short_hostname(); @@ -647,7 +647,7 @@ sub command_line_setup () { unless defined $glob_mysql_bench_dir; $path_my_basedir= - $opt_source_dist ? $glob_mysql_test_dir : $glob_basedir; + $source_dist ? $glob_mysql_test_dir : $glob_basedir; $glob_timers= mtr_init_timers(); @@ -901,7 +901,7 @@ sub command_line_setup () { # -------------------------------------------------------------------------- # Gcov flag # -------------------------------------------------------------------------- - if ( $opt_gcov and ! $opt_source_dist ) + if ( $opt_gcov and ! $source_dist ) { mtr_error("Coverage test needs the source - please use source dist"); } @@ -1526,7 +1526,7 @@ sub environment_setup () { # Setup LD_LIBRARY_PATH so the libraries from this distro/clone # are used in favor of the system installed ones # -------------------------------------------------------------------------- - if ( $opt_source_dist ) + if ( $source_dist ) { push(@ld_library_paths, "$glob_basedir/libmysql/.libs/", "$glob_basedir/libmysql_r/.libs/"); From c99678df03090bb2e9672c374934d44ca9304860 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Thu, 23 Nov 2006 20:07:53 +0100 Subject: [PATCH 078/131] Fix netware compile failure Remove other warnings about unused variables --- sql/udf_example.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sql/udf_example.c b/sql/udf_example.c index a4f7eddd302..bbab47e253d 100644 --- a/sql/udf_example.c +++ b/sql/udf_example.c @@ -1087,12 +1087,13 @@ my_bool is_const_init(UDF_INIT *initid, UDF_ARGS *args, char *message) strmov(message, "IS_CONST accepts only one argument"); return 1; } - initid->ptr= (args->args[0] != NULL) ? 1 : 0; + initid->ptr= (char*)((args->args[0] != NULL) ? 1 : 0); return 0; } -char * is_const(UDF_INIT *initid, UDF_ARGS *args, char *result, unsigned long - *length, char *is_null, char *error) +char * is_const(UDF_INIT *initid, UDF_ARGS *args __attribute__((unused)), + char *result, unsigned long *length, + char *is_null, char *error __attribute__((unused))) { if (initid->ptr != 0) { sprintf(result, "const"); From 91c3698aba896e78a5377fbd9b274ab352347f92 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Thu, 23 Nov 2006 20:08:48 +0100 Subject: [PATCH 079/131] Convert one more opt_source_dist --- 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 47fc6dca2fd..df22143e08d 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -658,7 +658,7 @@ sub command_line_setup () { # directory. And we install "/usr/share/mysql-test". Moving up one # more directory relative to "mysql-test" gives us a usable base # directory for RPM installs. - if ( ! $opt_source_dist and ! -d "$glob_basedir/bin" ) + if ( ! $source_dist and ! -d "$glob_basedir/bin" ) { $glob_basedir= dirname($glob_basedir); } From c4af2f26a7ff976973de6b21c4bd22fe67306045 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Thu, 23 Nov 2006 21:07:41 +0100 Subject: [PATCH 080/131] Add mysys/my_getpagesize.c as source file for mysql_upgrade --- client/CMakeLists.txt | 2 +- client/Makefile.am | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 09a6a3f1e2a..d37d99ad479 100755 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -66,7 +66,7 @@ TARGET_LINK_LIBRARIES(mysqldump mysqlclient mysys dbug yassl taocrypt zlib wsock ADD_EXECUTABLE(mysqlimport mysqlimport.c) TARGET_LINK_LIBRARIES(mysqlimport mysqlclient mysys dbug yassl taocrypt zlib wsock32) -ADD_EXECUTABLE(mysql_upgrade mysql_upgrade.c) +ADD_EXECUTABLE(mysql_upgrade mysql_upgrade.c ../mysys/my_getpagesize.c) TARGET_LINK_LIBRARIES(mysql_upgrade mysqlclient mysys dbug yassl taocrypt zlib wsock32) ADD_EXECUTABLE(mysqlshow mysqlshow.c) diff --git a/client/Makefile.am b/client/Makefile.am index df6e38223d4..db578b05da4 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -49,7 +49,8 @@ mysqlshow_SOURCES= mysqlshow.c mysqldump_SOURCES= mysqldump.c my_user.c \ $(top_srcdir)/mysys/mf_getdate.c mysqlimport_SOURCES= mysqlimport.c -mysql_upgrade_SOURCES= mysql_upgrade.c +mysql_upgrade_SOURCES= mysql_upgrade.c \ + $(top_srcdir)/mysys/my_getpagesize.c sql_src=log_event.h mysql_priv.h log_event.cc my_decimal.h my_decimal.cc strings_src=decimal.c From d4d675a6e2b68d7a988f9c81b0333e42821ff11f Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Thu, 23 Nov 2006 21:12:50 +0100 Subject: [PATCH 081/131] mysql_fix_priviileg_tables.sql might be in share/ but not in $path_share since that is where the lang files etc are --- 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 df22143e08d..c9dcd75415c 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1443,7 +1443,7 @@ sub executable_setup () { # Look for mysql_fix_privilege_tables.sql script $file_mysql_fix_privilege_tables= mtr_file_exists("$glob_basedir/scripts/mysql_fix_privilege_tables.sql", - "$path_share/mysql_fix_privilege_tables.sql"); + "$glob_basedir/share/mysql_fix_privilege_tables.sql"); if ( ! $opt_skip_ndbcluster and executable_setup_ndb()) { From d4595f3c57ae97e9251ee3b1680ad9fd6ddb218f Mon Sep 17 00:00:00 2001 From: "knielsen@ymer.(none)" <> Date: Fri, 24 Nov 2006 12:38:39 +0100 Subject: [PATCH 082/131] Do not link /usr/lib/debug/* on Debian <=3.1, as it causes broken stack traces in Valgrind (broken libc6-dbg). Installing libc6-dbg on Debian will still provide proper bactraces, even without setting LD_LIBRARY_PATH explicitly. --- mysql-test/lib/mtr_io.pl | 14 ++++++++++++++ mysql-test/mysql-test-run.pl | 10 +++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/mysql-test/lib/mtr_io.pl b/mysql-test/lib/mtr_io.pl index 984d834486c..09749bc74e3 100644 --- a/mysql-test/lib/mtr_io.pl +++ b/mysql-test/lib/mtr_io.pl @@ -13,6 +13,8 @@ sub mtr_tofile ($@); sub mtr_tonewfile($@); sub mtr_lastlinefromfile($); sub mtr_appendfile_to_file ($$); +sub mtr_grab_file($); + ############################################################################## # @@ -128,6 +130,7 @@ sub unspace { return "$quote$string$quote"; } +# Read a whole file, stripping leading and trailing whitespace. sub mtr_fromfile ($) { my $file= shift; @@ -181,5 +184,16 @@ sub mtr_appendfile_to_file ($$) { close TOFILE; } +# Read a whole file verbatim. +sub mtr_grab_file($) { + my $file= shift; + open(FILE, '<', $file) + or return undef; + local $/= undef; + my $data= scalar(); + close FILE; + return $data; +} + 1; diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index a028c94a2c5..22dc49c5ebd 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1557,9 +1557,17 @@ sub environment_setup () { # impossible to add correct supressions, that means if "/usr/lib/debug" # is available, it should be added to # LD_LIBRARY_PATH + # + # But pthread is broken in libc6-dbg on Debian <= 3.1 (see Debian + # bug 399035, http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=399035), + # so don't change LD_LIBRARY_PATH on that platform. # -------------------------------------------------------------------------- my $debug_libraries_path= "/usr/lib/debug"; - if ( $opt_valgrind and -d $debug_libraries_path ) + 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 > 3.1 ) ) { push(@ld_library_paths, $debug_libraries_path); } From 7d8c8af5a217315c5de1d01b0e1a7520630a9d94 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Fri, 24 Nov 2006 13:39:09 +0100 Subject: [PATCH 083/131] Fix merge conflicts --- mysql-test/mysql-test-run.pl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 4f32ae17724..79c3ac6582d 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -187,7 +187,6 @@ our $opt_fast; our $opt_force; our $opt_reorder= 0; our $opt_enable_disabled; -our $opt_report_features; our $opt_mem= $ENV{'MTR_MEM'}; our $opt_gcov; @@ -656,7 +655,7 @@ sub command_line_setup () { # directory. And we install "/usr/share/mysql-test". Moving up one # more directory relative to "mysql-test" gives us a usable base # directory for RPM installs. - if ( ! $opt_source_dist and ! -d "$glob_basedir/bin" ) + if ( ! $source_dist and ! -d "$glob_basedir/bin" ) { $glob_basedir= dirname($glob_basedir); } From 55aa6e04bd7a7b8b5b86fa15efe9d253a9650eeb Mon Sep 17 00:00:00 2001 From: "ramil/ram@mysql.com/myoffice.izhnet.ru" <> Date: Mon, 27 Nov 2006 13:24:24 +0400 Subject: [PATCH 084/131] Fix for bug #21587: FLUSH TABLES causes server crash when used with HANDLER statements Problems (appear only under some circumstances): 1. we get a reference to a deleted table searching in the thd->handler_tables_hash in the mysql_ha_read(). 2. DBUG_ASSERT(table->file->inited == handler::NONE); assert fails in the close_thread_table(). Fix: end open index scans and table scans and remove references to the tables from the handler tables hash. After this preparation it is safe to close the tables. The close can no longer fail on open index/table scans and the closed table will not be used again by handler functions. --- sql/mysql_priv.h | 1 + sql/sql_base.cc | 10 +++++++++- sql/sql_handler.cc | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index cd6c2a73ccc..c353cee356a 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -941,6 +941,7 @@ bool mysql_ha_read(THD *, TABLE_LIST *,enum enum_ha_read_modes,char *, List *,enum ha_rkey_function,Item *,ha_rows,ha_rows); int mysql_ha_flush(THD *thd, TABLE_LIST *tables, uint mode_flags, bool is_locked); +void mysql_ha_mark_tables_for_reopen(THD *thd, TABLE *table); /* mysql_ha_flush mode_flags bits */ #define MYSQL_HA_CLOSE_FINAL 0x00 #define MYSQL_HA_REOPEN_ON_USAGE 0x01 diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 0f6715fc078..053f6fcb845 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -519,7 +519,15 @@ void close_thread_tables(THD *thd, bool lock_in_use, bool skip_derived) DBUG_PRINT("info", ("thd->open_tables: %p", thd->open_tables)); - found_old_table= 0; + + /* + End open index scans and table scans and remove references to the tables + from the handler tables hash. After this preparation it is safe to close + the tables. + */ + mysql_ha_mark_tables_for_reopen(thd, thd->open_tables); + + found_old_table= 0; while (thd->open_tables) found_old_table|=close_thread_table(thd, &thd->open_tables); thd->some_tables_deleted=0; diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index 0193d4d5355..77c7bf137fb 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -748,3 +748,41 @@ static int mysql_ha_flush_table(THD *thd, TABLE **table_ptr, uint mode_flags) DBUG_RETURN(0); } + + +/* + Mark tables for reopen. + + SYNOPSIS + mysql_ha_mark_tables_for_reopen() + thd Thread identifier. + table Table list to mark for reopen. + + DESCRIPTION + For each table found in the handler hash mark it as closed + (ready for reopen) and end all index/table scans. + + NOTE + The caller must lock LOCK_open. +*/ + +void mysql_ha_mark_tables_for_reopen(THD *thd, TABLE *table) +{ + DBUG_ENTER("mysql_ha_mark_tables_for_reopen"); + + safe_mutex_assert_owner(&LOCK_open); + for (; table; table= table->next) + { + TABLE_LIST *hash_tables; + if ((hash_tables= (TABLE_LIST*) hash_search(&thd->handler_tables_hash, + (byte*) table->alias, + strlen(table->alias) + 1))) + { + /* Mark table as ready for reopen. */ + hash_tables->table= NULL; + /* End open index/table scans. */ + table->file->ha_index_or_rnd_end(); + } + } + DBUG_VOID_RETURN; +} From a45b64b1342f7b002439c85b0864be512172b30a Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 27 Nov 2006 14:02:14 +0100 Subject: [PATCH 085/131] Move misplaced #endif --- sql/ha_ndbcluster.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 76999896e3c..331f6cf016c 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -7197,6 +7197,8 @@ static void print_ndbcluster_open_tables() DBUG_UNLOCK_FILE; } +#endif + #define dbug_print_open_tables() \ DBUG_EXECUTE("info", \ @@ -7208,7 +7210,6 @@ static void print_ndbcluster_open_tables() print_share((t), (s));); \ DBUG_UNLOCK_FILE; -#endif #ifdef HAVE_NDB_BINLOG /* From 545fac620fceccd5f7e9a100e96925aa4441f1ca Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 27 Nov 2006 15:00:08 +0100 Subject: [PATCH 086/131] Add mysys/my_getpagesize as source file foir mysql_upgrade Don't link mysql_upgrade with mysys --- client/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index b2b734a48f4..c3dd57f098b 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -65,8 +65,8 @@ TARGET_LINK_LIBRARIES(mysqldump mysqlclient mysys dbug yassl taocrypt zlib wsock ADD_EXECUTABLE(mysqlimport mysqlimport.c) TARGET_LINK_LIBRARIES(mysqlimport mysqlclient mysys dbug yassl taocrypt zlib wsock32) -ADD_EXECUTABLE(mysql_upgrade mysql_upgrade.c) -TARGET_LINK_LIBRARIES(mysql_upgrade mysqlclient mysys dbug yassl taocrypt zlib wsock32) +ADD_EXECUTABLE(mysql_upgrade mysql_upgrade.c ../mysys/my_getpagesize.c) +TARGET_LINK_LIBRARIES(mysql_upgrade mysqlclient dbug yassl taocrypt zlib wsock32) ADD_EXECUTABLE(mysqlshow mysqlshow.c) TARGET_LINK_LIBRARIES(mysqlshow mysqlclient mysys dbug yassl taocrypt zlib wsock32) From e09616e1acb53a676e82a4a9924ff4164eb27b3f Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 27 Nov 2006 16:04:52 +0100 Subject: [PATCH 087/131] Add my_getpagesize.c as source for mysys --- mysys/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt index 7b362b4c1f9..ddbb5f5c328 100644 --- a/mysys/CMakeLists.txt +++ b/mysys/CMakeLists.txt @@ -26,4 +26,4 @@ ADD_LIBRARY(mysys array.c charset-def.c charset.c checksum.c default.c default_m my_static.c my_symlink.c my_symlink2.c my_sync.c my_thr_init.c my_wincond.c my_windac.c my_winsem.c my_winthread.c my_write.c ptr_cmp.c queues.c rijndael.c safemalloc.c sha1.c string.c thr_alarm.c thr_lock.c thr_mutex.c - thr_rwlock.c tree.c typelib.c my_vle.c base64.c my_memmem.c) + thr_rwlock.c tree.c typelib.c my_vle.c base64.c my_memmem.c my_getpagesize.c) From 76b8b450d6bb073f7d84b36155babbed6f0d2bde Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 27 Nov 2006 19:56:04 +0100 Subject: [PATCH 088/131] Fix for rpl000015 that fails if $MYSQL_TCP_PORT is set. The default value for master_port after a "change master" will be set to the compiled in default value i.e not always the same as what the master report as it's port number. --- mysql-test/mysql-test-run.pl | 1 + mysql-test/r/rpl000015.result | 2 +- mysql-test/t/rpl000015.test | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index c9dcd75415c..ecd2bc19a86 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1668,6 +1668,7 @@ sub environment_setup () { $ENV{'SLAVE_MYPORT1'}= $slave->[1]->{'port'}; $ENV{'SLAVE_MYPORT2'}= $slave->[2]->{'port'}; $ENV{'MYSQL_TCP_PORT'}= $mysqld_variables{'port'}; + $ENV{'DEFAULT_MASTER_PORT'}= $mysqld_variables{'master-port'}; $ENV{'IM_PATH_SOCK'}= $instance_manager->{path_sock}; $ENV{'IM_USERNAME'}= $instance_manager->{admin_login}; diff --git a/mysql-test/r/rpl000015.result b/mysql-test/r/rpl000015.result index e33201ced93..080ef436a2e 100644 --- a/mysql-test/r/rpl000015.result +++ b/mysql-test/r/rpl000015.result @@ -8,7 +8,7 @@ Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File change master to master_host='127.0.0.1'; show slave status; Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master -# 127.0.0.1 test MASTER_PORT 7 4 # # No No 0 0 0 # None 0 No # +# 127.0.0.1 test DEFAULT_MASTER_PORT 7 4 # # No No 0 0 0 # None 0 No # change master to master_host='127.0.0.1',master_user='root', master_password='',master_port=MASTER_PORT; show slave status; diff --git a/mysql-test/t/rpl000015.test b/mysql-test/t/rpl000015.test index df4bf6f977b..d61b7120fa1 100644 --- a/mysql-test/t/rpl000015.test +++ b/mysql-test/t/rpl000015.test @@ -12,7 +12,7 @@ show slave status; change master to master_host='127.0.0.1'; # The following needs to be cleaned up when change master is fixed ---replace_result $MYSQL_TCP_PORT MASTER_PORT +--replace_result $DEFAULT_MASTER_PORT DEFAULT_MASTER_PORT --replace_column 1 # 8 # 9 # 23 # 33 # show slave status; --replace_result $MASTER_MYPORT MASTER_PORT From 37d1d86d9fb3e0c53a2e1e047d7be7dd6c84ec35 Mon Sep 17 00:00:00 2001 From: "tsmith/tim@siva.hindu.god" <> Date: Mon, 27 Nov 2006 15:01:14 -0700 Subject: [PATCH 089/131] raise max_connections default to avoid conflicts with apache max_childs settings (Bug #23883) --- sql/mysqld.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 16bfbcbc565..a5c465d2408 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -5943,9 +5943,11 @@ The minimum value for this variable is 4096.", "If there is more than this number of interrupted connections from a host this host will be blocked from further connections.", (gptr*) &max_connect_errors, (gptr*) &max_connect_errors, 0, GET_ULONG, REQUIRED_ARG, MAX_CONNECT_ERRORS, 1, ~0L, 0, 1, 0}, + // Default max_connections of 151 is larger than Apache's default max + // children, to avoid "too many connections" error in a common setup {"max_connections", OPT_MAX_CONNECTIONS, "The number of simultaneous clients allowed.", (gptr*) &max_connections, - (gptr*) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 100, 1, 16384, 0, 1, + (gptr*) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 151, 1, 16384, 0, 1, 0}, {"max_delayed_threads", OPT_MAX_DELAYED_THREADS, "Don't start more than this number of threads to handle INSERT DELAYED statements. If set to zero, which means INSERT DELAYED is not used.", From ee4a5b865fe13bb493c232d9eb57ee89132487b5 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 28 Nov 2006 10:31:07 +0100 Subject: [PATCH 090/131] Backport of patch for bug#24471 mysql-test-run.pl: Removed "use diagnostics", reduces Perl speed significantly. Can be enabled with "perl -Mdiagnostics mysql-test-run.pl". mtr_report.pl: Don't try output "skipped" comment if there is none (bug#24471) --- mysql-test/lib/mtr_report.pl | 6 +++++- mysql-test/mysql-test-run.pl | 1 - 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/mysql-test/lib/mtr_report.pl b/mysql-test/lib/mtr_report.pl index 758e98984b8..a2c16e1941a 100644 --- a/mysql-test/lib/mtr_report.pl +++ b/mysql-test/lib/mtr_report.pl @@ -94,10 +94,14 @@ sub mtr_report_test_skipped ($) { { print "[ disabled ] $tinfo->{'comment'}\n"; } - else + elsif ( $tinfo->{'comment'} ) { print "[ skipped ] $tinfo->{'comment'}\n"; } + else + { + print "[ skipped ]\n"; + } } sub mtr_report_tests_not_skipped_though_disabled ($) { diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 5fe95fc3c6c..ab347157168 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -66,7 +66,6 @@ use IO::Socket::INET; use Data::Dumper; use strict; use warnings; -use diagnostics; select(STDOUT); $| = 1; # Automatically flush STDOUT From 26be89ed478f269b1ee6f8db391921b0ccb65400 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 28 Nov 2006 11:43:56 +0100 Subject: [PATCH 091/131] Fix problem with mysqladmin logging to var/log before var has been created And if var/ has been created, it will be recreated later so the logs will be lost --- mysql-test/lib/mtr_process.pl | 5 ++--- mysql-test/mysql-test-run.pl | 13 ------------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl index 9d0c1f601ba..37a82177f46 100644 --- a/mysql-test/lib/mtr_process.pl +++ b/mysql-test/lib/mtr_process.pl @@ -708,7 +708,7 @@ sub mtr_wait_blocking($) { } } -# Start "mysqladmin shutdown" for a specific mysqld +# Start "mysqladmin " for a specific mysqld sub mtr_mysqladmin_start($$$) { my $srv= shift; my $command= shift; @@ -738,9 +738,8 @@ sub mtr_mysqladmin_start($$$) { # Shutdown time must be high as slave may be in reconnect mtr_add_arg($args, "--shutdown_timeout=$adm_shutdown_tmo"); mtr_add_arg($args, "$command"); - my $path_mysqladmin_log= "$::opt_vardir/log/mysqladmin.log"; my $pid= mtr_spawn($::exe_mysqladmin, $args, - "", $path_mysqladmin_log, $path_mysqladmin_log, "", + "", "", "", "", { append_log_file => 1 }); mtr_verbose("mtr_mysqladmin_start, pid: $pid"); return $pid; diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index ab347157168..840a3865625 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1915,19 +1915,6 @@ sub kill_running_servers () { # This is different from terminating processes we have # started from this run of the script, this is terminating # leftovers from previous runs. - - if ( ! -d $opt_vardir ) - { - if ( -l $opt_vardir and ! -d readlink($opt_vardir) ) - { - mtr_report("Removing $opt_vardir symlink without destination"); - unlink($opt_vardir); - } - # The "var" dir does not exist already - # the processes that mtr_kill_leftovers start will write - # their log files to var/log so it should be created - mkpath("$opt_vardir/log"); - } mtr_kill_leftovers(); } } From d1ed2e21b8855128a0cf705dc606f3b818f9a07f Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 28 Nov 2006 12:33:36 +0100 Subject: [PATCH 092/131] Backport of patch for bug#24471 --- mysql-test/lib/mtr_report.pl | 6 +++++- mysql-test/mysql-test-run.pl | 1 - 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/mysql-test/lib/mtr_report.pl b/mysql-test/lib/mtr_report.pl index 8d7de9d1a4b..d0e836c1a90 100644 --- a/mysql-test/lib/mtr_report.pl +++ b/mysql-test/lib/mtr_report.pl @@ -89,10 +89,14 @@ sub mtr_report_test_skipped ($) { { print "[ disabled ] $tinfo->{'comment'}\n"; } - else + elsif ( $tinfo->{'comment'} ) { print "[ skipped ] $tinfo->{'comment'}\n"; } + else + { + print "[ skipped ]\n"; + } } sub mtr_report_tests_not_skipped_though_disabled ($) { diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 22dc49c5ebd..694ff4b712e 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -66,7 +66,6 @@ use IO::Socket::INET; use Data::Dumper; use strict; use warnings; -use diagnostics; select(STDOUT); $| = 1; # Automatically flush STDOUT From afe91a26c627608ea1fd4e9fc6d532d6712d6d36 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 28 Nov 2006 12:36:26 +0100 Subject: [PATCH 093/131] Fix problem with mysqladmin logging to var/log before var has been created And if var/ has been created, it will be recreated later so the logs from "mtr_kill_leftovers" will be lost anyway --- mysql-test/lib/mtr_process.pl | 5 ++--- mysql-test/mysql-test-run.pl | 13 ------------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl index 9d0c1f601ba..37a82177f46 100644 --- a/mysql-test/lib/mtr_process.pl +++ b/mysql-test/lib/mtr_process.pl @@ -708,7 +708,7 @@ sub mtr_wait_blocking($) { } } -# Start "mysqladmin shutdown" for a specific mysqld +# Start "mysqladmin " for a specific mysqld sub mtr_mysqladmin_start($$$) { my $srv= shift; my $command= shift; @@ -738,9 +738,8 @@ sub mtr_mysqladmin_start($$$) { # Shutdown time must be high as slave may be in reconnect mtr_add_arg($args, "--shutdown_timeout=$adm_shutdown_tmo"); mtr_add_arg($args, "$command"); - my $path_mysqladmin_log= "$::opt_vardir/log/mysqladmin.log"; my $pid= mtr_spawn($::exe_mysqladmin, $args, - "", $path_mysqladmin_log, $path_mysqladmin_log, "", + "", "", "", "", { append_log_file => 1 }); mtr_verbose("mtr_mysqladmin_start, pid: $pid"); return $pid; diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 694ff4b712e..d06a6a0a6a0 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1887,19 +1887,6 @@ sub kill_running_servers () { # This is different from terminating processes we have # started from this run of the script, this is terminating # leftovers from previous runs. - - if ( ! -d $opt_vardir ) - { - if ( -l $opt_vardir and ! -d readlink($opt_vardir) ) - { - mtr_report("Removing $opt_vardir symlink without destination"); - unlink($opt_vardir); - } - # The "var" dir does not exist already - # the processes that mtr_kill_leftovers start will write - # their log files to var/log so it should be created - mkpath("$opt_vardir/log"); - } mtr_kill_leftovers(); } } From 896adf77aeb9584900ac4d803e638121c82c2f45 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 28 Nov 2006 13:57:07 +0100 Subject: [PATCH 094/131] Bug#24354 option "--extern" of mysql-test-run.pl does not work anymore - Better control of when to create/remove vardir --- mysql-test/mysql-test-run.pl | 87 ++++++++++++++++++++++++++++-------- 1 file changed, 69 insertions(+), 18 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index d06a6a0a6a0..df9919a2f3f 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -312,7 +312,8 @@ sub datadir_setup (); sub executable_setup (); sub environment_setup (); sub kill_running_servers (); -sub cleanup_stale_files (); +sub remove_stale_vardir (); +sub setup_vardir (); sub check_ssl_support ($); sub check_running_as_root(); sub check_ndbcluster_support ($); @@ -1168,6 +1169,7 @@ sub command_line_setup () { # Setup master->[0] with the settings for the extern server $master->[0]->{'path_sock'}= $opt_socket if $opt_socket; + mtr_report("Using extern server at '$master->[0]->{path_sock}'"); } else { @@ -1891,12 +1893,24 @@ sub kill_running_servers () { } } -sub cleanup_stale_files () { +sub created_by_mem_filename(){ + return "$glob_mysql_test_dir/var/created_by_mem"; +} - my $created_by_mem_file= "$glob_mysql_test_dir/var/created_by_mem"; + +# +# Remove var and any directories in var/ created by previous +# tests +# +sub remove_stale_vardir () { mtr_report("Removing Stale Files"); + # Safety! + mtr_error("No, don't remove the vardir when running with --extern") + if $opt_extern; + + mtr_verbose("opt_vardir: $opt_vardir"); if ( $opt_vardir eq $default_vardir ) { # @@ -1905,29 +1919,37 @@ sub cleanup_stale_files () { if ( -l $opt_vardir) { # var is a symlink - if (-f $created_by_mem_file) + if (-f created_by_mem_filename() ) { # Remove the directory which the link points at + mtr_verbose("Removing " . readlink($opt_vardir)); rmtree(readlink($opt_vardir)); # Remove the entire "var" dir + mtr_verbose("Removing $opt_vardir/"); rmtree("$opt_vardir/"); # Remove the "var" symlink + mtr_verbose("unlink($opt_vardir)"); unlink($opt_vardir); } else { # Some users creates a soft link in mysql-test/var to another area - # - allow it + # - allow it, but remove all files in it + mtr_report("WARNING: Using the 'mysql-test/var' symlink"); - rmtree("$opt_vardir/log"); - rmtree("$opt_vardir/ndbcluster-$opt_ndbcluster_port"); - rmtree("$opt_vardir/run"); - rmtree("$opt_vardir/tmp"); + + my $dir= shift; + foreach my $bin ( glob("$opt_vardir/*") ) + { + mtr_verbose("Removing bin $bin"); + rmtree($bin); + } } } else { # Remove the entire "var" dir + mtr_verbose("Removing $opt_vardir/"); rmtree("$opt_vardir/"); } } @@ -1939,21 +1961,33 @@ sub cleanup_stale_files () { # Remove the var/ dir in mysql-test dir if any # this could be an old symlink that shouldn't be there + mtr_verbose("Removing $default_vardir"); rmtree($default_vardir); # Remove the "var" dir + mtr_verbose("Removing $opt_vardir/"); rmtree("$opt_vardir/"); } +} + +# +# Create var and the directories needed in var +# +sub setup_vardir() { + mtr_report("Creating Directories"); if ( $opt_mem ) { # Runinng with var as a link to some "memory" location, normally tmpfs - rmtree($opt_mem); + mtr_verbose("Creating $opt_mem"); mkpath($opt_mem); - mtr_report("Creating symlink from $opt_vardir to $opt_mem"); + + mtr_report("Symlinking 'var' to '$opt_mem'"); symlink($opt_mem, $opt_vardir); + # Put a small file to recognize this dir was created by --mem - mtr_tofile($created_by_mem_file, $opt_mem); + mtr_verbose("Creating " . created_by_mem_filename()); + mtr_tofile(created_by_mem_filename(), $opt_mem); } mkpath("$opt_vardir/log"); @@ -1961,10 +1995,9 @@ sub cleanup_stale_files () { mkpath("$opt_vardir/tmp"); mkpath($opt_tmpdir) if $opt_tmpdir ne "$opt_vardir/tmp"; - # Remove old and create new data dirs + # Create new data dirs foreach my $data_dir (@data_dir_lst) { - rmtree("$data_dir"); mkpath("$data_dir/mysql"); mkpath("$data_dir/test"); } @@ -2503,21 +2536,39 @@ sub initialize_servers () { datadir_setup(); - if ( ! $opt_extern ) + if ( $opt_extern ) + { + # Running against an already started server, if the specified + # vardir does not already exist it should be created + if ( ! -d $opt_vardir ) + { + mtr_report("Creating '$opt_vardir'"); + setup_vardir(); + } + else + { + mtr_report("No need to create '$opt_vardir' it already exists"); + } + } + else { kill_running_servers(); if ( ! $opt_start_dirty ) { - cleanup_stale_files(); + remove_stale_vardir(); + setup_vardir(); + mysql_install_db(); if ( $opt_force ) { + # Save a snapshot of the freshly installed db + # to make it possible to restore to a known point in time save_installed_db(); } } - check_running_as_root(); } + check_running_as_root(); } sub mysql_install_db () { @@ -4663,7 +4714,7 @@ Options that pass on options Options to run test on running server - extern Use running server for tests FIXME DANGEROUS + extern Use running server for tests ndb-connectstring=STR Use running cluster, and connect using STR ndb-connectstring-slave=STR Use running slave cluster, and connect using STR user=USER User for connection to extern server From fc1f9bfedee3ff0c7d674798a5179e562b41cbb5 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 28 Nov 2006 15:15:01 +0100 Subject: [PATCH 095/131] Rename function datadir_setup to datadir_list_setup to avoid mixup with the function where vardir's are created --- mysql-test/mysql-test-run.pl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index df9919a2f3f..3305563296e 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -308,7 +308,7 @@ our %mysqld_variables; sub main (); sub initial_setup (); sub command_line_setup (); -sub datadir_setup (); +sub datadir_list_setup (); sub executable_setup (); sub environment_setup (); sub kill_running_servers (); @@ -1185,7 +1185,7 @@ sub command_line_setup () { $path_snapshot= "$opt_tmpdir/snapshot_$opt_master_myport/"; } -sub datadir_setup () { +sub datadir_list_setup () { # Make a list of all data_dirs @data_dir_lst = ( @@ -2534,7 +2534,7 @@ sub run_suite () { sub initialize_servers () { - datadir_setup(); + datadir_list_setup(); if ( $opt_extern ) { From bccf1442605189820ca44f6ea843a2d7facdf663 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 28 Nov 2006 15:39:23 +0100 Subject: [PATCH 096/131] No need to have a "created_by_mem" file, just read the link and if that is same as opt_mem it can be removed --- mysql-test/mysql-test-run.pl | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 3305563296e..705b6e76578 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1893,10 +1893,6 @@ sub kill_running_servers () { } } -sub created_by_mem_filename(){ - return "$glob_mysql_test_dir/var/created_by_mem"; -} - # # Remove var and any directories in var/ created by previous @@ -1919,14 +1915,16 @@ sub remove_stale_vardir () { if ( -l $opt_vardir) { # var is a symlink - if (-f created_by_mem_filename() ) + if ( readlink($opt_vardir) eq $opt_mem ) { # Remove the directory which the link points at mtr_verbose("Removing " . readlink($opt_vardir)); rmtree(readlink($opt_vardir)); + # Remove the entire "var" dir mtr_verbose("Removing $opt_vardir/"); rmtree("$opt_vardir/"); + # Remove the "var" symlink mtr_verbose("unlink($opt_vardir)"); unlink($opt_vardir); @@ -1984,10 +1982,6 @@ sub setup_vardir() { mtr_report("Symlinking 'var' to '$opt_mem'"); symlink($opt_mem, $opt_vardir); - - # Put a small file to recognize this dir was created by --mem - mtr_verbose("Creating " . created_by_mem_filename()); - mtr_tofile(created_by_mem_filename(), $opt_mem); } mkpath("$opt_vardir/log"); From acf75687fb7b9861c0c63a119d2be3dd5ba37105 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 28 Nov 2006 15:51:52 +0100 Subject: [PATCH 097/131] Some more checks to avoid removing unwanted directories. --- mysql-test/mysql-test-run.pl | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 705b6e76578..34fbf9f1b66 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1974,14 +1974,28 @@ sub remove_stale_vardir () { sub setup_vardir() { mtr_report("Creating Directories"); - if ( $opt_mem ) + if ( $opt_vardir eq $default_vardir ) { - # Runinng with var as a link to some "memory" location, normally tmpfs - mtr_verbose("Creating $opt_mem"); - mkpath($opt_mem); + # + # Running with "var" in mysql-test dir + # + if ( -l $opt_vardir ) + { + # it's a symlink - mtr_report("Symlinking 'var' to '$opt_mem'"); - symlink($opt_mem, $opt_vardir); + # Make sure the directory where it points exist + mtr_error("The destination for symlink $opt_vardir does not exist") + if ! -d readlink($opt_vardir); + } + elsif ( $opt_mem ) + { + # Runinng with "var" as a link to some "memory" location, normally tmpfs + mtr_verbose("Creating $opt_mem"); + mkpath($opt_mem); + + mtr_report("Symlinking 'var' to '$opt_mem'"); + symlink($opt_mem, $opt_vardir); + } } mkpath("$opt_vardir/log"); From 294cb8432ff01b23f7aa316de462ccaf10ecf921 Mon Sep 17 00:00:00 2001 From: "thek@kpdesk.mysql.com" <> Date: Tue, 28 Nov 2006 16:03:53 +0100 Subject: [PATCH 098/131] Bug#22043 MySQL don't add "USE " before "DROP PROCEDURE EXISTS" - CREATE PROCEDURE stores database name based on query context instead of 'current database' as set by 'USE' according to manual. The bug reporter interpret the filtering statements as bug for DROP PROCEDURE based on this behavior. - Removed the code which changes db context. - Added code to check that a valid db was supplied. --- mysql-test/r/rpl_sp.result | 25 +++++++++++++++++++++++++ mysql-test/t/rpl_sp.test | 23 +++++++++++++++++++++++ sql/sp.cc | 9 --------- sql/sql_parse.cc | 24 ++++++++++++++++++++++++ 4 files changed, 72 insertions(+), 9 deletions(-) diff --git a/mysql-test/r/rpl_sp.result b/mysql-test/r/rpl_sp.result index 7b096b27733..d6f9880de17 100644 --- a/mysql-test/r/rpl_sp.result +++ b/mysql-test/r/rpl_sp.result @@ -465,3 +465,28 @@ RETURN 0 DROP PROCEDURE p1; DROP FUNCTION f1; drop table t1; +drop database if exists mysqltest; +drop database if exists mysqltest2; +create database mysqltest; +create database mysqltest2; +use mysqltest2; +create table t ( t integer ); +create procedure mysqltest.test() begin end; +insert into t values ( 1 ); +show binlog events in 'master-bin.000001' from 8186; +Log_name Pos Event_type Server_id End_log_pos Info +master-bin.000001 8186 Query 1 8317 use `test`; CREATE DEFINER=`root`@`localhost` FUNCTION f1() RETURNS INT RETURN 0 +master-bin.000001 8317 Query 1 8397 use `test`; DROP PROCEDURE p1 +master-bin.000001 8397 Query 1 8476 use `test`; DROP FUNCTION f1 +master-bin.000001 8476 Query 1 8552 use `test`; drop table t1 +master-bin.000001 8552 Query 1 8653 drop database if exists mysqltest +master-bin.000001 8653 Query 1 8756 drop database if exists mysqltest2 +master-bin.000001 8756 Query 1 8849 create database mysqltest +master-bin.000001 8849 Query 1 8944 create database mysqltest2 +master-bin.000001 8944 Query 1 9041 use `mysqltest2`; create table t ( t integer ) +master-bin.000001 9041 Query 1 9180 use `mysqltest2`; CREATE DEFINER=`root`@`localhost` procedure mysqltest.test() begin end +master-bin.000001 9180 Query 1 9275 use `mysqltest2`; insert into t values ( 1 ) +create procedure `\\`.test() begin end; +ERROR 42000: Incorrect database name '\\' +drop database mysqltest; +drop database mysqltest2; diff --git a/mysql-test/t/rpl_sp.test b/mysql-test/t/rpl_sp.test index 7479794eded..b7a9036908c 100644 --- a/mysql-test/t/rpl_sp.test +++ b/mysql-test/t/rpl_sp.test @@ -519,3 +519,26 @@ DROP FUNCTION f1; connection master; drop table t1; sync_slave_with_master; + +# +# Bug22043: MySQL don't add "USE " before "DROP PROCEDURE IF EXISTS" +# +connection master; +--disable_warnings +drop database if exists mysqltest; +drop database if exists mysqltest2; +--enable_warnings +create database mysqltest; +create database mysqltest2; +use mysqltest2; +create table t ( t integer ); +create procedure mysqltest.test() begin end; +insert into t values ( 1 ); +show binlog events in 'master-bin.000001' from 8186; +--error ER_WRONG_DB_NAME +create procedure `\\`.test() begin end; +# Clean up +drop database mysqltest; +drop database mysqltest2; + + diff --git a/sql/sp.cc b/sql/sp.cc index 283f43f55b2..f7c086061d3 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -494,17 +494,10 @@ db_create_routine(THD *thd, int type, sp_head *sp) char definer[USER_HOST_BUFF_SIZE]; char old_db_buf[NAME_LEN+1]; LEX_STRING old_db= { old_db_buf, sizeof(old_db_buf) }; - bool dbchanged; DBUG_ENTER("db_create_routine"); DBUG_PRINT("enter", ("type: %d name: %.*s",type,sp->m_name.length, sp->m_name.str)); - if ((ret= sp_use_new_db(thd, sp->m_db, &old_db, 0, &dbchanged))) - { - ret= SP_NO_DB_ERROR; - goto done; - } - if (!(table= open_proc_table_for_update(thd))) ret= SP_OPEN_TABLE_FAILED; else @@ -629,8 +622,6 @@ db_create_routine(THD *thd, int type, sp_head *sp) done: close_thread_tables(thd); - if (dbchanged) - (void) mysql_change_db(thd, old_db.str, 1); DBUG_RETURN(ret); } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 3a107c2296c..2feaebdde25 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4226,6 +4226,30 @@ end_with_restore_list: DBUG_ASSERT(lex->sphead != 0); DBUG_ASSERT(lex->sphead->m_db.str); /* Must be initialized in the parser */ + /* + Verify that the database name is allowed, optionally + lowercase it. + */ + if (check_db_name(lex->sphead->m_db.str)) + { + my_error(ER_WRONG_DB_NAME, MYF(0), lex->sphead->m_db.str); + delete lex->sphead; + lex->sphead= 0; + goto error; + } + + /* + Check that a database with this name + exists. + */ + if (check_db_dir_existence(lex->sphead->m_db.str)) + { + my_error(ER_BAD_DB_ERROR, MYF(0), lex->sphead->m_db.str); + delete lex->sphead; + lex->sphead= 0; + goto error; + } + if (check_access(thd, CREATE_PROC_ACL, lex->sphead->m_db.str, 0, 0, 0, is_schema_db(lex->sphead->m_db.str))) { From e5ff9ebcd8cde1c935199dc7a9dbcf611129289d Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 28 Nov 2006 16:22:59 +0100 Subject: [PATCH 099/131] Add warnings and more error checks in the creation of vardirs --- mysql-test/mysql-test-run.pl | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 34fbf9f1b66..84f884b3b4d 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1915,20 +1915,25 @@ sub remove_stale_vardir () { if ( -l $opt_vardir) { # var is a symlink - if ( readlink($opt_vardir) eq $opt_mem ) + + if ( $opt_mem and readlink($opt_vardir) eq $opt_mem ) { # Remove the directory which the link points at mtr_verbose("Removing " . readlink($opt_vardir)); rmtree(readlink($opt_vardir)); - # Remove the entire "var" dir - mtr_verbose("Removing $opt_vardir/"); - rmtree("$opt_vardir/"); - # Remove the "var" symlink mtr_verbose("unlink($opt_vardir)"); unlink($opt_vardir); } + elsif ( $opt_mem ) + { + # Just remove the "var" symlink + mtr_report("WARNING: Removing '$opt_vardir' symlink it's wrong"); + + mtr_verbose("unlink($opt_vardir)"); + unlink($opt_vardir); + } else { # Some users creates a soft link in mysql-test/var to another area @@ -1936,6 +1941,10 @@ sub remove_stale_vardir () { mtr_report("WARNING: Using the 'mysql-test/var' symlink"); + # Make sure the directory where it points exist + mtr_error("The destination for symlink $opt_vardir does not exist") + if ! -d readlink($opt_vardir); + my $dir= shift; foreach my $bin ( glob("$opt_vardir/*") ) { From ac2ef7dd5aee2e0dad356f614dbbe116057f4afd Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 28 Nov 2006 16:24:31 +0100 Subject: [PATCH 100/131] Remove the check for writable var dir, it has to be done later on --- mysql-test/mysql-test-run.pl | 7 ------- 1 file changed, 7 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index e8ebb812b5c..ce910b8879c 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -808,13 +808,6 @@ sub command_line_setup () { $opt_vardir= "$glob_mysql_test_dir/$opt_vardir"; } - # Ensure a proper error message - mkpath("$opt_vardir"); - unless ( -d $opt_vardir and -w $opt_vardir ) - { - mtr_error("Writable 'var' directory is needed, use the '--vardir' option"); - } - # -------------------------------------------------------------------------- # Set tmpdir # -------------------------------------------------------------------------- From d1d93f7412fb65208fe11c11d71cc1fc4b6d9710 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 28 Nov 2006 17:13:38 +0100 Subject: [PATCH 101/131] Fix spelling error reported by Paul --- sql/mysqld.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index a5c465d2408..47b6637720c 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2789,13 +2789,13 @@ static int init_common_variables(const char *conf_file_name, int argc, !(log_output_options & LOG_NONE)) sql_print_warning("Although a path was specified for the " "--log option, log tables are used. " - "To enable logging to file use the --log-output option."); + "To enable logging to files use the --log-output option."); if (opt_slow_log && opt_slow_logname && !(log_output_options & LOG_FILE) && !(log_output_options & LOG_NONE)) sql_print_warning("Although a path was specified for the " "--log-slow-queries option, log tables are used. " - "To enable logging to file use the --log-output option."); + "To enable logging to files use the --log-output option."); if (!opt_logname) opt_logname= make_default_log_name(buff, ".log"); From 100dd45ec45c7bf6394a1ea0cc2fc865400c4ae3 Mon Sep 17 00:00:00 2001 From: "andrey@example.com" <> Date: Tue, 28 Nov 2006 18:27:32 +0100 Subject: [PATCH 102/131] Fix for bug#24395: ALTER TABLE DISABLE KEYS doesn't work when modifying the table ENABLE|DISABLE KEYS combined with another ALTER TABLE option, different than RENAME TO did nothing. Also, if the table had disabled keys and was ALTER-ed then the end table was with enabled keys. Fixed by checking whether the table had disabled keys and enabling them in the copied table. --- myisam/mi_open.c | 21 +++++- mysql-test/r/alter_table.result | 121 ++++++++++++++++++++++++++++++++ mysql-test/t/alter_table.test | 97 +++++++++++++++++++++++++ sql/sql_table.cc | 73 +++++++++++++++++-- 4 files changed, 304 insertions(+), 8 deletions(-) diff --git a/myisam/mi_open.c b/myisam/mi_open.c index 4f298397615..db15f39c84a 100644 --- a/myisam/mi_open.c +++ b/myisam/mi_open.c @@ -1233,13 +1233,30 @@ int mi_enable_indexes(MI_INFO *info) RETURN 0 indexes are not disabled 1 all indexes are disabled - [2 non-unique indexes are disabled - NOT YET IMPLEMENTED] + 2 non-unique indexes are disabled */ int mi_indexes_are_disabled(MI_INFO *info) { MYISAM_SHARE *share= info->s; - return (! share->state.key_map && share->base.keys); + /* + No keys or all are enabled. keys is the number of keys. Left shifted + gives us only one bit set. When decreased by one, gives us all all bits + up to this one set and it gets unset. + */ + if (!share->base.keys || + (share->state.key_map == (ULL(1) << share->base.keys) - ULL(1))) + return 0; + + /* All are disabled */ + if (!share->state.key_map) + return 1; + + /* + We have keys. Some enabled, some disabled. + Don't check for any non-unique disabled but return directly 2 + */ + return 2; } diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result index eade19e85df..6c670af88a2 100644 --- a/mysql-test/r/alter_table.result +++ b/mysql-test/r/alter_table.result @@ -528,6 +528,127 @@ create table t1 ( a timestamp ); alter table t1 add unique ( a(1) ); ERROR HY000: Incorrect sub part key; the used key part isn't a string, the used length is longer than the key part, or the storage engine doesn't support unique sub keys drop table t1; +drop table if exists t1; +create table t1 (a int, key(a)); +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 1 a 1 a A NULL NULL NULL YES BTREE +"this used not to disable the index" +alter table t1 modify a int, disable keys; +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 1 a 1 a A NULL NULL NULL YES BTREE disabled +alter table t1 enable keys; +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 1 a 1 a A NULL NULL NULL YES BTREE +alter table t1 modify a bigint, disable keys; +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 1 a 1 a A NULL NULL NULL YES BTREE disabled +alter table t1 enable keys; +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 1 a 1 a A NULL NULL NULL YES BTREE +alter table t1 add b char(10), disable keys; +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 1 a 1 a A NULL NULL NULL YES BTREE disabled +alter table t1 add c decimal(10,2), enable keys; +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 1 a 1 a A NULL NULL NULL YES BTREE +"this however did" +alter table t1 disable keys; +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 1 a 1 a A NULL NULL NULL YES BTREE disabled +desc t1; +Field Type Null Key Default Extra +a bigint(20) YES MUL NULL +b char(10) YES NULL +c decimal(10,2) YES NULL +alter table t1 add d decimal(15,5); +"The key should still be disabled" +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 1 a 1 a A NULL NULL NULL YES BTREE disabled +drop table t1; +"Now will test with one unique index" +create table t1(a int, b char(10), unique(a)); +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 a 1 a A NULL NULL NULL YES BTREE +alter table t1 disable keys; +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 a 1 a A NULL NULL NULL YES BTREE +alter table t1 enable keys; +"If no copy on noop change, this won't touch the data file" +"Unique index, no change" +alter table t1 modify a int, disable keys; +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 a 1 a A NULL NULL NULL YES BTREE +"Change the type implying data copy" +"Unique index, no change" +alter table t1 modify a bigint, disable keys; +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 a 1 a A NULL NULL NULL YES BTREE +alter table t1 modify a bigint; +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 a 1 a A NULL NULL NULL YES BTREE +alter table t1 modify a int; +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 a 1 a A NULL NULL NULL YES BTREE +drop table t1; +"Now will test with one unique and one non-unique index" +create table t1(a int, b char(10), unique(a), key(b)); +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 a 1 a A NULL NULL NULL YES BTREE +t1 1 b 1 b A NULL NULL NULL YES BTREE +alter table t1 disable keys; +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 a 1 a A NULL NULL NULL YES BTREE +t1 1 b 1 b A NULL NULL NULL YES BTREE disabled +alter table t1 enable keys; +"If no copy on noop change, this won't touch the data file" +"The non-unique index will be disabled" +alter table t1 modify a int, disable keys; +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 a 1 a A NULL NULL NULL YES BTREE +t1 1 b 1 b A NULL NULL NULL YES BTREE disabled +alter table t1 enable keys; +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 a 1 a A NULL NULL NULL YES BTREE +t1 1 b 1 b A NULL NULL NULL YES BTREE +"Change the type implying data copy" +"The non-unique index will be disabled" +alter table t1 modify a bigint, disable keys; +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 a 1 a A NULL NULL NULL YES BTREE +t1 1 b 1 b A NULL NULL NULL YES BTREE disabled +"Change again the type, but leave the indexes as_is" +alter table t1 modify a int; +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 a 1 a A NULL NULL NULL YES BTREE +t1 1 b 1 b A NULL NULL NULL YES BTREE disabled +"Try the same. When data is no copied on similar tables, this is noop" +alter table t1 modify a int; +show indexes from t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 a 1 a A NULL NULL NULL YES BTREE +t1 1 b 1 b A NULL NULL NULL YES BTREE disabled +drop table t1; create database mysqltest1; create table t1 (c1 int); alter table t1 rename mysqltest1.t1; diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test index eba456982c8..f4624eda053 100644 --- a/mysql-test/t/alter_table.test +++ b/mysql-test/t/alter_table.test @@ -361,6 +361,103 @@ create table t1 ( a timestamp ); alter table t1 add unique ( a(1) ); drop table t1; +# +# Bug #24395: ALTER TABLE DISABLE KEYS doesn't work when modifying the table +# +# This problem happens if the data change is compatible. +# Changing to the same type is compatible for example. +# +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (a int, key(a)); +show indexes from t1; +--echo "this used not to disable the index" +alter table t1 modify a int, disable keys; +show indexes from t1; + +alter table t1 enable keys; +show indexes from t1; + +alter table t1 modify a bigint, disable keys; +show indexes from t1; + +alter table t1 enable keys; +show indexes from t1; + +alter table t1 add b char(10), disable keys; +show indexes from t1; + +alter table t1 add c decimal(10,2), enable keys; +show indexes from t1; + +--echo "this however did" +alter table t1 disable keys; +show indexes from t1; + +desc t1; + +alter table t1 add d decimal(15,5); +--echo "The key should still be disabled" +show indexes from t1; + +drop table t1; + +--echo "Now will test with one unique index" +create table t1(a int, b char(10), unique(a)); +show indexes from t1; +alter table t1 disable keys; +show indexes from t1; +alter table t1 enable keys; + +--echo "If no copy on noop change, this won't touch the data file" +--echo "Unique index, no change" +alter table t1 modify a int, disable keys; +show indexes from t1; + +--echo "Change the type implying data copy" +--echo "Unique index, no change" +alter table t1 modify a bigint, disable keys; +show indexes from t1; + +alter table t1 modify a bigint; +show indexes from t1; + +alter table t1 modify a int; +show indexes from t1; + +drop table t1; + +--echo "Now will test with one unique and one non-unique index" +create table t1(a int, b char(10), unique(a), key(b)); +show indexes from t1; +alter table t1 disable keys; +show indexes from t1; +alter table t1 enable keys; + + +--echo "If no copy on noop change, this won't touch the data file" +--echo "The non-unique index will be disabled" +alter table t1 modify a int, disable keys; +show indexes from t1; +alter table t1 enable keys; +show indexes from t1; + +--echo "Change the type implying data copy" +--echo "The non-unique index will be disabled" +alter table t1 modify a bigint, disable keys; +show indexes from t1; + +--echo "Change again the type, but leave the indexes as_is" +alter table t1 modify a int; +show indexes from t1; +--echo "Try the same. When data is no copied on similar tables, this is noop" +alter table t1 modify a int; +show indexes from t1; + +drop table t1; + + # # Bug#11493 - Alter table rename to default database does not work without # db name qualifying diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 256b9281e9f..f82dd627101 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -34,11 +34,12 @@ const char *primary_key_name="PRIMARY"; static bool check_if_keyname_exists(const char *name,KEY *start, KEY *end); static char *make_unique_key_name(const char *field_name,KEY *start,KEY *end); static int copy_data_between_tables(TABLE *from,TABLE *to, - List &create, - enum enum_duplicates handle_duplicates, + List &create, + enum enum_duplicates handle_duplicates, bool ignore, - uint order_num, ORDER *order, - ha_rows *copied,ha_rows *deleted); + uint order_num, ORDER *order, + ha_rows *copied, ha_rows *deleted, + enum enum_enable_or_disable keys_onoff); /* @@ -2836,6 +2837,54 @@ int mysql_drop_indexes(THD *thd, TABLE_LIST *table_list, #endif /* NOT_USED */ +/* + Manages enabling/disabling of indexes for ALTER TABLE + + SYNOPSIS + alter_table_manage_keys() + table Target table + indexes_were_disabled Whether the indexes of the from table + were disabled + keys_onoff ENABLE | DISABLE | LEAVE_AS_IS + + RETURN VALUES + FALSE OK + TRUE Error +*/ + +static +bool alter_table_manage_keys(TABLE *table, int indexes_were_disabled, + enum enum_enable_or_disable keys_onoff) +{ + int error= 0; + DBUG_ENTER("alter_table_manage_keys"); + DBUG_PRINT("enter", ("table=%p were_disabled=%d on_off=%d", + table, indexes_were_disabled, keys_onoff)); + + switch (keys_onoff) { + case ENABLE: + error= table->file->enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE); + break; + case LEAVE_AS_IS: + if (!indexes_were_disabled) + break; + /* fall-through: disabled indexes */ + case DISABLE: + error= table->file->disable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE); + } + + if (error == HA_ERR_WRONG_COMMAND) + { + push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_NOTE, + ER_ILLEGAL_HA, ER(ER_ILLEGAL_HA), table->table_name); + error= 0; + } else if (error) + table->file->print_error(error, MYF(0)); + + DBUG_RETURN(error); +} + + /* Alter table */ @@ -3375,7 +3424,14 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, if (!new_table->is_view) error=copy_data_between_tables(table,new_table,create_list, handle_duplicates, ignore, - order_num, order, &copied, &deleted); + order_num, order, &copied, &deleted, + alter_info->keys_onoff); + /* + No need to have call to alter_table_manage_keys() in the else because + in 4.1 we always copy data, except for views. In 5.0 it could happen + that no data is copied and only frm is modified. Then we have to handle + alter_info->keys_onoff outside of copy_data_between_tables + */ thd->last_insert_id=next_insert_id; // Needed for correct log thd->count_cuted_fields= CHECK_FIELD_IGNORE; @@ -3598,7 +3654,8 @@ copy_data_between_tables(TABLE *from,TABLE *to, bool ignore, uint order_num, ORDER *order, ha_rows *copied, - ha_rows *deleted) + ha_rows *deleted, + enum enum_enable_or_disable keys_onoff) { int error; Copy_field *copy,*copy_end; @@ -3630,6 +3687,10 @@ copy_data_between_tables(TABLE *from,TABLE *to, if (to->file->external_lock(thd, F_WRLCK)) DBUG_RETURN(-1); + + /* We need external lock before we can disable/enable keys */ + alter_table_manage_keys(to, from->file->indexes_are_disabled(), keys_onoff); + from->file->info(HA_STATUS_VARIABLE); to->file->start_bulk_insert(from->file->records); From 45ea756c5fae0ffe6c2e5f32ad42ba956f37abec Mon Sep 17 00:00:00 2001 From: "cmiller@zippy.cornsilk.net" <> Date: Tue, 28 Nov 2006 13:08:41 -0500 Subject: [PATCH 103/131] Revert charset breakage. --- mysql-test/r/mysql.result | 14 +++++++------- mysql-test/t/mysql.test | 8 ++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/mysql-test/r/mysql.result b/mysql-test/r/mysql.result index cfcb3eaf334..3bba1944c52 100644 --- a/mysql-test/r/mysql.result +++ b/mysql-test/r/mysql.result @@ -61,16 +61,16 @@ database() test unlock tables; drop table t1; -ƒ\ -ƒ\ +ƒ\ +ƒ\ c_cp932 -ƒ\ -ƒ\ -ƒ\ +ƒ\ +ƒ\ +ƒ\ ソ ソ -ƒ\ -ƒ\ +ƒ\ +ƒ\ +----------------------+------------+--------+ | concat('>',col1,'<') | col2 | col3 | +----------------------+------------+--------+ diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test index 5fc0692c70e..6b99f5154aa 100644 --- a/mysql-test/t/mysql.test +++ b/mysql-test/t/mysql.test @@ -52,10 +52,10 @@ drop table t1; --exec $MYSQL --default-character-set=cp932 test -e "charset utf8;" # its usage to switch internally in mysql to requested charset ---exec $MYSQL --default-character-set=utf8 test -e "charset cp932; select 'ƒ\'; create table t1 (c_cp932 TEXT CHARACTER SET cp932); insert into t1 values('ƒ\'); select * from t1; drop table t1;" ---exec $MYSQL --default-character-set=utf8 test -e "charset cp932; select 'ƒ\'" ---exec $MYSQL --default-character-set=utf8 test -e "/*charset cp932 */; set character_set_client= cp932; select 'ƒ\'" ---exec $MYSQL --default-character-set=utf8 test -e "/*!\C cp932 */; set character_set_client= cp932; select 'ƒ\'" +--exec $MYSQL --default-character-set=utf8 test -e "charset cp932; select 'ƒ\'; create table t1 (c_cp932 TEXT CHARACTER SET cp932); insert into t1 values('ƒ\'); select * from t1; drop table t1;" +--exec $MYSQL --default-character-set=utf8 test -e "charset cp932; select 'ƒ\'" +--exec $MYSQL --default-character-set=utf8 test -e "/*charset cp932 */; set character_set_client= cp932; select 'ƒ\'" +--exec $MYSQL --default-character-set=utf8 test -e "/*!\C cp932 */; set character_set_client= cp932; select 'ƒ\'" # # Bug#16859 -- NULLs in columns must not truncate data as if a C-language "string". From a92c7700bbe0199f82765e168c7f017f708cd67c Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 28 Nov 2006 19:10:39 +0100 Subject: [PATCH 104/131] Only force mysqld to use log file up until 5.1.6 After that it will by default use log tables. That setting can be overruled by adding a -master.opt file like mysql_client_test has. --- mysql-test/mysql-test-run.pl | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 84f884b3b4d..74486fe81aa 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -3454,6 +3454,12 @@ sub mysqld_arguments ($$$$$) { mtr_add_arg($args, "%s--ndb-extra-logging", $prefix); } } + + 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'}); + } } if ( $type eq 'slave' ) @@ -3471,8 +3477,6 @@ sub mysqld_arguments ($$$$$) { mtr_add_arg($args, "%s--log-slave-updates", $prefix); } - mtr_add_arg($args, "%s--log=%s", $prefix, - $slave->[$idx]->{'path_mylog'}); mtr_add_arg($args, "%s--master-retry-count=10", $prefix); mtr_add_arg($args, "%s--pid-file=%s", $prefix, $slave->[$idx]->{'path_pid'}); @@ -3533,6 +3537,13 @@ sub mysqld_arguments ($$$$$) { mtr_add_arg($args, "%s--ndb-extra-logging", $prefix); } } + + 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'}); + } + } # end slave if ( $opt_debug ) @@ -3609,7 +3620,6 @@ sub mysqld_arguments ($$$$$) { elsif ( $type eq 'master' ) { mtr_add_arg($args, "%s--open-files-limit=1024", $prefix); - mtr_add_arg($args, "%s--log=%s", $prefix, $master->[0]->{'path_mylog'}); } return $args; From 0aa9ac852f8e9b7f45f5623e253846e44c5e06cf Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 28 Nov 2006 19:12:59 +0100 Subject: [PATCH 105/131] Tell mysqld where to put the log file --- mysql-test/t/mysql_client_test-master.opt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/t/mysql_client_test-master.opt b/mysql-test/t/mysql_client_test-master.opt index 3711946168d..2dfcc4a2fb9 100644 --- a/mysql-test/t/mysql_client_test-master.opt +++ b/mysql-test/t/mysql_client_test-master.opt @@ -1 +1 @@ ---log --log-output=FILE +--log=$MYSQLTEST_VARDIR/log/master.log --log-output=FILE From 961ae4ab2f17cf0dfcad5acbc2c2f34f619e11a2 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 28 Nov 2006 19:54:16 +0100 Subject: [PATCH 106/131] Create new function "run_testcase_mark_logs' and use it to mark start of testcase in all cuurently known log files --- mysql-test/mysql-test-run.pl | 47 +++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 74486fe81aa..aed1b2c318b 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -2952,26 +2952,15 @@ sub do_before_run_mysqltest($) unlink("$result_dir/$tname.log"); unlink("$result_dir/$tname.warnings"); - mtr_tonewfile($path_current_test_log,"$tname\n"); # Always tell where we are - - # output current test to ndbcluster log file to enable diagnostics - mtr_tofile($path_ndb_testrun_log,"CURRENT TEST $tname\n"); - - mtr_tofile($master->[0]->{'path_myerr'},"CURRENT_TEST: $tname\n"); - if ( $master->[1]->{'pid'} ) - { - mtr_tofile($master->[1]->{'path_myerr'},"CURRENT_TEST: $tname\n"); - } - if ( $mysql_version_id < 50000 ) { - # Set envirnoment variable NDB_STATUS_OK to 1 + # Set environment variable NDB_STATUS_OK to 1 # if script decided to run mysqltest cluster _is_ installed ok $ENV{'NDB_STATUS_OK'} = "1"; } elsif ( $mysql_version_id < 50100 ) { - # Set envirnoment variable NDB_STATUS_OK to YES + # Set environment variable NDB_STATUS_OK to YES # if script decided to run mysqltest cluster _is_ installed ok $ENV{'NDB_STATUS_OK'} = "YES"; } @@ -2982,9 +2971,9 @@ sub do_after_run_mysqltest($) my $tinfo= shift; my $tname= $tinfo->{'name'}; - mtr_tofile($path_mysqltest_log,"CURRENT TEST $tname\n"); - # Save info from this testcase run to mysqltest.log + mtr_appendfile_to_file($path_current_test_log, $path_mysqltest_log) + if -f $path_current_test_log; mtr_appendfile_to_file($path_timefile, $path_mysqltest_log) if -f $path_timefile; @@ -2994,6 +2983,26 @@ sub do_after_run_mysqltest($) } +sub run_testcase_mark_logs($) +{ + my ($log_msg)= @_; + + # Write a marker to all log files + + # The file indicating current test name + mtr_tonewfile($path_current_test_log, $log_msg); + + # each mysqld's .err file + foreach my $mysqld (@{$master}, @{$slave}) + { + mtr_tofile($mysqld->{path_myerr}, $log_msg); + } + + # ndbcluster log file + mtr_tofile($path_ndb_testrun_log, $log_msg); + +} + sub find_testcase_skipped_reason($) { my ($tinfo)= @_; @@ -3113,6 +3122,10 @@ sub run_testcase ($) { run_testcase_stop_servers($tinfo, $master_restart, $slave_restart); } + + # Write to all log files to indicate start of testcase + run_testcase_mark_logs("CURRENT_TEST: $tinfo->{name}\n"); + my $died= mtr_record_dead_children(); if ($died or $master_restart or $slave_restart) { @@ -4124,8 +4137,6 @@ sub run_testcase_start_servers($) { return 1; } } - mtr_tofile($master->[1]->{'path_myerr'},"CURRENT_TEST: $tname\n"); - mysqld_start($master->[1],$tinfo->{'master_opt'},[]); } @@ -4153,8 +4164,6 @@ sub run_testcase_start_servers($) { # ---------------------------------------------------------------------- if ( $tinfo->{'slave_num'} ) { - mtr_tofile($slave->[0]->{'path_myerr'},"CURRENT_TEST: $tname\n"); - restore_slave_databases($tinfo->{'slave_num'}); do_before_start_slave($tinfo); From fa8af126511502ce5ab7fa4a7662da19f0a6803d Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 28 Nov 2006 20:00:27 +0100 Subject: [PATCH 107/131] Look for client binaries also in bin/ directory --- mysql-test/mysql-test-run.pl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index aed1b2c318b..3aabf9ab742 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -656,11 +656,12 @@ sub command_line_setup () { # number as early as possible # - # Look for the client binaries + # Look for the client binaries directory $path_client_bindir= mtr_path_exists("$glob_basedir/client_release", "$glob_basedir/client_debug", vs_config_dirs('client', ''), - "$glob_basedir/client"); + "$glob_basedir/client", + "$glob_basedir/bin/"); $exe_mysqld= mtr_exe_exists (vs_config_dirs('sql', 'mysqld'), "$glob_basedir/sql/mysqld", From 0c48000e6c636c62feed9f0a49de23ecf93bda4d Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 28 Nov 2006 21:57:42 +0100 Subject: [PATCH 108/131] Fix missing parameter declaration --- 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 91a5b09e4df..1ffa2bbc68c 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1224,7 +1224,7 @@ sub command_line_setup () { # But a fairly safe range seems to be 5001 - 32767 # -sub set_mtr_build_thread_ports() { +sub set_mtr_build_thread_ports($) { my $mtr_build_thread= shift; # Up to two masters, up to three slaves From 05eb532514c11fc73a7134cdaa92369a984b21ad Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 28 Nov 2006 22:16:31 +0100 Subject: [PATCH 109/131] Bug#24335 mysql-test-run.pl fails with ActiveState Perl on Windows - Avoid use of mtr_run when executing "mysqld --verbose --help" to find version and supported features --- mysql-test/mysql-test-run.pl | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 3aabf9ab742..c1b0c44a00c 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1216,26 +1216,15 @@ sub datadir_list_setup () { sub collect_mysqld_features () { - # - # Execute "mysqld --no-defaults --help --verbose", that will - # print out version and a list of all features and settings - # my $found_variable_list_start= 0; - my $spec_file= "$glob_mysql_test_dir/mysqld.spec.$$"; - if ( mtr_run($exe_mysqld, - ["--no-defaults", - "--verbose", - "--help"], - "", "$spec_file", "$spec_file", "") != 0 ) - { - mtr_error("Failed to get version and list of features from %s", - $exe_mysqld); - } - my $F= IO::File->new($spec_file) or - mtr_error("can't open file \"$spec_file\": $!"); + # + # Execute "mysqld --no-defaults --help --verbose" to get a + # of all features and settings + # + my $list= `$exe_mysqld --no-defaults --verbose --help`; - while ( my $line= <$F> ) + foreach my $line (split('\n', $list)) { # First look for version if ( !$mysql_version_id ) @@ -1288,7 +1277,7 @@ sub collect_mysqld_features () { } } } - unlink($spec_file); + mtr_error("Could not find version of MySQL") unless $mysql_version_id; mtr_error("Could not find variabes list") unless $found_variable_list_start; From 7eb487ab26f753e72bd8b4a9b9a689885a2edf3b Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 28 Nov 2006 23:06:06 +0100 Subject: [PATCH 110/131] Move the check that $opt_vardir could be created and was writable to the function where we know how to creat the vardir Remove unused variable --- mysql-test/mysql-test-run.pl | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index c1b0c44a00c..0859b02167c 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1883,7 +1883,6 @@ sub kill_running_servers () { } } - # # Remove var and any directories in var/ created by previous # tests @@ -1935,7 +1934,6 @@ sub remove_stale_vardir () { mtr_error("The destination for symlink $opt_vardir does not exist") if ! -d readlink($opt_vardir); - my $dir= shift; foreach my $bin ( glob("$opt_vardir/*") ) { mtr_verbose("Removing bin $bin"); @@ -1997,6 +1995,19 @@ sub setup_vardir() { } } + if ( ! -d $opt_vardir ) + { + mtr_verbose("Creating $opt_vardir"); + mkpath($opt_vardir); + } + + # Ensure a proper error message if vardir couldn't be created + unless ( -d $opt_vardir and -w $opt_vardir ) + { + mtr_error("Writable 'var' directory is needed, use the " . + "'--vardir=' option"); + } + mkpath("$opt_vardir/log"); mkpath("$opt_vardir/run"); mkpath("$opt_vardir/tmp"); From 2b98e19bb538a9fb48d3cd5a0fe2d2c6aa814583 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 28 Nov 2006 23:09:17 +0100 Subject: [PATCH 111/131] Remove the moved check a second time. --- mysql-test/mysql-test-run.pl | 7 ------- 1 file changed, 7 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 963aae85a59..80a444acb27 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -813,13 +813,6 @@ sub command_line_setup () { $opt_vardir= "$glob_mysql_test_dir/$opt_vardir"; } - # Ensure a proper error message - mkpath("$opt_vardir"); - unless ( -d $opt_vardir and -w $opt_vardir ) - { - mtr_error("Writable 'var' directory is needed, use the '--vardir' option"); - } - # -------------------------------------------------------------------------- # Set tmpdir # -------------------------------------------------------------------------- From 2a0e2d1d3860aea8f6b6b4287214b491c87c8cce Mon Sep 17 00:00:00 2001 From: "tsmith/tim@siva.hindu.god" <> Date: Tue, 28 Nov 2006 16:39:04 -0700 Subject: [PATCH 112/131] rpl_init_slave.result: Update test result due to fix for bug 23883. --- mysql-test/r/rpl_init_slave.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/r/rpl_init_slave.result b/mysql-test/r/rpl_init_slave.result index f92fb9b4c1d..740c918976c 100644 --- a/mysql-test/r/rpl_init_slave.result +++ b/mysql-test/r/rpl_init_slave.result @@ -16,7 +16,7 @@ Variable_name Value init_slave show variables like 'max_connections'; Variable_name Value -max_connections 100 +max_connections 151 set @my_global_init_connect= @@global.init_connect; set global init_connect="set @c=1"; show variables like 'init_connect'; From 838d1d53b4e65980fbd10e496b43f49251e04790 Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Wed, 29 Nov 2006 09:21:37 +0100 Subject: [PATCH 113/131] Import version 1.50 of yaSSL --- extra/yassl/README | 66 ++++++-- extra/yassl/examples/client/client.cpp | 75 +++++--- .../yassl/examples/echoclient/echoclient.cpp | 25 ++- .../yassl/examples/echoserver/echoserver.cpp | 11 +- extra/yassl/examples/server/server.cpp | 33 +++- extra/yassl/include/factory.hpp | 7 +- extra/yassl/include/openssl/prefix_ssl.h | 4 + extra/yassl/include/openssl/ssl.h | 9 +- extra/yassl/include/socket_wrapper.hpp | 6 +- extra/yassl/include/yassl_error.hpp | 5 +- extra/yassl/include/yassl_imp.hpp | 15 +- extra/yassl/include/yassl_int.hpp | 11 ++ extra/yassl/include/yassl_types.hpp | 3 +- extra/yassl/src/handshake.cpp | 101 ++++++++--- extra/yassl/src/make.bat | 2 +- extra/yassl/src/socket_wrapper.cpp | 10 +- extra/yassl/src/ssl.cpp | 152 ++++++++++------- extra/yassl/src/yassl_error.cpp | 12 ++ extra/yassl/src/yassl_imp.cpp | 151 +++++++++++++---- extra/yassl/src/yassl_int.cpp | 160 +++++++++++++++++- extra/yassl/taocrypt/benchmark/make.bat | 2 +- extra/yassl/taocrypt/include/aes.hpp | 13 +- extra/yassl/taocrypt/include/algebra.hpp | 3 +- extra/yassl/taocrypt/include/arc4.hpp | 3 +- extra/yassl/taocrypt/include/asn.hpp | 6 +- extra/yassl/taocrypt/include/block.hpp | 7 +- extra/yassl/taocrypt/include/blowfish.hpp | 18 +- extra/yassl/taocrypt/include/des.hpp | 25 ++- extra/yassl/taocrypt/include/integer.hpp | 10 +- extra/yassl/taocrypt/include/md5.hpp | 7 + extra/yassl/taocrypt/include/misc.hpp | 19 ++- extra/yassl/taocrypt/include/modes.hpp | 22 ++- extra/yassl/taocrypt/include/ripemd.hpp | 7 + extra/yassl/taocrypt/include/rsa.hpp | 3 +- extra/yassl/taocrypt/include/sha.hpp | 7 + extra/yassl/taocrypt/include/twofish.hpp | 17 +- extra/yassl/taocrypt/src/aes.cpp | 26 +-- extra/yassl/taocrypt/src/algebra.cpp | 6 +- extra/yassl/taocrypt/src/arc4.cpp | 15 +- extra/yassl/taocrypt/src/blowfish.cpp | 25 +-- extra/yassl/taocrypt/src/des.cpp | 54 ++---- extra/yassl/taocrypt/src/integer.cpp | 79 ++++----- extra/yassl/taocrypt/src/make.bat | 5 +- extra/yassl/taocrypt/src/md4.cpp | 6 +- extra/yassl/taocrypt/src/md5.cpp | 37 ++-- extra/yassl/taocrypt/src/misc.cpp | 138 +++++++++++++++ extra/yassl/taocrypt/src/random.cpp | 3 + extra/yassl/taocrypt/src/ripemd.cpp | 38 ++--- extra/yassl/taocrypt/src/sha.cpp | 41 +++-- extra/yassl/taocrypt/src/twofish.cpp | 25 +-- extra/yassl/taocrypt/test/make.bat | 2 +- extra/yassl/taocrypt/test/test.cpp | 2 + extra/yassl/testsuite/make.bat | 2 +- extra/yassl/testsuite/test.hpp | 67 +++++--- 54 files changed, 1116 insertions(+), 482 deletions(-) diff --git a/extra/yassl/README b/extra/yassl/README index 2af4e98fe4c..fbeffd9db77 100644 --- a/extra/yassl/README +++ b/extra/yassl/README @@ -1,4 +1,56 @@ -yaSSL Release notes, version 1.4.0 (08/13/06) +yaSSL Release notes, version 1.5.0 (11/09/06) + + This release of yaSSL contains bug fixes, portability enhancements, + and full TLS 1.1 support. Use the functions: + + SSL_METHOD *TLSv1_1_server_method(void); + SSL_METHOD *TLSv1_1_client_method(void); + + or the SSLv23 versions (even though yaSSL doesn't support SSL 2.0 the v23 + means to pick the highest of SSL 3.0, TLS 1.0, or TLS 1.1. + + +See normal build instructions below under 1.0.6. +See libcurl build instructions below under 1.3.0. + + + +****************yaSSL Release notes, version 1.4.5 (10/15/06) + + + This release of yaSSL contains bug fixes, portability enhancements, + zlib compression support, removal of assembly instructions at runtime if + not supported, and initial TLS 1.1 support. + + + Compression Notes: yaSSL uses zlib for compression and the compression + should only be used if yaSSL is at both ends because the implementation + details aren't yet standard. If you'd like to turn compression on use + the SSL_set_compression() function on the client before calling + SSL_connect(). If both the client and server were built with zlib support + then the connection will use compression. If the client isn't built with + support then SSL_set_compression() will return an error (-1). + + To build yaSSL with zlib support on Unix simply have zlib support on your + system and configure will find it if it's in the standard locations. If + it's somewhere else use the option ./configure --with-zlib=DIR. If you'd + like to disable compression support in yaSSL use ./configure --without-zlib. + + To build yaSSL with zlib support on Windows: + + 1) download zlib from http://www.zlib.net/ + 2) follow the instructions in zlib from projects/visualc6/README.txt + for how to add the zlib project into the yaSSL workspace noting that + you'll need to add configuration support for "Win32 Debug" and + "Win32 Release" in note 3 under "To use:". + 3) define HAVE_LIBZ when building yaSSL + + +See normal build instructions below under 1.0.6. +See libcurl build instructions below under 1.3.0. + + +********************yaSSL Release notes, version 1.4.0 (08/13/06) This release of yaSSL contains bug fixes, portability enhancements, @@ -122,18 +174,6 @@ Choose (Re)Build All from the project workspace run Debug\testsuite.exe from yaSSL-Home\testsuite to test the build ---To enable ia32 assembly for TaoCrypt ciphers and message digests - - On MSVC this is always on - - On GCC **, use ./configure --enable-ia32-asm - - ** This isn't on by default because of the use of intel syntax and the - problem that olders versions of gas have with some addressing statements. - If you enable this and get assemler errors during compilation or can't - pass the TaoCrypt tests, please send todd@yassl.com a message and disable - this option in the meantime. - ***************** yaSSL Release notes, version 1.0.5 diff --git a/extra/yassl/examples/client/client.cpp b/extra/yassl/examples/client/client.cpp index d655011deb6..6c3cdf04dc1 100644 --- a/extra/yassl/examples/client/client.cpp +++ b/extra/yassl/examples/client/client.cpp @@ -5,6 +5,35 @@ //#define TEST_RESUME +void ClientError(SSL_CTX* ctx, SSL* ssl, SOCKET_T& sockfd, const char* msg) +{ + SSL_CTX_free(ctx); + SSL_free(ssl); + tcp_close(sockfd); + err_sys(msg); +} + + +#ifdef NON_BLOCKING + void NonBlockingSSL_Connect(SSL* ssl, SSL_CTX* ctx, SOCKET_T& sockfd) + { + int ret = SSL_connect(ssl); + while (ret =! SSL_SUCCESS && SSL_get_error(ssl, 0) == + SSL_ERROR_WANT_READ) { + printf("... client would block\n"); + #ifdef _WIN32 + Sleep(1000); + #else + sleep(1); + #endif + ret = SSL_connect(ssl); + } + if (ret != SSL_SUCCESS) + ClientError(ctx, ssl, sockfd, "SSL_connect failed"); + } +#endif + + void client_test(void* args) { #ifdef _WIN32 @@ -18,6 +47,9 @@ void client_test(void* args) set_args(argc, argv, *static_cast(args)); tcp_connect(sockfd); +#ifdef NON_BLOCKING + tcp_set_nonblocking(sockfd); +#endif SSL_METHOD* method = TLSv1_client_method(); SSL_CTX* ctx = SSL_CTX_new(method); @@ -27,13 +59,13 @@ void client_test(void* args) SSL_set_fd(ssl, sockfd); + +#ifdef NON_BLOCKING + NonBlockingSSL_Connect(ssl, ctx, sockfd); +#else if (SSL_connect(ssl) != SSL_SUCCESS) - { - SSL_CTX_free(ctx); - SSL_free(ssl); - tcp_close(sockfd); - err_sys("SSL_connect failed"); - } + ClientError(ctx, ssl, sockfd, "SSL_connect failed"); +#endif showPeer(ssl); const char* cipher = 0; @@ -49,16 +81,14 @@ void client_test(void* args) char msg[] = "hello yassl!"; if (SSL_write(ssl, msg, sizeof(msg)) != sizeof(msg)) - { - SSL_CTX_free(ctx); - SSL_free(ssl); - tcp_close(sockfd); - err_sys("SSL_write failed"); - } + ClientError(ctx, ssl, sockfd, "SSL_write failed"); char reply[1024]; - reply[SSL_read(ssl, reply, sizeof(reply))] = 0; + int input = SSL_read(ssl, reply, sizeof(reply)); + if (input > 0) { + reply[input] = 0; printf("Server response: %s\n", reply); + } #ifdef TEST_RESUME SSL_SESSION* session = SSL_get_session(ssl); @@ -75,24 +105,17 @@ void client_test(void* args) SSL_set_session(sslResume, session); if (SSL_connect(sslResume) != SSL_SUCCESS) - { - SSL_CTX_free(ctx); - SSL_free(ssl); - tcp_close(sockfd); - err_sys("SSL resume failed"); - } + ClientError(ctx, sslResume, sockfd, "SSL_resume failed"); showPeer(sslResume); if (SSL_write(sslResume, msg, sizeof(msg)) != sizeof(msg)) - { - SSL_CTX_free(ctx); - SSL_free(ssl); - tcp_close(sockfd); - err_sys("SSL_write failed"); - } + ClientError(ctx, sslResume, sockfd, "SSL_write failed"); - reply[SSL_read(sslResume, reply, sizeof(reply))] = 0; + input = SSL_read(sslResume, reply, sizeof(reply)); + if (input > 0) { + reply[input] = 0; printf("Server response: %s\n", reply); + } SSL_shutdown(sslResume); SSL_free(sslResume); diff --git a/extra/yassl/examples/echoclient/echoclient.cpp b/extra/yassl/examples/echoclient/echoclient.cpp index 983254bf8a7..e2c33c7cda2 100644 --- a/extra/yassl/examples/echoclient/echoclient.cpp +++ b/extra/yassl/examples/echoclient/echoclient.cpp @@ -3,6 +3,15 @@ #include "../../testsuite/test.hpp" +void EchoClientError(SSL_CTX* ctx, SSL* ssl, SOCKET_T& sockfd, const char* msg) +{ + SSL_CTX_free(ctx); + SSL_free(ssl); + tcp_close(sockfd); + err_sys(msg); +} + + void echoclient_test(void* args) { #ifdef _WIN32 @@ -35,7 +44,7 @@ void echoclient_test(void* args) tcp_connect(sockfd); - SSL_METHOD* method = TLSv1_client_method(); + SSL_METHOD* method = SSLv23_client_method(); SSL_CTX* ctx = SSL_CTX_new(method); set_certs(ctx); SSL* ssl = SSL_new(ctx); @@ -43,12 +52,7 @@ void echoclient_test(void* args) SSL_set_fd(ssl, sockfd); if (SSL_connect(ssl) != SSL_SUCCESS) - { - SSL_CTX_free(ctx); - SSL_free(ssl); - tcp_close(sockfd); - err_sys("SSL_connect failed"); - } + EchoClientError(ctx, ssl, sockfd, "SSL_connect failed"); char send[1024]; char reply[1024]; @@ -57,12 +61,7 @@ void echoclient_test(void* args) int sendSz = strlen(send) + 1; if (SSL_write(ssl, send, sendSz) != sendSz) - { - SSL_CTX_free(ctx); - SSL_free(ssl); - tcp_close(sockfd); - err_sys("SSL_write failed"); - } + EchoClientError(ctx, ssl, sockfd, "SSL_write failed"); if (strncmp(send, "quit", 4) == 0) { fputs("sending server shutdown command: quit!\n", fout); diff --git a/extra/yassl/examples/echoserver/echoserver.cpp b/extra/yassl/examples/echoserver/echoserver.cpp index cd31fedddd8..92613744ba0 100644 --- a/extra/yassl/examples/echoserver/echoserver.cpp +++ b/extra/yassl/examples/echoserver/echoserver.cpp @@ -56,7 +56,7 @@ THREAD_RETURN YASSL_API echoserver_test(void* args) tcp_listen(sockfd); - SSL_METHOD* method = TLSv1_server_method(); + SSL_METHOD* method = SSLv23_server_method(); SSL_CTX* ctx = SSL_CTX_new(method); set_serverCerts(ctx); @@ -87,8 +87,12 @@ THREAD_RETURN YASSL_API echoserver_test(void* args) SSL* ssl = SSL_new(ctx); SSL_set_fd(ssl, clientfd); - if (SSL_accept(ssl) != SSL_SUCCESS) - EchoError(ctx, ssl, sockfd, clientfd, "SSL_accept failed"); + if (SSL_accept(ssl) != SSL_SUCCESS) { + printf("SSL_accept failed\n"); + SSL_free(ssl); + tcp_close(clientfd); + continue; + } char command[1024]; int echoSz(0); @@ -130,6 +134,7 @@ THREAD_RETURN YASSL_API echoserver_test(void* args) if (SSL_write(ssl, command, echoSz) != echoSz) EchoError(ctx, ssl, sockfd, clientfd, "SSL_write failed"); } + SSL_shutdown(ssl); SSL_free(ssl); tcp_close(clientfd); } diff --git a/extra/yassl/examples/server/server.cpp b/extra/yassl/examples/server/server.cpp index d0bf70cd634..75ce4224770 100644 --- a/extra/yassl/examples/server/server.cpp +++ b/extra/yassl/examples/server/server.cpp @@ -13,6 +13,26 @@ void ServerError(SSL_CTX* ctx, SSL* ssl, SOCKET_T& sockfd, const char* msg) } +#ifdef NON_BLOCKING + void NonBlockingSSL_Accept(SSL* ssl, SSL_CTX* ctx, SOCKET_T& clientfd) + { + int ret = SSL_accept(ssl); + while (ret != SSL_SUCCESS && SSL_get_error(ssl, 0) == + SSL_ERROR_WANT_READ) { + printf("... server would block\n"); + #ifdef _WIN32 + Sleep(1000); + #else + sleep(1); + #endif + ret = SSL_accept(ssl); + } + if (ret != SSL_SUCCESS) + ServerError(ctx, ssl, clientfd, "SSL_accept failed"); + } +#endif + + THREAD_RETURN YASSL_API server_test(void* args) { #ifdef _WIN32 @@ -33,7 +53,7 @@ THREAD_RETURN YASSL_API server_test(void* args) SSL_METHOD* method = TLSv1_server_method(); SSL_CTX* ctx = SSL_CTX_new(method); - //SSL_CTX_set_cipher_list(ctx, "RC4-SHA"); + //SSL_CTX_set_cipher_list(ctx, "RC4-SHA:RC4-MD5"); SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, 0); set_serverCerts(ctx); DH* dh = set_tmpDH(ctx); @@ -41,15 +61,22 @@ THREAD_RETURN YASSL_API server_test(void* args) SSL* ssl = SSL_new(ctx); SSL_set_fd(ssl, clientfd); +#ifdef NON_BLOCKING + NonBlockingSSL_Accept(ssl, ctx, clientfd); +#else if (SSL_accept(ssl) != SSL_SUCCESS) ServerError(ctx, ssl, clientfd, "SSL_accept failed"); +#endif showPeer(ssl); printf("Using Cipher Suite: %s\n", SSL_get_cipher(ssl)); char command[1024]; - command[SSL_read(ssl, command, sizeof(command))] = 0; + int input = SSL_read(ssl, command, sizeof(command)); + if (input > 0) { + command[input] = 0; printf("First client command: %s\n", command); + } char msg[] = "I hear you, fa shizzle!"; if (SSL_write(ssl, msg, sizeof(msg)) != sizeof(msg)) @@ -57,6 +84,7 @@ THREAD_RETURN YASSL_API server_test(void* args) DH_free(dh); SSL_CTX_free(ctx); + SSL_shutdown(ssl); SSL_free(ssl); tcp_close(clientfd); @@ -82,3 +110,4 @@ THREAD_RETURN YASSL_API server_test(void* args) } #endif // NO_MAIN_DRIVER + diff --git a/extra/yassl/include/factory.hpp b/extra/yassl/include/factory.hpp index 04d742431dc..dc25cf0ee70 100644 --- a/extra/yassl/include/factory.hpp +++ b/extra/yassl/include/factory.hpp @@ -42,12 +42,7 @@ namespace STL = STL_NAMESPACE; -// VC60 workaround: it doesn't allow typename in some places -#if defined(_MSC_VER) && (_MSC_VER < 1300) - #define CPP_TYPENAME -#else - #define CPP_TYPENAME typename -#endif + namespace yaSSL { diff --git a/extra/yassl/include/openssl/prefix_ssl.h b/extra/yassl/include/openssl/prefix_ssl.h index aa3f799cf80..dc6e3ef81f0 100644 --- a/extra/yassl/include/openssl/prefix_ssl.h +++ b/extra/yassl/include/openssl/prefix_ssl.h @@ -52,6 +52,7 @@ #define SSL_set_session yaSSL_set_session #define SSL_get_session yaSSL_get_session #define SSL_SESSION_set_timeout yaSSL_SESSION_set_timeout +#define SSL_CTX_set_session_cache_mode yaSSL_CTX_set_session_cache_mode #define SSL_get_peer_certificate yaSSL_get_peer_certificate #define SSL_get_verify_result yaSSL_get_verify_result #define SSL_CTX_set_verify yaSSL_CTX_set_verify @@ -98,6 +99,8 @@ #define SSLv3_client_method yaSSLv3_client_method #define TLSv1_server_method yaTLSv1_server_method #define TLSv1_client_method yaTLSv1_client_method +#define TLSv1_1_server_method yaTLSv1_1_server_method +#define TLSv1_1_client_method yaTLSv1_1_client_method #define SSLv23_server_method yaSSLv23_server_method #define SSL_CTX_use_certificate_file yaSSL_CTX_use_certificate_file #define SSL_CTX_use_PrivateKey_file yaSSL_CTX_use_PrivateKey_file @@ -159,3 +162,4 @@ #define MD5_Init yaMD5_Init #define MD5_Update yaMD5_Update #define MD5_Final yaMD5_Final +#define SSL_set_compression yaSSL_set_compression diff --git a/extra/yassl/include/openssl/ssl.h b/extra/yassl/include/openssl/ssl.h index 5e7290d2a7a..67c49a808fd 100644 --- a/extra/yassl/include/openssl/ssl.h +++ b/extra/yassl/include/openssl/ssl.h @@ -41,7 +41,7 @@ #include "rsa.h" -#define YASSL_VERSION "1.4.3" +#define YASSL_VERSION "1.5.0" #if defined(__cplusplus) @@ -228,6 +228,7 @@ void SSL_load_error_strings(void); int SSL_set_session(SSL *ssl, SSL_SESSION *session); SSL_SESSION* SSL_get_session(SSL* ssl); long SSL_SESSION_set_timeout(SSL_SESSION*, long); +long SSL_CTX_set_session_cache_mode(SSL_CTX* ctx, long mode); X509* SSL_get_peer_certificate(SSL*); long SSL_get_verify_result(SSL*); @@ -361,6 +362,8 @@ SSL_METHOD *SSLv3_server_method(void); SSL_METHOD *SSLv3_client_method(void); SSL_METHOD *TLSv1_server_method(void); SSL_METHOD *TLSv1_client_method(void); +SSL_METHOD *TLSv1_1_server_method(void); +SSL_METHOD *TLSv1_1_client_method(void); SSL_METHOD *SSLv23_server_method(void); int SSL_CTX_use_certificate_file(SSL_CTX*, const char*, int); @@ -531,6 +534,10 @@ void MD5_Final(unsigned char*, MD5_CTX*); #define SSL_DEFAULT_CIPHER_LIST "" /* default all */ +/* yaSSL adds */ +int SSL_set_compression(SSL*); /* turn on yaSSL zlib compression */ + + #if defined(__cplusplus) && !defined(YASSL_MYSQL_COMPATIBLE) diff --git a/extra/yassl/include/socket_wrapper.hpp b/extra/yassl/include/socket_wrapper.hpp index 9fc0d62f90e..bc82384d85e 100644 --- a/extra/yassl/include/socket_wrapper.hpp +++ b/extra/yassl/include/socket_wrapper.hpp @@ -70,8 +70,8 @@ typedef unsigned char byte; // Wraps Windows Sockets and BSD Sockets class Socket { socket_t socket_; // underlying socket descriptor - bool wouldBlock_; // for non-blocking data - bool blocking_; // is option set + bool wouldBlock_; // if non-blocking data, for last read + bool nonBlocking_; // is option set public: explicit Socket(socket_t s = INVALID_SOCKET); ~Socket(); @@ -85,7 +85,7 @@ public: bool wait(); bool WouldBlock() const; - bool IsBlocking() const; + bool IsNonBlocking() const; void closeSocket(); void shutDown(int how = SD_SEND); diff --git a/extra/yassl/include/yassl_error.hpp b/extra/yassl/include/yassl_error.hpp index 72b79b05dbd..f820e5811d9 100644 --- a/extra/yassl/include/yassl_error.hpp +++ b/extra/yassl/include/yassl_error.hpp @@ -56,7 +56,10 @@ enum YasslError { receive_error = 114, certificate_error = 115, privateKey_error = 116, - badVersion_error = 117 + badVersion_error = 117, + compress_error = 118, + decompress_error = 119, + pms_version_error = 120 // !!!! add error message to .cpp !!!! diff --git a/extra/yassl/include/yassl_imp.hpp b/extra/yassl/include/yassl_imp.hpp index 180d7fe7fe1..f51a902b2a5 100644 --- a/extra/yassl/include/yassl_imp.hpp +++ b/extra/yassl/include/yassl_imp.hpp @@ -132,7 +132,6 @@ class Data : public Message { public: Data(); Data(uint16 len, opaque* b); - Data(uint16 len, const opaque* w); friend output_buffer& operator<<(output_buffer&, const Data&); @@ -141,9 +140,9 @@ public: ContentType get_type() const; uint16 get_length() const; - const opaque* get_buffer() const; void set_length(uint16 l); opaque* set_buffer(); + void SetData(uint16, const opaque*); void Process(input_buffer&, SSL&); private: Data(const Data&); // hide copy @@ -232,11 +231,11 @@ public: void Process(input_buffer&, SSL&); const opaque* get_random() const; - friend void buildClientHello(SSL&, ClientHello&, CompressionMethod); + friend void buildClientHello(SSL&, ClientHello&); friend void ProcessOldClientHello(input_buffer& input, SSL& ssl); ClientHello(); - explicit ClientHello(ProtocolVersion pv); + ClientHello(ProtocolVersion pv, bool useCompression); private: ClientHello(const ClientHello&); // hide copy ClientHello& operator=(const ClientHello&); // and assign @@ -253,7 +252,7 @@ class ServerHello : public HandShakeBase { opaque cipher_suite_[SUITE_LEN]; CompressionMethod compression_method_; public: - explicit ServerHello(ProtocolVersion pv); + ServerHello(ProtocolVersion pv, bool useCompression); ServerHello(); friend input_buffer& operator>>(input_buffer&, ServerHello&); @@ -629,8 +628,11 @@ struct Connection { bool send_server_key_; // server key exchange? bool master_clean_; // master secret clean? bool TLS_; // TLSv1 or greater + bool TLSv1_1_; // TLSv1.1 or greater bool sessionID_Set_; // do we have a session - ProtocolVersion version_; + bool compression_; // zlib compression? + ProtocolVersion version_; // negotiated version + ProtocolVersion chVersion_; // client hello version RandomPool& random_; Connection(ProtocolVersion v, RandomPool& ran); @@ -640,6 +642,7 @@ struct Connection { void CleanPreMaster(); void CleanMaster(); void TurnOffTLS(); + void TurnOffTLS1_1(); private: Connection(const Connection&); // hide copy Connection& operator=(const Connection&); // and assign diff --git a/extra/yassl/include/yassl_int.hpp b/extra/yassl/include/yassl_int.hpp index 0edff289b61..4a3c0ba4e20 100644 --- a/extra/yassl/include/yassl_int.hpp +++ b/extra/yassl/include/yassl_int.hpp @@ -431,6 +431,7 @@ private: DH_Parms dhParms_; pem_password_cb passwordCb_; void* userData_; + bool sessionCacheOff_; Stats stats_; Mutex mutex_; // for Stats public: @@ -445,6 +446,7 @@ public: const Stats& GetStats() const; pem_password_cb GetPasswordCb() const; void* GetUserData() const; + bool GetSessionCacheOff() const; void setVerifyPeer(); void setVerifyNone(); @@ -453,6 +455,7 @@ public: bool SetDH(const DH&); void SetPasswordCb(pem_password_cb cb); void SetUserData(void*); + void SetSessionCacheOff(); void IncrementStats(StatsField); void AddCA(x509* ca); @@ -600,6 +603,7 @@ public: const Socket& getSocket() const; YasslError GetError() const; bool GetMultiProtocol() const; + bool CompressionOn() const; Crypto& useCrypto(); Security& useSecurity(); @@ -617,9 +621,12 @@ public: void set_preMaster(const opaque*, uint); void set_masterSecret(const opaque*); void SetError(YasslError); + int SetCompression(); + void UnSetCompression(); // helpers bool isTLS() const; + bool isTLSv1_1() const; void order_error(); void makeMasterSecret(); void makeTLSMasterSecret(); @@ -653,6 +660,10 @@ private: }; +// compression +int Compress(const byte*, int, input_buffer&); +int DeCompress(input_buffer&, int, input_buffer&); + // conversion functions void c32to24(uint32, uint24&); diff --git a/extra/yassl/include/yassl_types.hpp b/extra/yassl/include/yassl_types.hpp index e602ee180bf..646c71afddf 100644 --- a/extra/yassl/include/yassl_types.hpp +++ b/extra/yassl/include/yassl_types.hpp @@ -211,6 +211,7 @@ const int FINISHED_LABEL_SZ = 15; // TLS finished lable length const int SEED_LEN = RAN_LEN * 2; // TLS seed, client + server random const int DEFAULT_TIMEOUT = 500; // Default Session timeout in seconds const int MAX_RECORD_SIZE = 16384; // 2^14, max size by standard +const int COMPRESS_EXTRA = 1024; // extra compression possible addition typedef uint8 Cipher; // first byte is always 0x00 for SSLv3 & TLS @@ -222,7 +223,7 @@ typedef opaque* DistinguishedName; typedef bool IsExportable; -enum CompressionMethod { no_compression = 0 }; +enum CompressionMethod { no_compression = 0, zlib = 221 }; enum CipherType { stream, block }; diff --git a/extra/yassl/src/handshake.cpp b/extra/yassl/src/handshake.cpp index 25f36c4ea8c..c03d72ff2ef 100644 --- a/extra/yassl/src/handshake.cpp +++ b/extra/yassl/src/handshake.cpp @@ -40,9 +40,11 @@ namespace yaSSL { // Build a client hello message from cipher suites and compression method -void buildClientHello(SSL& ssl, ClientHello& hello, - CompressionMethod compression = no_compression) +void buildClientHello(SSL& ssl, ClientHello& hello) { + // store for pre master secret + ssl.useSecurity().use_connection().chVersion_ = hello.client_version_; + ssl.getCrypto().get_random().Fill(hello.random_, RAN_LEN); if (ssl.getSecurity().get_resuming()) { hello.id_len_ = ID_LEN; @@ -55,7 +57,6 @@ void buildClientHello(SSL& ssl, ClientHello& hello, memcpy(hello.cipher_suites_, ssl.getSecurity().get_parms().suites_, hello.suite_len_); hello.comp_len_ = 1; - hello.compression_methods_ = compression; hello.set_length(sizeof(ProtocolVersion) + RAN_LEN + @@ -83,7 +84,7 @@ void buildServerHello(SSL& ssl, ServerHello& hello) hello.cipher_suite_[0] = ssl.getSecurity().get_parms().suite_[0]; hello.cipher_suite_[1] = ssl.getSecurity().get_parms().suite_[1]; - hello.compression_method_ = no_compression; + hello.compression_method_ = hello.compression_method_; hello.set_length(sizeof(ProtocolVersion) + RAN_LEN + ID_LEN + sizeof(hello.id_len_) + SUITE_LEN + SIZEOF_ENUM); @@ -151,12 +152,18 @@ void buildHeaders(SSL& ssl, HandShakeHeader& hsHeader, // add handshake from buffer into md5 and sha hashes, exclude record header -void hashHandShake(SSL& ssl, const output_buffer& output) +void hashHandShake(SSL& ssl, const output_buffer& output, bool removeIV = false) { uint sz = output.get_size() - RECORD_HEADER; const opaque* buffer = output.get_buffer() + RECORD_HEADER; + if (removeIV) { // TLSv1_1 IV + uint blockSz = ssl.getCrypto().get_cipher().get_blockSize(); + sz -= blockSz; + buffer += blockSz; + } + ssl.useHashes().use_MD5().update(buffer, sz); ssl.useHashes().use_SHA().update(buffer, sz); } @@ -229,6 +236,18 @@ void decrypt_message(SSL& ssl, input_buffer& input, uint sz) ssl.useCrypto().use_cipher().decrypt(plain.get_buffer(), cipher, sz); memcpy(cipher, plain.get_buffer(), sz); ssl.useSecurity().use_parms().encrypt_size_ = sz; + + if (ssl.isTLSv1_1()) // IV + input.set_current(input.get_current() + + ssl.getCrypto().get_cipher().get_blockSize()); +} + + +// output operator for input_buffer +output_buffer& operator<<(output_buffer& output, const input_buffer& input) +{ + output.write(input.get_buffer(), input.get_size()); + return output; } @@ -239,9 +258,12 @@ void cipherFinished(SSL& ssl, Finished& fin, output_buffer& output) uint finishedSz = ssl.isTLS() ? TLS_FINISHED_SZ : FINISHED_SZ; uint sz = RECORD_HEADER + HANDSHAKE_HEADER + finishedSz + digestSz; uint pad = 0; + uint blockSz = ssl.getCrypto().get_cipher().get_blockSize(); + if (ssl.getSecurity().get_parms().cipher_type_ == block) { + if (ssl.isTLSv1_1()) + sz += blockSz; // IV sz += 1; // pad byte - uint blockSz = ssl.getCrypto().get_cipher().get_blockSize(); pad = (sz - RECORD_HEADER) % blockSz; pad = blockSz - pad; sz += pad; @@ -252,14 +274,21 @@ void cipherFinished(SSL& ssl, Finished& fin, output_buffer& output) buildHeaders(ssl, hsHeader, rlHeader, fin); rlHeader.length_ = sz - RECORD_HEADER; // record header includes mac // and pad, hanshake doesn't + input_buffer iv; + if (ssl.isTLSv1_1() && ssl.getSecurity().get_parms().cipher_type_== block){ + iv.allocate(blockSz); + ssl.getCrypto().get_random().Fill(iv.get_buffer(), blockSz); + iv.add_size(blockSz); + } + uint ivSz = iv.get_size(); output.allocate(sz); - output << rlHeader << hsHeader << fin; + output << rlHeader << iv << hsHeader << fin; - hashHandShake(ssl, output); + hashHandShake(ssl, output, ssl.isTLSv1_1() ? true : false); opaque digest[SHA_LEN]; // max size if (ssl.isTLS()) - TLS_hmac(ssl, digest, output.get_buffer() + RECORD_HEADER, - output.get_size() - RECORD_HEADER, handshake); + TLS_hmac(ssl, digest, output.get_buffer() + RECORD_HEADER + ivSz, + output.get_size() - RECORD_HEADER - ivSz, handshake); else hmac(ssl, digest, output.get_buffer() + RECORD_HEADER, output.get_size() - RECORD_HEADER, handshake); @@ -282,9 +311,12 @@ void buildMessage(SSL& ssl, output_buffer& output, const Message& msg) uint digestSz = ssl.getCrypto().get_digest().get_digestSize(); uint sz = RECORD_HEADER + msg.get_length() + digestSz; uint pad = 0; + uint blockSz = ssl.getCrypto().get_cipher().get_blockSize(); + if (ssl.getSecurity().get_parms().cipher_type_ == block) { + if (ssl.isTLSv1_1()) // IV + sz += blockSz; sz += 1; // pad byte - uint blockSz = ssl.getCrypto().get_cipher().get_blockSize(); pad = (sz - RECORD_HEADER) % blockSz; pad = blockSz - pad; sz += pad; @@ -294,13 +326,21 @@ void buildMessage(SSL& ssl, output_buffer& output, const Message& msg) buildHeader(ssl, rlHeader, msg); rlHeader.length_ = sz - RECORD_HEADER; // record header includes mac // and pad, hanshake doesn't + input_buffer iv; + if (ssl.isTLSv1_1() && ssl.getSecurity().get_parms().cipher_type_== block){ + iv.allocate(blockSz); + ssl.getCrypto().get_random().Fill(iv.get_buffer(), blockSz); + iv.add_size(blockSz); + } + + uint ivSz = iv.get_size(); output.allocate(sz); - output << rlHeader << msg; + output << rlHeader << iv << msg; opaque digest[SHA_LEN]; // max size if (ssl.isTLS()) - TLS_hmac(ssl, digest, output.get_buffer() + RECORD_HEADER, - output.get_size() - RECORD_HEADER, msg.get_type()); + TLS_hmac(ssl, digest, output.get_buffer() + RECORD_HEADER + ivSz, + output.get_size() - RECORD_HEADER - ivSz, msg.get_type()); else hmac(ssl, digest, output.get_buffer() + RECORD_HEADER, output.get_size() - RECORD_HEADER, msg.get_type()); @@ -456,6 +496,10 @@ void buildSHA_CertVerify(SSL& ssl, byte* digest) // some clients still send sslv2 client hello void ProcessOldClientHello(input_buffer& input, SSL& ssl) { + if (input.get_remaining() < 2) { + ssl.SetError(bad_input); + return; + } byte b0 = input[AUTO]; byte b1 = input[AUTO]; @@ -721,6 +765,7 @@ int DoProcessReply(SSL& ssl) // each message in record, can be more than 1 if not encrypted if (ssl.getSecurity().get_parms().pending_ == false) // cipher on decrypt_message(ssl, buffer, hdr.length_); + mySTL::auto_ptr msg(mf.CreateObject(hdr.type_)); if (!msg.get()) { ssl.SetError(factory_error); @@ -744,13 +789,13 @@ void processReply(SSL& ssl) if (DoProcessReply(ssl)) // didn't complete process - if (!ssl.getSocket().IsBlocking()) { - // keep trying now + if (!ssl.getSocket().IsNonBlocking()) { + // keep trying now, blocking ok while (!ssl.GetError()) if (DoProcessReply(ssl) == 0) break; } else - // user will have try again later + // user will have try again later, non blocking ssl.SetError(YasslError(SSL_ERROR_WANT_READ)); } @@ -761,7 +806,8 @@ void sendClientHello(SSL& ssl) ssl.verifyState(serverNull); if (ssl.GetError()) return; - ClientHello ch(ssl.getSecurity().get_connection().version_); + ClientHello ch(ssl.getSecurity().get_connection().version_, + ssl.getSecurity().get_connection().compression_); RecordLayerHeader rlHeader; HandShakeHeader hsHeader; output_buffer out; @@ -859,6 +905,7 @@ void sendFinished(SSL& ssl, ConnectionEnd side, BufferOutput buffer) buildFinished(ssl, ssl.useHashes().use_verify(), client); // client } else { + if (!ssl.getSecurity().GetContext()->GetSessionCacheOff()) GetSessions().add(ssl); // store session if (side == client_end) buildFinished(ssl, ssl.useHashes().use_verify(), server); // server @@ -885,7 +932,20 @@ int sendData(SSL& ssl, const void* buffer, int sz) for (;;) { int len = min(sz - sent, MAX_RECORD_SIZE); output_buffer out; - const Data data(len, static_cast(buffer) + sent); + input_buffer tmp; + + Data data; + + if (ssl.CompressionOn()) { + if (Compress(static_cast(buffer) + sent, len, + tmp) == -1) { + ssl.SetError(compress_error); + return -1; + } + data.SetData(tmp.get_size(), tmp.get_buffer()); + } + else + data.SetData(len, static_cast(buffer) + sent); buildMessage(ssl, out, data); ssl.Send(out.get_buffer(), out.get_size()); @@ -947,7 +1007,8 @@ void sendServerHello(SSL& ssl, BufferOutput buffer) ssl.verifyState(clientHelloComplete); if (ssl.GetError()) return; - ServerHello sh(ssl.getSecurity().get_connection().version_); + ServerHello sh(ssl.getSecurity().get_connection().version_, + ssl.getSecurity().get_connection().compression_); RecordLayerHeader rlHeader; HandShakeHeader hsHeader; mySTL::auto_ptr out(NEW_YS output_buffer); diff --git a/extra/yassl/src/make.bat b/extra/yassl/src/make.bat index 148427a6f41..dde305721a7 100644 --- a/extra/yassl/src/make.bat +++ b/extra/yassl/src/make.bat @@ -1,7 +1,7 @@ REM quick and dirty build file for testing different MSDEVs setlocal -set myFLAGS= /I../include /I../mySTL /I../taocrypt/include /W3 /c /ZI +set myFLAGS= /I../include /I../taocrypt/mySTL /I../taocrypt/include /W3 /c /ZI cl %myFLAGS% buffer.cpp cl %myFLAGS% cert_wrapper.cpp diff --git a/extra/yassl/src/socket_wrapper.cpp b/extra/yassl/src/socket_wrapper.cpp index 70944831884..f281b81a24a 100644 --- a/extra/yassl/src/socket_wrapper.cpp +++ b/extra/yassl/src/socket_wrapper.cpp @@ -63,7 +63,7 @@ namespace yaSSL { Socket::Socket(socket_t s) - : socket_(s), wouldBlock_(false), blocking_(false) + : socket_(s), wouldBlock_(false), nonBlocking_(false) {} @@ -148,8 +148,8 @@ uint Socket::receive(byte* buf, unsigned int sz, int flags) if (recvd == -1) { if (get_lastError() == SOCKET_EWOULDBLOCK || get_lastError() == SOCKET_EAGAIN) { - wouldBlock_ = true; - blocking_ = true; // socket can block, only way to tell for win32 + wouldBlock_ = true; // would have blocked this time only + nonBlocking_ = true; // socket nonblocking, win32 only way to tell return 0; } } @@ -191,9 +191,9 @@ bool Socket::WouldBlock() const } -bool Socket::IsBlocking() const +bool Socket::IsNonBlocking() const { - return blocking_; + return nonBlocking_; } diff --git a/extra/yassl/src/ssl.cpp b/extra/yassl/src/ssl.cpp index a008ea7228b..e0e27502f3d 100644 --- a/extra/yassl/src/ssl.cpp +++ b/extra/yassl/src/ssl.cpp @@ -184,10 +184,22 @@ SSL_METHOD* TLSv1_client_method() } +SSL_METHOD* TLSv1_1_server_method() +{ + return NEW_YS SSL_METHOD(server_end, ProtocolVersion(3,2)); +} + + +SSL_METHOD* TLSv1_1_client_method() +{ + return NEW_YS SSL_METHOD(client_end, ProtocolVersion(3,2)); +} + + SSL_METHOD* SSLv23_server_method() { // compatibility only, no version 2 support, but does SSL 3 and TLS 1 - return NEW_YS SSL_METHOD(server_end, ProtocolVersion(3,1), true); + return NEW_YS SSL_METHOD(server_end, ProtocolVersion(3,2), true); } @@ -196,7 +208,7 @@ SSL_METHOD* SSLv23_client_method() // compatibility only, no version 2 support, but does SSL 3 and TLS 1 // though it sends TLS1 hello not SSLv2 so SSLv3 only servers will decline // TODO: maybe add support to send SSLv2 hello ??? - return NEW_YS SSL_METHOD(client_end, ProtocolVersion(3,1), true); + return NEW_YS SSL_METHOD(client_end, ProtocolVersion(3,2), true); } @@ -407,7 +419,6 @@ int SSL_shutdown(SSL* ssl) Alert alert(warning, close_notify); sendAlert(*ssl, alert); ssl->useLog().ShowTCP(ssl->getSocket().get_fd(), true); - ssl->useSocket().closeSocket(); GetErrors().Remove(); @@ -415,8 +426,21 @@ int SSL_shutdown(SSL* ssl) } +/* on by default but allow user to turn off */ +long SSL_CTX_set_session_cache_mode(SSL_CTX* ctx, long mode) +{ + if (mode == SSL_SESS_CACHE_OFF) + ctx->SetSessionCacheOff(); + + return SSL_SUCCESS; +} + + SSL_SESSION* SSL_get_session(SSL* ssl) { + if (ssl->getSecurity().GetContext()->GetSessionCacheOff()) + return 0; + return GetSessions().lookup( ssl->getSecurity().get_connection().sessionID_); } @@ -424,6 +448,9 @@ SSL_SESSION* SSL_get_session(SSL* ssl) int SSL_set_session(SSL* ssl, SSL_SESSION* session) { + if (ssl->getSecurity().GetContext()->GetSessionCacheOff()) + return SSL_FAILURE; + ssl->set_session(session); return SSL_SUCCESS; } @@ -512,6 +539,19 @@ int SSL_get_error(SSL* ssl, int /*previous*/) } + +/* turn on yaSSL zlib compression + returns 0 for success, else error (not built in) + only need to turn on for client, becuase server on by default if built in + but calling for server will tell you whether it's available or not +*/ +int SSL_set_compression(SSL* ssl) +{ + return ssl->SetCompression(); +} + + + X509* SSL_get_peer_certificate(SSL* ssl) { return ssl->getCrypto().get_certManager().get_peerX509(); @@ -1359,6 +1399,56 @@ int SSL_pending(SSL* ssl) } +void SSL_CTX_set_default_passwd_cb(SSL_CTX* ctx, pem_password_cb cb) +{ + ctx->SetPasswordCb(cb); +} + + +int SSLeay_add_ssl_algorithms() // compatibility only +{ + return 1; +} + + +void ERR_remove_state(unsigned long) +{ + GetErrors().Remove(); +} + + +int ERR_GET_REASON(int l) +{ + return l & 0xfff; +} + + +unsigned long err_helper(bool peek = false) +{ + int ysError = GetErrors().Lookup(peek); + + // translate cert error for libcurl, it uses OpenSSL hex code + switch (ysError) { + case TaoCrypt::SIG_OTHER_E: + return CERTFICATE_ERROR; + break; + default : + return 0; + } +} + + +unsigned long ERR_peek_error() +{ + return err_helper(true); +} + + +unsigned long ERR_get_error() +{ + return err_helper(); +} + // functions for stunnel @@ -1477,13 +1567,6 @@ int SSL_pending(SSL* ssl) } - long SSL_CTX_set_session_cache_mode(SSL_CTX*, long) - { - // TDOD: - return SSL_SUCCESS; - } - - long SSL_CTX_set_timeout(SSL_CTX*, long) { // TDOD: @@ -1498,12 +1581,6 @@ int SSL_pending(SSL* ssl) } - void SSL_CTX_set_default_passwd_cb(SSL_CTX* ctx, pem_password_cb cb) - { - ctx->SetPasswordCb(cb); - } - - int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX*, const char*, int) { // TDOD: @@ -1555,49 +1632,6 @@ int SSL_pending(SSL* ssl) } - int SSLeay_add_ssl_algorithms() // compatibility only - { - return 1; - } - - - void ERR_remove_state(unsigned long) - { - GetErrors().Remove(); - } - - - int ERR_GET_REASON(int l) - { - return l & 0xfff; - } - - unsigned long err_helper(bool peek = false) - { - int ysError = GetErrors().Lookup(peek); - - // translate cert error for libcurl, it uses OpenSSL hex code - switch (ysError) { - case TaoCrypt::SIG_OTHER_E: - return CERTFICATE_ERROR; - break; - default : - return 0; - } - } - - - unsigned long ERR_peek_error() - { - return err_helper(true); - } - - - unsigned long ERR_get_error() - { - return err_helper(); - } - // end stunnel needs diff --git a/extra/yassl/src/yassl_error.cpp b/extra/yassl/src/yassl_error.cpp index 3531c0a2c74..25c595f40bc 100644 --- a/extra/yassl/src/yassl_error.cpp +++ b/extra/yassl/src/yassl_error.cpp @@ -133,6 +133,18 @@ void SetErrorString(YasslError error, char* buffer) strncpy(buffer, "protocl version mismatch", max); break; + case compress_error : + strncpy(buffer, "compression error", max); + break; + + case decompress_error : + strncpy(buffer, "decompression error", max); + break; + + case pms_version_error : + strncpy(buffer, "bad PreMasterSecret version error", max); + break; + // openssl errors case SSL_ERROR_WANT_READ : strncpy(buffer, "the read operation would block", max); diff --git a/extra/yassl/src/yassl_imp.cpp b/extra/yassl/src/yassl_imp.cpp index bd07f8b70f2..bf10c4b8932 100644 --- a/extra/yassl/src/yassl_imp.cpp +++ b/extra/yassl/src/yassl_imp.cpp @@ -87,7 +87,7 @@ void EncryptedPreMasterSecret::build(SSL& ssl) opaque tmp[SECRET_LEN]; memset(tmp, 0, sizeof(tmp)); ssl.getCrypto().get_random().Fill(tmp, SECRET_LEN); - ProtocolVersion pv = ssl.getSecurity().get_connection().version_; + ProtocolVersion pv = ssl.getSecurity().get_connection().chVersion_; tmp[0] = pv.major_; tmp[1] = pv.minor_; ssl.set_preMaster(tmp, SECRET_LEN); @@ -233,6 +233,10 @@ void EncryptedPreMasterSecret::read(SSL& ssl, input_buffer& input) rsa.decrypt(preMasterSecret, secret_, length_, ssl.getCrypto().get_random()); + ProtocolVersion pv = ssl.getSecurity().get_connection().chVersion_; + if (pv.major_ != preMasterSecret[0] || pv.minor_ != preMasterSecret[1]) + ssl.SetError(pms_version_error); // continue deriving for timing attack + ssl.set_preMaster(preMasterSecret, SECRET_LEN); ssl.makeMasterSecret(); } @@ -437,6 +441,7 @@ Parameters::Parameters(ConnectionEnd ce, const Ciphers& ciphers, ProtocolVersion pv, bool haveDH) : entity_(ce) { pending_ = true; // suite not set yet + strncpy(cipher_name_, "NONE", 5); if (ciphers.setSuites_) { // use user set list suites_size_ = ciphers.suiteSz_; @@ -445,6 +450,7 @@ Parameters::Parameters(ConnectionEnd ce, const Ciphers& ciphers, } else SetSuites(pv, ce == server_end && !haveDH); // defaults + } @@ -613,14 +619,18 @@ output_buffer& operator<<(output_buffer& output, const HandShakeHeader& hdr) void HandShakeHeader::Process(input_buffer& input, SSL& ssl) { ssl.verifyState(*this); + if (ssl.GetError()) return; const HandShakeFactory& hsf = ssl.getFactory().getHandShake(); mySTL::auto_ptr hs(hsf.CreateObject(type_)); if (!hs.get()) { ssl.SetError(factory_error); return; } - hashHandShake(ssl, input, c24to32(length_)); + uint len = c24to32(length_); + hashHandShake(ssl, input, len); + + hs->set_length(len); input >> *hs; hs->Process(input, ssl); } @@ -849,11 +859,17 @@ void Alert::Process(input_buffer& input, SSL& ssl) opaque mac[SHA_LEN]; input.read(mac, digestSz); + if (ssl.getSecurity().get_parms().cipher_type_ == block) { + int ivExtra = 0; opaque fill; - int padSz = ssl.getSecurity().get_parms().encrypt_size_ - aSz - - digestSz; + + if (ssl.isTLSv1_1()) + ivExtra = ssl.getCrypto().get_cipher().get_blockSize(); + int padSz = ssl.getSecurity().get_parms().encrypt_size_ - ivExtra - + aSz - digestSz; for (int i = 0; i < padSz; i++) fill = input[AUTO]; + } // verify if (memcmp(mac, verify, digestSz)) { @@ -879,9 +895,13 @@ Data::Data(uint16 len, opaque* b) {} -Data::Data(uint16 len, const opaque* w) - : length_(len), buffer_(0), write_buffer_(w) -{} +void Data::SetData(uint16 len, const opaque* buffer) +{ + assert(write_buffer_ == 0); + + length_ = len; + write_buffer_ = buffer; +} input_buffer& Data::set(input_buffer& in) { @@ -907,17 +927,12 @@ uint16 Data::get_length() const } -const opaque* Data::get_buffer() const -{ - return write_buffer_; -} - - void Data::set_length(uint16 l) { length_ = l; } + opaque* Data::set_buffer() { return buffer_; @@ -937,27 +952,42 @@ void Data::Process(input_buffer& input, SSL& ssl) { int msgSz = ssl.getSecurity().get_parms().encrypt_size_; int pad = 0, padByte = 0; + int ivExtra = 0; + if (ssl.getSecurity().get_parms().cipher_type_ == block) { - pad = *(input.get_buffer() + input.get_current() + msgSz - 1); + if (ssl.isTLSv1_1()) // IV + ivExtra = ssl.getCrypto().get_cipher().get_blockSize(); + pad = *(input.get_buffer() + input.get_current() + msgSz -ivExtra - 1); padByte = 1; } int digestSz = ssl.getCrypto().get_digest().get_digestSize(); - int dataSz = msgSz - digestSz - pad - padByte; + int dataSz = msgSz - ivExtra - digestSz - pad - padByte; opaque verify[SHA_LEN]; + const byte* rawData = input.get_buffer() + input.get_current(); + // read data - if (dataSz) { + if (dataSz) { // could be compressed + if (ssl.CompressionOn()) { + input_buffer tmp; + if (DeCompress(input, dataSz, tmp) == -1) { + ssl.SetError(decompress_error); + return; + } + ssl.addData(NEW_YS input_buffer(tmp.get_size(), + tmp.get_buffer(), tmp.get_size())); + } + else { input_buffer* data; ssl.addData(data = NEW_YS input_buffer(dataSz)); input.read(data->get_buffer(), dataSz); data->add_size(dataSz); + } if (ssl.isTLS()) - TLS_hmac(ssl, verify, data->get_buffer(), dataSz, application_data, - true); + TLS_hmac(ssl, verify, rawData, dataSz, application_data, true); else - hmac(ssl, verify, data->get_buffer(), dataSz, application_data, - true); + hmac(ssl, verify, rawData, dataSz, application_data, true); } // read mac and fill @@ -1220,6 +1250,13 @@ void ServerHello::Process(input_buffer&, SSL& ssl) if (ssl.isTLS() && server_version_.minor_ < 1) // downgrade to SSLv3 ssl.useSecurity().use_connection().TurnOffTLS(); + else if (ssl.isTLSv1_1() && server_version_.minor_ == 1) + // downdrage to TLSv1 + ssl.useSecurity().use_connection().TurnOffTLS1_1(); + } + else if (ssl.isTLSv1_1() && server_version_.minor_ < 2) { + ssl.SetError(badVersion_error); + return; } else if (ssl.isTLS() && server_version_.minor_ < 1) { ssl.SetError(badVersion_error); @@ -1252,6 +1289,10 @@ void ServerHello::Process(input_buffer&, SSL& ssl) ssl.useSecurity().set_resuming(false); ssl.useLog().Trace("server denied resumption"); } + + if (ssl.CompressionOn() && !compression_method_) + ssl.UnSetCompression(); // server isn't supporting yaSSL zlib request + ssl.useStates().useClient() = serverHelloComplete; } @@ -1263,8 +1304,9 @@ ServerHello::ServerHello() } -ServerHello::ServerHello(ProtocolVersion pv) - : server_version_(pv) +ServerHello::ServerHello(ProtocolVersion pv, bool useCompression) + : server_version_(pv), + compression_method_(useCompression ? zlib : no_compression) { memset(random_, 0, RAN_LEN); memset(session_id_, 0, ID_LEN); @@ -1341,6 +1383,8 @@ opaque* ClientKeyBase::get_clientKey() const // input operator for Client Hello input_buffer& operator>>(input_buffer& input, ClientHello& hello) { + uint begin = input.get_current(); // could have extensions at end + // Protocol hello.client_version_.major_ = input[AUTO]; hello.client_version_.minor_ = input[AUTO]; @@ -1361,8 +1405,19 @@ input_buffer& operator>>(input_buffer& input, ClientHello& hello) // Compression hello.comp_len_ = input[AUTO]; - while (hello.comp_len_--) // ignore for now - hello.compression_methods_ = CompressionMethod(input[AUTO]); + hello.compression_methods_ = no_compression; + while (hello.comp_len_--) { + CompressionMethod cm = CompressionMethod(input[AUTO]); + if (cm == zlib) + hello.compression_methods_ = zlib; + } + + uint read = input.get_current() - begin; + uint expected = hello.get_length(); + + // ignore client hello extensions for now + if (read < expected) + input.set_current(input.get_current() + expected - read); return input; } @@ -1400,6 +1455,13 @@ output_buffer& operator<<(output_buffer& output, const ClientHello& hello) // Client Hello processing handler void ClientHello::Process(input_buffer&, SSL& ssl) { + // store version for pre master secret + ssl.useSecurity().use_connection().chVersion_ = client_version_; + + if (client_version_.major_ != 3) { + ssl.SetError(badVersion_error); + return; + } if (ssl.GetMultiProtocol()) { // SSLv23 support if (ssl.isTLS() && client_version_.minor_ < 1) { // downgrade to SSLv3 @@ -1407,20 +1469,29 @@ void ClientHello::Process(input_buffer&, SSL& ssl) ProtocolVersion pv = ssl.getSecurity().get_connection().version_; ssl.useSecurity().use_parms().SetSuites(pv); // reset w/ SSL suites } + else if (ssl.isTLSv1_1() && client_version_.minor_ == 1) + // downgrade to TLSv1, but use same suites + ssl.useSecurity().use_connection().TurnOffTLS1_1(); + } + else if (ssl.isTLSv1_1() && client_version_.minor_ < 2) { + ssl.SetError(badVersion_error); + return; } else if (ssl.isTLS() && client_version_.minor_ < 1) { ssl.SetError(badVersion_error); return; } - else if (!ssl.isTLS() && (client_version_.major_ == 3 && - client_version_.minor_ >= 1)) { + else if (!ssl.isTLS() && client_version_.minor_ >= 1) { ssl.SetError(badVersion_error); return; } + ssl.set_random(random_, client_end); while (id_len_) { // trying to resume - SSL_SESSION* session = GetSessions().lookup(session_id_); + SSL_SESSION* session = 0; + if (!ssl.getSecurity().GetContext()->GetSessionCacheOff()) + session = GetSessions().lookup(session_id_); if (!session) { ssl.useLog().Trace("session lookup failed"); break; @@ -1444,6 +1515,9 @@ void ClientHello::Process(input_buffer&, SSL& ssl) ssl.matchSuite(cipher_suites_, suite_len_); ssl.set_pending(ssl.getSecurity().get_parms().suite_[1]); + if (compression_methods_ == zlib) + ssl.SetCompression(); + ssl.useStates().useServer() = clientHelloComplete; } @@ -1478,8 +1552,9 @@ ClientHello::ClientHello() } -ClientHello::ClientHello(ProtocolVersion pv) - : client_version_(pv) +ClientHello::ClientHello(ProtocolVersion pv, bool useCompression) + : client_version_(pv), + compression_methods_(useCompression ? zlib : no_compression) { memset(random_, 0, RAN_LEN); } @@ -1943,8 +2018,13 @@ void Finished::Process(input_buffer& input, SSL& ssl) int digestSz = ssl.getCrypto().get_digest().get_digestSize(); input.read(mac, digestSz); + uint ivExtra = 0; + if (ssl.getSecurity().get_parms().cipher_type_ == block) + if (ssl.isTLSv1_1()) + ivExtra = ssl.getCrypto().get_cipher().get_blockSize(); + opaque fill; - int padSz = ssl.getSecurity().get_parms().encrypt_size_ - + int padSz = ssl.getSecurity().get_parms().encrypt_size_ - ivExtra - HANDSHAKE_HEADER - finishedSz - digestSz; for (int i = 0; i < padSz; i++) fill = input[AUTO]; @@ -2018,7 +2098,9 @@ void clean(volatile opaque* p, uint sz, RandomPool& ran) Connection::Connection(ProtocolVersion v, RandomPool& ran) : pre_master_secret_(0), sequence_number_(0), peer_sequence_number_(0), pre_secret_len_(0), send_server_key_(false), master_clean_(false), - TLS_(v.major_ >= 3 && v.minor_ >= 1), version_(v), random_(ran) + TLS_(v.major_ >= 3 && v.minor_ >= 1), + TLSv1_1_(v.major_ >= 3 && v.minor_ >= 2), compression_(false), + version_(v), random_(ran) { memset(sessionID_, 0, sizeof(sessionID_)); } @@ -2043,6 +2125,13 @@ void Connection::TurnOffTLS() } +void Connection::TurnOffTLS1_1() +{ + TLSv1_1_ = false; + version_.minor_ = 1; +} + + // wipeout master secret void Connection::CleanMaster() { diff --git a/extra/yassl/src/yassl_int.cpp b/extra/yassl/src/yassl_int.cpp index 5288acb2bcd..1a407ca8ba5 100644 --- a/extra/yassl/src/yassl_int.cpp +++ b/extra/yassl/src/yassl_int.cpp @@ -38,6 +38,11 @@ #endif +#ifdef HAVE_LIBZ + #include "zlib.h" +#endif + + #ifdef YASSL_PURE_C void* operator new(size_t sz, yaSSL::new_t) @@ -727,6 +732,32 @@ void SSL::set_preMaster(const opaque* pre, uint sz) } +// set yaSSL zlib type compression +int SSL::SetCompression() +{ +#ifdef HAVE_LIBZ + secure_.use_connection().compression_ = true; + return 0; +#else + return -1; // not built in +#endif +} + + +// unset yaSSL zlib type compression +void SSL::UnSetCompression() +{ + secure_.use_connection().compression_ = false; +} + + +// is yaSSL zlib compression on +bool SSL::CompressionOn() const +{ + return secure_.get_connection().compression_; +} + + // store master secret void SSL::set_masterSecret(const opaque* sec) { @@ -1109,6 +1140,11 @@ void SSL::verifyState(const RecordLayerHeader& rlHeader) { if (GetError()) return; + if (rlHeader.version_.major_ != 3 || rlHeader.version_.minor_ > 2) { + SetError(badVersion_error); + return; + } + if (states_.getRecord() == recordNotReady || (rlHeader.type_ == application_data && // data and handshake states_.getHandShake() != handShakeReady) ) // isn't complete yet @@ -1247,6 +1283,9 @@ void SSL::matchSuite(const opaque* peer, uint length) void SSL::set_session(SSL_SESSION* s) { + if (getSecurity().GetContext()->GetSessionCacheOff()) + return; + if (s && GetSessions().lookup(s->GetID(), &secure_.use_resume())) { secure_.set_resuming(true); crypto_.use_certManager().setPeerX509(s->GetPeerX509()); @@ -1344,6 +1383,12 @@ bool SSL::isTLS() const } +bool SSL::isTLSv1_1() const +{ + return secure_.get_connection().TLSv1_1_; +} + + void SSL::addData(input_buffer* data) { buffers_.useData().push_back(data); @@ -1703,7 +1748,7 @@ bool SSL_METHOD::multipleProtocol() const SSL_CTX::SSL_CTX(SSL_METHOD* meth) : method_(meth), certificate_(0), privateKey_(0), passwordCb_(0), - userData_(0) + userData_(0), sessionCacheOff_(false) {} @@ -1784,12 +1829,24 @@ void* SSL_CTX::GetUserData() const } +bool SSL_CTX::GetSessionCacheOff() const +{ + return sessionCacheOff_; +} + + void SSL_CTX::SetUserData(void* data) { userData_ = data; } +void SSL_CTX::SetSessionCacheOff() +{ + sessionCacheOff_ = true; +} + + void SSL_CTX::setVerifyPeer() { method_->setVerifyPeer(); @@ -2312,9 +2369,110 @@ ASN1_STRING* StringHolder::GetString() } +#ifdef HAVE_LIBZ + + void* myAlloc(void* /* opaque */, unsigned int item, unsigned int size) + { + return NEW_YS unsigned char[item * size]; + } + + + void myFree(void* /* opaque */, void* memory) + { + unsigned char* ptr = static_cast(memory); + yaSSL::ysArrayDelete(ptr); + } + + + // put size in front of compressed data + int Compress(const byte* in, int sz, input_buffer& buffer) + { + byte tmp[LENGTH_SZ]; + z_stream c_stream; /* compression stream */ + + buffer.allocate(sz + sizeof(uint16) + COMPRESS_EXTRA); + + c_stream.zalloc = myAlloc; + c_stream.zfree = myFree; + c_stream.opaque = (voidpf)0; + + c_stream.next_in = const_cast(in); + c_stream.avail_in = sz; + c_stream.next_out = buffer.get_buffer() + sizeof(tmp); + c_stream.avail_out = buffer.get_capacity() - sizeof(tmp); + + if (deflateInit(&c_stream, 8) != Z_OK) return -1; + int err = deflate(&c_stream, Z_FINISH); + deflateEnd(&c_stream); + if (err != Z_OK && err != Z_STREAM_END) return -1; + + c16toa(sz, tmp); + memcpy(buffer.get_buffer(), tmp, sizeof(tmp)); + buffer.add_size(c_stream.total_out + sizeof(tmp)); + + return 0; + } + + + // get uncompressed size in front + int DeCompress(input_buffer& in, int sz, input_buffer& out) + { + byte tmp[LENGTH_SZ]; + + in.read(tmp, sizeof(tmp)); + + uint16 len; + ato16(tmp, len); + + out.allocate(len); + + z_stream d_stream; /* decompression stream */ + + d_stream.zalloc = myAlloc; + d_stream.zfree = myFree; + d_stream.opaque = (voidpf)0; + + d_stream.next_in = in.get_buffer() + in.get_current(); + d_stream.avail_in = sz - sizeof(tmp); + d_stream.next_out = out.get_buffer(); + d_stream.avail_out = out.get_capacity(); + + if (inflateInit(&d_stream) != Z_OK) return -1; + int err = inflate(&d_stream, Z_FINISH); + inflateEnd(&d_stream); + if (err != Z_OK && err != Z_STREAM_END) return -1; + + out.add_size(d_stream.total_out); + in.set_current(in.get_current() + sz - sizeof(tmp)); + + return 0; + } + + +#else // LIBZ + + // these versions should never get called + int Compress(const byte* in, int sz, input_buffer& buffer) + { + assert(0); + return -1; + } + + + int DeCompress(input_buffer& in, int sz, input_buffer& out) + { + assert(0); + return -1; + } + + +#endif // LIBZ + + } // namespace + extern "C" void yaSSL_CleanUp() { TaoCrypt::CleanUp(); diff --git a/extra/yassl/taocrypt/benchmark/make.bat b/extra/yassl/taocrypt/benchmark/make.bat index 4ebe4b32417..bf1383f5e97 100644 --- a/extra/yassl/taocrypt/benchmark/make.bat +++ b/extra/yassl/taocrypt/benchmark/make.bat @@ -1,7 +1,7 @@ REM quick and dirty build file for testing different MSDEVs setlocal -set myFLAGS= /I../include /I../../mySTL /c /W3 /G6 /O2 +set myFLAGS= /I../include /I../mySTL /c /W3 /G6 /O2 cl %myFLAGS% benchmark.cpp diff --git a/extra/yassl/taocrypt/include/aes.hpp b/extra/yassl/taocrypt/include/aes.hpp index cb70f5c0e7e..5c53fc39411 100644 --- a/extra/yassl/taocrypt/include/aes.hpp +++ b/extra/yassl/taocrypt/include/aes.hpp @@ -34,6 +34,12 @@ #include "modes.hpp" +#if defined(TAOCRYPT_X86ASM_AVAILABLE) && defined(TAO_ASM) + #define DO_AES_ASM +#endif + + + namespace TaoCrypt { @@ -46,15 +52,14 @@ public: enum { BLOCK_SIZE = AES_BLOCK_SIZE }; AES(CipherDir DIR, Mode MODE) - : Mode_BASE(BLOCK_SIZE), dir_(DIR), mode_(MODE) {} + : Mode_BASE(BLOCK_SIZE, DIR, MODE) {} +#ifdef DO_AES_ASM void Process(byte*, const byte*, word32); +#endif void SetKey(const byte* key, word32 sz, CipherDir fake = ENCRYPTION); void SetIV(const byte* iv) { memcpy(r_, iv, BLOCK_SIZE); } private: - CipherDir dir_; - Mode mode_; - static const word32 rcon_[]; word32 rounds_; diff --git a/extra/yassl/taocrypt/include/algebra.hpp b/extra/yassl/taocrypt/include/algebra.hpp index 07fc405f093..9cfbcf06ece 100644 --- a/extra/yassl/taocrypt/include/algebra.hpp +++ b/extra/yassl/taocrypt/include/algebra.hpp @@ -75,7 +75,8 @@ public: typedef Integer Element; AbstractRing() : AbstractGroup() {m_mg.m_pRing = this;} - AbstractRing(const AbstractRing &source) {m_mg.m_pRing = this;} + AbstractRing(const AbstractRing &source) : AbstractGroup() + {m_mg.m_pRing = this;} AbstractRing& operator=(const AbstractRing &source) {return *this;} virtual bool IsUnit(const Element &a) const =0; diff --git a/extra/yassl/taocrypt/include/arc4.hpp b/extra/yassl/taocrypt/include/arc4.hpp index 05b0921f5a1..ddd5082f557 100644 --- a/extra/yassl/taocrypt/include/arc4.hpp +++ b/extra/yassl/taocrypt/include/arc4.hpp @@ -46,7 +46,6 @@ public: ARC4() {} void Process(byte*, const byte*, word32); - void AsmProcess(byte*, const byte*, word32); void SetKey(const byte*, word32); private: byte x_; @@ -55,6 +54,8 @@ private: ARC4(const ARC4&); // hide copy const ARC4 operator=(const ARC4&); // and assign + + void AsmProcess(byte*, const byte*, word32); }; } // namespace diff --git a/extra/yassl/taocrypt/include/asn.hpp b/extra/yassl/taocrypt/include/asn.hpp index dbee54be6f1..1151f3c944e 100644 --- a/extra/yassl/taocrypt/include/asn.hpp +++ b/extra/yassl/taocrypt/include/asn.hpp @@ -34,7 +34,11 @@ #include "misc.hpp" #include "block.hpp" #include "error.hpp" -#include STL_LIST_FILE +#ifdef USE_SYS_STL + #include +#else + #include "list.hpp" +#endif namespace STL = STL_NAMESPACE; diff --git a/extra/yassl/taocrypt/include/block.hpp b/extra/yassl/taocrypt/include/block.hpp index a931158a83d..0cf27d0b6b5 100644 --- a/extra/yassl/taocrypt/include/block.hpp +++ b/extra/yassl/taocrypt/include/block.hpp @@ -34,7 +34,12 @@ #include "misc.hpp" #include // memcpy #include // ptrdiff_t -#include STL_ALGORITHM_FILE + +#ifdef USE_SYS_STL + #include +#else + #include "algorithm.hpp" +#endif namespace STL = STL_NAMESPACE; diff --git a/extra/yassl/taocrypt/include/blowfish.hpp b/extra/yassl/taocrypt/include/blowfish.hpp index 40953624232..4d6ad1b034b 100644 --- a/extra/yassl/taocrypt/include/blowfish.hpp +++ b/extra/yassl/taocrypt/include/blowfish.hpp @@ -32,12 +32,21 @@ #include "misc.hpp" #include "modes.hpp" -#include STL_ALGORITHM_FILE +#ifdef USE_SYS_STL + #include +#else + #include "algorithm.hpp" +#endif namespace STL = STL_NAMESPACE; +#if defined(TAOCRYPT_X86ASM_AVAILABLE) && defined(TAO_ASM) + #define DO_BLOWFISH_ASM +#endif + + namespace TaoCrypt { enum { BLOWFISH_BLOCK_SIZE = 8 }; @@ -49,15 +58,14 @@ public: enum { BLOCK_SIZE = BLOWFISH_BLOCK_SIZE, ROUNDS = 16 }; Blowfish(CipherDir DIR, Mode MODE) - : Mode_BASE(BLOCK_SIZE), dir_(DIR), mode_(MODE) {} + : Mode_BASE(BLOCK_SIZE, DIR, MODE) {} +#ifdef DO_BLOWFISH_ASM void Process(byte*, const byte*, word32); +#endif void SetKey(const byte* key, word32 sz, CipherDir fake = ENCRYPTION); void SetIV(const byte* iv) { memcpy(r_, iv, BLOCK_SIZE); } private: - CipherDir dir_; - Mode mode_; - static const word32 p_init_[ROUNDS + 2]; static const word32 s_init_[4 * 256]; diff --git a/extra/yassl/taocrypt/include/des.hpp b/extra/yassl/taocrypt/include/des.hpp index 48bb1e9119d..19273821f98 100644 --- a/extra/yassl/taocrypt/include/des.hpp +++ b/extra/yassl/taocrypt/include/des.hpp @@ -34,6 +34,12 @@ #include "misc.hpp" #include "modes.hpp" + +#if defined(TAOCRYPT_X86ASM_AVAILABLE) && defined(TAO_ASM) + #define DO_DES_ASM +#endif + + namespace TaoCrypt { @@ -53,13 +59,9 @@ protected: class DES : public Mode_BASE, public BasicDES { public: DES(CipherDir DIR, Mode MODE) - : Mode_BASE(DES_BLOCK_SIZE), dir_(DIR), mode_(MODE) {} + : Mode_BASE(DES_BLOCK_SIZE, DIR, MODE) {} - void Process(byte*, const byte*, word32); private: - CipherDir dir_; - Mode mode_; - void ProcessAndXorBlock(const byte*, const byte*, byte*) const; DES(const DES&); // hide copy @@ -71,14 +73,10 @@ private: class DES_EDE2 : public Mode_BASE { public: DES_EDE2(CipherDir DIR, Mode MODE) - : Mode_BASE(DES_BLOCK_SIZE), dir_(DIR), mode_(MODE) {} + : Mode_BASE(DES_BLOCK_SIZE, DIR, MODE) {} void SetKey(const byte*, word32, CipherDir dir); - void Process(byte*, const byte*, word32); private: - CipherDir dir_; - Mode mode_; - BasicDES des1_; BasicDES des2_; @@ -94,15 +92,14 @@ private: class DES_EDE3 : public Mode_BASE { public: DES_EDE3(CipherDir DIR, Mode MODE) - : Mode_BASE(DES_BLOCK_SIZE), dir_(DIR), mode_(MODE) {} + : Mode_BASE(DES_BLOCK_SIZE, DIR, MODE) {} void SetKey(const byte*, word32, CipherDir dir); void SetIV(const byte* iv) { memcpy(r_, iv, DES_BLOCK_SIZE); } +#ifdef DO_DES_ASM void Process(byte*, const byte*, word32); +#endif private: - CipherDir dir_; - Mode mode_; - BasicDES des1_; BasicDES des2_; BasicDES des3_; diff --git a/extra/yassl/taocrypt/include/integer.hpp b/extra/yassl/taocrypt/include/integer.hpp index 70b4dc79e73..751c79102c4 100644 --- a/extra/yassl/taocrypt/include/integer.hpp +++ b/extra/yassl/taocrypt/include/integer.hpp @@ -45,7 +45,11 @@ #include "random.hpp" #include "file.hpp" #include -#include STL_ALGORITHM_FILE +#ifdef USE_SYS_STL + #include +#else + #include "algorithm.hpp" +#endif #ifdef TAOCRYPT_X86ASM_AVAILABLE @@ -67,7 +71,8 @@ #endif // SSE2 intrinsics work in GCC 3.3 or later -#if defined(__SSE2__) && (__GNUC_MAJOR__ > 3 || __GNUC_MINOR__ > 2) +#if defined(__SSE2__) && (__GNUC__ == 4 || __GNUC_MAJOR__ > 3 || \ + __GNUC_MINOR__ > 2) #define SSE2_INTRINSICS_AVAILABLE #endif @@ -106,7 +111,6 @@ namespace TaoCrypt { #endif }; - template class TAOCRYPT_DLL AlignedAllocator; typedef Block > AlignedWordBlock; #else typedef WordBlock AlignedWordBlock; diff --git a/extra/yassl/taocrypt/include/md5.hpp b/extra/yassl/taocrypt/include/md5.hpp index 30d14d54fbf..f607a922155 100644 --- a/extra/yassl/taocrypt/include/md5.hpp +++ b/extra/yassl/taocrypt/include/md5.hpp @@ -31,6 +31,11 @@ #include "hash.hpp" + +#if defined(TAOCRYPT_X86ASM_AVAILABLE) && defined(TAO_ASM) + #define DO_MD5_ASM +#endif + namespace TaoCrypt { @@ -49,7 +54,9 @@ public: MD5(const MD5&); MD5& operator= (const MD5&); +#ifdef DO_MD5_ASM void Update(const byte*, word32); +#endif void Init(); void Swap(MD5&); diff --git a/extra/yassl/taocrypt/include/misc.hpp b/extra/yassl/taocrypt/include/misc.hpp index 3d2d4c62466..cc20b60d528 100644 --- a/extra/yassl/taocrypt/include/misc.hpp +++ b/extra/yassl/taocrypt/include/misc.hpp @@ -151,6 +151,17 @@ void CleanUp(); #endif +#ifdef TAOCRYPT_X86ASM_AVAILABLE + bool HaveCpuId(); + bool IsPentium(); + void CpuId(word32 input, word32 *output); + + extern bool isMMX; +#endif + + + + // Turn on ia32 ASM for Ciphers and Message Digests // Seperate define since these are more complex, use member offsets // and user may want to turn off while leaving Big Integer optos on @@ -200,17 +211,9 @@ void CleanUp(); #ifdef USE_SYS_STL // use system STL - #define STL_VECTOR_FILE - #define STL_LIST_FILE - #define STL_ALGORITHM_FILE - #define STL_MEMORY_FILE #define STL_NAMESPACE std #else // use mySTL - #define STL_VECTOR_FILE "vector.hpp" - #define STL_LIST_FILE "list.hpp" - #define STL_ALGORITHM_FILE "algorithm.hpp" - #define STL_MEMORY_FILE "memory.hpp" #define STL_NAMESPACE mySTL #endif diff --git a/extra/yassl/taocrypt/include/modes.hpp b/extra/yassl/taocrypt/include/modes.hpp index 65b7318661e..d77f855385c 100644 --- a/extra/yassl/taocrypt/include/modes.hpp +++ b/extra/yassl/taocrypt/include/modes.hpp @@ -38,6 +38,7 @@ namespace TaoCrypt { enum Mode { ECB, CBC }; + // BlockCipher abstraction template class BlockCipher { @@ -63,14 +64,16 @@ class Mode_BASE : public virtual_base { public: enum { MaxBlockSz = 16 }; - explicit Mode_BASE(int sz) + explicit Mode_BASE(int sz, CipherDir dir, Mode mode) : blockSz_(sz), reg_(reinterpret_cast(r_)), - tmp_(reinterpret_cast(t_)) + tmp_(reinterpret_cast(t_)), dir_(dir), mode_(mode) { assert(sz <= MaxBlockSz); } virtual ~Mode_BASE() {} + virtual void Process(byte*, const byte*, word32); + void SetIV(const byte* iv) { memcpy(reg_, iv, blockSz_); } protected: int blockSz_; @@ -80,6 +83,9 @@ protected: word32 r_[MaxBlockSz / sizeof(word32)]; // align reg_ on word32 word32 t_[MaxBlockSz / sizeof(word32)]; // align tmp_ on word32 + CipherDir dir_; + Mode mode_; + void ECB_Process(byte*, const byte*, word32); void CBC_Encrypt(byte*, const byte*, word32); void CBC_Decrypt(byte*, const byte*, word32); @@ -92,6 +98,18 @@ private: }; +inline void Mode_BASE::Process(byte* out, const byte* in, word32 sz) +{ + if (mode_ == ECB) + ECB_Process(out, in, sz); + else if (mode_ == CBC) + if (dir_ == ENCRYPTION) + CBC_Encrypt(out, in, sz); + else + CBC_Decrypt(out, in, sz); +} + + // ECB Process blocks inline void Mode_BASE::ECB_Process(byte* out, const byte* in, word32 sz) { diff --git a/extra/yassl/taocrypt/include/ripemd.hpp b/extra/yassl/taocrypt/include/ripemd.hpp index 2e594b7604d..5d443769662 100644 --- a/extra/yassl/taocrypt/include/ripemd.hpp +++ b/extra/yassl/taocrypt/include/ripemd.hpp @@ -31,6 +31,11 @@ #include "hash.hpp" + +#if defined(TAOCRYPT_X86ASM_AVAILABLE) && defined(TAO_ASM) + #define DO_RIPEMD_ASM +#endif + namespace TaoCrypt { @@ -49,7 +54,9 @@ public: RIPEMD160(const RIPEMD160&); RIPEMD160& operator= (const RIPEMD160&); +#ifdef DO_RIPEMD_ASM void Update(const byte*, word32); +#endif void Init(); void Swap(RIPEMD160&); private: diff --git a/extra/yassl/taocrypt/include/rsa.hpp b/extra/yassl/taocrypt/include/rsa.hpp index 1b531b9d0c0..c33e21b76a3 100644 --- a/extra/yassl/taocrypt/include/rsa.hpp +++ b/extra/yassl/taocrypt/include/rsa.hpp @@ -239,7 +239,8 @@ bool RSA_Encryptor::SSL_Verify(const byte* message, word32 sz, const byte* sig) { ByteBlock plain(PK_Lengths(key_.GetModulus()).FixedMaxPlaintextLength()); - SSL_Decrypt(key_, sig, plain.get_buffer()); + if (SSL_Decrypt(key_, sig, plain.get_buffer()) != sz) + return false; // not right justified or bad padding if ( (memcmp(plain.get_buffer(), message, sz)) == 0) return true; diff --git a/extra/yassl/taocrypt/include/sha.hpp b/extra/yassl/taocrypt/include/sha.hpp index 2d65932dc17..510c516b1a4 100644 --- a/extra/yassl/taocrypt/include/sha.hpp +++ b/extra/yassl/taocrypt/include/sha.hpp @@ -31,6 +31,11 @@ #include "hash.hpp" + +#if defined(TAOCRYPT_X86ASM_AVAILABLE) && defined(TAO_ASM) + #define DO_SHA_ASM +#endif + namespace TaoCrypt { @@ -46,7 +51,9 @@ public: word32 getDigestSize() const { return DIGEST_SIZE; } word32 getPadSize() const { return PAD_SIZE; } +#ifdef DO_SHA_ASM void Update(const byte* data, word32 len); +#endif void Init(); SHA(const SHA&); diff --git a/extra/yassl/taocrypt/include/twofish.hpp b/extra/yassl/taocrypt/include/twofish.hpp index ba144d2defb..8cad4923262 100644 --- a/extra/yassl/taocrypt/include/twofish.hpp +++ b/extra/yassl/taocrypt/include/twofish.hpp @@ -32,12 +32,20 @@ #include "misc.hpp" #include "modes.hpp" -#include STL_ALGORITHM_FILE +#ifdef USE_SYS_STL + #include +#else + #include "algorithm.hpp" +#endif namespace STL = STL_NAMESPACE; +#if defined(TAOCRYPT_X86ASM_AVAILABLE) && defined(TAO_ASM) + #define DO_TWOFISH_ASM +#endif + namespace TaoCrypt { enum { TWOFISH_BLOCK_SIZE = 16 }; @@ -49,15 +57,14 @@ public: enum { BLOCK_SIZE = TWOFISH_BLOCK_SIZE }; Twofish(CipherDir DIR, Mode MODE) - : Mode_BASE(BLOCK_SIZE), dir_(DIR), mode_(MODE) {} + : Mode_BASE(BLOCK_SIZE, DIR, MODE) {} +#ifdef DO_TWOFISH_ASM void Process(byte*, const byte*, word32); +#endif void SetKey(const byte* key, word32 sz, CipherDir fake = ENCRYPTION); void SetIV(const byte* iv) { memcpy(r_, iv, BLOCK_SIZE); } private: - CipherDir dir_; - Mode mode_; - static const byte q_[2][256]; static const word32 mds_[4][256]; diff --git a/extra/yassl/taocrypt/src/aes.cpp b/extra/yassl/taocrypt/src/aes.cpp index 574a88a736c..2940f06c074 100644 --- a/extra/yassl/taocrypt/src/aes.cpp +++ b/extra/yassl/taocrypt/src/aes.cpp @@ -34,33 +34,19 @@ #include "aes.hpp" -#if defined(TAOCRYPT_X86ASM_AVAILABLE) && defined(TAO_ASM) - #define DO_AES_ASM -#endif - - namespace TaoCrypt { -#if !defined(DO_AES_ASM) - -// Generic Version -void AES::Process(byte* out, const byte* in, word32 sz) -{ - if (mode_ == ECB) - ECB_Process(out, in, sz); - else if (mode_ == CBC) - if (dir_ == ENCRYPTION) - CBC_Encrypt(out, in, sz); - else - CBC_Decrypt(out, in, sz); -} - -#else +#if defined(DO_AES_ASM) // ia32 optimized version void AES::Process(byte* out, const byte* in, word32 sz) { + if (!isMMX) { + Mode_BASE::Process(out, in, sz); + return; + } + word32 blocks = sz / BLOCK_SIZE; if (mode_ == ECB) diff --git a/extra/yassl/taocrypt/src/algebra.cpp b/extra/yassl/taocrypt/src/algebra.cpp index 375cd6cd524..76c4e99323d 100644 --- a/extra/yassl/taocrypt/src/algebra.cpp +++ b/extra/yassl/taocrypt/src/algebra.cpp @@ -29,7 +29,11 @@ #include "runtime.hpp" #include "algebra.hpp" -#include STL_VECTOR_FILE +#ifdef USE_SYS_STL + #include +#else + #include "vector.hpp" +#endif namespace STL = STL_NAMESPACE; diff --git a/extra/yassl/taocrypt/src/arc4.cpp b/extra/yassl/taocrypt/src/arc4.cpp index ea1e084014c..90b5170c59e 100644 --- a/extra/yassl/taocrypt/src/arc4.cpp +++ b/extra/yassl/taocrypt/src/arc4.cpp @@ -80,12 +80,18 @@ inline unsigned int MakeByte(word32& x, word32& y, byte* s) } // namespace -#ifndef DO_ARC4_ASM void ARC4::Process(byte* out, const byte* in, word32 length) { if (length == 0) return; +#ifdef DO_ARC4_ASM + if (isMMX) { + AsmProcess(out, in, length); + return; + } +#endif + byte *const s = state_; word32 x = x_; word32 y = y_; @@ -100,13 +106,16 @@ void ARC4::Process(byte* out, const byte* in, word32 length) y_ = y; } -#else // DO_ARC4_ASM +#ifdef DO_ARC4_ASM + #ifdef _MSC_VER __declspec(naked) +#else + __attribute__ ((noinline)) #endif -void ARC4::Process(byte* out, const byte* in, word32 length) +void ARC4::AsmProcess(byte* out, const byte* in, word32 length) { #ifdef __GNUC__ #define AS1(x) asm(#x); diff --git a/extra/yassl/taocrypt/src/blowfish.cpp b/extra/yassl/taocrypt/src/blowfish.cpp index 40ae1a17e6c..d736292fb19 100644 --- a/extra/yassl/taocrypt/src/blowfish.cpp +++ b/extra/yassl/taocrypt/src/blowfish.cpp @@ -37,34 +37,21 @@ -#if defined(TAOCRYPT_X86ASM_AVAILABLE) && defined(TAO_ASM) - #define DO_BLOWFISH_ASM -#endif - namespace TaoCrypt { -#if !defined(DO_BLOWFISH_ASM) - -// Generic Version -void Blowfish::Process(byte* out, const byte* in, word32 sz) -{ - if (mode_ == ECB) - ECB_Process(out, in, sz); - else if (mode_ == CBC) - if (dir_ == ENCRYPTION) - CBC_Encrypt(out, in, sz); - else - CBC_Decrypt(out, in, sz); -} - -#else +#if defined(DO_BLOWFISH_ASM) // ia32 optimized version void Blowfish::Process(byte* out, const byte* in, word32 sz) { + if (!isMMX) { + Mode_BASE::Process(out, in, sz); + return; + } + word32 blocks = sz / BLOCK_SIZE; if (mode_ == ECB) diff --git a/extra/yassl/taocrypt/src/des.cpp b/extra/yassl/taocrypt/src/des.cpp index 2628e142bae..94428ac587e 100644 --- a/extra/yassl/taocrypt/src/des.cpp +++ b/extra/yassl/taocrypt/src/des.cpp @@ -34,16 +34,16 @@ #include "runtime.hpp" #include "des.hpp" -#include STL_ALGORITHM_FILE +#ifdef USE_SYS_STL + #include +#else + #include "algorithm.hpp" +#endif namespace STL = STL_NAMESPACE; -#if defined(TAOCRYPT_X86ASM_AVAILABLE) && defined(TAO_ASM) - #define DO_DES_ASM -#endif - namespace TaoCrypt { @@ -357,18 +357,6 @@ void BasicDES::RawProcessBlock(word32& lIn, word32& rIn) const } -void DES::Process(byte* out, const byte* in, word32 sz) -{ - if (mode_ == ECB) - ECB_Process(out, in, sz); - else if (mode_ == CBC) - if (dir_ == ENCRYPTION) - CBC_Encrypt(out, in, sz); - else - CBC_Decrypt(out, in, sz); -} - - typedef BlockGetAndPut Block; @@ -386,17 +374,6 @@ void DES::ProcessAndXorBlock(const byte* in, const byte* xOr, byte* out) const } -void DES_EDE2::Process(byte* out, const byte* in, word32 sz) -{ - if (mode_ == ECB) - ECB_Process(out, in, sz); - else if (mode_ == CBC) - if (dir_ == ENCRYPTION) - CBC_Encrypt(out, in, sz); - else - CBC_Decrypt(out, in, sz); -} - void DES_EDE2::SetKey(const byte* key, word32 sz, CipherDir dir) { des1_.SetKey(key, sz, dir); @@ -429,25 +406,16 @@ void DES_EDE3::SetKey(const byte* key, word32 sz, CipherDir dir) -#if !defined(DO_DES_ASM) - -// Generic Version -void DES_EDE3::Process(byte* out, const byte* in, word32 sz) -{ - if (mode_ == ECB) - ECB_Process(out, in, sz); - else if (mode_ == CBC) - if (dir_ == ENCRYPTION) - CBC_Encrypt(out, in, sz); - else - CBC_Decrypt(out, in, sz); -} - -#else +#if defined(DO_DES_ASM) // ia32 optimized version void DES_EDE3::Process(byte* out, const byte* in, word32 sz) { + if (!isMMX) { + Mode_BASE::Process(out, in, sz); + return; + } + word32 blocks = sz / DES_BLOCK_SIZE; if (mode_ == CBC) diff --git a/extra/yassl/taocrypt/src/integer.cpp b/extra/yassl/taocrypt/src/integer.cpp index 500160cfe37..1ed69ce34dc 100644 --- a/extra/yassl/taocrypt/src/integer.cpp +++ b/extra/yassl/taocrypt/src/integer.cpp @@ -55,12 +55,15 @@ extern "C" word myUMULH(word, word); #pragma intrinsic (myUMULH) #endif +#ifdef __GNUC__ + #include + #include +#endif + #ifdef SSE2_INTRINSICS_AVAILABLE #ifdef __GNUC__ #include - #include - #include #ifdef TAOCRYPT_MEMALIGN_AVAILABLE #include #else @@ -1015,44 +1018,20 @@ void Portable::Multiply8Bottom(word *R, const word *A, const word *B) // ************** x86 feature detection *************** -static bool s_sse2Enabled = true; - -static void CpuId(word32 input, word32 *output) -{ -#ifdef __GNUC__ - __asm__ - ( - // save ebx in case -fPIC is being used - "push %%ebx; cpuid; mov %%ebx, %%edi; pop %%ebx" - : "=a" (output[0]), "=D" (output[1]), "=c" (output[2]), "=d"(output[3]) - : "a" (input) - ); -#else - __asm - { - mov eax, input - cpuid - mov edi, output - mov [edi], eax - mov [edi+4], ebx - mov [edi+8], ecx - mov [edi+12], edx - } -#endif -} #ifdef SSE2_INTRINSICS_AVAILABLE + #ifndef _MSC_VER -static jmp_buf s_env; -static void SigIllHandler(int) -{ + static jmp_buf s_env; + static void SigIllHandler(int) + { longjmp(s_env, 1); -} + } #endif static bool HasSSE2() { - if (!s_sse2Enabled) + if (!IsPentium()) return false; word32 cpuid[4]; @@ -1081,23 +1060,22 @@ static bool HasSSE2() if (setjmp(s_env)) result = false; else - __asm __volatile ("xorps %xmm0, %xmm0"); + __asm __volatile ("xorpd %xmm0, %xmm0"); signal(SIGILL, oldHandler); return result; #endif } -#endif +#endif // SSE2_INTRINSICS_AVAILABLE + static bool IsP4() { - word32 cpuid[4]; - - CpuId(0, cpuid); - STL::swap(cpuid[2], cpuid[3]); - if (memcmp(cpuid+1, "GenuineIntel", 12) != 0) + if (!IsPentium()) return false; + word32 cpuid[4]; + CpuId(1, cpuid); return ((cpuid[0] >> 8) & 0xf) == 0xf; } @@ -1147,7 +1125,12 @@ static PMul s_pMul4, s_pMul8, s_pMul8B; static void SetPentiumFunctionPointers() { - if (IsP4()) + if (!IsPentium()) + { + s_pAdd = &Portable::Add; + s_pSub = &Portable::Subtract; + } + else if (IsP4()) { s_pAdd = &P4Optimized::Add; s_pSub = &P4Optimized::Subtract; @@ -1159,7 +1142,13 @@ static void SetPentiumFunctionPointers() } #ifdef SSE2_INTRINSICS_AVAILABLE - if (HasSSE2()) + if (!IsPentium()) + { + s_pMul4 = &Portable::Multiply4; + s_pMul8 = &Portable::Multiply8; + s_pMul8B = &Portable::Multiply8Bottom; + } + else if (HasSSE2()) { s_pMul4 = &P4Optimized::Multiply4; s_pMul8 = &P4Optimized::Multiply8; @@ -1177,11 +1166,6 @@ static void SetPentiumFunctionPointers() static const char s_RunAtStartupSetPentiumFunctionPointers = (SetPentiumFunctionPointers(), 0); -void DisableSSE2() -{ - s_sse2Enabled = false; - SetPentiumFunctionPointers(); -} class LowLevel : public PentiumOptimized { @@ -3984,6 +3968,9 @@ Integer CRT(const Integer &xp, const Integer &p, const Integer &xq, template hword DivideThreeWordsByTwo(hword*, hword, hword, Word*); #endif template word DivideThreeWordsByTwo(word*, word, word, DWord*); +#ifdef SSE2_INTRINSICS_AVAILABLE +template class AlignedAllocator; +#endif #endif diff --git a/extra/yassl/taocrypt/src/make.bat b/extra/yassl/taocrypt/src/make.bat index ecf7e8f8469..0aa1350f7d8 100644 --- a/extra/yassl/taocrypt/src/make.bat +++ b/extra/yassl/taocrypt/src/make.bat @@ -1,7 +1,7 @@ REM quick and dirty build file for testing different MSDEVs setlocal -set myFLAGS= /I../include /I../../mySTL /c /W3 /G6 /O2 +set myFLAGS= /I../include /I../mySTL /c /W3 /G6 /O2 cl %myFLAGS% aes.cpp cl %myFLAGS% aestables.cpp @@ -21,6 +21,7 @@ cl %myFLAGS% file.cpp cl %myFLAGS% hash.cpp cl %myFLAGS% integer.cpp cl %myFLAGS% md2.cpp +cl %myFLAGS% md4.cpp cl %myFLAGS% md5.cpp cl %myFLAGS% misc.cpp @@ -33,5 +34,5 @@ cl %myFLAGS% template_instnt.cpp cl %myFLAGS% tftables.cpp cl %myFLAGS% twofish.cpp -link.exe -lib /out:taocrypt.lib aes.obj aestables.obj algebra.obj arc4.obj asn.obj bftables.obj blowfish.obj coding.obj des.obj dh.obj dsa.obj file.obj hash.obj integer.obj md2.obj md5.obj misc.obj random.obj ripemd.obj rsa.obj sha.obj template_instnt.obj tftables.obj twofish.obj +link.exe -lib /out:taocrypt.lib aes.obj aestables.obj algebra.obj arc4.obj asn.obj bftables.obj blowfish.obj coding.obj des.obj dh.obj dsa.obj file.obj hash.obj integer.obj md2.obj md4.obj md5.obj misc.obj random.obj ripemd.obj rsa.obj sha.obj template_instnt.obj tftables.obj twofish.obj diff --git a/extra/yassl/taocrypt/src/md4.cpp b/extra/yassl/taocrypt/src/md4.cpp index 0dee8bf40cb..1efda04fbb8 100644 --- a/extra/yassl/taocrypt/src/md4.cpp +++ b/extra/yassl/taocrypt/src/md4.cpp @@ -28,7 +28,11 @@ #include "runtime.hpp" #include "md4.hpp" -#include STL_ALGORITHM_FILE +#ifdef USE_SYS_STL + #include +#else + #include "algorithm.hpp" +#endif namespace STL = STL_NAMESPACE; diff --git a/extra/yassl/taocrypt/src/md5.cpp b/extra/yassl/taocrypt/src/md5.cpp index 2bddc7fe308..bf485d11b95 100644 --- a/extra/yassl/taocrypt/src/md5.cpp +++ b/extra/yassl/taocrypt/src/md5.cpp @@ -28,15 +28,16 @@ #include "runtime.hpp" #include "md5.hpp" -#include STL_ALGORITHM_FILE +#ifdef USE_SYS_STL + #include +#else + #include "algorithm.hpp" +#endif namespace STL = STL_NAMESPACE; -#if defined(TAOCRYPT_X86ASM_AVAILABLE) && defined(TAO_ASM) - #define DO_MD5_ASM -#endif namespace TaoCrypt { @@ -84,10 +85,17 @@ void MD5::Swap(MD5& other) } -// Update digest with data of size len, do in blocks +#ifdef DO_MD5_ASM + +// Update digest with data of size len void MD5::Update(const byte* data, word32 len) { - byte* local = (byte*)buffer_; + if (!isMMX) { + HASHwithTransform::Update(data, len); + return; + } + + byte* local = reinterpret_cast(buffer_); // remove buffered data if possible if (buffLen_) { @@ -99,27 +107,14 @@ void MD5::Update(const byte* data, word32 len) len -= add; if (buffLen_ == BLOCK_SIZE) { - ByteReverseIf(local, local, BLOCK_SIZE, LittleEndianOrder); Transform(); AddLength(BLOCK_SIZE); buffLen_ = 0; } } - // do block size transforms or all at once for asm + // at once for asm if (buffLen_ == 0) { - #ifndef DO_MD5_ASM - while (len >= BLOCK_SIZE) { - memcpy(&local[0], data, BLOCK_SIZE); - - data += BLOCK_SIZE; - len -= BLOCK_SIZE; - - ByteReverseIf(local, local, BLOCK_SIZE, LittleEndianOrder); - Transform(); - AddLength(BLOCK_SIZE); - } - #else word32 times = len / BLOCK_SIZE; if (times) { AsmTransform(data, times); @@ -128,7 +123,6 @@ void MD5::Update(const byte* data, word32 len) len -= add; data += add; } - #endif } // cache any data left @@ -139,7 +133,6 @@ void MD5::Update(const byte* data, word32 len) } -#ifdef DO_MD5_ASM /* diff --git a/extra/yassl/taocrypt/src/misc.cpp b/extra/yassl/taocrypt/src/misc.cpp index 084a263a4ae..7ab05582e95 100644 --- a/extra/yassl/taocrypt/src/misc.cpp +++ b/extra/yassl/taocrypt/src/misc.cpp @@ -30,6 +30,20 @@ #include "misc.hpp" +#ifdef __GNUC__ + #include + #include +#endif + +#ifdef USE_SYS_STL + #include +#else + #include "algorithm.hpp" +#endif + +namespace STL = STL_NAMESPACE; + + #ifdef YASSL_PURE_C void* operator new(size_t sz, TaoCrypt::new_t) @@ -156,5 +170,129 @@ unsigned long Crop(unsigned long value, unsigned int size) } + +#ifdef TAOCRYPT_X86ASM_AVAILABLE + +#ifndef _MSC_VER + static jmp_buf s_env; + static void SigIllHandler(int) + { + longjmp(s_env, 1); + } +#endif + + +bool HaveCpuId() +{ +#ifdef _MSC_VER + __try + { + __asm + { + mov eax, 0 + cpuid + } + } + __except (1) + { + return false; + } + return true; +#else + typedef void (*SigHandler)(int); + + SigHandler oldHandler = signal(SIGILL, SigIllHandler); + if (oldHandler == SIG_ERR) + return false; + + bool result = true; + if (setjmp(s_env)) + result = false; + else + __asm__ __volatile + ( + // save ebx in case -fPIC is being used + "push %%ebx; mov $0, %%eax; cpuid; pop %%ebx" + : + : + : "%eax", "%ecx", "%edx" + ); + + signal(SIGILL, oldHandler); + return result; +#endif +} + + +void CpuId(word32 input, word32 *output) +{ +#ifdef __GNUC__ + __asm__ + ( + // save ebx in case -fPIC is being used + "push %%ebx; cpuid; mov %%ebx, %%edi; pop %%ebx" + : "=a" (output[0]), "=D" (output[1]), "=c" (output[2]), "=d"(output[3]) + : "a" (input) + ); +#else + __asm + { + mov eax, input + cpuid + mov edi, output + mov [edi], eax + mov [edi+4], ebx + mov [edi+8], ecx + mov [edi+12], edx + } +#endif +} + + +bool IsPentium() +{ + if (!HaveCpuId()) + return false; + + word32 cpuid[4]; + + CpuId(0, cpuid); + STL::swap(cpuid[2], cpuid[3]); + if (memcmp(cpuid+1, "GenuineIntel", 12) != 0) + return false; + + CpuId(1, cpuid); + byte family = ((cpuid[0] >> 8) & 0xf); + if (family < 5) + return false; + + return true; +} + + + +static bool IsMmx() +{ + if (!IsPentium()) + return false; + + word32 cpuid[4]; + + CpuId(1, cpuid); + if ((cpuid[3] & (1 << 23)) == 0) + return false; + + return true; +} + + +bool isMMX = IsMmx(); + + +#endif // TAOCRYPT_X86ASM_AVAILABLE + + + + } // namespace diff --git a/extra/yassl/taocrypt/src/random.cpp b/extra/yassl/taocrypt/src/random.cpp index c7bb6ae9549..3fab1ddba23 100644 --- a/extra/yassl/taocrypt/src/random.cpp +++ b/extra/yassl/taocrypt/src/random.cpp @@ -50,8 +50,11 @@ namespace TaoCrypt { RandomNumberGenerator::RandomNumberGenerator() { byte key[32]; + byte junk[256]; + seed_.GenerateSeed(key, sizeof(key)); cipher_.SetKey(key, sizeof(key)); + GenerateBlock(junk, sizeof(junk)); // rid initial state } diff --git a/extra/yassl/taocrypt/src/ripemd.cpp b/extra/yassl/taocrypt/src/ripemd.cpp index 03c09edde84..98bfe4b2645 100644 --- a/extra/yassl/taocrypt/src/ripemd.cpp +++ b/extra/yassl/taocrypt/src/ripemd.cpp @@ -28,15 +28,16 @@ #include "runtime.hpp" #include "ripemd.hpp" -#include STL_ALGORITHM_FILE +#ifdef USE_SYS_STL + #include +#else + #include "algorithm.hpp" +#endif namespace STL = STL_NAMESPACE; -#if defined(TAOCRYPT_X86ASM_AVAILABLE) && defined(TAO_ASM) - #define DO_RIPEMD_ASM -#endif namespace TaoCrypt { @@ -86,10 +87,17 @@ void RIPEMD160::Swap(RIPEMD160& other) } -// Update digest with data of size len, do in blocks +#ifdef DO_RIPEMD_ASM + +// Update digest with data of size len void RIPEMD160::Update(const byte* data, word32 len) { - byte* local = (byte*)buffer_; + if (!isMMX) { + HASHwithTransform::Update(data, len); + return; + } + + byte* local = reinterpret_cast(buffer_); // remove buffered data if possible if (buffLen_) { @@ -101,27 +109,14 @@ void RIPEMD160::Update(const byte* data, word32 len) len -= add; if (buffLen_ == BLOCK_SIZE) { - ByteReverseIf(local, local, BLOCK_SIZE, LittleEndianOrder); Transform(); AddLength(BLOCK_SIZE); buffLen_ = 0; } } - // do block size transforms or all at once for asm + // all at once for asm if (buffLen_ == 0) { - #ifndef DO_RIPEMD_ASM - while (len >= BLOCK_SIZE) { - memcpy(&local[0], data, BLOCK_SIZE); - - data += BLOCK_SIZE; - len -= BLOCK_SIZE; - - ByteReverseIf(local, local, BLOCK_SIZE, LittleEndianOrder); - Transform(); - AddLength(BLOCK_SIZE); - } - #else word32 times = len / BLOCK_SIZE; if (times) { AsmTransform(data, times); @@ -130,7 +125,6 @@ void RIPEMD160::Update(const byte* data, word32 len) len -= add; data += add; } - #endif } // cache any data left @@ -140,6 +134,8 @@ void RIPEMD160::Update(const byte* data, word32 len) } } +#endif // DO_RIPEMD_ASM + // for all #define F(x, y, z) (x ^ y ^ z) diff --git a/extra/yassl/taocrypt/src/sha.cpp b/extra/yassl/taocrypt/src/sha.cpp index 280d42fb3d4..b1273d9da8f 100644 --- a/extra/yassl/taocrypt/src/sha.cpp +++ b/extra/yassl/taocrypt/src/sha.cpp @@ -28,16 +28,16 @@ #include "runtime.hpp" #include #include "sha.hpp" -#include STL_ALGORITHM_FILE +#ifdef USE_SYS_STL + #include +#else + #include "algorithm.hpp" +#endif namespace STL = STL_NAMESPACE; -#if defined(TAOCRYPT_X86ASM_AVAILABLE) && defined(TAO_ASM) - #define DO_SHA_ASM -#endif - namespace TaoCrypt { @@ -108,10 +108,18 @@ void SHA::Swap(SHA& other) } -// Update digest with data of size len, do in blocks + +#ifdef DO_SHA_ASM + +// Update digest with data of size len void SHA::Update(const byte* data, word32 len) { - byte* local = (byte*)buffer_; + if (!isMMX) { + HASHwithTransform::Update(data, len); + return; + } + + byte* local = reinterpret_cast(buffer_); // remove buffered data if possible if (buffLen_) { @@ -123,27 +131,15 @@ void SHA::Update(const byte* data, word32 len) len -= add; if (buffLen_ == BLOCK_SIZE) { - ByteReverseIf(local, local, BLOCK_SIZE, BigEndianOrder); + ByteReverse(local, local, BLOCK_SIZE); Transform(); AddLength(BLOCK_SIZE); buffLen_ = 0; } } - // do block size transforms or all at once for asm + // all at once for asm if (buffLen_ == 0) { - #ifndef DO_SHA_ASM - while (len >= BLOCK_SIZE) { - memcpy(&local[0], data, BLOCK_SIZE); - - data += BLOCK_SIZE; - len -= BLOCK_SIZE; - - ByteReverseIf(local, local, BLOCK_SIZE, BigEndianOrder); - Transform(); - AddLength(BLOCK_SIZE); - } - #else word32 times = len / BLOCK_SIZE; if (times) { AsmTransform(data, times); @@ -152,7 +148,6 @@ void SHA::Update(const byte* data, word32 len) len -= add; data += add; } - #endif } // cache any data left @@ -162,6 +157,8 @@ void SHA::Update(const byte* data, word32 len) } } +#endif // DO_SHA_ASM + void SHA::Transform() { diff --git a/extra/yassl/taocrypt/src/twofish.cpp b/extra/yassl/taocrypt/src/twofish.cpp index a16a8f0d169..bb385331519 100644 --- a/extra/yassl/taocrypt/src/twofish.cpp +++ b/extra/yassl/taocrypt/src/twofish.cpp @@ -35,33 +35,20 @@ #include "twofish.hpp" -#if defined(TAOCRYPT_X86ASM_AVAILABLE) && defined(TAO_ASM) - #define DO_TWOFISH_ASM -#endif - namespace TaoCrypt { -#if !defined(DO_TWOFISH_ASM) - -// Generic Version -void Twofish::Process(byte* out, const byte* in, word32 sz) -{ - if (mode_ == ECB) - ECB_Process(out, in, sz); - else if (mode_ == CBC) - if (dir_ == ENCRYPTION) - CBC_Encrypt(out, in, sz); - else - CBC_Decrypt(out, in, sz); -} - -#else +#if defined(DO_TWOFISH_ASM) // ia32 optimized version void Twofish::Process(byte* out, const byte* in, word32 sz) { + if (!isMMX) { + Mode_BASE::Process(out, in, sz); + return; + } + word32 blocks = sz / BLOCK_SIZE; if (mode_ == ECB) diff --git a/extra/yassl/taocrypt/test/make.bat b/extra/yassl/taocrypt/test/make.bat index 5f01db68d0d..7b53e9abc90 100644 --- a/extra/yassl/taocrypt/test/make.bat +++ b/extra/yassl/taocrypt/test/make.bat @@ -1,7 +1,7 @@ REM quick and dirty build file for testing different MSDEVs setlocal -set myFLAGS= /I../include /I../../mySTL /c /W3 /G6 /O2 +set myFLAGS= /I../include /I../mySTL /c /W3 /G6 /O2 cl %myFLAGS% test.cpp diff --git a/extra/yassl/taocrypt/test/test.cpp b/extra/yassl/taocrypt/test/test.cpp index 28ef73dfac8..9e3ef709a78 100644 --- a/extra/yassl/taocrypt/test/test.cpp +++ b/extra/yassl/taocrypt/test/test.cpp @@ -247,6 +247,8 @@ void taocrypt_test(void* args) args.argv = argv; taocrypt_test(&args); + TaoCrypt::CleanUp(); + return args.return_code; } diff --git a/extra/yassl/testsuite/make.bat b/extra/yassl/testsuite/make.bat index 1bc7ce0513d..ea2677db481 100644 --- a/extra/yassl/testsuite/make.bat +++ b/extra/yassl/testsuite/make.bat @@ -1,7 +1,7 @@ REM quick and dirty build file for testing different MSDEVs setlocal -set myFLAGS= /I../include /I../taocrypt/include /I../mySTL /c /W3 /G6 /O2 /MT /D"WIN32" /D"NO_MAIN_DRIVER" +set myFLAGS= /I../include /I../taocrypt/include /I../taocrypt/mySTL /c /W3 /G6 /O2 /MT /D"WIN32" /D"NO_MAIN_DRIVER" cl %myFLAGS% testsuite.cpp cl %myFLAGS% ../examples/client/client.cpp diff --git a/extra/yassl/testsuite/test.hpp b/extra/yassl/testsuite/test.hpp index b23b36f0ba2..b2fed37f4e5 100644 --- a/extra/yassl/testsuite/test.hpp +++ b/extra/yassl/testsuite/test.hpp @@ -9,6 +9,8 @@ #include #include +//#define NON_BLOCKING // test server and client example (not echos) + #ifdef _WIN32 #include #include @@ -23,16 +25,17 @@ #include #include #include +#ifdef NON_BLOCKING + #include +#endif #define SOCKET_T int #endif /* _WIN32 */ -#if !defined(_SOCKLEN_T) && defined(_WIN32) +#if !defined(_SOCKLEN_T) && \ + (defined(_WIN32) || defined(__NETWARE__) || defined(__APPLE__)) typedef int socklen_t; #endif -#if !defined(_SOCKLEN_T) && defined(__NETWARE__) - typedef size_t socklen_t; -#endif // Check type of third arg to accept @@ -262,6 +265,20 @@ inline void set_args(int& argc, char**& argv, func_args& args) } +inline void tcp_set_nonblocking(SOCKET_T& sockfd) +{ +#ifdef NON_BLOCKING + #ifdef _WIN32 + unsigned long blocking = 1; + int ret = ioctlsocket(sockfd, FIONBIO, &blocking); + #else + int flags = fcntl(sockfd, F_GETFL, 0); + int ret = fcntl(sockfd, F_SETFL, flags | O_NONBLOCK); + #endif +#endif +} + + inline void tcp_socket(SOCKET_T& sockfd, sockaddr_in& addr) { sockfd = socket(AF_INET, SOCK_STREAM, 0); @@ -289,8 +306,7 @@ inline void tcp_connect(SOCKET_T& sockfd) sockaddr_in addr; tcp_socket(sockfd, addr); - if (connect(sockfd, (const sockaddr*)&addr, sizeof(addr)) != 0) - { + if (connect(sockfd, (const sockaddr*)&addr, sizeof(addr)) != 0) { tcp_close(sockfd); err_sys("tcp connect failed"); } @@ -302,19 +318,18 @@ inline void tcp_listen(SOCKET_T& sockfd) sockaddr_in addr; tcp_socket(sockfd, addr); - if (bind(sockfd, (const sockaddr*)&addr, sizeof(addr)) != 0) - { + if (bind(sockfd, (const sockaddr*)&addr, sizeof(addr)) != 0) { tcp_close(sockfd); err_sys("tcp bind failed"); } - if (listen(sockfd, 3) != 0) - { + if (listen(sockfd, 3) != 0) { tcp_close(sockfd); err_sys("tcp listen failed"); } } + inline void tcp_accept(SOCKET_T& sockfd, SOCKET_T& clientfd, func_args& args) { tcp_listen(sockfd); @@ -333,11 +348,14 @@ inline void tcp_accept(SOCKET_T& sockfd, SOCKET_T& clientfd, func_args& args) clientfd = accept(sockfd, (sockaddr*)&client, (ACCEPT_THIRD_T)&client_len); - if (clientfd == -1) - { + if (clientfd == -1) { tcp_close(sockfd); err_sys("tcp accept failed"); } + +#ifdef NON_BLOCKING + tcp_set_nonblocking(clientfd); +#endif } @@ -363,25 +381,30 @@ inline void showPeer(SSL* ssl) inline DH* set_tmpDH(SSL_CTX* ctx) { - static unsigned char dh512_p[] = + static unsigned char dh1024_p[] = { - 0xDA,0x58,0x3C,0x16,0xD9,0x85,0x22,0x89,0xD0,0xE4,0xAF,0x75, - 0x6F,0x4C,0xCA,0x92,0xDD,0x4B,0xE5,0x33,0xB8,0x04,0xFB,0x0F, - 0xED,0x94,0xEF,0x9C,0x8A,0x44,0x03,0xED,0x57,0x46,0x50,0xD3, - 0x69,0x99,0xDB,0x29,0xD7,0x76,0x27,0x6B,0xA2,0xD3,0xD4,0x12, - 0xE2,0x18,0xF4,0xDD,0x1E,0x08,0x4C,0xF6,0xD8,0x00,0x3E,0x7C, - 0x47,0x74,0xE8,0x33, + 0xE6, 0x96, 0x9D, 0x3D, 0x49, 0x5B, 0xE3, 0x2C, 0x7C, 0xF1, 0x80, 0xC3, + 0xBD, 0xD4, 0x79, 0x8E, 0x91, 0xB7, 0x81, 0x82, 0x51, 0xBB, 0x05, 0x5E, + 0x2A, 0x20, 0x64, 0x90, 0x4A, 0x79, 0xA7, 0x70, 0xFA, 0x15, 0xA2, 0x59, + 0xCB, 0xD5, 0x23, 0xA6, 0xA6, 0xEF, 0x09, 0xC4, 0x30, 0x48, 0xD5, 0xA2, + 0x2F, 0x97, 0x1F, 0x3C, 0x20, 0x12, 0x9B, 0x48, 0x00, 0x0E, 0x6E, 0xDD, + 0x06, 0x1C, 0xBC, 0x05, 0x3E, 0x37, 0x1D, 0x79, 0x4E, 0x53, 0x27, 0xDF, + 0x61, 0x1E, 0xBB, 0xBE, 0x1B, 0xAC, 0x9B, 0x5C, 0x60, 0x44, 0xCF, 0x02, + 0x3D, 0x76, 0xE0, 0x5E, 0xEA, 0x9B, 0xAD, 0x99, 0x1B, 0x13, 0xA6, 0x3C, + 0x97, 0x4E, 0x9E, 0xF1, 0x83, 0x9E, 0xB5, 0xDB, 0x12, 0x51, 0x36, 0xF7, + 0x26, 0x2E, 0x56, 0xA8, 0x87, 0x15, 0x38, 0xDF, 0xD8, 0x23, 0xC6, 0x50, + 0x50, 0x85, 0xE2, 0x1F, 0x0D, 0xD5, 0xC8, 0x6B, }; - static unsigned char dh512_g[] = + static unsigned char dh1024_g[] = { 0x02, }; DH* dh; if ( (dh = DH_new()) ) { - dh->p = BN_bin2bn(dh512_p, sizeof(dh512_p), 0); - dh->g = BN_bin2bn(dh512_g, sizeof(dh512_g), 0); + dh->p = BN_bin2bn(dh1024_p, sizeof(dh1024_p), 0); + dh->g = BN_bin2bn(dh1024_g, sizeof(dh1024_g), 0); } if (!dh->p || !dh->g) { DH_free(dh); From 72ad912b0b252c26e8480365fe21d32c76794d86 Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Wed, 29 Nov 2006 10:11:36 +0100 Subject: [PATCH 114/131] Update result file for func_misc to 5.1 version format --- mysql-test/r/func_misc.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result index cfea464dfd9..84974f845c5 100644 --- a/mysql-test/r/func_misc.result +++ b/mysql-test/r/func_misc.result @@ -138,7 +138,7 @@ create table t1 select INET_ATON('255.255.0.1') as `a`; show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` bigint(21) unsigned default NULL + `a` bigint(21) unsigned DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; End of 5.0 tests From ea6a91757b2a0d7303c6a6b1affbc8ffeb59ae08 Mon Sep 17 00:00:00 2001 From: "thek@kpdesk.mysql.com" <> Date: Wed, 29 Nov 2006 11:45:29 +0100 Subject: [PATCH 115/131] Bug#22043 MySQL don't add "USE " before "DROP PROCEDURE IF EXISTS" - Merge patch. - Test case needed update because event number were off. - Error code has changed because db name validation rules changes between 5.0 and 5.1 --- mysql-test/r/rpl_sp.result | 24 +++++++++--------------- mysql-test/t/rpl_sp.test | 7 ++++--- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/mysql-test/r/rpl_sp.result b/mysql-test/r/rpl_sp.result index e0d8d6d1db0..f3754f650fb 100644 --- a/mysql-test/r/rpl_sp.result +++ b/mysql-test/r/rpl_sp.result @@ -467,7 +467,7 @@ DROP FUNCTION f1; drop table t1; set global log_bin_trust_function_creators=0; set global log_bin_trust_function_creators=0; - +End of 5.0 tests drop database if exists mysqltest; drop database if exists mysqltest2; create database mysqltest; @@ -476,22 +476,16 @@ use mysqltest2; create table t ( t integer ); create procedure mysqltest.test() begin end; insert into t values ( 1 ); -show binlog events in 'master-bin.000001' from 8186; +show binlog events in 'master-bin.000001' from 8657; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 8186 Query 1 8317 use `test`; CREATE DEFINER=`root`@`localhost` FUNCTION f1() RETURNS INT RETURN 0 -master-bin.000001 8317 Query 1 8397 use `test`; DROP PROCEDURE p1 -master-bin.000001 8397 Query 1 8476 use `test`; DROP FUNCTION f1 -master-bin.000001 8476 Query 1 8552 use `test`; drop table t1 -master-bin.000001 8552 Query 1 8653 drop database if exists mysqltest -master-bin.000001 8653 Query 1 8756 drop database if exists mysqltest2 -master-bin.000001 8756 Query 1 8849 create database mysqltest -master-bin.000001 8849 Query 1 8944 create database mysqltest2 -master-bin.000001 8944 Query 1 9041 use `mysqltest2`; create table t ( t integer ) -master-bin.000001 9041 Query 1 9180 use `mysqltest2`; CREATE DEFINER=`root`@`localhost` procedure mysqltest.test() begin end -master-bin.000001 9180 Query 1 9275 use `mysqltest2`; insert into t values ( 1 ) +master-bin.000001 8657 Query 1 8760 drop database if exists mysqltest2 +master-bin.000001 8760 Query 1 8853 create database mysqltest +master-bin.000001 8853 Query 1 8948 create database mysqltest2 +master-bin.000001 8948 Query 1 9045 use `mysqltest2`; create table t ( t integer ) +master-bin.000001 9045 Query 1 9184 use `mysqltest2`; CREATE DEFINER=`root`@`localhost` procedure mysqltest.test() begin end +master-bin.000001 9184 Query 1 9279 use `mysqltest2`; insert into t values ( 1 ) create procedure `\\`.test() begin end; -ERROR 42000: Incorrect database name '\\' +ERROR 42000: Unknown database '\\' drop database mysqltest; drop database mysqltest2; -End of 5.0 tests End of 5.1 tests diff --git a/mysql-test/t/rpl_sp.test b/mysql-test/t/rpl_sp.test index 0e0de7cf2e7..2f0d04eff35 100644 --- a/mysql-test/t/rpl_sp.test +++ b/mysql-test/t/rpl_sp.test @@ -526,6 +526,8 @@ sync_slave_with_master; set global log_bin_trust_function_creators=0; connection master; set global log_bin_trust_function_creators=0; +--echo End of 5.0 tests + # # Bug22043: MySQL don't add "USE " before "DROP PROCEDURE IF EXISTS" # @@ -540,13 +542,12 @@ use mysqltest2; create table t ( t integer ); create procedure mysqltest.test() begin end; insert into t values ( 1 ); -show binlog events in 'master-bin.000001' from 8186; ---error ER_WRONG_DB_NAME +show binlog events in 'master-bin.000001' from 8657; +--error ER_BAD_DB_ERROR create procedure `\\`.test() begin end; # Clean up drop database mysqltest; drop database mysqltest2; ---echo End of 5.0 tests --echo End of 5.1 tests From dcf0f346cf1c06d85b8d319396539bc1afad1bd4 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Wed, 29 Nov 2006 12:04:29 +0100 Subject: [PATCH 116/131] Bug#20589 Missing some table level privileges after upgrade - The table_priv column of table_privs table was altered to a enum type with fewer enums causing the SHOW/CREATE VIEW grants to be truncated. - Improved comments and moved all declarations for table_privs, column_privs and proc_privs to one section for each table making it easy to see hat alterations are performed on each table - Reduced the number of ALTER's slightly, but as this is an upgrade script we need to take all possibilites into account. --- mysql-test/r/fix_priv_tables.result | 36 +++++++ mysql-test/r/fix_priv_tabs.result | 0 mysql-test/t/fix_priv_tables.test | 66 ++++++++++++ scripts/mysql_fix_privilege_tables.sql | 141 ++++++++++++++----------- 4 files changed, 181 insertions(+), 62 deletions(-) create mode 100644 mysql-test/r/fix_priv_tables.result create mode 100644 mysql-test/r/fix_priv_tabs.result create mode 100644 mysql-test/t/fix_priv_tables.test diff --git a/mysql-test/r/fix_priv_tables.result b/mysql-test/r/fix_priv_tables.result new file mode 100644 index 00000000000..e54330a5520 --- /dev/null +++ b/mysql-test/r/fix_priv_tables.result @@ -0,0 +1,36 @@ +drop table if exists t1,t1aa,t2aa; +DROP DATABASE IF EXISTS testdb; +CREATE DATABASE testdb; +CREATE TABLE testdb.t1 ( +c1 INT, +c3 INT NOT NULL AUTO_INCREMENT PRIMARY KEY); +CREATE VIEW testdb.v1 AS +SELECT * FROM testdb.t1; +GRANT CREATE VIEW, SHOW VIEW ON testdb.v1 TO 'show_view_tbl'@'localhost'; +SHOW GRANTS FOR 'show_view_tbl'@'localhost'; +Grants for show_view_tbl@localhost +GRANT USAGE ON *.* TO 'show_view_tbl'@'localhost' +GRANT CREATE VIEW, SHOW VIEW ON `testdb`.`v1` TO 'show_view_tbl'@'localhost' + +GRANT SELECT(c1) on testdb.v1 to 'select_only_c1'@localhost; +SHOW GRANTS FOR 'select_only_c1'@'localhost'; +Grants for select_only_c1@localhost +GRANT USAGE ON *.* TO 'select_only_c1'@'localhost' +GRANT SELECT (c1) ON `testdb`.`v1` TO 'select_only_c1'@'localhost' + +"after fix privs" +SHOW GRANTS FOR 'show_view_tbl'@'localhost'; +Grants for show_view_tbl@localhost +GRANT USAGE ON *.* TO 'show_view_tbl'@'localhost' +GRANT CREATE VIEW, SHOW VIEW ON `testdb`.`v1` TO 'show_view_tbl'@'localhost' + +SHOW GRANTS FOR 'select_only_c1'@'localhost'; +Grants for select_only_c1@localhost +GRANT USAGE ON *.* TO 'select_only_c1'@'localhost' +GRANT SELECT (c1) ON `testdb`.`v1` TO 'select_only_c1'@'localhost' + +DROP USER 'show_view_tbl'@'localhost'; +DROP USER 'select_only_c1'@'localhost'; +DROP VIEW testdb.v1; +DROP TABLE testdb.t1; +DROP DATABASE testdb; diff --git a/mysql-test/r/fix_priv_tabs.result b/mysql-test/r/fix_priv_tabs.result new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mysql-test/t/fix_priv_tables.test b/mysql-test/t/fix_priv_tables.test new file mode 100644 index 00000000000..3a91f41dfcc --- /dev/null +++ b/mysql-test/t/fix_priv_tables.test @@ -0,0 +1,66 @@ +# Embedded server doesn't support external clients +--source include/not_embedded.inc + +# +# This is the test for mysql_fix_privilege_tables +# It checks that a system tables from mysql 4.1.23 +# can be upgraded to current system table format +# +# Note: If this test fails, don't be confused about the errors reported +# by mysql-test-run This shows warnings generated by +# mysql_fix_system_tables which should be ignored. +# Instead, concentrate on the errors in r/system_mysql_db.reject + +--disable_warnings +drop table if exists t1,t1aa,t2aa; +--enable_warnings + +# +# Bug #20589 Missing some table level privileges after upgrade +# +# Add some grants that should survive the "upgrade" + +--disable_warnings +DROP DATABASE IF EXISTS testdb; +--enable_warnings +CREATE DATABASE testdb; +CREATE TABLE testdb.t1 ( + c1 INT, + c3 INT NOT NULL AUTO_INCREMENT PRIMARY KEY); + +CREATE VIEW testdb.v1 AS + SELECT * FROM testdb.t1; + +GRANT CREATE VIEW, SHOW VIEW ON testdb.v1 TO 'show_view_tbl'@'localhost'; +SHOW GRANTS FOR 'show_view_tbl'@'localhost'; +echo; + +# Some extra GRANTS for more complete test +GRANT SELECT(c1) on testdb.v1 to 'select_only_c1'@localhost; +SHOW GRANTS FOR 'select_only_c1'@'localhost'; +echo; + +-- disable_result_log +-- disable_query_log + +# Run the mysql_fix_privilege_tables.sql using "mysql --force" +--exec $MYSQL --force mysql < $MYSQL_FIX_PRIVILEGE_TABLES > $MYSQLTEST_VARDIR/log/fix_priv_tables.log 2>&1 + +-- enable_query_log +-- enable_result_log + +echo "after fix privs"; + +SHOW GRANTS FOR 'show_view_tbl'@'localhost'; +echo; +SHOW GRANTS FOR 'select_only_c1'@'localhost'; +echo; + +DROP USER 'show_view_tbl'@'localhost'; +DROP USER 'select_only_c1'@'localhost'; + +DROP VIEW testdb.v1; +DROP TABLE testdb.t1; +DROP DATABASE testdb; + +# End of 4.1 tests diff --git a/scripts/mysql_fix_privilege_tables.sql b/scripts/mysql_fix_privilege_tables.sql index 287d51379e2..5709fb96793 100644 --- a/scripts/mysql_fix_privilege_tables.sql +++ b/scripts/mysql_fix_privilege_tables.sql @@ -46,9 +46,8 @@ ADD x509_subject BLOB NOT NULL; ALTER TABLE user MODIFY ssl_type enum('','ANY','X509', 'SPECIFIED') NOT NULL; -- --- Create tables_priv and columns_priv if they don't exists +-- tables_priv -- - CREATE TABLE IF NOT EXISTS tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, @@ -56,22 +55,38 @@ CREATE TABLE IF NOT EXISTS tables_priv ( 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, + 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) ) CHARACTER SET utf8 COLLATE utf8_bin; --- Fix collation of set fields -ALTER TABLE tables_priv - modify Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') COLLATE utf8_general_ci DEFAULT '' NOT NULL, - modify Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL; -ALTER TABLE procs_priv ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin; -ALTER TABLE procs_priv - modify Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL; -ALTER TABLE procs_priv - add Routine_type enum('FUNCTION','PROCEDURE') COLLATE utf8_general_ci NOT NULL AFTER Routine_name; -ALTER TABLE procs_priv - modify Timestamp timestamp(14) AFTER Proc_priv; +ALTER TABLE tables_priv + ADD KEY Grantor (Grantor); + +ALTER TABLE tables_priv + MODIFY Host char(60) NOT NULL default '', + MODIFY Db char(64) NOT NULL default '', + MODIFY User char(16) NOT NULL default '', + MODIFY Table_name char(64) NOT NULL default '', + MODIFY Grantor char(77) NOT NULL default '', + ENGINE=MyISAM, + CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin; + +ALTER TABLE tables_priv + MODIFY Column_priv set('Select','Insert','Update','References') + COLLATE utf8_general_ci DEFAULT '' NOT NULL, + MODIFY Table_priv set('Select','Insert','Update','Delete','Create', + 'Drop','Grant','References','Index','Alter', + 'Create View','Show view') + COLLATE utf8_general_ci DEFAULT '' NOT NULL, + COMMENT='Table privileges'; + +-- +-- columns_priv +-- CREATE TABLE IF NOT EXISTS columns_priv ( Host char(60) DEFAULT '' NOT NULL, Db char(64) DEFAULT '' NOT NULL, @@ -82,16 +97,25 @@ CREATE TABLE IF NOT EXISTS columns_priv ( Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) CHARACTER SET utf8 COLLATE utf8_bin; --- Fix collation of set fields -ALTER TABLE columns_priv - MODIFY Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL; - --- -- Name change of Type -> Column_priv from MySQL 3.22.12 --- +ALTER TABLE columns_priv + CHANGE Type Column_priv set('Select','Insert','Update','References') + COLLATE utf8_general_ci DEFAULT '' NOT NULL; -ALTER TABLE columns_priv change Type Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL; +ALTER TABLE columns_priv + MODIFY Host char(60) NOT NULL default '', + MODIFY Db char(64) NOT NULL default '', + MODIFY User char(16) NOT NULL default '', + MODIFY Table_name char(64) NOT NULL default '', + MODIFY Column_name char(64) NOT NULL default '', + ENGINE=MyISAM, + CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin, + COMMENT='Column privileges'; + +ALTER TABLE columns_priv + MODIFY Column_priv set('Select','Insert','Update','References') + COLLATE utf8_general_ci DEFAULT '' NOT NULL; -- -- Add the new 'type' column to the func table. @@ -142,14 +166,12 @@ ADD Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT ADD Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL; alter table user change max_questions max_questions int(11) unsigned DEFAULT 0 NOT NULL; -alter table tables_priv add KEY Grantor (Grantor); + alter table db comment='Database privileges'; alter table host comment='Host privileges; Merged with database privileges'; alter table user comment='Users and global privileges'; alter table func comment='User defined functions'; -alter table tables_priv comment='Table privileges'; -alter table columns_priv comment='Column privileges'; -- Convert all tables to UTF-8 with binary collation -- and reset all char columns to correct width @@ -223,25 +245,6 @@ ALTER TABLE func ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin; ALTER TABLE func MODIFY type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL; -ALTER TABLE columns_priv - MODIFY Host char(60) NOT NULL default '', - MODIFY Db char(64) NOT NULL default '', - MODIFY User char(16) NOT NULL default '', - MODIFY Table_name char(64) NOT NULL default '', - MODIFY Column_name char(64) NOT NULL default '', - ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin; -ALTER TABLE columns_priv - MODIFY Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL; -ALTER TABLE tables_priv - MODIFY Host char(60) NOT NULL default '', - MODIFY Db char(64) NOT NULL default '', - MODIFY User char(16) NOT NULL default '', - MODIFY Table_name char(64) NOT NULL default '', - MODIFY Grantor char(77) NOT NULL default '', - ENGINE=MyISAM, CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin; -ALTER TABLE tables_priv - MODIFY Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter') COLLATE utf8_general_ci DEFAULT '' NOT NULL, - MODIFY Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL; # # Detect whether we had Create_view_priv @@ -273,11 +276,6 @@ ALTER TABLE host MODIFY Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEF ALTER TABLE user ADD Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv; ALTER TABLE user MODIFY Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL AFTER Create_view_priv; -# -# Show/Create views table privileges (v5.0) -# -ALTER TABLE tables_priv MODIFY Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view') COLLATE utf8_general_ci DEFAULT '' NOT NULL; - # # Assign create/show view privileges to people who have create provileges # @@ -344,22 +342,41 @@ UPDATE user LEFT JOIN db USING (Host,User) SET Create_user_priv='Y' WHERE @hadCreateUserPriv = 0 AND (user.Grant_priv = 'Y' OR db.Grant_priv = 'Y'); -# -# Create some possible missing tables -# +-- +-- procs_priv +-- CREATE TABLE IF NOT EXISTS procs_priv ( -Host char(60) binary DEFAULT '' NOT NULL, -Db char(64) binary DEFAULT '' NOT NULL, -User char(16) binary DEFAULT '' NOT NULL, -Routine_name char(64) binary DEFAULT '' NOT NULL, -Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, -Grantor char(77) DEFAULT '' NOT NULL, -Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, -Timestamp timestamp(14), -PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), -KEY Grantor (Grantor) + Host char(60) binary DEFAULT '' NOT NULL, + Db char(64) binary DEFAULT '' NOT NULL, + User char(16) binary DEFAULT '' NOT NULL, + Routine_name char(64) binary DEFAULT '' NOT NULL, + Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, + Grantor char(77) DEFAULT '' NOT NULL, + Proc_priv set('Execute','Alter Routine','Grant') + COLLATE utf8_general_ci DEFAULT '' NOT NULL, + Timestamp timestamp(14), + PRIMARY KEY (Host, Db, User, Routine_name, Routine_type), + KEY Grantor (Grantor) ) CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges'; +ALTER TABLE procs_priv + ENGINE=MyISAM, + CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin; + +ALTER TABLE procs_priv + MODIFY Proc_priv set('Execute','Alter Routine','Grant') + COLLATE utf8_general_ci DEFAULT '' NOT NULL; + +ALTER TABLE procs_priv + ADD Routine_type enum('FUNCTION','PROCEDURE') + COLLATE utf8_general_ci NOT NULL AFTER Routine_name; + +ALTER TABLE procs_priv + MODIFY Timestamp timestamp(14) AFTER Proc_priv; + +-- +-- help_topic +-- CREATE TABLE IF NOT EXISTS help_topic ( help_topic_id int unsigned not null, name varchar(64) not null, From e9d526f50a53b62cceb61d8889598430321e752f Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Wed, 29 Nov 2006 18:35:33 +0100 Subject: [PATCH 117/131] Merge fixes for new test cases --- mysql-test/r/mysql_upgrade.result | 4 ++-- mysql-test/t/system_mysql_db_fix40123.test | 2 +- mysql-test/t/system_mysql_db_fix50030.test | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/mysql_upgrade.result b/mysql-test/r/mysql_upgrade.result index e65b511fc41..434b7b2d23f 100644 --- a/mysql-test/r/mysql_upgrade.result +++ b/mysql-test/r/mysql_upgrade.result @@ -1,5 +1,5 @@ Run mysql_upgrade once -cluster.binlog_index OK +mysql.binlog_index OK mysql.columns_priv OK mysql.db OK mysql.event OK @@ -107,7 +107,7 @@ Run it again - should say already completed 1 1 Force should run it regardless of wheter it's been run before -cluster.binlog_index OK +mysql.binlog_index OK mysql.columns_priv OK mysql.db OK mysql.event OK diff --git a/mysql-test/t/system_mysql_db_fix40123.test b/mysql-test/t/system_mysql_db_fix40123.test index 5adefc2e966..2d4fd1e920f 100644 --- a/mysql-test/t/system_mysql_db_fix40123.test +++ b/mysql-test/t/system_mysql_db_fix40123.test @@ -69,7 +69,7 @@ CREATE TABLE time_zone_leap_second ( Transition_time bigint signed NOT NULL, -- disable_query_log # Drop all tables created by this test -DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event; +DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event, binlog_index; -- enable_query_log diff --git a/mysql-test/t/system_mysql_db_fix50030.test b/mysql-test/t/system_mysql_db_fix50030.test index 724786febaf..78ecf1e573c 100644 --- a/mysql-test/t/system_mysql_db_fix50030.test +++ b/mysql-test/t/system_mysql_db_fix50030.test @@ -72,7 +72,7 @@ CREATE TABLE procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char( -- disable_query_log # Drop all tables created by this test -DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event; +DROP TABLE db, host, user, func, plugin, tables_priv, columns_priv, procs_priv, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, general_log, slow_log, event, binlog_index; -- enable_query_log From d577e3d4a8bd50a95d55a7696967cb7e756e26f8 Mon Sep 17 00:00:00 2001 From: "cmiller@zippy.cornsilk.net" <> Date: Wed, 29 Nov 2006 12:49:21 -0500 Subject: [PATCH 118/131] Fix merges. --- mysql-test/r/func_misc.result | 2 +- mysql-test/r/mysql.result | 14 +++++++------- mysql-test/t/mysql.test | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result index cfea464dfd9..84974f845c5 100644 --- a/mysql-test/r/func_misc.result +++ b/mysql-test/r/func_misc.result @@ -138,7 +138,7 @@ create table t1 select INET_ATON('255.255.0.1') as `a`; show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` bigint(21) unsigned default NULL + `a` bigint(21) unsigned DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; End of 5.0 tests diff --git a/mysql-test/r/mysql.result b/mysql-test/r/mysql.result index cfcb3eaf334..3bba1944c52 100644 --- a/mysql-test/r/mysql.result +++ b/mysql-test/r/mysql.result @@ -61,16 +61,16 @@ database() test unlock tables; drop table t1; -ƒ\ -ƒ\ +ƒ\ +ƒ\ c_cp932 -ƒ\ -ƒ\ -ƒ\ +ƒ\ +ƒ\ +ƒ\ ソ ソ -ƒ\ -ƒ\ +ƒ\ +ƒ\ +----------------------+------------+--------+ | concat('>',col1,'<') | col2 | col3 | +----------------------+------------+--------+ diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test index 5f3f1140d4a..e21ecd3a790 100644 --- a/mysql-test/t/mysql.test +++ b/mysql-test/t/mysql.test @@ -52,10 +52,10 @@ drop table t1; --exec $MYSQL --default-character-set=cp932 test -e "charset utf8;" # its usage to switch internally in mysql to requested charset ---exec $MYSQL --default-character-set=utf8 test -e "charset cp932; select 'ƒ\'; create table t1 (c_cp932 TEXT CHARACTER SET cp932); insert into t1 values('ƒ\'); select * from t1; drop table t1;" ---exec $MYSQL --default-character-set=utf8 test -e "charset cp932; select 'ƒ\'" ---exec $MYSQL --default-character-set=utf8 test -e "/*charset cp932 */; set character_set_client= cp932; select 'ƒ\'" ---exec $MYSQL --default-character-set=utf8 test -e "/*!\C cp932 */; set character_set_client= cp932; select 'ƒ\'" +--exec $MYSQL --default-character-set=utf8 test -e "charset cp932; select 'ƒ\'; create table t1 (c_cp932 TEXT CHARACTER SET cp932); insert into t1 values('ƒ\'); select * from t1; drop table t1;" +--exec $MYSQL --default-character-set=utf8 test -e "charset cp932; select 'ƒ\'" +--exec $MYSQL --default-character-set=utf8 test -e "/*charset cp932 */; set character_set_client= cp932; select 'ƒ\'" +--exec $MYSQL --default-character-set=utf8 test -e "/*!\C cp932 */; set character_set_client= cp932; select 'ƒ\'" # # Bug#16859 -- NULLs in columns must not truncate data as if a C-language "string". From 7aec43481dc934c8dd12557a337951d017d0f84c Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Wed, 29 Nov 2006 21:38:38 +0100 Subject: [PATCH 119/131] Change mode of the checked in 4.1 version files so they are writable From 5f4acf145b662a8da13484f9a2eb866b9f286697 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Wed, 29 Nov 2006 22:49:02 +0100 Subject: [PATCH 120/131] After 5.1.6 just turn on logging, it will be sent to tables by default --- 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 0859b02167c..0b630c1f722 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -3474,6 +3474,11 @@ sub mysqld_arguments ($$$$$) { # Force mysqld to use log files up until 5.1.6 mtr_add_arg($args, "%s--log=%s", $prefix, $master->[0]->{'path_mylog'}); } + else + { + # Turn on logging, will be sent to tables + mtr_add_arg($args, "%s--log=", $prefix); + } } if ( $type eq 'slave' ) @@ -3557,6 +3562,11 @@ sub mysqld_arguments ($$$$$) { # Force mysqld to use log files up until 5.1.6 mtr_add_arg($args, "%s--log=%s", $prefix, $master->[0]->{'path_mylog'}); } + else + { + # Turn on logging, will be sent to tables + mtr_add_arg($args, "%s--log=", $prefix); + } } # end slave From db863d826c5de4a9eafca87b9aea0beec12434a8 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Wed, 29 Nov 2006 23:02:06 +0100 Subject: [PATCH 121/131] Add command "chmod" to mysqltest --- client/mysqltest.c | 45 +++++++++++++++++++++++++++++++++++ mysql-test/r/mysqltest.result | 6 +++++ mysql-test/t/mysqltest.test | 39 ++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+) diff --git a/client/mysqltest.c b/client/mysqltest.c index efb5f1915f4..29a31a6c60c 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -265,6 +265,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_CHMOD_FILE, Q_UNKNOWN, /* Unknown command. */ Q_COMMENT, /* Comments, ignored. */ @@ -345,6 +346,7 @@ const char *command_names[]= "copy_file", "perl", "die", + "chmod", 0 }; @@ -1751,6 +1753,48 @@ void do_copy_file(struct st_command *command) } +/* + SYNOPSIS + do_chmod_file + command command handle + + DESCRIPTION + chmod + Change file permission of + + NOTE! Simplified version, only supports +r, -r, +w, -w +*/ + +void do_chmod_file(struct st_command *command) +{ + mode_t mode= 0; + DYNAMIC_STRING ds_mode; + DYNAMIC_STRING ds_file; + const struct command_arg chmod_file_args[] = { + "mode", ARG_STRING, TRUE, &ds_mode, "Mode of file", + "file", ARG_STRING, TRUE, &ds_file, "Filename of file to modify" + }; + DBUG_ENTER("do_chmod_file"); + + check_command_args(command, command->first_argument, + chmod_file_args, + sizeof(chmod_file_args)/sizeof(struct command_arg), + ' '); + + /* Parse what mode to set */ + if (ds_mode.length != 4) + die("You must write a 4 digit octal number for mode"); + + str2int(ds_mode.str, 8, 0, INT_MAX, (long*)&mode); + + DBUG_PRINT("info", ("chmod %o %s", mode, ds_file.str)); + handle_command_error(command, chmod(ds_file.str, mode)); + dynstr_free(&ds_mode); + dynstr_free(&ds_file); + DBUG_VOID_RETURN; +} + + /* SYNOPSIS do_file_exists @@ -5604,6 +5648,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_COPY_FILE: do_copy_file(command); break; + case Q_CHMOD_FILE: do_chmod_file(command); break; case Q_PERL: do_perl(command); break; case Q_DELIMITER: do_delimiter(command); diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result index a0fce5f483f..ea9221fc476 100644 --- a/mysql-test/r/mysqltest.result +++ b/mysql-test/r/mysqltest.result @@ -512,6 +512,12 @@ mysqltest: At line 1: End of line junk detected: "write_file filename "; 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' +mysqltest: At line 1: Missing required argument 'mode' to command 'chmod' +mysqltest: At line 1: You must write a 4 digit octal number for mode +mysqltest: At line 1: You must write a 4 digit octal number for mode +mysqltest: At line 1: Missing required argument 'file' to command 'chmod' +mysqltest: At line 1: command "chmod" failed with error -1 +mysqltest: At line 1: You must write a 4 digit octal number for mode hello hello hello diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index d98375ca746..e11a0c5099f 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -1521,6 +1521,45 @@ remove_file $MYSQLTEST_VARDIR/tmp/file2.tmp; --error 1 --exec echo "copy_file from_file;" | $MYSQL_TEST 2>&1 +# ---------------------------------------------------------------------------- +# test for chmod +# ---------------------------------------------------------------------------- +--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp +file1 +EOF + +chmod 0000 $MYSQLTEST_VARDIR/tmp/file1.tmp; +# The below write fails, but --error is not implemented +# for write_file +#--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp +#test should fail +#EOF + +chmod 0777 $MYSQLTEST_VARDIR/tmp/file1.tmp; +--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp +test2 +EOF + +remove_file $MYSQLTEST_VARDIR/tmp/file1.tmp; + +--error 1 +--exec echo "chmod ;" | $MYSQL_TEST 2>&1 + +--error 1 +--exec echo "chmod 0 from_file;" | $MYSQL_TEST 2>&1 + +--error 1 +--exec echo "chmod 08 from_file;" | $MYSQL_TEST 2>&1 + +--error 1 +--exec echo "chmod from_file;" | $MYSQL_TEST 2>&1 + +--error 1 +--exec echo "chmod ABZD from_file;" | $MYSQL_TEST 2>&1 + +--error 1 +--exec echo "chmod 06789 from_file;" | $MYSQL_TEST 2>&1 + # ---------------------------------------------------------------------------- # test for perl # ---------------------------------------------------------------------------- From 68724b3a8d2815b396669d4f05cf4e978cbd51bd Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Wed, 29 Nov 2006 23:03:45 +0100 Subject: [PATCH 122/131] Bug#19371 VARBINARY() have trailing zeros after upgrade from 4.1 - chmod the saved files from 4.1 to make sure they are writable --- mysql-test/t/varbinary.test | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mysql-test/t/varbinary.test b/mysql-test/t/varbinary.test index a20359ac00e..0e45bfb5e1b 100644 --- a/mysql-test/t/varbinary.test +++ b/mysql-test/t/varbinary.test @@ -44,8 +44,11 @@ drop table t1; # Test with a saved table from 4.1 copy_file std_data/bug19371.frm $MYSQLTEST_VARDIR/master-data/test/t1.frm; +chmod 0777 $MYSQLTEST_VARDIR/master-data/test/t1.frm; copy_file std_data/bug19371.MYD $MYSQLTEST_VARDIR/master-data/test/t1.MYD; +chmod 0777 $MYSQLTEST_VARDIR/master-data/test/t1.MYD; copy_file std_data/bug19371.MYI $MYSQLTEST_VARDIR/master-data/test/t1.MYI; +chmod 0777 $MYSQLTEST_VARDIR/master-data/test/t1.MYI; # Everything _looks_ fine show create table t1; From 741eb0179a68ffd37c7f7c38c1dfe5bca932d899 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Wed, 29 Nov 2006 23:48:39 +0100 Subject: [PATCH 123/131] Update result to 5.1 version format --- mysql-test/r/varbinary.result | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/varbinary.result b/mysql-test/r/varbinary.result index 60445c022c6..e1ac58ecd52 100644 --- a/mysql-test/r/varbinary.result +++ b/mysql-test/r/varbinary.result @@ -29,8 +29,8 @@ drop table t1; show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` varbinary(255) default NULL, - `b` varchar(255) default NULL + `a` varbinary(255) DEFAULT NULL, + `b` varchar(255) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 select length(a), length(b) from t1; length(a) length(b) @@ -45,8 +45,8 @@ test.t1 repair status OK show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `a` varbinary(255) default NULL, - `b` varchar(255) default NULL + `a` varbinary(255) DEFAULT NULL, + `b` varchar(255) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 select length(a), length(b) from t1; length(a) length(b) From b9d696099a9b49c76619f76556be558fed8c31ac Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Thu, 30 Nov 2006 09:13:09 +0100 Subject: [PATCH 124/131] check_db_name know takes LEX_STRING* --- sql/sql_parse.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index ce59e334ab2..e2d732e6b15 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4435,7 +4435,7 @@ end_with_restore_list: Verify that the database name is allowed, optionally lowercase it. */ - if (check_db_name(lex->sphead->m_db.str)) + if (check_db_name(&lex->sphead->m_db)) { my_error(ER_WRONG_DB_NAME, MYF(0), lex->sphead->m_db.str); delete lex->sphead; From a743e17d8c790d19fbf5988feff1ec459865cd92 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Thu, 30 Nov 2006 10:54:50 +0100 Subject: [PATCH 125/131] Add "chmod" command to mysqltest --- client/mysqltest.c | 45 ++++++++++++++++++++++++++++++++++- mysql-test/r/mysqltest.result | 6 +++++ mysql-test/t/mysqltest.test | 40 +++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+), 1 deletion(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 78e74c23e54..372e62cbdcc 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -32,7 +32,7 @@ Holyfoot */ -#define MTEST_VERSION "3.0" +#define MTEST_VERSION "3.1" #include #include @@ -271,6 +271,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_UNKNOWN, /* Unknown command. */ Q_COMMENT, /* Comments, ignored. */ @@ -353,6 +354,7 @@ const char *command_names[]= "die", /* Don't execute any more commands, compare result */ "exit", + "chmod", 0 }; @@ -1808,6 +1810,46 @@ void do_copy_file(struct st_command *command) } +/* + SYNOPSIS + do_chmod_file + command command handle + + DESCRIPTION + chmod + Change file permission of + +*/ + +void do_chmod_file(struct st_command *command) +{ + ulong mode= 0; + static DYNAMIC_STRING ds_mode; + static DYNAMIC_STRING ds_file; + const struct command_arg chmod_file_args[] = { + "mode", ARG_STRING, TRUE, &ds_mode, "Mode of file", + "file", ARG_STRING, TRUE, &ds_file, "Filename of file to modify" + }; + DBUG_ENTER("do_chmod_file"); + + check_command_args(command, command->first_argument, + chmod_file_args, + sizeof(chmod_file_args)/sizeof(struct command_arg), + ' '); + + /* Parse what mode to set */ + if (ds_mode.length != 4 || + str2int(ds_mode.str, 8, 0, INT_MAX, &mode) == NullS) + die("You must write a 4 digit octal number for mode"); + + DBUG_PRINT("info", ("chmod %o %s", (uint)mode, ds_file.str)); + handle_command_error(command, chmod(ds_file.str, mode)); + dynstr_free(&ds_mode); + dynstr_free(&ds_file); + DBUG_VOID_RETURN; +} + + /* SYNOPSIS do_file_exists @@ -5693,6 +5735,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_COPY_FILE: do_copy_file(command); break; + case Q_CHMOD_FILE: do_chmod_file(command); break; case Q_PERL: do_perl(command); break; case Q_DELIMITER: do_delimiter(command); diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result index a63863977b0..3ddb82d4a8d 100644 --- a/mysql-test/r/mysqltest.result +++ b/mysql-test/r/mysqltest.result @@ -512,6 +512,12 @@ mysqltest: At line 1: End of line junk detected: "write_file filename "; 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' +mysqltest: At line 1: Missing required argument 'mode' to command 'chmod' +mysqltest: At line 1: You must write a 4 digit octal number for mode +mysqltest: At line 1: You must write a 4 digit octal number for mode +mysqltest: At line 1: Missing required argument 'file' to command 'chmod' +mysqltest: At line 1: You must write a 4 digit octal number for mode +mysqltest: At line 1: You must write a 4 digit octal number for mode hello hello hello diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index 3c20b38722f..c06d51d9d49 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -1521,6 +1521,46 @@ remove_file $MYSQLTEST_VARDIR/tmp/file2.tmp; --error 1 --exec echo "copy_file from_file;" | $MYSQL_TEST 2>&1 +# ---------------------------------------------------------------------------- +# test for chmod +# ---------------------------------------------------------------------------- +--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp +file1 +EOF + +chmod 0000 $MYSQLTEST_VARDIR/tmp/file1.tmp; +# The below write fails, but --error is not implemented +# for write_file +#--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp +#test should fail +#EOF + +chmod 0777 $MYSQLTEST_VARDIR/tmp/file1.tmp; +--write_file $MYSQLTEST_VARDIR/tmp/file1.tmp +test2 +EOF + +remove_file $MYSQLTEST_VARDIR/tmp/file1.tmp; + +--error 1 +--exec echo "chmod ;" | $MYSQL_TEST 2>&1 + +--error 1 +--exec echo "chmod 0 from_file;" | $MYSQL_TEST 2>&1 + +--error 1 +--exec echo "chmod 08 from_file;" | $MYSQL_TEST 2>&1 + +--error 1 +--exec echo "chmod from_file;" | $MYSQL_TEST 2>&1 + +--error 1 +--exec echo "chmod ABZD from_file;" | $MYSQL_TEST 2>&1 + +--error 1 +--exec echo "chmod 06789 from_file;" | $MYSQL_TEST 2>&1 + + # ---------------------------------------------------------------------------- # test for perl # ---------------------------------------------------------------------------- From 19def6ebe7d1251948ce64c2c3b57c5da189abb5 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Thu, 30 Nov 2006 11:33:26 +0100 Subject: [PATCH 126/131] Include *.MY* files from std_data in dist --- mysql-test/Makefile.am | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am index 49143332fe5..72998d786b9 100644 --- a/mysql-test/Makefile.am +++ b/mysql-test/Makefile.am @@ -66,6 +66,7 @@ dist-hook: $(INSTALL_DATA) $(srcdir)/std_data/des_key_file $(distdir)/std_data $(INSTALL_DATA) $(srcdir)/std_data/*.pem $(distdir)/std_data $(INSTALL_DATA) $(srcdir)/std_data/*.frm $(distdir)/std_data + $(INSTALL_DATA) $(srcdir)/std_data/*.MY* $(distdir)/std_data $(INSTALL_DATA) $(srcdir)/std_data/*.cnf $(distdir)/std_data $(INSTALL_DATA) $(srcdir)/lib/init_db.sql $(distdir)/lib $(INSTALL_DATA) $(srcdir)/lib/*.pl $(distdir)/lib @@ -97,6 +98,7 @@ install-data-local: $(INSTALL_DATA) $(srcdir)/std_data/Moscow_leap $(DESTDIR)$(testdir)/std_data $(INSTALL_DATA) $(srcdir)/std_data/*.pem $(DESTDIR)$(testdir)/std_data $(INSTALL_DATA) $(srcdir)/std_data/*.frm $(DESTDIR)$(testdir)/std_data + $(INSTALL_DATA) $(srcdir)/std_data/*.MY* $(distdir)/std_data $(INSTALL_DATA) $(srcdir)/std_data/*.cnf $(DESTDIR)$(testdir)/std_data $(INSTALL_DATA) $(srcdir)/lib/init_db.sql $(DESTDIR)$(testdir)/lib $(INSTALL_DATA) $(srcdir)/lib/*.pl $(DESTDIR)$(testdir)/lib From b4575723852ba85feb165c18577d91bc7a94065a Mon Sep 17 00:00:00 2001 From: "iggy@rolltop.ignatz42.dyndns.org" <> Date: Thu, 30 Nov 2006 21:04:02 -0500 Subject: [PATCH 127/131] Bug#17951: myisampack --force --silent : abnormal end in Windows XP -myisampack wrote to a block on the heap that it did not allocate. --- myisam/myisampack.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/myisam/myisampack.c b/myisam/myisampack.c index e80a3ffacd9..4582044009f 100644 --- a/myisam/myisampack.c +++ b/myisam/myisampack.c @@ -2922,6 +2922,8 @@ static void flush_bits(void) bits-= 8; *file_buffer.pos++= (uchar) (bit_buffer >> bits); } + if (file_buffer.pos >= file_buffer.end) + VOID(flush_buffer(~ (ulong) 0)); file_buffer.bits= BITS_SAVED; file_buffer.bitbucket= 0; } From 6c8d7ea8949eb938b1428ab85d199c6dfcbc2576 Mon Sep 17 00:00:00 2001 From: "Kristofer.Pettersson@naruto." <> Date: Fri, 1 Dec 2006 09:49:19 +0100 Subject: [PATCH 128/131] Bug#17733 Flushing logs causes daily server crash Server crashes if a flush commmand is issued and binlog is closed. - added check to prevent binlog access when binlog file isn't opened. --- mysql-test/r/flush2.result | 24 ++++++++++++++++++++++++ mysql-test/t/flush2-master.opt | 1 + mysql-test/t/flush2.test | 9 +++++++++ sql/sql_parse.cc | 11 ++++++++--- 4 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 mysql-test/r/flush2.result create mode 100644 mysql-test/t/flush2-master.opt create mode 100644 mysql-test/t/flush2.test diff --git a/mysql-test/r/flush2.result b/mysql-test/r/flush2.result new file mode 100644 index 00000000000..7c94219fd71 --- /dev/null +++ b/mysql-test/r/flush2.result @@ -0,0 +1,24 @@ +flush logs; +set global expire_logs_days = 3; +show variables like 'log%'; +Variable_name Value +log ON +log_bin OFF +log_bin_trust_function_creators ON +log_error +log_queries_not_using_indexes OFF +log_slave_updates OFF +log_slow_queries OFF +log_warnings 1 +flush logs; +show variables like 'log%'; +Variable_name Value +log ON +log_bin OFF +log_bin_trust_function_creators ON +log_error +log_queries_not_using_indexes OFF +log_slave_updates OFF +log_slow_queries OFF +log_warnings 1 +set global expire_logs_days = 0; diff --git a/mysql-test/t/flush2-master.opt b/mysql-test/t/flush2-master.opt new file mode 100644 index 00000000000..ccbd01c91d3 --- /dev/null +++ b/mysql-test/t/flush2-master.opt @@ -0,0 +1 @@ +--disable-log-bin diff --git a/mysql-test/t/flush2.test b/mysql-test/t/flush2.test new file mode 100644 index 00000000000..fc9e88e3141 --- /dev/null +++ b/mysql-test/t/flush2.test @@ -0,0 +1,9 @@ +# +# Bug#17733 Flushing logs causes daily server crash +# +flush logs; +set global expire_logs_days = 3; +show variables like 'log%'; +flush logs; +show variables like 'log%'; +set global expire_logs_days = 0; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 4992d2514c9..acc4b48e5a6 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4008,8 +4008,9 @@ end_with_restore_list: case SQLCOM_FLUSH: { bool write_to_binlog; - if (check_global_access(thd,RELOAD_ACL) || check_db_used(thd, all_tables)) + if (check_global_access(thd,RELOAD_ACL)) goto error; + /* reload_acl_and_cache() will tell us if we are allowed to write to the binlog or not. @@ -4030,7 +4031,8 @@ end_with_restore_list: } } send_ok(thd); - } + } + break; } case SQLCOM_KILL: @@ -6696,7 +6698,10 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables, tmp_write_to_binlog= 0; mysql_log.new_file(1); mysql_slow_log.new_file(1); - mysql_bin_log.rotate_and_purge(RP_FORCE_ROTATE); + if( mysql_bin_log.is_open() ) + { + mysql_bin_log.rotate_and_purge(RP_FORCE_ROTATE); + } #ifdef HAVE_REPLICATION pthread_mutex_lock(&LOCK_active_mi); rotate_relay_log(active_mi); From b201d4ef9382429b32c2da56121754014e48de01 Mon Sep 17 00:00:00 2001 From: "thek@kpdesk.mysql.com" <> Date: Fri, 1 Dec 2006 12:50:57 +0100 Subject: [PATCH 129/131] Bug#22043 MySQL don't add "USE " before "DROP PROCEDURE IF EXISTS" - Refactoring of duplicate code - Modified bad test cases - Changed expected error when operating on information_schema. --- mysql-test/r/information_schema.result | 2 +- mysql-test/r/rpl_sp.result | 21 ++--- mysql-test/t/information_schema.test | 2 +- mysql-test/t/rpl_sp.test | 3 +- sql/sql_parse.cc | 125 ++++++++++--------------- 5 files changed, 64 insertions(+), 89 deletions(-) diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index 3fffce73aa9..4de6e3c823d 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -1027,7 +1027,7 @@ CREATE PROCEDURE p1 () BEGIN SELECT 'foo' FROM DUAL; END | -ERROR 42000: Access denied for user 'root'@'localhost' to database 'information_schema' +ERROR 42000: Unknown database 'information_schema' select ROUTINE_NAME from routines; ROUTINE_NAME grant all on information_schema.* to 'user1'@'localhost'; diff --git a/mysql-test/r/rpl_sp.result b/mysql-test/r/rpl_sp.result index d6f9880de17..5c35cd8097f 100644 --- a/mysql-test/r/rpl_sp.result +++ b/mysql-test/r/rpl_sp.result @@ -465,6 +465,7 @@ RETURN 0 DROP PROCEDURE p1; DROP FUNCTION f1; drop table t1; +reset master; drop database if exists mysqltest; drop database if exists mysqltest2; create database mysqltest; @@ -473,19 +474,15 @@ use mysqltest2; create table t ( t integer ); create procedure mysqltest.test() begin end; insert into t values ( 1 ); -show binlog events in 'master-bin.000001' from 8186; +show binlog events in 'master-bin.000001' from 98; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 8186 Query 1 8317 use `test`; CREATE DEFINER=`root`@`localhost` FUNCTION f1() RETURNS INT RETURN 0 -master-bin.000001 8317 Query 1 8397 use `test`; DROP PROCEDURE p1 -master-bin.000001 8397 Query 1 8476 use `test`; DROP FUNCTION f1 -master-bin.000001 8476 Query 1 8552 use `test`; drop table t1 -master-bin.000001 8552 Query 1 8653 drop database if exists mysqltest -master-bin.000001 8653 Query 1 8756 drop database if exists mysqltest2 -master-bin.000001 8756 Query 1 8849 create database mysqltest -master-bin.000001 8849 Query 1 8944 create database mysqltest2 -master-bin.000001 8944 Query 1 9041 use `mysqltest2`; create table t ( t integer ) -master-bin.000001 9041 Query 1 9180 use `mysqltest2`; CREATE DEFINER=`root`@`localhost` procedure mysqltest.test() begin end -master-bin.000001 9180 Query 1 9275 use `mysqltest2`; insert into t values ( 1 ) +master-bin.000001 98 Query 1 199 drop database if exists mysqltest +master-bin.000001 199 Query 1 302 drop database if exists mysqltest2 +master-bin.000001 302 Query 1 395 create database mysqltest +master-bin.000001 395 Query 1 490 create database mysqltest2 +master-bin.000001 490 Query 1 587 use `mysqltest2`; create table t ( t integer ) +master-bin.000001 587 Query 1 726 use `mysqltest2`; CREATE DEFINER=`root`@`localhost` procedure mysqltest.test() begin end +master-bin.000001 726 Query 1 821 use `mysqltest2`; insert into t values ( 1 ) create procedure `\\`.test() begin end; ERROR 42000: Incorrect database name '\\' drop database mysqltest; diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index 27007bbe16a..18e5faf7178 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -715,7 +715,7 @@ create temporary table schemata(f1 char(10)); # Bug #10708 SP's can use INFORMATION_SCHEMA as ROUTINE_SCHEMA # delimiter |; ---error 1044 +--error ER_BAD_DB_ERROR CREATE PROCEDURE p1 () BEGIN SELECT 'foo' FROM DUAL; diff --git a/mysql-test/t/rpl_sp.test b/mysql-test/t/rpl_sp.test index b7a9036908c..5dc4ba5a4db 100644 --- a/mysql-test/t/rpl_sp.test +++ b/mysql-test/t/rpl_sp.test @@ -524,6 +524,7 @@ sync_slave_with_master; # Bug22043: MySQL don't add "USE " before "DROP PROCEDURE IF EXISTS" # connection master; +reset master; --disable_warnings drop database if exists mysqltest; drop database if exists mysqltest2; @@ -534,7 +535,7 @@ use mysqltest2; create table t ( t integer ); create procedure mysqltest.test() begin end; insert into t values ( 1 ); -show binlog events in 'master-bin.000001' from 8186; +show binlog events in 'master-bin.000001' from 98; --error ER_WRONG_DB_NAME create procedure `\\`.test() begin end; # Clean up diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 2feaebdde25..434ba3aa94f 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4221,11 +4221,10 @@ end_with_restore_list: { uint namelen; char *name; - int result; + int result= SP_INTERNAL_ERROR; DBUG_ASSERT(lex->sphead != 0); DBUG_ASSERT(lex->sphead->m_db.str); /* Must be initialized in the parser */ - /* Verify that the database name is allowed, optionally lowercase it. @@ -4233,37 +4232,26 @@ end_with_restore_list: if (check_db_name(lex->sphead->m_db.str)) { my_error(ER_WRONG_DB_NAME, MYF(0), lex->sphead->m_db.str); - delete lex->sphead; - lex->sphead= 0; - goto error; + goto create_sp_error; } /* - Check that a database with this name - exists. + Check that a database directory with this name + exists. Design note: This won't work on virtual databases + like information_schema. */ if (check_db_dir_existence(lex->sphead->m_db.str)) { my_error(ER_BAD_DB_ERROR, MYF(0), lex->sphead->m_db.str); - delete lex->sphead; - lex->sphead= 0; - goto error; + goto create_sp_error; } if (check_access(thd, CREATE_PROC_ACL, lex->sphead->m_db.str, 0, 0, 0, is_schema_db(lex->sphead->m_db.str))) - { - delete lex->sphead; - lex->sphead= 0; - goto error; - } + goto create_sp_error; - if (end_active_trans(thd)) - { - delete lex->sphead; - lex->sphead= 0; - goto error; - } + if (end_active_trans(thd)) + goto create_sp_error; name= lex->sphead->name(&namelen); #ifdef HAVE_DLOPEN @@ -4273,10 +4261,8 @@ end_with_restore_list: if (udf) { - my_error(ER_UDF_EXISTS, MYF(0), name); - delete lex->sphead; - lex->sphead= 0; - goto error; + my_error(ER_UDF_EXISTS, MYF(0), name); + goto create_sp_error; } } #endif @@ -4284,7 +4270,7 @@ end_with_restore_list: /* If the definer is not specified, this means that CREATE-statement missed DEFINER-clause. DEFINER-clause can be missed in two cases: - + - The user submitted a statement w/o the clause. This is a normal case, we should assign CURRENT_USER as definer. @@ -4293,7 +4279,7 @@ end_with_restore_list: CURRENT_USER as definer here, but also we should mark this routine as NON-SUID. This is essential for the sake of backward compatibility. - + The problem is the slave thread is running under "special" user (@), that actually does not exist. In the older versions we do not fail execution of a stored routine if its definer does not exist and @@ -4318,13 +4304,9 @@ end_with_restore_list: if (ps_arena) thd->restore_active_arena(ps_arena, &original_arena); + /* Error has been already reported. */ if (res) - { - /* Error has been already reported. */ - delete lex->sphead; - lex->sphead= 0; - goto error; - } + goto create_sp_error; if (thd->slave_thread) lex->sphead->m_chistics->suid= SP_IS_NOT_SUID; @@ -4335,7 +4317,7 @@ end_with_restore_list: that the current user has SUPER privilege (in order to create a stored routine under another user one must have SUPER privilege). */ - + else if (strcmp(lex->definer->user.str, thd->security_ctx->priv_user) || my_strcasecmp(system_charset_info, lex->definer->host.str, @@ -4344,9 +4326,7 @@ end_with_restore_list: if (check_global_access(thd, SUPER_ACL)) { my_error(ER_SPECIFIC_ACCESS_DENIED_ERROR, MYF(0), "SUPER"); - delete lex->sphead; - lex->sphead= 0; - goto error; + goto create_sp_error; } } @@ -4366,54 +4346,51 @@ end_with_restore_list: #endif /* NO_EMBEDDED_ACCESS_CHECKS */ res= (result= lex->sphead->create(thd)); - if (result == SP_OK) - { + switch (result) { + case SP_OK: #ifndef NO_EMBEDDED_ACCESS_CHECKS /* only add privileges if really neccessary */ if (sp_automatic_privileges && !opt_noacl && check_routine_access(thd, DEFAULT_CREATE_PROC_ACLS, - lex->sphead->m_db.str, name, + lex->sphead->m_db.str, name, lex->sql_command == SQLCOM_CREATE_PROCEDURE, 1)) { - close_thread_tables(thd); if (sp_grant_privileges(thd, lex->sphead->m_db.str, name, lex->sql_command == SQLCOM_CREATE_PROCEDURE)) - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, - ER_PROC_AUTO_GRANT_FAIL, - ER(ER_PROC_AUTO_GRANT_FAIL)); + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_PROC_AUTO_GRANT_FAIL, + ER(ER_PROC_AUTO_GRANT_FAIL)); + close_thread_tables(thd); } #endif - lex->unit.cleanup(); - delete lex->sphead; - lex->sphead= 0; - send_ok(thd); - } - else - { - switch (result) { - case SP_WRITE_ROW_FAILED: - my_error(ER_SP_ALREADY_EXISTS, MYF(0), SP_TYPE_STRING(lex), name); - break; - case SP_NO_DB_ERROR: - my_error(ER_BAD_DB_ERROR, MYF(0), lex->sphead->m_db.str); - break; - case SP_BAD_IDENTIFIER: - my_error(ER_TOO_LONG_IDENT, MYF(0), name); - break; - case SP_BODY_TOO_LONG: - my_error(ER_TOO_LONG_BODY, MYF(0), name); - break; - default: - my_error(ER_SP_STORE_FAILED, MYF(0), SP_TYPE_STRING(lex), name); - break; - } - lex->unit.cleanup(); - delete lex->sphead; - lex->sphead= 0; - goto error; - } break; - } + case SP_WRITE_ROW_FAILED: + my_error(ER_SP_ALREADY_EXISTS, MYF(0), SP_TYPE_STRING(lex), name); + break; + case SP_BAD_IDENTIFIER: + my_error(ER_TOO_LONG_IDENT, MYF(0), name); + break; + case SP_BODY_TOO_LONG: + my_error(ER_TOO_LONG_BODY, MYF(0), name); + break; + default: + my_error(ER_SP_STORE_FAILED, MYF(0), SP_TYPE_STRING(lex), name); + break; + } /* end switch */ + + /* + Capture all errors within this CASE and + clean up the environment. + */ +create_sp_error: + lex->unit.cleanup(); + delete lex->sphead; + lex->sphead= 0; + if (result != SP_OK ) + goto error; + send_ok(thd); + break; /* break super switch */ + } /* end case group bracket */ case SQLCOM_CALL: { sp_head *sp; From 620a9891335741da66ad26edd753044aaa1dd945 Mon Sep 17 00:00:00 2001 From: "thek@kpdesk.mysql.com" <> Date: Fri, 1 Dec 2006 17:36:51 +0100 Subject: [PATCH 130/131] Bug#22043 MySQL don't add "USE " before "DROP PROCEDURE IF EXISTS" - Merged; updated test case. --- mysql-test/r/rpl_sp.result | 16 +++++++++------- mysql-test/t/rpl_sp.test | 3 ++- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/rpl_sp.result b/mysql-test/r/rpl_sp.result index f3754f650fb..fe54b1cbeb4 100644 --- a/mysql-test/r/rpl_sp.result +++ b/mysql-test/r/rpl_sp.result @@ -468,6 +468,7 @@ drop table t1; set global log_bin_trust_function_creators=0; set global log_bin_trust_function_creators=0; End of 5.0 tests +reset master; drop database if exists mysqltest; drop database if exists mysqltest2; create database mysqltest; @@ -476,14 +477,15 @@ use mysqltest2; create table t ( t integer ); create procedure mysqltest.test() begin end; insert into t values ( 1 ); -show binlog events in 'master-bin.000001' from 8657; +show binlog events in 'master-bin.000001' from 102; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000001 8657 Query 1 8760 drop database if exists mysqltest2 -master-bin.000001 8760 Query 1 8853 create database mysqltest -master-bin.000001 8853 Query 1 8948 create database mysqltest2 -master-bin.000001 8948 Query 1 9045 use `mysqltest2`; create table t ( t integer ) -master-bin.000001 9045 Query 1 9184 use `mysqltest2`; CREATE DEFINER=`root`@`localhost` procedure mysqltest.test() begin end -master-bin.000001 9184 Query 1 9279 use `mysqltest2`; insert into t values ( 1 ) +master-bin.000001 102 Query 1 203 drop database if exists mysqltest +master-bin.000001 203 Query 1 306 drop database if exists mysqltest2 +master-bin.000001 306 Query 1 399 create database mysqltest +master-bin.000001 399 Query 1 494 create database mysqltest2 +master-bin.000001 494 Query 1 591 use `mysqltest2`; create table t ( t integer ) +master-bin.000001 591 Query 1 730 use `mysqltest2`; CREATE DEFINER=`root`@`localhost` procedure mysqltest.test() begin end +master-bin.000001 730 Query 1 825 use `mysqltest2`; insert into t values ( 1 ) create procedure `\\`.test() begin end; ERROR 42000: Unknown database '\\' drop database mysqltest; diff --git a/mysql-test/t/rpl_sp.test b/mysql-test/t/rpl_sp.test index 2f0d04eff35..3a93a6608cd 100644 --- a/mysql-test/t/rpl_sp.test +++ b/mysql-test/t/rpl_sp.test @@ -532,6 +532,7 @@ set global log_bin_trust_function_creators=0; # Bug22043: MySQL don't add "USE " before "DROP PROCEDURE IF EXISTS" # connection master; +reset master; --disable_warnings drop database if exists mysqltest; drop database if exists mysqltest2; @@ -542,7 +543,7 @@ use mysqltest2; create table t ( t integer ); create procedure mysqltest.test() begin end; insert into t values ( 1 ); -show binlog events in 'master-bin.000001' from 8657; +show binlog events in 'master-bin.000001' from 102; --error ER_BAD_DB_ERROR create procedure `\\`.test() begin end; # Clean up From 88ba7676c1a506b941a61848ea01375ba13fcde1 Mon Sep 17 00:00:00 2001 From: "malff/marcsql@weblab.(none)" <> Date: Fri, 1 Dec 2006 19:16:03 -0700 Subject: [PATCH 131/131] Bug#24736: UDF functions parsed as Stored Functions Before this fix, a call to a User Defined Function (UDF) could, under some circumstances, be interpreted as a call to a Stored function instead. This occurred if a native function was invoked in the parameters for the UDF, as in "select my_udf(abs(x))". The root cause of this defect is the introduction, by the fix for Bug 21809, of st_select_lex::udf_list, and it's usage in the parser in sql_yacc.yy in the rule function_call_generic (in 5.1). While the fix itself for Bug 21809 is correct in 5.0, the code change merged into the 5.1 release created the issue, because the calls in 5.1 to : - lex->current_select->udf_list.push_front(udf) - lex->current_select->udf_list.pop() are not balanced in case of native functions, causing the udf_list, which is really a stack, to be out of sync with the internal stack maintained by the bison parser. Instead of moving the call to udf_list.pop(), which would have fixed the symptom, this patch goes further and removes the need for udf_list. This is motivated by two reasons: a) Maintaining a stack in the MySQL code in sync with the stack maintained internally in sql_yacc.cc (not .yy) is extremely dependent of the implementation of yacc/bison, and extremely difficult to maintain. It's also totally dependent of the structure of the grammar, and has a risk to break with regression defects each time the grammar itself is changed. b) The previous code did report construct like "foo(expr AS name)" as syntax errors (ER_PARSER_ERROR), which is incorrect, and misleading. The syntax is perfectly valid, as this expression is valid when "foo" is a UDF. Whether this syntax is legal or not depends of the semantic of "foo". With this change: a) There is only one stack (in bison), and no List to maintain. b) "foo(expr AS name)", when used incorrectly, is reported as semantic error: - ER_WRONG_PARAMETERS_TO_NATIVE_FCT (for native functions) - ER_WRONG_PARAMETERS_TO_STORED_FCT (for stored functions) This is achieved by the changes implemented in item_create.cc --- mysql-test/r/parser.result | 101 ++++++++++++++ mysql-test/r/udf.result | 26 +++- mysql-test/t/parser.test | 110 +++++++++++++++ mysql-test/t/udf.test | 20 ++- sql/item_create.cc | 278 ++++++++++++++++++++++++++----------- sql/share/errmsg.txt | 2 + sql/sql_lex.cc | 2 - sql/sql_lex.h | 2 - sql/sql_yacc.yy | 19 +-- 9 files changed, 459 insertions(+), 101 deletions(-) diff --git a/mysql-test/r/parser.result b/mysql-test/r/parser.result index afd78561898..5ba11d75a5a 100644 --- a/mysql-test/r/parser.result +++ b/mysql-test/r/parser.result @@ -386,3 +386,104 @@ select yearweek(); ERROR 42000: Incorrect parameter count in the call to native function 'yearweek' select yearweek(1, 2, 3); ERROR 42000: Incorrect parameter count in the call to native function 'yearweek' +select abs(3); +abs(3) +3 +select abs(3 AS three); +ERROR 42000: Incorrect parameters in the call to native function 'abs' +select abs(3 three); +ERROR 42000: Incorrect parameters in the call to native function 'abs' +select abs(3 AS "three"); +ERROR 42000: Incorrect parameters in the call to native function 'abs' +select abs(3 "three"); +ERROR 42000: Incorrect parameters in the call to native function 'abs' +set @bar="bar"; +set @foobar="foobar"; +select instr("foobar", "bar"); +instr("foobar", "bar") +4 +select instr("foobar" AS p1, "bar"); +ERROR 42000: Incorrect parameters in the call to native function 'instr' +select instr("foobar" p1, "bar"); +ERROR 42000: Incorrect parameters in the call to native function 'instr' +select instr("foobar" AS "p1", "bar"); +ERROR 42000: Incorrect parameters in the call to native function 'instr' +select instr("foobar" "p1", "bar"); +instr("foobar" "p1", "bar") +4 +select instr(@foobar "p1", "bar"); +ERROR 42000: Incorrect parameters in the call to native function 'instr' +select instr("foobar", "bar" AS p2); +ERROR 42000: Incorrect parameters in the call to native function 'instr' +select instr("foobar", "bar" p2); +ERROR 42000: Incorrect parameters in the call to native function 'instr' +select instr("foobar", "bar" AS "p2"); +ERROR 42000: Incorrect parameters in the call to native function 'instr' +select instr("foobar", "bar" "p2"); +instr("foobar", "bar" "p2") +0 +select instr("foobar", @bar "p2"); +ERROR 42000: Incorrect parameters in the call to native function 'instr' +select instr("foobar" AS p1, "bar" AS p2); +ERROR 42000: Incorrect parameters in the call to native function 'instr' +select conv(255, 10, 16); +conv(255, 10, 16) +FF +select conv(255 AS p1, 10, 16); +ERROR 42000: Incorrect parameters in the call to native function 'conv' +select conv(255 p1, 10, 16); +ERROR 42000: Incorrect parameters in the call to native function 'conv' +select conv(255 AS "p1", 10, 16); +ERROR 42000: Incorrect parameters in the call to native function 'conv' +select conv(255 "p1", 10, 16); +ERROR 42000: Incorrect parameters in the call to native function 'conv' +select conv(255, 10 AS p2, 16); +ERROR 42000: Incorrect parameters in the call to native function 'conv' +select conv(255, 10 p2, 16); +ERROR 42000: Incorrect parameters in the call to native function 'conv' +select conv(255, 10 AS "p2", 16); +ERROR 42000: Incorrect parameters in the call to native function 'conv' +select conv(255, 10 "p2", 16); +ERROR 42000: Incorrect parameters in the call to native function 'conv' +select conv(255, 10, 16 AS p3); +ERROR 42000: Incorrect parameters in the call to native function 'conv' +select conv(255, 10, 16 p3); +ERROR 42000: Incorrect parameters in the call to native function 'conv' +select conv(255, 10, 16 AS "p3"); +ERROR 42000: Incorrect parameters in the call to native function 'conv' +select conv(255, 10, 16 "p3"); +ERROR 42000: Incorrect parameters in the call to native function 'conv' +select conv(255 AS p1, 10 AS p2, 16 AS p3); +ERROR 42000: Incorrect parameters in the call to native function 'conv' +select atan(10); +atan(10) +1.4711276743037 +select atan(10 AS p1); +ERROR 42000: Incorrect parameters in the call to native function 'atan' +select atan(10 p1); +ERROR 42000: Incorrect parameters in the call to native function 'atan' +select atan(10 AS "p1"); +ERROR 42000: Incorrect parameters in the call to native function 'atan' +select atan(10 "p1"); +ERROR 42000: Incorrect parameters in the call to native function 'atan' +select atan(10, 20); +atan(10, 20) +0.46364760900081 +select atan(10 AS p1, 20); +ERROR 42000: Incorrect parameters in the call to native function 'atan' +select atan(10 p1, 20); +ERROR 42000: Incorrect parameters in the call to native function 'atan' +select atan(10 AS "p1", 20); +ERROR 42000: Incorrect parameters in the call to native function 'atan' +select atan(10 "p1", 20); +ERROR 42000: Incorrect parameters in the call to native function 'atan' +select atan(10, 20 AS p2); +ERROR 42000: Incorrect parameters in the call to native function 'atan' +select atan(10, 20 p2); +ERROR 42000: Incorrect parameters in the call to native function 'atan' +select atan(10, 20 AS "p2"); +ERROR 42000: Incorrect parameters in the call to native function 'atan' +select atan(10, 20 "p2"); +ERROR 42000: Incorrect parameters in the call to native function 'atan' +select atan(10 AS p1, 20 AS p2); +ERROR 42000: Incorrect parameters in the call to native function 'atan' diff --git a/mysql-test/r/udf.result b/mysql-test/r/udf.result index 69c860d8f85..52c59e6feb0 100644 --- a/mysql-test/r/udf.result +++ b/mysql-test/r/udf.result @@ -132,9 +132,9 @@ a c 1 1 2 2 SELECT a, fn(MIN(b) xx) as c FROM t1 GROUP BY a; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'xx) as c FROM t1 GROUP BY a' at line 1 +ERROR 42000: Incorrect parameters in the call to stored function 'fn' SELECT myfunc_int(fn(MIN(b) xx)) as c FROM t1 GROUP BY a; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'xx)) as c FROM t1 GROUP BY a' at line 1 +ERROR 42000: Incorrect parameters in the call to stored function 'fn' SELECT myfunc_int(test.fn(MIN(b) xx)) as c FROM t1 GROUP BY a; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'xx)) as c FROM t1 GROUP BY a' at line 1 SELECT myfunc_int(fn(MIN(b)) xx) as c FROM t1 GROUP BY a; @@ -185,6 +185,28 @@ DROP VIEW v1; DROP TABLE t1; DROP FUNCTION fn; End of 5.0 tests. +select myfunc_double(3); +myfunc_double(3) +51.00 +select myfunc_double(3 AS three); +myfunc_double(3 AS three) +51.00 +select myfunc_double(abs(3)); +myfunc_double(abs(3)) +51.00 +select myfunc_double(abs(3) AS named_param); +myfunc_double(abs(3) AS named_param) +51.00 +select abs(myfunc_double(3)); +abs(myfunc_double(3)) +51.00 +select abs(myfunc_double(3 AS three)); +abs(myfunc_double(3 AS three)) +51.00 +select myfunc_double(abs(3 AS wrong)); +ERROR 42000: Incorrect parameters in the call to native function 'abs' +select abs(myfunc_double(3) AS wrong); +ERROR 42000: Incorrect parameters in the call to native function 'abs' DROP FUNCTION metaphon; DROP FUNCTION myfunc_double; DROP FUNCTION myfunc_nonexist; diff --git a/mysql-test/t/parser.test b/mysql-test/t/parser.test index 11af7c691d8..63e5137b3a3 100644 --- a/mysql-test/t/parser.test +++ b/mysql-test/t/parser.test @@ -508,3 +508,113 @@ select yearweek(); -- error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT select yearweek(1, 2, 3); +# +# Bug#24736: UDF functions parsed as Stored Functions +# + +# Verify that the syntax for calling UDF : foo(expr AS param, ...) +# can not be used when calling native functions + +# Native function with 1 argument + +select abs(3); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select abs(3 AS three); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select abs(3 three); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select abs(3 AS "three"); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select abs(3 "three"); + +# Native function with 2 arguments + +set @bar="bar"; +set @foobar="foobar"; + +select instr("foobar", "bar"); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select instr("foobar" AS p1, "bar"); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select instr("foobar" p1, "bar"); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select instr("foobar" AS "p1", "bar"); +## String concatenation, valid syntax +select instr("foobar" "p1", "bar"); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select instr(@foobar "p1", "bar"); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select instr("foobar", "bar" AS p2); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select instr("foobar", "bar" p2); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select instr("foobar", "bar" AS "p2"); +## String concatenation, valid syntax +select instr("foobar", "bar" "p2"); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select instr("foobar", @bar "p2"); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select instr("foobar" AS p1, "bar" AS p2); + +# Native function with 3 arguments + +select conv(255, 10, 16); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select conv(255 AS p1, 10, 16); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select conv(255 p1, 10, 16); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select conv(255 AS "p1", 10, 16); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select conv(255 "p1", 10, 16); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select conv(255, 10 AS p2, 16); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select conv(255, 10 p2, 16); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select conv(255, 10 AS "p2", 16); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select conv(255, 10 "p2", 16); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select conv(255, 10, 16 AS p3); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select conv(255, 10, 16 p3); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select conv(255, 10, 16 AS "p3"); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select conv(255, 10, 16 "p3"); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select conv(255 AS p1, 10 AS p2, 16 AS p3); + +# Native function with a variable number of arguments + +select atan(10); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select atan(10 AS p1); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select atan(10 p1); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select atan(10 AS "p1"); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select atan(10 "p1"); + +select atan(10, 20); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select atan(10 AS p1, 20); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select atan(10 p1, 20); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select atan(10 AS "p1", 20); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select atan(10 "p1", 20); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select atan(10, 20 AS p2); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select atan(10, 20 p2); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select atan(10, 20 AS "p2"); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select atan(10, 20 "p2"); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select atan(10 AS p1, 20 AS p2); + diff --git a/mysql-test/t/udf.test b/mysql-test/t/udf.test index 52ae424e423..24ddc1d44bc 100644 --- a/mysql-test/t/udf.test +++ b/mysql-test/t/udf.test @@ -149,9 +149,9 @@ EXPLAIN EXTENDED SELECT myfunc_int(a AS attr_name) FROM t1; EXPLAIN EXTENDED SELECT myfunc_int(a) FROM t1; SELECT a,c FROM v1; ---error ER_PARSE_ERROR +--error ER_WRONG_PARAMETERS_TO_STORED_FCT SELECT a, fn(MIN(b) xx) as c FROM t1 GROUP BY a; ---error ER_PARSE_ERROR +--error ER_WRONG_PARAMETERS_TO_STORED_FCT SELECT myfunc_int(fn(MIN(b) xx)) as c FROM t1 GROUP BY a; --error ER_PARSE_ERROR SELECT myfunc_int(test.fn(MIN(b) xx)) as c FROM t1 GROUP BY a; @@ -173,6 +173,22 @@ DROP FUNCTION fn; --echo End of 5.0 tests. +# +# Bug#24736: UDF functions parsed as Stored Functions +# + +select myfunc_double(3); +select myfunc_double(3 AS three); +select myfunc_double(abs(3)); +select myfunc_double(abs(3) AS named_param); +select abs(myfunc_double(3)); +select abs(myfunc_double(3 AS three)); + +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select myfunc_double(abs(3 AS wrong)); +-- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT +select abs(myfunc_double(3) AS wrong); + # # Drop the example functions from udf_example # diff --git a/sql/item_create.cc b/sql/item_create.cc index 7722ce28d4a..6f77cc0fa14 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -27,6 +27,37 @@ ============================================================================= */ +/** + Adapter for native functions with a variable number of arguments. + The main use of this class is to discard the following calls: + foo(expr1 AS name1, expr2 AS name2, ...) + which are syntactically correct (the syntax can refer to a UDF), + but semantically invalid for native functions. +*/ + +class Create_native_func : public Create_func +{ +public: + virtual Item* create(THD *thd, LEX_STRING name, List *item_list); + + /** + Builder method, with no arguments. + @param thd The current thread + @param name The native function name + @param item_list The function parameters, none of which are named + @return An item representing the function call + */ + virtual Item* create_native(THD *thd, LEX_STRING name, + List *item_list) = 0; + +protected: + /** Constructor. */ + Create_native_func() {} + /** Destructor. */ + virtual ~Create_native_func() {} +}; + + /** Adapter for functions that takes exactly zero arguments. */ @@ -302,10 +333,10 @@ protected: }; -class Create_func_atan : public Create_func +class Create_func_atan : public Create_native_func { public: - virtual Item* create(THD *thd, LEX_STRING name, List *item_list); + virtual Item* create_native(THD *thd, LEX_STRING name, List *item_list); static Create_func_atan s_singleton; @@ -434,10 +465,10 @@ protected: }; -class Create_func_concat : public Create_func +class Create_func_concat : public Create_native_func { public: - virtual Item* create(THD *thd, LEX_STRING name, List *item_list); + virtual Item* create_native(THD *thd, LEX_STRING name, List *item_list); static Create_func_concat s_singleton; @@ -447,10 +478,10 @@ protected: }; -class Create_func_concat_ws : public Create_func +class Create_func_concat_ws : public Create_native_func { public: - virtual Item* create(THD *thd, LEX_STRING name, List *item_list); + virtual Item* create_native(THD *thd, LEX_STRING name, List *item_list); static Create_func_concat_ws s_singleton; @@ -672,10 +703,10 @@ protected: }; -class Create_func_des_decrypt : public Create_func +class Create_func_des_decrypt : public Create_native_func { public: - virtual Item* create(THD *thd, LEX_STRING name, List *item_list); + virtual Item* create_native(THD *thd, LEX_STRING name, List *item_list); static Create_func_des_decrypt s_singleton; @@ -685,10 +716,10 @@ protected: }; -class Create_func_des_encrypt : public Create_func +class Create_func_des_encrypt : public Create_native_func { public: - virtual Item* create(THD *thd, LEX_STRING name, List *item_list); + virtual Item* create_native(THD *thd, LEX_STRING name, List *item_list); static Create_func_des_encrypt s_singleton; @@ -728,10 +759,10 @@ protected: #endif -class Create_func_elt : public Create_func +class Create_func_elt : public Create_native_func { public: - virtual Item* create(THD *thd, LEX_STRING name, List *item_list); + virtual Item* create_native(THD *thd, LEX_STRING name, List *item_list); static Create_func_elt s_singleton; @@ -754,10 +785,10 @@ protected: }; -class Create_func_encrypt : public Create_func +class Create_func_encrypt : public Create_native_func { public: - virtual Item* create(THD *thd, LEX_STRING name, List *item_list); + virtual Item* create_native(THD *thd, LEX_STRING name, List *item_list); static Create_func_encrypt s_singleton; @@ -825,10 +856,10 @@ protected: }; -class Create_func_export_set : public Create_func +class Create_func_export_set : public Create_native_func { public: - virtual Item* create(THD *thd, LEX_STRING name, List *item_list); + virtual Item* create_native(THD *thd, LEX_STRING name, List *item_list); static Create_func_export_set s_singleton; @@ -853,10 +884,10 @@ protected: #endif -class Create_func_field : public Create_func +class Create_func_field : public Create_native_func { public: - virtual Item* create(THD *thd, LEX_STRING name, List *item_list); + virtual Item* create_native(THD *thd, LEX_STRING name, List *item_list); static Create_func_field s_singleton; @@ -931,10 +962,10 @@ protected: }; -class Create_func_from_unixtime : public Create_func +class Create_func_from_unixtime : public Create_native_func { public: - virtual Item* create(THD *thd, LEX_STRING name, List *item_list); + virtual Item* create_native(THD *thd, LEX_STRING name, List *item_list); static Create_func_from_unixtime s_singleton; @@ -945,10 +976,10 @@ protected: #ifdef HAVE_SPATIAL -class Create_func_geometry_from_text : public Create_func +class Create_func_geometry_from_text : public Create_native_func { public: - virtual Item* create(THD *thd, LEX_STRING name, List *item_list); + virtual Item* create_native(THD *thd, LEX_STRING name, List *item_list); static Create_func_geometry_from_text s_singleton; @@ -960,10 +991,10 @@ protected: #ifdef HAVE_SPATIAL -class Create_func_geometry_from_wkb : public Create_func +class Create_func_geometry_from_wkb : public Create_native_func { public: - virtual Item* create(THD *thd, LEX_STRING name, List *item_list); + virtual Item* create_native(THD *thd, LEX_STRING name, List *item_list); static Create_func_geometry_from_wkb s_singleton; @@ -1032,10 +1063,10 @@ protected: #endif -class Create_func_greatest : public Create_func +class Create_func_greatest : public Create_native_func { public: - virtual Item* create(THD *thd, LEX_STRING name, List *item_list); + virtual Item* create_native(THD *thd, LEX_STRING name, List *item_list); static Create_func_greatest s_singleton; @@ -1237,10 +1268,10 @@ protected: }; -class Create_func_last_insert_id : public Create_func +class Create_func_last_insert_id : public Create_native_func { public: - virtual Item* create(THD *thd, LEX_STRING name, List *item_list); + virtual Item* create_native(THD *thd, LEX_STRING name, List *item_list); static Create_func_last_insert_id s_singleton; @@ -1263,10 +1294,10 @@ protected: }; -class Create_func_least : public Create_func +class Create_func_least : public Create_native_func { public: - virtual Item* create(THD *thd, LEX_STRING name, List *item_list); + virtual Item* create_native(THD *thd, LEX_STRING name, List *item_list); static Create_func_least s_singleton; @@ -1315,10 +1346,10 @@ protected: }; -class Create_func_locate : public Create_func +class Create_func_locate : public Create_native_func { public: - virtual Item* create(THD *thd, LEX_STRING name, List *item_list); + virtual Item* create_native(THD *thd, LEX_STRING name, List *item_list); static Create_func_locate s_singleton; @@ -1328,10 +1359,10 @@ protected: }; -class Create_func_log : public Create_func +class Create_func_log : public Create_native_func { public: - virtual Item* create(THD *thd, LEX_STRING name, List *item_list); + virtual Item* create_native(THD *thd, LEX_STRING name, List *item_list); static Create_func_log s_singleton; @@ -1419,10 +1450,10 @@ protected: }; -class Create_func_make_set : public Create_func +class Create_func_make_set : public Create_native_func { public: - virtual Item* create(THD *thd, LEX_STRING name, List *item_list); + virtual Item* create_native(THD *thd, LEX_STRING name, List *item_list); static Create_func_make_set s_singleton; @@ -1432,10 +1463,10 @@ protected: }; -class Create_func_master_pos_wait : public Create_func +class Create_func_master_pos_wait : public Create_native_func { public: - virtual Item* create(THD *thd, LEX_STRING name, List *item_list); + virtual Item* create_native(THD *thd, LEX_STRING name, List *item_list); static Create_func_master_pos_wait s_singleton; @@ -1676,10 +1707,10 @@ protected: }; -class Create_func_rand : public Create_func +class Create_func_rand : public Create_native_func { public: - virtual Item* create(THD *thd, LEX_STRING name, List *item_list); + virtual Item* create_native(THD *thd, LEX_STRING name, List *item_list); static Create_func_rand s_singleton; @@ -1715,10 +1746,10 @@ protected: }; -class Create_func_round : public Create_func +class Create_func_round : public Create_native_func { public: - virtual Item* create(THD *thd, LEX_STRING name, List *item_list); + virtual Item* create_native(THD *thd, LEX_STRING name, List *item_list); static Create_func_round s_singleton; @@ -2085,10 +2116,10 @@ protected: }; -class Create_func_unix_timestamp : public Create_func +class Create_func_unix_timestamp : public Create_native_func { public: - virtual Item* create(THD *thd, LEX_STRING name, List *item_list); + virtual Item* create_native(THD *thd, LEX_STRING name, List *item_list); static Create_func_unix_timestamp s_singleton; @@ -2221,10 +2252,10 @@ protected: #endif -class Create_func_year_week : public Create_func +class Create_func_year_week : public Create_native_func { public: - virtual Item* create(THD *thd, LEX_STRING name, List *item_list); + virtual Item* create_native(THD *thd, LEX_STRING name, List *item_list); static Create_func_year_week s_singleton; @@ -2240,6 +2271,29 @@ protected: ============================================================================= */ +/** + Checks if there are named parameters in a parameter list. + The syntax to name parameters in a function call is as follow: + foo(expr AS named, expr named, expr AS "named", expr "named") + @param params The parameter list, can be null + @return true if one or more parameter is named +*/ +static bool has_named_parameters(List *params) +{ + if (params) + { + Item *param; + List_iterator it(*params); + while ((param= it++)) + { + if (! param->is_autogenerated_name) + return true; + } + } + + return false; +} + #ifndef HAVE_SPATIAL Create_func_no_geom Create_func_no_geom::s_singleton; @@ -2387,11 +2441,27 @@ Create_sp_func::create(THD *thd, LEX_STRING db, LEX_STRING name, int arg_count= 0; Item *func= NULL; LEX *lex= thd->lex; - sp_name *qname= new (thd->mem_root) sp_name(db, name); + sp_name *qname; + + if (has_named_parameters(item_list)) + { + /* + The syntax "db.foo(expr AS p1, expr AS p2, ...) is invalid, + and has been rejected during syntactic parsing already, + because a stored function call may not have named parameters. + + The syntax "foo(expr AS p1, expr AS p2, ...)" is correct, + because it can refer to a User Defined Function call. + For a Stored Function however, this has no semantic. + */ + my_error(ER_WRONG_PARAMETERS_TO_STORED_FCT, MYF(0), name.str); + return NULL; + } if (item_list != NULL) arg_count= item_list->elements; + qname= new (thd->mem_root) sp_name(db, name); qname->init_qname(thd); sp_add_used_routine(lex, thd, qname, TYPE_ENUM_FUNCTION); @@ -2406,6 +2476,19 @@ Create_sp_func::create(THD *thd, LEX_STRING db, LEX_STRING name, } +Item* +Create_native_func::create(THD *thd, LEX_STRING name, List *item_list) +{ + if (has_named_parameters(item_list)) + { + my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.str); + return NULL; + } + + return create_native(thd, name, item_list); +} + + Item* Create_func_arg0::create(THD *thd, LEX_STRING name, List *item_list) { @@ -2439,6 +2522,13 @@ Create_func_arg1::create(THD *thd, LEX_STRING name, List *item_list) } Item *param_1= item_list->pop(); + + if (! param_1->is_autogenerated_name) + { + my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.str); + return NULL; + } + return create(thd, param_1); } @@ -2459,6 +2549,14 @@ Create_func_arg2::create(THD *thd, LEX_STRING name, List *item_list) Item *param_1= item_list->pop(); Item *param_2= item_list->pop(); + + if ( (! param_1->is_autogenerated_name) + || (! param_2->is_autogenerated_name)) + { + my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.str); + return NULL; + } + return create(thd, param_1, param_2); } @@ -2480,6 +2578,15 @@ Create_func_arg3::create(THD *thd, LEX_STRING name, List *item_list) Item *param_1= item_list->pop(); Item *param_2= item_list->pop(); Item *param_3= item_list->pop(); + + if ( (! param_1->is_autogenerated_name) + || (! param_2->is_autogenerated_name) + || (! param_3->is_autogenerated_name)) + { + my_error(ER_WRONG_PARAMETERS_TO_NATIVE_FCT, MYF(0), name.str); + return NULL; + } + return create(thd, param_1, param_2, param_3); } @@ -2574,7 +2681,8 @@ Create_func_asin::create(THD *thd, Item *arg1) Create_func_atan Create_func_atan::s_singleton; Item* -Create_func_atan::create(THD *thd, LEX_STRING name, List *item_list) +Create_func_atan::create_native(THD *thd, LEX_STRING name, + List *item_list) { Item* func= NULL; int arg_count= 0; @@ -2694,7 +2802,8 @@ Create_func_coercibility::create(THD *thd, Item *arg1) Create_func_concat Create_func_concat::s_singleton; Item* -Create_func_concat::create(THD *thd, LEX_STRING name, List *item_list) +Create_func_concat::create_native(THD *thd, LEX_STRING name, + List *item_list) { int arg_count= 0; @@ -2714,7 +2823,8 @@ Create_func_concat::create(THD *thd, LEX_STRING name, List *item_list) Create_func_concat_ws Create_func_concat_ws::s_singleton; Item* -Create_func_concat_ws::create(THD *thd, LEX_STRING name, List *item_list) +Create_func_concat_ws::create_native(THD *thd, LEX_STRING name, + List *item_list) { int arg_count= 0; @@ -2914,8 +3024,8 @@ Create_func_degrees::create(THD *thd, Item *arg1) Create_func_des_decrypt Create_func_des_decrypt::s_singleton; Item* -Create_func_des_decrypt::create(THD *thd, LEX_STRING name, - List *item_list) +Create_func_des_decrypt::create_native(THD *thd, LEX_STRING name, + List *item_list) { Item *func= NULL; int arg_count= 0; @@ -2951,8 +3061,8 @@ Create_func_des_decrypt::create(THD *thd, LEX_STRING name, Create_func_des_encrypt Create_func_des_encrypt::s_singleton; Item* -Create_func_des_encrypt::create(THD *thd, LEX_STRING name, - List *item_list) +Create_func_des_encrypt::create_native(THD *thd, LEX_STRING name, + List *item_list) { Item *func= NULL; int arg_count= 0; @@ -3011,7 +3121,8 @@ Create_func_disjoint::create(THD *thd, Item *arg1, Item *arg2) Create_func_elt Create_func_elt::s_singleton; Item* -Create_func_elt::create(THD *thd, LEX_STRING name, List *item_list) +Create_func_elt::create_native(THD *thd, LEX_STRING name, + List *item_list) { int arg_count= 0; @@ -3050,7 +3161,8 @@ Create_func_encode::create(THD *thd, Item *arg1, Item *arg2) Create_func_encrypt Create_func_encrypt::s_singleton; Item* -Create_func_encrypt::create(THD *thd, LEX_STRING name, List *item_list) +Create_func_encrypt::create_native(THD *thd, LEX_STRING name, + List *item_list) { Item *func= NULL; int arg_count= 0; @@ -3131,7 +3243,8 @@ Create_func_exp::create(THD *thd, Item *arg1) Create_func_export_set Create_func_export_set::s_singleton; Item* -Create_func_export_set::create(THD *thd, LEX_STRING name, List *item_list) +Create_func_export_set::create_native(THD *thd, LEX_STRING name, + List *item_list) { Item *func= NULL; int arg_count= 0; @@ -3195,7 +3308,8 @@ Create_func_exteriorring::create(THD *thd, Item *arg1) Create_func_field Create_func_field::s_singleton; Item* -Create_func_field::create(THD *thd, LEX_STRING name, List *item_list) +Create_func_field::create_native(THD *thd, LEX_STRING name, + List *item_list) { int arg_count= 0; @@ -3268,8 +3382,8 @@ Create_func_from_days::create(THD *thd, Item *arg1) Create_func_from_unixtime Create_func_from_unixtime::s_singleton; Item* -Create_func_from_unixtime::create(THD *thd, LEX_STRING name, - List *item_list) +Create_func_from_unixtime::create_native(THD *thd, LEX_STRING name, + List *item_list) { Item *func= NULL; int arg_count= 0; @@ -3307,8 +3421,8 @@ Create_func_from_unixtime::create(THD *thd, LEX_STRING name, Create_func_geometry_from_text Create_func_geometry_from_text::s_singleton; Item* -Create_func_geometry_from_text::create(THD *thd, LEX_STRING name, - List *item_list) +Create_func_geometry_from_text::create_native(THD *thd, LEX_STRING name, + List *item_list) { Item *func= NULL; int arg_count= 0; @@ -3347,8 +3461,8 @@ Create_func_geometry_from_text::create(THD *thd, LEX_STRING name, Create_func_geometry_from_wkb Create_func_geometry_from_wkb::s_singleton; Item* -Create_func_geometry_from_wkb::create(THD *thd, LEX_STRING name, - List *item_list) +Create_func_geometry_from_wkb::create_native(THD *thd, LEX_STRING name, + List *item_list) { Item *func= NULL; int arg_count= 0; @@ -3430,7 +3544,8 @@ Create_func_glength::create(THD *thd, Item *arg1) Create_func_greatest Create_func_greatest::s_singleton; Item* -Create_func_greatest::create(THD *thd, LEX_STRING name, List *item_list) +Create_func_greatest::create_native(THD *thd, LEX_STRING name, + List *item_list) { int arg_count= 0; @@ -3590,8 +3705,8 @@ Create_func_last_day::create(THD *thd, Item *arg1) Create_func_last_insert_id Create_func_last_insert_id::s_singleton; Item* -Create_func_last_insert_id::create(THD *thd, LEX_STRING name, - List *item_list) +Create_func_last_insert_id::create_native(THD *thd, LEX_STRING name, + List *item_list) { Item *func= NULL; int arg_count= 0; @@ -3636,7 +3751,8 @@ Create_func_lcase::create(THD *thd, Item *arg1) Create_func_least Create_func_least::s_singleton; Item* -Create_func_least::create(THD *thd, LEX_STRING name, List *item_list) +Create_func_least::create_native(THD *thd, LEX_STRING name, + List *item_list) { int arg_count= 0; @@ -3684,7 +3800,8 @@ Create_func_load_file::create(THD *thd, Item *arg1) Create_func_locate Create_func_locate::s_singleton; Item* -Create_func_locate::create(THD *thd, LEX_STRING name, List *item_list) +Create_func_locate::create_native(THD *thd, LEX_STRING name, + List *item_list) { Item *func= NULL; int arg_count= 0; @@ -3724,7 +3841,8 @@ Create_func_locate::create(THD *thd, LEX_STRING name, List *item_list) Create_func_log Create_func_log::s_singleton; Item* -Create_func_log::create(THD *thd, LEX_STRING name, List *item_list) +Create_func_log::create_native(THD *thd, LEX_STRING name, + List *item_list) { Item *func= NULL; int arg_count= 0; @@ -3814,7 +3932,8 @@ Create_func_maketime::create(THD *thd, Item *arg1, Item *arg2, Item *arg3) Create_func_make_set Create_func_make_set::s_singleton; Item* -Create_func_make_set::create(THD *thd, LEX_STRING name, List *item_list) +Create_func_make_set::create_native(THD *thd, LEX_STRING name, + List *item_list) { int arg_count= 0; @@ -3835,8 +3954,8 @@ Create_func_make_set::create(THD *thd, LEX_STRING name, List *item_list) Create_func_master_pos_wait Create_func_master_pos_wait::s_singleton; Item* -Create_func_master_pos_wait::create(THD *thd, LEX_STRING name, - List *item_list) +Create_func_master_pos_wait::create_native(THD *thd, LEX_STRING name, + List *item_list) { Item *func= NULL; int arg_count= 0; @@ -4044,7 +4163,8 @@ Create_func_radians::create(THD *thd, Item *arg1) Create_func_rand Create_func_rand::s_singleton; Item* -Create_func_rand::create(THD *thd, LEX_STRING name, List *item_list) +Create_func_rand::create_native(THD *thd, LEX_STRING name, + List *item_list) { Item *func= NULL; int arg_count= 0; @@ -4099,7 +4219,8 @@ Create_func_reverse::create(THD *thd, Item *arg1) Create_func_round Create_func_round::s_singleton; Item* -Create_func_round::create(THD *thd, LEX_STRING name, List *item_list) +Create_func_round::create_native(THD *thd, LEX_STRING name, + List *item_list) { Item *func= NULL; int arg_count= 0; @@ -4408,8 +4529,8 @@ Create_func_unhex::create(THD *thd, Item *arg1) Create_func_unix_timestamp Create_func_unix_timestamp::s_singleton; Item* -Create_func_unix_timestamp::create(THD *thd, LEX_STRING name, - List *item_list) +Create_func_unix_timestamp::create_native(THD *thd, LEX_STRING name, + List *item_list) { Item *func= NULL; int arg_count= 0; @@ -4540,7 +4661,8 @@ Create_func_y::create(THD *thd, Item *arg1) Create_func_year_week Create_func_year_week::s_singleton; Item* -Create_func_year_week::create(THD *thd, LEX_STRING name, List *item_list) +Create_func_year_week::create_native(THD *thd, LEX_STRING name, + List *item_list) { Item *func= NULL; int arg_count= 0; diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index 3022967eeeb..6d7e4075e2c 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -6010,4 +6010,6 @@ ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT 42000 eng "Incorrect parameter count in the call to native function '%-.64s'" ER_WRONG_PARAMETERS_TO_NATIVE_FCT 42000 eng "Incorrect parameters in the call to native function '%-.64s'" +ER_WRONG_PARAMETERS_TO_STORED_FCT 42000 + eng "Incorrect parameters in the call to stored function '%-.64s'" diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index ca40dc9013a..5c074cfc742 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -164,7 +164,6 @@ void lex_start(THD *thd, const uchar *buf, uint length) lex->select_lex.ftfunc_list= &lex->select_lex.ftfunc_list_alloc; lex->select_lex.group_list.empty(); lex->select_lex.order_list.empty(); - lex->select_lex.udf_list.empty(); lex->ignore_space=test(thd->variables.sql_mode & MODE_IGNORE_SPACE); lex->sql_command= SQLCOM_END; lex->duplicates= DUP_ERROR; @@ -1176,7 +1175,6 @@ void st_select_lex::init_select() braces= 0; when_list.empty(); expr_list.empty(); - udf_list.empty(); interval_list.empty(); use_index.empty(); ftfunc_list_alloc.empty(); diff --git a/sql/sql_lex.h b/sql/sql_lex.h index dd00018f5f8..21e1872d167 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -609,8 +609,6 @@ public: /* exclude this select from check of unique_table() */ bool exclude_from_table_unique_test; - List udf_list; /* udf function calls stack */ - void init_query(); void init_select(); st_select_lex_unit* master_unit(); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index f5ad6f1e278..a6d9f5a15db 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -6375,7 +6375,7 @@ function_call_generic: } } /* Temporary placing the result of find_udf in $3 */ - lex->current_select->udf_list.push_front(udf); + $$= udf; #endif } udf_expr_list ')' @@ -6403,10 +6403,10 @@ function_call_generic: { #ifdef HAVE_DLOPEN /* Retrieving the result of find_udf */ - udf_func *udf; + udf_func *udf= $3; LEX *lex= Lex; - if (NULL != (udf= lex->current_select->udf_list.pop())) + if (udf) { if (udf->type == UDFTYPE_AGGREGATE) { @@ -6502,7 +6502,6 @@ udf_expr_list3: udf_expr: remember_name expr remember_end select_alias { - udf_func *udf= Select->udf_list.head(); /* Use Item::name as a storage for the attribute value of user defined function argument. It is safe to use Item::name @@ -6511,20 +6510,10 @@ udf_expr: */ if ($4.str) { - if (!udf) - { - /* - Disallow using AS to specify explicit names for the arguments - of stored routine calls - */ - yyerror(ER(ER_SYNTAX_ERROR)); - YYABORT; - } - $2->is_autogenerated_name= FALSE; $2->set_name($4.str, $4.length, system_charset_info); } - else if (udf) + else $2->set_name($1, (uint) ($3 - $1), YYTHD->charset()); $$= $2; }