From 3e1dad411598662152dd5100c2fb88219a31634f Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 8 May 2005 21:03:50 +0100 Subject: [PATCH 1/2] Bug#6236 Incomplete ALTER TABLE breaks MERGE compatibility Fix implicit NOT NULL not set on ALTER of PK columns mysql-test/r/alter_table.result: Test for Bug#6236 mysql-test/t/alter_table.test: Test for Bug#6236 sql/sql_table.cc: Implicit NOT NULL not set on ALTER of PK columns BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted --- BitKeeper/etc/logging_ok | 1 + mysql-test/r/alter_table.result | 20 ++++++++++++++++++++ mysql-test/t/alter_table.test | 13 +++++++++++++ sql/sql_table.cc | 23 +++++++++++++++++------ 4 files changed, 51 insertions(+), 6 deletions(-) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index bf0dfb9e31d..5a34dbbb1d8 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -9,6 +9,7 @@ acurtis@pcgem.rdg.cyberkinetica.com ahlentz@co3064164-a.rochd1.qld.optusnet.com.au akishkin@work.mysql.com antony@ltantony.dsl-verizon.net +antony@ltantony.mysql.com antony@ltantony.rdg.cyberkinetica.homeunix.net arjen@bitbike.com arjen@co3064164-a.bitbike.com diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result index 78925a64e93..80d3ef5e0a5 100644 --- a/mysql-test/r/alter_table.result +++ b/mysql-test/r/alter_table.result @@ -386,3 +386,23 @@ Incorrect table name 't1\\' rename table t1 to `t1\\`; Incorrect table name 't1\\' drop table t1; +drop table if exists t1, t2; +create table t1 ( a varchar(10) not null primary key ) engine=myisam; +create table t2 ( a varchar(10) not null primary key ) engine=merge union=(t1); +flush tables; +alter table t1 modify a varchar(10); +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` varchar(10) NOT NULL default '', + PRIMARY KEY (`a`) +) TYPE=MRG_MyISAM UNION=(t1) +flush tables; +alter table t1 modify a varchar(10) not null; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` varchar(10) NOT NULL default '', + PRIMARY KEY (`a`) +) TYPE=MRG_MyISAM UNION=(t1) +drop table if exists t1, t2; diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test index 11290134a71..c69f9aabae6 100644 --- a/mysql-test/t/alter_table.test +++ b/mysql-test/t/alter_table.test @@ -254,3 +254,16 @@ alter table t1 rename to `t1\\`; rename table t1 to `t1\\`; drop table t1; +# +# BUG#6236 - ALTER TABLE MODIFY should set implicit NOT NULL on PK columns +# +drop table if exists t1, t2; +create table t1 ( a varchar(10) not null primary key ) engine=myisam; +create table t2 ( a varchar(10) not null primary key ) engine=merge union=(t1); +flush tables; +alter table t1 modify a varchar(10); +show create table t2; +flush tables; +alter table t1 modify a varchar(10) not null; +show create table t2; +drop table if exists t1, t2; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index cef480fadde..e065e5dfc58 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1795,6 +1795,11 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, } KEY_PART_INFO *key_part= key_info->key_part; + enum Key::Keytype key_type= key_info->flags & HA_NOSAME ? + (!my_strcasecmp(key_name, "PRIMARY") ? + Key::PRIMARY : Key::UNIQUE) : + (key_info->flags & HA_FULLTEXT ? + Key::FULLTEXT : Key::MULTIPLE); key_parts.empty(); for (uint j=0 ; j < key_info->key_parts ; j++,key_part++) { @@ -1824,16 +1829,22 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, cfield->pack_length <= key_part_length)) key_part_length=0; // Use whole field } + if (!(cfield->flags & NOT_NULL_FLAG)) + { + if (key_type == Key::PRIMARY) + { + /* Implicitly set primary key fields to NOT NULL for ISO conf. */ + cfield->flags|= NOT_NULL_FLAG; + cfield->pack_flag&= ~FIELDFLAG_MAYBE_NULL; + } + else + key_info->flags|= HA_NULL_PART_KEY; + } key_parts.push_back(new key_part_spec(cfield->field_name, key_part_length)); } if (key_parts.elements) - key_list.push_back(new Key(key_info->flags & HA_NOSAME ? - (!my_strcasecmp(key_name, "PRIMARY") ? - Key::PRIMARY : Key::UNIQUE) : - (key_info->flags & HA_FULLTEXT ? - Key::FULLTEXT : Key::MULTIPLE), - key_name,key_parts)); + key_list.push_back(new Key(key_type,key_name,key_parts)); } key_it.rewind(); { From 3ac2df4e4c2366d4b30b3251590207a3d07f483d Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 8 May 2005 22:56:58 +0100 Subject: [PATCH 2/2] Bug#8191 - SELECT INTO OUTFILE insists on FROM clause Fix bug + include test case. Enable outfile tests. mysql-test/t/outfile.test: Reenable outfile tests Add test for Bug#8191 sql/sql_yacc.yy: Fix Bug#8191 BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted --- BitKeeper/etc/logging_ok | 1 + mysql-test/include/have_outfile.inc | 5 +++ mysql-test/include/test_outfile.inc | 1 + mysql-test/r/have_outfile.require | 3 ++ mysql-test/r/outfile.result | Bin 0 -> 953 bytes mysql-test/t/outfile.test | 60 +++++++++++++++++++--------- sql/sql_yacc.yy | 7 ++-- 7 files changed, 56 insertions(+), 21 deletions(-) create mode 100644 mysql-test/include/have_outfile.inc create mode 100644 mysql-test/include/test_outfile.inc create mode 100644 mysql-test/r/have_outfile.require create mode 100644 mysql-test/r/outfile.result diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index bf0dfb9e31d..5a34dbbb1d8 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -9,6 +9,7 @@ acurtis@pcgem.rdg.cyberkinetica.com ahlentz@co3064164-a.rochd1.qld.optusnet.com.au akishkin@work.mysql.com antony@ltantony.dsl-verizon.net +antony@ltantony.mysql.com antony@ltantony.rdg.cyberkinetica.homeunix.net arjen@bitbike.com arjen@co3064164-a.bitbike.com diff --git a/mysql-test/include/have_outfile.inc b/mysql-test/include/have_outfile.inc new file mode 100644 index 00000000000..31e95f4810a --- /dev/null +++ b/mysql-test/include/have_outfile.inc @@ -0,0 +1,5 @@ +-- require r/have_outfile.require +disable_query_log; +select load_file(concat(@tmpdir,"/outfile.test")); +--exec rm $MYSQL_TEST_DIR/var/tmp/outfile.test +enable_query_log; diff --git a/mysql-test/include/test_outfile.inc b/mysql-test/include/test_outfile.inc new file mode 100644 index 00000000000..0bede4938c6 --- /dev/null +++ b/mysql-test/include/test_outfile.inc @@ -0,0 +1 @@ +eval select "Outfile OK" into outfile "$MYSQL_TEST_DIR/var/tmp/outfile.test"; diff --git a/mysql-test/r/have_outfile.require b/mysql-test/r/have_outfile.require new file mode 100644 index 00000000000..9fc2f8fdb5a --- /dev/null +++ b/mysql-test/r/have_outfile.require @@ -0,0 +1,3 @@ +load_file(concat(@tmpdir,"/outfile.test")) +Outfile OK + diff --git a/mysql-test/r/outfile.result b/mysql-test/r/outfile.result new file mode 100644 index 0000000000000000000000000000000000000000..a2720be075aeb427d4f11212b77ba3a2ad254710 GIT binary patch literal 953 zcmcIj!A`?44CU;vuzFc1twiZ|0PVsFahP`FhQ!j=V-aan5_izQC#fcFz$p?tT7J*Z zezqHDdt_A^LcK@&(w;rCTtn?hF`ZH@G2f{jR>oHIHR#ThW7HknfW@OS1Nl5VkTDiN ztuswFU*y@-6t~Lx7;c|8o51yCsAe=)HLrVZD6ef-E6yLd?HlbDnXm)LM8V|wR%Y`+ zNset_name($1,(uint) ((char*) lex->tok_end - $1)); }; -opt_into: +into: INTO OUTFILE TEXT_STRING { THD *thd= current_thd;