From c7f0fcab23aa392985ac70fc3ae63805989973b5 Mon Sep 17 00:00:00 2001 From: "svoj@mysql.com" <> Date: Sat, 7 May 2005 15:48:56 +0500 Subject: [PATCH 01/18] BUG#7709 fix - Boolean fulltext query against unsupported engines does not fail. --- BitKeeper/etc/logging_ok | 1 + mysql-test/r/innodb.result | 3 +++ mysql-test/t/innodb.test | 9 +++++++++ sql/item_func.cc | 5 +++++ 4 files changed, 18 insertions(+) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 5a34dbbb1d8..7052d853b00 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -142,6 +142,7 @@ serg@sergbook.mylan serg@sergbook.mysql.com sergefp@mysql.com sinisa@rhols221.adsl.netsonic.fi +svoj@mysql.com tfr@beta.frontier86.ee tfr@indrek.tfr.cafe.ee tfr@sarvik.tfr.cafe.ee diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result index f00679801f8..dbfe1c3aff5 100644 --- a/mysql-test/r/innodb.result +++ b/mysql-test/r/innodb.result @@ -1272,3 +1272,6 @@ Cannot delete or update a parent row: a foreign key constraint fails delete from t1 where id=15; delete from t1 where id=0; drop table t1; +CREATE TABLE t1 ( a char(10) ) ENGINE=InnoDB; +SELECT a FROM t1 WHERE MATCH (a) AGAINST ('test' IN BOOLEAN MODE); +The used table type doesn't support FULLTEXT indexes diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test index 2c8002ea841..c25f295cac8 100644 --- a/mysql-test/t/innodb.test +++ b/mysql-test/t/innodb.test @@ -911,3 +911,12 @@ delete from t1 where id=15; delete from t1 where id=0; drop table t1; + +# +# BUG#7709 test case - Boolean fulltext query against unsupported +# engines does not fail +# + +CREATE TABLE t1 ( a char(10) ) ENGINE=InnoDB; +--error 1214; +SELECT a FROM t1 WHERE MATCH (a) AGAINST ('test' IN BOOLEAN MODE); diff --git a/sql/item_func.cc b/sql/item_func.cc index 334be48dc9a..855e86b2382 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2257,6 +2257,11 @@ bool Item_func_match::fix_fields(THD *thd,struct st_table_list *tlist) key=NO_SUCH_KEY; const_item_cache=0; table=((Item_field *)fields.head())->field->table; + if (!(table->file->table_flags() & HA_CAN_FULLTEXT)) + { + my_error(ER_TABLE_CANT_HANDLE_FULLTEXT, MYF(0)); + return 1; + } table->fulltext_searched=1; record=table->record[0]; if (key == NO_SUCH_KEY && mode != FT_BOOL) From ded73eddf74a6b39b05ba440a59ec82fd673d33e Mon Sep 17 00:00:00 2001 From: "mwagner@ultrafly.mysql.com" <> Date: Sat, 7 May 2005 15:11:31 +0200 Subject: [PATCH 02/18] errmsg.txt: Add newline at EOF for proper processing by comp-err.exe on Windows where fgets() works differently than Linux (Bug #6195). --- BitKeeper/etc/logging_ok | 1 + sql/share/czech/errmsg.txt | 1 + sql/share/danish/errmsg.txt | 1 + sql/share/dutch/errmsg.txt | 1 + sql/share/english/errmsg.txt | 1 + sql/share/estonian/errmsg.txt | 1 + sql/share/french/errmsg.txt | 1 + sql/share/german/errmsg.txt | 1 + sql/share/greek/errmsg.txt | 1 + sql/share/hungarian/errmsg.txt | 1 + sql/share/italian/errmsg.txt | 1 + sql/share/japanese/errmsg.txt | 1 + sql/share/korean/errmsg.txt | 1 + sql/share/norwegian-ny/errmsg.txt | 1 + sql/share/norwegian/errmsg.txt | 1 + sql/share/polish/errmsg.txt | 1 + sql/share/portuguese/errmsg.txt | 1 + sql/share/romanian/errmsg.txt | 1 + sql/share/russian/errmsg.txt | 1 + sql/share/slovak/errmsg.txt | 1 + sql/share/spanish/errmsg.txt | 1 + sql/share/swedish/errmsg.txt | 1 + sql/share/ukrainian/errmsg.txt | 1 + 23 files changed, 23 insertions(+) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 967f8c7cb47..998f8234343 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -107,6 +107,7 @@ monty@work.mysql.com mwagner@cash.mwagner.org mwagner@evoq.mwagner.org mwagner@here.mwagner.org +mwagner@ultrafly.mysql.com mwagner@work.mysql.com mysqldev@build.mysql2.com nick@mysql.com diff --git a/sql/share/czech/errmsg.txt b/sql/share/czech/errmsg.txt index 88ecaed386b..70aea3fdf62 100644 --- a/sql/share/czech/errmsg.txt +++ b/sql/share/czech/errmsg.txt @@ -265,3 +265,4 @@ "Got fatal error %d: '%-.128s' from master when reading data from binary log", "Slave SQL thread ignored the query because of replicate-*-table rules" "Variable '%-.64s' is a %s variable" + diff --git a/sql/share/danish/errmsg.txt b/sql/share/danish/errmsg.txt index 6210bf7788c..8c0bf688311 100644 --- a/sql/share/danish/errmsg.txt +++ b/sql/share/danish/errmsg.txt @@ -256,3 +256,4 @@ "Got fatal error %d: '%-.128s' from master when reading data from binary log", "Slave SQL thread ignored the query because of replicate-*-table rules" "Variable '%-.64s' is a %s variable" + diff --git a/sql/share/dutch/errmsg.txt b/sql/share/dutch/errmsg.txt index c3607f4cd0f..c2baf0240af 100644 --- a/sql/share/dutch/errmsg.txt +++ b/sql/share/dutch/errmsg.txt @@ -265,3 +265,4 @@ "Kreeg fatale fout %d: '%-.128s' van master tijdens lezen van data uit binaire log", "Slave SQL thread ignored the query because of replicate-*-table rules" "Variable '%-.64s' is a %s variable" + diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt index 7c9d789c86e..ed5977fd78c 100644 --- a/sql/share/english/errmsg.txt +++ b/sql/share/english/errmsg.txt @@ -255,3 +255,4 @@ "Variable '%-.64s' is a %s variable" ] # End of error messages # Do NOT add new error messages here as this makes merges to 4.1 too hard! + diff --git a/sql/share/estonian/errmsg.txt b/sql/share/estonian/errmsg.txt index 8157a33836e..581baf24e09 100644 --- a/sql/share/estonian/errmsg.txt +++ b/sql/share/estonian/errmsg.txt @@ -258,3 +258,4 @@ "Got fatal error %d: '%-.128s' from master when reading data from binary log", "Slave SQL thread ignored the query because of replicate-*-table rules" "Variable '%-.64s' is a %s variable" + diff --git a/sql/share/french/errmsg.txt b/sql/share/french/errmsg.txt index 3c88ccc0378..9aa430aa718 100644 --- a/sql/share/french/errmsg.txt +++ b/sql/share/french/errmsg.txt @@ -253,3 +253,4 @@ "Got fatal error %d: '%-.128s' from master when reading data from binary log", "Slave SQL thread ignored the query because of replicate-*-table rules" "Variable '%-.64s' is a %s variable" + diff --git a/sql/share/german/errmsg.txt b/sql/share/german/errmsg.txt index 91f3f91a464..7fa896bcc34 100644 --- a/sql/share/german/errmsg.txt +++ b/sql/share/german/errmsg.txt @@ -257,3 +257,4 @@ "Got fatal error %d: '%-.128s' from master when reading data from binary log", "Slave SQL thread ignored the query because of replicate-*-table rules" "Variable '%-.64s' is a %s variable" + diff --git a/sql/share/greek/errmsg.txt b/sql/share/greek/errmsg.txt index aff7f8ba3c2..2a2bee5d69a 100644 --- a/sql/share/greek/errmsg.txt +++ b/sql/share/greek/errmsg.txt @@ -253,3 +253,4 @@ "Got fatal error %d: '%-.128s' from master when reading data from binary log", "Slave SQL thread ignored the query because of replicate-*-table rules" "Variable '%-.64s' is a %s variable" + diff --git a/sql/share/hungarian/errmsg.txt b/sql/share/hungarian/errmsg.txt index 60dc3204bb4..f998116410f 100644 --- a/sql/share/hungarian/errmsg.txt +++ b/sql/share/hungarian/errmsg.txt @@ -258,3 +258,4 @@ "Got fatal error %d: '%-.128s' from master when reading data from binary log", "Slave SQL thread ignored the query because of replicate-*-table rules" "Variable '%-.64s' is a %s variable" + diff --git a/sql/share/italian/errmsg.txt b/sql/share/italian/errmsg.txt index c51c69cf298..2ab360dff4e 100644 --- a/sql/share/italian/errmsg.txt +++ b/sql/share/italian/errmsg.txt @@ -253,3 +253,4 @@ "Errore fatale %d: '%-.128s' dal master leggendo i dati dal log binario", "Slave SQL thread ignored the query because of replicate-*-table rules" "Variable '%-.64s' is a %s variable" + diff --git a/sql/share/japanese/errmsg.txt b/sql/share/japanese/errmsg.txt index fb604923e4e..4ad7cc3ec37 100644 --- a/sql/share/japanese/errmsg.txt +++ b/sql/share/japanese/errmsg.txt @@ -257,3 +257,4 @@ "Got fatal error %d: '%-.128s' from master when reading data from binary log", "Slave SQL thread ignored the query because of replicate-*-table rules" "Variable '%-.64s' is a %s variable" + diff --git a/sql/share/korean/errmsg.txt b/sql/share/korean/errmsg.txt index 764cbb78740..3b027796c3b 100644 --- a/sql/share/korean/errmsg.txt +++ b/sql/share/korean/errmsg.txt @@ -253,3 +253,4 @@ "Got fatal error %d: '%-.128s' from master when reading data from binary log", "Slave SQL thread ignored the query because of replicate-*-table rules" "Variable '%-.64s' is a %s variable" + diff --git a/sql/share/norwegian-ny/errmsg.txt b/sql/share/norwegian-ny/errmsg.txt index 424530ecf87..5b994d2dc5b 100644 --- a/sql/share/norwegian-ny/errmsg.txt +++ b/sql/share/norwegian-ny/errmsg.txt @@ -255,3 +255,4 @@ "Got fatal error %d: '%-.128s' from master when reading data from binary log", "Slave SQL thread ignored the query because of replicate-*-table rules" "Variable '%-.64s' is a %s variable" + diff --git a/sql/share/norwegian/errmsg.txt b/sql/share/norwegian/errmsg.txt index 73314ea647b..305bf10899b 100644 --- a/sql/share/norwegian/errmsg.txt +++ b/sql/share/norwegian/errmsg.txt @@ -255,3 +255,4 @@ "Got fatal error %d: '%-.128s' from master when reading data from binary log", "Slave SQL thread ignored the query because of replicate-*-table rules" "Variable '%-.64s' is a %s variable" + diff --git a/sql/share/polish/errmsg.txt b/sql/share/polish/errmsg.txt index f24a54ec8e8..8d6b2fa542e 100644 --- a/sql/share/polish/errmsg.txt +++ b/sql/share/polish/errmsg.txt @@ -258,3 +258,4 @@ "Got fatal error %d: '%-.128s' from master when reading data from binary log", "Slave SQL thread ignored the query because of replicate-*-table rules" "Variable '%-.64s' is a %s variable" + diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt index 2810ac134b1..6fcc044c6b6 100644 --- a/sql/share/portuguese/errmsg.txt +++ b/sql/share/portuguese/errmsg.txt @@ -255,3 +255,4 @@ "Obteve fatal erro %d: '%-.128s' do master quando lendo dados do binary log", "Slave SQL thread ignorado a consulta devido às normas de replicação-*-tabela" "Variable '%-.64s' is a %s variable" + diff --git a/sql/share/romanian/errmsg.txt b/sql/share/romanian/errmsg.txt index 552b532c0a2..c218f19e212 100644 --- a/sql/share/romanian/errmsg.txt +++ b/sql/share/romanian/errmsg.txt @@ -258,3 +258,4 @@ "Got fatal error %d: '%-.128s' from master when reading data from binary log", "Slave SQL thread ignored the query because of replicate-*-table rules" "Variable '%-.64s' is a %s variable" + diff --git a/sql/share/russian/errmsg.txt b/sql/share/russian/errmsg.txt index 668b310a5dc..4419da08051 100644 --- a/sql/share/russian/errmsg.txt +++ b/sql/share/russian/errmsg.txt @@ -258,3 +258,4 @@ "ðÏÌÕÞÅÎÁ ÎÅÉÓÐÒÁ×ÉÍÁÑ ÏÛÉÂËÁ %d: '%-.128s' ÏÔ ÇÏÌÏ×ÎÏÇÏ ÓÅÒ×ÅÒÁ × ÐÒÏÃÅÓÓÅ ×ÙÂÏÒËÉ ÄÁÎÎÙÈ ÉÚ Ä×ÏÉÞÎÏÇÏ ÖÕÒÎÁÌÁ", "Slave SQL thread ignored the query because of replicate-*-table rules" "Variable '%-.64s' is a %s variable" + diff --git a/sql/share/slovak/errmsg.txt b/sql/share/slovak/errmsg.txt index 8467fad5b11..bb241673706 100644 --- a/sql/share/slovak/errmsg.txt +++ b/sql/share/slovak/errmsg.txt @@ -261,3 +261,4 @@ "Got fatal error %d: '%-.128s' from master when reading data from binary log", "Slave SQL thread ignored the query because of replicate-*-table rules" "Variable '%-.64s' is a %s variable" + diff --git a/sql/share/spanish/errmsg.txt b/sql/share/spanish/errmsg.txt index 4ab76a64ca7..2daeebc8eb8 100644 --- a/sql/share/spanish/errmsg.txt +++ b/sql/share/spanish/errmsg.txt @@ -256,3 +256,4 @@ "Recibió fatal error %d: '%-.128s' del master cuando leyendo datos del binary log", "Slave SQL thread ignorado el query debido a las reglas de replicación-*-tabla" "Variable '%-.64s' is a %s variable" + diff --git a/sql/share/swedish/errmsg.txt b/sql/share/swedish/errmsg.txt index 352a226ef23..a9273f6222c 100644 --- a/sql/share/swedish/errmsg.txt +++ b/sql/share/swedish/errmsg.txt @@ -253,3 +253,4 @@ "Fick fatalt fel %d: '%-.128s' från master vid läsning av binärloggen" "Slave SQL thread ignored the query because of replicate-*-table rules" "Variable '%-.64s' is a %s variable" + diff --git a/sql/share/ukrainian/errmsg.txt b/sql/share/ukrainian/errmsg.txt index 131cf07a8e2..371dd16d737 100644 --- a/sql/share/ukrainian/errmsg.txt +++ b/sql/share/ukrainian/errmsg.txt @@ -259,3 +259,4 @@ "Got fatal error %d: '%-.128s' from master when reading data from binary log", "Slave SQL thread ignored the query because of replicate-*-table rules" "Variable '%-.64s' is a %s variable" + From 45058e100a7839398f0e70c46f06117867c4dd66 Mon Sep 17 00:00:00 2001 From: "jimw@mysql.com" <> Date: Sat, 7 May 2005 08:16:43 -0700 Subject: [PATCH 03/18] Eliminate gcc 4.0 warning in libedit code. (Bug #9603) --- cmd-line-utils/libedit/vi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd-line-utils/libedit/vi.c b/cmd-line-utils/libedit/vi.c index 4a0352859dd..b977ce716c6 100644 --- a/cmd-line-utils/libedit/vi.c +++ b/cmd-line-utils/libedit/vi.c @@ -1014,7 +1014,7 @@ vi_histedit(EditLine *el, int c) return CC_ERROR; case 0: close(fd); - execlp("vi", "vi", tempfile, 0); + execlp("vi", "vi", tempfile, (char *) NULL); exit(0); /*NOTREACHED*/ default: From fc3ff35be6b32f873709be70d18b77109e76027a Mon Sep 17 00:00:00 2001 From: "svoj@mysql.com" <> Date: Sat, 7 May 2005 21:37:27 +0500 Subject: [PATCH 04/18] Test fix. DROP TABLE added. --- mysql-test/r/innodb.result | 1 + mysql-test/t/innodb.test | 1 + 2 files changed, 2 insertions(+) diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result index dbfe1c3aff5..f634edcbe91 100644 --- a/mysql-test/r/innodb.result +++ b/mysql-test/r/innodb.result @@ -1275,3 +1275,4 @@ drop table t1; CREATE TABLE t1 ( a char(10) ) ENGINE=InnoDB; SELECT a FROM t1 WHERE MATCH (a) AGAINST ('test' IN BOOLEAN MODE); The used table type doesn't support FULLTEXT indexes +DROP TABLE t1; diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test index c25f295cac8..96975d54810 100644 --- a/mysql-test/t/innodb.test +++ b/mysql-test/t/innodb.test @@ -920,3 +920,4 @@ drop table t1; CREATE TABLE t1 ( a char(10) ) ENGINE=InnoDB; --error 1214; SELECT a FROM t1 WHERE MATCH (a) AGAINST ('test' IN BOOLEAN MODE); +DROP TABLE t1; From d51308aec443aea67a0287abb7486190c8913fee Mon Sep 17 00:00:00 2001 From: "antony@ltantony.mysql.com" <> Date: Sun, 8 May 2005 21:03:50 +0100 Subject: [PATCH 05/18] Bug#6236 Incomplete ALTER TABLE breaks MERGE compatibility Fix implicit NOT NULL not set on ALTER of PK columns --- 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 b6609031fa867f46395ad405178b98b268530071 Mon Sep 17 00:00:00 2001 From: "antony@ltantony.mysql.com" <> Date: Sun, 8 May 2005 22:56:58 +0100 Subject: [PATCH 06/18] Bug#8191 - SELECT INTO OUTFILE insists on FROM clause Fix bug + include test case. Enable outfile tests. --- 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; From 61d7f1db13e544baeb225a4a5b87a8d2cef1d1a4 Mon Sep 17 00:00:00 2001 From: "antony@ltantony.mysql.com" <> Date: Mon, 9 May 2005 08:33:45 +0100 Subject: [PATCH 07/18] Fix outfile test/results --- mysql-test/r/outfile.result | Bin 953 -> 683 bytes mysql-test/t/outfile.test | 17 +++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/outfile.result b/mysql-test/r/outfile.result index a2720be075aeb427d4f11212b77ba3a2ad254710..a7871592241104fe2a949c98379cfa21dcbe5d68 100644 GIT binary patch delta 14 WcmdnVzM6Hz0mg}i`jh`M?EwHS^#)-8 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`+ zN Date: Wed, 11 May 2005 12:14:46 -0500 Subject: [PATCH 08/18] mysqldump.1.in: Remove obsolete section number. (Bug #10534) --- man/mysqldump.1.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/man/mysqldump.1.in b/man/mysqldump.1.in index 4d841117e59..0f581429af7 100644 --- a/man/mysqldump.1.in +++ b/man/mysqldump.1.in @@ -218,7 +218,8 @@ or ), mysqldump will create rows up to net_buffer_length length. If you increase this variable, you should also ensure that the max_allowed_packet variable in the MySQL server is bigger than the net_buffer_length. .SH EXAMPLES .TP -The most normal use of mysqldump is probably for making a backup of whole databases. See Mysql Manual section 21.2 Database Backups. +The most normal use of mysqldump is probably for making a backup of whole +databases. See the section on Database Backups in the MySQL Reference Manual. .TP mysqldump \-\-opt \fP\fIdatabase\fP > backup-file.sql .TP From 20f969b2568a730af3864b104134926a22e8ae96 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Fri, 13 May 2005 11:11:50 +0300 Subject: [PATCH 09/18] Change create_field->offset to store offset from start of fields, independent of null bits. Count null_bits separately from field offsets and adjust them in case of primary key parts. (Previously a CREATE TABLE with a lot of null fields that was part of a primary key caused MySQL to wrongly count the number of bytes needed to store null bits) This is a more complete bug fix for #6236 --- mysql-test/r/alter_table.result | 16 +++++++ mysql-test/t/alter_table.test | 17 +++++++ sql/handler.h | 1 + sql/sql_table.cc | 37 ++++++--------- sql/unireg.cc | 83 ++++++++++++++++++++------------- 5 files changed, 98 insertions(+), 56 deletions(-) diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result index 80d3ef5e0a5..19d2ca4d6ed 100644 --- a/mysql-test/r/alter_table.result +++ b/mysql-test/r/alter_table.result @@ -406,3 +406,19 @@ t2 CREATE TABLE `t2` ( PRIMARY KEY (`a`) ) TYPE=MRG_MyISAM UNION=(t1) drop table if exists t1, t2; +create table t1 (a int, b int, c int, d int, e int, f int, g int, h int,i int, primary key (a,b,c,d,e,f,g,i,h)) engine=MyISAM; +insert into t1 (a) values(1); +show table status like 't1'; +Name Type Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Create_options Comment +t1 MyISAM Fixed 1 37 37 X X X X X X X X +alter table t1 modify a int; +show table status like 't1'; +Name Type Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Create_options Comment +t1 MyISAM Fixed 1 37 37 X X X X X X X X +drop table t1; +create table t1 (a int not null, b int not null, c int not null, d int not null, e int not null, f int not null, g int not null, h int not null,i int not null, primary key (a,b,c,d,e,f,g,i,h)) engine=MyISAM; +insert into t1 (a) values(1); +show table status like 't1'; +Name Type Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Create_options Comment +t1 MyISAM Fixed 1 37 37 X X X X X X X X +drop table t1; diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test index c69f9aabae6..af0ec2bca16 100644 --- a/mysql-test/t/alter_table.test +++ b/mysql-test/t/alter_table.test @@ -267,3 +267,20 @@ flush tables; alter table t1 modify a varchar(10) not null; show create table t2; drop table if exists t1, t2; + +# The following is also part of bug #6236 (CREATE TABLE didn't properly count +# not null columns for primary keys) + +create table t1 (a int, b int, c int, d int, e int, f int, g int, h int,i int, primary key (a,b,c,d,e,f,g,i,h)) engine=MyISAM; +insert into t1 (a) values(1); +--replace_column 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X +show table status like 't1'; +alter table t1 modify a int; +--replace_column 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X +show table status like 't1'; +drop table t1; +create table t1 (a int not null, b int not null, c int not null, d int not null, e int not null, f int not null, g int not null, h int not null,i int not null, primary key (a,b,c,d,e,f,g,i,h)) engine=MyISAM; +insert into t1 (a) values(1); +--replace_column 7 X 8 X 9 X 10 X 11 X 12 X 13 X 14 X +show table status like 't1'; +drop table t1; diff --git a/sql/handler.h b/sql/handler.h index ac00050b777..e52164a871a 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -164,6 +164,7 @@ typedef struct st_ha_create_information SQL_LIST merge_list; enum db_type db_type; enum row_type row_type; + uint null_bits; /* NULL bits at start of record */ uint options; /* OR of HA_CREATE_ options */ uint raid_type,raid_chunks; uint merge_insert_method; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index e065e5dfc58..e275f902abd 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -363,7 +363,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, create_field *sql_field,*dup_field; int error= -1; uint db_options,field,null_fields,blob_columns; - ulong pos; + ulong record_offset; KEY *key_info,*key_info_buffer; KEY_PART_INFO *key_part_info; int auto_increment=0; @@ -418,10 +418,9 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, } it2.rewind(); } - /* If fixed row records, we need one bit to check for deleted rows */ - if (!(db_options & HA_OPTION_PACK_RECORD)) - null_fields++; - pos=(null_fields+7)/8; + + /* record_offset will be increased with 'length-of-null-bits' later */ + record_offset= 0; it.rewind(); while ((sql_field=it++)) @@ -478,10 +477,10 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, } if (!(sql_field->flags & NOT_NULL_FLAG)) sql_field->pack_flag|=FIELDFLAG_MAYBE_NULL; - sql_field->offset= pos; + sql_field->offset= record_offset; if (MTYP_TYPENR(sql_field->unireg_check) == Field::NEXT_NUMBER) auto_increment++; - pos+=sql_field->pack_length; + record_offset+= sql_field->pack_length; } if (auto_increment > 1) { @@ -578,11 +577,12 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, column->field_name); DBUG_RETURN(-1); } - /* for fulltext keys keyseg length is 1 for blobs (it's ignored in - ft code anyway, and 0 (set to column width later) for char's. - it has to be correct col width for char's, as char data are not - prefixed with length (unlike blobs, where ft code takes data length - from a data prefix, ignoring column->length). + /* + for fulltext keys keyseg length is 1 for blobs (it's ignored in + ft code anyway, and 0 (set to column width later) for char's. + it has to be correct col width for char's, as char data are not + prefixed with length (unlike blobs, where ft code takes data length + from a data prefix, ignoring column->length). */ if (key->type == Key::FULLTEXT) column->length=test(f_is_blob(sql_field->pack_flag)); @@ -609,6 +609,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, /* Implicitly set primary key fields to NOT NULL for ISO conf. */ sql_field->flags|= NOT_NULL_FLAG; sql_field->pack_flag&= ~FIELDFLAG_MAYBE_NULL; + null_fields--; } else key_info->flags|= HA_NULL_PART_KEY; @@ -765,6 +766,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, if (thd->sql_mode & MODE_NO_DIR_IN_CREATE) create_info->data_file_name= create_info->index_file_name= 0; create_info->table_options=db_options; + create_info->null_bits= null_fields; if (rea_create_table(path, create_info, fields, key_count, key_info_buffer)) @@ -1829,17 +1831,6 @@ 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)); } diff --git a/sql/unireg.cc b/sql/unireg.cc index 218ea6b5b8d..f81370539c6 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -32,18 +32,21 @@ static uchar * pack_screens(List &create_fields, uint *info_length, uint *screens, bool small_file); -static uint pack_keys(uchar *keybuff,uint key_count, KEY *key_info); +static uint pack_keys(uchar *keybuff,uint key_count, KEY *key_info, + ulong data_offset); static bool pack_header(uchar *forminfo, enum db_type table_type, List &create_fields, uint info_length, uint screens, uint table_options, - handler *file); + ulong data_offset, handler *file); static uint get_interval_id(uint *int_count,List &create_fields, create_field *last_field); -static bool pack_fields(File file, List &create_fields); +static bool pack_fields(File file, List &create_fields, + ulong data_offset); static bool make_empty_rec(int file, enum db_type table_type, uint table_options, List &create_fields, - uint reclength,uint null_fields); + uint reclength, uint null_fields, + ulong data_offset); int rea_create_table(my_string file_name, @@ -53,7 +56,7 @@ int rea_create_table(my_string file_name, { uint reclength,info_length,screens,key_info_length,maxlength,null_fields; File file; - ulong filepos; + ulong filepos, data_offset; uchar fileinfo[64],forminfo[288],*keybuff; TYPELIB formnames; uchar *screen_buff; @@ -64,8 +67,15 @@ int rea_create_table(my_string file_name, if (!(screen_buff=pack_screens(create_fields,&info_length,&screens,0))) DBUG_RETURN(1); db_file=get_new_handler((TABLE*) 0, create_info->db_type); + + /* If fixed row records, we need one bit to check for deleted rows */ + if (!(create_info->table_options & HA_OPTION_PACK_RECORD)) + create_info->null_bits++; + data_offset= (create_info->null_bits + 7) / 8; + if (pack_header(forminfo, create_info->db_type,create_fields,info_length, - screens, create_info->table_options, db_file)) + screens, create_info->table_options, + data_offset, db_file)) { NET *net=my_pthread_getspecific_ptr(NET*,THR_NET); my_free((gptr) screen_buff,MYF(0)); @@ -77,7 +87,7 @@ int rea_create_table(my_string file_name, if (!(screen_buff=pack_screens(create_fields,&info_length,&screens,1))) DBUG_RETURN(1); if (pack_header(forminfo, create_info->db_type, create_fields,info_length, - screens, create_info->table_options, db_file)) + screens, create_info->table_options, data_offset, db_file)) { my_free((gptr) screen_buff,MYF(0)); DBUG_RETURN(1); @@ -95,7 +105,7 @@ int rea_create_table(my_string file_name, uint key_buff_length=uint2korr(fileinfo+14); keybuff=(uchar*) my_alloca(key_buff_length); - key_info_length=pack_keys(keybuff,keys,key_info); + key_info_length= pack_keys(keybuff, keys, key_info, data_offset); VOID(get_form_pos(file,fileinfo,&formnames)); if (!(filepos=make_new_entry(file,fileinfo,&formnames,""))) goto err; @@ -117,13 +127,13 @@ int rea_create_table(my_string file_name, (ulong) uint2korr(fileinfo+6)+ (ulong) key_buff_length, MY_SEEK_SET,MYF(0))); if (make_empty_rec(file,create_info->db_type,create_info->table_options, - create_fields,reclength,null_fields)) + create_fields,reclength, null_fields, data_offset)) goto err; VOID(my_seek(file,filepos,MY_SEEK_SET,MYF(0))); if (my_write(file,(byte*) forminfo,288,MYF_RW) || my_write(file,(byte*) screen_buff,info_length,MYF_RW) || - pack_fields(file,create_fields)) + pack_fields(file, create_fields, data_offset)) goto err; #ifdef HAVE_CRYPTED_FRM @@ -248,7 +258,8 @@ static uchar * pack_screens(List &create_fields, /* Pack keyinfo and keynames to keybuff for save in form-file. */ -static uint pack_keys(uchar *keybuff,uint key_count,KEY *keyinfo) +static uint pack_keys(uchar *keybuff, uint key_count, KEY *keyinfo, + ulong data_offset) { uint key_parts,length; uchar *pos, *keyname_pos, *key_alg_pos; @@ -273,10 +284,13 @@ static uint pack_keys(uchar *keybuff,uint key_count,KEY *keyinfo) key_part++) { - DBUG_PRINT("loop",("field: %d startpos: %ld length: %ld", - key_part->fieldnr,key_part->offset,key_part->length)); + uint offset; + DBUG_PRINT("loop",("field: %d startpos: %lu length: %ld", + key_part->fieldnr, key_part->offset + data_offset, + key_part->length)); int2store(pos,key_part->fieldnr+1+FIELD_NAME_USED); - int2store(pos+2,key_part->offset+1); + offset= (uint) (key_part->offset+data_offset+1); + int2store(pos+2, offset); pos[4]=0; // Sort order int2store(pos+5,key_part->key_type); int2store(pos+7,key_part->length); @@ -316,8 +330,8 @@ static uint pack_keys(uchar *keybuff,uint key_count,KEY *keyinfo) static bool pack_header(uchar *forminfo, enum db_type table_type, List &create_fields, - uint info_length, uint screens,uint table_options, - handler *file) + uint info_length, uint screens, uint table_options, + ulong data_offset, handler *file) { uint length,int_count,int_length,no_empty, int_parts, time_stamp_pos,null_fields; @@ -351,10 +365,10 @@ static bool pack_header(uchar *forminfo, enum db_type table_type, if ((MTYP_TYPENR(field->unireg_check) == Field::TIMESTAMP_FIELD || f_packtype(field->pack_flag) == (int) FIELD_TYPE_TIMESTAMP) && !time_stamp_pos) - time_stamp_pos=(int) field->offset+1; + time_stamp_pos= (uint) field->offset+ (uint) data_offset + 1; length=field->pack_length; - if ((int) field->offset+length > reclength) - reclength=(int) field->offset+length; + if ((uint) field->offset+ (uint) data_offset+ length > reclength) + reclength=(uint) (field->offset+ data_offset + length); n_length+= (ulong) strlen(field->field_name)+1; field->interval_id=0; if (field->interval) @@ -440,7 +454,8 @@ static uint get_interval_id(uint *int_count,List &create_fields, /* Save fields, fieldnames and intervals */ -static bool pack_fields(File file,List &create_fields) +static bool pack_fields(File file, List &create_fields, + ulong data_offset) { reg2 uint i; uint int_count; @@ -455,11 +470,13 @@ static bool pack_fields(File file,List &create_fields) int_count=0; while ((field=it++)) { + uint recpos; buff[0]= (uchar) field->row; buff[1]= (uchar) field->col; buff[2]= (uchar) field->sc_length; buff[3]= (uchar) field->length; - uint recpos=(uint) field->offset+1; + /* The +1 is here becasue the col offset in .frm file have offset 1 */ + recpos= field->offset+1 + (uint) data_offset; int2store(buff+4,recpos); int2store(buff+6,field->pack_flag); int2store(buff+8,field->unireg_check); @@ -519,11 +536,12 @@ static bool pack_fields(File file,List &create_fields) static bool make_empty_rec(File file,enum db_type table_type, uint table_options, List &create_fields, - uint reclength, uint null_fields) + uint reclength, uint null_fields, + ulong data_offset) { int error; Field::utype type; - uint firstpos,null_count,null_length; + uint firstpos,null_count; uchar *buff,*null_pos; TABLE table; create_field *field; @@ -547,17 +565,16 @@ static bool make_empty_rec(File file,enum db_type table_type, firstpos=reclength; null_count=0; if (!(table_options & HA_OPTION_PACK_RECORD)) - { - null_fields++; // Need one bit for delete mark - null_count++; - } - bfill(buff,(null_length=(null_fields+7)/8),255); + null_count++; // Need one bit for delete mark + DBUG_ASSERT(data_offset == ((null_fields + null_count + 7) / 8)); + bfill(buff, (uint) data_offset, 255); null_pos=buff; List_iterator it(create_fields); while ((field=it++)) { - Field *regfield=make_field((char*) buff+field->offset,field->length, + Field *regfield=make_field((char*) buff+field->offset + data_offset, + field->length, field->flags & NOT_NULL_FLAG ? 0: null_pos+null_count/8, 1 << (null_count & 7), @@ -570,9 +587,9 @@ static bool make_empty_rec(File file,enum db_type table_type, if (!(field->flags & NOT_NULL_FLAG)) null_count++; - if ((uint) field->offset < firstpos && + if ((uint) (field->offset + data_offset) < firstpos && regfield->type() != FIELD_TYPE_NULL) - firstpos= field->offset; + firstpos= field->offset + data_offset; type= (Field::utype) MTYP_TYPENR(field->unireg_check); @@ -596,8 +613,8 @@ static bool make_empty_rec(File file,enum db_type table_type, } /* Fill not used startpos */ - bfill((byte*) buff+null_length,firstpos-null_length,255); - error=(int) my_write(file,(byte*) buff,(uint) reclength,MYF_RW); + bfill((byte*) buff+data_offset, firstpos- (uint) data_offset, 255); + error=(int) my_write(file,(byte*) buff, (uint) reclength,MYF_RW); my_free((gptr) buff,MYF(MY_FAE)); delete handler; DBUG_RETURN(error); From b54d7d04bd13498b5bc5e8e109f5690aeb10ec5d Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Fri, 13 May 2005 14:04:32 +0300 Subject: [PATCH 10/18] Fixes during review --- mysql-test/r/select.result | 4 ++-- mysql-test/t/select.test | 4 ++-- sql/hostname.cc | 4 ++-- sql/sql_yacc.yy | 29 ++++++++++------------------- strings/ctype-ucs2.c | 8 +++++--- 5 files changed, 21 insertions(+), 28 deletions(-) diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index 50300ed9b76..387e7eff693 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -2451,7 +2451,7 @@ a select distinct distinct * from t1; a select all distinct * from t1; -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 'distinct * from t1' at line 1 +ERROR HY000: Incorrect usage of ALL and DISTINCT select distinct all * from t1; -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 'all * from t1' at line 1 +ERROR HY000: Incorrect usage of ALL and DISTINCT drop table t1; diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 6d6d5f6b6e1..a46522c1510 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -1987,9 +1987,9 @@ drop table t1; create table t1 (a int(11)); select all all * from t1; select distinct distinct * from t1; ---error 1064 +--error 1221 select all distinct * from t1; ---error 1064 +--error 1221 select distinct all * from t1; drop table t1; diff --git a/sql/hostname.cc b/sql/hostname.cc index ec5c6f29a27..39223556024 100644 --- a/sql/hostname.cc +++ b/sql/hostname.cc @@ -209,8 +209,8 @@ my_string ip_to_hostname(struct in_addr *in, uint *errors) DBUG_PRINT("error",("gethostbyaddr returned %d",errno)); if (errno == HOST_NOT_FOUND || errno == NO_DATA) - add_wrong_ip(in); /* only cache negative responses, not failures */ - + goto add_wrong_ip_and_return; + /* Failure, don't cache responce */ DBUG_RETURN(0); } if (!hp->h_name[0]) // Don't allow empty hostnames diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index abe7a716a69..28d3560e5f0 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -2467,7 +2467,14 @@ select_from: select_options: /* empty*/ - | select_option_list; + | select_option_list + { + if (test_all_bits(Select->options, SELECT_ALL | SELECT_DISTINCT)) + { + net_printf(Lex->thd, ER_WRONG_USAGE, "ALL", "DISTINCT"); + YYABORT; + } + } select_option_list: select_option_list select_option @@ -2481,15 +2488,7 @@ select_option: YYABORT; Lex->lock_option= TL_READ_HIGH_PRIORITY; } - | DISTINCT - { - if (Select->options & SELECT_ALL) - { - yyerror(ER(ER_SYNTAX_ERROR)); - YYABORT; - } - Select->options|= SELECT_DISTINCT; - } + | DISTINCT { Select->options|= SELECT_DISTINCT; } | SQL_SMALL_RESULT { Select->options|= SELECT_SMALL_RESULT; } | SQL_BIG_RESULT { Select->options|= SELECT_BIG_RESULT; } | SQL_BUFFER_RESULT @@ -2509,15 +2508,7 @@ select_option: { Lex->select_lex.options|= OPTION_TO_QUERY_CACHE; } - | ALL - { - if (Select->options & SELECT_DISTINCT) - { - yyerror(ER(ER_SYNTAX_ERROR)); - YYABORT; - } - Select->options|= SELECT_ALL; - } + | ALL { Select->options|= SELECT_ALL; } ; select_lock_type: diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index f12cfe3256e..12c1ae905cf 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -1251,7 +1251,7 @@ static uint my_numchars_ucs2(CHARSET_INFO *cs __attribute__((unused)), const char *b, const char *e) { - return (e-b)/2; + return (uint) (e-b)/2; } @@ -1261,7 +1261,8 @@ uint my_charpos_ucs2(CHARSET_INFO *cs __attribute__((unused)), const char *e __attribute__((unused)), uint pos) { - return pos > e - b ? e - b + 2 : pos * 2; + uint string_length= (uint) (e - b); + return pos > string_length ? string_length + 2 : pos * 2; } @@ -1270,7 +1271,8 @@ uint my_well_formed_len_ucs2(CHARSET_INFO *cs __attribute__((unused)), const char *b, const char *e, uint nchars, int *error) { - uint nbytes= (e-b) & ~ (uint)1; + /* Ensure string length is dividable with 2 */ + uint nbytes= ((uint) (e-b)) & ~(uint) 1; *error= 0; nchars*= 2; return min(nbytes, nchars); From 320d9cb4c2425811313e115a532ffcc9b023005a Mon Sep 17 00:00:00 2001 From: "georg@lmy002.wdf.sap.corp" <> Date: Fri, 13 May 2005 15:06:11 +0200 Subject: [PATCH 11/18] added function mysql_set_character_set (reviewed by Monty) as a work around for #8317 and #9637 This function sends SET NAMES command and changes mysql->charset so mysql_real_escape_string will work as expected. --- libmysql/libmysql.c | 30 ++++++++++++++++++++++++++++++ libmysql/libmysql.def | 1 + 2 files changed, 31 insertions(+) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index c663dab7476..4c9f06df38e 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -1509,6 +1509,36 @@ const char * STDCALL mysql_character_set_name(MYSQL *mysql) return mysql->charset->csname; } +int STDCALL mysql_set_character_set(MYSQL *mysql, char *cs_name) +{ + struct charset_info_st *cs; + const char *save_csdir = charsets_dir; + + if (mysql->options.charset_dir) + charsets_dir = mysql->options.charset_dir; + + if ( (cs = get_charset_by_csname(cs_name, MY_CS_PRIMARY, MYF(0))) ) + { + char buff[MY_CS_NAME_SIZE + 10]; + charsets_dir = save_csdir; + sprintf(buff, "SET NAMES %s", cs_name); + if (!mysql_query(mysql, buff)) { + mysql->charset = cs; + } + } else { + char cs_dir_name[FN_REFLEN]; + get_charsets_dir(cs_dir_name); + mysql->net.last_errno=CR_CANT_READ_CHARSET; + strmov(mysql->net.sqlstate, unknown_sqlstate); + my_snprintf(mysql->net.last_error, sizeof(mysql->net.last_error)-1, + ER(mysql->net.last_errno), + cs_name, + cs_dir_name); + + } + charsets_dir = save_csdir; + return mysql->net.last_errno; +} uint STDCALL mysql_thread_safe(void) { diff --git a/libmysql/libmysql.def b/libmysql/libmysql.def index c5579e9ec2b..57c97ab08ee 100644 --- a/libmysql/libmysql.def +++ b/libmysql/libmysql.def @@ -146,4 +146,5 @@ EXPORTS mysql_rpl_query_type mysql_slave_query mysql_embedded + mysql_set_character_set get_defaults_files From 41d284e608c19811e7b3976003485b0cef5c1968 Mon Sep 17 00:00:00 2001 From: "georg@lmy002.wdf.sap.corp" <> Date: Fri, 13 May 2005 15:54:35 +0200 Subject: [PATCH 12/18] added prototype for mysql_set_character_set function --- include/mysql.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/mysql.h b/include/mysql.h index d8a56126756..ab61fe694d9 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -381,6 +381,7 @@ unsigned int STDCALL mysql_warning_count(MYSQL *mysql); const char * STDCALL mysql_info(MYSQL *mysql); unsigned long STDCALL mysql_thread_id(MYSQL *mysql); const char * STDCALL mysql_character_set_name(MYSQL *mysql); +int STDCALL mysql_set_character_set(MYSQL *mysql, char *csname); MYSQL * STDCALL mysql_init(MYSQL *mysql); my_bool STDCALL mysql_ssl_set(MYSQL *mysql, const char *key, From d4bbdad2f6f7eae088b95593f854e664c2cfca6f Mon Sep 17 00:00:00 2001 From: "heikki@hundin.mysql.fi" <> Date: Fri, 13 May 2005 18:37:22 +0300 Subject: [PATCH 13/18] row0mysql.c: InnoDB wrongly complained in the .err log that MySQL is trying to drop a non-existent table, if tablespace ran out (Bug #10607) --- innobase/row/row0mysql.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/innobase/row/row0mysql.c b/innobase/row/row0mysql.c index 9410f2ce7cc..280c306cce4 100644 --- a/innobase/row/row0mysql.c +++ b/innobase/row/row0mysql.c @@ -1606,10 +1606,18 @@ row_create_table_for_mysql( trx_general_rollback_for_mysql(trx, FALSE, NULL); if (err == DB_OUT_OF_FILE_SPACE) { - fputs("InnoDB: Warning: cannot create table ", stderr); + ut_print_timestamp(stderr); + + fputs(" InnoDB: Warning: cannot create table ", + stderr); ut_print_name(stderr, trx, table->name); fputs(" because tablespace full\n", stderr); - row_drop_table_for_mysql(table->name, trx, FALSE); + + if (dict_table_get_low(table->name)) { + + row_drop_table_for_mysql(table->name, trx, + FALSE); + } } else if (err == DB_DUPLICATE_KEY) { ut_print_timestamp(stderr); From c4c76c5fdb4fc2e677ee6f7b885074808910cd83 Mon Sep 17 00:00:00 2001 From: "serg@serg.mylan" <> Date: Fri, 13 May 2005 21:43:26 +0200 Subject: [PATCH 14/18] sql/ha_blackhole.cc bug#10175 - blackhole.test hangs with "Warning: prev link 1 didn't point at previous lock at read: read lock with no write locks" sql/sql_base.cc libmysqld/examples/mysql.cc linking problem --- sql/ha_blackhole.cc | 3 ++- sql/sql_base.cc | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sql/ha_blackhole.cc b/sql/ha_blackhole.cc index 7c6e7cb56b6..c9c94b3a9d7 100644 --- a/sql/ha_blackhole.cc +++ b/sql/ha_blackhole.cc @@ -129,8 +129,9 @@ THR_LOCK_DATA **ha_blackhole::store_lock(THD *thd, THR_LOCK_DATA **to, enum thr_lock_type lock_type) { + if (lock_type != TL_IGNORE && lock.type == TL_UNLOCK) + lock.type=lock_type; *to++= &lock; - return to; } diff --git a/sql/sql_base.cc b/sql/sql_base.cc index c580842ce06..e86362c857b 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2522,7 +2522,7 @@ bool get_key_map_from_key_list(key_map *map, TABLE *table, if ((pos= find_type(&table->keynames, name->ptr(), name->length(), 1)) <= 0) { - my_error(ER_KEY_COLUMN_DOES_NOT_EXITS, MYF(0), name->c_ptr(), + my_error(ER_KEY_COLUMN_DOES_NOT_EXITS, MYF(0), name->c_ptr_safe(), table->real_name); map->set_all(); return 1; From 9b39f8304ef1e9ca9a10803271125431ed15fc0f Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Fri, 13 May 2005 23:08:29 +0300 Subject: [PATCH 15/18] Fixed wrong buffer usage for auto-increment key with blob part that caused CHECK TABLE to report that the table was wrong. (Bug #10045) --- myisam/mi_key.c | 31 ++++++++++++++++++++---------- mysql-test/r/auto_increment.result | 14 ++++++++++++++ mysql-test/t/auto_increment.test | 12 ++++++++++++ 3 files changed, 47 insertions(+), 10 deletions(-) diff --git a/myisam/mi_key.c b/myisam/mi_key.c index 1688ab74823..06571c570e1 100644 --- a/myisam/mi_key.c +++ b/myisam/mi_key.c @@ -255,8 +255,25 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old, } /* _mi_pack_key */ - /* Put a key in record */ - /* Used when only-keyread is wanted */ + +/* + Store found key in record + + SYNOPSIS + _mi_put_key_in_record() + info MyISAM handler + keynr Key number that was used + record Store key here + + Last read key is in info->lastkey + + NOTES + Used when only-keyread is wanted + + RETURN + 0 ok + 1 error +*/ static int _mi_put_key_in_record(register MI_INFO *info, uint keynr, byte *record) @@ -267,14 +284,8 @@ static int _mi_put_key_in_record(register MI_INFO *info, uint keynr, byte *blob_ptr; DBUG_ENTER("_mi_put_key_in_record"); - if (info->s->base.blobs && info->s->keyinfo[keynr].flag & HA_VAR_LENGTH_KEY) - { - if (!(blob_ptr= - mi_alloc_rec_buff(info, info->s->keyinfo[keynr].keylength, - &info->rec_buff))) - goto err; - } - key=(byte*) info->lastkey; + blob_ptr= info->lastkey2; /* Place to put blob parts */ + key=(byte*) info->lastkey; /* KEy that was read */ key_end=key+info->lastkey_length; for (keyseg=info->s->keyinfo[keynr].seg ; keyseg->type ;keyseg++) { diff --git a/mysql-test/r/auto_increment.result b/mysql-test/r/auto_increment.result index 2d6b058d9c5..9345c029127 100644 --- a/mysql-test/r/auto_increment.result +++ b/mysql-test/r/auto_increment.result @@ -131,3 +131,17 @@ a 1 2 drop table t1; +CREATE TABLE t1 ( a INT AUTO_INCREMENT, b BLOB, PRIMARY KEY (a,b(10))); +INSERT INTO t1 (b) VALUES ('aaaa'); +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1 (b) VALUES (''); +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +INSERT INTO t1 (b) VALUES ('bbbb'); +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +DROP TABLE IF EXISTS t1; diff --git a/mysql-test/t/auto_increment.test b/mysql-test/t/auto_increment.test index c26983b5eec..e699415a838 100644 --- a/mysql-test/t/auto_increment.test +++ b/mysql-test/t/auto_increment.test @@ -89,3 +89,15 @@ select last_insert_id(); insert into t1 values (NULL); select * from t1; drop table t1; + +# +# BUG #10045: Problem with composite AUTO_INCREMENT + BLOB key + +CREATE TABLE t1 ( a INT AUTO_INCREMENT, b BLOB, PRIMARY KEY (a,b(10))); +INSERT INTO t1 (b) VALUES ('aaaa'); +CHECK TABLE t1; +INSERT INTO t1 (b) VALUES (''); +CHECK TABLE t1; +INSERT INTO t1 (b) VALUES ('bbbb'); +CHECK TABLE t1; +DROP TABLE IF EXISTS t1; From 6adfd9436ebfa0274f9fd5c4402e8d4e1d467f52 Mon Sep 17 00:00:00 2001 From: "konstantin@mysql.com" <> Date: Sat, 14 May 2005 02:28:10 +0400 Subject: [PATCH 16/18] Fix wrong format specifier in error messages. Not to be pushed into 5.0 as there it's fixed differently (in the new format of error messages) --- sql/share/danish/errmsg.txt | 2 +- sql/share/serbian/errmsg.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/share/danish/errmsg.txt b/sql/share/danish/errmsg.txt index 384625f7112..4983d39714a 100644 --- a/sql/share/danish/errmsg.txt +++ b/sql/share/danish/errmsg.txt @@ -262,7 +262,7 @@ character-set=latin1 "Key reference and table reference don't match", "Operand should contain %d column(s)", "Subquery returns more than 1 row", -"Unknown prepared statement handler (%ld) given to %s", +"Unknown prepared statement handler (%.*s) given to %s", "Help database is corrupt or does not exist", "Cyclic reference on subqueries", "Converting column '%s' from %s to %s", diff --git a/sql/share/serbian/errmsg.txt b/sql/share/serbian/errmsg.txt index accf1926abb..adda7d7cf53 100644 --- a/sql/share/serbian/errmsg.txt +++ b/sql/share/serbian/errmsg.txt @@ -252,7 +252,7 @@ character-set=cp1250 "Key reference and table reference don't match", "Operand should contain %d column(s)", "Subquery returns more than 1 row", -"Unknown prepared statement handler (%ld) given to %s", +"Unknown prepared statement handler (%.*s) given to %s", "Help database is corrupt or does not exist", "Cyclic reference on subqueries", "Converting column '%s' from %s to %s", From 6c981c0b8005a1577c7dfd93eb656a5da46ef9f0 Mon Sep 17 00:00:00 2001 From: "konstantin@mysql.com" <> Date: Sat, 14 May 2005 02:31:26 +0400 Subject: [PATCH 17/18] Fix a valgrind warning: memcpy does not allow its arguments to overlap. --- libmysql/libmysql.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 4c9f06df38e..3fcdc6bdc4d 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -3944,9 +3944,12 @@ my_bool STDCALL mysql_stmt_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind) /* We only need to check that stmt->field_count - if it is not null stmt->bind was initialized in mysql_stmt_prepare - */ + stmt->bind overlaps with bind if mysql_stmt_bind_param + is called from mysql_stmt_store_result. + */ - memcpy((char*) stmt->bind, (char*) bind, sizeof(MYSQL_BIND) * bind_count); + if (stmt->bind != bind) + memcpy((char*) stmt->bind, (char*) bind, sizeof(MYSQL_BIND) * bind_count); for (param= stmt->bind, end= param + bind_count, field= stmt->fields ; param < end ; From beb5867dfb429a88dc2b732fb1d379560d29fc29 Mon Sep 17 00:00:00 2001 From: "monty@mysql.com" <> Date: Sat, 14 May 2005 16:24:36 +0300 Subject: [PATCH 18/18] After merge fixes --- libmysql/libmysql.c | 31 ++-- mysql-test/r/alter_table.result | 225 +++++++++++++++--------------- mysql-test/r/innodb.result | 2 +- mysql-test/r/insert_update.result | 9 +- mysql-test/r/outfile.result | Bin 683 -> 959 bytes mysql-test/r/outfile2.result | 10 -- mysql-test/t/alter_table.test | 102 +++++++------- mysql-test/t/insert_update.test | 6 +- mysql-test/t/outfile.test | 1 + sql/item_func.cc | 2 +- sql/sql_table.cc | 2 +- 11 files changed, 200 insertions(+), 190 deletions(-) delete mode 100644 mysql-test/r/outfile2.result diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 4c9f06df38e..ff90cfb6007 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -1509,37 +1509,40 @@ const char * STDCALL mysql_character_set_name(MYSQL *mysql) return mysql->charset->csname; } + int STDCALL mysql_set_character_set(MYSQL *mysql, char *cs_name) { struct charset_info_st *cs; - const char *save_csdir = charsets_dir; + const char *save_csdir= charsets_dir; if (mysql->options.charset_dir) - charsets_dir = mysql->options.charset_dir; + charsets_dir= mysql->options.charset_dir; - if ( (cs = get_charset_by_csname(cs_name, MY_CS_PRIMARY, MYF(0))) ) + if ((cs= get_charset_by_csname(cs_name, MY_CS_PRIMARY, MYF(0)))) { char buff[MY_CS_NAME_SIZE + 10]; - charsets_dir = save_csdir; + charsets_dir= save_csdir; sprintf(buff, "SET NAMES %s", cs_name); - if (!mysql_query(mysql, buff)) { - mysql->charset = cs; - } - } else { + if (!mysql_query(mysql, buff)) + { + mysql->charset= cs; + } + } + else + { char cs_dir_name[FN_REFLEN]; get_charsets_dir(cs_dir_name); - mysql->net.last_errno=CR_CANT_READ_CHARSET; + mysql->net.last_errno= CR_CANT_READ_CHARSET; strmov(mysql->net.sqlstate, unknown_sqlstate); - my_snprintf(mysql->net.last_error, sizeof(mysql->net.last_error)-1, - ER(mysql->net.last_errno), - cs_name, - cs_dir_name); + my_snprintf(mysql->net.last_error, sizeof(mysql->net.last_error) - 1, + ER(mysql->net.last_errno), cs_name, cs_dir_name); } - charsets_dir = save_csdir; + charsets_dir= save_csdir; return mysql->net.last_errno; } + uint STDCALL mysql_thread_safe(void) { #ifdef THREAD diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result index 6cada0d5fb2..b7d47a09bee 100644 --- a/mysql-test/r/alter_table.result +++ b/mysql-test/r/alter_table.result @@ -303,6 +303,120 @@ ALTER TABLE t1 DISABLE KEYS; INSERT DELAYED INTO t1 VALUES(1),(2),(3); ALTER TABLE t1 ENABLE KEYS; drop table t1; +CREATE TABLE t1 ( +Host varchar(16) binary NOT NULL default '', +User varchar(16) binary NOT NULL default '', +PRIMARY KEY (Host,User) +) ENGINE=MyISAM; +ALTER TABLE t1 DISABLE KEYS; +LOCK TABLES t1 WRITE; +INSERT INTO t1 VALUES ('localhost','root'),('localhost',''),('games','monty'); +SHOW INDEX FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE +t1 0 PRIMARY 2 User A 3 NULL NULL BTREE +ALTER TABLE t1 ENABLE KEYS; +UNLOCK TABLES; +CHECK TABLES t1; +Table Op Msg_type Msg_text +test.t1 check status OK +DROP TABLE t1; +CREATE TABLE t1 ( +Host varchar(16) binary NOT NULL default '', +User varchar(16) binary NOT NULL default '', +PRIMARY KEY (Host,User), +KEY (Host) +) ENGINE=MyISAM; +ALTER TABLE t1 DISABLE KEYS; +SHOW INDEX FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE +t1 0 PRIMARY 2 User A 0 NULL NULL BTREE +t1 1 Host 1 Host A NULL NULL NULL BTREE disabled +LOCK TABLES t1 WRITE; +INSERT INTO t1 VALUES ('localhost','root'),('localhost',''); +SHOW INDEX FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE +t1 0 PRIMARY 2 User A 2 NULL NULL BTREE +t1 1 Host 1 Host A NULL NULL NULL BTREE disabled +ALTER TABLE t1 ENABLE KEYS; +SHOW INDEX FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE +t1 0 PRIMARY 2 User A 2 NULL NULL BTREE +t1 1 Host 1 Host A 1 NULL NULL BTREE +UNLOCK TABLES; +CHECK TABLES t1; +Table Op Msg_type Msg_text +test.t1 check status OK +LOCK TABLES t1 WRITE; +ALTER TABLE t1 RENAME t2; +UNLOCK TABLES; +select * from t2; +Host User +localhost +localhost root +DROP TABLE t2; +CREATE TABLE t1 ( +Host varchar(16) binary NOT NULL default '', +User varchar(16) binary NOT NULL default '', +PRIMARY KEY (Host,User), +KEY (Host) +) ENGINE=MyISAM; +LOCK TABLES t1 WRITE; +ALTER TABLE t1 DISABLE KEYS; +SHOW INDEX FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE +t1 0 PRIMARY 2 User A 0 NULL NULL BTREE +t1 1 Host 1 Host A NULL NULL NULL BTREE disabled +DROP TABLE t1; +create table t1 (a int); +alter table t1 rename to `t1\\`; +ERROR 42000: Incorrect table name 't1\\' +rename table t1 to `t1\\`; +ERROR 42000: Incorrect table name 't1\\' +drop table t1; +drop table if exists t1, t2; +Warnings: +Note 1051 Unknown table 't1' +Note 1051 Unknown table '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`) +) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 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`) +) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`) +drop table if exists t1, t2; +create table t1 (a int, b int, c int, d int, e int, f int, g int, h int,i int, primary key (a,b,c,d,e,f,g,i,h)) engine=MyISAM; +insert into t1 (a) values(1); +show table status like 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 MyISAM 9 Fixed 1 37 X X X X X X X X latin1_swedish_ci NULL +alter table t1 modify a int; +show table status like 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 MyISAM 9 Fixed 1 37 X X X X X X X X latin1_swedish_ci NULL +drop table t1; +create table t1 (a int not null, b int not null, c int not null, d int not null, e int not null, f int not null, g int not null, h int not null,i int not null, primary key (a,b,c,d,e,f,g,i,h)) engine=MyISAM; +insert into t1 (a) values(1); +show table status like 't1'; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 MyISAM 9 Fixed 1 37 X X X X X X X X latin1_swedish_ci NULL +drop table t1; set names koi8r; create table t1 (a char(10) character set koi8r); insert into t1 values ('ÔÅÓÔ'); @@ -382,75 +496,6 @@ t1 CREATE TABLE `t1` ( `mytext` longtext character set latin1 collate latin1_general_cs ) ENGINE=MyISAM DEFAULT CHARSET=latin2 drop table t1; -CREATE TABLE t1 ( -Host varchar(16) binary NOT NULL default '', -User varchar(16) binary NOT NULL default '', -PRIMARY KEY (Host,User) -) ENGINE=MyISAM; -ALTER TABLE t1 DISABLE KEYS; -LOCK TABLES t1 WRITE; -INSERT INTO t1 VALUES ('localhost','root'),('localhost',''),('games','monty'); -SHOW INDEX FROM t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment -t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE -t1 0 PRIMARY 2 User A 3 NULL NULL BTREE -ALTER TABLE t1 ENABLE KEYS; -UNLOCK TABLES; -CHECK TABLES t1; -Table Op Msg_type Msg_text -test.t1 check status OK -DROP TABLE t1; -CREATE TABLE t1 ( -Host varchar(16) binary NOT NULL default '', -User varchar(16) binary NOT NULL default '', -PRIMARY KEY (Host,User), -KEY (Host) -) ENGINE=MyISAM; -ALTER TABLE t1 DISABLE KEYS; -SHOW INDEX FROM t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment -t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE -t1 0 PRIMARY 2 User A 0 NULL NULL BTREE -t1 1 Host 1 Host A NULL NULL NULL BTREE disabled -LOCK TABLES t1 WRITE; -INSERT INTO t1 VALUES ('localhost','root'),('localhost',''); -SHOW INDEX FROM t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment -t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE -t1 0 PRIMARY 2 User A 2 NULL NULL BTREE -t1 1 Host 1 Host A NULL NULL NULL BTREE disabled -ALTER TABLE t1 ENABLE KEYS; -SHOW INDEX FROM t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment -t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE -t1 0 PRIMARY 2 User A 2 NULL NULL BTREE -t1 1 Host 1 Host A 1 NULL NULL BTREE -UNLOCK TABLES; -CHECK TABLES t1; -Table Op Msg_type Msg_text -test.t1 check status OK -LOCK TABLES t1 WRITE; -ALTER TABLE t1 RENAME t2; -UNLOCK TABLES; -select * from t2; -Host User -localhost -localhost root -DROP TABLE t2; -CREATE TABLE t1 ( -Host varchar(16) binary NOT NULL default '', -User varchar(16) binary NOT NULL default '', -PRIMARY KEY (Host,User), -KEY (Host) -) ENGINE=MyISAM; -LOCK TABLES t1 WRITE; -ALTER TABLE t1 DISABLE KEYS; -SHOW INDEX FROM t1; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment -t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE -t1 0 PRIMARY 2 User A 0 NULL NULL BTREE -t1 1 Host 1 Host A NULL NULL NULL BTREE disabled -DROP TABLE t1; CREATE TABLE t1 (a int PRIMARY KEY, b INT UNIQUE); ALTER TABLE t1 DROP PRIMARY KEY; SHOW CREATE TABLE t1; @@ -469,12 +514,6 @@ alter table t1 drop key no_such_key; ERROR 42000: Can't DROP 'no_such_key'; check that column/key exists alter table t1 drop key a; drop table t1; -create table t1 (a int); -alter table t1 rename to `t1\\`; -ERROR 42000: Incorrect table name 't1\\' -rename table t1 to `t1\\`; -ERROR 42000: Incorrect table name 't1\\' -drop table t1; create table t1 (a text) character set koi8r; insert into t1 values (_koi8r'ÔÅÓÔ'); select hex(a) from t1; @@ -489,39 +528,3 @@ create table t1 ( a timestamp ); alter table t1 add unique ( a(1) ); ERROR HY000: Incorrect sub part key; the used key part isn't a string, the used length is longer than the key part, or the storage engine doesn't support unique sub keys drop table t1; -drop table if exists t1, 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; -create table t1 (a int, b int, c int, d int, e int, f int, g int, h int,i int, primary key (a,b,c,d,e,f,g,i,h)) engine=MyISAM; -insert into t1 (a) values(1); -show table status like 't1'; -Name Type Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Create_options Comment -t1 MyISAM Fixed 1 37 37 X X X X X X X X -alter table t1 modify a int; -show table status like 't1'; -Name Type Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Create_options Comment -t1 MyISAM Fixed 1 37 37 X X X X X X X X -drop table t1; -create table t1 (a int not null, b int not null, c int not null, d int not null, e int not null, f int not null, g int not null, h int not null,i int not null, primary key (a,b,c,d,e,f,g,i,h)) engine=MyISAM; -insert into t1 (a) values(1); -show table status like 't1'; -Name Type Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Create_options Comment -t1 MyISAM Fixed 1 37 37 X X X X X X X X -drop table t1; diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result index def462fb521..4c983014d4b 100644 --- a/mysql-test/r/innodb.result +++ b/mysql-test/r/innodb.result @@ -1645,5 +1645,5 @@ concat(a, b) drop table t1; CREATE TABLE t1 ( a char(10) ) ENGINE=InnoDB; SELECT a FROM t1 WHERE MATCH (a) AGAINST ('test' IN BOOLEAN MODE); -The used table type doesn't support FULLTEXT indexes +ERROR HY000: The used table type doesn't support FULLTEXT indexes DROP TABLE t1; diff --git a/mysql-test/r/insert_update.result b/mysql-test/r/insert_update.result index f78372541f2..2143538469b 100644 --- a/mysql-test/r/insert_update.result +++ b/mysql-test/r/insert_update.result @@ -167,7 +167,7 @@ a b c VALUES(a) 2 1 11 NULL DROP TABLE t1; DROP TABLE t2; -create table t1 (a int not null unique); +create table t1 (a int not null unique) engine=myisam; insert into t1 values (1),(2); insert ignore into t1 select 1 on duplicate key update a=2; select * from t1; @@ -179,4 +179,11 @@ select * from t1; a 1 3 +insert into t1 select 1 on duplicate key update a=2; +select * from t1; +a +2 +3 +insert into t1 select a from t1 on duplicate key update a=a+1 ; +ERROR 23000: Duplicate entry '3' for key 1 drop table t1; diff --git a/mysql-test/r/outfile.result b/mysql-test/r/outfile.result index a7871592241104fe2a949c98379cfa21dcbe5d68..5eb24a78ef0d0242fcdd2f0ad1dfbf47f9d60dac 100644 GIT binary patch delta 348 zcmZXQ&q~8U5XMmu*?k5NgO{j?H3(jMO4F?@Y zpG+ZwP-z*hrJ?a@?VoU_hrj<%rt>6VA7x`&;>?mb`|b(bqMOs06nvZsMldG63m&Y9oCrbW!+}TKlZ9

zvZF(N`U{1WXL|qu delta 24 gcmdnbzM6HzU&e{cG$y}ifield->table; if (!(table->file->table_flags() & HA_CAN_FULLTEXT)) { - my_error(ER_TABLE_CANT_HANDLE_FULLTEXT, MYF(0)); + my_error(ER_TABLE_CANT_HANDLE_FT, MYF(0)); return 1; } table->fulltext_searched=1; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 7b0f24bcc45..67aade519f5 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1205,6 +1205,7 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, /* Sort keys in optimized order */ qsort((gptr) key_info_buffer, *key_count, sizeof(KEY), (qsort_cmp) sort_keys); + create_info->null_bits= null_fields; DBUG_RETURN(0); } @@ -1392,7 +1393,6 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, if (thd->variables.sql_mode & MODE_NO_DIR_IN_CREATE) create_info->data_file_name= create_info->index_file_name= 0; create_info->table_options=db_options; - create_info->null_bits= null_fields; if (rea_create_table(thd, path, create_info, fields, key_count, key_info_buffer))