From ca345dede4a001abb2ec06aa5feec34bed38f0e6 Mon Sep 17 00:00:00 2001 From: "ramil@mysql.com" <> Date: Tue, 22 Nov 2005 18:29:46 +0400 Subject: [PATCH 01/44] Fix for bug #10966: Variance functions return wrong data type. --- mysql-test/r/func_group.result | 14 ++++++++++++++ mysql-test/t/func_group.test | 11 +++++++++++ sql/item_sum.cc | 3 --- sql/item_sum.h | 2 +- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index 2b0176179ed..2a182057738 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -1089,3 +1089,17 @@ SUM(a) 6 DROP TABLE t1; set div_precision_increment= @sav_dpi; +create table t1 select variance(0); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `variance(0)` double(8,4) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +create table t1 select stddev(0); +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `stddev(0)` double(8,4) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test index c667f90940c..7e102ebaf29 100644 --- a/mysql-test/t/func_group.test +++ b/mysql-test/t/func_group.test @@ -703,3 +703,14 @@ SELECT SUM(a) FROM t1 GROUP BY b/c; DROP TABLE t1; set div_precision_increment= @sav_dpi; +# +# Bug #10966: Variance functions return wrong data type +# + +create table t1 select variance(0); +show create table t1; +drop table t1; +create table t1 select stddev(0); +show create table t1; +drop table t1; + \ No newline at end of file diff --git a/sql/item_sum.cc b/sql/item_sum.cc index b2eaf39d624..027655e5cc7 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1030,9 +1030,6 @@ Field *Item_sum_variance::create_tmp_field(bool group, TABLE *table, sizeof(double)*2) + sizeof(longlong), 0, name, table, &my_charset_bin); } - if (hybrid_type == DECIMAL_RESULT) - return new Field_new_decimal(max_length, maybe_null, name, table, - decimals, unsigned_flag); return new Field_double(max_length, maybe_null,name,table,decimals); } diff --git a/sql/item_sum.h b/sql/item_sum.h index 87cc248e5e4..7340dc78c66 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -481,7 +481,7 @@ public: { return sample ? "var_samp(" : "variance("; } Item *copy_or_same(THD* thd); Field *create_tmp_field(bool group, TABLE *table, uint convert_blob_length); - enum Item_result result_type () const { return hybrid_type; } + enum Item_result result_type () const { return REAL_RESULT; } }; class Item_sum_std; From 2e0cad5404e925b3bbe9095174617412bc92b45b Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Wed, 7 Jun 2006 14:07:11 +0200 Subject: [PATCH 02/44] Bug#20159 Inconsistant generation of generic error messages - Use hardcoded error message instead of ER_GET_ERRNO --- sql/sql_udf.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index 6269c0a2eb3..bea3d547f3e 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -237,7 +237,7 @@ void udf_init() } } if (error > 0) - sql_print_error(ER(ER_GET_ERRNO), my_errno); + sql_print_error("Got unknown error: %d", my_errno); end_read_record(&read_record_info); new_thd->version--; // Force close to free memory From 9ebf7944e36df42ea5bb61b34e32c8af0f4bc909 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Fri, 9 Jun 2006 19:35:54 +0200 Subject: [PATCH 03/44] Bug #7498 User variable SET saves SIGNED BIGINT as UNSIGNED BIGINT - Add unsigned flag to user_var_entry, used when 'type' is INT_RESULT - Propagate unsigned flag from the query executed by Item_single_row_subselect --- mysql-test/r/user_var.result | 36 ++++++++++++++++++++++++++++++++++++ mysql-test/t/user_var.test | 31 +++++++++++++++++++++++++++++++ sql/item_func.cc | 24 +++++++++++++++++------- sql/item_func.h | 6 ++---- sql/item_subselect.cc | 1 + sql/sql_class.h | 1 + 6 files changed, 88 insertions(+), 11 deletions(-) diff --git a/mysql-test/r/user_var.result b/mysql-test/r/user_var.result index 7439f9132fb..3a197cd2a47 100644 --- a/mysql-test/r/user_var.result +++ b/mysql-test/r/user_var.result @@ -256,3 +256,39 @@ t1 CREATE TABLE `t1` ( `@first_var` longtext ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1; +set @a=18446744071710965857; +select @a; +@a +18446744071710965857 +CREATE TABLE `bigfailure` ( +`afield` BIGINT UNSIGNED NOT NULL +); +INSERT INTO `bigfailure` VALUES (18446744071710965857); +SELECT * FROM bigfailure; +afield +18446744071710965857 +select * from (SELECT afield FROM bigfailure) as b; +afield +18446744071710965857 +select * from bigfailure where afield = (SELECT afield FROM bigfailure); +afield +18446744071710965857 +select * from bigfailure where afield = 18446744071710965857; +afield +18446744071710965857 +select * from bigfailure where afield = 18446744071710965856+1; +afield +18446744071710965857 +SET @a := (SELECT afield FROM bigfailure); +SELECT @a; +@a +18446744071710965857 +SET @a := (select afield from (SELECT afield FROM bigfailure) as b); +SELECT @a; +@a +18446744071710965857 +SET @a := (select * from bigfailure where afield = (SELECT afield FROM bigfailure)); +SELECT @a; +@a +18446744071710965857 +drop table bigfailure; diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test index e1b23a1782f..58c52b59a5a 100644 --- a/mysql-test/t/user_var.test +++ b/mysql-test/t/user_var.test @@ -171,3 +171,34 @@ set @first_var= cast(NULL as CHAR); create table t1 select @first_var; show create table t1; drop table t1; + +# +# Bug #7498 User variable SET saves SIGNED BIGINT as UNSIGNED BIGINT +# + +# First part, set user var to large number and select it +set @a=18446744071710965857; +select @a; + +# Second part, set user var from large number in table +# then select it +CREATE TABLE `bigfailure` ( + `afield` BIGINT UNSIGNED NOT NULL +); +INSERT INTO `bigfailure` VALUES (18446744071710965857); +SELECT * FROM bigfailure; +select * from (SELECT afield FROM bigfailure) as b; +select * from bigfailure where afield = (SELECT afield FROM bigfailure); +select * from bigfailure where afield = 18446744071710965857; +# This is fixed in 5.0, to be uncommented there +#select * from bigfailure where afield = '18446744071710965857'; +select * from bigfailure where afield = 18446744071710965856+1; + +SET @a := (SELECT afield FROM bigfailure); +SELECT @a; +SET @a := (select afield from (SELECT afield FROM bigfailure) as b); +SELECT @a; +SET @a := (select * from bigfailure where afield = (SELECT afield FROM bigfailure)); +SELECT @a; + +drop table bigfailure; diff --git a/sql/item_func.cc b/sql/item_func.cc index 6ec74560b91..7450451b0d0 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -3408,6 +3408,7 @@ static user_var_entry *get_variable(HASH *hash, LEX_STRING &name, entry->length=0; entry->update_query_id=0; entry->collation.set(NULL, DERIVATION_IMPLICIT); + entry->unsigned_flag= 0; /* If we are here, we were called from a SET or a query which sets a variable. Imagine it is this: @@ -3494,6 +3495,7 @@ Item_func_set_user_var::fix_length_and_dec() type - type of new value cs - charset info for new value dv - derivation for new value + unsigned_arg - indiates if a value of type INT_RESULT is unsigned RETURN VALUE False - success, True - failure @@ -3501,7 +3503,8 @@ Item_func_set_user_var::fix_length_and_dec() static bool update_hash(user_var_entry *entry, bool set_null, void *ptr, uint length, - Item_result type, CHARSET_INFO *cs, Derivation dv) + Item_result type, CHARSET_INFO *cs, Derivation dv, + bool unsigned_arg) { if (set_null) { @@ -3549,6 +3552,7 @@ update_hash(user_var_entry *entry, bool set_null, void *ptr, uint length, ((my_decimal*)entry->value)->fix_buffer_pointer(); entry->length= length; entry->collation.set(cs, dv); + entry->unsigned_flag= unsigned_arg; } entry->type=type; return 0; @@ -3557,7 +3561,8 @@ update_hash(user_var_entry *entry, bool set_null, void *ptr, uint length, bool Item_func_set_user_var::update_hash(void *ptr, uint length, Item_result type, - CHARSET_INFO *cs, Derivation dv) + CHARSET_INFO *cs, Derivation dv, + bool unsigned_arg) { /* If we set a variable explicitely to NULL then keep the old @@ -3566,7 +3571,7 @@ Item_func_set_user_var::update_hash(void *ptr, uint length, Item_result type, if ((null_value= args[0]->null_value) && null_item) type= entry->type; // Don't change type of item if (::update_hash(entry, (null_value= args[0]->null_value), - ptr, length, type, cs, dv)) + ptr, length, type, cs, dv, unsigned_arg)) { current_thd->fatal_error(); // Probably end of memory null_value= 1; @@ -3648,7 +3653,10 @@ String *user_var_entry::val_str(my_bool *null_value, String *str, str->set(*(double*) value, decimals, &my_charset_bin); break; case INT_RESULT: - str->set(*(longlong*) value, &my_charset_bin); + if (!unsigned_flag) + str->set(*(longlong*) value, &my_charset_bin); + else + str->set(*(ulonglong*) value, &my_charset_bin); break; case DECIMAL_RESULT: my_decimal2string(E_DEC_FATAL_ERROR, (my_decimal *)value, 0, 0, 0, str); @@ -3719,6 +3727,7 @@ Item_func_set_user_var::check() case INT_RESULT: { save_result.vint= args[0]->val_int(); + unsigned_flag= args[0]->unsigned_flag; break; } case STRING_RESULT: @@ -3774,7 +3783,8 @@ Item_func_set_user_var::update() case INT_RESULT: { res= update_hash((void*) &save_result.vint, sizeof(save_result.vint), - INT_RESULT, &my_charset_bin, DERIVATION_IMPLICIT); + INT_RESULT, &my_charset_bin, DERIVATION_IMPLICIT, + unsigned_flag); break; } case STRING_RESULT: @@ -4141,7 +4151,7 @@ bool Item_user_var_as_out_param::fix_fields(THD *thd, Item **ref) void Item_user_var_as_out_param::set_null_value(CHARSET_INFO* cs) { if (::update_hash(entry, TRUE, 0, 0, STRING_RESULT, cs, - DERIVATION_IMPLICIT)) + DERIVATION_IMPLICIT, 0 /* unsigned_arg */)) current_thd->fatal_error(); // Probably end of memory } @@ -4150,7 +4160,7 @@ void Item_user_var_as_out_param::set_value(const char *str, uint length, CHARSET_INFO* cs) { if (::update_hash(entry, FALSE, (void*)str, length, STRING_RESULT, cs, - DERIVATION_IMPLICIT)) + DERIVATION_IMPLICIT, 0 /* unsigned_arg */)) current_thd->fatal_error(); // Probably end of memory } diff --git a/sql/item_func.h b/sql/item_func.h index a91d93be8c6..8f90626ad26 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -1154,8 +1154,6 @@ class Item_func_set_user_var :public Item_func String *vstr; my_decimal *vdec; } save_result; - String save_buff; - public: LEX_STRING name; // keep it public @@ -1166,8 +1164,8 @@ public: longlong val_int(); String *val_str(String *str); my_decimal *val_decimal(my_decimal *); - bool update_hash(void *ptr, uint length, enum Item_result type, - CHARSET_INFO *cs, Derivation dv); + bool update_hash(void *ptr, uint length, enum Item_result type, + CHARSET_INFO *cs, Derivation dv, bool unsigned_arg= 0); bool check(); bool update(); enum Item_result result_type () const { return cached_result_type; } diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index d93f6501ebb..4e6b168c9e9 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -1497,6 +1497,7 @@ static Item_result set_row(List &item_list, Item *item, item->max_length= sel_item->max_length; res_type= sel_item->result_type(); item->decimals= sel_item->decimals; + item->unsigned_flag= sel_item->unsigned_flag; *maybe_null= sel_item->maybe_null; if (!(row[i]= Item_cache::get_cache(res_type))) return STRING_RESULT; // we should return something diff --git a/sql/sql_class.h b/sql/sql_class.h index 0ddba0e6f05..be13084b1ea 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1954,6 +1954,7 @@ class user_var_entry ulong length; query_id_t update_query_id, used_query_id; Item_result type; + bool unsigned_flag; double val_real(my_bool *null_value); longlong val_int(my_bool *null_value); From 4ca95f911a5e5c74bb3fcb1141d1ddd065aa9ed0 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 12 Jun 2006 13:07:40 +0200 Subject: [PATCH 04/44] Bug#19517 No simple way to detect wether server was compiled with libdbug - Define DBUG_ON and DBUG_OFF in config.h --- configure.in | 15 +++++++++------ dbug/dbug.c | 5 ++++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/configure.in b/configure.in index 3c335089688..8755fd1a3bb 100644 --- a/configure.in +++ b/configure.in @@ -1651,17 +1651,20 @@ AC_ARG_WITH(debug, if test "$with_debug" = "yes" then # Medium debug. - CFLAGS="$DEBUG_CFLAGS $DEBUG_OPTIMIZE_CC -DDBUG_ON -DSAFE_MUTEX $CFLAGS" - CXXFLAGS="$DEBUG_CXXFLAGS $DEBUG_OPTIMIZE_CXX -DDBUG_ON -DSAFE_MUTEX $CXXFLAGS" + AC_DEFINE([DBUG_ON], [1], [Use libdbug]) + CFLAGS="$DEBUG_CFLAGS $DEBUG_OPTIMIZE_CC -DSAFE_MUTEX $CFLAGS" + CXXFLAGS="$DEBUG_CXXFLAGS $DEBUG_OPTIMIZE_CXX -DSAFE_MUTEX $CXXFLAGS" elif test "$with_debug" = "full" then # Full debug. Very slow in some cases - CFLAGS="$DEBUG_CFLAGS -DDBUG_ON -DSAFE_MUTEX -DSAFEMALLOC $CFLAGS" - CXXFLAGS="$DEBUG_CXXFLAGS -DDBUG_ON -DSAFE_MUTEX -DSAFEMALLOC $CXXFLAGS" + AC_DEFINE([DBUG_ON], [1], [Use libdbug]) + CFLAGS="$DEBUG_CFLAGS -DSAFE_MUTEX -DSAFEMALLOC $CFLAGS" + CXXFLAGS="$DEBUG_CXXFLAGS -DSAFE_MUTEX -DSAFEMALLOC $CXXFLAGS" else # Optimized version. No debug - CFLAGS="$OPTIMIZE_CFLAGS -DDBUG_OFF $CFLAGS" - CXXFLAGS="$OPTIMIZE_CXXFLAGS -DDBUG_OFF $CXXFLAGS" + AC_DEFINE([DBUG_OFF], [1], [Don't use libdbug]) + CFLAGS="$OPTIMIZE_CFLAGS $CFLAGS" + CXXFLAGS="$OPTIMIZE_CXXFLAGS $CXXFLAGS" fi # Force static compilation to avoid linking problems/get more speed diff --git a/dbug/dbug.c b/dbug/dbug.c index c991daf3617..575481305e7 100644 --- a/dbug/dbug.c +++ b/dbug/dbug.c @@ -66,10 +66,13 @@ * Check of malloc on entry/exit (option "S") */ +#include + +/* This file won't compile unless DBUG_OFF is undefined locally */ #ifdef DBUG_OFF #undef DBUG_OFF #endif -#include + #include #include #if defined(MSDOS) || defined(__WIN__) From 9c18b5752c22efdfbfc6427747dbbc6092961bbd Mon Sep 17 00:00:00 2001 From: "jimw@rama.(none)" <> Date: Mon, 10 Jul 2006 19:50:40 -0700 Subject: [PATCH 05/44] Bug #18539: uncompress(d) is null: impossible? The UNCOMPRESS() function was not marked as maybe_null, even though it returns NULL on invalid data. This confused the optimizer. --- mysql-test/r/func_compress.result | 28 ++++++++++++++++++++++++++++ mysql-test/t/func_compress.test | 14 ++++++++++++++ sql/item_strfunc.h | 2 +- 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/func_compress.result b/mysql-test/r/func_compress.result index e3d31566741..df8939d98f1 100644 --- a/mysql-test/r/func_compress.result +++ b/mysql-test/r/func_compress.result @@ -79,3 +79,31 @@ uncompress(a) uncompressed_length(a) NULL NULL a 1 drop table t1; +create table t1 (a varchar(32) not null); +insert into t1 values ('foo'); +explain select * from t1 where uncompress(a) is null; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 system NULL NULL NULL NULL 1 +Warnings: +Error 1256 Uncompressed data size too large; the maximum size is 104857600 (probably, length of uncompressed data was corrupted) +select * from t1 where uncompress(a) is null; +a +foo +Warnings: +Error 1256 Uncompressed data size too large; the maximum size is 104857600 (probably, length of uncompressed data was corrupted) +explain select *, uncompress(a) from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 system NULL NULL NULL NULL 1 +select *, uncompress(a) from t1; +a uncompress(a) +foo NULL +Warnings: +Error 1256 Uncompressed data size too large; the maximum size is 104857600 (probably, length of uncompressed data was corrupted) +select *, uncompress(a), uncompress(a) is null from t1; +a uncompress(a) uncompress(a) is null +foo NULL 1 +Warnings: +Error 1256 Uncompressed data size too large; the maximum size is 104857600 (probably, length of uncompressed data was corrupted) +Error 1256 Uncompressed data size too large; the maximum size is 104857600 (probably, length of uncompressed data was corrupted) +drop table t1; +End of 5.0 tests diff --git a/mysql-test/t/func_compress.test b/mysql-test/t/func_compress.test index 4ae749f2343..eeb5d509b94 100644 --- a/mysql-test/t/func_compress.test +++ b/mysql-test/t/func_compress.test @@ -57,3 +57,17 @@ select uncompress(a), uncompressed_length(a) from t1; drop table t1; # End of 4.1 tests + +# +# Bug #18539: uncompress(d) is null: impossible? +# +create table t1 (a varchar(32) not null); +insert into t1 values ('foo'); +explain select * from t1 where uncompress(a) is null; +select * from t1 where uncompress(a) is null; +explain select *, uncompress(a) from t1; +select *, uncompress(a) from t1; +select *, uncompress(a), uncompress(a) is null from t1; +drop table t1; + +--echo End of 5.0 tests diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index af59b8d740b..d685bd63467 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -784,7 +784,7 @@ class Item_func_uncompress: public Item_str_func String buffer; public: Item_func_uncompress(Item *a): Item_str_func(a){} - void fix_length_and_dec(){max_length= MAX_BLOB_WIDTH;} + void fix_length_and_dec(){ maybe_null= 1; max_length= MAX_BLOB_WIDTH; } const char *func_name() const{return "uncompress";} String *val_str(String *) ZLIB_DEPENDED_FUNCTION }; From 794fe3435c865a6d3580e4ad83b8469a7b63b81d Mon Sep 17 00:00:00 2001 From: "ramil/ram@mysql.com/myoffice.izhnet.ru" <> Date: Wed, 12 Jul 2006 11:38:11 +0500 Subject: [PATCH 06/44] Fix for bug #19370: DateTime datatype in MySQL has two bugs in it --- mysql-test/r/date_formats.result | 4 +++- mysql-test/r/strict.result | 20 ++++++++++++++------ mysql-test/r/type_datetime.result | 4 +++- mysql-test/t/strict.test | 18 ++++++++++++++++-- sql-common/my_time.c | 4 +++- 5 files changed, 39 insertions(+), 11 deletions(-) diff --git a/mysql-test/r/date_formats.result b/mysql-test/r/date_formats.result index 77a3473e9fe..e427fd543c6 100644 --- a/mysql-test/r/date_formats.result +++ b/mysql-test/r/date_formats.result @@ -449,6 +449,8 @@ create table t1 select str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:% str_to_date("10:11:12.0012", "%H:%i:%S.%f") as f2, str_to_date("2003-01-02", "%Y-%m-%d") as f3, str_to_date("02", "%d") as f4, str_to_date("02 10", "%d %H") as f5; +Warnings: +Warning 1265 Data truncated for column 'f4' at row 1 describe t1; Field Type Null Key Default Extra f1 datetime YES NULL @@ -458,7 +460,7 @@ f4 date YES NULL f5 time YES NULL select * from t1; f1 f2 f3 f4 f5 -2003-01-02 10:11:12 10:11:12 2003-01-02 0000-00-02 58:00:00 +2003-01-02 10:11:12 10:11:12 2003-01-02 0000-00-00 58:00:00 drop table t1; create table t1 select "02 10" as a, "%d %H" as b; select str_to_date(a,b) from t1; diff --git a/mysql-test/r/strict.result b/mysql-test/r/strict.result index d0cf11d0511..08a33734910 100644 --- a/mysql-test/r/strict.result +++ b/mysql-test/r/strict.result @@ -5,7 +5,9 @@ select @@sql_mode; REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI,STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER DROP TABLE IF EXISTS t1; CREATE TABLE t1 (col1 date); -INSERT INTO t1 VALUES('2004-01-01'),('0000-10-31'),('2004-02-29'); +INSERT INTO t1 VALUES('2004-01-01'),('2004-02-29'); +INSERT INTO t1 VALUES('0000-10-31'); +ERROR 22007: Incorrect date value: '0000-10-31' for column 'col1' at row 1 INSERT INTO t1 VALUES('2004-0-31'); ERROR 22007: Incorrect date value: '2004-0-31' for column 'col1' at row 1 INSERT INTO t1 VALUES('2004-01-02'),('2004-0-31'); @@ -54,7 +56,6 @@ Warning 1265 Data truncated for column 'col1' at row 3 select * from t1; col1 2004-01-01 -0000-10-31 2004-02-29 2004-01-02 2004-01-03 @@ -121,7 +122,9 @@ col1 drop table t1; set @@sql_mode='ansi,traditional'; CREATE TABLE t1 (col1 datetime); -INSERT INTO t1 VALUES('2004-10-31 15:30:00'),('0000-10-31 15:30:00'),('2004-02-29 15:30:00'); +INSERT INTO t1 VALUES('2004-10-31 15:30:00'),('2004-02-29 15:30:00'); +INSERT INTO t1 VALUES('0000-10-31 15:30:00'); +ERROR 22007: Incorrect datetime value: '0000-10-31 15:30:00' for column 'col1' at row 1 INSERT INTO t1 VALUES('2004-0-31 15:30:00'); ERROR 22007: Incorrect datetime value: '2004-0-31 15:30:00' for column 'col1' at row 1 INSERT INTO t1 VALUES('2004-10-0 15:30:00'); @@ -141,7 +144,6 @@ ERROR 22007: Incorrect datetime value: '59' for column 'col1' at row 1 select * from t1; col1 2004-10-31 15:30:00 -0000-10-31 15:30:00 2004-02-29 15:30:00 drop table t1; CREATE TABLE t1 (col1 timestamp); @@ -204,6 +206,7 @@ INSERT INTO t1 (col1) VALUES (STR_TO_DATE('15.10.2004','%d.%m.%Y')); INSERT INTO t1 (col2) VALUES (STR_TO_DATE('15.10.2004 10.15','%d.%m.%Y %H.%i')); INSERT INTO t1 (col3) VALUES (STR_TO_DATE('15.10.2004 10.15','%d.%m.%Y %H.%i')); INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i')); +ERROR 22007: Incorrect date value: '0000-10-31 15:30:00' for column 'col1' at row 1 INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i')); ERROR 22007: Incorrect date value: '2004-00-31 15:30:00' for column 'col1' at row 1 INSERT INTO t1 (col1) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i')); @@ -219,6 +222,7 @@ ERROR HY000: Incorrect datetime value: '15.13.2004 15.30' for function str_to_ti INSERT INTO t1 (col1) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y')); ERROR 22007: Incorrect date value: '0000-00-00' for column 'col1' at row 1 INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i')); +ERROR 22007: Incorrect datetime value: '0000-10-31 15:30:00' for column 'col2' at row 1 INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i')); ERROR 22007: Incorrect datetime value: '2004-00-31 15:30:00' for column 'col2' at row 1 INSERT INTO t1 (col2) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i')); @@ -255,6 +259,7 @@ INSERT INTO t1 (col1) VALUES (CAST('2004-10-15' AS DATE)); INSERT INTO t1 (col2) VALUES (CAST('2004-10-15 10:15' AS DATETIME)); INSERT INTO t1 (col3) VALUES (CAST('2004-10-15 10:15' AS DATETIME)); INSERT INTO t1 (col1) VALUES(CAST('0000-10-31' AS DATE)); +ERROR 22007: Truncated incorrect datetime value: '0000-10-31' INSERT INTO t1 (col1) VALUES(CAST('2004-10-0' AS DATE)); ERROR 22007: Incorrect date value: '2004-10-00' for column 'col1' at row 1 INSERT INTO t1 (col1) VALUES(CAST('2004-0-10' AS DATE)); @@ -262,6 +267,7 @@ ERROR 22007: Incorrect date value: '2004-00-10' for column 'col1' at row 1 INSERT INTO t1 (col1) VALUES(CAST('0000-00-00' AS DATE)); ERROR 22007: Truncated incorrect datetime value: '0000-00-00' INSERT INTO t1 (col2) VALUES(CAST('0000-10-31 15:30' AS DATETIME)); +ERROR 22007: Truncated incorrect datetime value: '0000-10-31 15:30' INSERT INTO t1 (col2) VALUES(CAST('2004-10-0 15:30' AS DATETIME)); ERROR 22007: Incorrect datetime value: '2004-10-00 15:30:00' for column 'col2' at row 1 INSERT INTO t1 (col2) VALUES(CAST('2004-0-10 15:30' AS DATETIME)); @@ -269,7 +275,7 @@ ERROR 22007: Incorrect datetime value: '2004-00-10 15:30:00' for column 'col2' a INSERT INTO t1 (col2) VALUES(CAST('0000-00-00' AS DATETIME)); ERROR 22007: Truncated incorrect datetime value: '0000-00-00' INSERT INTO t1 (col3) VALUES(CAST('0000-10-31 15:30' AS DATETIME)); -ERROR 22007: Incorrect datetime value: '0000-10-31 15:30:00' for column 'col3' at row 1 +ERROR 22007: Truncated incorrect datetime value: '0000-10-31 15:30' INSERT INTO t1 (col3) VALUES(CAST('2004-10-0 15:30' AS DATETIME)); ERROR 22007: Incorrect datetime value: '2004-10-00 15:30:00' for column 'col3' at row 1 INSERT INTO t1 (col3) VALUES(CAST('2004-0-10 15:30' AS DATETIME)); @@ -282,6 +288,7 @@ INSERT INTO t1 (col1) VALUES (CONVERT('2004-10-15',DATE)); INSERT INTO t1 (col2) VALUES (CONVERT('2004-10-15 10:15',DATETIME)); INSERT INTO t1 (col3) VALUES (CONVERT('2004-10-15 10:15',DATETIME)); INSERT INTO t1 (col1) VALUES(CONVERT('0000-10-31' , DATE)); +ERROR 22007: Truncated incorrect datetime value: '0000-10-31' INSERT INTO t1 (col1) VALUES(CONVERT('2004-10-0' , DATE)); ERROR 22007: Incorrect date value: '2004-10-00' for column 'col1' at row 1 INSERT INTO t1 (col1) VALUES(CONVERT('2004-0-10' , DATE)); @@ -289,6 +296,7 @@ ERROR 22007: Incorrect date value: '2004-00-10' for column 'col1' at row 1 INSERT INTO t1 (col1) VALUES(CONVERT('0000-00-00',DATE)); ERROR 22007: Truncated incorrect datetime value: '0000-00-00' INSERT INTO t1 (col2) VALUES(CONVERT('0000-10-31 15:30',DATETIME)); +ERROR 22007: Truncated incorrect datetime value: '0000-10-31 15:30' INSERT INTO t1 (col2) VALUES(CONVERT('2004-10-0 15:30',DATETIME)); ERROR 22007: Incorrect datetime value: '2004-10-00 15:30:00' for column 'col2' at row 1 INSERT INTO t1 (col2) VALUES(CONVERT('2004-0-10 15:30',DATETIME)); @@ -296,7 +304,7 @@ ERROR 22007: Incorrect datetime value: '2004-00-10 15:30:00' for column 'col2' a INSERT INTO t1 (col2) VALUES(CONVERT('0000-00-00',DATETIME)); ERROR 22007: Truncated incorrect datetime value: '0000-00-00' INSERT INTO t1 (col3) VALUES(CONVERT('0000-10-31 15:30',DATETIME)); -ERROR 22007: Incorrect datetime value: '0000-10-31 15:30:00' for column 'col3' at row 1 +ERROR 22007: Truncated incorrect datetime value: '0000-10-31 15:30' INSERT INTO t1 (col3) VALUES(CONVERT('2004-10-0 15:30',DATETIME)); ERROR 22007: Incorrect datetime value: '2004-10-00 15:30:00' for column 'col3' at row 1 INSERT INTO t1 (col3) VALUES(CONVERT('2004-0-10 15:30',DATETIME)); diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result index 85f899be5d8..2addb9c93eb 100644 --- a/mysql-test/r/type_datetime.result +++ b/mysql-test/r/type_datetime.result @@ -26,6 +26,8 @@ Table Op Msg_type Msg_text test.t1 check status OK delete from t1; insert into t1 values("000101"),("691231"),("700101"),("991231"),("00000101"),("00010101"),("99991231"),("00101000000"),("691231000000"),("700101000000"),("991231235959"),("10000101000000"),("99991231235959"),("20030100000000"),("20030000000000"); +Warnings: +Warning 1264 Out of range value adjusted for column 't' at row 5 insert into t1 values ("2003-003-03"); insert into t1 values ("20030102T131415"),("2001-01-01T01:01:01"), ("2001-1-1T1:01:01"); select * from t1; @@ -34,7 +36,7 @@ t 2069-12-31 00:00:00 1970-01-01 00:00:00 1999-12-31 00:00:00 -0000-01-01 00:00:00 +0000-00-00 00:00:00 0001-01-01 00:00:00 9999-12-31 00:00:00 2000-10-10 00:00:00 diff --git a/mysql-test/t/strict.test b/mysql-test/t/strict.test index ce269b42ee9..6f22b81172d 100644 --- a/mysql-test/t/strict.test +++ b/mysql-test/t/strict.test @@ -13,7 +13,9 @@ DROP TABLE IF EXISTS t1; # Test INSERT with DATE CREATE TABLE t1 (col1 date); -INSERT INTO t1 VALUES('2004-01-01'),('0000-10-31'),('2004-02-29'); +INSERT INTO t1 VALUES('2004-01-01'),('2004-02-29'); +--error 1292 +INSERT INTO t1 VALUES('0000-10-31'); # All test cases expected to fail should return # SQLSTATE 22007 @@ -97,7 +99,9 @@ set @@sql_mode='ansi,traditional'; # Test INSERT with DATETIME CREATE TABLE t1 (col1 datetime); -INSERT INTO t1 VALUES('2004-10-31 15:30:00'),('0000-10-31 15:30:00'),('2004-02-29 15:30:00'); +INSERT INTO t1 VALUES('2004-10-31 15:30:00'),('2004-02-29 15:30:00'); +--error 1292 +INSERT INTO t1 VALUES('0000-10-31 15:30:00'); # All test cases expected to fail should return # SQLSTATE 22007 @@ -190,6 +194,7 @@ INSERT INTO t1 (col3) VALUES (STR_TO_DATE('15.10.2004 10.15','%d.%m.%Y %H.%i')); # All test cases expected to fail should return # SQLSTATE 22007 +--error 1292 INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i')); --error 1292 @@ -211,6 +216,7 @@ INSERT INTO t1 (col1) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y')); # All test cases expected to fail should return # SQLSTATE 22007 +--error 1292 INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i')); --error 1292 @@ -264,6 +270,8 @@ INSERT INTO t1 (col3) VALUES (CAST('2004-10-15 10:15' AS DATETIME)); ## Test INSERT with CAST AS DATE into DATE # All test cases expected to fail should return # SQLSTATE 22007 + +--error 1292 INSERT INTO t1 (col1) VALUES(CAST('0000-10-31' AS DATE)); --error 1292 @@ -290,6 +298,8 @@ INSERT INTO t1 (col1) VALUES(CAST('0000-00-00' AS DATE)); ## Test INSERT with CAST AS DATETIME into DATETIME # All test cases expected to fail should return # SQLSTATE 22007 + +--error 1292 INSERT INTO t1 (col2) VALUES(CAST('0000-10-31 15:30' AS DATETIME)); --error 1292 @@ -356,6 +366,8 @@ INSERT INTO t1 (col3) VALUES (CONVERT('2004-10-15 10:15',DATETIME)); ## Test INSERT with CONVERT to DATE into DATE # All test cases expected to fail should return # SQLSTATE 22007 + +--error 1292 INSERT INTO t1 (col1) VALUES(CONVERT('0000-10-31' , DATE)); --error 1292 @@ -381,6 +393,8 @@ INSERT INTO t1 (col1) VALUES(CONVERT('0000-00-00',DATE)); ## Test INSERT with CONVERT to DATETIME into DATETIME # All test cases expected to fail should return # SQLSTATE 22007 + +--error 1292 INSERT INTO t1 (col2) VALUES(CONVERT('0000-10-31 15:30',DATETIME)); --error 1292 diff --git a/sql-common/my_time.c b/sql-common/my_time.c index c9d39260761..93bf23ed284 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -69,6 +69,7 @@ uint calc_days_in_year(uint year) Here we assume that year and month is ok ! If month is 0 we allow any date. (This only happens if we allow zero date parts in str_to_datetime()) + Disallow dates with zero year and non-zero month and/or day. RETURN 0 ok @@ -85,7 +86,8 @@ static my_bool check_date(const MYSQL_TIME *ltime, my_bool not_zero_date, (!(flags & TIME_INVALID_DATES) && ltime->month && ltime->day > days_in_month[ltime->month-1] && (ltime->month != 2 || calc_days_in_year(ltime->year) != 366 || - ltime->day != 29))) + ltime->day != 29)) || + (ltime->year == 0 && (ltime->month != 0 || ltime->day != 0))) { *was_cut= 2; return TRUE; From 30d7290c2127e709bd9d8753eebbb67114a0b94d Mon Sep 17 00:00:00 2001 From: "jimw@rama.(none)" <> Date: Wed, 12 Jul 2006 13:22:38 -0700 Subject: [PATCH 07/44] Bug #17903: cast to char results in binary The character set was not being properly initialized in CAST() with a type like "CHAR(2) BINARY", which resulted in incorrect results or even a crash. --- mysql-test/r/cast.result | 11 +++++++++++ mysql-test/t/cast.test | 14 +++++++++++++- sql/sql_yacc.yy | 2 +- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/cast.result b/mysql-test/r/cast.result index d60efa083e0..a07ca21652b 100644 --- a/mysql-test/r/cast.result +++ b/mysql-test/r/cast.result @@ -381,3 +381,14 @@ DROP TABLE t1; select cast(NULL as decimal(6)) as t1; t1 NULL +set names latin1; +select hex(cast('a' as char(2) binary)); +hex(cast('a' as char(2) binary)) +61 +select hex(cast('a' as binary(2))); +hex(cast('a' as binary(2))) +6100 +select hex(cast('a' as char(2) binary)); +hex(cast('a' as char(2) binary)) +61 +End of 5.0 tests diff --git a/mysql-test/t/cast.test b/mysql-test/t/cast.test index 533da542855..ecc92ed01d1 100644 --- a/mysql-test/t/cast.test +++ b/mysql-test/t/cast.test @@ -204,7 +204,19 @@ SELECT CAST(v AS DECIMAL), CAST(tt AS DECIMAL), CAST(t AS DECIMAL), CAST(mt AS DECIMAL), CAST(lt AS DECIMAL) from t1; DROP TABLE t1; -# Bug @10237 (CAST(NULL DECIMAL) crashes server) + +# +# Bug #10237 (CAST(NULL DECIMAL) crashes server) # select cast(NULL as decimal(6)) as t1; + +# +# Bug #17903: cast to char results in binary +# +set names latin1; +select hex(cast('a' as char(2) binary)); +select hex(cast('a' as binary(2))); +select hex(cast('a' as char(2) binary)); + +--echo End of 5.0 tests diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index deac9cb5c40..a730e2533b1 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -3089,7 +3089,7 @@ opt_bin_mod: | BINARY { Lex->type|= BINCMP_FLAG; }; opt_bin_charset: - /* empty */ { } + /* empty */ { Lex->charset= NULL; } | ASCII_SYM { Lex->charset=&my_charset_latin1; } | UNICODE_SYM { From 2d43d0675e86339d71e3a9c3d72e5e2995e71411 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 18 Jul 2006 12:41:41 +0200 Subject: [PATCH 08/44] Bug#18539 uncompress(d) is null: impossible? - Add a check that length of field to uncompress is longer than 4 bytes. This can be dones as the length of uncompressed data is written as first four bytes of field and thus it can't be valid compressed data. --- mysql-test/r/func_compress.result | 10 +++++----- sql/item_strfunc.cc | 10 ++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/func_compress.result b/mysql-test/r/func_compress.result index df8939d98f1..00d5ebfc351 100644 --- a/mysql-test/r/func_compress.result +++ b/mysql-test/r/func_compress.result @@ -85,12 +85,12 @@ explain select * from t1 where uncompress(a) is null; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 system NULL NULL NULL NULL 1 Warnings: -Error 1256 Uncompressed data size too large; the maximum size is 104857600 (probably, length of uncompressed data was corrupted) +Error 1259 ZLIB: Input data corrupted select * from t1 where uncompress(a) is null; a foo Warnings: -Error 1256 Uncompressed data size too large; the maximum size is 104857600 (probably, length of uncompressed data was corrupted) +Error 1259 ZLIB: Input data corrupted explain select *, uncompress(a) from t1; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 system NULL NULL NULL NULL 1 @@ -98,12 +98,12 @@ select *, uncompress(a) from t1; a uncompress(a) foo NULL Warnings: -Error 1256 Uncompressed data size too large; the maximum size is 104857600 (probably, length of uncompressed data was corrupted) +Error 1259 ZLIB: Input data corrupted select *, uncompress(a), uncompress(a) is null from t1; a uncompress(a) uncompress(a) is null foo NULL 1 Warnings: -Error 1256 Uncompressed data size too large; the maximum size is 104857600 (probably, length of uncompressed data was corrupted) -Error 1256 Uncompressed data size too large; the maximum size is 104857600 (probably, length of uncompressed data was corrupted) +Error 1259 ZLIB: Input data corrupted +Error 1259 ZLIB: Input data corrupted drop table t1; End of 5.0 tests diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 97ed15c8bb7..a524e4e3056 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -2965,6 +2965,16 @@ String *Item_func_uncompress::val_str(String *str) if (res->is_empty()) return res; + /* If length is less than 4 bytes, data is corrupt */ + if (res->length() <= 4) + { + push_warning_printf(current_thd,MYSQL_ERROR::WARN_LEVEL_ERROR, + ER_ZLIB_Z_DATA_ERROR, + ER(ER_ZLIB_Z_DATA_ERROR)); + goto err; + } + + /* Size of uncompressed data is stored as first 4 bytes of field */ new_size= uint4korr(res->ptr()) & 0x3FFFFFFF; if (new_size > current_thd->variables.max_allowed_packet) { From d18eacc71d5c869bec9bcf9e7ba450c721ae3e90 Mon Sep 17 00:00:00 2001 From: "jimw@rama.(none)" <> Date: Tue, 18 Jul 2006 16:04:18 -0700 Subject: [PATCH 09/44] Bug #19498: Inconsistent support for DEFAULT in TEXT columns When a default of '' was specified for TEXT/BLOB columns, the specification was silently ignored. This is presumably to be nice to applications (or people) who generate their column definitions in a not-very-clever fashion. For clarity, doing this now results in a warning, or an error in strict mode. --- mysql-test/r/federated.result | 4 ++++ mysql-test/r/fulltext_distinct.result | 2 ++ mysql-test/r/fulltext_update.result | 2 ++ mysql-test/r/gis-rtree.result | 6 ++++++ mysql-test/r/gis.result | 2 ++ mysql-test/r/join_outer.result | 2 ++ mysql-test/r/order_by.result | 2 ++ mysql-test/r/type_blob.result | 20 ++++++++++++++++++++ mysql-test/r/type_ranges.result | 3 +++ mysql-test/t/type_blob.test | 15 +++++++++++++++ sql/field.cc | 21 +++++++++++++++++++-- 11 files changed, 77 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/federated.result b/mysql-test/r/federated.result index 709e44579e2..baf8641c9e9 100644 --- a/mysql-test/r/federated.result +++ b/mysql-test/r/federated.result @@ -967,6 +967,8 @@ CREATE TABLE federated.t1 ( `blurb` text default '', PRIMARY KEY (blurb_id)) DEFAULT CHARSET=latin1; +Warnings: +Warning 1101 BLOB/TEXT column 'blurb' can't have a default value DROP TABLE IF EXISTS federated.t1; CREATE TABLE federated.t1 ( `blurb_id` int NOT NULL DEFAULT 0, @@ -975,6 +977,8 @@ PRIMARY KEY (blurb_id)) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/federated/t1'; +Warnings: +Warning 1101 BLOB/TEXT column 'blurb' can't have a default value INSERT INTO federated.t1 VALUES (1, " MySQL supports a number of column types in several categories: numeric types, date and time types, and string (character) types. This chapter first gives an overview of these column types, and then provides a more detailed description of the properties of the types in each category, and a summary of the column type storage requirements. The overview is intentionally brief. The more detailed descriptions should be consulted for additional information about particular column types, such as the allowable formats in which you can specify values."); INSERT INTO federated.t1 VALUES (2, "All arithmetic is done using signed BIGINT or DOUBLE values, so you should not use unsigned big integers larger than 9223372036854775807 (63 bits) except with bit functions! If you do that, some of the last digits in the result may be wrong because of rounding errors when converting a BIGINT value to a DOUBLE."); INSERT INTO federated.t1 VALUES (3, " A floating-point number. p represents the precision. It can be from 0 to 24 for a single-precision floating-point number and from 25 to 53 for a double-precision floating-point number. These types are like the FLOAT and DOUBLE types described immediately following. FLOAT(p) has the same range as the corresponding FLOAT and DOUBLE types, but the display size and number of decimals are undefined. "); diff --git a/mysql-test/r/fulltext_distinct.result b/mysql-test/r/fulltext_distinct.result index de0668ff28c..7fd42fab646 100644 --- a/mysql-test/r/fulltext_distinct.result +++ b/mysql-test/r/fulltext_distinct.result @@ -8,6 +8,8 @@ KEY kt(tag), KEY kv(value(15)), FULLTEXT KEY kvf(value) ) ENGINE=MyISAM; +Warnings: +Warning 1101 BLOB/TEXT column 'value' can't have a default value CREATE TABLE t2 ( id_t2 mediumint unsigned NOT NULL default '0', id_t1 mediumint unsigned NOT NULL default '0', diff --git a/mysql-test/r/fulltext_update.result b/mysql-test/r/fulltext_update.result index 5d3f95b318c..4a615c88fdd 100644 --- a/mysql-test/r/fulltext_update.result +++ b/mysql-test/r/fulltext_update.result @@ -9,6 +9,8 @@ name VARCHAR(80) DEFAULT '' NOT NULL, FULLTEXT(url,description,shortdesc,longdesc), PRIMARY KEY(gnr) ); +Warnings: +Warning 1101 BLOB/TEXT column 'longdesc' can't have a default value insert into test (url,shortdesc,longdesc,description,name) VALUES ("http:/test.at", "kurz", "lang","desc", "name"); insert into test (url,shortdesc,longdesc,description,name) VALUES diff --git a/mysql-test/r/gis-rtree.result b/mysql-test/r/gis-rtree.result index 28c59053435..b283d64395d 100644 --- a/mysql-test/r/gis-rtree.result +++ b/mysql-test/r/gis-rtree.result @@ -804,6 +804,8 @@ INSERT INTO t2 SELECT GeomFromText(st) FROM t1; ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field drop table t1, t2; CREATE TABLE t1 (`geometry` geometry NOT NULL default '',SPATIAL KEY `gndx` (`geometry`(32))) ENGINE=MyISAM DEFAULT CHARSET=latin1; +Warnings: +Warning 1101 BLOB/TEXT column 'geometry' can't have a default value INSERT INTO t1 (geometry) VALUES (PolygonFromText('POLYGON((-18.6086111000 -66.9327777000, -18.6055555000 -66.8158332999, -18.7186111000 -66.8102777000, -18.7211111000 -66.9269443999, @@ -820,6 +822,8 @@ CREATE TABLE t1 ( c1 geometry NOT NULL default '', SPATIAL KEY i1 (c1(32)) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; +Warnings: +Warning 1101 BLOB/TEXT column 'c1' can't have a default value INSERT INTO t1 (c1) VALUES ( PolygonFromText('POLYGON((-18.6086111000 -66.9327777000, -18.6055555000 -66.8158332999, @@ -834,6 +838,8 @@ CREATE TABLE t1 ( c1 geometry NOT NULL default '', SPATIAL KEY i1 (c1(32)) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; +Warnings: +Warning 1101 BLOB/TEXT column 'c1' can't have a default value INSERT INTO t1 (c1) VALUES ( PolygonFromText('POLYGON((-18.6086111000 -66.9327777000, -18.6055555000 -66.8158332999, diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result index 7a0f689df36..e37dca9e86c 100644 --- a/mysql-test/r/gis.result +++ b/mysql-test/r/gis.result @@ -583,6 +583,8 @@ t1 CREATE TABLE `t1` ( drop table t1; CREATE TABLE `t1` (`object_id` bigint(20) unsigned NOT NULL default '0', `geo` geometry NOT NULL default '') ENGINE=MyISAM ; +Warnings: +Warning 1101 BLOB/TEXT column 'geo' can't have a default value insert into t1 values ('85984',GeomFromText('MULTIPOLYGON(((-115.006363 36.305435,-114.992394 36.305202,-114.991219 36.305975,-114.991163 36.306845,-114.989432 36.309452,-114.978275 36.312642,-114.977363 diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result index eae023813b5..a983b32ba46 100644 --- a/mysql-test/r/join_outer.result +++ b/mysql-test/r/join_outer.result @@ -598,6 +598,8 @@ id int(11) DEFAULT '0' NOT NULL, name tinytext DEFAULT '' NOT NULL, UNIQUE id (id) ); +Warnings: +Warning 1101 BLOB/TEXT column 'name' can't have a default value INSERT INTO t1 VALUES (1,'yes'),(2,'no'); CREATE TABLE t2 ( id int(11) DEFAULT '0' NOT NULL, diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result index a36935a583d..9756ab49ac7 100644 --- a/mysql-test/r/order_by.result +++ b/mysql-test/r/order_by.result @@ -280,6 +280,8 @@ info text NOT NULL default '', ipnr varchar(30) NOT NULL default '', PRIMARY KEY (member_id) ) ENGINE=MyISAM PACK_KEYS=1; +Warnings: +Warning 1101 BLOB/TEXT column 'info' can't have a default value insert into t1 (member_id) values (1),(2),(3); select member_id, nickname, voornaam FROM t1 ORDER by lastchange_datum DESC LIMIT 2; diff --git a/mysql-test/r/type_blob.result b/mysql-test/r/type_blob.result index 4fd220045c2..73b67a2241e 100644 --- a/mysql-test/r/type_blob.result +++ b/mysql-test/r/type_blob.result @@ -503,6 +503,8 @@ foobar boggle fish 10 drop table t1; create table t1 (id integer auto_increment unique,imagem LONGBLOB not null default ''); +Warnings: +Warning 1101 BLOB/TEXT column 'imagem' can't have a default value insert into t1 (id) values (1); select charset(load_file('../../std_data/words.dat')), @@ -788,3 +790,21 @@ NULL 616100000000 620000000000 drop table t1; +create table t1 (a text default ''); +Warnings: +Warning 1101 BLOB/TEXT column 'a' can't have a default value +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` text +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +insert into t1 values (default); +select * from t1; +a +NULL +drop table t1; +set @@sql_mode='TRADITIONAL'; +create table t1 (a text default ''); +ERROR 42000: BLOB/TEXT column 'a' can't have a default value +set @@sql_mode=''; +End of 5.0 tests diff --git a/mysql-test/r/type_ranges.result b/mysql-test/r/type_ranges.result index bd89c09e94d..cfbe11b975e 100644 --- a/mysql-test/r/type_ranges.result +++ b/mysql-test/r/type_ranges.result @@ -38,6 +38,9 @@ KEY (ulong), KEY (ulonglong,ulong), KEY (options,flags) ); +Warnings: +Warning 1101 BLOB/TEXT column 'mediumblob_col' can't have a default value +Warning 1101 BLOB/TEXT column 'longblob_col' can't have a default value show full fields from t1; Field Type Collation Null Key Default Extra Privileges Comment auto int(5) unsigned NULL NO PRI NULL auto_increment # diff --git a/mysql-test/t/type_blob.test b/mysql-test/t/type_blob.test index 503d7ffc0b9..6d79dcc863b 100644 --- a/mysql-test/t/type_blob.test +++ b/mysql-test/t/type_blob.test @@ -423,3 +423,18 @@ alter table t1 modify a binary(5); select hex(a) from t1 order by a; select hex(concat(a,'\0')) as b from t1 order by concat(a,'\0'); drop table t1; + +# +# Bug #19489: Inconsistent support for DEFAULT in TEXT columns +# +create table t1 (a text default ''); +show create table t1; +insert into t1 values (default); +select * from t1; +drop table t1; +set @@sql_mode='TRADITIONAL'; +--error ER_BLOB_CANT_HAVE_DEFAULT +create table t1 (a text default ''); +set @@sql_mode=''; + +--echo End of 5.0 tests diff --git a/sql/field.cc b/sql/field.cc index 946351efe36..31184a9f08c 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -8363,7 +8363,8 @@ bool create_field::init(THD *thd, char *fld_name, enum_field_types fld_type, comment= *fld_comment; /* - Set flag if this field doesn't have a default value + Set NO_DEFAULT_VALUE_FLAG if this field doesn't have a default value and + it is NOT NULL, not an AUTO_INCREMENT field and not a TIMESTAMP. */ if (!fld_default_value && !(fld_type_modifier & AUTO_INCREMENT_FLAG) && (fld_type_modifier & NOT_NULL_FLAG) && fld_type != FIELD_TYPE_TIMESTAMP) @@ -8440,12 +8441,28 @@ bool create_field::init(THD *thd, char *fld_name, enum_field_types fld_type, /* Allow empty as default value. */ String str,*res; res= fld_default_value->val_str(&str); - if (res->length()) + /* + A default other than '' is always an error, and any non-NULL + specified default is an error in strict mode. + */ + if (res->length() || (thd->variables.sql_mode & + (MODE_STRICT_TRANS_TABLES | + MODE_STRICT_ALL_TABLES))) { my_error(ER_BLOB_CANT_HAVE_DEFAULT, MYF(0), fld_name); /* purecov: inspected */ DBUG_RETURN(TRUE); } + else + { + /* + Otherwise a default of '' is just a warning. + */ + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_BLOB_CANT_HAVE_DEFAULT, + ER(ER_BLOB_CANT_HAVE_DEFAULT), + fld_name); + } def= 0; } flags|= BLOB_FLAG; From 34256fb8f59173c82ac5f5fed86662fe1af511c8 Mon Sep 17 00:00:00 2001 From: "cmiller@zippy.cornsilk.net" <> Date: Wed, 19 Jul 2006 14:33:56 -0400 Subject: [PATCH 10/44] Bug #14448: delimiter in 'prompt' "I want to have the current delimiter in the prompt so that I can know at a glance which is set." Add a 'l' format specifier that represents the current statement delimiter. --- client/mysql.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/client/mysql.cc b/client/mysql.cc index 94b43d030e8..22534324aca 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -3724,6 +3724,9 @@ static const char* construct_prompt() case 't': processed_prompt.append('\t'); break; + case 'l': + processed_prompt.append(delimiter_str); + break; default: processed_prompt.append(c); } From dbb5a408eaf1741823910fb73862a12b58502480 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Thu, 20 Jul 2006 17:30:44 +0200 Subject: [PATCH 11/44] Bug#15690 mysqlimport tries to set options the server doesn't understand - "set @@character_set_database" should be ignored by servers prior to 4.1.1 --- client/mysqlimport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/mysqlimport.c b/client/mysqlimport.c index 1f9b96f91be..67659684c9c 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -521,7 +521,7 @@ int main(int argc, char **argv) return(1); /* purecov: deadcode */ } - if (mysql_query(sock, "set @@character_set_database=binary;")) + if (mysql_query(sock, "/*!40101 set @@character_set_database=binary */;")) { db_error(sock); /* We shall countinue here, if --force was given */ return(1); From 5fda0b99d03457a9252367898866a59a4d650dcc Mon Sep 17 00:00:00 2001 From: "jimw@rama.(none)" <> Date: Fri, 21 Jul 2006 13:28:42 -0700 Subject: [PATCH 12/44] Bug #16881: password() and union select This was only demonstrated by the use of PASSWORD(), it was not related to that function at all. The calculation of the size of a field in the results of a UNION did not take into account the possible growth of a string field when being converted to the aggregated character set. --- mysql-test/r/union.result | 5 +++++ mysql-test/t/union.test | 7 +++++++ sql/item.cc | 16 ++++++++++++---- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index 426387e04f5..19b0211c442 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -1351,3 +1351,8 @@ drop table t1; (select avg(1)) union (select avg(1)) union (select avg(1)); avg(1) NULL +select _utf8'12' union select _latin1'12345'; +12 +12 +12345 +End of 5.0 tests diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index 7dfe4ac482f..b300cf91a22 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -841,3 +841,10 @@ drop table t1; (select avg(1)) union (select avg(1)) union (select avg(1)) union (select avg(1)) union (select avg(1)) union (select avg(1)); +# +# Bug #16881: password() and union select +# (The issue was poor handling of character set aggregation.) +# +select _utf8'12' union select _latin1'12345'; + +--echo End of 5.0 tests diff --git a/sql/item.cc b/sql/item.cc index ad8b79182d4..7d6ce031e15 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -6053,14 +6053,13 @@ bool Item_type_holder::join_types(THD *thd, Item *item) max_length= my_decimal_precision_to_length(precision, decimals, unsigned_flag); } - else - max_length= max(max_length, display_length(item)); - + switch (Field::result_merge_type(fld_type)) { case STRING_RESULT: { const char *old_cs, *old_derivation; + uint32 old_max_chars= max_length / collation.collation->mbmaxlen; old_cs= collation.collation->name; old_derivation= collation.derivation_name(); if (collation.aggregate(item->collation, MY_COLL_ALLOW_CONV)) @@ -6072,6 +6071,14 @@ bool Item_type_holder::join_types(THD *thd, Item *item) "UNION"); DBUG_RETURN(TRUE); } + /* + To figure out max_length, we have to take into account possible + expansion of the size of the values because of character set + conversions. + */ + max_length= max(old_max_chars * collation.collation->mbmaxlen, + display_length(item) / item->collation.collation->mbmaxlen * + collation.collation->mbmaxlen); break; } case REAL_RESULT: @@ -6090,7 +6097,8 @@ bool Item_type_holder::join_types(THD *thd, Item *item) max_length= (fld_type == MYSQL_TYPE_FLOAT) ? FLT_DIG+6 : DBL_DIG+7; break; } - default:; + default: + max_length= max(max_length, display_length(item)); }; maybe_null|= item->maybe_null; get_full_info(item); From dc0f4a21e65f9a74cbb8376df1a3223085e9a326 Mon Sep 17 00:00:00 2001 From: "jimw@rama.(none)" <> Date: Fri, 21 Jul 2006 20:29:25 -0700 Subject: [PATCH 13/44] Bug #19147: mysqlshow INFORMATION_SCHEMA does not work When a wildcard database name is given the mysqlshow, but that wildcard matches one database *exactly* (it contains the wildcard character), we list the contents of that database instead of just listing the database name as matching the wildcard. Probably the most common instance of users encountering this behavior would be with "mysqlshow information_schema". --- client/mysqlshow.c | 27 +++++++++++++++++-- mysql-test/r/mysqlshow.result | 49 +++++++++++++++++++++++++++++++++++ mysql-test/t/mysqlshow.test | 9 +++++++ 3 files changed, 83 insertions(+), 2 deletions(-) diff --git a/client/mysqlshow.c b/client/mysqlshow.c index d090495ff81..40405c53565 100644 --- a/client/mysqlshow.c +++ b/client/mysqlshow.c @@ -344,7 +344,7 @@ list_dbs(MYSQL *mysql,const char *wild) char query[255]; MYSQL_FIELD *field; MYSQL_RES *result; - MYSQL_ROW row, rrow; + MYSQL_ROW row= NULL, rrow; if (!(result=mysql_list_dbs(mysql,wild))) { @@ -352,6 +352,26 @@ list_dbs(MYSQL *mysql,const char *wild) mysql_error(mysql)); return 1; } + + /* + If a wildcard was used, but there was only one row and it's name is an + exact match, we'll assume they really wanted to see the contents of that + database. This is because it is fairly common for database names to + contain the underscore (_), like INFORMATION_SCHEMA. + */ + if (wild && mysql_num_rows(result) == 1) + { + row= mysql_fetch_row(result); + if (!my_strcasecmp(&my_charset_latin1, row[0], wild)) + { + mysql_free_result(result); + if (opt_status) + return list_table_status(mysql, wild, NULL); + else + return list_tables(mysql, wild, NULL); + } + } + if (wild) printf("Wildcard: %s\n",wild); @@ -368,7 +388,8 @@ list_dbs(MYSQL *mysql,const char *wild) else print_header(header,length,"Tables",6,"Total Rows",12,NullS); - while ((row = mysql_fetch_row(result))) + /* The first row may have already been read up above. */ + while (row || (row= mysql_fetch_row(result))) { counter++; @@ -422,6 +443,8 @@ list_dbs(MYSQL *mysql,const char *wild) print_row(row[0],length,tables,6,NullS); else print_row(row[0],length,tables,6,rows,12,NullS); + + row= NULL; } print_trailer(length, diff --git a/mysql-test/r/mysqlshow.result b/mysql-test/r/mysqlshow.result index 942cde83f21..2bf8a58de4e 100644 --- a/mysql-test/r/mysqlshow.result +++ b/mysql-test/r/mysqlshow.result @@ -75,3 +75,52 @@ Database: test 2 rows in set. DROP TABLE t1, t2; +Database: information_schema ++---------------------------------------+ +| Tables | ++---------------------------------------+ +| CHARACTER_SETS | +| COLLATIONS | +| COLLATION_CHARACTER_SET_APPLICABILITY | +| COLUMNS | +| COLUMN_PRIVILEGES | +| KEY_COLUMN_USAGE | +| ROUTINES | +| SCHEMATA | +| SCHEMA_PRIVILEGES | +| STATISTICS | +| TABLES | +| TABLE_CONSTRAINTS | +| TABLE_PRIVILEGES | +| TRIGGERS | +| USER_PRIVILEGES | +| VIEWS | ++---------------------------------------+ +Database: INFORMATION_SCHEMA ++---------------------------------------+ +| Tables | ++---------------------------------------+ +| CHARACTER_SETS | +| COLLATIONS | +| COLLATION_CHARACTER_SET_APPLICABILITY | +| COLUMNS | +| COLUMN_PRIVILEGES | +| KEY_COLUMN_USAGE | +| ROUTINES | +| SCHEMATA | +| SCHEMA_PRIVILEGES | +| STATISTICS | +| TABLES | +| TABLE_CONSTRAINTS | +| TABLE_PRIVILEGES | +| TRIGGERS | +| USER_PRIVILEGES | +| VIEWS | ++---------------------------------------+ +Wildcard: inf_rmation_schema ++--------------------+ +| Databases | ++--------------------+ +| information_schema | ++--------------------+ +End of 5.0 tests diff --git a/mysql-test/t/mysqlshow.test b/mysql-test/t/mysqlshow.test index 78c4ae2b531..9ed93079f57 100644 --- a/mysql-test/t/mysqlshow.test +++ b/mysql-test/t/mysqlshow.test @@ -25,3 +25,12 @@ select "---- -v -t ---------" as ""; select "---- -v -v -t ------" as ""; --exec $MYSQL_SHOW test -v -v -t DROP TABLE t1, t2; + +# +# Bug #19147: mysqlshow INFORMATION_SCHEMA does not work +# +--exec $MYSQL_SHOW information_schema +--exec $MYSQL_SHOW INFORMATION_SCHEMA +--exec $MYSQL_SHOW inf_rmation_schema + +--echo End of 5.0 tests From 1c04310e30b77d8dc7cae66fa5ea9b263faca92f Mon Sep 17 00:00:00 2001 From: "ramil/ram@mysql.com/myoffice.izhnet.ru" <> Date: Sun, 23 Jul 2006 15:25:30 +0500 Subject: [PATCH 14/44] Fix for bug #8143: A date with value 0 is treated as a NULL value --- mysql-test/r/delete.result | 10 ++++++++++ mysql-test/t/delete.test | 11 +++++++++++ sql/sql_delete.cc | 8 ++++++++ 3 files changed, 29 insertions(+) diff --git a/mysql-test/r/delete.result b/mysql-test/r/delete.result index 05f1c967e77..0946dc8f809 100644 --- a/mysql-test/r/delete.result +++ b/mysql-test/r/delete.result @@ -192,3 +192,13 @@ delete t2.*,t3.* from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b; select * from t3; a b drop table t1,t2,t3; +create table t1(a date not null); +insert into t1 values (0); +select * from t1 where a is null; +a +0000-00-00 +delete from t1 where a is null; +select count(*) from t1; +count(*) +0 +drop table t1; diff --git a/mysql-test/t/delete.test b/mysql-test/t/delete.test index 4284bd2a06d..677ffaa2860 100644 --- a/mysql-test/t/delete.test +++ b/mysql-test/t/delete.test @@ -171,3 +171,14 @@ delete t2.*,t3.* from t1,t2,t3 where t1.a=t2.a AND t2.b=t3.a and t1.b=t3.b; # This should be empty select * from t3; drop table t1,t2,t3; + +# +# Bug #8143: deleting '0000-00-00' values using IS NULL +# + +create table t1(a date not null); +insert into t1 values (0); +select * from t1 where a is null; +delete from t1 where a is null; +select count(*) from t1; +drop table t1; diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 381d1a71e31..b608773bf6e 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -91,6 +91,14 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, /* Handler didn't support fast delete; Delete rows one by one */ } + if (conds) + { + Item::cond_result result; + conds= remove_eq_conds(thd, conds, &result); + if (result == Item::COND_FALSE) // Impossible where + limit= 0; + } + table->used_keys.clear_all(); table->quick_keys.clear_all(); // Can't use 'only index' select=make_select(table, 0, 0, conds, 0, &error); From 3aa99c062f7af2b911b32ffcd9fb428220d7a82f Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 24 Jul 2006 10:56:33 +0200 Subject: [PATCH 15/44] Bug#10877 mysqldump should use consistent last line - Add printout in write_footer to tell that mysqldump has completed. Ex: -- Dump completed 2006-07-24 8:55:05 --- client/Makefile.am | 4 +++- client/mysqldump.c | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/client/Makefile.am b/client/Makefile.am index 5787905fd35..b80357f68ea 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -47,7 +47,9 @@ 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) -mysqldump_SOURCES= mysqldump.c my_user.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) 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 diff --git a/client/mysqldump.c b/client/mysqldump.c index 4318e4b9528..de35358ee42 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -565,6 +565,13 @@ static void write_footer(FILE *sql_file) fprintf(sql_file, "/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;\n"); fputs("\n", sql_file); + if (opt_comments) + { + char time_str[20]; + get_date(time_str, GETDATE_DATE_TIME, 0); + fprintf(sql_file, "-- Dump completed on %s\n", + time_str); + } check_io(sql_file); } } /* write_footer */ From 6c12e990b2936aba2481457c6381bc14f9f20f9c Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 24 Jul 2006 11:51:52 +0200 Subject: [PATCH 16/44] Add function verbose_msg --- client/mysqldump.c | 94 +++++++++++++++++++++++----------------------- 1 file changed, 48 insertions(+), 46 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index 4318e4b9528..9350d013c18 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -426,6 +426,30 @@ static my_bool dump_all_views_in_db(char *database); #include +/* + Print the supplied message if in verbose mode + + SYNOPSIS + verbose_msg() + fmt format specifier + ... variable number of parameters +*/ + +static void verbose_msg(const char *fmt, ...) +{ + va_list args; + DBUG_ENTER("verbose_msg"); + + if (!verbose) + DBUG_VOID_RETURN; + + va_start(args, fmt); + vfprintf(stderr, fmt, args); + va_end(args); + + DBUG_VOID_RETURN; +} + /* exit with message if ferror(file) @@ -894,10 +918,8 @@ static int dbConnect(char *host, char *user,char *passwd) { char buff[20+FN_REFLEN]; DBUG_ENTER("dbConnect"); - if (verbose) - { - fprintf(stderr, "-- Connecting to %s...\n", host ? host : "localhost"); - } + + verbose_msg("-- Connecting to %s...\n", host ? host : "localhost"); mysql_init(&mysql_connection); if (opt_compress) mysql_options(&mysql_connection,MYSQL_OPT_COMPRESS,NullS); @@ -963,8 +985,7 @@ static int dbConnect(char *host, char *user,char *passwd) */ static void dbDisconnect(char *host) { - if (verbose) - fprintf(stderr, "-- Disconnecting from %s...\n", host ? host : "localhost"); + verbose_msg("-- Disconnecting from %s...\n", host ? host : "localhost"); mysql_close(sock); } /* dbDisconnect */ @@ -1418,10 +1439,8 @@ static uint get_table_structure(char *table, char *db, char *table_type, if (delayed && (*ignore_flag & IGNORE_INSERT_DELAYED)) { delayed= 0; - if (verbose) - fprintf(stderr, - "-- Warning: Unable to use delayed inserts for table '%s' " - "because it's of type %s\n", table, table_type); + verbose_msg("-- Warning: Unable to use delayed inserts for table '%s' " + "because it's of type %s\n", table, table_type); } complete_insert= 0; @@ -1437,8 +1456,7 @@ static uint get_table_structure(char *table, char *db, char *table_type, insert_option= ((delayed && opt_ignore) ? " DELAYED IGNORE " : delayed ? " DELAYED " : opt_ignore ? " IGNORE " : ""); - if (verbose) - fprintf(stderr, "-- Retrieving table structure for table %s...\n", table); + verbose_msg("-- Retrieving table structure for table %s...\n", table); len= my_snprintf(query_buff, sizeof(query_buff), "SET OPTION SQL_QUOTE_SHOW_CREATE=%d", @@ -1505,8 +1523,7 @@ static uint get_table_structure(char *table, char *db, char *table_type, { char *scv_buff = NULL; - if (verbose) - fprintf(stderr, "-- It's a view, create dummy table for view\n"); + verbose_msg("-- It's a view, create dummy table for view\n"); /* save "show create" statement for later */ if ((row= mysql_fetch_row(result)) && (scv_buff=row[1])) @@ -1649,10 +1666,8 @@ static uint get_table_structure(char *table, char *db, char *table_type, } else { - if (verbose) - fprintf(stderr, - "%s: Warning: Can't set SQL_QUOTE_SHOW_CREATE option (%s)\n", - my_progname, mysql_error(sock)); + verbose_msg("%s: Warning: Can't set SQL_QUOTE_SHOW_CREATE option (%s)\n", + my_progname, mysql_error(sock)); my_snprintf(query_buff, sizeof(query_buff), "show fields from %s", result_table); @@ -1841,10 +1856,8 @@ static uint get_table_structure(char *table, char *db, char *table_type, { if (mysql_errno(sock) != ER_PARSE_ERROR) { /* If old MySQL version */ - if (verbose) - fprintf(stderr, - "-- Warning: Couldn't get status information for table %s (%s)\n", - result_table,mysql_error(sock)); + verbose_msg("-- Warning: Couldn't get status information for " \ + "table %s (%s)\n", result_table,mysql_error(sock)); } } else if (!(row= mysql_fetch_row(result))) @@ -2096,10 +2109,8 @@ static void dump_table(char *table, char *db) /* Check --no-data flag */ if (dFlag) { - if (verbose) - fprintf(stderr, - "-- Skipping dump data for table '%s', --no-data was used\n", - table); + verbose_msg("-- Skipping dump data for table '%s', --no-data was used\n", + table); DBUG_VOID_RETURN; } @@ -2112,27 +2123,22 @@ static void dump_table(char *table, char *db) */ if (ignore_flag & IGNORE_DATA) { - if (verbose) - fprintf(stderr, - "-- Warning: Skipping data for table '%s' because it's of type %s\n", - table, table_type); + verbose_msg("-- Warning: Skipping data for table '%s' because " \ + "it's of type %s\n", table, table_type); DBUG_VOID_RETURN; } /* Check that there are any fields in the table */ if (num_fields == 0) { - if (verbose) - fprintf(stderr, - "-- Skipping dump data for table '%s', it has no fields\n", - table); + verbose_msg("-- Skipping dump data for table '%s', it has no fields\n", + table); DBUG_VOID_RETURN; } result_table= quote_name(table,table_buff, 1); opt_quoted_table= quote_name(table, table_buff2, 0); - if (verbose) - fprintf(stderr, "-- Sending SELECT query...\n"); + verbose_msg("-- Sending SELECT query...\n"); if (path) { char filename[FN_REFLEN], tmp_path[FN_REFLEN]; @@ -2229,8 +2235,8 @@ static void dump_table(char *table, char *db) DB_error(sock, "when retrieving data from server"); goto err; } - if (verbose) - fprintf(stderr, "-- Retrieving rows...\n"); + + verbose_msg("-- Retrieving rows...\n"); if (mysql_num_fields(res) != num_fields) { fprintf(stderr,"%s: Error in field count for table: %s ! Aborting.\n", @@ -3172,10 +3178,8 @@ char check_if_ignore_table(const char *table_name, char *table_type) { if (mysql_errno(sock) != ER_PARSE_ERROR) { /* If old MySQL version */ - if (verbose) - fprintf(stderr, - "-- Warning: Couldn't get status information for table %s (%s)\n", - table_name,mysql_error(sock)); + verbose_msg("-- Warning: Couldn't get status information for " \ + "table %s (%s)\n", table_name,mysql_error(sock)); DBUG_RETURN(result); /* assume table is ok */ } } @@ -3361,8 +3365,7 @@ static my_bool get_view_structure(char *table, char* db) if (tFlag) /* Don't write table creation info */ DBUG_RETURN(0); - if (verbose) - fprintf(stderr, "-- Retrieving view structure for table %s...\n", table); + verbose_msg("-- Retrieving view structure for table %s...\n", table); #ifdef NOT_REALLY_USED_YET sprintf(insert_pat,"SET OPTION SQL_QUOTE_SHOW_CREATE=%d", @@ -3383,8 +3386,7 @@ static my_bool get_view_structure(char *table, char* db) field= mysql_fetch_field_direct(table_res, 0); if (strcmp(field->name, "View") != 0) { - if (verbose) - fprintf(stderr, "-- It's base table, skipped\n"); + verbose_msg("-- It's base table, skipped\n"); DBUG_RETURN(0); } From b450438c8b7f86f50d15f2e274312136aa5bbae6 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 24 Jul 2006 11:56:01 +0200 Subject: [PATCH 17/44] Change tFlag and dFlag into human readable format tFlag => opt_no_create_info dFlag => opt_no_data --- client/mysqldump.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index 9350d013c18..36472364df8 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -83,7 +83,8 @@ static ulong find_set(TYPELIB *lib, const char *x, uint length, static char *alloc_query_str(ulong size); static char *field_escape(char *to,const char *from,uint length); -static my_bool verbose=0,tFlag=0,dFlag=0,quick= 1, extended_insert= 1, +static my_bool verbose= 0, opt_no_create_info= 0, opt_no_data= 0, + quick= 1, extended_insert= 1, lock_tables=1,ignore_errors=0,flush_logs=0, opt_drop=1,opt_keywords=0,opt_lock=1,opt_compress=0, opt_delayed=0,create_options=1,opt_quoted=0,opt_databases=0, @@ -312,9 +313,10 @@ static struct my_option my_long_options[] = (gptr*) &opt_create_db, (gptr*) &opt_create_db, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"no-create-info", 't', "Don't write table creation info.", - (gptr*) &tFlag, (gptr*) &tFlag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"no-data", 'd', "No row information.", (gptr*) &dFlag, (gptr*) &dFlag, 0, - GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + (gptr*) &opt_no_create_info, (gptr*) &opt_no_create_info, 0, GET_BOOL, + NO_ARG, 0, 0, 0, 0, 0, 0}, + {"no-data", 'd', "No row information.", (gptr*) &opt_no_data, + (gptr*) &opt_no_data, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"no-set-names", 'N', "Deprecated. Use --skip-set-charset instead.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -1474,7 +1476,7 @@ static uint get_table_structure(char *table, char *db, char *table_type, if (!opt_xml && !mysql_query_with_error_report(sock, 0, query_buff)) { /* using SHOW CREATE statement */ - if (!tFlag) + if (!opt_no_create_info) { /* Make an sql-file, if path was given iow. option -T was given */ char buff[20+FN_REFLEN]; @@ -1678,7 +1680,7 @@ static uint get_table_structure(char *table, char *db, char *table_type, } /* Make an sql-file, if path was given iow. option -T was given */ - if (!tFlag) + if (!opt_no_create_info) { if (path) { @@ -1722,7 +1724,7 @@ static uint get_table_structure(char *table, char *db, char *table_type, ulong *lengths= mysql_fetch_lengths(result); if (init) { - if (!opt_xml && !tFlag) + if (!opt_xml && !opt_no_create_info) { fputs(",\n",sql_file); check_io(sql_file); @@ -1734,7 +1736,7 @@ static uint get_table_structure(char *table, char *db, char *table_type, if (opt_complete_insert) dynstr_append(&insert_pat, quote_name(row[SHOW_FIELDNAME], name_buff, 0)); - if (!tFlag) + if (!opt_no_create_info) { if (opt_xml) { @@ -1764,7 +1766,7 @@ static uint get_table_structure(char *table, char *db, char *table_type, } num_fields= mysql_num_rows(result); mysql_free_result(result); - if (!tFlag) + if (!opt_no_create_info) { /* Make an sql-file, if path was given iow. option -T was given */ char buff[20+FN_REFLEN]; @@ -2107,7 +2109,7 @@ static void dump_table(char *table, char *db) return; /* Check --no-data flag */ - if (dFlag) + if (opt_no_data) { verbose_msg("-- Skipping dump data for table '%s', --no-data was used\n", table); @@ -3215,7 +3217,7 @@ char check_if_ignore_table(const char *table_name, char *table_type) /* If these two types, we do want to skip dumping the table */ - if (!dFlag && + if (!opt_no_data && (!strcmp(table_type,"MRG_MyISAM") || !strcmp(table_type,"MRG_ISAM"))) result= IGNORE_DATA; } @@ -3362,7 +3364,7 @@ static my_bool get_view_structure(char *table, char* db) FILE *sql_file = md_result_file; DBUG_ENTER("get_view_structure"); - if (tFlag) /* Don't write table creation info */ + if (opt_no_create_info) /* Don't write table creation info */ DBUG_RETURN(0); verbose_msg("-- Retrieving view structure for table %s...\n", table); From 0ab8948c9988308512652bde086b715c993a3dde Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 24 Jul 2006 12:00:44 +0200 Subject: [PATCH 18/44] Replace sock -> mysql --- client/mysqldump.c | 183 +++++++++++++++++++++++---------------------- 1 file changed, 92 insertions(+), 91 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index 36472364df8..7c6d56cb018 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -97,7 +97,7 @@ static my_bool verbose= 0, opt_no_create_info= 0, opt_no_data= 0, opt_complete_insert= 0, opt_drop_database= 0, opt_dump_triggers= 0, opt_routines=0, opt_tz_utc=1; static ulong opt_max_allowed_packet, opt_net_buffer_length; -static MYSQL mysql_connection,*sock=0; +static MYSQL mysql_connection,*mysql=0; static my_bool insert_pat_inited=0; static DYNAMIC_STRING insert_pat; static char *opt_password=0,*current_user=0, @@ -906,8 +906,8 @@ static void safe_exit(int error) first_error= error; if (ignore_errors) return; - if (sock) - mysql_close(sock); + if (mysql) + mysql_close(mysql); exit(error); } /* safe_exit */ @@ -939,7 +939,7 @@ static int dbConnect(char *host, char *user,char *passwd) mysql_options(&mysql_connection,MYSQL_SHARED_MEMORY_BASE_NAME,shared_memory_base_name); #endif mysql_options(&mysql_connection, MYSQL_SET_CHARSET_NAME, default_charset); - if (!(sock= mysql_real_connect(&mysql_connection,host,user,passwd, + if (!(mysql= mysql_real_connect(&mysql_connection,host,user,passwd, NULL,opt_mysql_port,opt_mysql_unix_port, 0))) { @@ -955,12 +955,12 @@ static int dbConnect(char *host, char *user,char *passwd) As we're going to set SQL_MODE, it would be lost on reconnect, so we cannot reconnect. */ - sock->reconnect= 0; + mysql->reconnect= 0; my_snprintf(buff, sizeof(buff), "/*!40100 SET @@SQL_MODE='%s' */", compatible_mode_normal_str); - if (mysql_query_with_error_report(sock, 0, buff)) + if (mysql_query_with_error_report(mysql, 0, buff)) { - mysql_close(sock); + mysql_close(mysql); safe_exit(EX_MYSQLERR); return 1; } @@ -971,9 +971,9 @@ static int dbConnect(char *host, char *user,char *passwd) if (opt_tz_utc) { my_snprintf(buff, sizeof(buff), "/*!40103 SET TIME_ZONE='+00:00' */"); - if (mysql_query_with_error_report(sock, 0, buff)) + if (mysql_query_with_error_report(mysql, 0, buff)) { - mysql_close(sock); + mysql_close(mysql); safe_exit(EX_MYSQLERR); return 1; } @@ -988,7 +988,7 @@ static int dbConnect(char *host, char *user,char *passwd) static void dbDisconnect(char *host) { verbose_msg("-- Disconnecting from %s...\n", host ? host : "localhost"); - mysql_close(sock); + mysql_close(mysql); } /* dbDisconnect */ @@ -1281,7 +1281,7 @@ static uint dump_routines_for_db(char *db) DBUG_ENTER("dump_routines_for_db"); DBUG_PRINT("enter", ("db: '%s'", db)); - mysql_real_escape_string(sock, db_name_buff, db, strlen(db)); + mysql_real_escape_string(mysql, db_name_buff, db, strlen(db)); /* nice comments */ if (opt_comments) @@ -1292,7 +1292,7 @@ static uint dump_routines_for_db(char *db) enough privileges to lock mysql.proc. */ if (lock_tables) - mysql_query(sock, "LOCK TABLES mysql.proc READ"); + mysql_query(mysql, "LOCK TABLES mysql.proc READ"); fprintf(sql_file, "DELIMITER ;;\n"); @@ -1303,7 +1303,7 @@ static uint dump_routines_for_db(char *db) "SHOW %s STATUS WHERE Db = '%s'", routine_type[i], db_name_buff); - if (mysql_query_with_error_report(sock, &routine_list_res, query_buff)) + if (mysql_query_with_error_report(mysql, &routine_list_res, query_buff)) DBUG_RETURN(1); if (mysql_num_rows(routine_list_res)) @@ -1317,7 +1317,7 @@ static uint dump_routines_for_db(char *db) my_snprintf(query_buff, sizeof(query_buff), "SHOW CREATE %s %s", routine_type[i], routine_name); - if (mysql_query_with_error_report(sock, &routine_res, query_buff)) + if (mysql_query_with_error_report(mysql, &routine_res, query_buff)) DBUG_RETURN(1); while ((row= mysql_fetch_row(routine_res))) @@ -1399,7 +1399,7 @@ static uint dump_routines_for_db(char *db) fprintf(sql_file, "DELIMITER ;\n"); if (lock_tables) - VOID(mysql_query_with_error_report(sock, 0, "UNLOCK TABLES")); + VOID(mysql_query_with_error_report(mysql, 0, "UNLOCK TABLES")); DBUG_RETURN(0); } @@ -1473,7 +1473,7 @@ static uint get_table_structure(char *table, char *db, char *table_type, if (opt_order_by_primary) order_by = primary_key_fields(result_table); - if (!opt_xml && !mysql_query_with_error_report(sock, 0, query_buff)) + if (!opt_xml && !mysql_query_with_error_report(mysql, 0, query_buff)) { /* using SHOW CREATE statement */ if (!opt_no_create_info) @@ -1483,7 +1483,7 @@ static uint get_table_structure(char *table, char *db, char *table_type, MYSQL_FIELD *field; my_snprintf(buff, sizeof(buff), "show create table %s", result_table); - if (mysql_query_with_error_report(sock, 0, buff)) + if (mysql_query_with_error_report(mysql, 0, buff)) { safe_exit(EX_MYSQLERR); DBUG_RETURN(0); @@ -1519,7 +1519,7 @@ static uint get_table_structure(char *table, char *db, char *table_type, check_io(sql_file); } - result= mysql_store_result(sock); + result= mysql_store_result(mysql); field= mysql_fetch_field_direct(result, 0); if (strcmp(field->name, "View") == 0) { @@ -1546,7 +1546,7 @@ static uint get_table_structure(char *table, char *db, char *table_type, */ my_snprintf(query_buff, sizeof(query_buff), "SHOW FIELDS FROM %s", result_table); - if (mysql_query_with_error_report(sock, 0, query_buff)) + if (mysql_query_with_error_report(mysql, 0, query_buff)) { /* View references invalid or privileged table/col/fun (err 1356), @@ -1554,7 +1554,7 @@ static uint get_table_structure(char *table, char *db, char *table_type, a comment with the view's 'show create' statement. (Bug #17371) */ - if (mysql_errno(sock) == ER_VIEW_INVALID) + if (mysql_errno(mysql) == ER_VIEW_INVALID) fprintf(sql_file, "\n-- failed on view %s: %s\n\n", result_table, scv_buff ? scv_buff : ""); my_free(scv_buff, MYF(MY_ALLOW_ZERO_PTR)); @@ -1565,7 +1565,7 @@ static uint get_table_structure(char *table, char *db, char *table_type, else my_free(scv_buff, MYF(MY_ALLOW_ZERO_PTR)); - if ((result= mysql_store_result(sock))) + if ((result= mysql_store_result(mysql))) { if (mysql_num_rows(result)) { @@ -1618,7 +1618,7 @@ static uint get_table_structure(char *table, char *db, char *table_type, } my_snprintf(query_buff, sizeof(query_buff), "show fields from %s", result_table); - if (mysql_query_with_error_report(sock, &result, query_buff)) + if (mysql_query_with_error_report(mysql, &result, query_buff)) { if (path) my_fclose(sql_file, MYF(MY_WME)); @@ -1669,11 +1669,11 @@ static uint get_table_structure(char *table, char *db, char *table_type, else { verbose_msg("%s: Warning: Can't set SQL_QUOTE_SHOW_CREATE option (%s)\n", - my_progname, mysql_error(sock)); + my_progname, mysql_error(mysql)); my_snprintf(query_buff, sizeof(query_buff), "show fields from %s", result_table); - if (mysql_query_with_error_report(sock, &result, query_buff)) + if (mysql_query_with_error_report(mysql, &result, query_buff)) { safe_exit(EX_MYSQLERR); DBUG_RETURN(0); @@ -1772,16 +1772,16 @@ static uint get_table_structure(char *table, char *db, char *table_type, char buff[20+FN_REFLEN]; uint keynr,primary_key; my_snprintf(buff, sizeof(buff), "show keys from %s", result_table); - if (mysql_query_with_error_report(sock, &result, buff)) + if (mysql_query_with_error_report(mysql, &result, buff)) { - if (mysql_errno(sock) == ER_WRONG_OBJECT) + if (mysql_errno(mysql) == ER_WRONG_OBJECT) { /* it is VIEW */ fputs("\t\t\n", sql_file); goto continue_xml; } fprintf(stderr, "%s: Can't get keys for table %s (%s)\n", - my_progname, result_table, mysql_error(sock)); + my_progname, result_table, mysql_error(mysql)); if (path) my_fclose(sql_file, MYF(MY_WME)); safe_exit(EX_MYSQLERR); @@ -1854,19 +1854,19 @@ static uint get_table_structure(char *table, char *db, char *table_type, my_snprintf(buff, sizeof(buff), "show table status like %s", quote_for_like(table, show_name_buff)); - if (mysql_query_with_error_report(sock, &result, buff)) + if (mysql_query_with_error_report(mysql, &result, buff)) { - if (mysql_errno(sock) != ER_PARSE_ERROR) + if (mysql_errno(mysql) != ER_PARSE_ERROR) { /* If old MySQL version */ verbose_msg("-- Warning: Couldn't get status information for " \ - "table %s (%s)\n", result_table,mysql_error(sock)); + "table %s (%s)\n", result_table,mysql_error(mysql)); } } else if (!(row= mysql_fetch_row(result))) { fprintf(stderr, "Error: Couldn't read status information for table %s (%s)\n", - result_table,mysql_error(sock)); + result_table,mysql_error(mysql)); } else { @@ -1939,7 +1939,7 @@ static void dump_triggers_for_table (char *table, char *db) "SHOW TRIGGERS LIKE %s", quote_for_like(table, name_buff)); - if (mysql_query_with_error_report(sock, &result, query_buff)) + if (mysql_query_with_error_report(mysql, &result, query_buff)) { if (path) my_fclose(sql_file, MYF(MY_WME)); @@ -2178,9 +2178,9 @@ static void dump_table(char *table, char *db) if (order_by) end = strxmov(end, " ORDER BY ", order_by, NullS); } - if (mysql_real_query(sock, query, (uint) (end - query))) + if (mysql_real_query(mysql, query, (uint) (end - query))) { - DB_error(sock, "when executing 'SELECT INTO OUTFILE'"); + DB_error(mysql, "when executing 'SELECT INTO OUTFILE'"); DBUG_VOID_RETURN; } } @@ -2226,15 +2226,15 @@ static void dump_table(char *table, char *db) fputs("\n", md_result_file); check_io(md_result_file); } - if (mysql_query_with_error_report(sock, 0, query)) - DB_error(sock, "when retrieving data from server"); + if (mysql_query_with_error_report(mysql, 0, query)) + DB_error(mysql, "when retrieving data from server"); if (quick) - res=mysql_use_result(sock); + res=mysql_use_result(mysql); else - res=mysql_store_result(sock); + res=mysql_store_result(mysql); if (!res) { - DB_error(sock, "when retrieving data from server"); + DB_error(mysql, "when retrieving data from server"); goto err; } @@ -2507,13 +2507,13 @@ static void dump_table(char *table, char *db) fputs(";\n", md_result_file); /* If not empty table */ fflush(md_result_file); check_io(md_result_file); - if (mysql_errno(sock)) + if (mysql_errno(mysql)) { my_snprintf(query, QUERY_LENGTH, "%s: Error %d: %s when dumping table %s at row: %ld\n", my_progname, - mysql_errno(sock), - mysql_error(sock), + mysql_errno(mysql), + mysql_error(mysql), result_table, rownr); fputs(query,stderr); @@ -2559,7 +2559,7 @@ static char *getTableName(int reset) if (!res) { - if (!(res = mysql_list_tables(sock,NullS))) + if (!(res = mysql_list_tables(mysql,NullS))) return(NULL); } if ((row = mysql_fetch_row(res))) @@ -2582,7 +2582,7 @@ static int dump_all_databases() MYSQL_RES *tableres; int result=0; - if (mysql_query_with_error_report(sock, &tableres, "SHOW DATABASES")) + if (mysql_query_with_error_report(mysql, &tableres, "SHOW DATABASES")) return 1; while ((row = mysql_fetch_row(tableres))) { @@ -2591,11 +2591,11 @@ static int dump_all_databases() } if (seen_views) { - if (mysql_query(sock, "SHOW DATABASES") || - !(tableres = mysql_store_result(sock))) + if (mysql_query(mysql, "SHOW DATABASES") || + !(tableres = mysql_store_result(mysql))) { my_printf_error(0, "Error: Couldn't execute 'SHOW DATABASES': %s", - MYF(0), mysql_error(sock)); + MYF(0), mysql_error(mysql)); return 1; } while ((row = mysql_fetch_row(tableres))) @@ -2632,13 +2632,13 @@ static int dump_databases(char **db_names) static int init_dumping(char *database) { - if (mysql_get_server_version(sock) >= 50003 && + if (mysql_get_server_version(mysql) >= 50003 && !my_strcasecmp(&my_charset_latin1, database, "information_schema")) return 1; - if (mysql_select_db(sock, database)) + if (mysql_select_db(mysql, database)) { - DB_error(sock, "when selecting the database"); + DB_error(mysql, "when selecting the database"); return 1; /* If --force */ } if (!path && !opt_xml) @@ -2665,7 +2665,7 @@ static int init_dumping(char *database) "SHOW CREATE DATABASE IF NOT EXISTS %s", qdatabase); - if (mysql_query(sock, qbuf) || !(dbinfo = mysql_store_result(sock))) + if (mysql_query(mysql, qbuf) || !(dbinfo = mysql_store_result(mysql))) { /* Old server version, dump generic CREATE DATABASE */ if (opt_drop_database) @@ -2733,15 +2733,15 @@ static int dump_all_tables_in_db(char *database) dynstr_append(&query, quote_name(table, table_buff, 1)); dynstr_append(&query, " READ /*!32311 LOCAL */,"); } - if (numrows && mysql_real_query(sock, query.str, query.length-1)) - DB_error(sock, "when using LOCK TABLES"); + if (numrows && mysql_real_query(mysql, query.str, query.length-1)) + DB_error(mysql, "when using LOCK TABLES"); /* We shall continue here, if --force was given */ dynstr_free(&query); } if (flush_logs) { - if (mysql_refresh(sock, REFRESH_LOG)) - DB_error(sock, "when doing refresh"); + if (mysql_refresh(mysql, REFRESH_LOG)) + DB_error(mysql, "when doing refresh"); /* We shall continue here, if --force was given */ } while ((table= getTableName(0))) @@ -2753,12 +2753,12 @@ static int dump_all_tables_in_db(char *database) my_free(order_by, MYF(MY_ALLOW_ZERO_PTR)); order_by= 0; if (opt_dump_triggers && ! opt_xml && - mysql_get_server_version(sock) >= 50009) + mysql_get_server_version(mysql) >= 50009) dump_triggers_for_table(table, database); } } if (opt_routines && !opt_xml && - mysql_get_server_version(sock) >= 50009) + mysql_get_server_version(mysql) >= 50009) { DBUG_PRINT("info", ("Dumping routines for database %s", database)); dump_routines_for_db(database); @@ -2769,7 +2769,7 @@ static int dump_all_tables_in_db(char *database) check_io(md_result_file); } if (lock_tables) - VOID(mysql_query_with_error_report(sock, 0, "UNLOCK TABLES")); + VOID(mysql_query_with_error_report(mysql, 0, "UNLOCK TABLES")); return 0; } /* dump_all_tables_in_db */ @@ -2792,9 +2792,9 @@ static my_bool dump_all_views_in_db(char *database) uint numrows; char table_buff[NAME_LEN*2+3]; - if (mysql_select_db(sock, database)) + if (mysql_select_db(mysql, database)) { - DB_error(sock, "when selecting the database"); + DB_error(mysql, "when selecting the database"); return 1; } @@ -2809,15 +2809,15 @@ static my_bool dump_all_views_in_db(char *database) dynstr_append(&query, quote_name(table, table_buff, 1)); dynstr_append(&query, " READ /*!32311 LOCAL */,"); } - if (numrows && mysql_real_query(sock, query.str, query.length-1)) - DB_error(sock, "when using LOCK TABLES"); + if (numrows && mysql_real_query(mysql, query.str, query.length-1)) + DB_error(mysql, "when using LOCK TABLES"); /* We shall continue here, if --force was given */ dynstr_free(&query); } if (flush_logs) { - if (mysql_refresh(sock, REFRESH_LOG)) - DB_error(sock, "when doing refresh"); + if (mysql_refresh(mysql, REFRESH_LOG)) + DB_error(mysql, "when doing refresh"); /* We shall continue here, if --force was given */ } while ((table= getTableName(0))) @@ -2828,7 +2828,7 @@ static my_bool dump_all_views_in_db(char *database) check_io(md_result_file); } if (lock_tables) - VOID(mysql_query_with_error_report(sock, 0, "UNLOCK TABLES")); + VOID(mysql_query_with_error_report(mysql, 0, "UNLOCK TABLES")); return 0; } /* dump_all_tables_in_db */ @@ -2858,12 +2858,12 @@ static char *get_actual_table_name(const char *old_table_name, MEM_ROOT *root) my_snprintf(query, sizeof(query), "SHOW TABLES LIKE %s", quote_for_like(old_table_name, show_name_buff)); - if (mysql_query_with_error_report(sock, 0, query)) + if (mysql_query_with_error_report(mysql, 0, query)) { safe_exit(EX_MYSQLERR); } - if ((table_res= mysql_store_result(sock))) + if ((table_res= mysql_store_result(mysql))) { my_ulonglong num_rows= mysql_num_rows(table_res); if (num_rows > 0) @@ -2925,16 +2925,16 @@ static int dump_selected_tables(char *db, char **table_names, int tables) if (lock_tables) { - if (mysql_real_query(sock, lock_tables_query.str, + if (mysql_real_query(mysql, lock_tables_query.str, lock_tables_query.length-1)) - DB_error(sock, "when doing LOCK TABLES"); + DB_error(mysql, "when doing LOCK TABLES"); /* We shall countinue here, if --force was given */ } dynstr_free(&lock_tables_query); if (flush_logs) { - if (mysql_refresh(sock, REFRESH_LOG)) - DB_error(sock, "when doing refresh"); + if (mysql_refresh(mysql, REFRESH_LOG)) + DB_error(mysql, "when doing refresh"); /* We shall countinue here, if --force was given */ } if (opt_xml) @@ -2946,7 +2946,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables) DBUG_PRINT("info",("Dumping table %s", *pos)); dump_table(*pos, db); if (opt_dump_triggers && - mysql_get_server_version(sock) >= 50009) + mysql_get_server_version(mysql) >= 50009) dump_triggers_for_table(*pos, db); } @@ -2958,7 +2958,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables) } /* obtain dump of routines (procs/functions) */ if (opt_routines && !opt_xml && - mysql_get_server_version(sock) >= 50009) + mysql_get_server_version(mysql) >= 50009) { DBUG_PRINT("info", ("Dumping routines for database %s", db)); dump_routines_for_db(db); @@ -2972,7 +2972,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables) check_io(md_result_file); } if (lock_tables) - VOID(mysql_query_with_error_report(sock, 0, "UNLOCK TABLES")); + VOID(mysql_query_with_error_report(mysql, 0, "UNLOCK TABLES")); DBUG_RETURN(0); } /* dump_selected_tables */ @@ -3157,7 +3157,7 @@ static void print_value(FILE *file, MYSQL_RES *result, MYSQL_ROW row, table_type Type of table GLOBAL VARIABLES - sock MySQL socket + mysql MySQL connection verbose Write warning messages RETURN @@ -3176,12 +3176,12 @@ char check_if_ignore_table(const char *table_name, char *table_type) DBUG_ASSERT(2*sizeof(table_name) < sizeof(show_name_buff)); my_snprintf(buff, sizeof(buff), "show table status like %s", quote_for_like(table_name, show_name_buff)); - if (mysql_query_with_error_report(sock, &res, buff)) + if (mysql_query_with_error_report(mysql, &res, buff)) { - if (mysql_errno(sock) != ER_PARSE_ERROR) + if (mysql_errno(mysql) != ER_PARSE_ERROR) { /* If old MySQL version */ verbose_msg("-- Warning: Couldn't get status information for " \ - "table %s (%s)\n", table_name,mysql_error(sock)); + "table %s (%s)\n", table_name,mysql_error(mysql)); DBUG_RETURN(result); /* assume table is ok */ } } @@ -3189,7 +3189,7 @@ char check_if_ignore_table(const char *table_name, char *table_type) { fprintf(stderr, "Error: Couldn't read status information for table %s (%s)\n", - table_name, mysql_error(sock)); + table_name, mysql_error(mysql)); mysql_free_result(res); DBUG_RETURN(result); /* assume table is ok */ } @@ -3225,6 +3225,7 @@ char check_if_ignore_table(const char *table_name, char *table_type) DBUG_RETURN(result); } + /* Get string of comma-separated primary key field names @@ -3254,12 +3255,12 @@ static char *primary_key_fields(const char *table_name) my_snprintf(show_keys_buff, sizeof(show_keys_buff), "SHOW KEYS FROM %s", table_name); - if (mysql_query(sock, show_keys_buff) || - !(res = mysql_store_result(sock))) + if (mysql_query(mysql, show_keys_buff) || + !(res = mysql_store_result(mysql))) { fprintf(stderr, "Warning: Couldn't read keys from table %s;" " records are NOT sorted (%s)\n", - table_name, mysql_error(sock)); + table_name, mysql_error(mysql)); /* Don't exit, because it's better to print out unsorted records */ goto cleanup; } @@ -3378,7 +3379,7 @@ static my_bool get_view_structure(char *table, char* db) opt_quoted_table= quote_name(table, table_buff2, 0); my_snprintf(query, sizeof(query), "SHOW CREATE TABLE %s", result_table); - if (mysql_query_with_error_report(sock, &table_res, query)) + if (mysql_query_with_error_report(mysql, &table_res, query)) { safe_exit(EX_MYSQLERR); DBUG_RETURN(0); @@ -3423,7 +3424,7 @@ static my_bool get_view_structure(char *table, char* db) "SELECT CHECK_OPTION, DEFINER, SECURITY_TYPE " \ "FROM information_schema.views " \ "WHERE table_name=\"%s\" AND table_schema=\"%s\"", table, db); - if (mysql_query(sock, query)) + if (mysql_query(mysql, query)) { /* Use the raw output from SHOW CREATE TABLE if @@ -3449,7 +3450,7 @@ static my_bool get_view_structure(char *table, char* db) mysql_free_result(table_res); /* Get the result from "select ... information_schema" */ - if (!(table_res= mysql_store_result(sock)) || + if (!(table_res= mysql_store_result(mysql)) || !(row= mysql_fetch_row(table_res))) { safe_exit(EX_MYSQLERR); @@ -3544,21 +3545,21 @@ int main(int argc, char **argv) write_header(md_result_file, *argv); if ((opt_lock_all_tables || opt_master_data) && - do_flush_tables_read_lock(sock)) + do_flush_tables_read_lock(mysql)) goto err; - if (opt_single_transaction && start_transaction(sock, test(opt_master_data))) + if (opt_single_transaction && start_transaction(mysql, test(opt_master_data))) goto err; - if (opt_delete_master_logs && do_reset_master(sock)) + if (opt_delete_master_logs && do_reset_master(mysql)) goto err; if (opt_lock_all_tables || opt_master_data) { - if (flush_logs && mysql_refresh(sock, REFRESH_LOG)) + if (flush_logs && mysql_refresh(mysql, REFRESH_LOG)) goto err; flush_logs= 0; /* not anymore; that would not be sensible */ } - if (opt_master_data && do_show_master_status(sock)) + if (opt_master_data && do_show_master_status(mysql)) goto err; - if (opt_single_transaction && do_unlock_tables(sock)) /* unlock but no commit! */ + if (opt_single_transaction && do_unlock_tables(mysql)) /* unlock but no commit! */ goto err; if (opt_alldbs) From c2e2ebb1a707af4b17e570d6d0a27e815f3df9f7 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 24 Jul 2006 12:43:35 +0200 Subject: [PATCH 19/44] Remove double printout of mysqldump in error message --- client/mysqldump.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index 7c6d56cb018..9eecc23abd9 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -870,9 +870,8 @@ static int mysql_query_with_error_report(MYSQL *mysql_con, MYSQL_RES **res, if (mysql_query(mysql_con, query) || (res && !((*res)= mysql_store_result(mysql_con)))) { - my_printf_error(0, "%s: Couldn't execute '%s': %s (%d)", - MYF(0), my_progname, query, - mysql_error(mysql_con), mysql_errno(mysql_con)); + my_printf_error(0, "Couldn't execute '%s': %s (%d)", MYF(0), + query, mysql_error(mysql_con), mysql_errno(mysql_con)); return 1; } return 0; From 9f78d779e316c9afab20a64e17808eba5cb31789 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 24 Jul 2006 12:48:02 +0200 Subject: [PATCH 20/44] Don't close connection to mysql before 'safe_exit', that is done in 'safe_exit' if it decides to exit. --- client/mysqldump.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index 9eecc23abd9..ad350075534 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -959,7 +959,6 @@ static int dbConnect(char *host, char *user,char *passwd) compatible_mode_normal_str); if (mysql_query_with_error_report(mysql, 0, buff)) { - mysql_close(mysql); safe_exit(EX_MYSQLERR); return 1; } @@ -972,7 +971,6 @@ static int dbConnect(char *host, char *user,char *passwd) my_snprintf(buff, sizeof(buff), "/*!40103 SET TIME_ZONE='+00:00' */"); if (mysql_query_with_error_report(mysql, 0, buff)) { - mysql_close(mysql); safe_exit(EX_MYSQLERR); return 1; } From c84cdbf40b50549b0e6b164d034e589eae625874 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 24 Jul 2006 13:10:24 +0200 Subject: [PATCH 21/44] Bug#21215 mysqldump creating incomplete backups without warning - Add call to 'safe_exit' function when db query fails. --- client/mysqldump.c | 1 + mysql-test/r/mysqldump.result | 16 ++++++++++++++ mysql-test/t/mysqldump.test | 40 +++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) diff --git a/client/mysqldump.c b/client/mysqldump.c index ad350075534..2f4a5b46cd4 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -872,6 +872,7 @@ static int mysql_query_with_error_report(MYSQL *mysql_con, MYSQL_RES **res, { my_printf_error(0, "Couldn't execute '%s': %s (%d)", MYF(0), query, mysql_error(mysql_con), mysql_errno(mysql_con)); + safe_exit(EX_MYSQLERR); return 1; } return 0; diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index 118079906bf..49caa096cb8 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -2867,3 +2867,19 @@ drop view nasishnasifu; drop database mysqldump_views; drop table mysqldump_tables.basetable; drop database mysqldump_tables; +use test; +create user mysqltest_1; +create table t1(a int, b varchar(34)); +mysqldump: Couldn't execute 'FLUSH TABLES': Access denied; you need the RELOAD privilege for this operation (1227) +mysqldump: Couldn't execute 'FLUSH TABLES': Access denied; you need the RELOAD privilege for this operation (1227) +grant RELOAD on *.* to mysqltest_1@localhost; +mysqldump: Couldn't execute 'SHOW MASTER STATUS': Access denied; you need the SUPER,REPLICATION CLIENT privilege for this operation (1227) +mysqldump: Couldn't execute 'SHOW MASTER STATUS': Access denied; you need the SUPER,REPLICATION CLIENT privilege for this operation (1227) +grant REPLICATION CLIENT on *.* to mysqltest_1@localhost; +CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000003', MASTER_LOG_POS=3784; +CREATE TABLE `t1` ( + `a` int(11) default NULL, + `b` varchar(34) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1; +drop table t1; +drop user mysqltest_1; diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 858d8910781..e5e83a46a2e 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -1228,3 +1228,43 @@ drop view nasishnasifu; drop database mysqldump_views; drop table mysqldump_tables.basetable; drop database mysqldump_tables; + +# +# Bug#21215 mysqldump creating incomplete backups without warning +# +use test; + +# Create user without sufficient privs to perform the requested operation +create user mysqltest_1; +create table t1(a int, b varchar(34)); + +# Execute mysqldump, will fail on FLUSH TABLES +--error 2 +--exec $MYSQL_DUMP --compact --master-data -u mysqltest_1 test 2>&1 + +# Execute mysqldump, will fail on FLUSH TABLES +# use --force, should no affect behaviour +--error 2 +--exec $MYSQL_DUMP --compact --force --master-data -u mysqltest_1 test 2>&1 + +# Add RELOAD grants +grant RELOAD on *.* to mysqltest_1@localhost; + +# Execute mysqldump, will fail on SHOW MASTER STATUS +--error 2 +--exec $MYSQL_DUMP --compact --master-data -u mysqltest_1 test 2>&1 + +# Execute mysqldump, will fail on SHOW MASTER STATUS. +# use --force, should not alter behaviour +--error 2 +--exec $MYSQL_DUMP --compact --force --master-data -u mysqltest_1 test 2>&1 + +# Add REPLICATION CLIENT grants +grant REPLICATION CLIENT on *.* to mysqltest_1@localhost; + +# Execute mysqldump, should now succeed +--exec $MYSQL_DUMP --compact --master-data -u mysqltest_1 test 2>&1 + +# Clean up +drop table t1; +drop user mysqltest_1; From bbf6c985c8979d72ccb314768deb2ed2e71dfa14 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 24 Jul 2006 18:05:00 +0200 Subject: [PATCH 22/44] Bug#20145 perror segfault when call it with error nr - Add test case(execute perror) - Check if strerror has returned NULL and set msg to "Unknown Error" in that case - Thanks to Steven Xie for pointing out how to fix. --- extra/perror.c | 5 ++++- mysql-test/mysql-test-run.pl | 8 ++++++++ mysql-test/r/have_perror.require | 2 ++ mysql-test/r/perror.result | 3 +++ mysql-test/t/perror.test | 11 +++++++++++ 5 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 mysql-test/r/have_perror.require create mode 100644 mysql-test/r/perror.result create mode 100644 mysql-test/t/perror.test diff --git a/extra/perror.c b/extra/perror.c index 82311c1b2c9..531d30dae86 100644 --- a/extra/perror.c +++ b/extra/perror.c @@ -218,8 +218,11 @@ int main(int argc,char *argv[]) On some system, like NETWARE, strerror(unknown_error) returns a string 'Unknown Error'. To avoid printing it we try to find the error string by asking for an impossible big error message. + + On Solaris 2.8 it might return NULL */ - msg= strerror(10000); + if ((msg= strerror(10000)) == NULL) + msg= "Unknown Error"; /* Allocate a buffer for unknown_error since strerror always returns diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 91a9a758d1d..95ce5dc1bb2 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -187,6 +187,7 @@ our $exe_mysqltest; our $exe_slave_mysqld; our $exe_im; our $exe_my_print_defaults; +our $exe_perror; our $lib_udf_example; our $exe_libtool; @@ -1048,6 +1049,8 @@ sub executable_setup () { $path_charsetsdir= mtr_path_exists("$glob_basedir/share/charsets"); $exe_my_print_defaults= mtr_exe_exists("$path_client_bindir/my_print_defaults"); + $exe_perror= + mtr_exe_exists("$path_client_bindir/perror"); } else { @@ -1060,6 +1063,8 @@ sub executable_setup () { "$glob_basedir/server-tools/instance-manager/mysqlmanager"); $exe_my_print_defaults= mtr_exe_exists("$glob_basedir/extra/my_print_defaults"); + $exe_perror= + mtr_exe_exists("$glob_basedir/extra/perror"); } if ( $glob_use_embedded_server ) @@ -1107,6 +1112,8 @@ sub executable_setup () { "$glob_basedir/scripts/mysql_fix_privilege_tables"); $exe_my_print_defaults= mtr_exe_exists("$path_client_bindir/my_print_defaults"); + $exe_perror= + mtr_exe_exists("$path_client_bindir/perror"); $path_language= mtr_path_exists("$glob_basedir/share/mysql/english/", "$glob_basedir/share/english/"); @@ -3103,6 +3110,7 @@ sub run_mysqltest ($) { $ENV{'MYSQL_MY_PRINT_DEFAULTS'}= $exe_my_print_defaults; $ENV{'UDF_EXAMPLE_LIB'}= ($lib_udf_example ? basename($lib_udf_example) : ""); + $ENV{'MY_PERROR'}= $exe_perror; $ENV{'NDB_MGM'}= $exe_ndb_mgm; $ENV{'NDB_BACKUP_DIR'}= $path_ndb_data_dir; diff --git a/mysql-test/r/have_perror.require b/mysql-test/r/have_perror.require new file mode 100644 index 00000000000..260687c87f0 --- /dev/null +++ b/mysql-test/r/have_perror.require @@ -0,0 +1,2 @@ +have_perror +1 diff --git a/mysql-test/r/perror.result b/mysql-test/r/perror.result new file mode 100644 index 00000000000..6539955bba6 --- /dev/null +++ b/mysql-test/r/perror.result @@ -0,0 +1,3 @@ +MySQL error code 150: Foreign key constraint is incorrectly formed +Is a named type file +Didn't find key on read or update diff --git a/mysql-test/t/perror.test b/mysql-test/t/perror.test new file mode 100644 index 00000000000..81847f85c96 --- /dev/null +++ b/mysql-test/t/perror.test @@ -0,0 +1,11 @@ +# +# Check if the variable MY_PERROR is set +# +--require r/have_perror.require +disable_query_log; +eval select LENGTH("$MY_PERROR") > 0 as "have_perror"; +enable_query_log; + +--exec $MY_PERROR 150 +--exec $MY_PERROR --silent 120 + From 8f21e375a2b1430726315702f2d856be381d9264 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 24 Jul 2006 19:01:54 +0200 Subject: [PATCH 23/44] Bug #19265 describe command does not work from mysql prompt - Add test case --- mysql-test/r/mysql.result | 10 ++++++++++ mysql-test/t/mysql.test | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/mysql-test/r/mysql.result b/mysql-test/r/mysql.result index 4b7084e813c..164ee4d50ac 100644 --- a/mysql-test/r/mysql.result +++ b/mysql-test/r/mysql.result @@ -104,4 +104,14 @@ c_cp932 | 2 | NULL | | 3 | | +------+------+ +create table t1(a int, b varchar(255), c int); +Field Type Null Key Default Extra +a int(11) YES NULL +b varchar(255) YES NULL +c int(11) YES NULL +Field Type Null Key Default Extra +a int(11) YES NULL +b varchar(255) YES NULL +c int(11) YES NULL +drop table t1; End of 5.0 tests diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test index ac4c323f51e..cfc47a5fbd5 100644 --- a/mysql-test/t/mysql.test +++ b/mysql-test/t/mysql.test @@ -77,6 +77,15 @@ drop table t1; # --exec $MYSQL -t test -e "create table b19564 (i int, s1 char(1)); insert into b19564 values (1, 'x'); insert into b19564 values (2, NULL); insert into b19564 values (3, ' '); select * from b19564 order by i; drop table b19564;" +# +# Bug#19265 describe command does not work from mysql prompt +# + +create table t1(a int, b varchar(255), c int); +--exec $MYSQL test -e "desc t1" +--exec $MYSQL test -e "desc t1\g" +drop table t1; + --echo End of 5.0 tests From 8489a8db0700b424b1c528b86efd7a87bdc549ff Mon Sep 17 00:00:00 2001 From: "jimw@rama.(none)" <> Date: Mon, 24 Jul 2006 13:31:20 -0700 Subject: [PATCH 24/44] Bug #16502: mysqlcheck gets confused with views Make mysqlcheck skip over views when processing all of the tables in a database. --- client/mysqlcheck.c | 16 ++++++++++++---- mysql-test/r/mysqlcheck.result | 7 +++++++ mysql-test/t/mysqlcheck.test | 14 ++++++++++++++ 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 804fa14956f..5d87a4fd23c 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -458,7 +458,7 @@ static int process_all_tables_in_db(char *database) LINT_INIT(res); if (use_db(database)) return 1; - if (mysql_query(sock, "SHOW TABLES") || + if (mysql_query(sock, "SHOW TABLE STATUS") || !((res= mysql_store_result(sock)))) return 1; @@ -484,8 +484,12 @@ static int process_all_tables_in_db(char *database) } for (end = tables + 1; (row = mysql_fetch_row(res)) ;) { - end= fix_table_name(end, row[0]); - *end++= ','; + /* Skip tables with an engine of NULL (probably a view). */ + if (row[1]) + { + end= fix_table_name(end, row[0]); + *end++= ','; + } } *--end = 0; if (tot_length) @@ -495,7 +499,11 @@ static int process_all_tables_in_db(char *database) else { while ((row = mysql_fetch_row(res))) - handle_request_for_tables(row[0], strlen(row[0])); + /* Skip tables with an engine of NULL (probably a view). */ + if (row[1]) + { + handle_request_for_tables(row[0], strlen(row[0])); + } } mysql_free_result(res); return 0; diff --git a/mysql-test/r/mysqlcheck.result b/mysql-test/r/mysqlcheck.result index 8c98e18aa9b..df0835b830c 100644 --- a/mysql-test/r/mysqlcheck.result +++ b/mysql-test/r/mysqlcheck.result @@ -32,3 +32,10 @@ mysql.time_zone_name OK mysql.time_zone_transition OK mysql.time_zone_transition_type OK mysql.user OK +create table t1 (a int); +create view v1 as select * from t1; +test.t1 OK +test.t1 OK +drop view v1; +drop table t1; +End of 5.0 tests diff --git a/mysql-test/t/mysqlcheck.test b/mysql-test/t/mysqlcheck.test index bc88be001ab..338e16363ea 100644 --- a/mysql-test/t/mysqlcheck.test +++ b/mysql-test/t/mysqlcheck.test @@ -9,3 +9,17 @@ --replace_result 'Table is already up to date' OK --exec $MYSQL_CHECK --analyze --optimize --databases test information_schema mysql --exec $MYSQL_CHECK --analyze --optimize information_schema schemata + +# +# Bug #16502: mysqlcheck tries to check views +# +create table t1 (a int); +create view v1 as select * from t1; +--replace_result 'Table is already up to date' OK +--exec $MYSQL_CHECK --analyze --optimize --databases test +--replace_result 'Table is already up to date' OK +--exec $MYSQL_CHECK --all-in-1 --analyze --optimize --databases test +drop view v1; +drop table t1; + +--echo End of 5.0 tests From e1b1ba54c600fddbe27aa216fd5bbd18b23789be Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Wed, 26 Jul 2006 11:08:15 +0200 Subject: [PATCH 25/44] Bug#21218 Test "mysqlbinlog" fails to execute another program on Windows - Modify test case to workaround the test tool problem - (Null merge into 5.0) --- mysql-test/t/mysqlbinlog.test | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test index 0e4d16efb64..a54d5e56d72 100644 --- a/mysql-test/t/mysqlbinlog.test +++ b/mysql-test/t/mysqlbinlog.test @@ -107,7 +107,8 @@ create table t4 (f text character set cp932); --exec $MYSQL --default-character-set=cp932 test -e "insert into t4 values(_cp932'ƒ\');" flush logs; rename table t3 to t03, t4 to t04; ---exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000004 | $MYSQL --default-character-set=utf8 +--exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000004 > $MYSQL_TEST_DIR/var/tmp/bug16217.sql +--exec $MYSQL --default-character-set=utf8 < $MYSQL_TEST_DIR/var/tmp/bug16217.sql # original and recovered data must be equal select HEX(f) from t03; select HEX(f) from t3; @@ -123,7 +124,8 @@ flush logs; # resulted binlog, parly consisting of multi-byte utf8 chars, # must be digestable for both client and server. In 4.1 the client # should use default-character-set same as the server. ---exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000006 | $MYSQL +--exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000006 > $MYSQL_TEST_DIR/var/tmp/bug14157.sql +--exec $MYSQL < $MYSQL_TEST_DIR/var/tmp/bug14157.sql select * from t5 /* must be (1),(1) */; # clean up From 2bb5f5662f9810112e3d3db3f515f49a8b94102e Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Wed, 26 Jul 2006 14:02:24 +0200 Subject: [PATCH 26/44] Bug#19890 mysqltest: "query" command is broken - Allow "query" to be used as a prefix for focing a command to be sent to server - Add testcases --- client/mysqltest.c | 8 ++++++++ mysql-test/r/mysqltest.result | 6 ++++++ mysql-test/t/mysqltest.test | 15 +++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/client/mysqltest.c b/client/mysqltest.c index 2fc09fbc3d2..a1bc82593c0 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -4757,6 +4757,14 @@ int main(int argc, char **argv) q->require_file=require_file; save_file[0]=0; } + /* + To force something being sent as a query to the mysqld one can + use the prefix "query". Remove "query" from string before executing + */ + if (strncmp(q->query, "query ", 6) == 0) + { + q->query= q->first_argument; + } run_query(&cur_con->mysql, q, flags); query_executed= 1; q->last_argument= q->end; diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result index 8055a33ec7d..d9ca863b6bc 100644 --- a/mysql-test/r/mysqltest.result +++ b/mysql-test/r/mysqltest.result @@ -441,3 +441,9 @@ select-me 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 'insertz error query' at line 1 drop table t1; drop table t1; +sleep; +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 'sleep' at line 1 +sleep; +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 'sleep' at line 1 +; +ERROR 42000: Query was empty diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index 3968eb519e1..6a0b805f43b 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -1125,3 +1125,18 @@ drop table t1; drop table t1; +# +# Bug#19890 mysqltest: "query" command is broken +# + +# It should be possible to use the command "query" to force mysqltest to +# send the command to the server although it's a builtin mysqltest command. +--error 1064 +query sleep; + +--error 1064 +--query sleep + +# Just an empty query command +--error 1065 +query ; From 9e000766b7c22c2de7ff58a6c1ae7bb3abb1709c Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Wed, 26 Jul 2006 14:09:20 +0200 Subject: [PATCH 27/44] Bug#16561 Unknown ERROR msg "ERROR 1186 (HY000): Binlog closed" by perror - Since error 1186 is not found among NDB error codes, the message retuned should indicate that. --- extra/perror.c | 27 ++++++++++++++------------ mysql-test/t/perror.test | 11 +++++++++++ ndb/src/kernel/error/ndbd_exit_codes.c | 2 +- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/extra/perror.c b/extra/perror.c index 531d30dae86..b26e516a101 100644 --- a/extra/perror.c +++ b/extra/perror.c @@ -261,7 +261,7 @@ int main(int argc,char *argv[]) found= 1; msg= 0; } - else + else #endif msg = strerror(code); @@ -281,20 +281,23 @@ int main(int argc,char *argv[]) else puts(msg); } - if (!(msg=get_ha_error_msg(code))) + + if (!found) { - if (!found) - { + /* Error message still not found, look in handler error codes */ + if (!(msg=get_ha_error_msg(code))) + { fprintf(stderr,"Illegal error code: %d\n",code); error=1; - } - } - else - { - if (verbose) - printf("MySQL error code %3d: %s\n",code,msg); - else - puts(msg); + } + else + { + found= 1; + if (verbose) + printf("MySQL error code %3d: %s\n",code,msg); + else + puts(msg); + } } } } diff --git a/mysql-test/t/perror.test b/mysql-test/t/perror.test index 81847f85c96..63f2301f18e 100644 --- a/mysql-test/t/perror.test +++ b/mysql-test/t/perror.test @@ -9,3 +9,14 @@ enable_query_log; --exec $MY_PERROR 150 --exec $MY_PERROR --silent 120 +# +# Bug#16561 Unknown ERROR msg "ERROR 1186 (HY000): Binlog closed" by perror +# + +# As long there is no error code 1186 defined by NDB +# we should get a message "Illegal ndb error code: 1186" +--error 1 +--exec $MY_PERROR --ndb 1186 + +# As there is an error code defined for 1186, expect error +--exec $MY_PERROR 1186 diff --git a/ndb/src/kernel/error/ndbd_exit_codes.c b/ndb/src/kernel/error/ndbd_exit_codes.c index 07b276346a0..cb3272b38a9 100644 --- a/ndb/src/kernel/error/ndbd_exit_codes.c +++ b/ndb/src/kernel/error/ndbd_exit_codes.c @@ -247,7 +247,7 @@ int ndbd_exit_string(int err_no, char *str, unsigned int size) ndbd_exit_classification cl; ndbd_exit_status st; const char *msg = ndbd_exit_message(err_no, &cl); - if (msg[0] != '\0') + if (msg[0] != '\0' && cl != XUE) { const char *cl_msg = ndbd_exit_classification_message(cl, &st); const char *st_msg = ndbd_exit_status_message(st); From 7e8cfe3830f6a0ffa1993c1ac79b8507589dfae5 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Wed, 26 Jul 2006 14:21:40 +0200 Subject: [PATCH 28/44] Update test result for perror --- mysql-test/r/perror.result | 5 ++--- mysql-test/t/perror.test | 9 +++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/perror.result b/mysql-test/r/perror.result index 6539955bba6..a26bdb0e068 100644 --- a/mysql-test/r/perror.result +++ b/mysql-test/r/perror.result @@ -1,3 +1,2 @@ -MySQL error code 150: Foreign key constraint is incorrectly formed -Is a named type file -Didn't find key on read or update +Illegal ndb error code: 1186 +Illegal error code: 1186 diff --git a/mysql-test/t/perror.test b/mysql-test/t/perror.test index 63f2301f18e..e6c9546161b 100644 --- a/mysql-test/t/perror.test +++ b/mysql-test/t/perror.test @@ -6,8 +6,8 @@ disable_query_log; eval select LENGTH("$MY_PERROR") > 0 as "have_perror"; enable_query_log; ---exec $MY_PERROR 150 ---exec $MY_PERROR --silent 120 +--exec $MY_PERROR 150 > /dev/null +--exec $MY_PERROR --silent 120 > /dev/null # # Bug#16561 Unknown ERROR msg "ERROR 1186 (HY000): Binlog closed" by perror @@ -16,7 +16,8 @@ enable_query_log; # As long there is no error code 1186 defined by NDB # we should get a message "Illegal ndb error code: 1186" --error 1 ---exec $MY_PERROR --ndb 1186 +--exec $MY_PERROR --ndb 1186 2>&1 # As there is an error code defined for 1186, expect error ---exec $MY_PERROR 1186 +--error 1 +--exec $MY_PERROR 1186 2>&1 From b3bbb3789e2bcac169b9a20ca33f15c2d341a734 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Thu, 27 Jul 2006 12:28:49 +0200 Subject: [PATCH 29/44] Bug#21042 mysql client segfaults on importing a mysqldump export - Use strxnmov to protect the "buff" variable from overrun --- client/mysql.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/mysql.cc b/client/mysql.cc index 22534324aca..5c0b5ce04fe 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2858,7 +2858,7 @@ com_connect(String *buffer, char *line) bzero(buff, sizeof(buff)); if (buffer) { - strmov(buff, line); + strxnmov(buff, sizeof(buff), line, NullS); tmp= get_arg(buff, 0); if (tmp && *tmp) { From 61a3a8e95cef229113fab2f2381338315e8b4a2a Mon Sep 17 00:00:00 2001 From: "igreenhoe/greenman@anubis.greendragongames.com" <> Date: Fri, 28 Jul 2006 20:51:17 -0700 Subject: [PATCH 30/44] Fix for bug #16226 (timestamp_diff truncation issue when requesting difference between timestamp in values of months and quarters.) Problem: when requesting timestamp diff in months or quarters, it would only examine the date (and not the time) for the comparison. Solution: increased precision of comparison. --- mysql-test/r/func_time.result | 72 +++++++++++++++++++++++++++++++++++ mysql-test/t/func_time.test | 31 +++++++++++++++ sql/item_timefunc.cc | 15 ++++++++ 3 files changed, 118 insertions(+) diff --git a/mysql-test/r/func_time.result b/mysql-test/r/func_time.result index 66fe355ffce..699f0c9ec4b 100644 --- a/mysql-test/r/func_time.result +++ b/mysql-test/r/func_time.result @@ -667,6 +667,78 @@ timestampdiff(SQL_TSI_DAY, '1996-02-01', '1996-03-01') as a3, timestampdiff(SQL_TSI_DAY, '2000-02-01', '2000-03-01') as a4; a1 a2 a3 a4 28 28 29 29 +SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:27'); +TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:27') +0 +SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:28'); +TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:28') +1 +SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:29'); +TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:29') +1 +SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:27'); +TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:27') +1 +SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:28'); +TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:28') +2 +SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:29'); +TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:29') +2 +SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:27'); +TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:27') +0 +SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:28'); +TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:28') +1 +SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:29'); +TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:29') +1 +SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:27'); +TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:27') +1 +SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:28'); +TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:28') +2 +SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:29'); +TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:29') +2 +SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:27'); +TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:27') +0 +SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:28'); +TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:28') +1 +SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:29'); +TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:29') +1 +SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:27'); +TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:27') +1 +SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:28'); +TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:28') +2 +SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:29'); +TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:29') +2 +SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:27'); +TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:27') +0 +SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:28'); +TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:28') +1 +SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:29'); +TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:29') +1 +SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:27'); +TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:27') +1 +SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:28'); +TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:28') +2 +SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:29'); +TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:29') +2 select date_add(time,INTERVAL 1 SECOND) from t1; date_add(time,INTERVAL 1 SECOND) NULL diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index 188e5667009..83b877e725c 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -318,6 +318,37 @@ select timestampdiff(SQL_TSI_DAY, '1986-02-01', '1986-03-01') as a1, timestampdiff(SQL_TSI_DAY, '1996-02-01', '1996-03-01') as a3, timestampdiff(SQL_TSI_DAY, '2000-02-01', '2000-03-01') as a4; +# bug 16226 +SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:27'); +SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:28'); +SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-11 14:30:29'); +SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:27'); +SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:28'); +SELECT TIMESTAMPDIFF(day,'2006-01-10 14:30:28','2006-01-12 14:30:29'); + +SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:27'); +SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:28'); +SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-17 14:30:29'); +SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:27'); +SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:28'); +SELECT TIMESTAMPDIFF(week,'2006-01-10 14:30:28','2006-01-24 14:30:29'); + +SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:27'); +SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:28'); +SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-02-10 14:30:29'); +SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:27'); +SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:28'); +SELECT TIMESTAMPDIFF(month,'2006-01-10 14:30:28','2006-03-10 14:30:29'); + +SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:27'); +SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:28'); +SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2007-01-10 14:30:29'); +SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:27'); +SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:28'); +SELECT TIMESTAMPDIFF(year,'2006-01-10 14:30:28','2008-01-10 14:30:29'); + +# end of bug + select date_add(time,INTERVAL 1 SECOND) from t1; drop table t1; diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 9e1962835c8..835be6554bc 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -2877,6 +2877,8 @@ longlong Item_func_timestamp_diff::val_int() { uint year_beg, year_end, month_beg, month_end, day_beg, day_end; uint years= 0; + uint second_beg, second_end, microsecond_beg, microsecond_end; + if (neg == -1) { year_beg= ltime2.year; @@ -2885,6 +2887,10 @@ longlong Item_func_timestamp_diff::val_int() month_end= ltime1.month; day_beg= ltime2.day; day_end= ltime1.day; + second_beg= ltime2.hour * 3600 + ltime2.minute * 60 + ltime2.second; + second_end= ltime1.hour * 3600 + ltime1.minute * 60 + ltime1.second; + microsecond_beg= ltime2.second_part; + microsecond_end= ltime1.second_part; } else { @@ -2894,6 +2900,10 @@ longlong Item_func_timestamp_diff::val_int() month_end= ltime2.month; day_beg= ltime1.day; day_end= ltime2.day; + second_beg= ltime1.hour * 3600 + ltime1.minute * 60 + ltime1.second; + second_end= ltime2.hour * 3600 + ltime2.minute * 60 + ltime2.second; + microsecond_beg= ltime1.second_part; + microsecond_end= ltime2.second_part; } /* calc years */ @@ -2907,8 +2917,13 @@ longlong Item_func_timestamp_diff::val_int() months+= 12 - (month_beg - month_end); else months+= (month_end - month_beg); + if (day_end < day_beg) months-= 1; + else if ((day_end == day_beg) && + ((second_end < second_beg) || + (second_end == second_beg && microsecond_end < microsecond_beg))) + months-= 1; } switch (int_type) { From a5112188e2a7dd85ff8bae01133e044f5b108fa0 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 31 Jul 2006 12:47:56 +0200 Subject: [PATCH 31/44] Fix lowercase_fs_off problem on windows. This test should not be run if lower_case_filesystem=OFF. By default lowercase_table_names are 1 on windows, and that makes the initialization of lower_case_filesystem variable to be skipped. Add an else bracnh that does the initialization. --- sql/mysqld.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 429bdee17d6..b5b6ac1449f 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2770,6 +2770,11 @@ You should consider changing lower_case_table_names to 1 or 2", mysql_real_data_home); lower_case_table_names= 0; } + else + { + lower_case_file_system= + (test_if_case_insensitive(mysql_real_data_home) == 1); + } /* Reset table_alias_charset, now that lower_case_table_names is set. */ table_alias_charset= (lower_case_table_names ? From 823ead0775f70253a7a85d38fc2812ae4ba920bd Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 31 Jul 2006 13:11:21 +0200 Subject: [PATCH 32/44] perror returns 2 if it does not understand the option --ndb Move that perror test to ndb_basic so it's only run when there is support for --ndb --- mysql-test/r/ndb_basic.result | 1 + mysql-test/r/perror.result | 1 - mysql-test/t/ndb_basic.test | 10 ++++++++++ mysql-test/t/perror.test | 5 ----- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/ndb_basic.result b/mysql-test/r/ndb_basic.result index 09c4f9b29f9..d2111db24fe 100644 --- a/mysql-test/r/ndb_basic.result +++ b/mysql-test/r/ndb_basic.result @@ -748,3 +748,4 @@ f1 f2 f3 111111 aaaaaa 1 222222 bbbbbb 2 drop table t1; +Illegal ndb error code: 1186 diff --git a/mysql-test/r/perror.result b/mysql-test/r/perror.result index a26bdb0e068..05639197391 100644 --- a/mysql-test/r/perror.result +++ b/mysql-test/r/perror.result @@ -1,2 +1 @@ -Illegal ndb error code: 1186 Illegal error code: 1186 diff --git a/mysql-test/t/ndb_basic.test b/mysql-test/t/ndb_basic.test index 5d79d5eb9f9..6c1a4e44f4b 100644 --- a/mysql-test/t/ndb_basic.test +++ b/mysql-test/t/ndb_basic.test @@ -700,3 +700,13 @@ select * from t1 order by f1; select * from t1 order by f2; select * from t1 order by f3; drop table t1; + +# +# Bug#16561 Unknown ERROR msg "ERROR 1186 (HY000): Binlog closed" by perror +# + +# As long there is no error code 1186 defined by NDB +# we should get a message "Illegal ndb error code: 1186" +--error 1 +--exec $MY_PERROR --ndb 1186 2>&1 + diff --git a/mysql-test/t/perror.test b/mysql-test/t/perror.test index e6c9546161b..21297fccd95 100644 --- a/mysql-test/t/perror.test +++ b/mysql-test/t/perror.test @@ -13,11 +13,6 @@ enable_query_log; # Bug#16561 Unknown ERROR msg "ERROR 1186 (HY000): Binlog closed" by perror # -# As long there is no error code 1186 defined by NDB -# we should get a message "Illegal ndb error code: 1186" ---error 1 ---exec $MY_PERROR --ndb 1186 2>&1 - # As there is an error code defined for 1186, expect error --error 1 --exec $MY_PERROR 1186 2>&1 From 2461e48698b6d2ce223597cd1ddaf0ee83a8ebd6 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 31 Jul 2006 14:22:32 +0200 Subject: [PATCH 33/44] Bug#21042 mysql client segfaults on importing a mysqldump export - Use strmake, that will both protect the buffer and make sure it's terminated by a zero - Add test case --- client/mysql.cc | 2 +- mysql-test/r/mysql.result | 1 + mysql-test/t/mysql.test | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/client/mysql.cc b/client/mysql.cc index 5c0b5ce04fe..25faf91b25d 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -2858,7 +2858,7 @@ com_connect(String *buffer, char *line) bzero(buff, sizeof(buff)); if (buffer) { - strxnmov(buff, sizeof(buff), line, NullS); + strmake(buff, line, sizeof(buff)); tmp= get_arg(buff, 0); if (tmp && *tmp) { diff --git a/mysql-test/r/mysql.result b/mysql-test/r/mysql.result index 164ee4d50ac..55ed2a4868b 100644 --- a/mysql-test/r/mysql.result +++ b/mysql-test/r/mysql.result @@ -114,4 +114,5 @@ a int(11) YES NULL b varchar(255) YES NULL c int(11) YES NULL drop table t1; +ERROR 1049 (42000) at line 1: Unknown database 'verylongdatabasenamethatshouldblowthe256byteslongbufferincom_con' End of 5.0 tests diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test index cfc47a5fbd5..10c07c931ab 100644 --- a/mysql-test/t/mysql.test +++ b/mysql-test/t/mysql.test @@ -86,6 +86,12 @@ create table t1(a int, b varchar(255), c int); --exec $MYSQL test -e "desc t1\g" drop table t1; +# +# Bug#21042 mysql client segfaults on importing a mysqldump export +# +--error 1 +--exec $MYSQL test -e "connect verylongdatabasenamethatshouldblowthe256byteslongbufferincom_connectfunctionxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxendcccccccdxxxxxxxxxxxxxxxxxkskskskskkskskskskskskskskskskkskskskskkskskskskskskskskskend" 2>&1 + --echo End of 5.0 tests From e9b624df99bb59393216cd8fcc485419c3b1d883 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 1 Aug 2006 11:29:10 +0200 Subject: [PATCH 34/44] Change error code to test for "unknown error" with to 10000 --- mysql-test/r/perror.result | 2 +- mysql-test/t/perror.test | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/perror.result b/mysql-test/r/perror.result index 05639197391..4946523bc42 100644 --- a/mysql-test/r/perror.result +++ b/mysql-test/r/perror.result @@ -1 +1 @@ -Illegal error code: 1186 +Illegal error code: 10000 diff --git a/mysql-test/t/perror.test b/mysql-test/t/perror.test index 21297fccd95..a4b99d8aa22 100644 --- a/mysql-test/t/perror.test +++ b/mysql-test/t/perror.test @@ -13,6 +13,7 @@ enable_query_log; # Bug#16561 Unknown ERROR msg "ERROR 1186 (HY000): Binlog closed" by perror # -# As there is an error code defined for 1186, expect error +# Test with error code 10000 as it's a common "unknown error" +# As there is no error code defined for 10000, expect error --error 1 ---exec $MY_PERROR 1186 2>&1 +--exec $MY_PERROR 10000 2>&1 From 111513f09f581c9400956d27b3041714eb6ac130 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 1 Aug 2006 11:35:37 +0200 Subject: [PATCH 35/44] Bug#21367 IM tests do not recognize "win2003-amd64" as Windows - Disable Instance manager on Windows --- mysql-test/mysql-test-run.pl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 95ce5dc1bb2..d8ab940fdca 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -812,6 +812,13 @@ sub command_line_setup () { $opt_with_ndbcluster= 0; } + # Check IM arguments + if ( $glob_win32 ) + { + mtr_report("Disable Instance manager - not supported on Windows"); + opt_skip_im= 1; + } + # Check valgrind arguments if ( $opt_valgrind or $opt_valgrind_path or defined $opt_valgrind_options) { From c1f0f4dc587b1ce8a1ee876de8e0ac70511c20f9 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 1 Aug 2006 15:21:09 +0200 Subject: [PATCH 36/44] Add missing $ --- 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 d8ab940fdca..f029924e292 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -816,7 +816,7 @@ sub command_line_setup () { if ( $glob_win32 ) { mtr_report("Disable Instance manager - not supported on Windows"); - opt_skip_im= 1; + $opt_skip_im= 1; } # Check valgrind arguments From 116feb009ea20afd11be5395ad3583320fe20209 Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Tue, 1 Aug 2006 20:20:46 +0200 Subject: [PATCH 37/44] Import latest version of yaSSL --- extra/yassl/COPYING | 340 +++++++++++++++++++++++++++ extra/yassl/include/yassl_imp.hpp | 1 + extra/yassl/src/yassl_imp.cpp | 6 +- extra/yassl/src/yassl_int.cpp | 3 + extra/yassl/taocrypt/include/asn.hpp | 8 +- extra/yassl/taocrypt/src/asn.cpp | 2 +- 6 files changed, 354 insertions(+), 6 deletions(-) create mode 100644 extra/yassl/COPYING diff --git a/extra/yassl/COPYING b/extra/yassl/COPYING new file mode 100644 index 00000000000..d60c31a97a5 --- /dev/null +++ b/extra/yassl/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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 + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/extra/yassl/include/yassl_imp.hpp b/extra/yassl/include/yassl_imp.hpp index 838aace72c8..6e475c23db8 100644 --- a/extra/yassl/include/yassl_imp.hpp +++ b/extra/yassl/include/yassl_imp.hpp @@ -626,6 +626,7 @@ struct Connection { bool send_server_key_; // server key exchange? bool master_clean_; // master secret clean? bool TLS_; // TLSv1 or greater + bool sessionID_Set_; // do we have a session ProtocolVersion version_; RandomPool& random_; diff --git a/extra/yassl/src/yassl_imp.cpp b/extra/yassl/src/yassl_imp.cpp index 310e8819c54..98f8035732e 100644 --- a/extra/yassl/src/yassl_imp.cpp +++ b/extra/yassl/src/yassl_imp.cpp @@ -1172,7 +1172,8 @@ input_buffer& operator>>(input_buffer& input, ServerHello& hello) // Session hello.id_len_ = input[AUTO]; - input.read(hello.session_id_, ID_LEN); + if (hello.id_len_) + input.read(hello.session_id_, hello.id_len_); // Suites hello.cipher_suite_[0] = input[AUTO]; @@ -1215,7 +1216,10 @@ void ServerHello::Process(input_buffer&, SSL& ssl) { ssl.set_pending(cipher_suite_[1]); ssl.set_random(random_, server_end); + if (id_len_) ssl.set_sessionID(session_id_); + else + ssl.useSecurity().use_connection().sessionID_Set_ = false; if (ssl.getSecurity().get_resuming()) if (memcmp(session_id_, ssl.getSecurity().get_resume().GetID(), diff --git a/extra/yassl/src/yassl_int.cpp b/extra/yassl/src/yassl_int.cpp index 831942aaf69..9b83f964348 100644 --- a/extra/yassl/src/yassl_int.cpp +++ b/extra/yassl/src/yassl_int.cpp @@ -709,6 +709,7 @@ void SSL::set_masterSecret(const opaque* sec) void SSL::set_sessionID(const opaque* sessionID) { memcpy(secure_.use_connection().sessionID_, sessionID, ID_LEN); + secure_.use_connection().sessionID_Set_ = true; } @@ -1423,8 +1424,10 @@ typedef Mutex::Lock Lock; void Sessions::add(const SSL& ssl) { + if (ssl.getSecurity().get_connection().sessionID_Set_) { Lock guard(mutex_); list_.push_back(NEW_YS SSL_SESSION(ssl, random_)); + } } diff --git a/extra/yassl/taocrypt/include/asn.hpp b/extra/yassl/taocrypt/include/asn.hpp index 90bc46a59fd..8bea2ae780b 100644 --- a/extra/yassl/taocrypt/include/asn.hpp +++ b/extra/yassl/taocrypt/include/asn.hpp @@ -103,7 +103,7 @@ enum Constants MAX_ALGO_SIZE = 9, MAX_DIGEST_SZ = 25, // SHA + enum(Bit or Octet) + length(4) DSA_SIG_SZ = 40, - NAME_MAX = 512 // max total of all included names + ASN_NAME_MAX = 512 // max total of all included names }; @@ -216,7 +216,7 @@ enum { SHA_SIZE = 20 }; // A Signing Authority class Signer { PublicKey key_; - char name_[NAME_MAX]; + char name_[ASN_NAME_MAX]; byte hash_[SHA_SIZE]; public: Signer(const byte* k, word32 kSz, const char* n, const byte* h); @@ -270,8 +270,8 @@ private: byte subjectHash_[SHA_SIZE]; // hash of all Names byte issuerHash_[SHA_SIZE]; // hash of all Names byte* signature_; - char issuer_[NAME_MAX]; // Names - char subject_[NAME_MAX]; // Names + char issuer_[ASN_NAME_MAX]; // Names + char subject_[ASN_NAME_MAX]; // Names char beforeDate_[MAX_DATE_SZ]; // valid before date char afterDate_[MAX_DATE_SZ]; // valid after date bool verify_; // Default to yes, but could be off diff --git a/extra/yassl/taocrypt/src/asn.cpp b/extra/yassl/taocrypt/src/asn.cpp index beb5490bb66..45fb1e60a0c 100644 --- a/extra/yassl/taocrypt/src/asn.cpp +++ b/extra/yassl/taocrypt/src/asn.cpp @@ -665,7 +665,7 @@ void CertDecoder::GetName(NameType nt) SHA sha; word32 length = GetSequence(); // length of all distinguished names - assert (length < NAME_MAX); + assert (length < ASN_NAME_MAX); length += source_.get_index(); char* ptr = (nt == ISSUER) ? issuer_ : subject_; From 502498ed7be9442a3229d4d76174978b191a960b Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Wed, 2 Aug 2006 08:46:58 +0200 Subject: [PATCH 38/44] Disable test case for for bug 21042 --- mysql-test/r/mysql.result | 1 - mysql-test/t/mysql.test | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/mysql.result b/mysql-test/r/mysql.result index 9e426b6df46..c133e4eb2cb 100644 --- a/mysql-test/r/mysql.result +++ b/mysql-test/r/mysql.result @@ -114,5 +114,4 @@ a int(11) YES NULL b varchar(255) YES NULL c int(11) YES NULL drop table t1; -ERROR 1049 (42000) at line 1: Unknown database 'verylongdatabasenamethatshouldblowthe256byteslongbufferincom_con' End of 5.0 tests diff --git a/mysql-test/t/mysql.test b/mysql-test/t/mysql.test index 9d412c43bb5..cf6f72570ff 100644 --- a/mysql-test/t/mysql.test +++ b/mysql-test/t/mysql.test @@ -86,11 +86,13 @@ create table t1(a int, b varchar(255), c int); --exec $MYSQL test -e "desc t1\g" drop table t1; +--disable_parsing # # Bug#21042 mysql client segfaults on importing a mysqldump export # --error 1 --exec $MYSQL test -e "connect verylongdatabasenamethatshouldblowthe256byteslongbufferincom_connectfunctionxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxkxendcccccccdxxxxxxxxxxxxxxxxxkskskskskkskskskskskskskskskskkskskskskkskskskskskskskskskend" 2>&1 +--enable_parsing --echo End of 5.0 tests From 1572beadcdc9ece5bfbfa1512fe5224f228cd9c9 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Thu, 3 Aug 2006 09:48:42 +0200 Subject: [PATCH 39/44] Removing disabling of lowercase_fs_off --- mysql-test/t/disabled.def | 1 - 1 file changed, 1 deletion(-) diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index 7f9170847db..007847fab37 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -11,4 +11,3 @@ ############################################################################## ndb_load : Bug#17233 -lowercase_fs_off : Bug#21419 From 61c5d97309d6b8510dec8adea6eb4fc69076b072 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Thu, 3 Aug 2006 12:09:22 +0200 Subject: [PATCH 40/44] Remove double error printout in mysqldump --- client/mysqldump.c | 2 -- mysql-test/r/mysqldump.result | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index 1964e5dee85..3dce7fe8dc8 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -2994,8 +2994,6 @@ static int do_show_master_status(MYSQL *mysql_con) (opt_master_data == MYSQL_OPT_MASTER_DATA_COMMENTED_SQL) ? "-- " : ""; if (mysql_query_with_error_report(mysql_con, &master, "SHOW MASTER STATUS")) { - my_printf_error(0, "Error: Couldn't execute 'SHOW MASTER STATUS': %s", - MYF(0), mysql_error(mysql_con)); return 1; } else diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index 51744d6d603..090387d08e9 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -2884,7 +2884,7 @@ grant RELOAD on *.* to mysqltest_1@localhost; mysqldump: Couldn't execute 'SHOW MASTER STATUS': Access denied; you need the SUPER,REPLICATION CLIENT privilege for this operation (1227) mysqldump: Couldn't execute 'SHOW MASTER STATUS': Access denied; you need the SUPER,REPLICATION CLIENT privilege for this operation (1227) grant REPLICATION CLIENT on *.* to mysqltest_1@localhost; -CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000003', MASTER_LOG_POS=3784; +CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000003', MASTER_LOG_POS=9227; CREATE TABLE `t1` ( `a` int(11) default NULL, `b` varchar(34) default NULL From ac4e03a3158fab6c15711daaaa966a851adf0071 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Thu, 3 Aug 2006 15:48:28 +0200 Subject: [PATCH 41/44] Update result after merge, since the function Item::tmp_table_field_from_field_type() now takes mbmaxlen into account when calculating max_length of new field. --- mysql-test/r/union.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index b1da3d3d1de..42a3874db08 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -1318,7 +1318,7 @@ t2 CREATE TABLE `t2` ( `f5` timestamp NOT NULL default '0000-00-00 00:00:00', `f6` varchar(1) character set utf8 default NULL, `f7` text, - `f8` text character set utf8 + `f8` mediumtext character set utf8 ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1, t2; (select avg(1)) union (select avg(1)) union (select avg(1)) union From b9b2ef9cfbbd352eca2c1e214398ecd1726343ff Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Thu, 3 Aug 2006 16:47:24 +0200 Subject: [PATCH 42/44] Make test case for bug#21215repeateble by calling "reset master" --- mysql-test/r/mysqldump.result | 3 ++- mysql-test/t/mysqldump.test | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index 090387d08e9..4c684be0a3c 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -2878,13 +2878,14 @@ drop database mysqldump_dbb; use test; create user mysqltest_1; create table t1(a int, b varchar(34)); +reset master; mysqldump: Couldn't execute 'FLUSH TABLES': Access denied; you need the RELOAD privilege for this operation (1227) mysqldump: Couldn't execute 'FLUSH TABLES': Access denied; you need the RELOAD privilege for this operation (1227) grant RELOAD on *.* to mysqltest_1@localhost; mysqldump: Couldn't execute 'SHOW MASTER STATUS': Access denied; you need the SUPER,REPLICATION CLIENT privilege for this operation (1227) mysqldump: Couldn't execute 'SHOW MASTER STATUS': Access denied; you need the SUPER,REPLICATION CLIENT privilege for this operation (1227) grant REPLICATION CLIENT on *.* to mysqltest_1@localhost; -CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000003', MASTER_LOG_POS=9227; +CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=537; CREATE TABLE `t1` ( `a` int(11) default NULL, `b` varchar(34) default NULL diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 674a1680b67..4cdfabd4484 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -1276,6 +1276,9 @@ use test; create user mysqltest_1; create table t1(a int, b varchar(34)); +# To get consistent output, reset the master, starts over from first log +reset master; + # Execute mysqldump, will fail on FLUSH TABLES --error 2 --exec $MYSQL_DUMP --compact --master-data -u mysqltest_1 test 2>&1 From 12051070a78f32550984f961453f58ee044edfc7 Mon Sep 17 00:00:00 2001 From: "kostja@bodhi.local" <> Date: Fri, 4 Aug 2006 00:00:48 +0400 Subject: [PATCH 43/44] Fix a bug in the .dsp file. Ignore a symlink. --- .bzrignore | 1 + VC++Files/sql/mysqld.dsp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.bzrignore b/.bzrignore index 68e8120fae0..5e6c7509354 100644 --- a/.bzrignore +++ b/.bzrignore @@ -1296,3 +1296,4 @@ vio/viotest-sslconnect.cpp vio/viotest.cpp zlib/*.ds? zlib/*.vcproj +ndb/src/common/util/testBitmask.cpp diff --git a/VC++Files/sql/mysqld.dsp b/VC++Files/sql/mysqld.dsp index 259c044e390..45c5e75beb5 100644 --- a/VC++Files/sql/mysqld.dsp +++ b/VC++Files/sql/mysqld.dsp @@ -1639,7 +1639,7 @@ SOURCE=.\sql_load.cpp # End Source File # Begin Source File -SOURCE=.\sql\sql_locale.cpp +SOURCE=.\sql_locale.cpp # End Source File # Begin Source File From 2f9a6c7c4bd41bb2cae4c05f0af26fe2594ae563 Mon Sep 17 00:00:00 2001 From: "kostja@bodhi.local" <> Date: Fri, 4 Aug 2006 01:41:21 +0400 Subject: [PATCH 44/44] Add my_memmem.c to mysys.dsp (needed by mysql_client_test) --- VC++Files/mysys/mysys.dsp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/VC++Files/mysys/mysys.dsp b/VC++Files/mysys/mysys.dsp index 935f1411530..0f1b4bd5d54 100644 --- a/VC++Files/mysys/mysys.dsp +++ b/VC++Files/mysys/mysys.dsp @@ -457,6 +457,10 @@ SOURCE=.\my_malloc.c # End Source File # Begin Source File +SOURCE=.\my_memmem.c +# End Source File +# Begin Source File + SOURCE=.\my_messnc.c # End Source File # Begin Source File