From 33cf11b4285c83f0ba90178fb9fe8c039d0de129 Mon Sep 17 00:00:00 2001 From: Patrick Crews Date: Fri, 5 Dec 2008 08:21:03 -0500 Subject: [PATCH 1/3] Bug#41258: mysql-test-run does not copy subdirectories of std_data on Windows (5.0 only) Altered how we copy data from mysql-test/std_data on Windows to match what we are doing in 5.1 and 6.0 --- mysql-test/mysql-test-run.pl | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 268dd3fbd16..70637034b6e 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -2380,13 +2380,7 @@ sub setup_vardir() { { # on windows, copy all files from std_data into var/std_data_ln mkpath("$opt_vardir/std_data_ln"); - opendir(DIR, "$glob_mysql_test_dir/std_data") - or mtr_error("Can't find the std_data directory: $!"); - for(readdir(DIR)) { - next if -d "$glob_mysql_test_dir/std_data/$_"; - copy("$glob_mysql_test_dir/std_data/$_", "$opt_vardir/std_data_ln/$_"); - } - closedir(DIR); + mtr_copy_dir("$glob_mysql_test_dir/std_data", "$opt_vardir/std_data_ln"); } # Remove old log files From d2b5e0bb940dbcf4dae0000a745cab58a351408e Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Tue, 9 Dec 2008 16:38:52 +0400 Subject: [PATCH 2/3] Bug#31291 ALTER TABLE CONVERT TO CHARACTER SET does not change some data types added ability for TINY[MEDIUM] text fields to be converted to greater subtype during alter if necessary(altered charset) --- mysql-test/r/alter_table.result | 16 ++++++++++++++++ mysql-test/t/alter_table.test | 13 +++++++++++++ sql/sql_table.cc | 4 +++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result index 95c652055ec..d81086682f1 100644 --- a/mysql-test/r/alter_table.result +++ b/mysql-test/r/alter_table.result @@ -915,3 +915,19 @@ check table t1; Table Op Msg_type Msg_text test.t1 check status OK drop table t1; +create table t1 (a tinytext character set latin1); +alter table t1 convert to character set utf8; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` text +) ENGINE=MyISAM DEFAULT CHARSET=utf8 +drop table t1; +create table t1 (a mediumtext character set latin1); +alter table t1 convert to character set utf8; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` longtext +) ENGINE=MyISAM DEFAULT CHARSET=utf8 +drop table t1; diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test index bcca122f9f8..18481291bba 100644 --- a/mysql-test/t/alter_table.test +++ b/mysql-test/t/alter_table.test @@ -696,3 +696,16 @@ unlock tables; select * from t1; check table t1; drop table t1; + + +# +# Bug#31291 ALTER TABLE CONVERT TO CHARACTER SET does not change some data types +# +create table t1 (a tinytext character set latin1); +alter table t1 convert to character set utf8; +show create table t1; +drop table t1; +create table t1 (a mediumtext character set latin1); +alter table t1 convert to character set utf8; +show create table t1; +drop table t1; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 8baeca9ccf7..eefe2a5596e 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1535,7 +1535,9 @@ static bool prepare_blob_field(THD *thd, create_field *sql_field) if ((sql_field->flags & BLOB_FLAG) && sql_field->length) { - if (sql_field->sql_type == FIELD_TYPE_BLOB) + if (sql_field->sql_type == FIELD_TYPE_BLOB || + sql_field->sql_type == FIELD_TYPE_TINY_BLOB || + sql_field->sql_type == FIELD_TYPE_MEDIUM_BLOB) { /* The user has given a length to the blob column */ sql_field->sql_type= get_blob_type_from_length(sql_field->length); From c5c64a30d44f720ff3c9a6bfcdbf11a0bcc70797 Mon Sep 17 00:00:00 2001 From: Sergey Glukhov Date: Tue, 9 Dec 2008 16:59:47 +0400 Subject: [PATCH 3/3] Bug#31399 Wrong query result when doing join buffering over BIT fields if table has bit fields then uneven bits(if exist) are stored into null bits place. So we need to copy null bits in case of uneven bit field presence. --- mysql-test/r/type_bit.result | 26 ++++++++++++++++++++++++++ mysql-test/t/type_bit.test | 30 ++++++++++++++++++++++++++++++ sql/sql_select.cc | 8 ++++++-- 3 files changed, 62 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/type_bit.result b/mysql-test/r/type_bit.result index 2a83d9b4c62..63dec0297d0 100644 --- a/mysql-test/r/type_bit.result +++ b/mysql-test/r/type_bit.result @@ -723,4 +723,30 @@ CREATE TABLE IF NOT EXISTS t1 ( f1 bit(2) NOT NULL default b'' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; ERROR 42000: Invalid default value for 'f1' +create table t1bit7 (a1 bit(7) not null) engine=MyISAM; +create table t2bit7 (b1 bit(7)) engine=MyISAM; +insert into t1bit7 values (b'1100000'); +insert into t1bit7 values (b'1100001'); +insert into t1bit7 values (b'1100010'); +insert into t2bit7 values (b'1100001'); +insert into t2bit7 values (b'1100010'); +insert into t2bit7 values (b'1100110'); +select bin(a1) from t1bit7, t2bit7 where t1bit7.a1=t2bit7.b1; +bin(a1) +1100001 +1100010 +drop table t1bit7, t2bit7; +create table t1bit7 (a1 bit(15) not null) engine=MyISAM; +create table t2bit7 (b1 bit(15)) engine=MyISAM; +insert into t1bit7 values (b'110000011111111'); +insert into t1bit7 values (b'110000111111111'); +insert into t1bit7 values (b'110001011111111'); +insert into t2bit7 values (b'110000111111111'); +insert into t2bit7 values (b'110001011111111'); +insert into t2bit7 values (b'110011011111111'); +select bin(a1) from t1bit7, t2bit7 where t1bit7.a1=t2bit7.b1; +bin(a1) +110000111111111 +110001011111111 +drop table t1bit7, t2bit7; End of 5.0 tests diff --git a/mysql-test/t/type_bit.test b/mysql-test/t/type_bit.test index 81dca17f112..bdc678688f1 100644 --- a/mysql-test/t/type_bit.test +++ b/mysql-test/t/type_bit.test @@ -367,4 +367,34 @@ CREATE TABLE IF NOT EXISTS t1 ( f1 bit(2) NOT NULL default b'' ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; + +# +# Bug#31399 Wrong query result when doing join buffering over BIT fields +# +create table t1bit7 (a1 bit(7) not null) engine=MyISAM; +create table t2bit7 (b1 bit(7)) engine=MyISAM; + +insert into t1bit7 values (b'1100000'); +insert into t1bit7 values (b'1100001'); +insert into t1bit7 values (b'1100010'); +insert into t2bit7 values (b'1100001'); +insert into t2bit7 values (b'1100010'); +insert into t2bit7 values (b'1100110'); + +select bin(a1) from t1bit7, t2bit7 where t1bit7.a1=t2bit7.b1; +drop table t1bit7, t2bit7; + +create table t1bit7 (a1 bit(15) not null) engine=MyISAM; +create table t2bit7 (b1 bit(15)) engine=MyISAM; + +insert into t1bit7 values (b'110000011111111'); +insert into t1bit7 values (b'110000111111111'); +insert into t1bit7 values (b'110001011111111'); +insert into t2bit7 values (b'110000111111111'); +insert into t2bit7 values (b'110001011111111'); +insert into t2bit7 values (b'110011011111111'); + +select bin(a1) from t1bit7, t2bit7 where t1bit7.a1=t2bit7.b1; +drop table t1bit7, t2bit7; + --echo End of 5.0 tests diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 2ac33c4e07f..b080fff8725 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -13233,6 +13233,7 @@ join_init_cache(THD *thd,JOIN_TAB *tables,uint table_count) length=0; for (i=0 ; i < table_count ; i++) { + bool have_bit_fields= FALSE; uint null_fields=0,used_fields; Field **f_ptr,*field; @@ -13247,13 +13248,16 @@ join_init_cache(THD *thd,JOIN_TAB *tables,uint table_count) length+=field->fill_cache_field(copy); if (copy->blob_field) (*blob_ptr++)=copy; - if (field->maybe_null()) + if (field->real_maybe_null()) null_fields++; + if (field->type() == MYSQL_TYPE_BIT && + ((Field_bit*)field)->bit_len) + have_bit_fields= TRUE; copy++; } } /* Copy null bits from table */ - if (null_fields && tables[i].table->s->null_fields) + if (null_fields || have_bit_fields) { /* must copy null bits */ copy->str=(char*) tables[i].table->null_flags; copy->length= tables[i].table->s->null_bytes;