From 60a0a5d006b36542ef536008f1c001a1793f4bd6 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 19 Nov 2003 23:11:27 +0100 Subject: [PATCH 001/113] ignore: added sql/udf_example.so scripts/make_win_src_distribution BitKeeper/etc/ignore: added sql/udf_example.so scripts/make_win_src_distribution --- .bzrignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.bzrignore b/.bzrignore index 7929adbf881..b2c877e16c5 100644 --- a/.bzrignore +++ b/.bzrignore @@ -335,3 +335,5 @@ innobase/stamp-h1 stamp-h1 configure.lineno innobase/configure.lineno +sql/udf_example.so +scripts/make_win_src_distribution From b4364c8c708306925c73b2e0fd0cdfd2de4d2165 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 25 Nov 2003 17:26:19 +0100 Subject: [PATCH 002/113] - The LGPL section was removed from manual.texi, hence we now use a local copy of COPYING.LIB (moved from the mysys subdirectory) instead of creating it on the fly out of the manual. COPYING.LIB: Rename: mysys/COPYING.LIB -> COPYING.LIB Docs/Makefile.am: - Don't build COPYING.LIB from manual.texi anymore (section was removed from the manual) --- mysys/COPYING.LIB => COPYING.LIB | 0 Docs/Makefile.am | 6 +----- 2 files changed, 1 insertion(+), 5 deletions(-) rename mysys/COPYING.LIB => COPYING.LIB (100%) diff --git a/mysys/COPYING.LIB b/COPYING.LIB similarity index 100% rename from mysys/COPYING.LIB rename to COPYING.LIB diff --git a/Docs/Makefile.am b/Docs/Makefile.am index 17450c3b072..eea93380b35 100644 --- a/Docs/Makefile.am +++ b/Docs/Makefile.am @@ -25,8 +25,7 @@ EXTRA_DIST = $(noinst_SCRIPTS) $(BUILT_SOURCES) mysqld_error.txt INSTALL-BINARY all: $(targets) txt_files -txt_files: ../INSTALL-SOURCE ../COPYING ../COPYING.LIB \ - INSTALL-BINARY +txt_files: ../INSTALL-SOURCE ../COPYING INSTALL-BINARY CLEAN_FILES: $(BUILD_SOURCES) touch $(BUILD_SOURCES) @@ -142,8 +141,5 @@ INSTALL-BINARY: mysql.info $(GT) ../COPYING: mysql.info $(GT) perl -w $(GT) mysql.info "GPL license" "LGPL license" > $@ -../COPYING.LIB: mysql.info $(GT) - perl -w $(GT) mysql.info "LGPL license" "Function Index" > $@ - # Don't update the files from bitkeeper %::SCCS/s.% From 594fe5086b52fd8d2a90d84fefb009a62d887931 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 27 Nov 2003 09:35:55 +0100 Subject: [PATCH 003/113] fix contact person --- BitKeeper/etc/config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BitKeeper/etc/config b/BitKeeper/etc/config index 85b5a871301..1faf57416f5 100644 --- a/BitKeeper/etc/config +++ b/BitKeeper/etc/config @@ -42,7 +42,7 @@ single_host: # discovers a problem which requires local intervention. Please make the # contact information accurate so we can support you. # -contact: Sasha Pachev +contact: sys@mysql.com # # It is very important that this email address is filled out and accurate. # If someone converts your repository to open logging (which you may not @@ -51,7 +51,7 @@ contact: Sasha Pachev # response from anyone else at your location after 90 days, then open logging # will be implicitly approved. # -email: sasha@mysql.com +email: sys@mysql.com # # Add your street address if you like, it is optional. # From 5454f676ff4cd8a2f6ec577e35746dd18b31478f Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 16 Dec 2003 17:55:34 -0400 Subject: [PATCH 004/113] fixed restoring of thd->count_cuted_fields in store_val_in_field (fixed #bug 2012) mysql-test/r/insert_select.result: added test case for bug #2012 mysql-test/t/insert_select.test: added test case for bug #2012 --- mysql-test/r/insert_select.result | 12 ++++++++++++ mysql-test/t/insert_select.test | 31 +++++++++++++++++++++++++++++++ sql/sql_select.cc | 8 +++++++- 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/insert_select.result b/mysql-test/r/insert_select.result index c754085ccb3..2435e28d7fe 100644 --- a/mysql-test/r/insert_select.result +++ b/mysql-test/r/insert_select.result @@ -11,3 +11,15 @@ payoutID 19 20 22 +Month Type Field Count +2003-09-01 1 1 100 +2003-09-01 1 2 100 +2003-09-01 2 1 100 +2003-09-01 2 2 100 +2003-09-01 3 1 100 +NULL Field Count +NULL 1 100 +NULL 2 100 +No Field Count +0 1 100 +0 2 100 diff --git a/mysql-test/t/insert_select.test b/mysql-test/t/insert_select.test index 17ecb2d5a1f..625f4755a79 100644 --- a/mysql-test/t/insert_select.test +++ b/mysql-test/t/insert_select.test @@ -10,3 +10,34 @@ insert into t2 (payoutID) SELECT DISTINCT payoutID FROM t1; insert into t2 (payoutID) SELECT payoutID+10 FROM t1; select * from t2; drop table t1,t2; + +# +# Another problem from Bug #2012 +# + +CREATE TABLE t1( + Month date NOT NULL, + Type tinyint(3) unsigned NOT NULL auto_increment, + Field int(10) unsigned NOT NULL, + Count int(10) unsigned NOT NULL, + UNIQUE KEY Month (Month,Type,Field) +); + +insert into t1 Values +(20030901, 1, 1, 100), +(20030901, 1, 2, 100), +(20030901, 2, 1, 100), +(20030901, 2, 2, 100), +(20030901, 3, 1, 100); + +select * from t1; + +Select null, Field, Count From t1 Where Month=20030901 and Type=2; + +create table t2(No int not null, Field int not null, Count int not null); + +insert into t2 Select null, Field, Count From t1 Where Month=20030901 and Type=2; + +select * from t2; + +drop table t1, t2; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 1230dffcaa9..26b1966ffed 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2184,9 +2184,15 @@ store_val_in_field(Field *field,Item *item) { THD *thd=current_thd; ulong cuted_fields=thd->cuted_fields; + /* + we should restore old value of count_cuted_fields because + store_val_in_field can be called from mysql_insert + with select_insert, which make count_cuted_fields= 1 + */ + bool old_count_cuted_fields= thd->count_cuted_fields; thd->count_cuted_fields=1; item->save_in_field(field); - thd->count_cuted_fields=0; + thd->count_cuted_fields= old_count_cuted_fields; return cuted_fields != thd->cuted_fields; } From d6be93aa27becf6864b15a699cf62c394620355e Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 17 Dec 2003 16:37:47 -0400 Subject: [PATCH 005/113] added error message for receiving variable with wrong GLOBAL|LOCAL type (bug #2086) include/mysqld_error.h: added error message for receiving variable with wrong GLOBAL|LOCAL type mysql-test/r/variables.result: added error message for receiving variable with wrong GLOBAL|LOCAL type mysql-test/t/variables.test: added error message for receiving variable with wrong GLOBAL|LOCAL type sql/set_var.cc: added error message for receiving variable with wrong GLOBAL|LOCAL type sql/share/czech/errmsg.txt: added error message for receiving variable with wrong GLOBAL|LOCAL type sql/share/danish/errmsg.txt: added error message for receiving variable with wrong GLOBAL|LOCAL type sql/share/dutch/errmsg.txt: added error message for receiving variable with wrong GLOBAL|LOCAL type sql/share/english/errmsg.txt: added error message for receiving variable with wrong GLOBAL|LOCAL type sql/share/estonian/errmsg.txt: added error message for receiving variable with wrong GLOBAL|LOCAL type sql/share/french/errmsg.txt: added error message for receiving variable with wrong GLOBAL|LOCAL type sql/share/german/errmsg.txt: added error message for receiving variable with wrong GLOBAL|LOCAL type sql/share/greek/errmsg.txt: added error message for receiving variable with wrong GLOBAL|LOCAL type sql/share/hungarian/errmsg.txt: added error message for receiving variable with wrong GLOBAL|LOCAL type sql/share/italian/errmsg.txt: added error message for receiving variable with wrong GLOBAL|LOCAL type sql/share/japanese/errmsg.txt: added error message for receiving variable with wrong GLOBAL|LOCAL type sql/share/korean/errmsg.txt: added error message for receiving variable with wrong GLOBAL|LOCAL type sql/share/norwegian-ny/errmsg.txt: added error message for receiving variable with wrong GLOBAL|LOCAL type sql/share/norwegian/errmsg.txt: added error message for receiving variable with wrong GLOBAL|LOCAL type sql/share/polish/errmsg.txt: added error message for receiving variable with wrong GLOBAL|LOCAL type sql/share/portuguese/errmsg.txt: added error message for receiving variable with wrong GLOBAL|LOCAL type sql/share/romanian/errmsg.txt: added error message for receiving variable with wrong GLOBAL|LOCAL type sql/share/russian/errmsg.txt: added error message for receiving variable with wrong GLOBAL|LOCAL type sql/share/slovak/errmsg.txt: added error message for receiving variable with wrong GLOBAL|LOCAL type sql/share/spanish/errmsg.txt: added error message for receiving variable with wrong GLOBAL|LOCAL type sql/share/swedish/errmsg.txt: added error message for receiving variable with wrong GLOBAL|LOCAL type sql/share/ukrainian/errmsg.txt: added error message for receiving variable with wrong GLOBAL|LOCAL type --- include/mysqld_error.h | 3 ++- mysql-test/r/variables.result | 6 ++++-- mysql-test/t/variables.test | 7 +++++-- sql/set_var.cc | 5 ++--- 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 + 26 files changed, 35 insertions(+), 8 deletions(-) diff --git a/include/mysqld_error.h b/include/mysqld_error.h index 9d3197c0bd4..acc9b5961c6 100644 --- a/include/mysqld_error.h +++ b/include/mysqld_error.h @@ -254,4 +254,5 @@ #define ER_NOT_SUPPORTED_YET 1235 #define ER_MASTER_FATAL_ERROR_READING_BINLOG 1236 #define ER_SLAVE_IGNORED_TABLE 1237 /* only the slave SQL thread can be sent this */ -#define ER_ERROR_MESSAGES 238 +#define ER_INCORRECT_GLOBAL_LOCAL_VAR 1238 +#define ER_ERROR_MESSAGES 239 diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index 8afdced206b..b4a607cb174 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -231,7 +231,7 @@ Wrong argument type to variable 'convert_character_set' set global autocommit=1; Variable 'autocommit' is a LOCAL variable and can't be used with SET GLOBAL select @@global.timestamp; -Variable 'timestamp' is a LOCAL variable and can't be used with SET GLOBAL +Variable 'timestamp' is a LOCAL variable set @@version=''; Unknown system variable 'version' set @@concurrent_insert=1; @@ -239,7 +239,7 @@ Variable 'concurrent_insert' is a GLOBAL variable and should be set with SET GLO set @@global.sql_auto_is_null=1; Variable 'sql_auto_is_null' is a LOCAL variable and can't be used with SET GLOBAL select @@global.sql_auto_is_null; -Variable 'sql_auto_is_null' is a LOCAL variable and can't be used with SET GLOBAL +Variable 'sql_auto_is_null' is a LOCAL variable set myisam_max_sort_file_size=100; Variable 'myisam_max_sort_file_size' is a GLOBAL variable and should be set with SET GLOBAL set myisam_max_extra_sort_file_size=100; @@ -375,3 +375,5 @@ Unknown system variable 'xxxxxxxxxx' select 1; 1 1 +select @@session.key_buffer_size; +Variable 'key_buffer_size' is a GLOBAL variable diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index 8e38160c60b..ec86a763023 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -139,7 +139,7 @@ set character set unknown; set character set 0; --error 1228 set global autocommit=1; ---error 1228 +--error 1238 select @@global.timestamp; --error 1193 set @@version=''; @@ -147,7 +147,7 @@ set @@version=''; set @@concurrent_insert=1; --error 1228 set @@global.sql_auto_is_null=1; ---error 1228 +--error 1238 select @@global.sql_auto_is_null; --error 1229 set myisam_max_sort_file_size=100; @@ -266,3 +266,6 @@ drop table t1,t2; --error 1193 select @@xxxxxxxxxx; select 1; + +--error 1238 +select @@session.key_buffer_size; \ No newline at end of file diff --git a/sql/set_var.cc b/sql/set_var.cc index 4aea611e401..4e22d7983dd 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -1032,9 +1032,8 @@ Item *sys_var::item(THD *thd, enum_var_type var_type) { if (var_type != OPT_DEFAULT) { - net_printf(&thd->net, - var_type == OPT_GLOBAL ? ER_LOCAL_VARIABLE : - ER_GLOBAL_VARIABLE, name); + net_printf(&thd->net,ER_INCORRECT_GLOBAL_LOCAL_VAR, + name, var_type == OPT_GLOBAL ? "LOCAL" : "GLOBAL"); return 0; } /* As there was no local variable, return the global value */ diff --git a/sql/share/czech/errmsg.txt b/sql/share/czech/errmsg.txt index 72a593cf5f7..6e8f060b6b1 100644 --- a/sql/share/czech/errmsg.txt +++ b/sql/share/czech/errmsg.txt @@ -248,3 +248,4 @@ "This version of MySQL doesn't yet support '%s'", "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 f59abfeb6da..fe2cedb69bb 100644 --- a/sql/share/danish/errmsg.txt +++ b/sql/share/danish/errmsg.txt @@ -242,3 +242,4 @@ "This version of MySQL doesn't yet support '%s'", "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 974b4601ac8..e2e5bd6839c 100644 --- a/sql/share/dutch/errmsg.txt +++ b/sql/share/dutch/errmsg.txt @@ -250,3 +250,4 @@ "Deze versie van MySQL ondersteunt nog geen '%s'", "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 0ce90ac0dab..9d4fd9af41c 100644 --- a/sql/share/english/errmsg.txt +++ b/sql/share/english/errmsg.txt @@ -239,3 +239,4 @@ "This version of MySQL doesn't yet support '%s'", "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/estonian/errmsg.txt b/sql/share/estonian/errmsg.txt index 38b45c1443b..6cbd7249374 100644 --- a/sql/share/estonian/errmsg.txt +++ b/sql/share/estonian/errmsg.txt @@ -244,3 +244,4 @@ "This version of MySQL doesn't yet support '%s'", "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 df2be2803b4..d85ef75bb3a 100644 --- a/sql/share/french/errmsg.txt +++ b/sql/share/french/errmsg.txt @@ -239,3 +239,4 @@ "This version of MySQL doesn't yet support '%s'", "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 cdeab579eca..6258171e34e 100644 --- a/sql/share/german/errmsg.txt +++ b/sql/share/german/errmsg.txt @@ -242,3 +242,4 @@ "This version of MySQL doesn't yet support '%s'", "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 e3778aaac10..e9d812cab0f 100644 --- a/sql/share/greek/errmsg.txt +++ b/sql/share/greek/errmsg.txt @@ -239,3 +239,4 @@ "This version of MySQL doesn't yet support '%s'", "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 85ea5c2e742..5390511ba74 100644 --- a/sql/share/hungarian/errmsg.txt +++ b/sql/share/hungarian/errmsg.txt @@ -241,3 +241,4 @@ "This version of MySQL doesn't yet support '%s'", "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 3be8058661a..cf094da76d2 100644 --- a/sql/share/italian/errmsg.txt +++ b/sql/share/italian/errmsg.txt @@ -239,3 +239,4 @@ "Questa versione di MySQL non supporta ancora '%s'", "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 f99d262a689..89a770d0be8 100644 --- a/sql/share/japanese/errmsg.txt +++ b/sql/share/japanese/errmsg.txt @@ -241,3 +241,4 @@ "This version of MySQL doesn't yet support '%s'", "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 2a7e03b026d..f808a7f0f5d 100644 --- a/sql/share/korean/errmsg.txt +++ b/sql/share/korean/errmsg.txt @@ -239,3 +239,4 @@ "This version of MySQL doesn't yet support '%s'", "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 e6ec84e98a0..4a8207bebff 100644 --- a/sql/share/norwegian-ny/errmsg.txt +++ b/sql/share/norwegian-ny/errmsg.txt @@ -241,3 +241,4 @@ "This version of MySQL doesn't yet support '%s'", "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 fe379261151..e441ef3e3fc 100644 --- a/sql/share/norwegian/errmsg.txt +++ b/sql/share/norwegian/errmsg.txt @@ -241,3 +241,4 @@ "This version of MySQL doesn't yet support '%s'", "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 a300dc1e2ab..4429a187599 100644 --- a/sql/share/polish/errmsg.txt +++ b/sql/share/polish/errmsg.txt @@ -243,3 +243,4 @@ "This version of MySQL doesn't yet support '%s'", "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 89af701f21a..bdb721d9e94 100644 --- a/sql/share/portuguese/errmsg.txt +++ b/sql/share/portuguese/errmsg.txt @@ -239,3 +239,4 @@ "Esta versão de MySQL não suporta ainda '%s'", "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 bf1306cd332..49524349087 100644 --- a/sql/share/romanian/errmsg.txt +++ b/sql/share/romanian/errmsg.txt @@ -243,3 +243,4 @@ "This version of MySQL doesn't yet support '%s'", "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 03964efb26b..03e6874549e 100644 --- a/sql/share/russian/errmsg.txt +++ b/sql/share/russian/errmsg.txt @@ -241,3 +241,4 @@ "üÔÁ ×ÅÒÓÉÑ MySQL ÐÏËÁ ÅÝÅ ÎÅ ÐÏÄÄÅÒÖÉ×ÁÅÔ '%s'", "ðÏÌÕÞÅÎÁ ÎÅÉÓÐÒÁ×ÉÍÁÑ ÏÛÉÂËÁ %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 b9970465871..31bdd40dd62 100644 --- a/sql/share/slovak/errmsg.txt +++ b/sql/share/slovak/errmsg.txt @@ -247,3 +247,4 @@ "This version of MySQL doesn't yet support '%s'", "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 acb0b9fd2ab..0068b3a6e12 100644 --- a/sql/share/spanish/errmsg.txt +++ b/sql/share/spanish/errmsg.txt @@ -240,3 +240,4 @@ "Esta versión de MySQL no soporta todavia '%s'", "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 32eec834ed1..5ecb7962aed 100644 --- a/sql/share/swedish/errmsg.txt +++ b/sql/share/swedish/errmsg.txt @@ -239,3 +239,4 @@ "Denna version av MySQL kan ännu inte utföra '%s'", "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 c0931ab9f02..a5f94e90d6a 100644 --- a/sql/share/ukrainian/errmsg.txt +++ b/sql/share/ukrainian/errmsg.txt @@ -244,3 +244,4 @@ "This version of MySQL doesn't yet support '%s'", "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 cb12a8b827672c92a9ed7eb1589996856fcea1b4 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 19 Dec 2003 23:08:20 +0100 Subject: [PATCH 006/113] do not put --user into command line if the value comes from [mysqld] or [server] sections Bug #2163 --- scripts/mysqld_safe.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index ece4ba098f4..5d77863c9b4 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -46,8 +46,9 @@ parse_arguments() { --user=*) if test $SET_USER -eq 0 then - user=`echo "$arg" | sed -e "s;--[^=]*=;;"` ; SET_USER=1 + user=`echo "$arg" | sed -e "s;--[^=]*=;;"` fi + SET_USER=1 ;; # these two might have been set in a [mysqld_safe] section of my.cnf @@ -129,7 +130,6 @@ fi # these rely on $DATADIR by default, so we'll set them later on pid_file= err_log= -SET_USER=0 # Get first arguments from the my.cnf file, groups [mysqld] and [mysqld_safe] # and then merge with the command line arguments @@ -147,7 +147,13 @@ else fi args= -parse_arguments `$print_defaults --loose-verbose $defaults mysqld server mysqld_safe safe_mysqld` +SET_USER=2 +parse_arguments `$print_defaults --loose-verbose $defaults mysqld server` +if test $SET_USER -eq 2 +then + SET_USER=0 +fi +parse_arguments `$print_defaults --loose-verbose $defaults mysqld_safe safe_mysqld` parse_arguments PICK-ARGS-FROM-ARGV "$@" if test ! -x $ledir/$MYSQLD From 1f9763c169a5c15da350f18a9a2d494fa14a8d98 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 21 Dec 2003 16:32:32 +0200 Subject: [PATCH 007/113] Removed some test that was not relevant for MySQL (and which caused problems in MySQL 4.1) --- sql/filesort.cc | 51 +++++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/sql/filesort.cc b/sql/filesort.cc index 1d30c23a15e..439a72c42e4 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -51,17 +51,38 @@ static int merge_index(SORTPARAM *param,uchar *sort_buffer, static bool save_index(SORTPARAM *param,uchar **sort_keys, uint count); static uint sortlength(SORT_FIELD *sortorder,uint length); - /* - Creates a set of pointers that can be used to read the rows - in sorted order. This should be done with the functions - in records.cc +/* + Sort a table - Before calling filesort, one must have done - table->file->info(HA_STATUS_VARIABLE) + SYNOPSIS + filesort() + table Table to sort + sortorder How to sort the table + s_length Number of elements in sortorder + select condition to apply to the rows + special Not used. + (This could be used to sort the rows pointed on by + select->file) + examined_rows Store number of examined rows here - The result set is stored in table->io_cache or - table->record_pointers - */ + IMPLEMENTATION + Creates a set of pointers that can be used to read the rows + in sorted order. This should be done with the functions + in records.cc + + REQUIREMENTS + Before calling filesort, one must have done + table->file->info(HA_STATUS_VARIABLE) + + RETURN + HA_POS_ERROR Error + # Number of rows + + examined_rows will be set to number of examined rows + + The result set is stored in table->io_cache or + table->record_pointers +*/ ha_rows filesort(TABLE *table, SORT_FIELD *sortorder, uint s_length, SQL_SELECT *select, ha_rows special, ha_rows max_rows, @@ -127,8 +148,6 @@ ha_rows filesort(TABLE *table, SORT_FIELD *sortorder, uint s_length, records=table->file->estimate_number_of_rows(); selected_records_file= 0; } - if (param.sort_length == param.ref_length && records > param.max_rows) - records=param.max_rows; /* purecov: inspected */ #ifdef USE_STRCOLL if (use_strcoll(default_charset_info) && @@ -372,16 +391,6 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, if (write_keys(param,sort_keys,idx,buffpek_pointers,tempfile)) DBUG_RETURN(HA_POS_ERROR); idx=0; - if (param->ref_length == param->sort_length && - my_b_tell(tempfile)/param->sort_length >= param->max_rows) - { - /* - We are writing the result index file and have found all - rows that we need. Abort the sort and return the result. - */ - error=HA_ERR_END_OF_FILE; - break; /* Found enough records */ - } indexpos++; } make_sortkey(param,sort_keys[idx++],ref_pos); From 76a36815dff4e094131db5caebe6bf1eb97b396e Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 22 Dec 2003 13:03:23 +0100 Subject: [PATCH 008/113] typos fixed --- sql/mysqld.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index a4e59c399e5..103917249c9 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -4955,7 +4955,8 @@ static void fix_paths(void) if (!lower_case_table_names && test_if_case_insensitive(mysql_real_data_home) == 1) { - sql_print_error("Warning: Setting lower_case_table_names=1 becasue file system %s is case insensitve", mysql_real_data_home); + sql_print_error("Warning: Setting lower_case_table_names=1 because file system %s is case insensitive", mysql_real_data_home); + lower_case_table_names=1; } } @@ -4964,7 +4965,7 @@ static void fix_paths(void) set how many open files we want to be able to handle SYNOPSIS - set_maximum_open_files() + set_maximum_open_files() max_file_limit Files to open NOTES From 9cd4e65081dadd69fd5cc7e12a6a9786d657c681 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 22 Dec 2003 14:56:06 +0100 Subject: [PATCH 009/113] - marked /etc/logrotate.d/mysql as a config file in the RPM spec file (BUG#2156) support-files/mysql.spec.sh: - marked /etc/logrotate.d/mysql as a config file (BUG#2156) --- support-files/mysql.spec.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index e1c3476f738..e25a8a40c71 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -493,7 +493,7 @@ fi %attr(755, root, root) %{_sbindir}/rcmysql %attr(644, root, root) %{_libdir}/mysql/mysqld.sym -%attr(644, root, root) %{_sysconfdir}/logrotate.d/mysql +%attr(644, root, root) %config(noreplace,missingok) %{_sysconfdir}/logrotate.d/mysql %attr(755, root, root) %{_sysconfdir}/init.d/mysql %attr(755, root, root) %{_datadir}/mysql/ @@ -572,6 +572,10 @@ fi # The spec file changelog only includes changes made to the spec file # itself %changelog +* Mon Dec 22 2003 Lenz Grimmer + +- marked /etc/logrotate.d/mysql as a config file (BUG 2156) + * Fri Dec 13 2003 Lenz Grimmer - fixed file permissions (BUG 1672) From 8e139ddc336c75d155dd3e505d1ff7262822d7ac Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 23 Dec 2003 16:51:14 +0100 Subject: [PATCH 010/113] - Fixed another missing space --- Build-tools/Do-rpm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Build-tools/Do-rpm b/Build-tools/Do-rpm index a216a3ba5dc..3473bcb1f5f 100755 --- a/Build-tools/Do-rpm +++ b/Build-tools/Do-rpm @@ -188,7 +188,7 @@ $command.= basename($SPECFILE); # $command= "mv"; $command.= " -v " if ($opt_verbose); -$command.= "$SRCRPMDIR/MySQL*$VERSION*.src.rpm $PWD"; +$command.= " $SRCRPMDIR/MySQL*$VERSION*.src.rpm $PWD"; &logger("Moving source RPM to current dir."); &run_command($command, "Error moving source RPM!"); From 06f7d70ba6d457139cf0587f6dc90e874391cf92 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 23 Dec 2003 22:55:38 +0200 Subject: [PATCH 011/113] log0log.c: Do not assert in log0log.c, line 856 if ib_logfiles are too small for innodb_thread_concurrency. Instead, print instructions how to adjust my.cnf and call exit(1). innobase/log/log0log.c: Do not assert in log0log.c, line 856 if ib_logfiles are too small for innodb_thread_concurrency. Instead, print instructions how to adjust my.cnf and call exit(1). --- innobase/log/log0log.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/innobase/log/log0log.c b/innobase/log/log0log.c index 1c7a79525e3..5df63e39296 100644 --- a/innobase/log/log0log.c +++ b/innobase/log/log0log.c @@ -661,7 +661,18 @@ failure: if (!success) { fprintf(stderr, -"InnoDB: Error: log file group too small for innodb_thread_concurrency\n"); +"InnoDB: Error: ib_logfiles are too small for innodb_thread_concurrency %lu.\n" +"InnoDB: The combined size of ib_logfiles should be bigger than\n" +"InnoDB: 200 kB * innodb_thread_concurrency.\n" +"InnoDB: To get mysqld to start up, set innodb_thread_concurrency in my.cnf\n" +"InnoDB: to a lower value, for example, to 8. After an ERROR-FREE shutdown\n" +"InnoDB: of mysqld you can adjust the size of ib_logfiles, as explained in\n" +"InnoDB: section 5 of http://www.innodb.com/ibman.php", + (ulong)srv_thread_concurrency); + fprintf(stderr, +"InnoDB: Cannot continue operation. Calling exit(1).\n"); + + exit(1); } return(success); From 02b5c69a9f6fb20068d0ed7df62140b2f9d5097d Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 24 Dec 2003 17:01:48 +0400 Subject: [PATCH 012/113] ctype-big5.c: Like did not work in some cases , strings/ctype-big5.c: Like did not work in some cases , BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted --- BitKeeper/etc/logging_ok | 1 + strings/ctype-big5.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 386ab8a0e49..5cf95b9fc2a 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -9,6 +9,7 @@ akishkin@work.mysql.com arjen@co3064164-a.bitbike.com arjen@fred.bitbike.com arjen@george.bitbike.com +bar@bar.intranet.mysql.r18.ru bar@bar.mysql.r18.ru bar@bar.udmsearch.izhnet.ru bell@laptop.sanja.is.com.ua diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c index 44f8a100897..1f82c844a50 100644 --- a/strings/ctype-big5.c +++ b/strings/ctype-big5.c @@ -356,7 +356,7 @@ my_bool my_like_range_big5(const char *ptr,uint ptr_length,pchar escape, *min_length= (uint) (min_str-min_org); *max_length= res_length; do { - *min_str++ = '\0'; /* Because if key compression */ + *min_str++ = ' '; /* Because if key compression */ *max_str++ = max_sort_char; } while (min_str != min_end); return 0; From 376fb08072e00c6be932b5c38ff6e23288e81e50 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 30 Dec 2003 13:14:21 +0200 Subject: [PATCH 013/113] Some small portability fixes. Added support for lower_case_table_names=2, which is to be used on case insensitive file systems. This tells MySQL to preserve the used case of filenames and database names to make it esier to move files between cases sensitive can case insensitive file systems (like Windows and Linux) client/mysqltest.c: Indentation cleanup include/myisam.h: Made some pointers 'const' mysql-test/mysql-test-run.sh: Portability fix for OSX sql/filesort.cc: Safety fix (not needed for current code but needed for 5.0) sql/ha_berkeley.cc: More debugging Changed 'create' to return error number sql/ha_berkeley.h: Added HA_FILE_BASED sql/ha_innodb.cc: Added missing DBUG_RETURN sql/ha_isam.cc: Changed create to return error number sql/ha_isam.h: Added HA_FILE_BASED sql/ha_isammrg.h: Added HA_FILE_BASED sql/ha_myisam.cc: Changed create to return error number sql/ha_myisam.h: Added HA_FILE_BASED sql/ha_myisammrg.cc: Changed create to return error number sql/ha_myisammrg.h: Added HA_FILE_BASED sql/handler.cc: Ensure that table engines gets table names in lower case even if we are using lower_case_table_names Removed test for DB_TYPE_INNODB by ensuring that create method returns error number. sql/handler.h: Added HA_FILE_BASED Made some struct entries 'const' Added 'alias' for create to be able to create tables in mixed case on case insensitive file systems sql/mysql_priv.h: Support for lower_case_table_names=2 sql/mysqld.cc: Support for lower_case_table_names=2 Moved test of case insenstive file system after all mutex are created sql/set_var.cc: Support for lower_case_table_names=2 sql/sql_class.h: Indentation change sql/sql_db.cc: Support for lower_case_table_names=2 sql/sql_insert.cc: Indentation change sql/sql_parse.cc: Support for lower_case_table_names=2 sql/sql_rename.cc: Support for lower_case_table_names=2 Added missing 'unpack_filename' to RENAME which may fix a bug in RENAME TABLE on windows sql/sql_show.cc: If lower_case_table_name=2 is given, show original case in SHOW CREATE TABLE sql/sql_table.cc: Support for lower_case_table_names=2 for DROP TABLE, RENAME TABLE, ALTER TABLE and CREATE TABLE --- client/mysqltest.c | 8 +- include/myisam.h | 2 +- mysql-test/mysql-test-run.sh | 3 +- mysql-test/r/lowercase2.require | 2 + mysql-test/r/lowercase_table2.result | 108 +++++++++++++++++++++++ mysql-test/t/lowercase_table2-master.opt | 1 + mysql-test/t/lowercase_table2.test | 80 +++++++++++++++++ sql/filesort.cc | 1 + sql/ha_berkeley.cc | 34 +++---- sql/ha_berkeley.h | 9 +- sql/ha_innodb.cc | 2 +- sql/ha_isam.cc | 2 +- sql/ha_isam.h | 2 +- sql/ha_isammrg.h | 2 +- sql/ha_myisam.cc | 5 +- sql/ha_myisam.h | 3 +- sql/ha_myisammrg.cc | 4 +- sql/ha_myisammrg.h | 2 +- sql/handler.cc | 30 ++++--- sql/handler.h | 9 +- sql/mysql_priv.h | 9 +- sql/mysqld.cc | 36 ++++---- sql/set_var.cc | 2 +- sql/sql_class.h | 10 +-- sql/sql_db.cc | 29 ++++-- sql/sql_insert.cc | 4 +- sql/sql_parse.cc | 42 +++++---- sql/sql_rename.cc | 26 ++++-- sql/sql_show.cc | 4 +- sql/sql_table.cc | 85 +++++++++++------- 30 files changed, 421 insertions(+), 135 deletions(-) create mode 100644 mysql-test/r/lowercase2.require create mode 100644 mysql-test/r/lowercase_table2.result create mode 100644 mysql-test/t/lowercase_table2-master.opt create mode 100644 mysql-test/t/lowercase_table2.test diff --git a/client/mysqltest.c b/client/mysqltest.c index e3aa78c05df..13f575eaf0a 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -440,10 +440,10 @@ static void free_used_memory() my_free((gptr) (*q),MYF(0)); } for (i=0; i < 10; i++) - { - if (var_reg[i].alloced_len) - my_free(var_reg[i].str_val, MYF(MY_WME)); - } + { + if (var_reg[i].alloced_len) + my_free(var_reg[i].str_val, MYF(MY_WME)); + } while (embedded_server_arg_count > 1) my_free(embedded_server_args[--embedded_server_arg_count],MYF(0)); delete_dynamic(&q_lines); diff --git a/include/myisam.h b/include/myisam.h index 11dae5f59ba..87a40b50c73 100644 --- a/include/myisam.h +++ b/include/myisam.h @@ -91,7 +91,7 @@ typedef struct st_mi_isaminfo /* Struct from h_info */ typedef struct st_mi_create_info { - char *index_file_name, *data_file_name; /* If using symlinks */ + const char *index_file_name, *data_file_name; /* If using symlinks */ ha_rows max_rows; ha_rows reloc_rows; ulonglong auto_increment; diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index a298701dc7f..5b39b167d7d 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -182,7 +182,8 @@ MY_LOG_DIR="$MYSQL_TEST_DIR/var/log" # Set LD_LIBRARY_PATH if we are using shared libraries # LD_LIBRARY_PATH="$BASEDIR/lib:$BASEDIR/libmysql/.libs:$LD_LIBRARY_PATH" -export LD_LIBRARY_PATH +DYLD_LIBRARY_PATH="$BASEDIR/lib:$BASEDIR/libmysql/.libs:$DYLD_LIBRARY_PATH" +export LD_LIBRARY_PATH DYLD_LIBRARY_PATH MASTER_RUNNING=0 MASTER_MYPORT=9306 diff --git a/mysql-test/r/lowercase2.require b/mysql-test/r/lowercase2.require new file mode 100644 index 00000000000..522eac63e81 --- /dev/null +++ b/mysql-test/r/lowercase2.require @@ -0,0 +1,2 @@ +Variable_name Value +lower_case_table_names 2 diff --git a/mysql-test/r/lowercase_table2.result b/mysql-test/r/lowercase_table2.result new file mode 100644 index 00000000000..e582978c126 --- /dev/null +++ b/mysql-test/r/lowercase_table2.result @@ -0,0 +1,108 @@ +DROP TABLE IF EXISTS t1,t2,T1,T2,t3,T3; +DROP DATABASE IF EXISTS `TEST_$1`; +DROP DATABASE IF EXISTS `test_$1`; +CREATE TABLE T1 (a int); +INSERT INTO T1 VALUES (1); +SHOW TABLES LIKE "T1"; +Tables_in_test (T1) +T1 +SHOW TABLES LIKE "t1"; +Tables_in_test (t1) +T1 +SHOW CREATE TABLE T1; +Table Create Table +T1 CREATE TABLE `T1` ( + `a` int(11) default NULL +) TYPE=MyISAM +RENAME TABLE T1 TO T2; +SHOW TABLES LIKE "T2"; +Tables_in_test (T2) +T2 +SELECT * FROM t2; +a +1 +RENAME TABLE T2 TO t3; +SHOW TABLES LIKE "T3"; +Tables_in_test (T3) +t3 +RENAME TABLE T3 TO T1; +SHOW TABLES LIKE "T1"; +Tables_in_test (T1) +T1 +ALTER TABLE T1 add b int; +SHOW TABLES LIKE "T1"; +Tables_in_test (T1) +t1 +ALTER TABLE T1 RENAME T2; +SHOW TABLES LIKE "T2"; +Tables_in_test (T2) +T2 +LOCK TABLE T2 WRITE; +ALTER TABLE T2 drop b; +SHOW TABLES LIKE "T2"; +Tables_in_test (T2) +t2 +UNLOCK TABLES; +RENAME TABLE T2 TO T1; +SHOW TABLES LIKE "T1"; +Tables_in_test (T1) +T1 +SELECT * from T1; +a +1 +DROP TABLE T1; +CREATE DATABASE `TEST_$1`; +SHOW DATABASES LIKE "TEST%"; +Database (TEST%) +TEST_$1 +DROP DATABASE `test_$1`; +CREATE TABLE T1 (a int) engine=innodb; +INSERT INTO T1 VALUES (1); +SHOW TABLES LIKE "T1"; +Tables_in_test (T1) +T1 +SHOW TABLES LIKE "t1"; +Tables_in_test (t1) +T1 +SHOW CREATE TABLE T1; +Table Create Table +T1 CREATE TABLE `T1` ( + `a` int(11) default NULL +) TYPE=InnoDB +RENAME TABLE T1 TO T2; +SHOW TABLES LIKE "T2"; +Tables_in_test (T2) +t2 +SELECT * FROM t2; +a +1 +RENAME TABLE T2 TO t3; +SHOW TABLES LIKE "T3"; +Tables_in_test (T3) +t3 +RENAME TABLE T3 TO T1; +SHOW TABLES LIKE "T1"; +Tables_in_test (T1) +t1 +ALTER TABLE T1 add b int; +SHOW TABLES LIKE "T1"; +Tables_in_test (T1) +t1 +ALTER TABLE T1 RENAME T2; +SHOW TABLES LIKE "T2"; +Tables_in_test (T2) +t2 +LOCK TABLE T2 WRITE; +ALTER TABLE T2 drop b; +SHOW TABLES LIKE "T2"; +Tables_in_test (T2) +t2 +UNLOCK TABLES; +RENAME TABLE T2 TO T1; +SHOW TABLES LIKE "T1"; +Tables_in_test (T1) +t1 +SELECT * from T1; +a +1 +DROP TABLE T1; diff --git a/mysql-test/t/lowercase_table2-master.opt b/mysql-test/t/lowercase_table2-master.opt new file mode 100644 index 00000000000..9b27aef9bf8 --- /dev/null +++ b/mysql-test/t/lowercase_table2-master.opt @@ -0,0 +1 @@ +--lower_case_table_names=0 diff --git a/mysql-test/t/lowercase_table2.test b/mysql-test/t/lowercase_table2.test new file mode 100644 index 00000000000..86bb26f0cf9 --- /dev/null +++ b/mysql-test/t/lowercase_table2.test @@ -0,0 +1,80 @@ +# +# Test of --lower-case-table-names=2 +# (User has case insensitive file system and want's to preserve case of +# table names) +# +--source include/have_innodb.inc +--require r/lowercase2.require +disable_query_log; +show variables like "lower_case_table_names"; +enable_query_log; + +--disable_warnings +DROP TABLE IF EXISTS t1,t2,T1,T2,t3,T3; +DROP DATABASE IF EXISTS `TEST_$1`; +DROP DATABASE IF EXISTS `test_$1`; +--enable_warnings + +CREATE TABLE T1 (a int); +INSERT INTO T1 VALUES (1); +SHOW TABLES LIKE "T1"; +SHOW TABLES LIKE "t1"; +SHOW CREATE TABLE T1; +RENAME TABLE T1 TO T2; +SHOW TABLES LIKE "T2"; +SELECT * FROM t2; +RENAME TABLE T2 TO t3; +SHOW TABLES LIKE "T3"; +RENAME TABLE T3 TO T1; +SHOW TABLES LIKE "T1"; +ALTER TABLE T1 add b int; +SHOW TABLES LIKE "T1"; +ALTER TABLE T1 RENAME T2; +SHOW TABLES LIKE "T2"; + +LOCK TABLE T2 WRITE; +ALTER TABLE T2 drop b; +SHOW TABLES LIKE "T2"; +UNLOCK TABLES; +RENAME TABLE T2 TO T1; +SHOW TABLES LIKE "T1"; +SELECT * from T1; +DROP TABLE T1; + +# +# Test database level +# + +CREATE DATABASE `TEST_$1`; +SHOW DATABASES LIKE "TEST%"; +DROP DATABASE `test_$1`; + +# +# Test of innodb tables with lower_case_table_names=2 +# + +CREATE TABLE T1 (a int) engine=innodb; +INSERT INTO T1 VALUES (1); +SHOW TABLES LIKE "T1"; +SHOW TABLES LIKE "t1"; +SHOW CREATE TABLE T1; +RENAME TABLE T1 TO T2; +SHOW TABLES LIKE "T2"; +SELECT * FROM t2; +RENAME TABLE T2 TO t3; +SHOW TABLES LIKE "T3"; +RENAME TABLE T3 TO T1; +SHOW TABLES LIKE "T1"; +ALTER TABLE T1 add b int; +SHOW TABLES LIKE "T1"; +ALTER TABLE T1 RENAME T2; +SHOW TABLES LIKE "T2"; + +LOCK TABLE T2 WRITE; +ALTER TABLE T2 drop b; +SHOW TABLES LIKE "T2"; +UNLOCK TABLES; +RENAME TABLE T2 TO T1; +SHOW TABLES LIKE "T1"; +SELECT * from T1; +DROP TABLE T1; diff --git a/sql/filesort.cc b/sql/filesort.cc index 439a72c42e4..ae6895b26b9 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -759,6 +759,7 @@ int merge_buffers(SORTPARAM *param, IO_CACHE *from_file, sort_length)); if (error == -1) goto err; /* purecov: inspected */ + buffpek->max_keys= buffpek->mem_count; // If less data in buffers than expected queue_insert(&queue,(byte*) buffpek); } diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc index 6796a9c3306..15eb7fc72c6 100644 --- a/sql/ha_berkeley.cc +++ b/sql/ha_berkeley.cc @@ -544,7 +544,10 @@ int ha_berkeley::open(const char *name, int mode, uint test_if_locked) (*ptr)->set_bt_compare(*ptr, berkeley_cmp_packed_key); (*ptr)->app_private= (void*) (table->key_info+i); if (!(table->key_info[i].flags & HA_NOSAME)) + { + DBUG_PRINT("bdb",("Setting DB_DUP for key %u", i)); (*ptr)->set_flags(*ptr, DB_DUP); + } if ((error=((*ptr)->open(*ptr, name_buff, part, DB_BTREE, open_mode, 0)))) { @@ -1635,8 +1638,9 @@ void ha_berkeley::info(uint flag) share->rec_per_key[i]; } } - else if (flag & HA_STATUS_ERRKEY) - errkey=last_dup_key; + /* Don't return key if we got an error for the internal primary key */ + if (flag & HA_STATUS_ERRKEY && last_dup_key < table->keys) + errkey= last_dup_key; DBUG_VOID_RETURN; } @@ -1834,7 +1838,7 @@ static int create_sub_table(const char *table_name, const char *sub_name, int error; DB *file; DBUG_ENTER("create_sub_table"); - DBUG_PRINT("enter",("sub_name: %s",sub_name)); + DBUG_PRINT("enter",("sub_name: %s flags: %d",sub_name, flags)); if (!(error=db_create(&file, db_env, 0))) { @@ -1866,14 +1870,14 @@ int ha_berkeley::create(const char *name, register TABLE *form, char name_buff[FN_REFLEN]; char part[7]; uint index=1; - int error=1; + int error; DBUG_ENTER("ha_berkeley::create"); fn_format(name_buff,name,"", ha_berkeley_ext,2 | 4); /* Create the main table that will hold the real rows */ - if (create_sub_table(name_buff,"main",DB_BTREE,0)) - DBUG_RETURN(1); /* purecov: inspected */ + if ((error= create_sub_table(name_buff,"main",DB_BTREE,0))) + DBUG_RETURN(error); /* purecov: inspected */ primary_key=table->primary_key; /* Create the keys */ @@ -1882,10 +1886,10 @@ int ha_berkeley::create(const char *name, register TABLE *form, if (i != primary_key) { sprintf(part,"key%02d",index++); - if (create_sub_table(name_buff, part, DB_BTREE, - (table->key_info[i].flags & HA_NOSAME) ? 0 : - DB_DUP)) - DBUG_RETURN(1); /* purecov: inspected */ + if ((error= create_sub_table(name_buff, part, DB_BTREE, + (table->key_info[i].flags & HA_NOSAME) ? 0 : + DB_DUP))) + DBUG_RETURN(error); /* purecov: inspected */ } } @@ -1893,16 +1897,15 @@ int ha_berkeley::create(const char *name, register TABLE *form, /* Is DB_BTREE the best option here ? (QUEUE can't be used in sub tables) */ DB *status_block; - if (!db_create(&status_block, db_env, 0)) + if (!(error=(db_create(&status_block, db_env, 0)))) { - if (!status_block->open(status_block, name_buff, - "status", DB_BTREE, DB_CREATE, 0)) + if (!(error=(status_block->open(status_block, name_buff, + "status", DB_BTREE, DB_CREATE, 0)))) { char rec_buff[4+MAX_KEY*4]; uint length= 4+ table->keys*4; bzero(rec_buff, length); - if (!write_status(status_block, rec_buff, length)) - error=0; + error= write_status(status_block, rec_buff, length); status_block->close(status_block,0); } } @@ -1910,6 +1913,7 @@ int ha_berkeley::create(const char *name, register TABLE *form, } + int ha_berkeley::delete_table(const char *name) { int error; diff --git a/sql/ha_berkeley.h b/sql/ha_berkeley.h index d2dc5e3216d..285bb575699 100644 --- a/sql/ha_berkeley.h +++ b/sql/ha_berkeley.h @@ -88,10 +88,11 @@ class ha_berkeley: public handler public: ha_berkeley(TABLE *table): handler(table), alloc_ptr(0),rec_buff(0), file(0), int_table_flags(HA_REC_NOT_IN_SEQ | - HA_KEYPOS_TO_RNDPOS | HA_LASTKEY_ORDER | - HA_NULL_KEY | HA_BLOB_KEY | HA_NOT_EXACT_COUNT | - HA_PRIMARY_KEY_IN_READ_INDEX | HA_DROP_BEFORE_CREATE | - HA_AUTO_PART_KEY | HA_TABLE_SCAN_ON_INDEX), + HA_KEYPOS_TO_RNDPOS | HA_LASTKEY_ORDER | + HA_NULL_KEY | HA_BLOB_KEY | HA_NOT_EXACT_COUNT | + HA_PRIMARY_KEY_IN_READ_INDEX | HA_DROP_BEFORE_CREATE | + HA_AUTO_PART_KEY | HA_TABLE_SCAN_ON_INDEX | + HA_FILE_BASED), changed_rows(0),last_dup_key((uint) -1),version(0),using_ignore(0) { } diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index beff8c1f515..bcd1130dcdb 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -3394,7 +3394,7 @@ ha_innobase::create( /* The limit probably should be REC_MAX_N_FIELDS - 3 = 1020, but we play safe here */ - return(HA_ERR_TO_BIG_ROW); + DBUG_RETURN(HA_ERR_TO_BIG_ROW); } /* Get the transaction associated with the current thd, or create one diff --git a/sql/ha_isam.cc b/sql/ha_isam.cc index 7371628890f..a93bb25eb77 100644 --- a/sql/ha_isam.cc +++ b/sql/ha_isam.cc @@ -278,7 +278,7 @@ int ha_isam::create(const char *name, register TABLE *form, type=HA_KEYTYPE_BINARY; // Keep compiler happy if (!(recinfo= (N_RECINFO*) my_malloc((form->fields*2+2)*sizeof(N_RECINFO), MYF(MY_WME)))) - DBUG_RETURN(1); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); pos=form->key_info; for (i=0; i < form->keys ; i++, pos++) diff --git a/sql/ha_isam.h b/sql/ha_isam.h index 82a243ef5c0..b573d4b295c 100644 --- a/sql/ha_isam.h +++ b/sql/ha_isam.h @@ -34,7 +34,7 @@ class ha_isam: public handler :handler(table), file(0), int_table_flags(HA_READ_RND_SAME | HA_KEYPOS_TO_RNDPOS | HA_LASTKEY_ORDER | HA_KEY_READ_WRONG_STR | HA_DUPP_POS | - HA_NOT_DELETE_WITH_CACHE) + HA_NOT_DELETE_WITH_CACHE | HA_FILE_BASED) {} ~ha_isam() {} const char *table_type() const { return "ISAM"; } diff --git a/sql/ha_isammrg.h b/sql/ha_isammrg.h index c936a15164a..e5846d20212 100644 --- a/sql/ha_isammrg.h +++ b/sql/ha_isammrg.h @@ -33,7 +33,7 @@ class ha_isammrg: public handler const char *table_type() const { return "MRG_ISAM"; } const char **bas_ext() const; ulong table_flags() const { return (HA_READ_RND_SAME | HA_KEYPOS_TO_RNDPOS | - HA_REC_NOT_IN_SEQ); } + HA_REC_NOT_IN_SEQ | HA_FILE_BASED); } ulong index_flags(uint idx) const { return HA_NOT_READ_PREFIX_LAST; } uint max_record_length() const { return HA_MAX_REC_LENGTH; } diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index 97c002cee52..d630e9774a5 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -1054,9 +1054,10 @@ int ha_myisam::create(const char *name, register TABLE *table_arg, &recinfo,(table_arg->fields*2+2)*sizeof(MI_COLUMNDEF), &keydef, table_arg->keys*sizeof(MI_KEYDEF), &keyseg, - ((table_arg->key_parts + table_arg->keys) * sizeof(MI_KEYSEG)), + ((table_arg->key_parts + table_arg->keys) * + sizeof(MI_KEYSEG)), NullS))) - DBUG_RETURN(1); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); pos=table_arg->key_info; for (i=0; i < table_arg->keys ; i++, pos++) diff --git a/sql/ha_myisam.h b/sql/ha_myisam.h index 215608f8f0a..212850d8f28 100644 --- a/sql/ha_myisam.h +++ b/sql/ha_myisam.h @@ -46,7 +46,8 @@ class ha_myisam: public handler ha_myisam(TABLE *table): handler(table), file(0), int_table_flags(HA_READ_RND_SAME | HA_KEYPOS_TO_RNDPOS | HA_LASTKEY_ORDER | HA_NULL_KEY | HA_CAN_FULLTEXT | HA_CAN_SQL_HANDLER | - HA_DUPP_POS | HA_BLOB_KEY | HA_AUTO_PART_KEY), + HA_DUPP_POS | HA_BLOB_KEY | HA_AUTO_PART_KEY | + HA_FILE_BASED), enable_activate_all_index(1) {} ~ha_myisam() {} diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc index 616248b2cf3..f65c9afc786 100644 --- a/sql/ha_myisammrg.cc +++ b/sql/ha_myisammrg.cc @@ -343,7 +343,7 @@ int ha_myisammrg::create(const char *name, register TABLE *form, if (!(table_names= (char**) sql_alloc((create_info->merge_list.elements+1)* sizeof(char*)))) - DBUG_RETURN(1); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); for (pos=table_names ; tables ; tables=tables->next) { char *table_name; @@ -357,7 +357,7 @@ int ha_myisammrg::create(const char *name, register TABLE *form, my_snprintf(buff,FN_REFLEN,"%s/%s/%s",mysql_real_data_home, tables->db, tables->real_name)); if (!table_name) - DBUG_RETURN(1); + DBUG_RETURN(HA_ERR_OUT_OF_MEM); strcpy(table_name, buff); } else diff --git a/sql/ha_myisammrg.h b/sql/ha_myisammrg.h index dd649fe8fcb..db3c20bede2 100644 --- a/sql/ha_myisammrg.h +++ b/sql/ha_myisammrg.h @@ -36,7 +36,7 @@ class ha_myisammrg: public handler { return (HA_REC_NOT_IN_SEQ | HA_READ_RND_SAME | HA_AUTO_PART_KEY | HA_KEYPOS_TO_RNDPOS | HA_LASTKEY_ORDER | - HA_NULL_KEY | HA_BLOB_KEY); + HA_NULL_KEY | HA_BLOB_KEY | HA_FILE_BASED); } ulong index_flags(uint inx) const { diff --git a/sql/handler.cc b/sql/handler.cc index 56cbddff66b..f0756aceadb 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -584,14 +584,23 @@ bool ha_flush_logs() int ha_delete_table(enum db_type table_type, const char *path) { + char tmp_path[FN_REFLEN]; handler *file=get_new_handler((TABLE*) 0, table_type); if (!file) return ENOENT; + if (lower_case_table_names == 2 && !(file->table_flags() & HA_FILE_BASED)) + { + /* Ensure that table handler get path in lower case */ + strmov(tmp_path, path); + casedn_str(tmp_path); + path= tmp_path; + } int error=file->delete_table(path); delete file; return error; } + void ha_store_ptr(byte *buff, uint pack_length, my_off_t pos) { switch (pack_length) { @@ -1043,6 +1052,7 @@ int ha_create_table(const char *name, HA_CREATE_INFO *create_info, { int error; TABLE table; + char name_buff[FN_REFLEN]; DBUG_ENTER("ha_create_table"); if (openfrm(name,"",0,(uint) READ_ALL, 0, &table)) @@ -1053,19 +1063,19 @@ int ha_create_table(const char *name, HA_CREATE_INFO *create_info, if (table.file->table_flags() & HA_DROP_BEFORE_CREATE) table.file->delete_table(name); // Needed for BDB tables } + if (lower_case_table_names == 2 && + !(table.file->table_flags() & HA_FILE_BASED)) + { + /* Ensure that handler gets name in lower case */ + strmov(name_buff, name); + casedn_str(name_buff); + name= name_buff; + } + error=table.file->create(name,&table,create_info); VOID(closefrm(&table)); if (error) - { - if (table.db_type == DB_TYPE_INNODB) - { - /* Creation of InnoDB table cannot fail because of an OS error: - put error as the number */ - my_error(ER_CANT_CREATE_TABLE,MYF(ME_BELL+ME_WAITTANG),name,error); - } - else - my_error(ER_CANT_CREATE_TABLE,MYF(ME_BELL+ME_WAITTANG),name,my_errno); - } + my_error(ER_CANT_CREATE_TABLE,MYF(ME_BELL+ME_WAITTANG),name,error); DBUG_RETURN(error != 0); } diff --git a/sql/handler.h b/sql/handler.h index 03568e2e070..8e72267c337 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -67,12 +67,14 @@ #define HA_CAN_FULLTEXT (HA_NO_PREFIX_CHAR_KEYS*2) #define HA_CAN_SQL_HANDLER (HA_CAN_FULLTEXT*2) #define HA_NO_AUTO_INCREMENT (HA_CAN_SQL_HANDLER*2) +/* Table data are stored in separate files */ +#define HA_FILE_BASED (HA_NO_AUTO_INCREMENT*2) /* Next record gives next record according last record read (even if database is updated after read). Not used at this point. */ -#define HA_LASTKEY_ORDER (HA_NO_AUTO_INCREMENT*2) +#define HA_LASTKEY_ORDER (HA_FILE_BASED*2) /* bits in index_flags(index_number) for what you can do with index */ @@ -149,8 +151,9 @@ enum enum_tx_isolation { ISO_READ_UNCOMMITTED, ISO_READ_COMMITTED, typedef struct st_ha_create_information { - char *comment,*password; - char *data_file_name, *index_file_name; + const char *comment,*password; + const char *data_file_name, *index_file_name; + const char *alias; ulonglong max_rows,min_rows; ulonglong auto_increment_value; ulong table_options; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index d0e0e6992fa..acb7005c26c 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -696,7 +696,7 @@ extern ulong specialflag, current_pid; extern uint test_flags,select_errors,ha_open_options; extern uint protocol_version,dropping_tables; -extern uint delay_key_write_options; +extern uint delay_key_write_options, lower_case_table_names; extern bool opt_endinfo, using_udf_functions, locked_in_memory; extern bool opt_using_transactions, mysql_embedded; extern bool using_update_log, opt_large_files; @@ -705,7 +705,7 @@ extern bool opt_disable_networking, opt_skip_show_db; extern bool volatile abort_loop, shutdown_in_progress, grant_option; extern uint volatile thread_count, thread_running, global_read_lock; extern my_bool opt_sql_bin_update, opt_safe_user_create, opt_no_mix_types; -extern my_bool opt_safe_show_db, opt_local_infile, lower_case_table_names; +extern my_bool opt_safe_show_db, opt_local_infile; extern my_bool opt_slave_compressed_protocol, use_temp_pool; extern my_bool opt_readonly; extern my_bool opt_enable_named_pipe; @@ -894,3 +894,8 @@ inline void table_case_convert(char * name, uint length) if (lower_case_table_names) casedn(name, length); } + +inline const char *table_case_name(HA_CREATE_INFO *info, const char *name) +{ + return ((lower_case_table_names == 2 && info->alias) ? info->alias : name); +} diff --git a/sql/mysqld.cc b/sql/mysqld.cc index a58f3b973ac..e1c7ecd3e4b 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -290,6 +290,7 @@ bool opt_disable_networking=0, opt_skip_show_db=0; my_bool opt_enable_named_pipe= 0, opt_debugging= 0; my_bool opt_local_infile, opt_external_locking, opt_slave_compressed_protocol; uint delay_key_write_options= (uint) DELAY_KEY_WRITE_ON; +uint lower_case_table_names; static my_bool opt_do_pstack = 0; static ulong opt_specialflag=SPECIAL_ENGLISH; @@ -305,7 +306,7 @@ char* log_error_file_ptr= log_error_file; static pthread_t select_thread; static my_bool opt_noacl=0, opt_bootstrap=0, opt_myisam_log=0; my_bool opt_safe_user_create = 0, opt_no_mix_types = 0; -my_bool lower_case_table_names, opt_old_rpl_compat; +my_bool opt_old_rpl_compat; my_bool opt_show_slave_auth_info, opt_sql_bin_update = 0; my_bool opt_log_slave_updates= 0, opt_console= 0; my_bool opt_readonly = 0; @@ -2097,6 +2098,18 @@ int main(int argc, char **argv) exit(1); charsets_list = list_charsets(MYF(MY_COMPILED_SETS|MY_CONFIG_SETS)); + /* + Ensure that lower_case_table_names is set on system where we have case + insensitive names. If this is not done the users MyISAM tables will + get corrupted if accesses with names of different case. + */ + if (!lower_case_table_names && + test_if_case_insensitive(mysql_real_data_home) == 1) + { + sql_print_error("Warning: Setting lower_case_table_names=2 because file system for %s is case insensitive", mysql_real_data_home); + lower_case_table_names= 2; + } + #ifdef HAVE_OPENSSL if (opt_use_ssl) { @@ -3841,15 +3854,15 @@ replicating a LOAD DATA INFILE command", (gptr*) &max_system_variables.long_query_time, 0, GET_ULONG, REQUIRED_ARG, 10, 1, LONG_TIMEOUT, 0, 1, 0}, {"lower_case_table_names", OPT_LOWER_CASE_TABLE_NAMES, - "If set to 1 table names are stored in lowercase on disk and table names will be case-insensitive.", + "If set to 1 table names are stored in lowercase on disk and table names will be case-insensitive. Should be set to 2 if you are using a case insensitive file system", (gptr*) &lower_case_table_names, - (gptr*) &lower_case_table_names, 0, GET_BOOL, NO_ARG, + (gptr*) &lower_case_table_names, 0, GET_UINT, OPT_ARG, #ifdef FN_NO_CASE_SENCE 1 #else 0 #endif - , 0, 1, 0, 1, 0}, + , 0, 2, 0, 1, 0}, {"max_allowed_packet", OPT_MAX_ALLOWED_PACKET, "Max packetlength to send/receive from to server.", (gptr*) &global_system_variables.max_allowed_packet, @@ -4814,6 +4827,9 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), sf_malloc_quick=1; #endif break; + case OPT_LOWER_CASE_TABLE_NAMES: + lower_case_table_names= argument ? atoi(argument) : 1; + break; } return 0; } @@ -4946,18 +4962,6 @@ static void fix_paths(void) if (!(slave_load_tmpdir = (char*) my_strdup(mysql_tmpdir, MYF(MY_FAE)))) exit(1); } - - /* - Ensure that lower_case_table_names is set on system where we have case - insensitive names. If this is not done the users MyISAM tables will - get corrupted if accesses with names of different case. - */ - if (!lower_case_table_names && - test_if_case_insensitive(mysql_real_data_home) == 1) - { - sql_print_error("Warning: Setting lower_case_table_names=1 becasue file system %s is case insensitive", mysql_real_data_home); - lower_case_table_names= 1; - } } diff --git a/sql/set_var.cc b/sql/set_var.cc index 4aea611e401..70e56825467 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -514,7 +514,7 @@ struct show_var_st init_vars[]= { {sys_log_warnings.name, (char*) &sys_log_warnings, SHOW_SYS}, {sys_long_query_time.name, (char*) &sys_long_query_time, SHOW_SYS}, {sys_low_priority_updates.name, (char*) &sys_low_priority_updates, SHOW_SYS}, - {"lower_case_table_names", (char*) &lower_case_table_names, SHOW_MY_BOOL}, + {"lower_case_table_names", (char*) &lower_case_table_names, SHOW_INT}, {sys_max_allowed_packet.name,(char*) &sys_max_allowed_packet, SHOW_SYS}, {sys_max_binlog_cache_size.name,(char*) &sys_max_binlog_cache_size, SHOW_SYS}, {sys_max_binlog_size.name, (char*) &sys_max_binlog_size, SHOW_SYS}, diff --git a/sql/sql_class.h b/sql/sql_class.h index 632e7b49d9f..f4fc7b4770f 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -732,11 +732,11 @@ class select_create: public select_insert { MYSQL_LOCK *lock; Field **field; public: - select_create (const char *db_name, const char *table_name, - HA_CREATE_INFO *create_info_par, - List &fields_par, - List &keys_par, - List &select_fields,enum_duplicates duplic) + select_create(const char *db_name, const char *table_name, + HA_CREATE_INFO *create_info_par, + List &fields_par, + List &keys_par, + List &select_fields,enum_duplicates duplic) :select_insert (NULL, &select_fields, duplic), db(db_name), name(table_name), extra_fields(&fields_par),keys(&keys_par), create_info(create_info_par), lock(0) diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 6c11067ac8f..3fa3f5b0907 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -116,12 +116,21 @@ const char *known_exts[]= static TYPELIB known_extentions= {array_elements(known_exts)-1,"known_exts", known_exts}; -/* - Drop all tables in a database. - db-name is already validated when we come here - If thd == 0, do not write any messages; This is useful in replication - when we want to remove a stale database before replacing it with the new one +/* + Drop all tables in a database and the database itself + + SYNOPSIS + mysql_rm_db() + thd Thread handle + db Database name in the case given by user + It's already validated when we come here + if_exists Don't give error if database doesn't exists + silent Don't generate errors + + RETURN + 0 ok (Database dropped) + -1 Error generated */ @@ -129,7 +138,7 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) { long deleted=0; int error = 0; - char path[FN_REFLEN+16]; + char path[FN_REFLEN+16], tmp_db[NAME_LEN+1]; MY_DIR *dirp; DBUG_ENTER("mysql_rm_db"); @@ -156,6 +165,14 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) send_ok(&thd->net,0); goto exit; } + if (lower_case_table_names) + { + /* Convert database to lower case */ + strmov(tmp_db, db); + casedn_str(tmp_db); + db= tmp_db; + } + pthread_mutex_lock(&LOCK_open); remove_db_from_cache(db); pthread_mutex_unlock(&LOCK_open); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 75a37e4035c..97b7c1db03d 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1434,8 +1434,8 @@ select_create::prepare(List &values) { DBUG_ENTER("select_create::prepare"); - table=create_table_from_items(thd, create_info, db, name, - extra_fields, keys, &values, &lock); + table= create_table_from_items(thd, create_info, db, name, + extra_fields, keys, &values, &lock); if (!table) DBUG_RETURN(-1); // abort() deletes table diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 5c08127bfdc..608cdd23282 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -59,8 +59,8 @@ static bool check_merge_table_access(THD *thd, char *db, TABLE_LIST *tables); static void mysql_init_query(THD *thd); static void remove_escape(char *name); static void refresh_status(void); -static bool append_file_to_dir(THD *thd, char **filename_ptr, - char *table_name); +static bool append_file_to_dir(THD *thd, const char **filename_ptr, + const char *table_name); static bool create_total_list(THD *thd, LEX *lex, TABLE_LIST **result, bool skip_first); @@ -1121,10 +1121,12 @@ bool dispatch_command(enum enum_server_command command, THD *thd, case COM_CREATE_DB: // QQ: To be removed { + char *db=thd->strdup(packet), *alias; + statistic_increment(com_stat[SQLCOM_CREATE_DB],&LOCK_status); - char *db=thd->strdup(packet); // null test to handle EOM - if (!db || !strip_sp(db) || check_db_name(db)) + if (!db || !strip_sp(db) || !(alias= thd->strdup(db)) || + check_db_name(db)) { net_printf(&thd->net,ER_WRONG_DB_NAME, db ? db : "NULL"); break; @@ -1132,15 +1134,16 @@ bool dispatch_command(enum enum_server_command command, THD *thd, if (check_access(thd,CREATE_ACL,db,0,1)) break; mysql_log.write(thd,command,packet); - mysql_create_db(thd,db,0,0); + mysql_create_db(thd,(lower_case_table_names == 2 ? alias : db),0,0); break; } case COM_DROP_DB: // QQ: To be removed { statistic_increment(com_stat[SQLCOM_DROP_DB],&LOCK_status); - char *db=thd->strdup(packet); + char *db=thd->strdup(packet), *alias; // null test to handle EOM - if (!db || !strip_sp(db) || check_db_name(db)) + if (!db || !strip_sp(db) || !(alias= thd->strdup(db)) || + check_db_name(db)) { net_printf(&thd->net,ER_WRONG_DB_NAME, db ? db : "NULL"); break; @@ -1153,7 +1156,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, break; } mysql_log.write(thd,command,db); - mysql_rm_db(thd,db,0,0); + mysql_rm_db(thd,alias,0,0); break; } case COM_BINLOG_DUMP: @@ -1599,6 +1602,7 @@ mysql_execute_command(void) CREATE_TMP_ACL : CREATE_ACL); if (!tables->db) tables->db=thd->db; + lex->create_info.alias= tables->alias; if (check_access(thd,want_priv,tables->db,&tables->grant.privilege) || check_merge_table_access(thd, tables->db, (TABLE_LIST *) @@ -1664,7 +1668,8 @@ mysql_execute_command(void) if (!(res=open_and_lock_tables(thd,tables->next))) { if ((result=new select_create(tables->db ? tables->db : thd->db, - tables->real_name, &lex->create_info, + tables->real_name, + &lex->create_info, lex->create_list, lex->key_list, select_lex->item_list,lex->duplicates))) @@ -1676,7 +1681,8 @@ mysql_execute_command(void) else // regular create { res = mysql_create_table(thd,tables->db ? tables->db : thd->db, - tables->real_name, &lex->create_info, + tables->real_name, + &lex->create_info, lex->create_list, lex->key_list,0, 0); // do logging if (!res) @@ -2341,7 +2347,9 @@ mysql_execute_command(void) break; case SQLCOM_CREATE_DB: { - if (!strip_sp(lex->name) || check_db_name(lex->name)) + char *alias; + if (!strip_sp(lex->name) || !(alias=thd->strdup(lex->name)) || + check_db_name(lex->name)) { net_printf(&thd->net,ER_WRONG_DB_NAME, lex->name); break; @@ -2363,12 +2371,15 @@ mysql_execute_command(void) if (check_access(thd,CREATE_ACL,lex->name,0,1)) break; - res=mysql_create_db(thd,lex->name,lex->create_info.options,0); + res=mysql_create_db(thd,(lower_case_table_names == 2 ? alias : lex->name), + lex->create_info.options,0); break; } case SQLCOM_DROP_DB: { - if (!strip_sp(lex->name) || check_db_name(lex->name)) + char *alias; + if (!strip_sp(lex->name) || !(alias=thd->strdup(lex->name)) || + check_db_name(lex->name)) { net_printf(&thd->net,ER_WRONG_DB_NAME, lex->name); break; @@ -2394,7 +2405,7 @@ mysql_execute_command(void) send_error(&thd->net,ER_LOCK_OR_ACTIVE_TRANSACTION); goto error; } - res=mysql_rm_db(thd,lex->name,lex->drop_if_exists,0); + res=mysql_rm_db(thd,alias,lex->drop_if_exists,0); break; } case SQLCOM_CREATE_FUNCTION: @@ -3779,7 +3790,8 @@ static void refresh_status(void) /* If pointer is not a null pointer, append filename to it */ -static bool append_file_to_dir(THD *thd, char **filename_ptr, char *table_name) +static bool append_file_to_dir(THD *thd, const char **filename_ptr, + const char *table_name) { char buff[FN_REFLEN],*ptr, *end; if (!*filename_ptr) diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc index 05d31c173d3..c560b96a615 100644 --- a/sql/sql_rename.cc +++ b/sql/sql_rename.cc @@ -112,19 +112,31 @@ rename_tables(THD *thd, TABLE_LIST *table_list, bool skip_error) { db_type table_type; char name[FN_REFLEN]; - new_table=ren_table->next; + const char *new_alias, *old_alias; + new_table=ren_table->next; + if (lower_case_table_names == 2) + { + old_alias= ren_table->alias; + new_alias= new_table->alias; + } + else + { + old_alias= ren_table->real_name; + new_alias= new_table->real_name; + } sprintf(name,"%s/%s/%s%s",mysql_data_home, - new_table->db,new_table->real_name, - reg_ext); + new_table->db, new_alias, reg_ext); + unpack_filename(name, name); if (!access(name,F_OK)) { - my_error(ER_TABLE_EXISTS_ERROR,MYF(0),name); + my_error(ER_TABLE_EXISTS_ERROR,MYF(0),new_alias); DBUG_RETURN(ren_table); // This can't be skipped } sprintf(name,"%s/%s/%s%s",mysql_data_home, - ren_table->db,ren_table->real_name, + ren_table->db, old_alias, reg_ext); + unpack_filename(name, name); if ((table_type=get_table_type(name)) == DB_TYPE_UNKNOWN) { my_error(ER_FILE_NOT_FOUND, MYF(0), name, my_errno); @@ -132,8 +144,8 @@ rename_tables(THD *thd, TABLE_LIST *table_list, bool skip_error) DBUG_RETURN(ren_table); } else if (mysql_rename_table(table_type, - ren_table->db, ren_table->real_name, - new_table->db, new_table->real_name)) + ren_table->db, old_alias, + new_table->db, new_alias)) { if (!skip_error) DBUG_RETURN(ren_table); diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 1a2f900eb7e..d34e2e68067 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -865,7 +865,9 @@ store_create_info(THD *thd, TABLE *table, String *packet) packet->append("CREATE TEMPORARY TABLE ", 23); else packet->append("CREATE TABLE ", 13); - append_identifier(thd,packet,table->real_name); + append_identifier(thd,packet, + (lower_case_table_names == 2 ? table->table_name : + table->real_name)); packet->append(" (\n", 3); for (ptr=table->field ; (field= *ptr); ptr++) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 2833946fe3b..7fa973eb60f 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -163,7 +163,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, bool dont_log_query) { TABLE_LIST *table; - char path[FN_REFLEN]; + char path[FN_REFLEN], *alias; String wrong_tables; db_type table_type; int error; @@ -193,15 +193,12 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, drop_locked_tables(thd,db,table->real_name); if (thd->killed) DBUG_RETURN(-1); - + alias= (lower_case_table_names == 2) ? table->alias : table->real_name; /* remove form file and isam files */ - strxmov(path, mysql_data_home, "/", db, "/", table->real_name, reg_ext, - NullS); + strxmov(path, mysql_data_home, "/", db, "/", alias, reg_ext, NullS); (void) unpack_filename(path,path); error=0; - table_type=get_table_type(path); - if (access(path,F_OK)) { if (!if_exists) @@ -210,7 +207,8 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, else { char *end; - *(end=fn_ext(path))=0; // Remove extension + table_type= get_table_type(path); + *(end=fn_ext(path))=0; // Remove extension for delete error=ha_delete_table(table_type, path); if (error == ENOENT && if_exists) error = 0; @@ -350,7 +348,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, List &keys,bool tmp_table,bool no_log) { char path[FN_REFLEN]; - const char *key_name; + const char *key_name, *alias; create_field *sql_field,*dup_field; int error= -1; uint db_options,field,null_fields,blob_columns; @@ -361,10 +359,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, handler *file; DBUG_ENTER("mysql_create_table"); - /* - ** Check for duplicate fields and check type of table to create - */ - + /* Check for duplicate fields and check type of table to create */ if (!fields.elements) { my_error(ER_TABLE_MUST_HAVE_COLUMNS,MYF(0)); @@ -375,6 +370,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, db_options=create_info->table_options; if (create_info->row_type == ROW_TYPE_DYNAMIC) db_options|=HA_OPTION_PACK_RECORD; + alias= table_case_name(create_info, table_name); file=get_new_handler((TABLE*) 0, create_info->db_type); if ((create_info->options & HA_LEX_CREATE_TMP_TABLE) && @@ -722,7 +718,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, create_info->table_options|=HA_CREATE_DELAY_KEY_WRITE; } else - (void) sprintf(path,"%s/%s/%s%s",mysql_data_home,db,table_name,reg_ext); + (void) sprintf(path,"%s/%s/%s%s",mysql_data_home,db,alias,reg_ext); unpack_filename(path,path); /* Check if table already exists */ if ((create_info->options & HA_LEX_CREATE_TMP_TABLE) @@ -747,7 +743,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, create_info->table_existed= 1; // Mark that table existed DBUG_RETURN(0); } - my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name); + my_error(ER_TABLE_EXISTS_ERROR,MYF(0), alias); DBUG_RETURN(-1); } } @@ -873,7 +869,7 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, DBUG_RETURN(0); if (!(table=open_table(thd,db,name,name,(bool*) 0))) { - quick_rm_table(create_info->db_type,db,name); + quick_rm_table(create_info->db_type,db,table_case_name(create_info,name)); DBUG_RETURN(0); } table->reginfo.lock_type=TL_WRITE; @@ -882,7 +878,7 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, VOID(pthread_mutex_lock(&LOCK_open)); hash_delete(&open_cache,(byte*) table); VOID(pthread_mutex_unlock(&LOCK_open)); - quick_rm_table(create_info->db_type,db,name); + quick_rm_table(create_info->db_type,db,table_case_name(create_info, name)); DBUG_RETURN(0); } table->file->extra(HA_EXTRA_WRITE_CACHE); @@ -897,18 +893,32 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, bool mysql_rename_table(enum db_type base, const char *old_db, - const char * old_name, + const char *old_name, const char *new_db, - const char * new_name) + const char *new_name) { - char from[FN_REFLEN],to[FN_REFLEN]; + char from[FN_REFLEN], to[FN_REFLEN]; + char tmp_from[NAME_LEN+1], tmp_to[NAME_LEN+1]; handler *file=get_new_handler((TABLE*) 0, base); int error=0; DBUG_ENTER("mysql_rename_table"); + + if (lower_case_table_names == 2 && !(file->table_flags() & HA_FILE_BASED)) + { + /* Table handler expects to get all file names as lower case */ + strmov(tmp_from, old_name); + casedn_str(tmp_from); + old_name= tmp_from; + + strmov(tmp_to, new_name); + casedn_str(tmp_to); + new_name= tmp_to; + } (void) sprintf(from,"%s/%s/%s",mysql_data_home,old_db,old_name); (void) sprintf(to,"%s/%s/%s",mysql_data_home,new_db,new_name); fn_format(from,from,"","",4); fn_format(to,to, "","",4); + if (!(error=file->rename_table((const char*) from,(const char *) to))) { if (rename_file_ext(from,to,reg_ext)) @@ -924,6 +934,7 @@ mysql_rename_table(enum db_type base, DBUG_RETURN(error != 0); } + /* Force all other threads to stop using the table @@ -968,7 +979,7 @@ static void wait_while_table_is_used(THD *thd,TABLE *table, Close a cached table SYNOPSIS - clsoe_cached_table() + close_cached_table() thd Thread handler table Table to remove from cache @@ -1446,8 +1457,8 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, { TABLE *table,*new_table; int error; - char tmp_name[80],old_name[32],new_name_buff[FN_REFLEN], - *table_name,*db; + char tmp_name[80],old_name[32],new_name_buff[FN_REFLEN]; + char new_alias_buff[FN_REFLEN], *table_name, *db, *new_alias, *alias; char index_file[FN_REFLEN], data_file[FN_REFLEN]; bool use_timestamp=0; ha_rows copied,deleted; @@ -1458,11 +1469,13 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, thd->proc_info="init"; table_name=table_list->real_name; + alias= (lower_case_table_names == 2) ? table_list->alias : table_name; + db=table_list->db; if (!new_db || !strcmp(new_db,db)) new_db=db; used_fields=create_info->used_fields; - + mysql_ha_closeall(thd, table_list); if (!(table=open_ltable(thd,table_list,TL_WRITE_ALLOW_READ))) DBUG_RETURN(-1); @@ -1471,21 +1484,29 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, if (new_name) { strmov(new_name_buff,new_name); + strmov(new_alias= new_alias_buff, new_name); fn_same(new_name_buff,table_name,3); if (lower_case_table_names) + { + if (lower_case_table_names != 2) + { + casedn_str(new_name_buff); + new_alias= new_name; // Create lower case table name + } casedn_str(new_name); + } if ((lower_case_table_names && !my_strcasecmp(new_name_buff,table_name)) || (!lower_case_table_names && !strcmp(new_name_buff,table_name))) - new_name=table_name; // No. Make later check easier + new_alias= new_name= table_name; // No change. Make later check easier else { if (table->tmp_table) { if (find_temporary_table(thd,new_db,new_name_buff)) { - my_error(ER_TABLE_EXISTS_ERROR,MYF(0),new_name); + my_error(ER_TABLE_EXISTS_ERROR,MYF(0),new_name_buff); DBUG_RETURN(-1); } } @@ -1495,14 +1516,14 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, F_OK)) { /* Table will be closed in do_command() */ - my_error(ER_TABLE_EXISTS_ERROR,MYF(0),new_name); + my_error(ER_TABLE_EXISTS_ERROR,MYF(0), new_alias); DBUG_RETURN(-1); } } } } else - new_name=table_name; + new_alias= new_name= table_name; old_db_type=table->db_type; if (create_info->db_type == DB_TYPE_DEFAULT) @@ -1532,7 +1553,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, { *fn_ext(new_name)=0; close_cached_table(thd, table); - if (mysql_rename_table(old_db_type,db,table_name,new_db,new_name)) + if (mysql_rename_table(old_db_type,db,table_name,new_db,new_alias)) error= -1; } VOID(pthread_mutex_unlock(&LOCK_open)); @@ -1925,7 +1946,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, } /* Remove link to old table and rename the new one */ close_temporary_table(thd,table->table_cache_key,table_name); - if (rename_temporary_table(thd, new_table, new_db, new_name)) + if (rename_temporary_table(thd, new_table, new_db, new_alias)) { // Fatal error close_temporary_table(thd,new_db,tmp_name); my_free((gptr) new_table,MYF(0)); @@ -2001,12 +2022,12 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, VOID(quick_rm_table(new_db_type,new_db,tmp_name)); } else if (mysql_rename_table(new_db_type,new_db,tmp_name,new_db, - new_name)) + new_alias)) { // Try to get everything back error=1; - VOID(quick_rm_table(new_db_type,new_db,new_name)); + VOID(quick_rm_table(new_db_type,new_db,new_alias)); VOID(quick_rm_table(new_db_type,new_db,tmp_name)); - VOID(mysql_rename_table(old_db_type,db,old_name,db,table_name)); + VOID(mysql_rename_table(old_db_type,db,old_name,db,alias)); } if (error) { From 824111e6c4583441719bd6fa431b6aedcab8fff6 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 30 Dec 2003 19:23:38 +0400 Subject: [PATCH 014/113] Fix for the bug #2231: string column, INDEX+LIKE, don't take the ESCAPE character. (acctually i don't like the fix, any suggestions?) --- mysql-test/r/func_like.result | 6 ++++++ mysql-test/t/func_like.test | 9 +++++++++ sql/item_cmpfunc.h | 9 ++++----- sql/opt_range.cc | 11 +++++++---- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/mysql-test/r/func_like.result b/mysql-test/r/func_like.result index f923c16b2ac..0f94348a5f8 100644 --- a/mysql-test/r/func_like.result +++ b/mysql-test/r/func_like.result @@ -37,3 +37,9 @@ select * from t1 where a like "%abc\d%"; a abcd drop table t1; +create table t1 (a varchar(10), key(a)); +insert into t1 values ('a'), ('a\\b'); +select * from t1 where a like 'a\\%' escape '#'; +a +a\b +drop table t1; diff --git a/mysql-test/t/func_like.test b/mysql-test/t/func_like.test index a5d1193fd74..1e14c70a76a 100644 --- a/mysql-test/t/func_like.test +++ b/mysql-test/t/func_like.test @@ -21,3 +21,12 @@ select * from t1 where a like "%abcd%"; select * from t1 where a like "%abc\d%"; drop table t1; + +# +# Bug #2231 +# + +create table t1 (a varchar(10), key(a)); +insert into t1 values ('a'), ('a\\b'); +select * from t1 where a like 'a\\%' escape '#'; +drop table t1; diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 58c7ea8d00d..9f19e7575d5 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -505,8 +505,6 @@ public: class Item_func_like :public Item_bool_func2 { - char escape; - // Turbo Boyer-Moore data bool canDoTurboBM; // pattern is '%abcd%' case const char* pattern; @@ -523,10 +521,11 @@ class Item_func_like :public Item_bool_func2 enum { alphabet_size = 256 }; public: + char escape; + Item_func_like(Item *a,Item *b, char* escape_arg) - :Item_bool_func2(a,b), escape(*escape_arg), canDoTurboBM(false), - pattern(0), pattern_len(0), bmGs(0), bmBc(0) - {} + :Item_bool_func2(a,b), canDoTurboBM(false), pattern(0), pattern_len(0), + bmGs(0), bmBc(0), escape(*escape_arg) {} longlong val_int(); enum Functype functype() const { return LIKE_FUNC; } optimize_type select_optimize() const; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 7e5ca50d349..c918635b61f 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -290,6 +290,7 @@ typedef struct st_qsel_param { char min_key[MAX_KEY_LENGTH+MAX_FIELD_WIDTH], max_key[MAX_KEY_LENGTH+MAX_FIELD_WIDTH]; bool quick; // Don't calulate possible keys + char escape; } PARAM; static SEL_TREE * get_mm_parts(PARAM *param,Field *field, @@ -637,7 +638,9 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, param.table=head; param.keys=0; param.mem_root= &alloc; - + if (cond->type() == Item::FUNC_ITEM && + ((Item_func*)cond)->functype() == Item_func::LIKE_FUNC) + param.escape= ((Item_func_like*)cond)->escape; param.thd->no_errors=1; // Don't warn about NULL init_sql_alloc(&alloc, param.thd->variables.range_alloc_block_size, 0); if (!(param.key_parts = (KEY_PART*) alloc_root(&alloc, @@ -994,7 +997,7 @@ get_mm_leaf(PARAM *param, Field *field, KEY_PART *key_part, if (maybe_null) max_str[0]= min_str[0]=0; if (field->binary()) - like_error=like_range(res->ptr(),res->length(),wild_prefix,field_length, + like_error=like_range(res->ptr(),res->length(),param->escape,field_length, min_str+offset,max_str+offset,(char) 255, &min_length,&max_length); else @@ -1002,12 +1005,12 @@ get_mm_leaf(PARAM *param, Field *field, KEY_PART *key_part, #ifdef USE_STRCOLL if (use_strcoll(default_charset_info)) like_error= my_like_range(default_charset_info, - res->ptr(),res->length(),wild_prefix, + res->ptr(),res->length(),param->escape, field_length, min_str+maybe_null, max_str+maybe_null,&min_length,&max_length); else #endif - like_error=like_range(res->ptr(),res->length(),wild_prefix, + like_error=like_range(res->ptr(),res->length(),param->escape, field_length, min_str+offset,max_str+offset, max_sort_char,&min_length,&max_length); From 7219513743ec021216f8ad81dc8e80607d431769 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 6 Jan 2004 13:40:14 +0200 Subject: [PATCH 015/113] trx0sys.c, srv0start.c, ibuf0ibuf.c, trx0sys.h, srv0srv.h: DO NOT MERGE TO 4.1: add code for automatic downgrade 4.1.1 -> 4.0 if the user has not created multiple tablespaces yet innobase/include/srv0srv.h: DO NOT MERGE TO 4.1: add code for automatic downgrade 4.1.1 -> 4.0 if the user has not created multiple tablespaces yet innobase/include/trx0sys.h: DO NOT MERGE TO 4.1: add code for automatic downgrade 4.1.1 -> 4.0 if the user has not created multiple tablespaces yet innobase/ibuf/ibuf0ibuf.c: DO NOT MERGE TO 4.1: add code for automatic downgrade 4.1.1 -> 4.0 if the user has not created multiple tablespaces yet innobase/srv/srv0start.c: DO NOT MERGE TO 4.1: add code for automatic downgrade 4.1.1 -> 4.0 if the user has not created multiple tablespaces yet innobase/trx/trx0sys.c: DO NOT MERGE TO 4.1: add code for automatic downgrade 4.1.1 -> 4.0 if the user has not created multiple tablespaces yet --- innobase/ibuf/ibuf0ibuf.c | 8 ++++ innobase/include/srv0srv.h | 2 + innobase/include/trx0sys.h | 18 ++++++++ innobase/srv/srv0start.c | 25 +++++++++++ innobase/trx/trx0sys.c | 88 +++++++++++++++++++++++++++++++++++++- 5 files changed, 140 insertions(+), 1 deletion(-) diff --git a/innobase/ibuf/ibuf0ibuf.c b/innobase/ibuf/ibuf0ibuf.c index c07756ab308..7c31ca7c320 100644 --- a/innobase/ibuf/ibuf0ibuf.c +++ b/innobase/ibuf/ibuf0ibuf.c @@ -2622,6 +2622,14 @@ loop: goto reset_bit; } + /* Do NOT merge to the 4.1 code base! */ + if (trx_sys_downgrading_from_4_1_1) { + fprintf(stderr, +"InnoDB: Fatal error: you are downgrading from >= 4.1.1 to 4.0, but\n" +"InnoDB: the insert buffer was not empty.\n"); + ut_a(0); + } + if (corruption_noticed) { rec_sprintf(err_buf, 450, ibuf_rec); diff --git a/innobase/include/srv0srv.h b/innobase/include/srv0srv.h index 87df3904f19..02d3d3bba0a 100644 --- a/innobase/include/srv0srv.h +++ b/innobase/include/srv0srv.h @@ -17,6 +17,8 @@ Created 10/10/1995 Heikki Tuuri #include "que0types.h" #include "trx0types.h" +extern char* srv_main_thread_op_info; + /* Buffer which can be used in printing fatal error messages */ extern char srv_fatal_errbuf[]; diff --git a/innobase/include/trx0sys.h b/innobase/include/trx0sys.h index a54a6424a4f..a8ed675a8a5 100644 --- a/innobase/include/trx0sys.h +++ b/innobase/include/trx0sys.h @@ -24,6 +24,18 @@ Created 3/26/1996 Heikki Tuuri #include "fsp0fsp.h" #include "read0types.h" +/* Do NOT merge this to the 4.1 code base! */ +extern ibool trx_sys_downgrading_from_4_1_1; + +/******************************************************************** +Do NOT merge this to the 4.1 code base! +Marks the trx sys header when we have successfully downgraded from the >= 4.1.1 +multiple tablespace format back to the 4.0 format. */ + +void +trx_sys_mark_downgraded_from_4_1_1(void); +/*====================================*/ + /* In a MySQL replication slave, in crash recovery we store the master log file name and position here. We have successfully got the updates to InnoDB up to this position. If .._pos is -1, it means no crash recovery was needed, @@ -354,8 +366,14 @@ this contains the same fields as TRX_SYS_MYSQL_LOG_INFO below */ sys header is half-written to disk, we still may be able to recover the information */ +#define TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED (24 + FSEG_HEADER_SIZE) + /* If this is set to + .._N, then we are + DOWNGRADING from >= 4.1.1 to + 4.0 */ /*-------------------------------------------------------------*/ #define TRX_SYS_DOUBLEWRITE_MAGIC_N 536853855 +#define TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED_N 1783657386 #define TRX_SYS_DOUBLEWRITE_BLOCK_SIZE FSP_EXTENT_SIZE diff --git a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c index af4ca71d443..8ff2076d5d1 100644 --- a/innobase/srv/srv0start.c +++ b/innobase/srv/srv0start.c @@ -1479,6 +1479,31 @@ NetWare. */ os_fast_mutex_free(&srv_os_test_mutex); + /***********************************************************/ + /* Do NOT merge to the 4.1 code base! */ + if (trx_sys_downgrading_from_4_1_1) { + fprintf(stderr, +"InnoDB: You are downgrading from an InnoDB version which allows multiple\n" +"InnoDB: tablespaces. Wait that purge and insert buffer merge run to\n" +"InnoDB: completion...\n"); + for (;;) { + os_thread_sleep(10000000); + + if (0 == strcmp(srv_main_thread_op_info, + "waiting for server activity")) { + break; + } + } + fprintf(stderr, +"InnoDB: Full purge and insert buffer merge completed.\n"); + + trx_sys_mark_downgraded_from_4_1_1(); + + fprintf(stderr, +"InnoDB: Downgraded from >= 4.1.1 to 4.0\n"); + } + /***********************************************************/ + if (srv_print_verbose_log) { ut_print_timestamp(stderr); fprintf(stderr, " InnoDB: Started\n"); diff --git a/innobase/trx/trx0sys.c b/innobase/trx/trx0sys.c index f1b03fff3bd..6ed70280b26 100644 --- a/innobase/trx/trx0sys.c +++ b/innobase/trx/trx0sys.c @@ -34,6 +34,43 @@ or there was no master log position info inside InnoDB. */ char trx_sys_mysql_master_log_name[TRX_SYS_MYSQL_LOG_NAME_LEN]; ib_longlong trx_sys_mysql_master_log_pos = -1; +/* Do NOT merge this to the 4.1 code base! */ +ibool trx_sys_downgrading_from_4_1_1 = FALSE; + +/******************************************************************** +Do NOT merge this to the 4.1 code base! +Marks the trx sys header when we have successfully downgraded from the >= 4.1.1 +multiple tablespace format back to the 4.0 format. */ + +void +trx_sys_mark_downgraded_from_4_1_1(void) +/*====================================*/ +{ + page_t* page; + byte* doublewrite; + mtr_t mtr; + + /* Let us mark to the trx_sys header that the downgrade has been + done. */ + + mtr_start(&mtr); + + page = buf_page_get(TRX_SYS_SPACE, TRX_SYS_PAGE_NO, RW_X_LATCH, &mtr); + buf_page_dbg_add_level(page, SYNC_NO_ORDER_CHECK); + + doublewrite = page + TRX_SYS_DOUBLEWRITE; + + mlog_write_ulint(doublewrite + TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED, + TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED_N + 1, + MLOG_4BYTES, &mtr); + mtr_commit(&mtr); + + /* Flush the modified pages to disk and make a checkpoint */ + log_make_checkpoint_at(ut_dulint_max, TRUE); + + trx_sys_downgrading_from_4_1_1 = FALSE; +} + /******************************************************************** Determines if a page number is located inside the doublewrite buffer. */ @@ -138,12 +175,36 @@ start_again: if (mach_read_from_4(doublewrite + TRX_SYS_DOUBLEWRITE_MAGIC) == TRX_SYS_DOUBLEWRITE_MAGIC_N) { + /* Do NOT merge to the 4.1 code base! */ + if (mach_read_from_4(doublewrite + + TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED) + == TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED_N) { + + fprintf(stderr, +"InnoDB: You are downgrading from the multiple tablespace format of\n" +"InnoDB: >= MySQL-4.1.1 back to the old format of MySQL-4.0.\n" +"InnoDB:\n" +"InnoDB: MAKE SURE that the mysqld server is idle, and purge and the insert\n" +"InnoDB: buffer merge have run to completion under >= 4.1.1 before trying to\n" +"InnoDB: downgrade! You can determine this by looking at SHOW INNODB STATUS:\n" +"InnoDB: if the Main thread is 'waiting for server activity' and SHOW\n" +"InnoDB: PROCESSLIST shows that you have ended all other connections\n" +"InnoDB: to mysqld, then purge and the insert buffer merge have been\n" +"InnoDB: completed.\n" +"InnoDB: If you have already created .ibd tables in >= 4.1.1, then those\n" +"InnoDB: tables cannot be used under 4.0.\n" +"InnoDB: NOTE THAT this downgrade procedure has not been properly tested!\n" +"InnoDB: The safe way to downgrade is to dump all InnoDB tables and recreate\n" +"InnoDB: the whole tablespace.\n"); + + trx_sys_downgrading_from_4_1_1 = TRUE; + } /* The doublewrite buffer has already been created: just read in some numbers */ trx_doublewrite_init(doublewrite); - + mtr_commit(&mtr); } else { fprintf(stderr, @@ -295,6 +356,31 @@ trx_sys_doublewrite_restore_corrupt_pages(void) == TRX_SYS_DOUBLEWRITE_MAGIC_N) { /* The doublewrite buffer has been created */ + /* Do NOT merge to the 4.1 code base! */ + if (mach_read_from_4(doublewrite + + TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED) + == TRX_SYS_DOUBLEWRITE_SPACE_ID_STORED_N) { + + fprintf(stderr, +"InnoDB: You are downgrading from the multiple tablespace format of\n" +"InnoDB: >= MySQL-4.1.1 back to the old format of MySQL-4.0.\n" +"InnoDB:\n" +"InnoDB: MAKE SURE that the mysqld server is idle, and purge and the insert\n" +"InnoDB: buffer merge have run to completion under >= 4.1.1 before trying to\n" +"InnoDB: downgrade! You can determine this by looking at SHOW INNODB STATUS:\n" +"InnoDB: if the Main thread is 'waiting for server activity' and SHOW\n" +"InnoDB: PROCESSLIST shows that you have ended all other connections\n" +"InnoDB: to mysqld, then purge and the insert buffer merge have been\n" +"InnoDB: completed.\n" +"InnoDB: If you have already created .ibd tables in >= 4.1.1, then those\n" +"InnoDB: tables cannot be used under 4.0.\n" +"InnoDB: NOTE THAT this downgrade procedure has not been properly tested!\n" +"InnoDB: The safe way to downgrade is to dump all InnoDB tables and recreate\n" +"InnoDB: the whole tablespace.\n"); + + trx_sys_downgrading_from_4_1_1 = TRUE; + } + trx_doublewrite_init(doublewrite); block1 = trx_doublewrite->block1; From a5edde882350c2654c94508c84bf550b9ab1eb54 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 6 Jan 2004 14:01:49 +0100 Subject: [PATCH 016/113] Completion of fix for BUG#2121 "Inadequate message "check permissions on master.info"": I had not corrected these languages. As it has been discussed with the docs team, the new messages will be merged to 4.1, and then will be translated in 4.1 (they will remain in English in 4.0). sql/share/danish/errmsg.txt: better error message sql/share/dutch/errmsg.txt: better error message sql/share/german/errmsg.txt: better error message sql/share/italian/errmsg.txt: better error message sql/share/portuguese/errmsg.txt: better error message sql/share/russian/errmsg.txt: better error message sql/share/spanish/errmsg.txt: better error message sql/share/swedish/errmsg.txt: better error message sql/share/ukrainian/errmsg.txt: better error message --- sql/share/danish/errmsg.txt | 2 +- sql/share/dutch/errmsg.txt | 2 +- sql/share/german/errmsg.txt | 2 +- sql/share/italian/errmsg.txt | 2 +- sql/share/portuguese/errmsg.txt | 2 +- sql/share/russian/errmsg.txt | 2 +- sql/share/spanish/errmsg.txt | 2 +- sql/share/swedish/errmsg.txt | 2 +- sql/share/ukrainian/errmsg.txt | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sql/share/danish/errmsg.txt b/sql/share/danish/errmsg.txt index fe2cedb69bb..4e612c599ec 100644 --- a/sql/share/danish/errmsg.txt +++ b/sql/share/danish/errmsg.txt @@ -205,7 +205,7 @@ "Denne handling kunne ikke udføres med kørende slave, brug først kommandoen SLAVE STOP", "Denne handling kræver en kørende slave. Konfigurer en slave og brug kommandoen SLAVE START", "Denne server er ikke konfigureret som slave. Ret in config-filen eller brug kommandoen CHANGE MASTER TO", -"Kunne ikke initialisere master info-struktur. Check om rettigheder i master.info", +"Could not initialize master info structure, more error messages can be found in the MySQL error log", "Kunne ikke danne en slave-tråd. Check systemressourcerne", "Brugeren %-.64s har allerede mere end 'max_user_connections' aktive forbindelser", "Du må kun bruge konstantudtryk med SET", diff --git a/sql/share/dutch/errmsg.txt b/sql/share/dutch/errmsg.txt index e2e5bd6839c..4aafa51e856 100644 --- a/sql/share/dutch/errmsg.txt +++ b/sql/share/dutch/errmsg.txt @@ -213,7 +213,7 @@ "Deze operatie kan niet worden uitgevoerd met een actieve slave, doe eerst SLAVE STOP", "Deze operatie vereist een actieve slave, configureer slave en doe dan SLAVE START", "De server is niet geconfigureerd als slave, fix in configuratie bestand of met CHANGE MASTER TO", -"Kon master info structuur niet initialiseren, controleer permissies in master.info", +"Could not initialize master info structure, more error messages can be found in the MySQL error log", "Kon slave thread niet aanmaken, controleer systeem resources", "Gebruiker %-.64s heeft reeds meer dan 'max_user_connections' actieve verbindingen", "U mag alleen constante expressies gebruiken bij SET", diff --git a/sql/share/german/errmsg.txt b/sql/share/german/errmsg.txt index 6258171e34e..518cb507466 100644 --- a/sql/share/german/errmsg.txt +++ b/sql/share/german/errmsg.txt @@ -205,7 +205,7 @@ "Diese Operation kann nicht bei einem aktiven Slave durchgeführt werden. Das Kommand SLAVE STOP muss zuerst ausgeführt werden.", "Diese Operationbenötigt einen aktiven Slave. Slave konfigurieren und mittels SLAVE START aktivieren.", "Der Server ist nicht als Slave konfigiriert. Im Konfigurations-File oder mittel CHANGE MASTER TO beheben.", -"Konnte Master-Info-Struktur nicht initialisieren; Berechtigungen von master.info prüfen.", +"Could not initialize master info structure, more error messages can be found in the MySQL error log", "Konnte keinen Slave-Thread starten. System-Resourcen überprüfen.", "Benutzer %-.64s hat mehr als 'max_user_connections' aktive Verbindungen", "Bei der Verwendung mit SET dürfen nur Constante Ausdrücke verwendet werden", diff --git a/sql/share/italian/errmsg.txt b/sql/share/italian/errmsg.txt index cf094da76d2..30dff93ebef 100644 --- a/sql/share/italian/errmsg.txt +++ b/sql/share/italian/errmsg.txt @@ -202,7 +202,7 @@ "Questa operazione non puo' essere eseguita con un database 'slave' che gira, lanciare prima SLAVE STOP", "Questa operaione richiede un database 'slave', configurarlo ed eseguire SLAVE START", "Il server non e' configurato come 'slave', correggere il file di configurazione cambiando CHANGE MASTER TO", -"Impossibile inizializzare la struttura 'master info', controllare i permessi sul file master.info", +"Could not initialize master info structure, more error messages can be found in the MySQL error log", "Impossibile creare il thread 'slave', controllare le risorse di sistema", "L'utente %-.64s ha gia' piu' di 'max_user_connections' connessioni attive", "Si possono usare solo espressioni costanti con SET", diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt index bdb721d9e94..a1b5e87a52d 100644 --- a/sql/share/portuguese/errmsg.txt +++ b/sql/share/portuguese/errmsg.txt @@ -202,7 +202,7 @@ "Esta operação não pode ser realizada com um 'slave' em execução. Execute SLAVE STOP primeiro", "Esta operação requer um 'slave' em execução. Configure o 'slave' e execute SLAVE START", "O servidor não está configurado como 'slave'. Acerte o arquivo de configuração ou use CHANGE MASTER TO", -"Não pode inicializar a estrutura de informação do 'master'. Verifique as permissões em 'master.info'", +"Could not initialize master info structure, more error messages can be found in the MySQL error log", "Não conseguiu criar 'thread' de 'slave'. Verifique os recursos do sistema", "Usuário '%-.64s' já possui mais que o valor máximo de conexões (max_user_connections) ativas", "Você pode usar apenas expressões constantes com SET", diff --git a/sql/share/russian/errmsg.txt b/sql/share/russian/errmsg.txt index 03e6874549e..472031c6300 100644 --- a/sql/share/russian/errmsg.txt +++ b/sql/share/russian/errmsg.txt @@ -204,7 +204,7 @@ "üÔÕ ÏÐÅÒÁÃÉÀ ÎÅ×ÏÚÍÏÖÎÏ ×ÙÐÏÌÎÉÔØ ÐÒÉ ÒÁÂÏÔÁÀÝÅÍ ÐÏÔÏËÅ ÐÏÄÞÉÎÅÎÎÏÇÏ ÓÅÒ×ÅÒÁ. óÎÁÞÁÌÁ ×ÙÐÏÌÎÉÔÅ STOP SLAVE", "äÌÑ ÜÔÏÊ ÏÐÅÒÁÃÉÉ ÔÒÅÂÕÅÔÓÑ ÒÁÂÏÔÁÀÝÉÊ ÐÏÄÞÉÎÅÎÎÙÊ ÓÅÒ×ÅÒ. óÎÁÞÁÌÁ ×ÙÐÏÌÎÉÔÅ START SLAVE", "üÔÏÔ ÓÅÒ×ÅÒ ÎÅ ÎÁÓÔÒÏÅÎ ËÁË ÐÏÄÞÉÎÅÎÎÙÊ. ÷ÎÅÓÉÔÅ ÉÓÐÒÁ×ÌÅÎÉÑ × ËÏÎÆÉÇÕÒÁÃÉÏÎÎÏÍ ÆÁÊÌÅ ÉÌÉ Ó ÐÏÍÏÝØÀ CHANGE MASTER TO", -"îÅ×ÏÚÍÏÖÎÏ ÉÎÉÃÉÁÌÉÚÉÒÏ×ÁÔØ ÓÔÒÕËÔÕÒÕ ÄÌÑ ÉÎÆÏÒÍÁÃÉÉ Ï ÇÏÌÏ×ÎÏÍ ÓÅÒ×ÅÒÅ. ðÒÏ×ÅÒØÔÅ ÐÒÁ×Á ÎÁ ÆÁÊÌ master.info", +"Could not initialize master info structure, more error messages can be found in the MySQL error log", "îÅ×ÏÚÍÏÖÎÏ ÓÏÚÄÁÔØ ÐÏÔÏË ÐÏÄÞÉÎÅÎÎÏÇÏ ÓÅÒ×ÅÒÁ. ðÒÏ×ÅÒØÔÅ ÓÉÓÔÅÍÎÙÅ ÒÅÓÕÒÓÙ", "õ ÐÏÌØÚÏ×ÁÔÅÌÑ %-.64s ÕÖÅ ÂÏÌØÛÅ ÞÅÍ 'max_user_connections' ÁËÔÉ×ÎÙÈ ÓÏÅÄÉÎÅÎÉÊ", "÷Ù ÍÏÖÅÔÅ ÉÓÐÏÌØÚÏ×ÁÔØ × SET ÔÏÌØËÏ ËÏÎÓÔÁÎÔÎÙÅ ×ÙÒÁÖÅÎÉÑ", diff --git a/sql/share/spanish/errmsg.txt b/sql/share/spanish/errmsg.txt index 0068b3a6e12..0010769aa4f 100644 --- a/sql/share/spanish/errmsg.txt +++ b/sql/share/spanish/errmsg.txt @@ -203,7 +203,7 @@ "Esta operación no puede ser hecha con el esclavo funcionando, primero use SLAVE STOP", "Esta operación necesita el esclavo funcionando, configure esclavo y haga el SLAVE START", "El servidor no está configurado como esclavo, edite el archivo config file o con CHANGE MASTER TO", -"No puedo inicializar la estructura info del master, verifique permisiones en el master.info", +"Could not initialize master info structure, more error messages can be found in the MySQL error log", "No puedo crear el thread esclavo, verifique recursos del sistema", "Usario %-.64s ya tiene mas que 'max_user_connections' conexiones activas", "Tu solo debes usar expresiones constantes con SET", diff --git a/sql/share/swedish/errmsg.txt b/sql/share/swedish/errmsg.txt index 5ecb7962aed..508737dde2f 100644 --- a/sql/share/swedish/errmsg.txt +++ b/sql/share/swedish/errmsg.txt @@ -202,7 +202,7 @@ "Denna operation kan inte göras under replikering; Gör SLAVE STOP först", "Denna operation kan endast göras under replikering; Konfigurera slaven och gör SLAVE START", "Servern är inte konfigurerade som en replikationsslav. Ändra konfigurationsfilen eller gör CHANGE MASTER TO", -"Kunde inte initialisera replikationsstrukturerna. Kontrollera privilegerna för 'master.info'", +"Could not initialize master info structure, more error messages can be found in the MySQL error log", "Kunde inte starta en tråd för replikering", "Användare '%-.64s' har redan 'max_user_connections' aktiva inloggningar", "Man kan endast använda konstantuttryck med SET", diff --git a/sql/share/ukrainian/errmsg.txt b/sql/share/ukrainian/errmsg.txt index a5f94e90d6a..372cfa78dff 100644 --- a/sql/share/ukrainian/errmsg.txt +++ b/sql/share/ukrainian/errmsg.txt @@ -207,7 +207,7 @@ "ïÐÅÒÁÃ¦Ñ ÎÅ ÍÏÖÅ ÂÕÔÉ ×ÉËÏÎÁÎÁ Ú ÚÁÐÕÝÅÎÉÍ Ð¦ÄÌÅÇÌÉÍ, ÓÐÏÞÁÔËÕ ×ÉËÏÎÁÊÔÅ SLAVE STOP", "ïÐÅÒÁÃ¦Ñ ×ÉÍÁÇÁ¤ ÚÁÐÕÝÅÎÏÇÏ Ð¦ÄÌÅÇÌÏÇÏ, ÚËÏÎÆ¦ÇÕÒÕÊÔŠЦÄÌÅÇÌÏÇÏ ÔÁ ×ÉËÏÎÁÊÔÅ SLAVE START", "óÅÒ×ÅÒ ÎÅ ÚËÏÎÆ¦ÇÕÒÏ×ÁÎÏ ÑË Ð¦ÄÌÅÇÌÉÊ, ×ÉÐÒÁ×ÔÅ ÃÅ Õ ÆÁÊ̦ ËÏÎÆ¦ÇÕÒÁæ§ ÁÂÏ Ú CHANGE MASTER TO", -"îÅ ÍÏÖÕ ¦Î¦Ã¦Á̦ÚÕ×ÁÔÉ ÓÔÒÕËÔÕÒÕ ÉÎÆÏÒÍÁæ§ ÇÏÌÏ×ÎÏÇÏ, ÐÅÒÅצÒÔÅ ÐÒÁ×Á ÄÏÓÔÕÐÕ ÎÁ master.info", +"Could not initialize master info structure, more error messages can be found in the MySQL error log", "îÅ ÍÏÖÕ ÓÔ×ÏÒÉÔÉ Ð¦ÄÌÅÇÌÕ Ç¦ÌËÕ, ÐÅÒÅצÒÔÅ ÓÉÓÔÅÍΦ ÒÅÓÕÒÓÉ", "ëÏÒÉÓÔÕ×ÁÞ %-.64s ×ÖÅ ÍÁ¤ Â¦ÌØÛÅ Î¦Ö 'max_user_connections' ÁËÔÉ×ÎÉÈ Ú'¤ÄÎÁÎØ", "íÏÖÎÁ ×ÉËÏÒÉÓÔÏ×Õ×ÁÔÉ ÌÉÛÅ ×ÉÒÁÚÉ Ú¦ ÓÔÁÌÉÍÉ Õ SET", From 7622c393a9fc2c70b47cf5b874eb0d275c0db395 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 6 Jan 2004 19:23:30 +0200 Subject: [PATCH 017/113] mysqldump.c: Fix for UNLOCK TABLES bug #2242 client/mysqldump.c: Fix for UNLOCK TABLES bug #2242 --- client/mysqldump.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index 489869f6c3d..38202a5c253 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -1389,7 +1389,7 @@ static int dump_all_tables_in_db(char *database) if (opt_xml) fprintf(md_result_file, "\n"); if (lock_tables) - mysql_query(sock,"UNLOCK_TABLES"); + mysql_query(sock,"UNLOCK TABLES"); return 0; } /* dump_all_tables_in_db */ @@ -1435,7 +1435,7 @@ static int dump_selected_tables(char *db, char **table_names, int tables) if (opt_xml) fprintf(md_result_file, "\n"); if (lock_tables) - mysql_query(sock,"UNLOCK_TABLES"); + mysql_query(sock,"UNLOCK TABLES"); return 0; } /* dump_selected_tables */ From b958fd15b26918cd6238c9b54111a957eb520e77 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 6 Jan 2004 19:50:50 +0200 Subject: [PATCH 018/113] trx0sys.c: DO NOT MERGE TO 4.1: charset changes can cause problems in a downgrade 4.1.1 -> 4.0.18 innobase/trx/trx0sys.c: DO NOT MERGE TO 4.1: charset changes can cause problems in a downgrade 4.1.1 -> 4.0.18 --- innobase/trx/trx0sys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/innobase/trx/trx0sys.c b/innobase/trx/trx0sys.c index 6ed70280b26..aacf5da8be8 100644 --- a/innobase/trx/trx0sys.c +++ b/innobase/trx/trx0sys.c @@ -191,7 +191,7 @@ start_again: "InnoDB: PROCESSLIST shows that you have ended all other connections\n" "InnoDB: to mysqld, then purge and the insert buffer merge have been\n" "InnoDB: completed.\n" -"InnoDB: If you have already created .ibd tables in >= 4.1.1, then those\n" +"InnoDB: If you have already created tables in >= 4.1.1, then those\n" "InnoDB: tables cannot be used under 4.0.\n" "InnoDB: NOTE THAT this downgrade procedure has not been properly tested!\n" "InnoDB: The safe way to downgrade is to dump all InnoDB tables and recreate\n" From a65aea9de77163a74f0a699784296721bf54b74a Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 6 Jan 2004 20:06:07 +0200 Subject: [PATCH 019/113] trx0sys.c: DO NOT MERGE TO 4.1: forgot to change this in the previous push innobase/trx/trx0sys.c: DO NOT MERGE TO 4.1: forgot to change this in the previous push --- innobase/trx/trx0sys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/innobase/trx/trx0sys.c b/innobase/trx/trx0sys.c index aacf5da8be8..3b5f024d39e 100644 --- a/innobase/trx/trx0sys.c +++ b/innobase/trx/trx0sys.c @@ -372,7 +372,7 @@ trx_sys_doublewrite_restore_corrupt_pages(void) "InnoDB: PROCESSLIST shows that you have ended all other connections\n" "InnoDB: to mysqld, then purge and the insert buffer merge have been\n" "InnoDB: completed.\n" -"InnoDB: If you have already created .ibd tables in >= 4.1.1, then those\n" +"InnoDB: If you have already created tables in >= 4.1.1, then those\n" "InnoDB: tables cannot be used under 4.0.\n" "InnoDB: NOTE THAT this downgrade procedure has not been properly tested!\n" "InnoDB: The safe way to downgrade is to dump all InnoDB tables and recreate\n" From f61cec71d19659759b44f42f1deccbe64a25bdbb Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 7 Jan 2004 18:15:17 +0200 Subject: [PATCH 020/113] buf0lru.c: Start InnoDB Monitor if 80 % of the buffer pool occupied by adaptive has or lock heaps; do not print the same warning more than 1 time innobase/buf/buf0lru.c: Start InnoDB Monitor if 80 % of the buffer pool occupied by adaptive has or lock heaps; do not print the same warning more than 1 time --- innobase/buf/buf0lru.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/innobase/buf/buf0lru.c b/innobase/buf/buf0lru.c index eeccbf7728a..a8729efb999 100644 --- a/innobase/buf/buf0lru.c +++ b/innobase/buf/buf0lru.c @@ -216,7 +216,7 @@ buf_LRU_get_free_block(void) buf_block_t* block = NULL; ibool freed; ulint n_iterations = 1; - ibool mon_value_was = 0; /* remove bug */ + ibool mon_value_was = FALSE; ibool started_monitor = FALSE; loop: mutex_enter(&(buf_pool->mutex)); @@ -235,12 +235,14 @@ loop: } else if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free) + UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 5) { + if (!srv_print_innodb_monitor) { - /* Over 80 % of the buffer pool is occupied by lock heaps - or the adaptive hash index. This may be a memory leak! */ + /* Over 80 % of the buffer pool is occupied by lock + heaps or the adaptive hash index. This may be a memory + leak! */ - ut_print_timestamp(stderr); - fprintf(stderr, + ut_print_timestamp(stderr); + fprintf(stderr, " InnoDB: WARNING: over 4 / 5 of the buffer pool is occupied by\n" "InnoDB: lock heaps or the adaptive hash index! Check that your\n" "InnoDB: transactions do not set too many row locks.\n" @@ -248,10 +250,11 @@ loop: "InnoDB: the buffer pool bigger?\n" "InnoDB: Starting the InnoDB Monitor to print diagnostics, including\n" "InnoDB: lock heap and hash index sizes.\n", - buf_pool->curr_size / (1024 * 1024 / UNIV_PAGE_SIZE)); - - srv_print_innodb_monitor = TRUE; + buf_pool->curr_size / (1024 * 1024 / UNIV_PAGE_SIZE)); + srv_print_innodb_monitor = TRUE; + os_event_set(srv_lock_timeout_thread_event); + } } else if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free) + UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 4) { @@ -318,6 +321,7 @@ loop: mon_value_was = srv_print_innodb_monitor; started_monitor = TRUE; srv_print_innodb_monitor = TRUE; + os_event_set(srv_lock_timeout_thread_event); } /* No free block was found: try to flush the LRU list */ From aafca9f08dcf5252fc05eabf9be4f15fe4b65ac2 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 8 Jan 2004 12:24:36 +0400 Subject: [PATCH 021/113] An improvement of the fix for the bug #2231: string column, INDEX+LIKE, don't take the ESCAPE character. (ver. 2) --- mysql-test/r/func_like.result | 3 +++ mysql-test/t/func_like.test | 1 + sql/opt_range.cc | 32 +++++++++++++++++--------------- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/mysql-test/r/func_like.result b/mysql-test/r/func_like.result index 0f94348a5f8..b196b50f53b 100644 --- a/mysql-test/r/func_like.result +++ b/mysql-test/r/func_like.result @@ -42,4 +42,7 @@ insert into t1 values ('a'), ('a\\b'); select * from t1 where a like 'a\\%' escape '#'; a a\b +select * from t1 where a like 'a\\%' escape '#' and a like 'a\\\\b'; +a +a\b drop table t1; diff --git a/mysql-test/t/func_like.test b/mysql-test/t/func_like.test index 1e14c70a76a..6d6ee8f86a3 100644 --- a/mysql-test/t/func_like.test +++ b/mysql-test/t/func_like.test @@ -29,4 +29,5 @@ drop table t1; create table t1 (a varchar(10), key(a)); insert into t1 values ('a'), ('a\\b'); select * from t1 where a like 'a\\%' escape '#'; +select * from t1 where a like 'a\\%' escape '#' and a like 'a\\\\b'; drop table t1; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index c918635b61f..bed1b52a79a 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -290,7 +290,7 @@ typedef struct st_qsel_param { char min_key[MAX_KEY_LENGTH+MAX_FIELD_WIDTH], max_key[MAX_KEY_LENGTH+MAX_FIELD_WIDTH]; bool quick; // Don't calulate possible keys - char escape; + COND *cond; } PARAM; static SEL_TREE * get_mm_parts(PARAM *param,Field *field, @@ -638,9 +638,6 @@ int SQL_SELECT::test_quick_select(THD *thd, key_map keys_to_use, param.table=head; param.keys=0; param.mem_root= &alloc; - if (cond->type() == Item::FUNC_ITEM && - ((Item_func*)cond)->functype() == Item_func::LIKE_FUNC) - param.escape= ((Item_func_like*)cond)->escape; param.thd->no_errors=1; // Don't warn about NULL init_sql_alloc(&alloc, param.thd->variables.range_alloc_block_size, 0); if (!(param.key_parts = (KEY_PART*) alloc_root(&alloc, @@ -821,6 +818,8 @@ static SEL_TREE *get_mm_tree(PARAM *param,COND *cond) if (cond_func->select_optimize() == Item_func::OPTIMIZE_NONE) DBUG_RETURN(0); // Can't be calculated + param->cond= cond; + if (cond_func->functype() == Item_func::BETWEEN) { if (cond_func->arguments()[0]->type() == Item::FIELD_ITEM) @@ -997,23 +996,26 @@ get_mm_leaf(PARAM *param, Field *field, KEY_PART *key_part, if (maybe_null) max_str[0]= min_str[0]=0; if (field->binary()) - like_error=like_range(res->ptr(),res->length(),param->escape,field_length, - min_str+offset,max_str+offset,(char) 255, - &min_length,&max_length); + like_error=like_range(res->ptr(), res->length(), + ((Item_func_like*)(param->cond))->escape, + field_length, min_str + offset, max_str + offset, + (char) 255, &min_length, &max_length); else { #ifdef USE_STRCOLL if (use_strcoll(default_charset_info)) - like_error= my_like_range(default_charset_info, - res->ptr(),res->length(),param->escape, - field_length, min_str+maybe_null, - max_str+maybe_null,&min_length,&max_length); + like_error= my_like_range(default_charset_info, res->ptr(), + res->length(), + ((Item_func_like*)(param->cond))->escape, + field_length, min_str + maybe_null, + max_str + maybe_null, &min_length, + &max_length); else #endif - like_error=like_range(res->ptr(),res->length(),param->escape, - field_length, - min_str+offset,max_str+offset, - max_sort_char,&min_length,&max_length); + like_error=like_range(res->ptr(), res->length(), + ((Item_func_like*)(param->cond))->escape, + field_length, min_str + offset, max_str + offset, + max_sort_char, &min_length, &max_length); } if (like_error) // Can't optimize with LIKE DBUG_RETURN(0); From 9d8bf6980ab67940e91425d5bcb6968e630ac8a2 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 11 Jan 2004 14:12:46 +0400 Subject: [PATCH 022/113] A fix (bug #2335: Inconsistancy with handling of Years and NOW() function). The test might fail if one runs it at 23:59:59 Dec 31 mysql-test/r/type_year.result: a fix (bug #2335: Inconsistancy with handling of Years and NOW() function) mysql-test/t/type_year.test: a fix (bug #2335: Inconsistancy with handling of Years and NOW() function) sql/field.h: a fix (bug #2335: Inconsistancy with handling of Years and NOW() function) --- mysql-test/r/type_year.result | 6 ++++++ mysql-test/t/type_year.test | 9 +++++++++ sql/field.h | 1 + 3 files changed, 16 insertions(+) diff --git a/mysql-test/r/type_year.result b/mysql-test/r/type_year.result index 25ddda88f48..5ef3c1bba81 100644 --- a/mysql-test/r/type_year.result +++ b/mysql-test/r/type_year.result @@ -26,3 +26,9 @@ y y2 2001 01 2069 69 drop table t1; +create table t1 (y year); +insert into t1 values (now()); +select if(y = now(), 1, 0) from t1; +if(y = now(), 1, 0) +1 +drop table t1; diff --git a/mysql-test/t/type_year.test b/mysql-test/t/type_year.test index 8f4f23badb4..e9e34dbc29f 100644 --- a/mysql-test/t/type_year.test +++ b/mysql-test/t/type_year.test @@ -8,3 +8,12 @@ select * from t1; select * from t1 order by y; select * from t1 order by y2; drop table t1; + +# +# Bug 2335 +# + +create table t1 (y year); +insert into t1 values (now()); +select if(y = now(), 1, 0) from t1; +drop table t1; diff --git a/sql/field.h b/sql/field.h index 8a829a455ed..413a08f08d4 100644 --- a/sql/field.h +++ b/sql/field.h @@ -600,6 +600,7 @@ public: longlong val_int(void); String *val_str(String*,String *); void sql_type(String &str) const; + bool store_for_compare() { return 1; } }; From e2ab8558e899716d653d994af1a1e86c54e90bf9 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 12 Jan 2004 16:25:13 +0200 Subject: [PATCH 023/113] opt_sum.cc: A fix for a bug #3189, pertaining to crashing MySQL server when a query with MIN / MAX on the BLOB column is to be optimised sql/opt_sum.cc: A fix for a bug #3189, pertaining to crashing MySQL server when a query with MIN / MAX on the BLOB column is to be optimised --- mysql-test/r/type_blob.result | 6 ++++++ mysql-test/t/type_blob.test | 6 ++++++ sql/opt_sum.cc | 4 +++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/type_blob.result b/mysql-test/r/type_blob.result index 0bb9146fafc..685301f3639 100644 --- a/mysql-test/r/type_blob.result +++ b/mysql-test/r/type_blob.result @@ -601,3 +601,9 @@ id txt 2 Chevy 4 Ford drop table t1; +CREATE TABLE t1 ( i int(11) NOT NULL default '0', c text NOT NULL, PRIMARY KEY (i), KEY (c(1),c(1))); +INSERT t1 VALUES (1,''),(2,''),(3,'asdfh'),(4,''); +select max(i) from t1 where c = ''; +max(i) +4 +drop table t1; diff --git a/mysql-test/t/type_blob.test b/mysql-test/t/type_blob.test index cf5c0d6e581..928f79a661e 100644 --- a/mysql-test/t/type_blob.test +++ b/mysql-test/t/type_blob.test @@ -312,3 +312,9 @@ select * from t1 where txt <= 'Chevy'; select * from t1 where txt > 'Chevy'; select * from t1 where txt >= 'Chevy'; drop table t1; +CREATE TABLE t1 ( i int(11) NOT NULL default '0', c text NOT NULL, PRIMARY KEY (i), KEY (c(1),c(1))); +INSERT t1 VALUES (1,''),(2,''),(3,'asdfh'),(4,''); +select max(i) from t1 where c = ''; +drop table t1; + + diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index 855813f1140..abf04cf5517 100644 --- a/sql/opt_sum.cc +++ b/sql/opt_sum.cc @@ -443,7 +443,9 @@ static bool find_range_key(TABLE_REF *ref, Field* field, COND *cond) // Save found constant if (part->null_bit) *key_ptr++= (byte) test(part->field->is_null()); - part->field->get_key_image((char*) key_ptr,part->length); + part->field->get_key_image((char*) key_ptr, + (part->field->type() == FIELD_TYPE_BLOB) ? + part->length + HA_KEY_BLOB_LENGTH : part->length); key_ptr+=part->store_length - test(part->null_bit); left_length-=part->store_length; } From 8ae9f145918a0a78cdbae576621001fe4d723bea Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 12 Jan 2004 21:15:49 -0100 Subject: [PATCH 024/113] Checked and applied Novell-supplied patches inside the netware directory only. netware/BUILD/compile-linux-tools: Need to run make on sql_yacc.cc. netware/BUILD/compile-netware-END: Use .zip package. netware/BUILD/compile-netware-all: Add compile-netware-src. netware/BUILD/compile-netware-standard: Need backslash to avoid error. netware/BUILD/mwenv: Add additional include, library paths, -dialect and -map flags for CW. netware/BUILD/nwbootstrap: Additional status messages, update versions in .def files. netware/Makefile.am: Cosmetic change, add @openssl_libs@ in case of OpenSSL feature usage. netware/isamchk.def: Add SCREENNAME to allow interaction. netware/my_manage.c: Take out unused args to mysqladmin. netware/myisamchk.def: Add SCREENNAME to allow interaction. netware/myisamlog.def: Add SCREENNAME to allow interaction. netware/myisampack.def: Add SCREENNAME to allow interaction. netware/mysql_test_run.c: Multiple changes to help test suite. netware/mysqlbinlog.def: Add SCREENNAME to allow interaction. netware/mysqlcheck.def: Add SCREENNAME to allow interaction. netware/mysqld_safe.c: Make error message more accurate/descriptive. netware/mysqldump.def: Add SCREENNAME to allow interaction. netware/mysqlimport.def: Add SCREENNAME to allow interaction. --- netware/BUILD/compile-linux-tools | 5 +- netware/BUILD/compile-netware-END | 4 +- netware/BUILD/compile-netware-all | 1 + netware/BUILD/compile-netware-standard | 2 +- netware/BUILD/mwenv | 12 +- netware/BUILD/nwbootstrap | 15 +- netware/Makefile.am | 8 +- netware/isamchk.def | 1 + netware/my_manage.c | 8 +- netware/myisamchk.def | 1 + netware/myisamlog.def | 1 + netware/myisampack.def | 1 + netware/mysql_test_run.c | 193 ++++++++++++++++++------- netware/mysqlbinlog.def | 1 + netware/mysqlcheck.def | 1 + netware/mysqld_safe.c | 4 +- netware/mysqldump.def | 1 + netware/mysqlimport.def | 1 + 18 files changed, 186 insertions(+), 74 deletions(-) diff --git a/netware/BUILD/compile-linux-tools b/netware/BUILD/compile-linux-tools index 3590a900338..886f866d674 100755 --- a/netware/BUILD/compile-linux-tools +++ b/netware/BUILD/compile-linux-tools @@ -1,4 +1,4 @@ -#! /bin/sh +#! /bin/sh # debug #set -x @@ -46,6 +46,9 @@ make clean config.h (cd sql; make gen_lex_hash) (cd strings; make conf_to_src) +# so the file will be linked +(cd sql; make sql_yacc.cc) + # copying required linux tools cp extra/comp_err extra/comp_err.linux cp libmysql/conf_to_src libmysql/conf_to_src.linux diff --git a/netware/BUILD/compile-netware-END b/netware/BUILD/compile-netware-END index e0097484500..2bd59f97114 100755 --- a/netware/BUILD/compile-netware-END +++ b/netware/BUILD/compile-netware-END @@ -1,4 +1,4 @@ -#! /bin/sh +#! /bin/sh # debug #set -x @@ -29,7 +29,7 @@ rm -rf Makefile.in.bk make clean bin-dist # mark the build -for file in *.tar.gz +for file in *.tar.gz *.zip do if (expr "$file" : "mysql-[1-9].*" > /dev/null) then diff --git a/netware/BUILD/compile-netware-all b/netware/BUILD/compile-netware-all index 35d275f3b42..6baff699e94 100755 --- a/netware/BUILD/compile-netware-all +++ b/netware/BUILD/compile-netware-all @@ -8,6 +8,7 @@ set -e path=`dirname $0` +$path/compile-netware-src $path/compile-netware-standard $path/compile-netware-debug #$path/compile-netware-max diff --git a/netware/BUILD/compile-netware-standard b/netware/BUILD/compile-netware-standard index 12cae1f024e..45f5021862c 100755 --- a/netware/BUILD/compile-netware-standard +++ b/netware/BUILD/compile-netware-standard @@ -13,7 +13,7 @@ path=`dirname $0` suffix="standard" extra_configs=" \ - --with-innodb + --with-innodb \ " . $path/compile-netware-END diff --git a/netware/BUILD/mwenv b/netware/BUILD/mwenv index 26794c3f77f..c16ada6552a 100755 --- a/netware/BUILD/mwenv +++ b/netware/BUILD/mwenv @@ -6,9 +6,9 @@ # the default is "F:/mydev" export MYDEV="WINE_BUILD_DIR" -export MWCNWx86Includes="$MYDEV/libc/include" -export MWNWx86Libraries="$MYDEV/libc/imports;$MYDEV/mw/lib" -export MWNWx86LibraryFiles="libcpre.o;libc.imp;netware.imp;mwcrtl.lib;mwcpp.lib" +export MWCNWx86Includes="$MYDEV/libc/include;$MYDEV" +export MWNWx86Libraries="$MYDEV/libc/imports;$MYDEV/mw/lib;$MYDEV/mysql-VERSION/netware/BUILD" +export MWNWx86LibraryFiles="libcpre.o;libc.imp;netware.imp;mwcrtl.lib;mwcpp.lib;knetware.imp" export WINEPATH="$MYDEV/mw/bin" @@ -19,11 +19,11 @@ export AR='mwldnlm' export AR_FLAGS='-type library -o' export AS='mwasmnlm' export CC='mwccnlm -gccincludes' -export CFLAGS='-dialect c -proc 686 -relax_pointers' +export CFLAGS='-align 8 -proc 686 -relax_pointers -dialect c' export CXX='mwccnlm -gccincludes' -export CXXFLAGS='-dialect c++ -proc 686 -bool on -wchar_t on -relax_pointers -D_WCHAR_T' +export CXXFLAGS='-align 8 -proc 686 -relax_pointers -dialect c++ -bool on -wchar_t on -D_WCHAR_T' export LD='mwldnlm' -export LDFLAGS='-entry _LibCPrelude -exit _LibCPostlude -flags pseudopreemption' +export LDFLAGS='-entry _LibCPrelude -exit _LibCPostlude -map -flags pseudopreemption' export RANLIB=: export STRIP=: diff --git a/netware/BUILD/nwbootstrap b/netware/BUILD/nwbootstrap index 5d068e4e4de..f54775bf054 100755 --- a/netware/BUILD/nwbootstrap +++ b/netware/BUILD/nwbootstrap @@ -11,7 +11,7 @@ path=`dirname $0` # repository direcotry repo_dir=`pwd` -# build direcotry +# build directory build_dir="$HOME/mydev" wine_build_dir="F:/mydev" @@ -147,10 +147,12 @@ then fi # make files writeable +echo "making files writable..." cd $target_dir chmod -R u+rw,g+rw . # edit the mvenv file +echo "updating the mwenv environment file..." mwenv="./netware/BUILD/mwenv" mv -f $mwenv $mwenv.org sed -e "s;WINE_BUILD_DIR;$wine_build_dir;g" \ @@ -158,6 +160,17 @@ sed -e "s;WINE_BUILD_DIR;$wine_build_dir;g" \ -e "s;VERSION;$version;g" $mwenv.org > $mwenv chmod +rwx $mwenv +# edit the def file versions +echo "updating *.def file versions..." +nlm_version=`echo "$version" | sed -e "s;\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*;\1, \2, \3;"` + +for file in ./netware/*.def +do + mv -f $file $file.org + sed -e "s;VERSION.*;VERSION $nlm_version;g" $file.org > $file + rm $file.org +done + # build linux tools echo "compiling linux tools..." ./netware/BUILD/compile-linux-tools diff --git a/netware/Makefile.am b/netware/Makefile.am index 801d144b968..0f5e862c579 100644 --- a/netware/Makefile.am +++ b/netware/Makefile.am @@ -1,4 +1,4 @@ -# Copyright (c) 2002 Novell, Inc. All Rights Reserved. +# Copyright (c) 2002 Novell, Inc. All Rights Reserved. # # 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 @@ -20,7 +20,7 @@ mysqld_safe_SOURCES= mysqld_safe.c my_manage.c mysql_install_db_SOURCES= mysql_install_db.c my_manage.c mysql_test_run_SOURCES= mysql_test_run.c my_manage.c libmysql_SOURCES= libmysqlmain.c -libmysql_LDADD = ../libmysql/.libs/libmysqlclient.a +libmysql_LDADD = ../libmysql/.libs/libmysqlclient.a @openssl_libs@ netware_build_files = client/mysql.def client/mysqladmin.def \ client/mysqlbinlog.def client/mysqlcheck.def \ @@ -29,12 +29,12 @@ netware_build_files = client/mysql.def client/mysqladmin.def \ extra/mysql_install.def extra/my_print_defaults.def \ extra/perror.def extra/replace.def \ extra/resolveip.def extra/comp_err.def \ - isam/isamchk.def \ + isam/isamchk.def \ isam/isamlog.def isam/pack_isam.def \ libmysqld/libmysqld.def myisam/myisamchk.def \ myisam/myisamlog.def myisam/myisampack.def \ sql/mysqld.def - + link_sources: set -x; \ for f in $(netware_build_files); do \ diff --git a/netware/isamchk.def b/netware/isamchk.def index 8d756466609..69e8ac0405b 100644 --- a/netware/isamchk.def +++ b/netware/isamchk.def @@ -2,6 +2,7 @@ # ISAM Check #------------------------------------------------------------------------------ MODULE libc.nlm +SCREENNAME "MySQL ISAM Table Check Tool" COPYRIGHT "(c) 2003 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL ISAM Table Check Tool" VERSION 4, 0 diff --git a/netware/my_manage.c b/netware/my_manage.c index 490438b0485..1c1e75990b4 100644 --- a/netware/my_manage.c +++ b/netware/my_manage.c @@ -157,7 +157,7 @@ int sleep_until_file_deleted(char *pid_file) /****************************************************************************** sleep_until_file_exists() - + Sleep until the given file exists. ******************************************************************************/ @@ -199,9 +199,13 @@ int wait_for_server_start(char *bin_dir, char *user, char *password, int port) add_arg(&al, "--user=%s", user); add_arg(&al, "--password=%s", password); add_arg(&al, "--silent"); + + /** Not supported on NetWare add_arg(&al, "-O"); add_arg(&al, "connect_timeout=10"); add_arg(&al, "-w"); + **/ + add_arg(&al, "--host=localhost"); add_arg(&al, "ping"); @@ -210,7 +214,7 @@ int wait_for_server_start(char *bin_dir, char *user, char *password, int port) for(i = 0; (i < TRY_MAX) && (err = spawn(mysqladmin_file, &al, TRUE, NULL, trash, NULL)); i++) sleep(1); - + // free args free_args(&al); diff --git a/netware/myisamchk.def b/netware/myisamchk.def index 2222a1317e1..cdfe186058f 100644 --- a/netware/myisamchk.def +++ b/netware/myisamchk.def @@ -2,6 +2,7 @@ # MyISAM Check #------------------------------------------------------------------------------ MODULE libc.nlm +SCREENNAME "MySQL MyISAM Table Check Tool" COPYRIGHT "(c) 2003 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL MyISAM Table Check Tool" VERSION 4, 0 diff --git a/netware/myisamlog.def b/netware/myisamlog.def index bfa673e12be..5c4cbb23361 100644 --- a/netware/myisamlog.def +++ b/netware/myisamlog.def @@ -2,6 +2,7 @@ # MyISAM Log #------------------------------------------------------------------------------ MODULE libc.nlm +SCREENNAME "MySQL MyISAM Table Log Tool" COPYRIGHT "(c) 2003 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL MyISAM Table Log Tool" VERSION 4, 0 diff --git a/netware/myisampack.def b/netware/myisampack.def index 72403d2591e..9111538c2c0 100644 --- a/netware/myisampack.def +++ b/netware/myisampack.def @@ -2,6 +2,7 @@ # MyISAM Pack #------------------------------------------------------------------------------ MODULE libc.nlm +SCREENNAME "MySQL MyISAM Table Pack Tool" COPYRIGHT "(c) 2003 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL MyISAM Table Pack Tool" VERSION 4, 0 diff --git a/netware/mysql_test_run.c b/netware/mysql_test_run.c index ff629546793..e1a07baca6c 100644 --- a/netware/mysql_test_run.c +++ b/netware/mysql_test_run.c @@ -7,7 +7,7 @@ (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 + 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. @@ -27,6 +27,7 @@ #include #include #include +#include #include "my_config.h" #include "my_manage.h" @@ -94,6 +95,13 @@ char slave_master_info[PATH_MAX] = ""; char master_init_script[PATH_MAX] = ""; char slave_init_script[PATH_MAX] = ""; +// OpenSSL +char ca_cert[PATH_MAX]; +char server_cert[PATH_MAX]; +char server_key[PATH_MAX]; +char client_cert[PATH_MAX]; +char client_key[PATH_MAX]; + int total_skip = 0; int total_pass = 0; int total_fail = 0; @@ -101,6 +109,7 @@ int total_test = 0; double total_time = 0; +int use_openssl = FALSE; int master_running = FALSE; int slave_running = FALSE; int skip_slave = TRUE; @@ -184,7 +193,7 @@ void install_db(char *datadir) char input[PATH_MAX]; char output[PATH_MAX]; char error[PATH_MAX]; - + // input file snprintf(input, PATH_MAX, "%s/bin/init_db.sql", base_dir); snprintf(output, PATH_MAX, "%s/install.out", datadir); @@ -193,13 +202,14 @@ void install_db(char *datadir) // args init_args(&al); add_arg(&al, mysqld_file); + add_arg(&al, "--no-defaults"); add_arg(&al, "--bootstrap"); add_arg(&al, "--skip-grant-tables"); add_arg(&al, "--basedir=%s", base_dir); add_arg(&al, "--datadir=%s", datadir); add_arg(&al, "--skip-innodb"); add_arg(&al, "--skip-bdb"); - + // spawn if ((err = spawn(mysqld_file, &al, TRUE, input, output, error)) != 0) { @@ -266,15 +276,16 @@ void start_master() int err, i; char master_out[PATH_MAX]; char master_err[PATH_MAX]; - + char temp[PATH_MAX], temp2[PATH_MAX]; + // remove old berkeley db log files that can confuse the server removef("%s/log.*", master_dir); - - // remove stale binary logs - removef("%s/*-bin.*", master_dir); // remove stale binary logs - removef("%s/*.index", master_dir); + removef("%s/var/log/*-bin.*", mysql_test_dir); + + // remove stale binary logs + removef("%s/var/log/*.index", mysql_test_dir); // remove master.info file removef("%s/master.info", master_dir); @@ -284,11 +295,26 @@ void start_master() // remove relay-log.info file removef("%s/relay-log.info", master_dir); - + // init script if (master_init_script[0] != NULL) { // run_init_script(master_init_script); + + // TODO: use the scripts + if (strindex(master_init_script, "repair_part2-master.sh") != NULL) + { + FILE *fp; + + // create an empty index file + snprintf(temp, PATH_MAX, "%s/test/t1.MYI", master_dir); + fp = fopen(temp, "wb+"); + + fputs("1", fp); + + fclose(fp); + } + } // redirection files @@ -296,12 +322,17 @@ void start_master() mysql_test_dir, restarts); snprintf(master_err, PATH_MAX, "%s/var/run/master%u.err", mysql_test_dir, restarts); - + + snprintf(temp2,PATH_MAX,"%s/var",mysql_test_dir); + mkdir(temp2,0); + snprintf(temp2,PATH_MAX,"%s/var/log",mysql_test_dir); + mkdir(temp2,0); + // args init_args(&al); add_arg(&al, "%s", mysqld_file); add_arg(&al, "--no-defaults"); - add_arg(&al, "--log-bin=master-bin"); + add_arg(&al, "--log-bin=%s/var/log/master-bin",mysql_test_dir); add_arg(&al, "--server-id=1"); add_arg(&al, "--basedir=%s", base_dir); add_arg(&al, "--port=%u", master_port); @@ -312,11 +343,18 @@ void start_master() add_arg(&al, "--character-sets-dir=%s", char_dir); add_arg(&al, "--tmpdir=%s", mysql_tmp_dir); add_arg(&al, "--language=%s", lang_dir); - + + if (use_openssl) + { + add_arg(&al, "--ssl-ca=%s", ca_cert); + add_arg(&al, "--ssl-cert=%s", server_cert); + add_arg(&al, "--ssl-key=%s", server_key); + } + // $MASTER_40_ARGS add_arg(&al, "--rpl-recovery-rank=1"); add_arg(&al, "--init-rpl-role=master"); - + // $SMALL_SERVER add_arg(&al, "-O"); add_arg(&al, "key_buffer_size=1M"); @@ -329,17 +367,24 @@ void start_master() if (master_opt[0] != NULL) { char *p; + char *temp; p = (char *)strtok(master_opt, " \t"); - while(p) + if ((temp = strstr(p, "timezone")) == NULL) { - add_arg(&al, "%s", p); - - p = (char *)strtok(NULL, " \t"); + while(p) + { + add_arg(&al, "%s", p); + p = (char *)strtok(NULL, " \t"); + } + } + else + { + //do nothing } } - + // remove the pid file if it exists remove(master_pid); @@ -347,7 +392,7 @@ void start_master() if ((err = spawn(mysqld_file, &al, FALSE, NULL, master_out, master_err)) == 0) { sleep_until_file_exists(master_pid); - + if ((err = wait_for_server_start(bin_dir, user, password, master_port)) == 0) { master_running = TRUE; @@ -361,7 +406,7 @@ void start_master() { log_error("Unable to start master server."); } - + // free_args free_args(&al); } @@ -409,7 +454,7 @@ void start_slave() { // create empty master.info file snprintf(temp, PATH_MAX, "%s/master.info", slave_dir); - close(open(temp, O_WRONLY | O_CREAT)); + close(open(temp, O_WRONLY | O_CREAT,S_IRWXU|S_IRWXG|S_IRWXO)); } else if (strindex(slave_init_script, "rpl000017-slave.sh") != NULL) { @@ -434,7 +479,7 @@ void start_slave() { // create empty master.info file snprintf(temp, PATH_MAX, "%s/master.info", slave_dir); - close(open(temp, O_WRONLY | O_CREAT)); + close(open(temp, O_WRONLY | O_CREAT,S_IRWXU|S_IRWXG|S_IRWXO)); } } @@ -458,7 +503,7 @@ void start_slave() add_arg(&al, "--core"); add_arg(&al, "--tmpdir=%s", mysql_tmp_dir); add_arg(&al, "--language=%s", lang_dir); - + add_arg(&al, "--exit-info=256"); add_arg(&al, "--log-slave-updates"); add_arg(&al, "--init-rpl-role=slave"); @@ -474,6 +519,13 @@ void start_slave() add_arg(&al, "-O"); add_arg(&al, "slave_net_timeout=10"); + if (use_openssl) + { + add_arg(&al, "--ssl-ca=%s", ca_cert); + add_arg(&al, "--ssl-cert=%s", server_cert); + add_arg(&al, "--ssl-key=%s", server_key); + } + // slave master info if (slave_master_info[0] != NULL) { @@ -557,10 +609,11 @@ void start_slave() ******************************************************************************/ void mysql_start() { + log_info("Starting the MySQL server(s): %u", ++restarts); start_master(); start_slave(); - + // activate the test screen ActivateScreen(getscreenhandle()); } @@ -568,17 +621,17 @@ void mysql_start() /****************************************************************************** stop_slave() - + Stop the slave server. ******************************************************************************/ void stop_slave() { int err; - + // running? if (!slave_running) return; - + // stop if ((err = stop_server(bin_dir, user, password, slave_port, slave_pid)) == 0) { @@ -593,17 +646,17 @@ void stop_slave() /****************************************************************************** stop_master() - + Stop the master server. ******************************************************************************/ void stop_master() { int err; - + // running? if (!master_running) return; - + if ((err = stop_server(bin_dir, user, password, master_port, master_pid)) == 0) { master_running = FALSE; @@ -617,16 +670,17 @@ void stop_master() /****************************************************************************** mysql_stop() - + Stop the mysql servers. ******************************************************************************/ void mysql_stop() { + log_info("Stopping the MySQL server(s)..."); stop_master(); stop_slave(); - + // activate the test screen ActivateScreen(getscreenhandle()); } @@ -634,13 +688,12 @@ void mysql_stop() /****************************************************************************** mysql_restart() - + Restart the mysql servers. ******************************************************************************/ void mysql_restart() { - log_info("Restarting the MySQL server(s): %u", ++restarts); mysql_stop(); @@ -650,7 +703,7 @@ void mysql_restart() /****************************************************************************** read_option() - + Read the option file. ******************************************************************************/ @@ -660,10 +713,10 @@ int read_option(char *opt_file, char *opt) int result; char *p; char buf[PATH_MAX]; - + // copy current option strncpy(buf, opt, PATH_MAX); - + // open options file fd = open(opt_file, O_RDONLY); @@ -771,14 +824,19 @@ void run_test(char *test) if (stat(test_file, &info)) { snprintf(test_file, PATH_MAX, "%s/%s%s", test_dir, test, TEST_SUFFIX); + if(access(test_file,0)) + { + printf("Invalid test name %s, %s file not found\n",test,test_file); + return; + } } - + snprintf(result_file, PATH_MAX, "%s/%s%s", result_dir, test, NW_RESULT_SUFFIX); if (stat(result_file, &info)) { snprintf(result_file, PATH_MAX, "%s/%s%s", result_dir, test, RESULT_SUFFIX); } - + // init scripts snprintf(master_init_script, PATH_MAX, "%s/%s-master.sh", test_dir, test); if (stat(master_init_script, &info)) @@ -826,7 +884,14 @@ void run_test(char *test) add_arg(&al, "-v"); add_arg(&al, "-R"); add_arg(&al, "%s", result_file); - + + if (use_openssl) + { + add_arg(&al, "--ssl-ca=%s", ca_cert); + add_arg(&al, "--ssl-cert=%s", client_cert); + add_arg(&al, "--ssl-key=%s", client_key); + } + // start timer NXGetTime(NX_SINCE_BOOT, NX_USECONDS, &start); @@ -915,7 +980,7 @@ void vlog(char *format, va_list ap) void log(char *format, ...) { va_list ap; - + va_start(ap, format); vlog(format, ap); @@ -1009,8 +1074,10 @@ void die(char *msg) void setup(char *file) { char temp[PATH_MAX]; + char mysqldump_load[PATH_MAX*2],mysqlbinlog_load[PATH_MAX*2]; + char *p; - + // set the timezone for the timestamp test setenv("TZ", "GMT-3", TRUE); @@ -1023,7 +1090,7 @@ void setup(char *file) *p = NULL; strcpy(base_dir, temp); } - + // setup paths snprintf(bin_dir, PATH_MAX, "%s/bin", base_dir); snprintf(mysql_test_dir, PATH_MAX, "%s/mysql-test", base_dir); @@ -1034,7 +1101,18 @@ void setup(char *file) snprintf(slave_dir, PATH_MAX, "%s/var/slave-data", mysql_test_dir); snprintf(lang_dir, PATH_MAX, "%s/share/english", base_dir); snprintf(char_dir, PATH_MAX, "%s/share/charsets", base_dir); - + +#ifdef HAVE_OPENSSL + use_openssl = TRUE; +#endif // HAVE_OPENSSL + + // OpenSSL paths + snprintf(ca_cert, PATH_MAX, "%s/SSL/cacert.pem", base_dir); + snprintf(server_cert, PATH_MAX, "%s/SSL/server-cert.pem", base_dir); + snprintf(server_key, PATH_MAX, "%s/SSL/server-key.pem", base_dir); + snprintf(client_cert, PATH_MAX, "%s/SSL/client-cert.pem", base_dir); + snprintf(client_key, PATH_MAX, "%s/SSL/client-key.pem", base_dir); + // setup files snprintf(mysqld_file, PATH_MAX, "%s/mysqld", bin_dir); snprintf(mysqltest_file, PATH_MAX, "%s/mysqltest", bin_dir); @@ -1048,14 +1126,19 @@ void setup(char *file) { log_errno("Unable to create log file."); } - + // prepare skip test list while((p = strchr(skip_test, ',')) != NULL) *p = ' '; strcpy(temp, strlwr(skip_test)); snprintf(skip_test, PATH_MAX, " %s ", temp); - - // enviornment + + snprintf(mysqlbinlog_load,PATH_MAX*2,"%s/mysqlbinlog --no-defaults --local-load=%s",bin_dir,mysql_tmp_dir); + snprintf(mysqldump_load,PATH_MAX*2,"%s/mysqldump --no-defaults -uroot --port=%d",bin_dir,master_port); + // environment setenv("MYSQL_TEST_DIR", mysql_test_dir, 1); + setenv("MYSQL_DUMP", mysqldump_load, 1); + setenv("MYSQL_BINLOG", mysqlbinlog_load, 1); + setenv("MASTER_MYPORT", "9306", 1); } /****************************************************************************** @@ -1087,7 +1170,7 @@ int main(int argc, char **argv) int i; // single test - single_test = TRUE; + single_test = TRUE; for (i = 1; i < argc; i++) { @@ -1131,21 +1214,21 @@ int main(int argc, char **argv) closedir(dir); } - - log(DASH); - log("\n"); - - log("Ending Tests...\n"); // stop server mysql_stop(); + log(DASH); + log("\n"); + + log("Ending Tests...\n"); + // report stats report_stats(); - + // close log if (log_fd) fclose(log_fd); - + // keep results up pressanykey(); diff --git a/netware/mysqlbinlog.def b/netware/mysqlbinlog.def index 74d8e168b00..89677b4a353 100644 --- a/netware/mysqlbinlog.def +++ b/netware/mysqlbinlog.def @@ -2,6 +2,7 @@ # MySQL Binary Log #------------------------------------------------------------------------------ MODULE libc.nlm +SCREENNAME "MySQL Binary Log Dump Tool" COPYRIGHT "(c) 2003 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL Binary Log Dump Tool" VERSION 4, 0 diff --git a/netware/mysqlcheck.def b/netware/mysqlcheck.def index 6e476556ffe..8820e9aae8e 100644 --- a/netware/mysqlcheck.def +++ b/netware/mysqlcheck.def @@ -2,6 +2,7 @@ # MySQL Client #------------------------------------------------------------------------------ MODULE libc.nlm +SCREENNAME "MySQL Check Tool" COPYRIGHT "(c) 2003 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL Check Tool" VERSION 4, 0 diff --git a/netware/mysqld_safe.c b/netware/mysqld_safe.c index 845797e0022..a815497ac0f 100644 --- a/netware/mysqld_safe.c +++ b/netware/mysqld_safe.c @@ -456,10 +456,10 @@ void check_data_vol() // retrieve information netware_vol_info_from_name(&vol, buff); - + if ((vol.flags & VOL_NSS_PRESENT) == 0) { - log("Error: The data directory is not on an NSS volume!\n\n"); + log("Error: Either the data directory does not exist or is not on an NSS volume!\n\n"); exit(-1); } } diff --git a/netware/mysqldump.def b/netware/mysqldump.def index f267b60ff77..901c9b262dc 100644 --- a/netware/mysqldump.def +++ b/netware/mysqldump.def @@ -2,6 +2,7 @@ # MySQL Admin #------------------------------------------------------------------------------ MODULE libc.nlm +SCREENNAME "MySQL Dump Tool" COPYRIGHT "(c) 2003 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL Dump Tool" VERSION 4, 0 diff --git a/netware/mysqlimport.def b/netware/mysqlimport.def index 69e9f6eada5..d6f7fcb6bbd 100644 --- a/netware/mysqlimport.def +++ b/netware/mysqlimport.def @@ -2,6 +2,7 @@ # MySQL Client #------------------------------------------------------------------------------ MODULE libc.nlm +SCREENNAME "MySQL Import" COPYRIGHT "(c) 2003 Novell, Inc. Portions (c) 2003 MySQL AB. All Rights Reserved." DESCRIPTION "MySQL Import Tool" VERSION 4, 0 From e1d5f62041deaf97e139e660bc57a0de784f76e6 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 12 Jan 2004 22:47:26 -0400 Subject: [PATCH 025/113] Fixed Bug #2338 Trigonometric arithmetic problem by fixing optimizer bug with help of 'volatile' keyword mysql-test/r/func_math.result: added tests for BUG #2338 Trigonometric arithmetic problems mysql-test/t/func_math.test: added tests for BUG #2338 Trigonometric arithmetic problems sql/item_func.cc: added keyword volatile in Item_func_acos::val and Item_func_asin::val to calm optimizer down and to avoid it's bug --- mysql-test/r/func_math.result | 12 ++++++++++++ mysql-test/t/func_math.test | 11 +++++++++++ sql/item_func.cc | 6 ++++-- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/func_math.result b/mysql-test/r/func_math.result index e2723311682..5e774fe9886 100644 --- a/mysql-test/r/func_math.result +++ b/mysql-test/r/func_math.result @@ -20,3 +20,15 @@ PI() sin(pi()/2) cos(pi()/2) abs(tan(pi())) cot(1) asin(1) acos(0) atan(1) 3.141593 1.000000 0.000000 0.000000 0.64209262 1.570796 1.570796 0.785398 degrees(pi()) radians(360) 180 6.2831853071796 +ACOS(1.0) +0.000000 +ASIN(1.0) +1.570796 +ACOS(0.2*5.0) +0.000000 +ACOS(0.5*2.0) +0.000000 +ASIN(0.8+0.2) +1.570796 +ASIN(1.2-0.2) +1.570796 diff --git a/mysql-test/t/func_math.test b/mysql-test/t/func_math.test index 5299897d0f0..42ba8c73f69 100644 --- a/mysql-test/t/func_math.test +++ b/mysql-test/t/func_math.test @@ -13,3 +13,14 @@ select pow(10,log10(10)),power(2,4); select rand(999999),rand(); select pi(),sin(pi()/2),cos(pi()/2),abs(tan(pi())),cot(1),asin(1),acos(0),atan(1); select degrees(pi()),radians(360); + +# +# Bug #2338 Trignometric arithmatic problems +# + +SELECT ACOS(1.0); +SELECT ASIN(1.0); +SELECT ACOS(0.2*5.0); +SELECT ACOS(0.5*2.0); +SELECT ASIN(0.8+0.2); +SELECT ASIN(1.2-0.2); diff --git a/sql/item_func.cc b/sql/item_func.cc index 217768db2c5..28a1c428cab 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -456,7 +456,8 @@ double Item_func_pow::val() double Item_func_acos::val() { - double value=args[0]->val(); + // this 'volatile' was added as a fix for BUG #2338 to calm optimizer down + volatile double value=args[0]->val(); if ((null_value=(args[0]->null_value || (value < -1.0 || value > 1.0)))) return 0.0; return fix_result(acos(value)); @@ -464,7 +465,8 @@ double Item_func_acos::val() double Item_func_asin::val() { - double value=args[0]->val(); + // this 'volatile' was added as a fix for BUG #2338 to calm optimizer down + volatile double value=args[0]->val(); if ((null_value=(args[0]->null_value || (value < -1.0 || value > 1.0)))) return 0.0; return fix_result(asin(value)); From febc79bb5d8a7cfe1f8e5eef50595f321786c467 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 13 Jan 2004 12:31:25 +0100 Subject: [PATCH 026/113] BUG#2304 - HANDLER and tables in non-current db --- mysql-test/r/handler.result | 18 ++++++++++++++++++ mysql-test/t/handler.test | 16 ++++++++++++++++ sql/sql_handler.cc | 7 +++---- sql/sql_yacc.yy | 15 ++++++++++----- 4 files changed, 47 insertions(+), 9 deletions(-) diff --git a/mysql-test/r/handler.result b/mysql-test/r/handler.result index 5467ea6dec2..1cfc3a9de8b 100644 --- a/mysql-test/r/handler.result +++ b/mysql-test/r/handler.result @@ -173,3 +173,21 @@ Unknown column 'W' in 'field list' handler t1 read a=(a); Wrong arguments to HANDLER ... READ drop table t1; +create table t1 (a char(5)); +insert into t1 values ("Ok"); +handler t1 open as t; +handler t read first; +a +Ok +use mysql; +handler t read first; +a +Ok +handler t close; +handler test.t1 open as t; +handler t read first; +a +Ok +handler t close; +use test; +drop table t1; diff --git a/mysql-test/t/handler.test b/mysql-test/t/handler.test index 736091a52a9..936902fd9bf 100644 --- a/mysql-test/t/handler.test +++ b/mysql-test/t/handler.test @@ -107,3 +107,19 @@ handler t1 read a=(W); handler t1 read a=(a); drop table t1; +# +# BUG#2304 +# +create table t1 (a char(5)); +insert into t1 values ("Ok"); +handler t1 open as t; +handler t read first; +use mysql; +handler t read first; +handler t close; +handler test.t1 open as t; +handler t read first; +handler t close; +use test; +drop table t1; + diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index 208545a435b..963111015da 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -276,14 +276,13 @@ static TABLE **find_table_ptr_by_name(THD *thd, const char *db, int dblen; TABLE **ptr; - if (!db || ! *db) - db= thd->db ? thd->db : ""; - dblen=strlen(db)+1; + DBUG_ASSERT(db); + dblen=*db ? strlen(db)+1 : 0; ptr=&(thd->handler_tables); for (TABLE *table=*ptr; table ; table=*ptr) { - if (!memcmp(table->table_cache_key, db, dblen) && + if ((!dblen || !memcmp(table->table_cache_key, db, dblen)) && !my_strcasecmp((is_alias ? table->table_name : table->real_name),table_name)) { if (table->version != refresh_version) diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index b5b9a4cdfb7..991a5f500e6 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -501,7 +501,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); opt_table_alias %type - table_ident + table_ident table_ident_ref %type remember_name remember_end opt_len opt_ident opt_db text_or_password @@ -3243,8 +3243,13 @@ field_ident: table_ident: ident { $$=new Table_ident($1); } | ident '.' ident { $$=new Table_ident($1,$3,0);} - | '.' ident { $$=new Table_ident($2);} - /* For Delphi */; + | '.' ident { $$=new Table_ident($2);} /* For Delphi */ + ; + +table_ident_ref: + ident { LEX_STRING db={"",0}; $$=new Table_ident(db,$1,0); } + | ident '.' ident { $$=new Table_ident($1,$3,0);} + ; ident: IDENT { $$=$1; } @@ -3610,13 +3615,13 @@ handler: if (!add_table_to_list($2,$4,0)) YYABORT; } - | HANDLER_SYM table_ident CLOSE_SYM + | HANDLER_SYM table_ident_ref CLOSE_SYM { Lex->sql_command = SQLCOM_HA_CLOSE; if (!add_table_to_list($2,0,0)) YYABORT; } - | HANDLER_SYM table_ident READ_SYM + | HANDLER_SYM table_ident_ref READ_SYM { LEX *lex=Lex; lex->sql_command = SQLCOM_HA_READ; From 54ee2705b0f9594bcae77ba62a55f287ec90e8d4 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 13 Jan 2004 19:33:01 +0100 Subject: [PATCH 027/113] - improved wording in mysql_install_db on what to do to set the password for the MySQL root user (BUG#2375) scripts/mysql_install_db.sh: - improved wording on what to do to set the password for the MySQL root user (BUG#2375) --- scripts/mysql_install_db.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index ba95ff3b5b9..6d6bacd831e 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -340,7 +340,7 @@ then echo fi echo "PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !" - echo "This is done with:" + echo "To do so, start the server, then issue the following commands:" echo "$bindir/mysqladmin -u root password 'new-password'" echo "$bindir/mysqladmin -u root -h $hostname password 'new-password'" echo "See the manual for more instructions." From 4ee3e7dc69d7ef15d290d935336331ec27c025dd Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 13 Jan 2004 19:44:33 +0100 Subject: [PATCH 028/113] - be able to build MySQL-shared-compat RPMs for other archs than i386 --- support-files/MySQL-shared-compat.spec.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/support-files/MySQL-shared-compat.spec.sh b/support-files/MySQL-shared-compat.spec.sh index 06dfec1f6f9..2a257a601a1 100644 --- a/support-files/MySQL-shared-compat.spec.sh +++ b/support-files/MySQL-shared-compat.spec.sh @@ -42,8 +42,8 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-build Obsoletes: MySQL-shared, mysql-shared Provides: MySQL-shared Summary: MySQL shared libraries for MySQL %{version4} and %{version3} -Source0: MySQL-shared-%{version4}-0.i386.rpm -Source1: MySQL-shared-%{version3}-1.i386.rpm +Source0: MySQL-shared-%{version4}-0.%{_arch}.rpm +Source1: MySQL-shared-%{version3}-1.%{_arch}.rpm # No need to include the RPMs once more - they can be downloaded seperately # if you want to rebuild this package NoSource: 0 From d7c2c8f1f998cfff2ee39ce5aaa0a17920898ecf Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 14 Jan 2004 16:21:54 +0200 Subject: [PATCH 029/113] row0ins.c: Fix bug: FOREIGN KEY ... ON UPDATE/DELETE NO ACTION must check the foreign key constraint, not ignore it. Peter Gulutzan said that NO ACTION should check the constraint as deferred, at the end of the SQL statement, while RESTRICT should check it immediately. Since we do not have defered constraints in InnoDB, this bug fix makes InnoDB to check NO ACTION constraints immediately, like it checks RESTRICT constraints. innobase/row/row0ins.c: Fix bug: FOREIGN KEY ... ON UPDATE/DELETE NO ACTION must check the foreign key constraint, not ignore it. Peter Gulutzan said that NO ACTION should check the constraint as deferred, at the end of the SQL statement, while RESTRICT should check it immediately. Since we do not have defered constraints in InnoDB, this bug fix makes InnoDB to check NO ACTION constraints immediately, like it checks RESTRICT constraints. --- innobase/row/row0ins.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/innobase/row/row0ins.c b/innobase/row/row0ins.c index 45c5897eee7..d589cc8c9bc 100644 --- a/innobase/row/row0ins.c +++ b/innobase/row/row0ins.c @@ -682,14 +682,6 @@ row_ins_foreign_check_on_constraint( (DICT_FOREIGN_ON_DELETE_CASCADE | DICT_FOREIGN_ON_DELETE_SET_NULL))) { - /* No action is defined: return a foreign key error if - NO ACTION is not specified */ - - if (foreign->type & DICT_FOREIGN_ON_DELETE_NO_ACTION) { - - return(DB_SUCCESS); - } - row_ins_foreign_report_err((char*)"Trying to delete", thr, foreign, btr_pcur_get_rec(pcur), entry); @@ -703,14 +695,6 @@ row_ins_foreign_check_on_constraint( /* This is an UPDATE */ - /* No action is defined: return a foreign key error if - NO ACTION is not specified */ - - if (foreign->type & DICT_FOREIGN_ON_UPDATE_NO_ACTION) { - - return(DB_SUCCESS); - } - row_ins_foreign_report_err((char*)"Trying to update", thr, foreign, btr_pcur_get_rec(pcur), entry); From 81e869bcf2dd2d4a4d534e2fc73a85a906cc5e4e Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 15 Jan 2004 16:14:30 +0100 Subject: [PATCH 030/113] - fixed early removing of socket file when multiple instances of mysqld are started via mysqld_safe (BUG#2114) Thanks to Rodrigo Marchant for the suggestion scripts/mysqld_safe.sh: - fixed early removing of socket file when multiple instances of mysqld are started via the script (BUG#2114) Thanks to Rodrigo Marchant for the suggestion --- scripts/mysqld_safe.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index 5d77863c9b4..0f415ccd5f0 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -115,7 +115,6 @@ else ledir=@libexecdir@ fi -safe_mysql_unix_port=${mysql_unix_port:-${MYSQL_UNIX_PORT:-@MYSQL_UNIX_ADDR@}} user=@MYSQLD_USER@ niceness=0 @@ -155,6 +154,7 @@ then fi parse_arguments `$print_defaults --loose-verbose $defaults mysqld_safe safe_mysqld` parse_arguments PICK-ARGS-FROM-ARGV "$@" +safe_mysql_unix_port=${mysql_unix_port:-${MYSQL_UNIX_PORT:-@MYSQL_UNIX_ADDR@}} if test ! -x $ledir/$MYSQLD then From ae4b94598c08747fcb75480ebe7ab2681f38bde6 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 15 Jan 2004 16:31:27 +0100 Subject: [PATCH 031/113] an obvious bug in _mi_key_cmp fixed (BUG#2295 - range on blobs) --- myisam/mi_search.c | 10 ++++++---- mysql-test/r/range.result | 8 ++++++++ mysql-test/t/range.test | 12 ++++++++++++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/myisam/mi_search.c b/myisam/mi_search.c index 5d0750f6a82..c6ee18a8477 100644 --- a/myisam/mi_search.c +++ b/myisam/mi_search.c @@ -840,9 +840,11 @@ int _mi_key_cmp(register MI_KEYSEG *keyseg, register uchar *a, break; case HA_KEYTYPE_VARTEXT: { - int a_length,b_length,pack_length; + int a_length,full_a_length,b_length,full_b_length,pack_length; get_key_length(a_length,a); get_key_pack_length(b_length,pack_length,b); + full_a_length=a_length; + full_b_length=b_length; next_key_length=key_length-b_length-pack_length; if (!(nextflag & (SEARCH_PREFIX | SEARCH_UPDATE))) @@ -857,8 +859,8 @@ int _mi_key_cmp(register MI_KEYSEG *keyseg, register uchar *a, (my_bool) ((nextflag & SEARCH_PREFIX) && next_key_length <= 0)))) return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag); - a+=a_length; - b+=b_length; + a+=full_a_length; + b+=full_b_length; break; } break; @@ -963,7 +965,7 @@ int _mi_key_cmp(register MI_KEYSEG *keyseg, register uchar *a, if (keyseg->flag & HA_REVERSE_SORT) { - swap(uchar*,a,b); + swap(uchar*,a,b); swap_flag=1; /* Remember swap of a & b */ end= a+ (int) (end-b); } diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result index e87df9a6c24..45d20a8fced 100644 --- a/mysql-test/r/range.result +++ b/mysql-test/r/range.result @@ -300,3 +300,11 @@ SELECT COUNT(*) FROM t1 WHERE (c=0 and b=1) or (c=0 and a=1); COUNT(*) 6 DROP TABLE t1; +create table t1(a text not null, b text not null, c text not null, index (a(10),b(10),c(10))); +insert into t1 values('807780', '477', '165'); +insert into t1 values('807780', '477', '162'); +insert into t1 values('807780', '472', '162'); +select * from t1 where a='807780' and b='477' and c='165'; +a b c +807780 477 165 +drop table t1; diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test index 364ea2d4195..9d9feaa4edc 100644 --- a/mysql-test/t/range.test +++ b/mysql-test/t/range.test @@ -248,3 +248,15 @@ INSERT INTO t1 VALUES (0,1,0),(0,1,0),(0,1,0); SELECT COUNT(*) FROM t1 WHERE (c=0 and a=1) or (c=0 and b=1); SELECT COUNT(*) FROM t1 WHERE (c=0 and b=1) or (c=0 and a=1); DROP TABLE t1; + +# +# BUG#2295 - range on blob +# + +create table t1(a text not null, b text not null, c text not null, index (a(10),b(10),c(10))); +insert into t1 values('807780', '477', '165'); +insert into t1 values('807780', '477', '162'); +insert into t1 values('807780', '472', '162'); +select * from t1 where a='807780' and b='477' and c='165'; +drop table t1; + From f6940525aa6aec2c56aeffae919cc536fc577291 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 15 Jan 2004 16:08:32 -0100 Subject: [PATCH 032/113] Wrote small Windows build automation script in preparation for re-working project files and enabling remote builds. --- Build-tools/Do-win-build | 82 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100755 Build-tools/Do-win-build diff --git a/Build-tools/Do-win-build b/Build-tools/Do-win-build new file mode 100755 index 00000000000..b446ba6f601 --- /dev/null +++ b/Build-tools/Do-win-build @@ -0,0 +1,82 @@ +#!/usr/bin/perl -w + +use Getopt::Long; + +$opt_help=0; +$opt_tarball=$opt_builddir=""; + +GetOptions( + "help", + "tarball=s", + "builddir=s", +) || print_help(); + +print_help() if ($opt_help); + +chomp($MSDEV=`which msdev`); + +if (!$opt_builddir) { + $opt_builddir = "/cygdrive/c/mysql-win-build"; +} + +$opt_tarball =~ /(mysql[^\/]*)-win-src\.tar/; +$mysqlver=$1; +$basedir = "$opt_builddir/$mysqlver"; + +# Make sure build dir exists +mkdir($opt_builddir); +# Clean out any previous build +system("rm -rf $basedir"); +mkdir($basedir); +mkdir("$basedir/tarball"); + +system("cp $opt_tarball $basedir/tarball"); + +if (!chdir($basedir)) +{ + print "Do-win-build error: Could not change to $opt_builddir"; + exit 1; +} + +mkdir("build"); +chdir("build"); + +system("tar -zxvf ../tarball/$mysqlver-win-src.tar.gz"); + +chdir($mysqlver); + +system("\"$MSDEV\" mysql.dsw /MAKE \"ALL\" /OUT $mysqlver-build.log"); + +# +# Print a help text message +# +sub print_help +{ + print < +Set the Cygwin path to build under; the tarball will actually +be moved to /mysql-/tarball and extracted under +/mysql-/build. +Default: /cygdrive/c/mysql-win-build + +--tarball= +Windows source tarball to use for this build. Must be of the form +mysql[com]-x.x.x-win-src.tar.gz (REQUIRED) + +EOF + exit 1; +} From 130ae28ccac7c482861f85bc3009b52283364f2a Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 15 Jan 2004 21:39:56 +0100 Subject: [PATCH 033/113] Fixed table crash bug when updating row > 16M (Bug #2159) myisam/mi_dynrec.c: Fixed table crash bug when updating row > 16M --- myisam/mi_dynrec.c | 134 ++++++++++++++++++++-------- mysql-test/r/myisam-blob.result | 27 ++++++ mysql-test/t/myisam-blob-master.opt | 1 + mysql-test/t/myisam-blob.test | 30 +++++++ 4 files changed, 156 insertions(+), 36 deletions(-) create mode 100644 mysql-test/r/myisam-blob.result create mode 100644 mysql-test/t/myisam-blob-master.opt create mode 100644 mysql-test/t/myisam-blob.test diff --git a/myisam/mi_dynrec.c b/myisam/mi_dynrec.c index e1bfe4c3ac5..f83516bc95c 100644 --- a/myisam/mi_dynrec.c +++ b/myisam/mi_dynrec.c @@ -14,7 +14,15 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - /* Functions to handle space-packed-records and blobs */ +/* + Functions to handle space-packed-records and blobs + + A row may be stored in one or more linked blocks. + The block size is between MI_MIN_BLOCK_LENGTH and MI_MAX_BLOCK_LENGTH. + Each block is aligned on MI_DYN_ALIGN_SIZE. + The reson for the max block size is to not have too many different types + of blocks. For the differnet block types, look at _mi_get_block_info() +*/ #include "myisamdef.h" #include @@ -264,6 +272,48 @@ static bool unlink_deleted_block(MI_INFO *info, MI_BLOCK_INFO *block_info) DBUG_RETURN(0); } + +/* + Add a backward link to delete block + + SYNOPSIS + update_backward_delete_link() + info MyISAM handler + delete_block Position to delete block to update. + If this is 'HA_OFFSET_ERROR', nothing will be done + filepos Position to block that 'delete_block' should point to + + RETURN + 0 ok + 1 error. In this case my_error is set. +*/ + +static int update_backward_delete_link(MI_INFO *info, my_off_t delete_block, + my_off_t filepos) +{ + MI_BLOCK_INFO block_info; + DBUG_ENTER("update_backward_delete_link"); + + if (delete_block != HA_OFFSET_ERROR) + { + block_info.second_read=0; + if (_mi_get_block_info(&block_info,info->dfile,delete_block) + & BLOCK_DELETED) + { + char buff[8]; + mi_sizestore(buff,filepos); + if (my_pwrite(info->dfile,buff, 8, delete_block+12, MYF(MY_NABP))) + DBUG_RETURN(1); /* Error on write */ + } + else + { + my_errno=HA_ERR_WRONG_IN_RECORD; + DBUG_RETURN(1); /* Wrong delete link */ + } + } + return 0; +} + /* Delete datarecord from database */ /* info->rec_cache.seek_not_done is updated in cmp_record */ @@ -272,29 +322,12 @@ static int delete_dynamic_record(MI_INFO *info, my_off_t filepos, { uint length,b_type; MI_BLOCK_INFO block_info,del_block; - int error=0; + int error; my_bool remove_next_block; DBUG_ENTER("delete_dynamic_record"); /* First add a link from the last block to the new one */ - if (info->s->state.dellink != HA_OFFSET_ERROR) - { - block_info.second_read=0; - if (_mi_get_block_info(&block_info,info->dfile,info->s->state.dellink) - & BLOCK_DELETED) - { - char buff[8]; - mi_sizestore(buff,filepos); - if (my_pwrite(info->dfile,buff,8,info->s->state.dellink+12, - MYF(MY_NABP))) - error=1; /* Error on write */ - } - else - { - error=1; /* Wrong delete link */ - my_errno=HA_ERR_WRONG_IN_RECORD; - } - } + error= update_backward_delete_link(info, info->s->state.dellink, filepos); block_info.second_read=second_read; do @@ -518,21 +551,11 @@ int _mi_write_part_record(MI_INFO *info, *reclength-=(length-head_length); *flag=6; - if (del_length && next_delete_block != HA_OFFSET_ERROR) + if (del_length) { /* link the next delete block to this */ - MI_BLOCK_INFO del_block; - del_block.second_read=0; - if (!(_mi_get_block_info(&del_block,info->dfile,next_delete_block) - & BLOCK_DELETED)) - { - my_errno=HA_ERR_WRONG_IN_RECORD; - goto err; - } - mi_sizestore(del_block.header+12,info->s->state.dellink); - if (my_pwrite(info->dfile,(char*) del_block.header+12,8, - next_delete_block+12, - MYF(MY_NABP))) + if (update_backward_delete_link(info, next_delete_block, + info->s->state.dellink)) goto err; } @@ -574,6 +597,8 @@ static int update_dynamic_record(MI_INFO *info, my_off_t filepos, byte *record, { uint tmp=MY_ALIGN(reclength - length + 3 + test(reclength >= 65520L),MI_DYN_ALIGN_SIZE); + /* Don't create a block bigger than MI_MAX_BLOCK_LENGTH */ + tmp= min(length+tmp, MI_MAX_BLOCK_LENGTH)-length; /* Check if we can extend this block */ if (block_info.filepos + block_info.block_len == info->state->data_file_length && @@ -588,9 +613,15 @@ static int update_dynamic_record(MI_INFO *info, my_off_t filepos, byte *record, info->update|= HA_STATE_WRITE_AT_END | HA_STATE_EXTEND_BLOCK; length+=tmp; } - else + else if (length < MI_MAX_BLOCK_LENGTH - MI_MIN_BLOCK_LENGTH) { - /* Check if next block is a deleted block */ + /* + Check if next block is a deleted block + Above we have MI_MIN_BLOCK_LENGTH to avoid the problem where + the next block is so small it can't be splited which could + casue problems + */ + MI_BLOCK_INFO del_block; del_block.second_read=0; if (_mi_get_block_info(&del_block,info->dfile, @@ -601,7 +632,35 @@ static int update_dynamic_record(MI_INFO *info, my_off_t filepos, byte *record, DBUG_PRINT("info",("Extending current block")); if (unlink_deleted_block(info,&del_block)) goto err; - length+=del_block.block_len; + if ((length+=del_block.block_len) > MI_MAX_BLOCK_LENGTH) + { + /* + New block was too big, link overflow part back to + delete list + */ + my_off_t next_pos; + ulong rest_length= length-MI_MAX_BLOCK_LENGTH; + set_if_bigger(rest_length, MI_MIN_BLOCK_LENGTH); + next_pos= del_block.filepos+ del_block.block_len - rest_length; + + if (update_backward_delete_link(info, info->s->state.dellink, + next_pos)) + DBUG_RETURN(1); + + /* create delete link for data that didn't fit into the page */ + del_block.header[0]=0; + mi_int3store(del_block.header+1, rest_length); + mi_sizestore(del_block.header+4,info->s->state.dellink); + bfill(del_block.header+12,8,255); + if (my_pwrite(info->dfile,(byte*) del_block.header,20, next_pos, + MYF(MY_NABP))) + DBUG_RETURN(1); + info->s->state.dellink= next_pos; + info->s->state.split++; + info->state->del++; + info->state->empty+= rest_length; + length-= rest_length; + } } } } @@ -615,7 +674,10 @@ static int update_dynamic_record(MI_INFO *info, my_off_t filepos, byte *record, &record,&reclength,&flag)) goto err; if ((filepos=block_info.next_filepos) == HA_OFFSET_ERROR) + { + /* Start writing data on deleted blocks */ filepos=info->s->state.dellink; + } } if (block_info.next_filepos != HA_OFFSET_ERROR) diff --git a/mysql-test/r/myisam-blob.result b/mysql-test/r/myisam-blob.result new file mode 100644 index 00000000000..743d4dac254 --- /dev/null +++ b/mysql-test/r/myisam-blob.result @@ -0,0 +1,27 @@ +drop table if exists t1; +CREATE TABLE t1 (data LONGBLOB) ENGINE=myisam; +INSERT INTO t1 (data) VALUES (NULL); +UPDATE t1 set data=repeat('a',18*1024*1024); +select length(data) from t1; +length(data) +18874368 +delete from t1 where left(data,1)='a'; +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +truncate table t1; +INSERT INTO t1 (data) VALUES (repeat('a',1*1024*1024)); +INSERT INTO t1 (data) VALUES (repeat('b',16*1024*1024-1024)); +delete from t1 where left(data,1)='b'; +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +UPDATE t1 set data=repeat('c',17*1024*1024); +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +delete from t1 where left(data,1)='c'; +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +drop table t1; diff --git a/mysql-test/t/myisam-blob-master.opt b/mysql-test/t/myisam-blob-master.opt new file mode 100644 index 00000000000..1a1076c7bad --- /dev/null +++ b/mysql-test/t/myisam-blob-master.opt @@ -0,0 +1 @@ +--max-allowed-packet=24M --skip-innodb --key-buffer-size=1M diff --git a/mysql-test/t/myisam-blob.test b/mysql-test/t/myisam-blob.test new file mode 100644 index 00000000000..d58222ec8bf --- /dev/null +++ b/mysql-test/t/myisam-blob.test @@ -0,0 +1,30 @@ +# +# Test bugs in the MyISAM code with blobs +# + +--disable_warnings +drop table if exists t1; +--enable_warnings + +# Bug #2159 (Problem with update of blob to > 16M) + +CREATE TABLE t1 (data LONGBLOB) ENGINE=myisam; +INSERT INTO t1 (data) VALUES (NULL); +UPDATE t1 set data=repeat('a',18*1024*1024); +select length(data) from t1; +delete from t1 where left(data,1)='a'; +check table t1; +truncate table t1; +INSERT INTO t1 (data) VALUES (repeat('a',1*1024*1024)); +INSERT INTO t1 (data) VALUES (repeat('b',16*1024*1024-1024)); +delete from t1 where left(data,1)='b'; +check table t1; + +# now we have two blocks in the table, first is a 1M record and second is +# a 16M delete block. + +UPDATE t1 set data=repeat('c',17*1024*1024); +check table t1; +delete from t1 where left(data,1)='c'; +check table t1; +drop table t1; From 2ff0016df35be813d335178cab2df0c99e6cbeff Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 16 Jan 2004 19:18:57 +0400 Subject: [PATCH 034/113] a fix (Bug #2298: Trailing whitespace inconsistently handled in WHERE clause) --- myisam/mi_key.c | 4 ++-- myisam/mi_search.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/myisam/mi_key.c b/myisam/mi_key.c index 766ecf334b6..58318697e57 100644 --- a/myisam/mi_key.c +++ b/myisam/mi_key.c @@ -62,7 +62,7 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key, end=pos+length; if (type != HA_KEYTYPE_NUM) { - while (end > pos && end[-1] == ' ') + while (end > pos && (end[-1] == ' ' || end[-1] == '\t')) end--; } else @@ -186,7 +186,7 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old, end=pos+length; if (type != HA_KEYTYPE_NUM) { - while (end > pos && end[-1] == ' ') + while (end > pos && (end[-1] == ' ' || end[-1] == '\t')) end--; } else diff --git a/myisam/mi_search.c b/myisam/mi_search.c index c6ee18a8477..82004c6f172 100644 --- a/myisam/mi_search.c +++ b/myisam/mi_search.c @@ -795,9 +795,9 @@ int _mi_key_cmp(register MI_KEYSEG *keyseg, register uchar *a, uint length=(uint) (end-a), a_length=length, b_length=length; if (!(nextflag & SEARCH_PREFIX)) { - while (a_length && a[a_length-1] == ' ') + while (a_length && (a[a_length-1] == ' ' || a[a_length-1] == '\t')) a_length--; - while (b_length && b[b_length-1] == ' ') + while (b_length && (b[b_length-1] == ' ' || b[b_length-1] == '\t')) b_length--; } if (piks && @@ -849,9 +849,9 @@ int _mi_key_cmp(register MI_KEYSEG *keyseg, register uchar *a, if (!(nextflag & (SEARCH_PREFIX | SEARCH_UPDATE))) { - while (a_length && a[a_length-1] == ' ') + while (a_length && (a[a_length-1] == ' ' || a[a_length-1] == '\t')) a_length--; - while (b_length && b[b_length-1] == ' ') + while (b_length && (b[b_length-1] == ' ' || b[b_length-1] == '\t')) b_length--; } if (piks && From 8badeb5b83ab9b45a7f717f14c546ce610e46c4d Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 16 Jan 2004 21:01:58 +0300 Subject: [PATCH 035/113] typo fixed PPTHREAD -> PTHREAD --- mysys/my_thr_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c index 57eecd7b746..878a861bc94 100644 --- a/mysys/my_thr_init.c +++ b/mysys/my_thr_init.c @@ -105,7 +105,7 @@ void my_thread_global_end(void) #ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP pthread_mutexattr_destroy(&my_fast_mutexattr); #endif -#ifdef PPTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP +#ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP pthread_mutexattr_destroy(&my_errchk_mutexattr); #endif pthread_mutex_destroy(&THR_LOCK_malloc); From 36d82d189a258989a3c4cfdecc2011e240f65cdb Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 18 Jan 2004 17:51:20 +0100 Subject: [PATCH 036/113] BUG#2428 "--old-rpl-compat is broken": I remove the --old-rpl-compat which produces broken binlogs readable neither by 4.0 nor by 3.23. This option is a leftover of the early replication of 4.0.0, when it was still partly compatible with 3.23. I explained this to the user in the bug report. sql/mysqld.cc: removing --old-rpl-compat sql/sql_load.cc: removing --old-rpl-compat sql/sql_repl.h: removing --old-rpl-compat --- sql/mysqld.cc | 7 +------ sql/sql_load.cc | 36 ++++++++++++------------------------ sql/sql_repl.h | 2 +- 3 files changed, 14 insertions(+), 31 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 28cf466f5b3..b2b53e571c3 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -306,7 +306,6 @@ char* log_error_file_ptr= log_error_file; static pthread_t select_thread; static my_bool opt_noacl=0, opt_bootstrap=0, opt_myisam_log=0; my_bool opt_safe_user_create = 0, opt_no_mix_types = 0; -my_bool opt_old_rpl_compat; my_bool opt_show_slave_auth_info, opt_sql_bin_update = 0; my_bool opt_log_slave_updates= 0, opt_console= 0; my_bool opt_readonly = 0; @@ -3198,7 +3197,7 @@ enum options_mysqld { OPT_HAVE_NAMED_PIPE, OPT_DO_PSTACK, OPT_REPORT_HOST, OPT_REPORT_USER, OPT_REPORT_PASSWORD, OPT_REPORT_PORT, - OPT_SHOW_SLAVE_AUTH_INFO, OPT_OLD_RPL_COMPAT, + OPT_SHOW_SLAVE_AUTH_INFO, OPT_SLAVE_LOAD_TMPDIR, OPT_NO_MIX_TYPE, OPT_RPL_RECOVERY_RANK,OPT_INIT_RPL_ROLE, OPT_RELAY_LOG, OPT_RELAY_LOG_INDEX, OPT_RELAY_LOG_INFO_FILE, @@ -3544,10 +3543,6 @@ Does nothing yet.", {"old-protocol", 'o', "Use the old (3.20) protocol client/server protocol", (gptr*) &protocol_version, (gptr*) &protocol_version, 0, GET_UINT, NO_ARG, PROTOCOL_VERSION, 0, 0, 0, 0, 0}, - {"old-rpl-compat", OPT_OLD_RPL_COMPAT, - "Use old LOAD DATA format in the binary log (don't save data in file)", - (gptr*) &opt_old_rpl_compat, (gptr*) &opt_old_rpl_compat, 0, GET_BOOL, - NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef ONE_THREAD {"one-thread", OPT_ONE_THREAD, "Only use one thread (for debugging under Linux)", 0, 0, 0, GET_NO_ARG, diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 7c3e7b8e877..93dfcd84caf 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -220,7 +220,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, DBUG_RETURN(-1); // Can't allocate buffers } - if (!opt_old_rpl_compat && mysql_bin_log.is_open()) + if (mysql_bin_log.is_open()) { lf_info.thd = thd; lf_info.ex = ex; @@ -287,7 +287,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, { if (transactional_table) ha_autocommit_or_rollback(thd,error); - if (!opt_old_rpl_compat && mysql_bin_log.is_open()) + if (mysql_bin_log.is_open()) { /* Make sure last block (the one which caused the error) gets logged. @@ -332,28 +332,16 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, thd->options|=OPTION_STATUS_NO_TRANS_UPDATE; if (mysql_bin_log.is_open()) { - if (opt_old_rpl_compat) + /* + As already explained above, we need to call end_io_cache() or the last + block will be logged only after Execute_load_log_event (which is wrong), + when read_info is destroyed. + */ + read_info.end_io_cache(); + if (lf_info.wrote_create_file) { - if (!read_file_from_client) - { - Load_log_event qinfo(thd, ex, db, table->table_name, fields, - handle_duplicates, log_delayed); - mysql_bin_log.write(&qinfo); - } - } - else - { - /* - As already explained above, we need to call end_io_cache() or the last - block will be logged only after Execute_load_log_event (which is wrong), - when read_info is destroyed. - */ - read_info.end_io_cache(); - if (lf_info.wrote_create_file) - { - Execute_load_log_event e(thd, db, log_delayed); - mysql_bin_log.write(&e); - } + Execute_load_log_event e(thd, db, log_delayed); + mysql_bin_log.write(&e); } } if (transactional_table) @@ -644,7 +632,7 @@ READ_INFO::READ_INFO(File file_par, uint tot_length, String &field_term, cache.read_function = _my_b_net_read; need_end_io_cache = 1; - if (!opt_old_rpl_compat && mysql_bin_log.is_open()) + if (mysql_bin_log.is_open()) cache.pre_read = cache.pre_close = (IO_CACHE_CALLBACK) log_loaded_block; } diff --git a/sql/sql_repl.h b/sql/sql_repl.h index c73744c4b7c..570c41c98f7 100644 --- a/sql/sql_repl.h +++ b/sql/sql_repl.h @@ -11,7 +11,7 @@ typedef struct st_slave_info THD* thd; } SLAVE_INFO; -extern my_bool opt_show_slave_auth_info, opt_old_rpl_compat; +extern my_bool opt_show_slave_auth_info; extern char *master_host, *master_info_file; extern bool server_id_supplied; extern I_List binlog_do_db, binlog_ignore_db; From 45591dec328f2a9dd4a402a263b4e919bc185d82 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 19 Jan 2004 23:10:01 +0100 Subject: [PATCH 037/113] Fixed bug in IN() optimization --- sql/sql_select.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 1d7187824fe..e3bd3c8b570 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1475,8 +1475,8 @@ add_key_field(KEY_FIELD **key_fields,uint and_level, bool optimizable=0; for (uint i=0; iused_tables(); - if (!((*value)->used_tables() & (field->table->map | RAND_TABLE_BIT))) + used_tables|=(value[i])->used_tables(); + if (!((value[i])->used_tables() & (field->table->map | RAND_TABLE_BIT))) optimizable=1; } if (!optimizable) From fe9647968d1aaa02dfab2d13cc9c9d7f27bb2228 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 19 Jan 2004 23:44:39 +0100 Subject: [PATCH 038/113] Proper fix for bug with BLOB in MIN/MAX sql/key.cc: Change constant to define --- sql/key.cc | 4 ++-- sql/opt_sum.cc | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/sql/key.cc b/sql/key.cc index 809c5a164b9..0a5937fc881 100644 --- a/sql/key.cc +++ b/sql/key.cc @@ -182,9 +182,9 @@ int key_cmp(TABLE *table,const byte *key,uint idx,uint key_length) } if (key_part->key_part_flag & (HA_BLOB_PART | HA_VAR_LENGTH)) { - if (key_part->field->key_cmp(key, key_part->length+2)) + if (key_part->field->key_cmp(key, key_part->length+ HA_KEY_BLOB_LENGTH)) return 1; - length=key_part->length+2; + length=key_part->length+HA_KEY_BLOB_LENGTH; } else { diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index abf04cf5517..b5eec2d5dd4 100644 --- a/sql/opt_sum.cc +++ b/sql/opt_sum.cc @@ -440,14 +440,16 @@ static bool find_range_key(TABLE_REF *ref, Field* field, COND *cond) left_length < part->store_length || (table->file->index_flags(idx) & HA_WRONG_ASCII_ORDER)) break; + uint store_length= part->store_length; // Save found constant if (part->null_bit) + { *key_ptr++= (byte) test(part->field->is_null()); - part->field->get_key_image((char*) key_ptr, - (part->field->type() == FIELD_TYPE_BLOB) ? - part->length + HA_KEY_BLOB_LENGTH : part->length); - key_ptr+=part->store_length - test(part->null_bit); - left_length-=part->store_length; + store_length--; + } + part->field->get_key_image((char*) key_ptr, store_length); + key_ptr+= store_length; + left_length-= part->store_length; } if (part == part_end && part->field == field) { From 17bfc6735ccd1e767fbdc7b9b796f0652bb33d1a Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 20 Jan 2004 09:05:37 +0100 Subject: [PATCH 039/113] two bugs in parallel repair fixed --- myisam/mi_check.c | 10 ++++++++-- myisam/mi_dynrec.c | 16 ++++++++-------- myisam/myisamdef.h | 5 ++++- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/myisam/mi_check.c b/myisam/mi_check.c index 38e48eb5e06..8581f79c99d 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -922,7 +922,7 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend) info->checksum=mi_checksum(info,record); if (param->testflag & (T_EXTEND | T_MEDIUM | T_VERBOSE)) { - if (_mi_rec_check(info,record, info->rec_buff)) + if (_mi_rec_check(info,record, info->rec_buff,block_info.rec_len)) { mi_check_print_error(param,"Found wrong packed record at %s", llstr(start_recpos,llbuff)); @@ -2350,6 +2350,11 @@ int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, sort_param[i].record= (((char *)(sort_param+share->base.keys))+ (share->base.pack_reclength * i)); + if (!mi_alloc_rec_buff(info, -1, &sort_param[i].rec_buff)) + { + mi_check_print_error(param,"Not enough memory!"); + goto err; + } sort_param[i].key_length=share->rec_reflength; for (keyseg=sort_param[i].keyinfo->seg; keyseg->type != HA_KEYTYPE_END; @@ -2911,7 +2916,8 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) info->checksum=mi_checksum(info,sort_param->record); if ((param->testflag & (T_EXTEND | T_REP)) || searching) { - if (_mi_rec_check(info, sort_param->record, sort_param->rec_buff)) + if (_mi_rec_check(info, sort_param->record, sort_param->rec_buff, + sort_param->find_length)) { mi_check_print_info(param,"Found wrong packed record at %s", llstr(sort_param->start_recpos,llbuff)); diff --git a/myisam/mi_dynrec.c b/myisam/mi_dynrec.c index e1bfe4c3ac5..e4e83b716ec 100644 --- a/myisam/mi_dynrec.c +++ b/myisam/mi_dynrec.c @@ -148,7 +148,7 @@ static int write_dynamic_record(MI_INFO *info, const byte *record, } while (reclength); DBUG_RETURN(0); - err: +err: DBUG_RETURN(1); } @@ -744,7 +744,8 @@ uint _mi_rec_pack(MI_INFO *info, register byte *to, register const byte *from) Returns 0 if record is ok. */ -my_bool _mi_rec_check(MI_INFO *info,const char *record, byte *rec_buff) +my_bool _mi_rec_check(MI_INFO *info,const char *record, byte *rec_buff, + ulong packed_length) { uint length,new_length,flag,bit,i; char *pos,*end,*packpos,*to; @@ -836,8 +837,7 @@ my_bool _mi_rec_check(MI_INFO *info,const char *record, byte *rec_buff) to+=length; } } - if (info->packed_length != (uint) (to - rec_buff) - + test(info->s->calc_checksum) || + if (packed_length != (uint) (to - rec_buff) + test(info->s->calc_checksum) || (bit != 1 && (flag & ~(bit - 1)))) goto err; if (info->s->calc_checksum) @@ -850,7 +850,7 @@ my_bool _mi_rec_check(MI_INFO *info,const char *record, byte *rec_buff) } DBUG_RETURN(0); - err: +err: DBUG_RETURN(1); } @@ -966,8 +966,8 @@ ulong _mi_rec_unpack(register MI_INFO *info, register byte *to, byte *from, if (info->s->calc_checksum) from++; if (to == to_end && from == from_end && (bit == 1 || !(flag & ~(bit-1)))) - DBUG_RETURN((info->packed_length=found_length)); - err: + DBUG_RETURN(found_length); +err: my_errno=HA_ERR_RECORD_DELETED; DBUG_PRINT("error",("to_end: %lx -> %lx from_end: %lx -> %lx", to,to_end,from,from_end)); @@ -1210,7 +1210,7 @@ int _mi_cmp_dynamic_record(register MI_INFO *info, register const byte *record) } } my_errno=0; - err: +err: if (buffer != info->rec_buff) my_afree((gptr) buffer); DBUG_RETURN(my_errno); diff --git a/myisam/myisamdef.h b/myisam/myisamdef.h index e1df1d73191..51a2dd3a2b3 100644 --- a/myisam/myisamdef.h +++ b/myisam/myisamdef.h @@ -244,6 +244,8 @@ struct st_myisam_info { my_off_t last_search_keypage; /* Last keypage when searching */ my_off_t dupp_key_pos; ha_checksum checksum; + /* QQ: the folloing two xxx_length fields should be removed, + as they are not compatible with parallel repair */ ulong packed_length,blob_length; /* Length of found, packed record */ int dfile; /* The datafile */ uint opt_flag; /* Optim. for space/speed */ @@ -536,7 +538,8 @@ extern byte *mi_alloc_rec_buff(MI_INFO *,ulong, byte**); extern ulong _mi_rec_unpack(MI_INFO *info,byte *to,byte *from, ulong reclength); -extern my_bool _mi_rec_check(MI_INFO *info,const char *record, byte *packpos); +extern my_bool _mi_rec_check(MI_INFO *info,const char *record, byte *packpos, + ulong reclength); extern int _mi_write_part_record(MI_INFO *info,my_off_t filepos,ulong length, my_off_t next_filepos,byte **record, ulong *reclength,int *flag); From efa80e01a4ca410723dd8bf185e84e4d6ed02359 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 20 Jan 2004 17:14:02 +0100 Subject: [PATCH 040/113] What started as an attempt to fix BUG#2270 (Substitute paths in mysql manpage) turned out as a major overhaul of all man pages: - renamed all *.1 files to *.1.in to act as templates which are being processed at build time - replaced some hard-coded values with place holder that are being replaced with the proper values at build time - Updated list of available man pages in the SEE ALSO section and added a hint to the manual for more details - Added a BUGS section to all pages, referring to the bugs DB - Updated some obsolete URLs and mail addresses The actual content of these man pages should probably be cross-checked for correctness, though... man/Makefile.am: - Replace some hard-coded values in the man pages with the proper values at build time instead. Instead of the *.1 files, we now add the *.1.in files (the templates) to the source distribution and generate the *.1 files during make. man/isamchk.1.in: - replaced some hard-coded values (e.g. Version numbers) with variables which are replaced with the proper values at build time - Updated list of other man pages listed in SEE ALSO - Added BUGS section, referring to the bugs database - Updated URL and Mail address man/isamlog.1.in: - replaced some hard-coded values (e.g. Version numbers) with variables which are replaced with the proper values at build time - Updated list of other man pages listed in SEE ALSO - Added BUGS section, referring to the bugs database - Updated URL and Mail address man/mysql_fix_privilege_tables.1.in: - replaced some hard-coded values (e.g. Version numbers) with variables which are replaced with the proper values at build time - Updated list of other man pages listed in SEE ALSO - Added BUGS section, referring to the bugs database - Updated URL and Mail address man/mysql_zap.1.in: - replaced some hard-coded values (e.g. Version numbers) with variables which are replaced with the proper values at build time - Updated list of other man pages listed in SEE ALSO - Added BUGS section, referring to the bugs database - Updated URL and Mail address man/mysqlaccess.1.in: - replaced some hard-coded values (e.g. Version numbers) with variables which are replaced with the proper values at build time - Updated list of other man pages listed in SEE ALSO - Added BUGS section, referring to the bugs database - Updated URL and Mail address man/mysqladmin.1.in: - replaced some hard-coded values (e.g. Version numbers) with variables which are replaced with the proper values at build time - Updated list of other man pages listed in SEE ALSO - Added BUGS section, referring to the bugs database - Updated URL and Mail address man/mysqld.1.in: - replaced some hard-coded values (e.g. Version numbers) with variables which are replaced with the proper values at build time - Updated list of other man pages listed in SEE ALSO - Added BUGS section, referring to the bugs database - Updated URL and Mail address man/mysqld_multi.1.in: - replaced some hard-coded values (e.g. Version numbers) with variables which are replaced with the proper values at build time - Updated list of other man pages listed in SEE ALSO - Added BUGS section, referring to the bugs database - Updated URL and Mail address man/mysqld_safe.1.in: - replaced some hard-coded values (e.g. Version numbers) with variables which are replaced with the proper values at build time - Updated list of other man pages listed in SEE ALSO - Added BUGS section, referring to the bugs database - Updated URL and Mail address man/mysqldump.1.in: - replaced some hard-coded values (e.g. Version numbers) with variables which are replaced with the proper values at build time - Updated list of other man pages listed in SEE ALSO - Added BUGS section, referring to the bugs database - Updated URL and Mail address man/mysqlshow.1.in: - replaced some hard-coded values (e.g. Version numbers) with variables which are replaced with the proper values at build time - Updated list of other man pages listed in SEE ALSO - Added BUGS section, referring to the bugs database - Updated URL and Mail address man/perror.1.in: - replaced some hard-coded values (e.g. Version numbers) with variables which are replaced with the proper values at build time - Updated list of other man pages listed in SEE ALSO - Added BUGS section, referring to the bugs database - Updated URL and Mail address man/replace.1.in: - replaced some hard-coded values (e.g. Version numbers) with variables which are replaced with the proper values at build time - Updated list of other man pages listed in SEE ALSO - Added BUGS section, referring to the bugs database - Updated URL and Mail address man/mysql.1.in: - replaced some hard-coded values (e.g. Version numbers, path names) with variables which are replaced with the proper values at build time - Updated list of other man pages listed in SEE ALSO - Added BUGS section, referring to the bugs database - Updated URL and Mail address --- man/Makefile.am | 21 ++++++- man/{isamchk.1 => isamchk.1.in} | 41 +++++++------ man/{isamlog.1 => isamlog.1.in} | 42 ++++++++------ man/{mysql.1 => mysql.1.in} | 58 +++++++++++-------- ...bles.1 => mysql_fix_privilege_tables.1.in} | 22 ++++++- man/mysql_zap.1 | 34 ----------- man/mysql_zap.1.in | 52 +++++++++++++++++ man/{mysqlaccess.1 => mysqlaccess.1.in} | 41 +++++++------ man/{mysqladmin.1 => mysqladmin.1.in} | 45 +++++++------- man/{mysqld.1 => mysqld.1.in} | 44 +++++++------- man/{mysqld_multi.1 => mysqld_multi.1.in} | 42 ++++++++------ man/{mysqld_safe.1 => mysqld_safe.1.in} | 37 +++++++----- man/{mysqldump.1 => mysqldump.1.in} | 41 +++++++------ man/{mysqlshow.1 => mysqlshow.1.in} | 41 +++++++------ man/{perror.1 => perror.1.in} | 41 +++++++------ man/{replace.1 => replace.1.in} | 41 +++++++------ 16 files changed, 378 insertions(+), 265 deletions(-) rename man/{isamchk.1 => isamchk.1.in} (84%) rename man/{isamlog.1 => isamlog.1.in} (67%) rename man/{mysql.1 => mysql.1.in} (78%) rename man/{mysql_fix_privilege_tables.1 => mysql_fix_privilege_tables.1.in} (57%) delete mode 100644 man/mysql_zap.1 create mode 100644 man/mysql_zap.1.in rename man/{mysqlaccess.1 => mysqlaccess.1.in} (79%) rename man/{mysqladmin.1 => mysqladmin.1.in} (86%) rename man/{mysqld.1 => mysqld.1.in} (94%) rename man/{mysqld_multi.1 => mysqld_multi.1.in} (77%) rename man/{mysqld_safe.1 => mysqld_safe.1.in} (77%) rename man/{mysqldump.1 => mysqldump.1.in} (92%) rename man/{mysqlshow.1 => mysqlshow.1.in} (75%) rename man/{perror.1 => perror.1.in} (60%) rename man/{replace.1 => replace.1.in} (65%) diff --git a/man/Makefile.am b/man/Makefile.am index 9f919e77b8f..37eb8a13f4e 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -21,7 +21,26 @@ man_MANS = mysql.1 isamchk.1 isamlog.1 mysql_zap.1 mysqlaccess.1 \ mysqladmin.1 mysqld.1 mysqld_multi.1 mysqldump.1 mysqlshow.1 \ perror.1 replace.1 mysqld_safe.1 mysql_fix_privilege_tables.1 -EXTRA_DIST = $(man_MANS) +EXTRA_DIST = mysql.1.in isamchk.1.in isamlog.1.in mysql_zap.1.in \ + mysqlaccess.1.in mysqladmin.1.in mysqld.1.in mysqld_multi.1.in \ + mysqldump.1.in mysqlshow.1.in perror.1.in replace.1.in \ + mysqld_safe.1.in mysql_fix_privilege_tables.1.in + +CLEANFILES = $(man_MANS) + +SUFFIXES = .in + +.in: + @RM@ -f $@ $@-t + @SED@ \ + -e 's!@''MYSQL_BASE_VERSION''@!@MYSQL_BASE_VERSION@!' \ + -e 's!@''sysconfdir''@!@sysconfdir@!' \ + -e 's!@''bindir''@!$(bindir)!g' \ + -e 's!@''libexecdir''@!$(libexecdir)!g' \ + -e 's!@''localstatedir''@!$(localstatedir)!g' \ + -e 's!@''MYSQL_NO_DASH_VERSION''@!@MYSQL_NO_DASH_VERSION@!' \ + $< > $@-t + @MV@ $@-t $@ # Don't update the files from bitkeeper %::SCCS/s.% diff --git a/man/isamchk.1 b/man/isamchk.1.in similarity index 84% rename from man/isamchk.1 rename to man/isamchk.1.in index 341e968a131..cad1303ee55 100644 --- a/man/isamchk.1 +++ b/man/isamchk.1.in @@ -1,4 +1,4 @@ -.TH isamchk 1 "19 December 2000" "MySQL 4.0" "MySQL database" +.TH isamchk 1 "19 December 2000" "MySQL @MYSQL_BASE_VERSION@" "MySQL database" .SH NAME .BR isamchk \- Description, check and repair of ISAM tables. @@ -114,24 +114,29 @@ Print version and exit. .BR \-w | \-\-wait Wait if table is locked. .SH "SEE ALSO" -isamchk (1), -isamlog (1), -mysqlaccess (1), -mysqladmin (1), -mysqlbug (1), -mysqld (1), -mysqldump (1), -mysqlshow (1), -msql2mysql (1), -perror (1), -replace (1), -mysqld_safe (1), -which1 (1), -zap (1), +isamlog(1), +mysql(1), +mysqlaccess(1), +mysqladmin(1), +mysqld(1), +mysqld_multi(1), +mysqld_safe(1), +mysqldump(1), +mysql_fix_privilege_tables(1), +mysqlshow(1), +mysql_zap(1), +perror(1), +replace(1) +.P +For more information please refer to the MySQL reference +manual, which may already be installed locally and which +is also available online at http://www.mysql.com/doc/en/ +.SH BUGS +Please refer to http://bugs.mysql.com/ to report bugs. .SH AUTHOR -Ver 1.0, distribution 3.23.29a -Michael (Monty) Widenius (monty@tcx.se), -TCX Datakonsult AB (http://www.tcx.se). +Ver 1.0, distribution @MYSQL_NO_DASH_VERSION@ +Michael (Monty) Widenius (monty@mysql.com), +MySQL AB (http://www.mysql.com/). This software comes with no warranty. Manual page by L. (Kill-9) Pedersen (kill-9@kill\-9.dk), Mercurmedia Data Model Architect / diff --git a/man/isamlog.1 b/man/isamlog.1.in similarity index 67% rename from man/isamlog.1 rename to man/isamlog.1.in index 402c3052ad8..6040f6c4ad8 100644 --- a/man/isamlog.1 +++ b/man/isamlog.1.in @@ -1,4 +1,4 @@ -.TH isamlog 1 "19 December 2000" "MySQL 4.0" "MySQL database" +.TH isamlog 1 "19 December 2000" "MySQL @MYSQL_BASE_VERSION@" "MySQL database" .SH NAME isamlog - Write info about whats in a nisam log file. .SH USAGE @@ -71,27 +71,31 @@ If one gives table names as arguments only these tables will be updated .SH "SEE ALSO" - -isamchk (1), -isamlog (1), -mysqlaccess (1), -mysqladmin (1), -mysqlbug (1), -mysqld (1), -mysqldump (1), -mysqlshow (1), -msql2mysql (1), -perror (1), -replace (1), -mysqld_safe (1), -which1 (1), -zap (1), +isamchk(1), +mysql(1), +mysqlaccess(1), +mysqladmin(1), +mysqld(1), +mysqld_multi(1), +mysqld_safe(1), +mysqldump(1), +mysql_fix_privilege_tables(1), +mysqlshow(1), +mysql_zap(1), +perror(1), +replace(1) +.P +For more information please refer to the MySQL reference +manual, which may already be installed locally and which +is also available online at http://www.mysql.com/doc/en/ +.SH BUGS +Please refer to http://bugs.mysql.com/ to report bugs. .SH AUTHOR -Ver 1.0, distribution 3.23.29a -Michael (Monty) Widenius (monty@tcx.se), -TCX Datakonsult AB (http://www.tcx.se). +Ver 1.0, distribution @MYSQL_NO_DASH_VERSION@ +Michael (Monty) Widenius (monty@mysql.com), +MySQL AB (http://www.mysql.com/). This software comes with no warranty. Manual page by L. (Kill-9) Pedersen (kill-9@kill-9.dk), Mercurmedia Data Model Architect / diff --git a/man/mysql.1 b/man/mysql.1.in similarity index 78% rename from man/mysql.1 rename to man/mysql.1.in index c0c37716b14..35ff48693e1 100644 --- a/man/mysql.1 +++ b/man/mysql.1.in @@ -1,6 +1,8 @@ -.TH mysql 1 "19 December 2000" "MySQL 4.0" "MySQL database" +.TH mysql 1 "19 December 2000" "MySQL @MYSQL_BASE_VERSION@" "MySQL database" .SH NAME mysql \- text-based client for mysqld, a SQL-based relational database daemon +.SH USAGE +mysql [OPTIONS] [Database] .SH SYNOPSIS .B mysql .RB [ \-B | \-\-batch ] @@ -105,16 +107,19 @@ version number and exit. Wait and retry if the database server connection is down. .SH FILES .TP 2.2i -.I /depot/bin/mysql -executable +.I @sysconfdir@/my.cnf +MySQL configuration file .TP -.I /depot/bin/mysqld -executable +.I @bindir@/mysql +Client executable .TP -.I /depot/bin/mysqld_safe +.I @libexecdir@/mysqld +Server executable +.TP +.I @bindir@/mysqld_safe executable shell script for starting mysqld safely .TP -.I /site/var/mysql/data +.I @localstatedir@ location of database files .SH EXAMPLE You can also read a backup dump file back into MySQL with: @@ -124,24 +129,29 @@ You can also read a backup dump file back into MySQL with: .BR < backup-file.sql .SH "SEE ALSO" -isamchk (1), -isamlog (1), -mysqlaccess (1), -mysqladmin (1), -mysqlbug (1), -mysqld (1), -mysqldump (1), -mysqlshow (1), -msql2mysql (1), -perror (1), -replace (1), -mysqld_safe (1), -which1 (1), -zap (1), +isamchk(1), +isamlog(1), +mysqlaccess(1), +mysqladmin(1), +mysqld(1), +mysqld_multi(1), +mysqld_safe(1), +mysqldump(1), +mysql_fix_privilege_tables(1), +mysqlshow(1), +mysql_zap(1), +perror(1), +replace(1) +.P +For more information please refer to the MySQL reference +manual, which may already be installed locally and which +is also available online at http://www.mysql.com/doc/en/ +.SH BUGS +Please refer to http://bugs.mysql.com/ to report bugs. .SH AUTHOR -Ver 6.3, distribution 3.20.20 -Michael (Monty) Widenius (monty@tcx.se), -TCX Datakonsult AB (http://www.tcx.se). +Ver 6.3, distribution @MYSQL_NO_DASH_VERSION@ +Michael (Monty) Widenius (monty@mysql.com), +MySQL AB (http://www.mysql.com/) This software comes with no warranty. Manual page by R. P. C. Rodgers, Lister Hill National Center for Biomedical Communication, diff --git a/man/mysql_fix_privilege_tables.1 b/man/mysql_fix_privilege_tables.1.in similarity index 57% rename from man/mysql_fix_privilege_tables.1 rename to man/mysql_fix_privilege_tables.1.in index 4ed81368098..1d42681f298 100644 --- a/man/mysql_fix_privilege_tables.1 +++ b/man/mysql_fix_privilege_tables.1.in @@ -1,4 +1,4 @@ -.TH mysql 1 "17 March 2003" "MySQL 4.0" "MySQL database" +.TH mysql 1 "17 March 2003" "MySQL @MYSQL_BASE_VERSION@" "MySQL database" .SH NAME mysql_fix_privilege_tables \- Fixes MySQL privilege tables. .SH SYNOPSIS @@ -14,7 +14,25 @@ If you get 'Access denied' errors, run the script again and give the MySQL root user password as an argument. .SH "SEE ALSO" -mysql (1), mysqld (1) +isamchk(1), +isamlog(1), +mysql(1), +mysqlaccess(1), +mysqladmin(1), +mysqld(1), +mysqld_multi(1), +mysqld_safe(1), +mysqldump(1), +mysqlshow(1), +mysql_zap(1), +perror(1), +replace(1) +.P +For more information please refer to the MySQL reference +manual, which may already be installed locally and which +is also available online at http://www.mysql.com/doc/en/ +.SH BUGS +Please refer to http://bugs.mysql.com/ to report bugs. .SH AUTHOR This manpage was written by Christian Hammers . diff --git a/man/mysql_zap.1 b/man/mysql_zap.1 deleted file mode 100644 index 71931c03db6..00000000000 --- a/man/mysql_zap.1 +++ /dev/null @@ -1,34 +0,0 @@ -.TH zap 1 "19 December 2000" "MySQL 4.0" "MySQL database" -.SH NAME -zap - a perl script used to kill processes -.SH USAGE -/usr/bin/mysql_zap [-signal] [-?Ift] pattern -.SH SYNOPSIS -.B zap -.RB [ \-I | \-? ] -.RB [ \-f ] -.RB [ \-t ] -.SH DESCRIPTION -.TP -.BR zap -supports by executing -.TP -.BR \-I | \-? -info -.TP -.BR \-f -force -.TP -.BR \-t -test -.SH NOTE -If -.BR -f -isn't given, ask user for confirmation for each process to kill. If signal isn't given, try first with signal 15 and after that with signal 9. If -.BR -t -is given the processes is only shown on stdout. -.SH "SEE ALSO" -isamchk (1), isamlog (1), mysqlaccess (1), mysqladmin (1), mysqlbug (1), mysqld (1), mysqldump (1), mysqlshow (1), msql2mysql (1), perror (1), replace (1), mysqld_safe (1), which1 (1), zap (1), -.SH AUTHOR -Ver 1.0, distribution 3.23.29a Michael (Monty) Widenius (monty@tcx.se), TCX Datakonsult AB (http://www.tcx.se). This software comes with no warranty. Manual page by L. (Kill-9) Pedersen (kill-9@kill-9.dk), Mercurmedia Data Model Architect / system developer (http://www.mercurmedia.com) -.\" end of man page \ No newline at end of file diff --git a/man/mysql_zap.1.in b/man/mysql_zap.1.in new file mode 100644 index 00000000000..511a8feaa7c --- /dev/null +++ b/man/mysql_zap.1.in @@ -0,0 +1,52 @@ +.TH zap 1 "19 December 2000" "MySQL @MYSQL_BASE_VERSION@" "MySQL database" +.SH NAME +zap - a perl script used to kill processes +.SH USAGE +/usr/bin/mysql_zap [-signal] [-?Ift] pattern +.SH SYNOPSIS +.B zap +.RB [ \-I | \-? ] +.RB [ \-f ] +.RB [ \-t ] +.SH DESCRIPTION +.TP +.BR zap +supports by executing +.TP +.BR \-I | \-? +info +.TP +.BR \-f +force +.TP +.BR \-t +test +.SH NOTE +If +.BR -f +isn't given, ask user for confirmation for each process to kill. If signal isn't given, try first with signal 15 and after that with signal 9. If +.BR -t +is given the processes is only shown on stdout. +.SH "SEE ALSO" +isamchk(1), +isamlog(1), +mysql(1), +mysqlaccess(1), +mysqladmin(1), +mysqld(1), +mysqld_multi(1), +mysqld_safe(1), +mysqldump(1), +mysql_fix_privilege_tables(1), +mysqlshow(1), +perror(1), +replace(1) +.P +For more information please refer to the MySQL reference +manual, which may already be installed locally and which +is also available online at http://www.mysql.com/doc/en/ +.SH BUGS +Please refer to http://bugs.mysql.com/ to report bugs. +.SH AUTHOR +Ver 1.0, distribution @MYSQL_NO_DASH_VERSION@ Michael (Monty) Widenius (monty@mysql.com), MySQL AB (http://www.mysql.com/). This software comes with no warranty. Manual page by L. (Kill-9) Pedersen (kill-9@kill-9.dk), Mercurmedia Data Model Architect / system developer (http://www.mercurmedia.com) +.\" end of man page diff --git a/man/mysqlaccess.1 b/man/mysqlaccess.1.in similarity index 79% rename from man/mysqlaccess.1 rename to man/mysqlaccess.1.in index 95e392b1194..9a5e58541d2 100644 --- a/man/mysqlaccess.1 +++ b/man/mysqlaccess.1.in @@ -1,4 +1,4 @@ -.TH mysqlaccess 1 "19 December 2000" "MySQL 4.0" "MySQL database" +.TH mysqlaccess 1 "19 December 2000" "MySQL @MYSQL_BASE_VERSION@" "MySQL database" .SH NAME .BR mysqlaccess \- Create new users to mysql. @@ -95,24 +95,29 @@ If no host is given, `localhost' is assumed Wildcards (*,?,%,_) are allowed for host, user and db, but be sure to escape them from your shell!! (i.e., type \\* or '*') .SH "SEE ALSO" -isamchk (1), -isamlog (1), -mysqlaccess (1), -mysqladmin (1), -mysqlbug (1), -mysqld (1), -mysqldump (1), -mysqlshow (1), -msql2mysql (1), -perror (1), -replace (1), -mysqld_safe (1), -which1 (1), -zap (1), +isamchk(1), +isamlog(1), +mysql(1), +mysqladmin(1), +mysqld(1), +mysqld_multi(1), +mysqld_safe(1), +mysqldump(1), +mysql_fix_privilege_tables(1), +mysqlshow(1), +mysql_zap(1), +perror(1), +replace(1) +.P +For more information please refer to the MySQL reference +manual, which may already be installed locally and which +is also available online at http://www.mysql.com/doc/en/ +.SH BUGS +Please refer to http://bugs.mysql.com/ to report bugs. .SH AUTHOR -Ver 1.0, distribution 3.23.29a -Michael (Monty) Widenius (monty@tcx.se), -TCX Datakonsult AB (http://www.tcx.se). +Ver 1.0, distribution @MYSQL_NO_DASH_VERSION@ +Michael (Monty) Widenius (monty@mysql.com), +MySQL AB (http://www.mysql.com/). This software comes with no warranty. Manual page by L. (Kill-9) Pedersen (kill-9@kill\-9.dk), Mercurmedia Data Model Architect / diff --git a/man/mysqladmin.1 b/man/mysqladmin.1.in similarity index 86% rename from man/mysqladmin.1 rename to man/mysqladmin.1.in index 693e8aa5a72..a549f1c0e22 100644 --- a/man/mysqladmin.1 +++ b/man/mysqladmin.1.in @@ -1,4 +1,4 @@ -.TH mysqladmin 1 "19 December 2000" "MySQL 4.0" "MySQL database" +.TH mysqladmin 1 "19 December 2000" "MySQL @MYSQL_BASE_VERSION@" "MySQL database" .SH NAME mysqladmin [OPTIONS] command command.... \- A utility for performing administrative operations .SH OPTION SYNOPSIS @@ -178,31 +178,32 @@ Prints variables available .BR version Get version info from server .SH "SEE ALSO" -isamchk (1), -isamlog (1), -mysqlaccess (1), -mysqladmin (1), -mysqlbug (1), -mysqld (1), -mysqldump (1), -mysqlshow (1), -msql2mysql (1), -perror (1), -replace (1), -mysqld_safe (1), -which1 (1), -zap (1), +isamchk(1), +isamlog(1), +mysql(1), +mysqlaccess(1), +mysqld(1), +mysqld_multi(1), +mysqld_safe(1), +mysqldump(1), +mysql_fix_privilege_tables(1), +mysqlshow(1), +mysql_zap(1), +perror(1), +replace(1) +.P +For more information please refer to the MySQL reference +manual, which may already be installed locally and which +is also available online at http://www.mysql.com/doc/en/ +.SH BUGS +Please refer to http://bugs.mysql.com/ to report bugs. .SH AUTHOR -Ver 1.0, distribution 3.23.29a -Michael (Monty) Widenius (monty@tcx.se), -TCX Datakonsult AB (http://www.tcx.se). +Ver 1.0, distribution @MYSQL_NO_DASH_VERSION@ +Michael (Monty) Widenius (monty@mysql.com), +MySQL AB (http://www.mysql.com/). This software comes with no warranty. Manual page by L. (Kill-9) Pedersen (kill-9@kill-9.dk), Mercurmedia Data Model Architect / system developer (http://www.mercurmedia.com) .\" end of man page - - - - diff --git a/man/mysqld.1 b/man/mysqld.1.in similarity index 94% rename from man/mysqld.1 rename to man/mysqld.1.in index 98247cd9445..719711edca2 100644 --- a/man/mysqld.1 +++ b/man/mysqld.1.in @@ -1,7 +1,6 @@ -.TH mysqld 1 "19 December 2000" "MySQL 4.0" "MySQL database" +.TH mysqld 1 "19 December 2000" "MySQL @MYSQL_BASE_VERSION@" "MySQL database" .SH NAME -.BR mysqld - \- Starts the MySQL server demon +mysqld \- The MySQL server demon .SH USAGE mysqld [OPTIONS] .SH SYNOPSIS @@ -204,24 +203,29 @@ Output version information and exit. .SH NOTE .SH "SEE ALSO" -isamchk (1), -isamlog (1), -mysqlaccess (1), -mysqladmin (1), -mysqlbug (1), -mysqld (1), -mysqldump (1), -mysqlshow (1), -msql2mysql (1), -perror (1), -replace (1), -mysqld_safe (1), -which1 (1), -zap (1), +isamchk(1), +isamlog(1), +mysql(1), +mysqlaccess(1), +mysqladmin(1), +mysqld_multi(1), +mysqld_safe(1), +mysqldump(1), +mysql_fix_privilege_tables(1), +mysqlshow(1), +mysql_zap(1), +perror(1), +replace(1) +.P +For more information please refer to the MySQL reference +manual, which may already be installed locally and which +is also available online at http://www.mysql.com/doc/en/ +.SH BUGS +Please refer to http://bugs.mysql.com/ to report bugs. .SH AUTHOR -Ver 1.0, distribution 3.23.29a -Michael (Monty) Widenius (monty@tcx.se), -TCX Datakonsult AB (http://www.tcx.se). +Ver 1.0, distribution @MYSQL_NO_DASH_VERSION@ +Michael (Monty) Widenius (monty@mysql.com), +MySQL AB (http://www.mysql.com/). This software comes with no warranty. Manual page by L. (Kill-9) Pedersen (kill-9@kill\-9.dk), Mercurmedia Data Model Architect / diff --git a/man/mysqld_multi.1 b/man/mysqld_multi.1.in similarity index 77% rename from man/mysqld_multi.1 rename to man/mysqld_multi.1.in index 47418835939..26e7a091b60 100644 --- a/man/mysqld_multi.1 +++ b/man/mysqld_multi.1.in @@ -1,4 +1,4 @@ -.TH mysqld_multi 1 "19 December 2000" "MySQL 4.0" "MySQL database" +.TH mysqld_multi 1 "19 December 2000" "MySQL @MYSQL_BASE_VERSION@" "MySQL database" .SH NAME mysqld_multi - is meant for managing several mysqld processes running in different UNIX sockets and TCP/IP ports. .SH USAGE @@ -58,27 +58,31 @@ Please see the mysql manual for more detailed information on this. .SH "SEE ALSO" - -isamchk (1), -isamlog (1), -mysqlaccess (1), -mysqladmin (1), -mysqlbug (1), -mysqld (1), -mysqldump (1), -mysqlshow (1), -msql2mysql (1), -perror (1), -replace (1), -mysqld_safe (1), -which1 (1), -zap (1), +isamchk(1), +isamlog(1), +mysql(1), +mysqlaccess(1), +mysqladmin(1), +mysqld(1), +mysqld_safe(1), +mysqldump(1), +mysql_fix_privilege_tables(1), +mysqlshow(1), +mysql_zap(1), +perror(1), +replace(1) +.P +For more information please refer to the MySQL reference +manual, which may already be installed locally and which +is also available online at http://www.mysql.com/doc/en/ +.SH BUGS +Please refer to http://bugs.mysql.com/ to report bugs. .SH AUTHOR -Ver 1.0, distribution 3.23.29a -Michael (Monty) Widenius (monty@tcx.se), -TCX Datakonsult AB (http://www.tcx.se). +Ver 1.0, distribution @MYSQL_NO_DASH_VERSION@ +Michael (Monty) Widenius (monty@mysql.com), +MySQL AB (http://www.mysql.com/). This software comes with no warranty. Manual page by L. (Kill-9) Pedersen (kill-9@kill-9.dk), Mercurmedia Data Model Architect / diff --git a/man/mysqld_safe.1 b/man/mysqld_safe.1.in similarity index 77% rename from man/mysqld_safe.1 rename to man/mysqld_safe.1.in index 3679346d7db..641f34677c7 100644 --- a/man/mysqld_safe.1 +++ b/man/mysqld_safe.1.in @@ -1,4 +1,4 @@ -.TH safe_mysqld 1 "19 December 2000" "MySQL 4.0" "MySQL database" +.TH safe_mysqld 1 "19 December 2000" "MySQL @MYSQL_BASE_VERSION@" "MySQL database" .SH NAME mysqld_safe \- start the mysqld daemon on Unix. .SH SYNOPSIS @@ -60,22 +60,27 @@ Set the timezone (the TZ) variable to the value of this parameter. .SH NOTE Note that all options on the command line to mysqld_safe are passed to mysqld. If you wants to use any options in mysqld_safe that mysqld doesn't support, you must specify these in the option file. .SH "SEE ALSO" -isamchk (1), -isamlog (1), -mysqlaccess (1), -mysqladmin (1), -mysqlbug (1), -mysqld (1), -mysqldump (1), -mysqlshow (1), -msql2mysql (1), -perror (1), -replace (1), -mysqld_safe (1), -which1 (1), -zap (1), +isamchk(1), +isamlog(1), +mysql(1), +mysqlaccess(1), +mysqladmin(1), +mysqld(1), +mysqld_multi(1), +mysqldump(1), +mysql_fix_privilege_tables(1), +mysqlshow(1), +mysql_zap(1), +perror(1), +replace(1) +.P +For more information please refer to the MySQL reference +manual, which may already be installed locally and which +is also available online at http://www.mysql.com/doc/en/ +.SH BUGS +Please refer to http://bugs.mysql.com/ to report bugs. .SH AUTHOR -Ver 1.0, distribution 3.23.29a +Ver 1.0, distribution @MYSQL_NO_DASH_VERSION@ Michael (Monty) Widenius (monty@mysql.com), MySQL AB (http://www.mysql.com). This software comes with no warranty. diff --git a/man/mysqldump.1 b/man/mysqldump.1.in similarity index 92% rename from man/mysqldump.1 rename to man/mysqldump.1.in index 6907fcc8777..34d83dbe0b3 100644 --- a/man/mysqldump.1 +++ b/man/mysqldump.1.in @@ -1,4 +1,4 @@ -.TH mysqldump 1 "19 December 2000" "MySQL 4.0" "MySQL database" +.TH mysqldump 1 "19 December 2000" "MySQL @MYSQL_BASE_VERSION@" "MySQL database" .SH NAME mysqldump \- text-based client for dumping or backing up mysql databases , tables and or data. @@ -247,24 +247,29 @@ If all the databases are wanted, one can use: mysqldump \fP\fI\-\-all\-databases\fP > all_databases.sql .SH "SEE ALSO" -isamchk (1), -isamlog (1), -mysqlaccess (1), -mysqladmin (1), -mysqlbug (1), -mysqld (1), -mysqldump (1), -mysqlshow (1), -msql2mysql (1), -perror (1), -replace (1), -mysqld_safe (1), -which1 (1), -zap (1), +isamchk(1), +isamlog(1), +mysql(1), +mysqlaccess(1), +mysqladmin(1), +mysqld(1), +mysqld_multi(1), +mysqld_safe(1), +mysql_fix_privilege_tables(1), +mysqlshow(1), +mysql_zap(1), +perror(1), +replace(1) +.P +For more information please refer to the MySQL reference +manual, which may already be installed locally and which +is also available online at http://www.mysql.com/doc/en/ +.SH BUGS +Please refer to http://bugs.mysql.com/ to report bugs. .SH AUTHOR -Ver 1.0, distribution 3.23.29a -Michael (Monty) Widenius (monty@tcx.se), -TCX Datakonsult AB (http://www.tcx.se). +Ver 1.0, distribution @MYSQL_NO_DASH_VERSION@ +Michael (Monty) Widenius (monty@mysql.com), +MySQL AB (http://www.mysql.com/). This software comes with no warranty. Manual page by L. (Kill-9) Pedersen (kill-9@kill-9.dk), Mercurmedia Data Model Architect / diff --git a/man/mysqlshow.1 b/man/mysqlshow.1.in similarity index 75% rename from man/mysqlshow.1 rename to man/mysqlshow.1.in index 39590b54375..903d9620fd6 100644 --- a/man/mysqlshow.1 +++ b/man/mysqlshow.1.in @@ -1,4 +1,4 @@ -.TH mysqlshow 1 "19 December 2000" "MySQL 4.0" "MySQL database" +.TH mysqlshow 1 "19 December 2000" "MySQL @MYSQL_BASE_VERSION@" "MySQL database" .SH NAME .BR mysqlshow \- Shows the structure of a mysql database (databases,tables and columns) @@ -67,24 +67,29 @@ If no column is given then all matching columns and columntypes in table are shown .SH "SEE ALSO" -isamchk (1), -isamlog (1), -mysqlaccess (1), -mysqladmin (1), -mysqlbug (1), -mysqld (1), -mysqldump (1), -mysqlshow (1), -msql2mysql (1), -perror (1), -replace (1), -mysqld_safe (1), -which1 (1), -zap (1), +isamchk(1), +isamlog(1), +mysql(1), +mysqlaccess(1), +mysqladmin(1), +mysqld(1), +mysqld_multi(1), +mysqld_safe(1), +mysqldump(1), +mysql_fix_privilege_tables(1), +mysql_zap(1), +perror(1), +replace(1) +.P +For more information please refer to the MySQL reference +manual, which may already be installed locally and which +is also available online at http://www.mysql.com/doc/en/ +.SH BUGS +Please refer to http://bugs.mysql.com/ to report bugs. .SH AUTHOR -Ver 1.0, distribution 3.23.29a -Michael (Monty) Widenius (monty@tcx.se), -TCX Datakonsult AB (http://www.tcx.se). +Ver 1.0, distribution @MYSQL_NO_DASH_VERSION@ +Michael (Monty) Widenius (monty@mysql.com), +MySQL AB (http://www.mysql.com/). This software comes with no warranty. Manual page by L. (Kill-9) Pedersen (kill-9@kill\-9.dk), Mercurmedia Data Model Architect / diff --git a/man/perror.1 b/man/perror.1.in similarity index 60% rename from man/perror.1 rename to man/perror.1.in index b8eec8af318..f9efb48510b 100644 --- a/man/perror.1 +++ b/man/perror.1.in @@ -1,4 +1,4 @@ -.TH perror 1 "19 December 2000" "MySQL 4.0" "MySQL database" +.TH perror 1 "19 December 2000" "MySQL @MYSQL_BASE_VERSION@" "MySQL database" .SH NAME perror \- describes a system or MySQL error code. .SH SYNOPSIS @@ -27,24 +27,29 @@ shell> perror 64 79 Error code 64: Machine is not on the network Error code 79: Can not access a needed shared library .SH "SEE ALSO" -isamchk (1), -isamlog (1), -mysqlaccess (1), -mysqladmin (1), -mysqlbug (1), -mysqld (1), -mysqldump (1), -mysqlshow (1), -msql2mysql (1), -perror (1), -replace (1), -mysqld_safe (1), -which1 (1), -zap (1), +isamchk(1), +isamlog(1), +mysql(1), +mysqlaccess(1), +mysqladmin(1), +mysqld(1), +mysqld_multi(1), +mysqld_safe(1), +mysqldump(1), +mysql_fix_privilege_tables(1), +mysqlshow(1), +mysql_zap(1), +replace(1) +.P +For more information please refer to the MySQL reference +manual, which may already be installed locally and which +is also available online at http://www.mysql.com/doc/en/ +.SH BUGS +Please refer to http://bugs.mysql.com/ to report bugs. .SH AUTHOR -Ver 1.0, distribution 3.23.29a -Michael (Monty) Widenius (monty@tcx.se), -TCX Datakonsult AB (http://www.tcx.se). +Ver 1.0, distribution @MYSQL_NO_DASH_VERSION@ +Michael (Monty) Widenius (monty@mysql.com), +MySQL AB (http://www.mysql.com/). This software comes with no warranty. Manual page by L. (Kill-9) Pedersen (kill-9@kill\-9.dk), Mercurmedia Data Model Architect / diff --git a/man/replace.1 b/man/replace.1.in similarity index 65% rename from man/replace.1 rename to man/replace.1.in index 46d542d57f4..395411f7e9f 100644 --- a/man/replace.1 +++ b/man/replace.1.in @@ -1,4 +1,4 @@ -.TH replace 1 "19 December 2000" "MySQL 4.0" "MySQL database" +.TH replace 1 "19 December 2000" "MySQL @MYSQL_BASE_VERSION@" "MySQL database" .SH NAME .TP replace - A utility program that is used by msql2mysql, but that has more general applicability as well. replace changes strings in place in files or on the standard input. Uses a finite state machine to match longer strings first. Can be used to swap strings. @@ -41,24 +41,29 @@ this command swaps a and b in the given files: .TP shell> replace a b b a -- file1 file2 ... .SH "SEE ALSO" -isamchk (1), -isamlog (1), -mysqlaccess (1), -mysqladmin (1), -mysqlbug (1), -mysqld (1), -mysqldump (1), -mysqlshow (1), -msql2mysql (1), -perror (1), -replace (1), -mysqld_safe (1), -which1 (1), -zap (1), +isamchk(1), +isamlog(1), +mysql(1), +mysqlaccess(1), +mysqladmin(1), +mysqld(1), +mysqld_multi(1), +mysqld_safe(1), +mysqldump(1), +mysql_fix_privilege_tables(1), +mysqlshow(1), +mysql_zap(1), +perror(1), +.P +For more information please refer to the MySQL reference +manual, which may already be installed locally and which +is also available online at http://www.mysql.com/doc/en/ +.SH BUGS +Please refer to http://bugs.mysql.com/ to report bugs. .SH AUTHOR -Ver 1.0, distribution 3.23.29a -Michael (Monty) Widenius (monty@tcx.se), -TCX Datakonsult AB (http://www.tcx.se). +Ver 1.0, distribution @MYSQL_NO_DASH_VERSION@ +Michael (Monty) Widenius (monty@mysql.com), +MySQL AB (http://www.mysql.com/). This software comes with no warranty. Manual page by L. (Kill-9) Pedersen (kill-9@kill-9.dk), Mercurmedia Data Model Architect / From c2d849f8bdd031c7dd785281c40cfa6b54f77e15 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 20 Jan 2004 15:41:22 -0500 Subject: [PATCH 041/113] Fix for BUG#2452 "Empty LOAD DATA INFILE failes with the master in 3.23.x": do not write the Execute_load_log_event if there was no Create_file_log_event (empty file). --- sql/slave.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sql/slave.cc b/sql/slave.cc index 116d602b238..d6510b26271 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -2840,6 +2840,14 @@ static int process_io_create_file(MASTER_INFO* mi, Create_file_log_event* cev) if (unlikely(!num_bytes)) /* eof */ { send_ok(net); /* 3.23 master wants it */ + /* + If we wrote Create_file_log_event, then we need to write + Execute_load_log_event. If we did not write Create_file_log_event, + then this is an empty file and we can just do as if the LOAD DATA + INFILE had not existed, i.e. write nothing. + */ + if (unlikely(cev_not_written)) + break; Execute_load_log_event xev(thd,0,0); xev.log_pos = mi->master_log_pos; if (unlikely(mi->rli.relay_log.append(&xev))) From 24ca1e1edb1ddbd7609c88cf648447afb67f3098 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 21 Jan 2004 02:18:51 +0400 Subject: [PATCH 042/113] added test for bug #2290 "output truncated with ELT when using DISTINCT" sql/item_strfunc.cc: fixed bug #2290 "output truncated with ELT when using DISTINCT" --- mysql-test/r/func_str.result | 7 +++++++ mysql-test/t/func_str.test | 9 +++++++++ sql/item_strfunc.cc | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index 35a5ba70e86..7d2668c8cf6 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -266,3 +266,10 @@ CONCAT("",RPAD("",(55 - LENGTH(title)),".")) NULL .......................... DROP TABLE t1; +CREATE TABLE t1 (i int, j int); +INSERT INTO t1 VALUES (1,1),(2,2); +SELECT DISTINCT i, ELT(j, '345', '34') FROM t1; +i ELT(j, '345', '34') +1 345 +2 34 +DROP TABLE t1; diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index 33d89b3ca37..2fecf26d7c3 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -154,3 +154,12 @@ INSERT INTO t1 VALUES ('House passes the CAREERS bill'); SELECT CONCAT("",RPAD("",(55 - LENGTH(title)),".")) from t1; DROP TABLE t1; + +# +# test for Bug #2290 "output truncated with ELT when using DISTINCT" +# + +CREATE TABLE t1 (i int, j int); +INSERT INTO t1 VALUES (1,1),(2,2); +SELECT DISTINCT i, ELT(j, '345', '34') FROM t1; +DROP TABLE t1; \ No newline at end of file diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index a4d04253dd7..f2f728367ee 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1507,7 +1507,7 @@ void Item_func_elt::fix_length_and_dec() { max_length=0; decimals=0; - for (uint i=1 ; i < arg_count ; i++) + for (uint i= 0; i < arg_count ; i++) // first number argument isn't in list! { set_if_bigger(max_length,args[i]->max_length); set_if_bigger(decimals,args[i]->decimals); From 17fdccce28af1a99f755c4422e81bbaaaef1b619 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 21 Jan 2004 17:42:41 +0100 Subject: [PATCH 043/113] - remove unnecessary code from Do-rpm to delete the source tarball and spec file after the build as RPM has its own option for this Build-tools/Do-rpm: - remove unnecessary code to delete the source tarball and spec file after the build as RPM has its own option for this --- Build-tools/Do-rpm | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/Build-tools/Do-rpm b/Build-tools/Do-rpm index 3473bcb1f5f..7da8b022031 100755 --- a/Build-tools/Do-rpm +++ b/Build-tools/Do-rpm @@ -115,10 +115,12 @@ if (defined $opt_log) if (-x "/usr/bin/rpmbuild") { $RPM= "/usr/bin/rpmbuild"; + $RMSOURCE= "--rmsource --rmspec"; } else { $RPM= "/bin/rpm"; + $RMSOURCE= "--rmspec"; } if ($RPM) @@ -177,7 +179,7 @@ $ENV{MYSQL_BUILD_CXX}=$opt_cxx if ($opt_cxx); $command= "$RPM"; $command.= " -v" if ($opt_verbose); $command.= " -ba"; -$command.= " --clean" if $opt_clean; +$command.= " --clean $RMSOURCE" if $opt_clean; $command.= " $SPECDIR/"; $command.= basename($SPECFILE); &logger("Building RPM."); @@ -198,19 +200,6 @@ $command.= " $RPMDIR/$RPMARCH/MySQL*$VERSION*.$RPMARCH.rpm $PWD"; &logger("Moving binary RPMs to current dir."); &run_command($command, "Error moving binary RPMs!"); -# -# Clean up -# -if ($opt_clean) -{ - &logger("Removing spec file and source package"); - unless ($opt_dry_run) - { - unlink("$SPECDIR/" . basename($SPECFILE)); - unlink("$SOURCEDIR/$SOURCEFILE"); - } -} - &logger("SUCCESS: RPM files successfully created.") unless ($opt_dry_run); exit 0; From 2c3fdcf749b57d4b168710606c84f42943a4ad24 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 21 Jan 2004 21:43:41 +0100 Subject: [PATCH 044/113] test case for MyISAM sort-repair bug --- mysql-test/r/myisam.result | 6 ++++++ mysql-test/t/myisam.test | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index e113a48f4da..11e8ef4fcd7 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -385,3 +385,9 @@ check table t1; Table Op Msg_type Msg_text test.t1 check status OK drop table t1; +create table t1 ( a text not null, key a (a(20))); +insert into t1 values ('aaa '),('aaa'); +repair table t1; +Table Op Msg_type Msg_text +test.t1 repair status OK +drop table t1; diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index 12853cd67ca..7ad038bcad0 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -385,3 +385,12 @@ insert into t1 (b) values (repeat('z',100)); update t1 set b="test" where left(b,1) > 'n'; check table t1; drop table t1; + +# +# sort-repair bug +# +create table t1 ( a text not null, key a (a(20))); +insert into t1 values ('aaa '),('aaa'); +repair table t1; +drop table t1; + From 0ef9acc9a9932ea63ff41d4528231632f3a3d31d Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 21 Jan 2004 23:29:17 +0100 Subject: [PATCH 045/113] two more bugfixes for "space stripping in MyISAM indexes" --- myisam/mi_search.c | 2 +- mysql-test/r/myisam.result | 4 ++++ mysql-test/t/myisam.test | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/myisam/mi_search.c b/myisam/mi_search.c index c6ee18a8477..b98ee351195 100644 --- a/myisam/mi_search.c +++ b/myisam/mi_search.c @@ -847,7 +847,7 @@ int _mi_key_cmp(register MI_KEYSEG *keyseg, register uchar *a, full_b_length=b_length; next_key_length=key_length-b_length-pack_length; - if (!(nextflag & (SEARCH_PREFIX | SEARCH_UPDATE))) + if ((nextflag & (SEARCH_FIND | SEARCH_UPDATE)) == SEARCH_FIND) { while (a_length && a[a_length-1] == ' ') a_length--; diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index 11e8ef4fcd7..fbb84a677cf 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -390,4 +390,8 @@ insert into t1 values ('aaa '),('aaa'); repair table t1; Table Op Msg_type Msg_text test.t1 repair status OK +select concat(a,'.') from t1 where a='aaa'; +concat(a,'.') +aaa. +aaa . drop table t1; diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index 7ad038bcad0..25bb76ceaba 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -387,10 +387,11 @@ check table t1; drop table t1; # -# sort-repair bug +# two bugs in myisam-space-stripping feature # create table t1 ( a text not null, key a (a(20))); insert into t1 values ('aaa '),('aaa'); repair table t1; +select concat(a,'.') from t1 where a='aaa'; drop table t1; From cdcf112af01e0365f5600b9de442f6640569a7a0 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 21 Jan 2004 23:39:35 +0100 Subject: [PATCH 046/113] test moved to an appropriate file --- mysql-test/r/myisam.result | 8 ++++++++ mysql-test/r/range.result | 8 -------- mysql-test/t/myisam.test | 11 +++++++++++ mysql-test/t/range.test | 11 ----------- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index fbb84a677cf..68a667f6d95 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -395,3 +395,11 @@ concat(a,'.') aaa. aaa . drop table t1; +create table t1(a text not null, b text not null, c text not null, index (a(10),b(10),c(10))); +insert into t1 values('807780', '477', '165'); +insert into t1 values('807780', '477', '162'); +insert into t1 values('807780', '472', '162'); +select * from t1 where a='807780' and b='477' and c='165'; +a b c +807780 477 165 +drop table t1; diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result index 45d20a8fced..e87df9a6c24 100644 --- a/mysql-test/r/range.result +++ b/mysql-test/r/range.result @@ -300,11 +300,3 @@ SELECT COUNT(*) FROM t1 WHERE (c=0 and b=1) or (c=0 and a=1); COUNT(*) 6 DROP TABLE t1; -create table t1(a text not null, b text not null, c text not null, index (a(10),b(10),c(10))); -insert into t1 values('807780', '477', '165'); -insert into t1 values('807780', '477', '162'); -insert into t1 values('807780', '472', '162'); -select * from t1 where a='807780' and b='477' and c='165'; -a b c -807780 477 165 -drop table t1; diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index 25bb76ceaba..394261aae40 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -395,3 +395,14 @@ repair table t1; select concat(a,'.') from t1 where a='aaa'; drop table t1; +# +# Third bug in the same code (BUG#2295) +# + +create table t1(a text not null, b text not null, c text not null, index (a(10),b(10),c(10))); +insert into t1 values('807780', '477', '165'); +insert into t1 values('807780', '477', '162'); +insert into t1 values('807780', '472', '162'); +select * from t1 where a='807780' and b='477' and c='165'; +drop table t1; + diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test index 9d9feaa4edc..b04e614a740 100644 --- a/mysql-test/t/range.test +++ b/mysql-test/t/range.test @@ -249,14 +249,3 @@ SELECT COUNT(*) FROM t1 WHERE (c=0 and a=1) or (c=0 and b=1); SELECT COUNT(*) FROM t1 WHERE (c=0 and b=1) or (c=0 and a=1); DROP TABLE t1; -# -# BUG#2295 - range on blob -# - -create table t1(a text not null, b text not null, c text not null, index (a(10),b(10),c(10))); -insert into t1 values('807780', '477', '165'); -insert into t1 values('807780', '477', '162'); -insert into t1 values('807780', '472', '162'); -select * from t1 where a='807780' and b='477' and c='165'; -drop table t1; - From 79f6e16d5e8b5edeb76d97b5d9886306e000ae87 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 22 Jan 2004 18:05:47 +0400 Subject: [PATCH 047/113] a proper fix for the bug #2298 Trailing whitespace inconsistently handled in WHERE clause. ramil, in MySQL/MyISAM we should only strip end space, not 'space-like' characters. This is according to SQL; When doing a comparision end space and only end space are ignored. myisam/mi_key.c: a proper fix for the bug #2298 Trailing whitespace inconsistently handled in WHERE clause. myisam/mi_search.c: a proper fix for the bug #2298 Trailing whitespace inconsistently handled in WHERE clause. mysql-test/r/select.result: test case for the bug #2298 Trailing whitespace inconsistently handled in WHERE clause. mysql-test/t/select.test: test case for the bug #2298 Trailing whitespace inconsistently handled in WHERE clause. sql/sql_string.cc: a proper fix for the bug #2298 Trailing whitespace inconsistently handled in WHERE clause. --- myisam/mi_key.c | 4 ++-- myisam/mi_search.c | 8 ++++---- mysql-test/r/select.result | 20 ++++++++++++++++++++ mysql-test/t/select.test | 16 ++++++++++++++++ sql/sql_string.cc | 8 ++++---- 5 files changed, 46 insertions(+), 10 deletions(-) diff --git a/myisam/mi_key.c b/myisam/mi_key.c index 58318697e57..766ecf334b6 100644 --- a/myisam/mi_key.c +++ b/myisam/mi_key.c @@ -62,7 +62,7 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key, end=pos+length; if (type != HA_KEYTYPE_NUM) { - while (end > pos && (end[-1] == ' ' || end[-1] == '\t')) + while (end > pos && end[-1] == ' ') end--; } else @@ -186,7 +186,7 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old, end=pos+length; if (type != HA_KEYTYPE_NUM) { - while (end > pos && (end[-1] == ' ' || end[-1] == '\t')) + while (end > pos && end[-1] == ' ') end--; } else diff --git a/myisam/mi_search.c b/myisam/mi_search.c index 82004c6f172..c6ee18a8477 100644 --- a/myisam/mi_search.c +++ b/myisam/mi_search.c @@ -795,9 +795,9 @@ int _mi_key_cmp(register MI_KEYSEG *keyseg, register uchar *a, uint length=(uint) (end-a), a_length=length, b_length=length; if (!(nextflag & SEARCH_PREFIX)) { - while (a_length && (a[a_length-1] == ' ' || a[a_length-1] == '\t')) + while (a_length && a[a_length-1] == ' ') a_length--; - while (b_length && (b[b_length-1] == ' ' || b[b_length-1] == '\t')) + while (b_length && b[b_length-1] == ' ') b_length--; } if (piks && @@ -849,9 +849,9 @@ int _mi_key_cmp(register MI_KEYSEG *keyseg, register uchar *a, if (!(nextflag & (SEARCH_PREFIX | SEARCH_UPDATE))) { - while (a_length && (a[a_length-1] == ' ' || a[a_length-1] == '\t')) + while (a_length && a[a_length-1] == ' ') a_length--; - while (b_length && (b[b_length-1] == ' ' || b[b_length-1] == '\t')) + while (b_length && b[b_length-1] == ' ') b_length--; } if (piks && diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index 9cc5ad76ff0..206fa507615 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -2307,3 +2307,23 @@ left join t4 on id3 = id4 where id2 = 1 or id4 = 1; id1 id2 id3 id4 id44 1 1 NULL NULL NULL drop table t1,t2,t3,t4; +create table t1(s varchar(10) not null); +create table t2(s varchar(10) not null primary key); +create table t3(s varchar(10) not null primary key); +insert into t1 values ('one\t'), ('two\t'); +insert into t2 values ('one\r'), ('two\t'); +insert into t3 values ('one '), ('two\t'); +select * from t1 where s = 'one'; +s +select * from t2 where s = 'one'; +s +select * from t3 where s = 'one'; +s +one +select * from t1,t2 where t1.s = t2.s; +s s +two two +select * from t2,t3 where t2.s = t3.s; +s s +two two +drop table t1, t2, t3; diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 3e23fa1a3f2..7cb157f194e 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -1858,3 +1858,19 @@ left join t4 on id3 = id4 where id2 = 1 or id4 = 1; drop table t1,t2,t3,t4; +# +# Bug #2298 +# + +create table t1(s varchar(10) not null); +create table t2(s varchar(10) not null primary key); +create table t3(s varchar(10) not null primary key); +insert into t1 values ('one\t'), ('two\t'); +insert into t2 values ('one\r'), ('two\t'); +insert into t3 values ('one '), ('two\t'); +select * from t1 where s = 'one'; +select * from t2 where s = 'one'; +select * from t3 where s = 'one'; +select * from t1,t2 where t1.s = t2.s; +select * from t2,t3 where t2.s = t3.s; +drop table t1, t2, t3; diff --git a/sql/sql_string.cc b/sql/sql_string.cc index 2dcda2d40c2..658cd6d2411 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -467,9 +467,9 @@ int sortcmp(const String *x,const String *y) if (use_strcoll(default_charset_info)) { #ifndef CMP_ENDSPACE - while (x_len && isspace(s[x_len-1])) + while (x_len && s[x_len-1] == ' ') x_len--; - while (y_len && isspace(t[y_len-1])) + while (y_len && t[y_len-1] == ' ') y_len--; #endif return my_strnncoll(default_charset_info, @@ -493,14 +493,14 @@ int sortcmp(const String *x,const String *y) { const char *end=t+y_len; for (; t != end ; t++) - if (!isspace(*t)) + if (*t != ' ') return -1; } else { const char *end=s+x_len; for (; s != end ; s++) - if (!isspace(*s)) + if (*s != ' ') return 1; } return 0; From 8b03b319f5cdd21cd47042142bee96e2163100fa Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 22 Jan 2004 20:20:43 +0400 Subject: [PATCH 048/113] some ammendments (comments and code style) mysql-test/t/func_str.test: add skipped new line sql/item_strfunc.cc: rewrote some comments for Item_func_elt --- mysql-test/t/func_str.test | 2 +- sql/item_strfunc.cc | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index 2fecf26d7c3..1eba49a9583 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -162,4 +162,4 @@ DROP TABLE t1; CREATE TABLE t1 (i int, j int); INSERT INTO t1 VALUES (1,1),(2,2); SELECT DISTINCT i, ELT(j, '345', '34') FROM t1; -DROP TABLE t1; \ No newline at end of file +DROP TABLE t1; diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index f2f728367ee..74a7c97113e 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1507,7 +1507,14 @@ void Item_func_elt::fix_length_and_dec() { max_length=0; decimals=0; - for (uint i= 0; i < arg_count ; i++) // first number argument isn't in list! + /* + first numeric argument isn't in args (3.23 and 4.0) + but since 4.1 the cycle should start from 1 + so this change + + should NOT be merged into 4.1!!! + */ + for (uint i= 0; i < arg_count ; i++) { set_if_bigger(max_length,args[i]->max_length); set_if_bigger(decimals,args[i]->decimals); From bd980424268b146dca070d5c3c250afc23ee0576 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 27 Jan 2004 20:10:04 +0200 Subject: [PATCH 049/113] data0data.ic, data0data.h, row0sel.c: Fix bug #2483 with InnoDB, UNIQUE secondary index, and NULL values in that unique index; with the IS NULL predicate, InnoDB returned only the first matching row, though there can be many innobase/row/row0sel.c: Fix bug #2483 with InnoDB, UNIQUE secondary index, and NULL values in that unique index; with the IS NULL predicate, InnoDB returned only the first matching row, though there can be many innobase/include/data0data.h: Fix bug #2483 with InnoDB, UNIQUE secondary index, and NULL values in that unique index; with the IS NULL predicate, InnoDB returned only the first matching row, though there can be many innobase/include/data0data.ic: Fix bug #2483 with InnoDB, UNIQUE secondary index, and NULL values in that unique index; with the IS NULL predicate, InnoDB returned only the first matching row, though there can be many --- innobase/include/data0data.h | 8 ++++++++ innobase/include/data0data.ic | 25 +++++++++++++++++++++++++ innobase/row/row0sel.c | 11 ++++++++++- 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/innobase/include/data0data.h b/innobase/include/data0data.h index 889d148d3fe..2ec94a9517a 100644 --- a/innobase/include/data0data.h +++ b/innobase/include/data0data.h @@ -262,6 +262,14 @@ dtuple_set_types_binary( /*====================*/ dtuple_t* tuple, /* in: data tuple */ ulint n); /* in: number of fields to set */ +/************************************************************************** +Checks if a dtuple contains an SQL null value. */ +UNIV_INLINE +ibool +dtuple_contains_null( +/*=================*/ + /* out: TRUE if some field is SQL null */ + dtuple_t* tuple); /* in: dtuple */ /************************************************************** Checks that a data field is typed. Asserts an error if not. */ diff --git a/innobase/include/data0data.ic b/innobase/include/data0data.ic index d356664df21..bc5a93cb2f8 100644 --- a/innobase/include/data0data.ic +++ b/innobase/include/data0data.ic @@ -406,3 +406,28 @@ data_write_sql_null( data[j] = '\0'; } } + +/************************************************************************** +Checks if a dtuple contains an SQL null value. */ +UNIV_INLINE +ibool +dtuple_contains_null( +/*=================*/ + /* out: TRUE if some field is SQL null */ + dtuple_t* tuple) /* in: dtuple */ +{ + ulint n; + ulint i; + + n = dtuple_get_n_fields(tuple); + + for (i = 0; i < n; i++) { + if (dfield_get_len(dtuple_get_nth_field(tuple, i)) + == UNIV_SQL_NULL) { + + return(TRUE); + } + } + + return(FALSE); +} \ No newline at end of file diff --git a/innobase/row/row0sel.c b/innobase/row/row0sel.c index 27d27b75a1c..fce47a8f9af 100644 --- a/innobase/row/row0sel.c +++ b/innobase/row/row0sel.c @@ -2818,7 +2818,16 @@ row_search_for_mysql( if (match_mode == ROW_SEL_EXACT && index->type & DICT_UNIQUE && dtuple_get_n_fields(search_tuple) - == dict_index_get_n_unique(index)) { + == dict_index_get_n_unique(index) + && (index->type & DICT_CLUSTERED + || !dtuple_contains_null(search_tuple))) { + + /* Note above that a UNIQUE secondary index can contain many + rows with the same key value if one of the columns is the SQL + null. A clustered index under MySQL can never contain null + columns because we demand that all the columns in primary key + are non-null. */ + unique_search = TRUE; /* Even if the condition is unique, MySQL seems to try to From f138cd10152d4df58dcd3f573f443a58b7705250 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 28 Jan 2004 15:26:01 +0100 Subject: [PATCH 050/113] Fix for BUG#2542 "If slave ignores a query it may make the next LOAD DATA INFILE fail": reset errors (in thd) before executing the event. Otherwise if an event is ignored because of replicate-*-table rules (error ER_SLAVE_IGNORED_TABLE) this error code may remain in thd->net and the next event may pick it. sql/log_event.cc: Reset errors (in thd) before executing the event. Otherwise if an event is ignored because of replicate-*-table rules (error ER_SLAVE_IGNORED_TABLE) this error code may remain in thd->net and the next event may pick it. --- sql/log_event.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sql/log_event.cc b/sql/log_event.cc index 4413a77c364..cafd1666eac 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1823,6 +1823,8 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli) since we must store the pos of the END of the current log event */ rli->event_len= get_event_len(); + thd->query_error= 0; // clear error + thd->clear_error(); if (db_ok(thd->db, replicate_do_db, replicate_ignore_db)) { @@ -1833,9 +1835,6 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli) VOID(pthread_mutex_lock(&LOCK_thread_count)); thd->query_id = query_id++; VOID(pthread_mutex_unlock(&LOCK_thread_count)); - thd->query_error = 0; // clear error - thd->net.last_errno = 0; - thd->net.last_error[0] = 0; thd->slave_proxy_id = thread_id; // for temp tables /* @@ -1890,6 +1889,7 @@ Default database: '%s'", ignored_error_code(actual_error)) { thd->query_error = 0; + thd->clear_error(); *rli->last_slave_error = 0; rli->last_slave_errno = 0; } @@ -1960,6 +1960,7 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli, DBUG_ASSERT(thd->query == 0); thd->query = 0; // Should not be needed thd->query_error = 0; + thd->clear_error(); /* We test replicate_*_db rules. Note that we have already prepared the file to From 9fa2dc4a2284bd4959c5a45ae6477c014f92916d Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 29 Jan 2004 14:41:49 +0200 Subject: [PATCH 051/113] btr0cur.c: Fix bug: InnoDB row count and index cardinality estimates wrapped over at 512 million in 32-bit computers innobase/btr/btr0cur.c: Fix bug: InnoDB row count and index cardinality estimates wrapped over at 512 million in 32-bit computers --- innobase/btr/btr0cur.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/innobase/btr/btr0cur.c b/innobase/btr/btr0cur.c index bfb4d042850..d506c5a91a7 100644 --- a/innobase/btr/btr0cur.c +++ b/innobase/btr/btr0cur.c @@ -2638,7 +2638,7 @@ btr_estimate_number_of_different_key_vals( ulint n_cols; ulint matched_fields; ulint matched_bytes; - ulint* n_diff; + ib_longlong* n_diff; ulint not_empty_flag = 0; ulint total_external_size = 0; ulint i; @@ -2710,7 +2710,8 @@ btr_estimate_number_of_different_key_vals( for (j = 0; j <= n_cols; j++) { index->stat_n_diff_key_vals[j] = - (n_diff[j] * index->stat_n_leaf_pages + (n_diff[j] + * (ib_longlong)index->stat_n_leaf_pages + BTR_KEY_VAL_ESTIMATE_N_PAGES - 1 + total_external_size + not_empty_flag) From b9073593d0defc65472125b625e399e5ab22d1f6 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 29 Jan 2004 15:16:48 +0100 Subject: [PATCH 052/113] Mark that strings may change on index only reads (for BDB tables). This fixed problem with index reads on character fields with BDB tables. (Bug #2509) BitKeeper/etc/ignore: added man/*.1 mysql-test/r/bdb.result: New test mysql-test/r/myisam.result: More tests mysql-test/t/bdb.test: Test for idnex only read mysql-test/t/myisam.test: More test to verify pushed bug fix sql/ha_berkeley.h: Mark that strings may change on index only reads sql/item_strfunc.cc: Cleanup sql/table.cc: Allow index only reads on binary strings --- .bzrignore | 1 + mysql-test/r/bdb.result | 25 +++++++++++++++++++++++++ mysql-test/r/myisam.result | 30 +++++++++++++++++++++++++++++- mysql-test/t/bdb.test | 14 ++++++++++++++ mysql-test/t/myisam.test | 18 +++++++++++++++++- sql/ha_berkeley.h | 2 +- sql/item_strfunc.cc | 11 ++++------- sql/table.cc | 3 ++- 8 files changed, 93 insertions(+), 11 deletions(-) diff --git a/.bzrignore b/.bzrignore index 12cdf99cbc9..572f877a49f 100644 --- a/.bzrignore +++ b/.bzrignore @@ -541,3 +541,4 @@ libmysql_r/vio_priv.h hardcopy.0 scripts/make_sharedlib_distribution sql/udf_example.so +man/*.1 diff --git a/mysql-test/r/bdb.result b/mysql-test/r/bdb.result index 05845df9dd3..2ccb5148d58 100644 --- a/mysql-test/r/bdb.result +++ b/mysql-test/r/bdb.result @@ -1165,3 +1165,28 @@ create table t2 (c char(8) not null, b char(8) not null, a char(8) not null, pri insert into t2 select * from t1; delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b; drop table t1,t2; +create table t1 (a char(10), key(a), b int not null, key(b)) engine=bdb; +insert into t1 values ('a',1),('A',2); +explain select a from t1; +table type possible_keys key key_len ref rows Extra +t1 ALL NULL NULL NULL NULL 2 +select a from t1; +a +a +A +explain select b from t1; +table type possible_keys key key_len ref rows Extra +t1 index NULL b 4 NULL 2 Using index +select b from t1; +b +1 +2 +alter table t1 modify a char(10) binary; +explain select a from t1; +table type possible_keys key key_len ref rows Extra +t1 index NULL a 11 NULL 2 Using index +select a from t1; +a +A +a +drop table t1; diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index 68a667f6d95..cc541388a5c 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -386,7 +386,10 @@ Table Op Msg_type Msg_text test.t1 check status OK drop table t1; create table t1 ( a text not null, key a (a(20))); -insert into t1 values ('aaa '),('aaa'); +insert into t1 values ('aaa '),('aaa'),('aa'); +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK repair table t1; Table Op Msg_type Msg_text test.t1 repair status OK @@ -394,6 +397,15 @@ select concat(a,'.') from t1 where a='aaa'; concat(a,'.') aaa. aaa . +select concat(a,'.') from t1 where binary a='aaa'; +concat(a,'.') +aaa. +update t1 set a='bbb' where a='aaa'; +select concat(a,'.') from t1; +concat(a,'.') +bbb. +bbb. +aa. drop table t1; create table t1(a text not null, b text not null, c text not null, index (a(10),b(10),c(10))); insert into t1 values('807780', '477', '165'); @@ -403,3 +415,19 @@ select * from t1 where a='807780' and b='477' and c='165'; a b c 807780 477 165 drop table t1; +create table t1 (a int not null auto_increment primary key, b text not null, unique b (b(20))); +insert into t1 (b) values ('a'),('a '),('a '); +select concat(b,'.') from t1; +concat(b,'.') +a. +a . +a . +update t1 set b='b ' where a=2; +update t1 set b='b ' where a > 1; +Duplicate entry 'b ' for key 2 +delete from t1 where b='b'; +select a,concat(b,'.') from t1; +a concat(b,'.') +1 a. +3 a . +drop table t1; diff --git a/mysql-test/t/bdb.test b/mysql-test/t/bdb.test index 2dfaecba9b1..4b490052535 100644 --- a/mysql-test/t/bdb.test +++ b/mysql-test/t/bdb.test @@ -815,3 +815,17 @@ insert into t2 select * from t1; delete t1,t2 from t2,t1 where t1.a<'B' and t2.b=t1.b; drop table t1,t2; + +# +# Test index only read (Bug #2509) +# +create table t1 (a char(10), key(a), b int not null, key(b)) engine=bdb; +insert into t1 values ('a',1),('A',2); +explain select a from t1; +select a from t1; +explain select b from t1; +select b from t1; +alter table t1 modify a char(10) binary; +explain select a from t1; +select a from t1; +drop table t1; diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index 394261aae40..7302e5dfdda 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -390,9 +390,13 @@ drop table t1; # two bugs in myisam-space-stripping feature # create table t1 ( a text not null, key a (a(20))); -insert into t1 values ('aaa '),('aaa'); +insert into t1 values ('aaa '),('aaa'),('aa'); +check table t1; repair table t1; select concat(a,'.') from t1 where a='aaa'; +select concat(a,'.') from t1 where binary a='aaa'; +update t1 set a='bbb' where a='aaa'; +select concat(a,'.') from t1; drop table t1; # @@ -406,3 +410,15 @@ insert into t1 values('807780', '472', '162'); select * from t1 where a='807780' and b='477' and c='165'; drop table t1; +# +# Test text and unique +# +create table t1 (a int not null auto_increment primary key, b text not null, unique b (b(20))); +insert into t1 (b) values ('a'),('a '),('a '); +select concat(b,'.') from t1; +update t1 set b='b ' where a=2; +--error 1062 +update t1 set b='b ' where a > 1; +delete from t1 where b='b'; +select a,concat(b,'.') from t1; +drop table t1; diff --git a/sql/ha_berkeley.h b/sql/ha_berkeley.h index 285bb575699..1925d1c410f 100644 --- a/sql/ha_berkeley.h +++ b/sql/ha_berkeley.h @@ -92,7 +92,7 @@ class ha_berkeley: public handler HA_NULL_KEY | HA_BLOB_KEY | HA_NOT_EXACT_COUNT | HA_PRIMARY_KEY_IN_READ_INDEX | HA_DROP_BEFORE_CREATE | HA_AUTO_PART_KEY | HA_TABLE_SCAN_ON_INDEX | - HA_FILE_BASED), + HA_KEY_READ_WRONG_STR | HA_FILE_BASED), changed_rows(0),last_dup_key((uint) -1),version(0),using_ignore(0) { } diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 74a7c97113e..31c2dc943e5 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1507,14 +1507,11 @@ void Item_func_elt::fix_length_and_dec() { max_length=0; decimals=0; - /* - first numeric argument isn't in args (3.23 and 4.0) - but since 4.1 the cycle should start from 1 - so this change - - should NOT be merged into 4.1!!! - */ +#if MYSQL_VERSION_ID < 40100 for (uint i= 0; i < arg_count ; i++) +#else + for (uint i= 1; i < arg_count ; i++) +#endif { set_if_bigger(max_length,args[i]->max_length); set_if_bigger(decimals,args[i]->decimals); diff --git a/sql/table.cc b/sql/table.cc index c8def7441fd..a90220fa55b 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -498,7 +498,8 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, field->type() != FIELD_TYPE_BLOB) { if (field->key_type() != HA_KEYTYPE_TEXT || - (!(ha_option & HA_KEY_READ_WRONG_STR) && + ((!(ha_option & HA_KEY_READ_WRONG_STR) || + field->flags & BINARY_FLAG) && !(keyinfo->flags & HA_FULLTEXT))) field->part_of_key|= ((key_map) 1 << key); if ((field->key_type() != HA_KEYTYPE_TEXT || From 8746a25554d18f03fc32ca5d338850f9308bee88 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 29 Jan 2004 19:22:29 +0100 Subject: [PATCH 053/113] Fix for BUG#2527 "Multi-Table Delete - Not Replication use replicate-wild-do-table" (as long as replicate-*-table rules were defined, multi-table DELETE was never replicated by the slave). sql/sql_parse.cc: For a multi-table DELETE, there are two lists of tables: - 'tables' contains the tables in the FROM. They have 'updating==0'. - 'thd->lex.auxilliary_table_list.first' contains the tables between the DELETE and the FROM. They have 'updating==1'. So the bug was that the slave only tests 'tables' and as all its elements have updating==0, tables_ok() always returns 0. So for a multi DELETE the slave now tests the 2nd list too. I started with the other tip of the sausage: I thought of changing multi DELETE to use only one list (given that 'updating' can be used to separate it in two when needed) (with one list we wouldn't need to change the slave code), but finally hit the unicity check in add_table_to_list() which started to return ER_NONUNIQ_TABLE (logical). --- mysql-test/r/rpl_multi_delete.result | 22 ++++++++++++++++++++++ mysql-test/t/rpl_multi_delete-slave.opt | 1 + mysql-test/t/rpl_multi_delete.test | 23 +++++++++++++++++++++++ sql/sql_parse.cc | 4 +++- 4 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 mysql-test/r/rpl_multi_delete.result create mode 100644 mysql-test/t/rpl_multi_delete-slave.opt create mode 100644 mysql-test/t/rpl_multi_delete.test diff --git a/mysql-test/r/rpl_multi_delete.result b/mysql-test/r/rpl_multi_delete.result new file mode 100644 index 00000000000..fa254d76393 --- /dev/null +++ b/mysql-test/r/rpl_multi_delete.result @@ -0,0 +1,22 @@ +slave stop; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +slave start; +create table t1 (a int); +create table t2 (a int); +insert into t1 values (1); +insert into t2 values (1); +delete t1.* from t1, t2 where t1.a = t2.a; +select * from t1; +a +select * from t2; +a +1 +select * from t1; +a +select * from t2; +a +1 +drop table t1,t2; diff --git a/mysql-test/t/rpl_multi_delete-slave.opt b/mysql-test/t/rpl_multi_delete-slave.opt new file mode 100644 index 00000000000..c98fe0b0a46 --- /dev/null +++ b/mysql-test/t/rpl_multi_delete-slave.opt @@ -0,0 +1 @@ +--replicate-wild-do-table=test.% diff --git a/mysql-test/t/rpl_multi_delete.test b/mysql-test/t/rpl_multi_delete.test new file mode 100644 index 00000000000..299cb720b62 --- /dev/null +++ b/mysql-test/t/rpl_multi_delete.test @@ -0,0 +1,23 @@ +source include/master-slave.inc; +create table t1 (a int); +create table t2 (a int); + +insert into t1 values (1); +insert into t2 values (1); + +delete t1.* from t1, t2 where t1.a = t2.a; + +save_master_pos; +select * from t1; +select * from t2; + +connection slave; +sync_with_master; +select * from t1; +select * from t2; + +connection master; +drop table t1,t2; +save_master_pos; +connection slave; +sync_with_master; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 608cdd23282..0d22704ef3c 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1334,7 +1334,9 @@ mysql_execute_command(void) Skip if we are in the slave thread, some table rules have been given and the table list says the query should not be replicated */ - if (table_rules_on && tables && !tables_ok(thd,tables)) + if (table_rules_on && tables && !tables_ok(thd,tables) && + ((lex->sql_command != SQLCOM_DELETE_MULTI) || + !tables_ok(thd,(TABLE_LIST *)thd->lex.auxilliary_table_list.first))) { /* we warn the slave SQL thread */ my_error(ER_SLAVE_IGNORED_TABLE, MYF(0)); From bbd2adf4ba6ec2086a5e8eeaa89f56f1abee02f6 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 30 Jan 2004 00:05:34 +0100 Subject: [PATCH 054/113] Fix for BUG#2477 "Slave stop with error after master reboot if use HEAP tables": when we open the HEAP table for the first time since server restart, in hp_open(), we set a flag to propagate this info to the handler level which then writes a DELETE FROM this_heap_table to the binlog. It is not a perfect solution for the bug, because between the server start and the first open of the table, the slave still had old data in his table so a SELECT on the slave may show wrong content. But if there is a --init-file to populate the HEAP table on master as startup, then this is a safe fix (I'll put a note about init-file in the HEAP section of the manual). heap/hp_info.c: new info variable implicit_emptied heap/hp_open.c: If this is the first open of the HEAP table, it means it is empty, so we mark it. include/heap.h: new variables implicit_emptied (we need one in HEAPINFO for the hp_info() call). sql/ha_heap.cc: report info to upper level sql/handler.h: new info 'implicit_emptied' in the handler level; only HEAP uses it. sql/sql_base.cc: When a HEAP table is opened for the first time, write a DELETE FROM to the binlog, for replication and mysqlbinlog|mysql. Monty: I added the entry->file->implicit_emptied= 0; --- heap/hp_info.c | 15 +++++----- heap/hp_open.c | 3 ++ include/heap.h | 2 ++ mysql-test/r/rpl_heap.result | 29 +++++++++++++++++++ mysql-test/t/rpl_heap.test | 47 +++++++++++++++++++++++++++++++ sql/ha_heap.cc | 1 + sql/handler.h | 3 +- sql/sql_base.cc | 54 +++++++++++++++++++++++++++++------- 8 files changed, 136 insertions(+), 18 deletions(-) create mode 100644 mysql-test/r/rpl_heap.result create mode 100644 mysql-test/t/rpl_heap.test diff --git a/heap/hp_info.c b/heap/hp_info.c index 3e9d6b6a90b..c8cdfc58c2d 100644 --- a/heap/hp_info.c +++ b/heap/hp_info.c @@ -48,12 +48,13 @@ int heap_info(reg1 HP_INFO *info,reg2 HEAPINFO *x, int flag __attribute__((unused))) { DBUG_ENTER("heap_info"); - x->records = info->s->records; - x->deleted = info->s->deleted; - x->reclength = info->s->reclength; - x->data_length = info->s->data_length; - x->index_length= info->s->index_length; - x->max_records = info->s->max_records; - x->errkey = info->errkey; + x->records = info->s->records; + x->deleted = info->s->deleted; + x->reclength = info->s->reclength; + x->data_length = info->s->data_length; + x->index_length = info->s->index_length; + x->max_records = info->s->max_records; + x->errkey = info->errkey; + x->implicit_emptied= info->implicit_emptied; DBUG_RETURN(0); } /* heap_info */ diff --git a/heap/hp_open.c b/heap/hp_open.c index ec8b5fea904..3bf2881667a 100644 --- a/heap/hp_open.c +++ b/heap/hp_open.c @@ -30,6 +30,7 @@ HP_INFO *heap_open(const char *name, int mode, uint keys, HP_KEYDEF *keydef, uint reclength, ulong max_records, ulong min_records) { uint i,j,key_segs,max_length,length; + my_bool implicit_emptied= 0; HP_INFO *info; HP_SHARE *share; HP_KEYSEG *keyseg; @@ -39,6 +40,7 @@ HP_INFO *heap_open(const char *name, int mode, uint keys, HP_KEYDEF *keydef, if (!(share=_hp_find_named_heap(name))) { DBUG_PRINT("info",("Initializing new table")); + implicit_emptied= 1; for (i=key_segs=max_length=0 ; i < keys ; i++) { key_segs+= keydef[i].keysegs; @@ -127,6 +129,7 @@ HP_INFO *heap_open(const char *name, int mode, uint keys, HP_KEYDEF *keydef, #ifndef DBUG_OFF info->opt_flag=READ_CHECK_USED; /* Check when changing */ #endif + info->implicit_emptied= implicit_emptied; DBUG_PRINT("exit",("heap: %lx reclength: %d records_in_block: %d", info,share->reclength,share->block.records_in_block)); DBUG_RETURN(info); diff --git a/include/heap.h b/include/heap.h index 02b04e2b3ec..ed023133469 100644 --- a/include/heap.h +++ b/include/heap.h @@ -47,6 +47,7 @@ typedef struct st_heapinfo /* Struct from heap_info */ ulong index_length; uint reclength; /* Length of one record */ int errkey; + my_bool implicit_emptied; } HEAPINFO; @@ -126,6 +127,7 @@ typedef struct st_heap_info int mode; /* Mode of file (READONLY..) */ uint opt_flag,update; byte *lastkey; /* Last used key with rkey */ + my_bool implicit_emptied; #ifdef THREAD THR_LOCK_DATA lock; #endif diff --git a/mysql-test/r/rpl_heap.result b/mysql-test/r/rpl_heap.result new file mode 100644 index 00000000000..1556bcd5f25 --- /dev/null +++ b/mysql-test/r/rpl_heap.result @@ -0,0 +1,29 @@ +reset master; +drop table if exists t1; +create table t1 (a int) type=HEAP; +insert into t1 values(10); +show binlog events from 79; +Log_name Pos Event_type Server_id Orig_log_pos Info +master-bin.001 79 Query 1 79 use `test`; create table t1 (a int) type=HEAP +master-bin.001 147 Query 1 147 use `test`; DELETE FROM `test`.`t1` +master-bin.001 205 Query 1 205 use `test`; insert into t1 values(10) +reset slave; +start slave; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) default NULL +) TYPE=HEAP +select * from t1; +a +10 +select * from t1; +a +select * from t1 limit 10; +a +show binlog events in 'master-bin.002' from 79; +Log_name Pos Event_type Server_id Orig_log_pos Info +master-bin.002 79 Query 1 79 use `test`; DELETE FROM `test`.`t1` +select * from t1; +a +drop table t1; diff --git a/mysql-test/t/rpl_heap.test b/mysql-test/t/rpl_heap.test new file mode 100644 index 00000000000..15f61918034 --- /dev/null +++ b/mysql-test/t/rpl_heap.test @@ -0,0 +1,47 @@ +# You must run this test with --manager. + +require_manager; + +# Don't know why, but using TCP/IP connections makes this test fail +# with "Lost connection to MySQL server during query" when we +# issue a query after the server restart. +# Maybe this is something awkward in mysqltest or in the manager? +# So we use sockets. +connect (master,localhost,root,,test,0,master.sock); +connect (slave,localhost,root,,test,0,slave.sock); + +connection master; +reset master; +drop table if exists t1; +create table t1 (a int) type=HEAP; +insert into t1 values(10); +save_master_pos; +show binlog events from 79; +connection slave; +reset slave; +start slave; +sync_with_master; +show create table t1; +select * from t1; # should be one row + +server_stop master; +server_start master; + +connection master; +select * from t1; +# to check that DELETE is not written twice +# (the LIMIT is to not use the query cache) +select * from t1 limit 10; +save_master_pos; +show binlog events in 'master-bin.002' from 79; + +connection slave; +sync_with_master; +select * from t1; # should be empty + +# clean up +connection master; +drop table t1; +save_master_pos; +connection slave; +sync_with_master; diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc index 2edc3b1478e..eb4bf517374 100644 --- a/sql/ha_heap.cc +++ b/sql/ha_heap.cc @@ -222,6 +222,7 @@ void ha_heap::info(uint flag) index_file_length=info.index_length; max_data_file_length= info.max_records* info.reclength; delete_length= info.deleted * info.reclength; + implicit_emptied= info.implicit_emptied; } int ha_heap::extra(enum ha_extra_function operation) diff --git a/sql/handler.h b/sql/handler.h index 8e72267c337..60edf539e2c 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -213,6 +213,7 @@ public: uint raid_type,raid_chunks; FT_INFO *ft_handler; bool auto_increment_column_changed; + bool implicit_emptied; /* Can be !=0 only if HEAP */ handler(TABLE *table_arg) :table(table_arg), ref(0), data_file_length(0), max_data_file_length(0), index_file_length(0), @@ -221,7 +222,7 @@ public: create_time(0), check_time(0), update_time(0), key_used_on_scan(MAX_KEY), active_index(MAX_REF_PARTS), ref_length(sizeof(my_off_t)), block_size(0), - raid_type(0), ft_handler(0) + raid_type(0), ft_handler(0), implicit_emptied(0) {} virtual ~handler(void) {} int ha_open(const char *name, int mode, int test_if_locked); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 9937336fb4a..40153ad847e 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -550,6 +550,11 @@ void close_temporary_tables(THD *thd) query_buf_size= 50; // Enough for DROP ... TABLE for (table=thd->temporary_tables ; table ; table=table->next) + /* + We are going to add 4 ` around the db/table names, so 1 does not look + enough; indeed it is enough, because table->key_length is greater (by 8, + because of server_id and thread_id) than db||table. + */ query_buf_size+= table->key_length+1; if ((query = alloc_root(&thd->mem_root, query_buf_size))) @@ -566,8 +571,8 @@ void close_temporary_tables(THD *thd) Here we assume table_cache_key always starts with \0 terminated db name */ - end = strxmov(end,"`",table->table_cache_key,"`", - ".`",table->real_name,"`,", NullS); + end = strxmov(end,"`",table->table_cache_key,"`.`", + table->real_name,"`,", NullS); } next=table->next; close_temporary(table); @@ -1331,8 +1336,7 @@ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db, } } pthread_mutex_unlock(&LOCK_open); - thd->net.last_error[0]=0; // Clear error message - thd->net.last_errno=0; + thd->clear_error(); error=0; if (openfrm(path,alias, (uint) (HA_OPEN_KEYFILE | HA_OPEN_RNDFILE | HA_GET_INDEX | @@ -1343,8 +1347,7 @@ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db, (entry->file->is_crashed() && entry->file->check_and_repair(thd))) { /* Give right error message */ - thd->net.last_error[0]=0; - thd->net.last_errno=0; + thd->clear_error(); my_error(ER_NOT_KEYFILE, MYF(0), name, my_errno); sql_print_error("Error: Couldn't repair table: %s.%s",db,name); if (entry->file) @@ -1352,16 +1355,47 @@ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db, error=1; } else - { - thd->net.last_error[0]=0; // Clear error message - thd->net.last_errno=0; - } + thd->clear_error(); pthread_mutex_lock(&LOCK_open); unlock_table_name(thd,&table_list); if (error) goto err; } + /* + If we are here, there was no fatal error (but error may be still + unitialized). + */ + if (unlikely(entry->file->implicit_emptied)) + { + entry->file->implicit_emptied= 0; + if (mysql_bin_log.is_open()) + { + char *query, *end; + uint query_buf_size= 20 + 2*NAME_LEN + 1; + if ((query= (char*)my_malloc(query_buf_size,MYF(MY_WME)))) + { + end = strxmov(strmov(query, "DELETE FROM `"), + db,"`.`",name,"`", NullS); + Query_log_event qinfo(thd, query, (ulong)(end-query), 0); + mysql_bin_log.write(&qinfo); + my_free(query, MYF(0)); + } + else + { + /* + As replication is maybe going to be corrupted, we need to warn the + DBA on top of warning the client (which will automatically be done + because of MYF(MY_WME) in my_malloc() above). + */ + sql_print_error("Error: when opening HEAP table, could not allocate \ +memory to write 'DELETE FROM `%s`.`%s`' to the binary log",db,name); + if (entry->file) + closefrm(entry); + goto err; + } + } + } DBUG_RETURN(0); err: DBUG_RETURN(1); From f120273dd284ff4df9649191e8cc37b2d84dd033 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 30 Jan 2004 10:46:30 +0100 Subject: [PATCH 055/113] Fixed parsing of column names and foreign key constraints in Innobase to handle quoted identifiers and identifiers with space. (Bug #1725) Fix optimizer tuning bug when first used key part was a constant. (Bug #1679) innobase/dict/dict0dict.c: Fixed parsing of column names and foreign key constraints to handle quoted identifiers and identifiers with space. (Bug #1725) mysql-test/r/innodb.result: Test of innodb internal parsing mysql-test/t/innodb.test: Test of innodb internal parsing sql/sql_class.cc: Safety fix for select into outfile and select into dumpfile. Before calling send_error() could cause end_io_cache() to be called several times. sql/sql_class.h: Add path to dumpfile so that we can delete the generated file if something goes wrong. sql/sql_select.cc: Fix optimizer tuning bug when first used key part was a constant. Previously all keys that had this key part first was regarded as equal, even if the query used more key parts for some of the keys. Now we use the range optimizer results to just limit the number of estimated rows if not all key parts where constants. (Bug #1679) --- innobase/dict/dict0dict.c | 73 +++++++++++++++++++++++--------------- mysql-test/r/innodb.result | 3 ++ mysql-test/t/innodb.test | 9 +++++ sql/sql_class.cc | 22 +++++++----- sql/sql_class.h | 4 ++- sql/sql_select.cc | 15 ++++++-- 6 files changed, 86 insertions(+), 40 deletions(-) diff --git a/innobase/dict/dict0dict.c b/innobase/dict/dict0dict.c index a576a886b97..dc7acfcba36 100644 --- a/innobase/dict/dict0dict.c +++ b/innobase/dict/dict0dict.c @@ -2138,19 +2138,37 @@ dict_scan_col( return(ptr); } - if (*ptr == '`') { - ptr++; - } + if (*ptr == '`' || *ptr == '"') { + /* + The identifier is quoted. Search for end quote. + We can't use the general code here as the name may contain + special characters like space. + */ + char quote= *ptr++; - old_ptr = ptr; + old_ptr= ptr; + /* + The colum name should always end with 'quote' but we check for + end zero just to be safe if this is called outside of MySQL + */ + while (*ptr && *ptr != quote) + ptr++; + *column_name_len = (ulint)(ptr - old_ptr); + + if (*ptr) /* Skip end quote */ + ptr++; + } + else + { + old_ptr = ptr; - while (!isspace(*ptr) && *ptr != ',' && *ptr != ')' && *ptr != '`' - && *ptr != '\0') { - + while (!isspace(*ptr) && *ptr != ',' && *ptr != ')' + && *ptr != '\0') { ptr++; + } + *column_name_len = (ulint)(ptr - old_ptr); } - *column_name_len = (ulint)(ptr - old_ptr); if (table == NULL) { *success = TRUE; @@ -2161,9 +2179,9 @@ dict_scan_col( col = dict_table_get_nth_col(table, i); - if (ut_strlen(col->name) == (ulint)(ptr - old_ptr) + if (ut_strlen(col->name) == *column_name_len && 0 == ut_cmp_in_lower_case(col->name, old_ptr, - (ulint)(ptr - old_ptr))) { + *column_name_len)) { /* Found */ *success = TRUE; @@ -2175,10 +2193,6 @@ dict_scan_col( } } - if (*ptr == '`') { - ptr++; - } - return(ptr); } @@ -2200,6 +2214,7 @@ dict_scan_table_name( char* dot_ptr = NULL; char* old_ptr; ulint i; + char quote = 0; *success = FALSE; *table = NULL; @@ -2213,14 +2228,16 @@ dict_scan_table_name( return(ptr); } - if (*ptr == '`') { - ptr++; + if (*ptr == '`' || *ptr == '"') { + quote= *ptr++; } old_ptr = ptr; - while (!isspace(*ptr) && *ptr != '(' && *ptr != '`' && *ptr != '\0') { - if (*ptr == '.') { + while (*ptr != quote && + (quote || (!isspace(*ptr) && *ptr != '(')) && + *ptr != '\0') { + if (!quote && *ptr == '.') { dot_ptr = ptr; } @@ -2273,7 +2290,7 @@ dict_scan_table_name( *table = dict_table_get_low(second_table_name); - if (*ptr == '`') { + if (*ptr && *ptr == quote) { ptr++; } @@ -2293,7 +2310,7 @@ dict_scan_id( scannable */ ulint* len) /* out: length of the id */ { - ibool scanned_backquote = FALSE; + char quote = 0; *start = NULL; @@ -2306,23 +2323,23 @@ dict_scan_id( return(ptr); } - if (*ptr == '`') { - scanned_backquote = TRUE; - ptr++; + if (*ptr == '`' || *ptr == '"') { + quote = *ptr++; } *start = ptr; - while (!isspace(*ptr) && *ptr != ',' && *ptr != '(' && *ptr != ')' - && *ptr != '\0' && *ptr != '`') { - + while (*ptr != quote && + (!quote || (!isspace(*ptr) && *ptr != ',' && *ptr != '(' && + *ptr != ')')) + && *ptr != '\0') { ptr++; } *len = (ulint) (ptr - *start); - if (scanned_backquote) { - if (*ptr == '`') { + if (quote) { + if (*ptr == quote) { ptr++; } else { /* Syntax error */ diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result index ce5491a718f..ca4a49fea4e 100644 --- a/mysql-test/r/innodb.result +++ b/mysql-test/r/innodb.result @@ -1243,3 +1243,6 @@ a 3 4 drop table t1; +CREATE TABLE t1 (`id 1` INT NOT NULL, PRIMARY KEY (`id 1`)) TYPE=INNODB; +CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id), FOREIGN KEY (`t1_id`) REFERENCES `t1`(`id 1`) ON DELETE CASCADE ) TYPE=INNODB; +drop table t1,t2; diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test index 7cc509caf74..51fadccdc1c 100644 --- a/mysql-test/t/innodb.test +++ b/mysql-test/t/innodb.test @@ -869,3 +869,12 @@ truncate table t1; insert into t1 (a) values (NULL),(NULL); SELECT * from t1; drop table t1; + +# +# Test dictionary handling with spaceand quoting +# + +CREATE TABLE t1 (`id 1` INT NOT NULL, PRIMARY KEY (`id 1`)) TYPE=INNODB; +CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id), FOREIGN KEY (`t1_id`) REFERENCES `t1`(`id 1`) ON DELETE CASCADE ) TYPE=INNODB; +#show create table t2; +drop table t1,t2; diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 3ea61da28fc..fc83131e98a 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -538,7 +538,6 @@ select_export::~select_export() int select_export::prepare(List &list) { - char path[FN_REFLEN]; uint option=4; bool blob_flag=0; #ifdef DONT_ALLOW_FULL_LOAD_DATA_PATHS @@ -739,9 +738,13 @@ err: void select_export::send_error(uint errcode,const char *err) { ::send_error(&thd->net,errcode,err); - (void) end_io_cache(&cache); - (void) my_close(file,MYF(0)); - file= -1; + if (file > 0) + { + (void) end_io_cache(&cache); + (void) my_close(file,MYF(0)); + (void) my_delete(path,MYF(0)); // Delete file on error + file= -1; + } } @@ -849,10 +852,13 @@ err: void select_dump::send_error(uint errcode,const char *err) { ::send_error(&thd->net,errcode,err); - (void) end_io_cache(&cache); - (void) my_close(file,MYF(0)); - (void) my_delete(path,MYF(0)); // Delete file on error - file= -1; + if (file > 0) + { + (void) end_io_cache(&cache); + (void) my_close(file,MYF(0)); + (void) my_delete(path,MYF(0)); // Delete file on error + file= -1; + } } diff --git a/sql/sql_class.h b/sql/sql_class.h index f4fc7b4770f..d96c6bb53cc 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -665,11 +665,13 @@ class select_export :public select_result { File file; IO_CACHE cache; ha_rows row_count; + char path[FN_REFLEN]; uint field_term_length; int field_sep_char,escape_char,line_sep_char; bool fixed_row_size; public: - select_export(sql_exchange *ex) :exchange(ex),file(-1),row_count(0L) {} + select_export(sql_exchange *ex) :exchange(ex),file(-1),row_count(0L) + { path[0]=0; } ~select_export(); int prepare(List &list); bool send_fields(List &list, diff --git a/sql/sql_select.cc b/sql/sql_select.cc index e3bd3c8b570..36ef97cbf30 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1912,7 +1912,8 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count, read_time+=record_count/(double) TIME_FOR_COMPARE; if (join->sort_by_table && - join->sort_by_table != join->positions[join->const_tables].table->table) + join->sort_by_table != + join->positions[join->const_tables].table->table) read_time+=record_count; // We have to make a temp table if (read_time < join->best_read) { @@ -1946,7 +1947,7 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count, uint max_key_part=0; /* Test how we can use keys */ - rec= s->records/MATCHING_ROWS_IN_OTHER_TABLE; /* Assumed records/key */ + rec= s->records/MATCHING_ROWS_IN_OTHER_TABLE; // Assumed records/key for (keyuse=s->keyuse ; keyuse->table == table ;) { key_map found_part=0; @@ -2085,7 +2086,7 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count, will match */ if (table->quick_keys & ((key_map) 1 << key) && - table->quick_key_parts[key] <= max_key_part) + table->quick_key_parts[key] == max_key_part) tmp=records= (double) table->quick_rows[key]; else { @@ -2127,6 +2128,14 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count, } records=(ulong) tmp; } + /* + If quick_select was used on a part of this key, we know + the maximum number of rows that the key can match. + */ + if (table->quick_keys & ((key_map) 1 << key) && + table->quick_key_parts[key] <= max_key_part && + records > (double) table->quick_rows[key]) + tmp= records= (double) table->quick_rows[key]; } /* Limit the number of matched rows */ set_if_smaller(tmp, (double) thd->variables.max_seeks_for_key); From a96ffb29258a80f8dfaa11f336d0edaa23ad6cf6 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 30 Jan 2004 15:13:19 +0300 Subject: [PATCH 056/113] Fix for bugs #1885, #2464, #2539. Proper handling of default values for TIMESTAMP columns. The solution is not perfect since we just silently ignoring default value for first TIMESTAMP column and properly reflecting this fact in SHOW CREATE TABLE. We can't give a warning or simply support standard syntax (niladic functions as legal value for default) for first field since it is 4.0 tree. mysql-test/r/type_timestamp.result: Added test for bugs #1885, #2464, #2539 (proper support of default values for TIMESTAMP columns) mysql-test/t/type_timestamp.test: Added test for bugs #1885, #2464, #2539 (proper support of default values for TIMESTAMP columns) sql/field.cc: Enabled copying of defaults for TIMESTAMP fields when we are creating table with CREATE TABLE x (SELECT ...) sql/field.h: Set proper DEFAULT value for non-first TIMESTAMP column. sql/sql_parse.cc: Allowed default values for TIMESTAMP column. sql/sql_show.cc: Enabled printing of default values in SHOW CREATE TABLE and SHOW COLUMNS for all TIMESTAMP columns except first one. --- mysql-test/r/type_timestamp.result | 47 ++++++++++++++++++++++++++++-- mysql-test/t/type_timestamp.test | 33 +++++++++++++++++++-- sql/field.cc | 3 +- sql/field.h | 5 +++- sql/sql_parse.cc | 12 ++++---- sql/sql_show.cc | 14 +++++++-- 6 files changed, 98 insertions(+), 16 deletions(-) diff --git a/mysql-test/r/type_timestamp.result b/mysql-test/r/type_timestamp.result index b513f958787..cd45bcf911d 100644 --- a/mysql-test/r/type_timestamp.result +++ b/mysql-test/r/type_timestamp.result @@ -122,5 +122,48 @@ t2 t4 t6 t8 t10 t12 t14 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 0000-00-00 00:00:00 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 1997-12-31 23:47:59 drop table t1; -create table t1 (a timestamp default 1); -Invalid default value for 'a' +create table t1 (t1 timestamp default '2003-01-01 00:00:00', +t2 timestamp default '2003-01-01 00:00:00'); +set TIMESTAMP=1000000000; +insert into t1 values(); +select * from t1; +t1 t2 +2001-09-09 04:46:40 2003-01-01 00:00:00 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `t1` timestamp(14) NOT NULL, + `t2` timestamp(14) NOT NULL default '2003-01-01 00:00:00' +) TYPE=MyISAM +show columns from t1; +Field Type Null Key Default Extra +t1 timestamp(14) YES NULL +t2 timestamp(14) YES 2003-01-01 00:00:00 +show columns from t1 like 't2'; +Field Type Null Key Default Extra +t2 timestamp(14) YES 2003-01-01 00:00:00 +create table t2 (select * from t1); +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `t1` timestamp(14) NOT NULL, + `t2` timestamp(14) NOT NULL default '2003-01-01 00:00:00' +) TYPE=MyISAM +alter table t1 add column t0 timestamp first; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `t0` timestamp(14) NOT NULL, + `t1` timestamp(14) NOT NULL default '2003-01-01 00:00:00', + `t2` timestamp(14) NOT NULL default '2003-01-01 00:00:00' +) TYPE=MyISAM +drop table t1,t2; +create table t1 (ts1 timestamp, ts2 timestamp); +set TIMESTAMP=1000000000; +insert into t1 values (); +insert into t1 values (DEFAULT, DEFAULT); +select * from t1; +ts1 ts2 +2001-09-09 04:46:40 0000-00-00 00:00:00 +2001-09-09 04:46:40 0000-00-00 00:00:00 +drop table t1; diff --git a/mysql-test/t/type_timestamp.test b/mysql-test/t/type_timestamp.test index 17f7b7c487f..3483227376e 100644 --- a/mysql-test/t/type_timestamp.test +++ b/mysql-test/t/type_timestamp.test @@ -73,8 +73,35 @@ select * from t1; drop table t1; # -# Bug #1885 +# Bug #1885, bug #2539. +# Not perfect but still sensible attitude towards defaults for TIMESTAMP +# We will ignore default value for first TIMESTAMP column. +# +create table t1 (t1 timestamp default '2003-01-01 00:00:00', + t2 timestamp default '2003-01-01 00:00:00'); +set TIMESTAMP=1000000000; +insert into t1 values(); +select * from t1; +show create table t1; +show columns from t1; +show columns from t1 like 't2'; +create table t2 (select * from t1); +show create table t2; + +# Ugly, but we can't do anything about this in 4.0 +alter table t1 add column t0 timestamp first; +show create table t1; + +drop table t1,t2; + +# +# Test for bug 2464, DEFAULT keyword in INSERT statement should return +# default value for column. # ---error 1067 -create table t1 (a timestamp default 1); +create table t1 (ts1 timestamp, ts2 timestamp); +set TIMESTAMP=1000000000; +insert into t1 values (); +insert into t1 values (DEFAULT, DEFAULT); +select * from t1; +drop table t1; diff --git a/sql/field.cc b/sql/field.cc index 8bcbf8ecc56..687c22bb69b 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -5124,8 +5124,7 @@ create_field::create_field(Field *old_field,Field *orig_field) interval=0; def=0; if (!old_field->is_real_null() && ! (flags & BLOB_FLAG) && - old_field->type() != FIELD_TYPE_TIMESTAMP && old_field->ptr && - orig_field) + old_field->ptr && orig_field) { char buff[MAX_FIELD_WIDTH],*pos; String tmp(buff,sizeof(buff)); diff --git a/sql/field.h b/sql/field.h index 413a08f08d4..6f049e3809e 100644 --- a/sql/field.h +++ b/sql/field.h @@ -564,7 +564,10 @@ public: void set_time(); virtual void set_default() { - set_time(); + if (table->timestamp_field == this) + set_time(); + else + Field::set_default(); } inline long get_timestamp() { diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 608cdd23282..69257913b5b 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3056,12 +3056,12 @@ bool add_field_to_list(char *field_name, enum_field_types type, if (default_value) { - if (type == FIELD_TYPE_TIMESTAMP) - { - net_printf(&thd->net, ER_INVALID_DEFAULT, field_name); - DBUG_RETURN(1); - } - else if (default_value->type() == Item::NULL_ITEM) + /* + We allow specifying value for first TIMESTAMP column + altough it is silently ignored. This should be fixed in 4.1 + (by proper warning or real support for default values) + */ + if (default_value->type() == Item::NULL_ITEM) { default_value=0; if ((type_modifier & (NOT_NULL_FLAG | AUTO_INCREMENT_FLAG)) == diff --git a/sql/sql_show.cc b/sql/sql_show.cc index d34e2e68067..1aca352a894 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -508,6 +508,12 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild, field->sql_type(type); net_store_data(packet,convert,type.ptr(),type.length()); + /* + Altough TIMESTAMP fields can't contain NULL as its value they + will accept NULL if you will try to insert such value and will + convert it to current TIMESTAMP. So YES here means that NULL + is allowed for assignment but can't be returned. + */ pos=(byte*) ((flags & NOT_NULL_FLAG) && field->type() != FIELD_TYPE_TIMESTAMP ? "" : "YES"); @@ -517,7 +523,11 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild, (field->flags & MULTIPLE_KEY_FLAG) ? "MUL":""); net_store_data(packet,convert,(char*) pos); - if (field->type() == FIELD_TYPE_TIMESTAMP || + /* + We handle first TIMESTAMP column in special way because its + default value is ignored and current timestamp used instead. + */ + if (table->timestamp_field == field || field->unireg_check == Field::NEXT_NUMBER) null_default_value=1; if (!null_default_value && !field->is_null()) @@ -888,7 +898,7 @@ store_create_info(THD *thd, TABLE *table, String *packet) packet->append(type.ptr(),type.length()); has_default= (field->type() != FIELD_TYPE_BLOB && - field->type() != FIELD_TYPE_TIMESTAMP && + table->timestamp_field != field && field->unireg_check != Field::NEXT_NUMBER); if (flags & NOT_NULL_FLAG) packet->append(" NOT NULL", 9); From ef55f2dcdbc79c78aa37e6646ac2aef62c23e7d3 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 30 Jan 2004 19:15:11 +0300 Subject: [PATCH 057/113] Fix for bug #2523 '"func_time" test fails on QNX'. Moved all range checks for TIMESTAMP value to my_gmt_sec(). Also fixed check of upper boundary of TIMESTAMP range (which also now will catch datetime values which are too small for TIMESTAMP in case if time_t is unsigned). mysql-test/r/timezone.result: Added test which checks if TIMESTAMP range is checked correctly (current time zone is honoured and both upper and lower bounds of TIMESTAMP range are checked). mysql-test/t/timezone.test: Added test which checks if TIMESTAMP range is checked correctly (current time zone is honoured and both upper and lower bounds of TIMESTAMP range are checked). sql/field.cc: Check if datetime value is in TIMESTAMP range has moved to my_gmt_sec() function. sql/mysql_priv.h: Added more constants for checking if datetime is in allowed range for TIMESTAMP. sql/time.cc: Check if datetime value is in TIMESTAMP range has moved to my_gmt_sec() function. Fixed check of its return value to catch overflows in both directions and also overflows in case of unsigned time_t. --- mysql-test/r/timezone.result | 6 ++++++ mysql-test/t/timezone.test | 7 +++++++ sql/field.cc | 14 +++++--------- sql/mysql_priv.h | 3 +++ sql/time.cc | 19 +++++++++++-------- 5 files changed, 32 insertions(+), 17 deletions(-) diff --git a/mysql-test/r/timezone.result b/mysql-test/r/timezone.result index 20706408075..15f0d4121c7 100644 --- a/mysql-test/r/timezone.result +++ b/mysql-test/r/timezone.result @@ -32,3 +32,9 @@ ts from_unixtime(ts) 1048989599 2003-03-30 03:59:59 1048989601 2003-03-30 04:00:01 DROP TABLE t1; +select unix_timestamp('1970-01-01 01:00:00'), +unix_timestamp('1970-01-01 01:00:01'), +unix_timestamp('2038-01-01 00:59:59'), +unix_timestamp('2038-01-01 01:00:00'); +unix_timestamp('1970-01-01 01:00:00') unix_timestamp('1970-01-01 01:00:01') unix_timestamp('2038-01-01 00:59:59') unix_timestamp('2038-01-01 01:00:00') +0 1 2145916799 0 diff --git a/mysql-test/t/timezone.test b/mysql-test/t/timezone.test index ab732c11a34..ba65eb72fe6 100644 --- a/mysql-test/t/timezone.test +++ b/mysql-test/t/timezone.test @@ -38,3 +38,10 @@ INSERT INTO t1 (ts) VALUES (Unix_timestamp('2003-03-30 04:00:01')); SELECT ts,from_unixtime(ts) FROM t1; DROP TABLE t1; +# +# Test for fix for Bug#2523 +# +select unix_timestamp('1970-01-01 01:00:00'), + unix_timestamp('1970-01-01 01:00:01'), + unix_timestamp('2038-01-01 00:59:59'), + unix_timestamp('2038-01-01 01:00:00'); diff --git a/sql/field.cc b/sql/field.cc index 687c22bb69b..ac3ebb4bfc7 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -2583,22 +2583,18 @@ static longlong fix_datetime(longlong nr, TIME *time_res) void Field_timestamp::store(longlong nr) { TIME l_time; - time_t timestamp; + time_t timestamp= 0; if ((nr= fix_datetime(nr, &l_time))) { long not_used; - if (l_time.year >= TIMESTAMP_MAX_YEAR || l_time.year < 1900+YY_PART_YEAR-1) - { + timestamp= my_gmt_sec(&l_time, ¬_used); + + if (!timestamp) current_thd->cuted_fields++; - timestamp=0; - } - else - timestamp=my_gmt_sec(&l_time, ¬_used); } - else - timestamp=0; + #ifdef WORDS_BIGENDIAN if (table->db_low_byte_first) { diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index acb7005c26c..46f7ece8641 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -116,6 +116,9 @@ char* query_table_status(THD *thd,const char *db,const char *table_name); /* Time handling defaults */ #define TIMESTAMP_MAX_YEAR 2038 #define YY_PART_YEAR 70 +#define TIMESTAMP_MIN_YEAR (1900 + YY_PART_YEAR - 1) +#define TIMESTAMP_MAX_VALUE 2145916799 +#define TIMESTAMP_MIN_VALUE 1 #define PRECISION_FOR_DOUBLE 53 #define PRECISION_FOR_FLOAT 24 diff --git a/sql/time.cc b/sql/time.cc index 5dc229b1d88..0363d764100 100644 --- a/sql/time.cc +++ b/sql/time.cc @@ -63,6 +63,9 @@ long my_gmt_sec(TIME *t, long *my_timezone) struct tm *l_time,tm_tmp; long diff, current_timezone; + if (t->year > TIMESTAMP_MAX_YEAR || t->year < TIMESTAMP_MIN_YEAR) + return 0; + if (t->hour >= 24) { /* Fix for time-loop */ t->day+=t->hour/24; @@ -125,8 +128,10 @@ long my_gmt_sec(TIME *t, long *my_timezone) tmp-=t->minute*60 + t->second; // Move to previous hour } *my_timezone= current_timezone; - if (tmp < 0 && t->year <= 1900+YY_PART_YEAR) + + if (tmp < TIMESTAMP_MIN_VALUE || tmp > TIMESTAMP_MAX_VALUE) tmp= 0; + return (long) tmp; } /* my_gmt_sec */ @@ -444,15 +449,13 @@ time_t str_to_timestamp(const char *str,uint length) { TIME l_time; long not_used; + time_t timestamp= 0; - if (str_to_TIME(str,length,&l_time,0) == TIMESTAMP_NONE) - return(0); - if (l_time.year >= TIMESTAMP_MAX_YEAR || l_time.year < 1900+YY_PART_YEAR-1) - { + if (str_to_TIME(str,length,&l_time,0) != TIMESTAMP_NONE && + !(timestamp= my_gmt_sec(&l_time, ¬_used))) current_thd->cuted_fields++; - return(0); - } - return(my_gmt_sec(&l_time, ¬_used)); + + return timestamp; } From 7eefcb75db0707dbc8044808390f047b60484454 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 1 Feb 2004 19:20:16 +0200 Subject: [PATCH 058/113] dict0dict.c: Cleanup innobase/dict/dict0dict.c: Cleanup --- innobase/dict/dict0dict.c | 115 ++++++++++++++++++++++---------------- 1 file changed, 67 insertions(+), 48 deletions(-) diff --git a/innobase/dict/dict0dict.c b/innobase/dict/dict0dict.c index dc7acfcba36..b7740321831 100644 --- a/innobase/dict/dict0dict.c +++ b/innobase/dict/dict0dict.c @@ -2139,36 +2139,39 @@ dict_scan_col( } if (*ptr == '`' || *ptr == '"') { - /* - The identifier is quoted. Search for end quote. - We can't use the general code here as the name may contain - special characters like space. - */ - char quote= *ptr++; + /* The identifier is quoted. Search for the end quote. We + cannot use the general code here as the name may contain + special characters like the space. */ - old_ptr= ptr; - /* - The colum name should always end with 'quote' but we check for - end zero just to be safe if this is called outside of MySQL - */ - while (*ptr && *ptr != quote) - ptr++; - *column_name_len = (ulint)(ptr - old_ptr); + char quote = *ptr; - if (*ptr) /* Skip end quote */ - ptr++; - } - else - { - old_ptr = ptr; + ptr++; /* Skip the quote */ + + old_ptr = ptr; + + /* The column name should always end with 'quote' but we check + for an end zero just to be safe if this is called outside of + MySQL. */ + + while (*ptr && *ptr != quote) { + ptr++; + } + *column_name_len = (ulint)(ptr - old_ptr); + + if (*ptr) { /* Skip end quote */ + ptr++; + } else { + return(ptr); /* Syntax error */ + } + } else { + old_ptr = ptr; - while (!isspace(*ptr) && *ptr != ',' && *ptr != ')' - && *ptr != '\0') { - ptr++; - } - *column_name_len = (ulint)(ptr - old_ptr); + while (!isspace(*ptr) && *ptr != ',' && *ptr != ')' + && *ptr != '\0') { + ptr++; + } + *column_name_len = (ulint)(ptr - old_ptr); } - if (table == NULL) { *success = TRUE; @@ -2181,7 +2184,7 @@ dict_scan_col( if (ut_strlen(col->name) == *column_name_len && 0 == ut_cmp_in_lower_case(col->name, old_ptr, - *column_name_len)) { + *column_name_len)) { /* Found */ *success = TRUE; @@ -2211,10 +2214,10 @@ dict_scan_table_name( the referenced table name; must be at least 2500 bytes */ { - char* dot_ptr = NULL; + char* dot_ptr = NULL; char* old_ptr; + char quote = '\0'; ulint i; - char quote = 0; *success = FALSE; *table = NULL; @@ -2229,22 +2232,33 @@ dict_scan_table_name( } if (*ptr == '`' || *ptr == '"') { - quote= *ptr++; - } - - old_ptr = ptr; - - while (*ptr != quote && - (quote || (!isspace(*ptr) && *ptr != '(')) && - *ptr != '\0') { - if (!quote && *ptr == '.') { - dot_ptr = ptr; - } - + quote = *ptr; ptr++; } + old_ptr = ptr; + + if (quote) { + while (*ptr != quote && *ptr != '\0') { + ptr++; + } + + if (*ptr == '\0') { + + return(old_ptr); /* Syntax error */ + } + } else { + while (!isspace(*ptr) && *ptr != '(' && *ptr != '\0') { + + if (*ptr == '.') { + dot_ptr = ptr; + } + ptr++; + } + } + if (ptr - old_ptr > 2000) { + return(old_ptr); } @@ -2290,7 +2304,7 @@ dict_scan_table_name( *table = dict_table_get_low(second_table_name); - if (*ptr && *ptr == quote) { + if (quote && *ptr == quote) { ptr++; } @@ -2310,7 +2324,7 @@ dict_scan_id( scannable */ ulint* len) /* out: length of the id */ { - char quote = 0; + char quote = '\0'; *start = NULL; @@ -2329,11 +2343,16 @@ dict_scan_id( *start = ptr; - while (*ptr != quote && - (!quote || (!isspace(*ptr) && *ptr != ',' && *ptr != '(' && - *ptr != ')')) - && *ptr != '\0') { - ptr++; + if (quote) { + while (*ptr != quote && *ptr != '\0') { + ptr++; + } + } else { + while (!isspace(*ptr) && *ptr != '(' && *ptr != ')' + && *ptr != ',' && *ptr != '\0') { + + ptr++; + } } *len = (ulint) (ptr - *start); From 08177508f5db7c003ebbe1fe16e17dd02fff49b0 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 2 Feb 2004 00:10:45 +0200 Subject: [PATCH 059/113] dict0dict.c: Remove redundant code; parse both the database name and the table name in a FOREIGN KEY constraint with quotes in mind row0mysql.c, ha_innodb.cc, sql_table.cc: Return error message Cannot delete or update a parent row... if we try to drop a table which is referenced by a FOREIGN KEY constraint, and the user has not set foreign_key_checks=0 sql/sql_table.cc: Return error message Cannot delete or update a parent row... if we try to drop a table which is referenced by a FOREIGN KEY constraint, and the user has not set foreign_key_checks=0 sql/ha_innodb.cc: Return error message Cannot delete or update a parent row... if we try to drop a table which is referenced by a FOREIGN KEY constraint, and the user has not set foreign_key_checks=0 innobase/row/row0mysql.c: Return error message Cannot delete or update a parent row... if we try to drop a table which is referenced by a FOREIGN KEY constraint, and the user has not set foreign_key_checks=0 innobase/dict/dict0dict.c: Remove redundant code; parse both the database name and the table name in a FOREIGN KEY constraint with quotes in mind --- innobase/dict/dict0dict.c | 308 +++++++++++++++++--------------------- innobase/row/row0mysql.c | 26 ++++ sql/ha_innodb.cc | 11 +- sql/sql_table.cc | 10 +- 4 files changed, 178 insertions(+), 177 deletions(-) diff --git a/innobase/dict/dict0dict.c b/innobase/dict/dict0dict.c index b7740321831..d132d082e6a 100644 --- a/innobase/dict/dict0dict.c +++ b/innobase/dict/dict0dict.c @@ -2108,6 +2108,68 @@ dict_accept( return(ptr + ut_strlen(string)); } +/************************************************************************* +Scans an id. For the lexical definition of an 'id', see the code below. +Strips backquotes or double quotes from around the id. */ +static +char* +dict_scan_id( +/*=========*/ + /* out: scanned to */ + char* ptr, /* in: scanned to */ + char** start, /* out: start of the id; NULL if no id was + scannable */ + ulint* len, /* out: length of the id */ + ibool accept_also_dot)/* in: TRUE if also a dot can appear in a + non-quoted id; in a quoted id it can appear + always */ +{ + char quote = '\0'; + + *start = NULL; + + while (isspace(*ptr)) { + ptr++; + } + + if (*ptr == '\0') { + + return(ptr); + } + + if (*ptr == '`' || *ptr == '"') { + quote = *ptr++; + } + + *start = ptr; + + if (quote) { + while (*ptr != quote && *ptr != '\0') { + ptr++; + } + } else { + while (!isspace(*ptr) && *ptr != '(' && *ptr != ')' + && (accept_also_dot || *ptr != '.') + && *ptr != ',' && *ptr != '\0') { + + ptr++; + } + } + + *len = (ulint) (ptr - *start); + + if (quote) { + if (*ptr == quote) { + ptr++; + } else { + /* Syntax error */ + *start = NULL; + } + } + + return(ptr); +} + /************************************************************************* Tries to scan a column name. */ static @@ -2124,66 +2186,28 @@ dict_scan_col( ulint* column_name_len)/* out: column name length */ { dict_col_t* col; - char* old_ptr; ulint i; *success = FALSE; - while (isspace(*ptr)) { - ptr++; + ptr = dict_scan_id(ptr, column_name, column_name_len, TRUE); + + if (column_name == NULL) { + + return(ptr); /* Syntax error */ } - if (*ptr == '\0') { - - return(ptr); - } - - if (*ptr == '`' || *ptr == '"') { - /* The identifier is quoted. Search for the end quote. We - cannot use the general code here as the name may contain - special characters like the space. */ - - char quote = *ptr; - - ptr++; /* Skip the quote */ - - old_ptr = ptr; - - /* The column name should always end with 'quote' but we check - for an end zero just to be safe if this is called outside of - MySQL. */ - - while (*ptr && *ptr != quote) { - ptr++; - } - *column_name_len = (ulint)(ptr - old_ptr); - - if (*ptr) { /* Skip end quote */ - ptr++; - } else { - return(ptr); /* Syntax error */ - } - } else { - old_ptr = ptr; - - while (!isspace(*ptr) && *ptr != ',' && *ptr != ')' - && *ptr != '\0') { - ptr++; - } - *column_name_len = (ulint)(ptr - old_ptr); - } - if (table == NULL) { *success = TRUE; *column = NULL; - *column_name = old_ptr; } else { for (i = 0; i < dict_table_get_n_cols(table); i++) { col = dict_table_get_nth_col(table, i); if (ut_strlen(col->name) == *column_name_len - && 0 == ut_cmp_in_lower_case(col->name, old_ptr, + && 0 == ut_cmp_in_lower_case(col->name, + *column_name, *column_name_len)) { /* Found */ @@ -2214,163 +2238,99 @@ dict_scan_table_name( the referenced table name; must be at least 2500 bytes */ { - char* dot_ptr = NULL; - char* old_ptr; - char quote = '\0'; + char* database_name = NULL; + ulint database_name_len = 999999999; /* init to a dummy value to + suppress a compiler warning */ + char* table_name = NULL; + ulint table_name_len; + char* scanned_id; + ulint scanned_id_len; ulint i; *success = FALSE; *table = NULL; + + ptr = dict_scan_id(ptr, &scanned_id, &scanned_id_len, FALSE); + + if (scanned_id == NULL) { + + return(ptr); /* Syntax error */ + } + + if (*ptr == '.') { + /* We scanned the database name; scan also the table name */ - while (isspace(*ptr)) { ptr++; - } - if (*ptr == '\0') { + database_name = scanned_id; + database_name_len = scanned_id_len; - return(ptr); - } + ptr = dict_scan_id(ptr, &table_name, &table_name_len, FALSE); - if (*ptr == '`' || *ptr == '"') { - quote = *ptr; - ptr++; - } + if (table_name == NULL) { - old_ptr = ptr; - - if (quote) { - while (*ptr != quote && *ptr != '\0') { - ptr++; - } - - if (*ptr == '\0') { - - return(old_ptr); /* Syntax error */ + return(ptr); /* Syntax error */ } } else { - while (!isspace(*ptr) && *ptr != '(' && *ptr != '\0') { - - if (*ptr == '.') { - dot_ptr = ptr; - } - ptr++; - } + table_name = scanned_id; + table_name_len = scanned_id_len; } - if (ptr - old_ptr > 2000) { + if (database_name == NULL) { + /* Use the database name of the foreign key table */ - return(old_ptr); + database_name = name; + + i = 0; + while (name[i] != '/') { + i++; + } + + database_name_len = i; + } + + if (table_name_len + database_name_len > 2000) { + + return(ptr); /* Too long name */ } - if (dot_ptr == NULL) { - /* Copy the database name from 'name' to the start */ - for (i = 0;; i++) { - second_table_name[i] = name[i]; - if (name[i] == '/') { - i++; - break; - } - } #ifdef __WIN__ - ut_cpy_in_lower_case(second_table_name + i, old_ptr, - ptr - old_ptr); + ut_cpy_in_lower_case(second_table_name, database_name, + database_name_len); #else - if (srv_lower_case_table_names) { - ut_cpy_in_lower_case(second_table_name + i, old_ptr, - ptr - old_ptr); - } else { - ut_memcpy(second_table_name + i, old_ptr, - ptr - old_ptr); - } -#endif - second_table_name[i + (ptr - old_ptr)] = '\0'; + if (srv_lower_case_table_names) { + ut_cpy_in_lower_case(second_table_name, database_name, + database_name_len); } else { -#ifdef __WIN__ - ut_cpy_in_lower_case(second_table_name, old_ptr, - ptr - old_ptr); -#else - if (srv_lower_case_table_names) { - ut_cpy_in_lower_case(second_table_name, old_ptr, - ptr - old_ptr); - } else { - ut_memcpy(second_table_name, old_ptr, ptr - old_ptr); - } -#endif - second_table_name[dot_ptr - old_ptr] = '/'; - second_table_name[ptr - old_ptr] = '\0'; + ut_memcpy(second_table_name, database_name, + database_name_len); } +#endif + second_table_name[database_name_len] = '/'; + +#ifdef __WIN__ + ut_cpy_in_lower_case(second_table_name + database_name_len + 1, + table_name, table_name_len); +#else + if (srv_lower_case_table_names) { + ut_cpy_in_lower_case(second_table_name + database_name_len + 1, + table_name, table_name_len); + } else { + ut_memcpy(second_table_name + database_name_len + 1, + table_name, table_name_len); + } +#endif + second_table_name[database_name_len + 1 + table_name_len] = '\0'; *success = TRUE; *table = dict_table_get_low(second_table_name); - if (quote && *ptr == quote) { - ptr++; - } - return(ptr); } /************************************************************************* -Scans an id. For the lexical definition of an 'id', see the code below. -Strips backquotes from around the id. */ -static -char* -dict_scan_id( -/*=========*/ - /* out: scanned to */ - char* ptr, /* in: scanned to */ - char** start, /* out: start of the id; NULL if no id was - scannable */ - ulint* len) /* out: length of the id */ -{ - char quote = '\0'; - - *start = NULL; - - while (isspace(*ptr)) { - ptr++; - } - - if (*ptr == '\0') { - - return(ptr); - } - - if (*ptr == '`' || *ptr == '"') { - quote = *ptr++; - } - - *start = ptr; - - if (quote) { - while (*ptr != quote && *ptr != '\0') { - ptr++; - } - } else { - while (!isspace(*ptr) && *ptr != '(' && *ptr != ')' - && *ptr != ',' && *ptr != '\0') { - - ptr++; - } - } - - *len = (ulint) (ptr - *start); - - if (quote) { - if (*ptr == quote) { - ptr++; - } else { - /* Syntax error */ - *start = NULL; - } - } - - return(ptr); -} - -/************************************************************************* -Skips one id. */ +Skips one id. The id is allowed to contain also '.'. */ static char* dict_skip_word( @@ -2385,7 +2345,7 @@ dict_skip_word( *success = FALSE; - ptr = dict_scan_id(ptr, &start, &len); + ptr = dict_scan_id(ptr, &start, &len, TRUE); if (start) { *success = TRUE; @@ -3083,7 +3043,7 @@ loop: goto syntax_error; } - ptr = dict_scan_id(ptr, &start, &len); + ptr = dict_scan_id(ptr, &start, &len, TRUE); if (start == NULL) { diff --git a/innobase/row/row0mysql.c b/innobase/row/row0mysql.c index 468404268f4..257756ff8aa 100644 --- a/innobase/row/row0mysql.c +++ b/innobase/row/row0mysql.c @@ -1804,6 +1804,7 @@ row_drop_table_for_mysql( char* name, /* in: table name */ trx_t* trx) /* in: transaction handle */ { + dict_foreign_t* foreign; dict_table_t* table; que_thr_t* thr; que_t* graph; @@ -1996,6 +1997,31 @@ row_drop_table_for_mysql( goto funct_exit; } + foreign = UT_LIST_GET_FIRST(table->referenced_list); + + if (foreign && trx->check_foreigns) { + char* buf = dict_foreign_err_buf; + + /* We only allow dropping a referenced table if + FOREIGN_KEY_CHECKS is set to 0 */ + + err = DB_CANNOT_DROP_CONSTRAINT; + + mutex_enter(&dict_foreign_err_mutex); + ut_sprintf_timestamp(buf); + + sprintf(buf + strlen(buf), + " Cannot drop table %.500s\n", name); + sprintf(buf + strlen(buf), +"because it is referenced by %.500s\n", foreign->foreign_table_name); + + ut_a(strlen(buf) < DICT_FOREIGN_ERR_BUF_LEN); + + mutex_exit(&dict_foreign_err_mutex); + + goto funct_exit; + } + if (table->n_mysql_handles_opened > 0) { ut_print_timestamp(stderr); diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index bcd1130dcdb..68052014f57 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -276,7 +276,7 @@ convert_error_code_to_mysql( } else if (error == (int) DB_CANNOT_DROP_CONSTRAINT) { - return(HA_WRONG_CREATE_OPTION); + return(HA_ERR_ROW_IS_REFERENCED); } else if (error == (int) DB_COL_APPEARS_TWICE_IN_INDEX) { @@ -3572,6 +3572,7 @@ ha_innobase::delete_table( int error; trx_t* parent_trx; trx_t* trx; + THD *thd= current_thd; char norm_name[1000]; DBUG_ENTER("ha_innobase::delete_table"); @@ -3597,6 +3598,14 @@ ha_innobase::delete_table( trx->mysql_thd = current_thd; trx->mysql_query_str = &((*current_thd).query); + if (thd->options & OPTION_NO_FOREIGN_KEY_CHECKS) { + trx->check_foreigns = FALSE; + } + + if (thd->options & OPTION_RELAXED_UNIQUE_CHECKS) { + trx->check_unique_secondary = FALSE; + } + name_len = strlen(name); assert(name_len < 1000); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 7fa973eb60f..774801c094a 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -167,7 +167,7 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, String wrong_tables; db_type table_type; int error; - bool some_tables_deleted=0, tmp_table_deleted=0; + bool some_tables_deleted=0, tmp_table_deleted=0, foreign_key_error=0; DBUG_ENTER("mysql_rm_table_part2"); if (lock_table_names(thd, tables)) @@ -212,6 +212,9 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, error=ha_delete_table(table_type, path); if (error == ENOENT && if_exists) error = 0; + if (error == HA_ERR_ROW_IS_REFERENCED) + foreign_key_error=1; /* the table is referenced by a foreign key + constraint */ if (!error || error == ENOENT) { /* Delete the table definition file */ @@ -247,7 +250,10 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, error= 0; if (wrong_tables.length()) { - my_error(ER_BAD_TABLE_ERROR,MYF(0),wrong_tables.c_ptr()); + if (!foreign_key_error) + my_error(ER_BAD_TABLE_ERROR,MYF(0),wrong_tables.c_ptr()); + else + my_error(ER_ROW_IS_REFERENCED,MYF(0)); error= 1; } DBUG_RETURN(error); From 2cac1f4d33a0ae56e35a77011a851b38f4b2e24d Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 2 Feb 2004 01:03:05 +0200 Subject: [PATCH 060/113] dict0dict.c: Change print format of FOREIGN KEY constraints spanning multiple databases to: .; but we when parsing them we must also accept , because that was the output format in < 4.0.18 innobase/dict/dict0dict.c: Change print format of FOREIGN KEY constraints spanning multiple databases to: .; but we when parsing them we must also accept , because that was the output format in < 4.0.18 --- innobase/dict/dict0dict.c | 50 +++++++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/innobase/dict/dict0dict.c b/innobase/dict/dict0dict.c index d132d082e6a..5e4821d7690 100644 --- a/innobase/dict/dict0dict.c +++ b/innobase/dict/dict0dict.c @@ -2272,6 +2272,24 @@ dict_scan_table_name( return(ptr); /* Syntax error */ } } else { + /* To be able to read table dumps made with InnoDB-4.0.17 or + earlier, we must allow the dot separator between the database + name and the table name also to appear within a quoted + identifier! InnoDB used to print a constraint as: + ... REFERENCES `databasename.tablename` ... + starting from 4.0.18 it is + ... REFERENCES `databasename`.`tablename` ... */ + + for (i = 0; i < scanned_id_len; i++) { + if (scanned_id[i] == '.') { + database_name = scanned_id; + database_name_len = i; + + scanned_id = scanned_id + i + 1; + scanned_id_len -= i + 1; + } + } + table_name = scanned_id; table_name_len = scanned_id_len; } @@ -3878,6 +3896,7 @@ dict_print_info_on_foreign_key_in_create_format( char* buf) /* in: buffer of at least 5000 bytes */ { char* buf2 = buf; + ulint cpy_len; ulint i; buf2 += sprintf(buf2, ",\n CONSTRAINT `%s` FOREIGN KEY (", @@ -3897,24 +3916,31 @@ dict_print_info_on_foreign_key_in_create_format( if (dict_tables_have_same_db(foreign->foreign_table_name, foreign->referenced_table_name)) { - /* Do not print the database name of the referenced - table */ + /* Do not print the database name of the referenced table */ buf2 += sprintf(buf2, ") REFERENCES `%.500s` (", dict_remove_db_name( foreign->referenced_table_name)); } else { - buf2 += sprintf(buf2, ") REFERENCES `%.500s` (", - foreign->referenced_table_name); - /* Change the '/' in the table name to '.' */ + buf2 += sprintf(buf2, ") REFERENCES `"); + + /* Look for the '/' in the table name */ - for (i = ut_strlen(buf); i > 0; i--) { - if (buf[i] == '/') { - - buf[i] = '.'; - - break; - } + i = 0; + while (foreign->referenced_table_name[i] != '/') { + i++; } + + cpy_len = i; + + if (cpy_len > 500) { + cpy_len = 500; + } + + memcpy(buf2, foreign->referenced_table_name, cpy_len); + buf2 += cpy_len; + + buf2 += sprintf(buf2, "`.`%.500s` (", + foreign->referenced_table_name + i + 1); } for (i = 0; i < foreign->n_fields; i++) { From 1b8d5ca887918ee77f4ccc7a73df115c00885a40 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 2 Feb 2004 01:05:53 +0200 Subject: [PATCH 061/113] dict0dict.c: Change print format of FOREIGN KEY constraints spanning multiple databases to databasename.tablename; but when parsing them we must also accept databasename.tablename, because that was the output format in < 4.0.18 innobase/dict/dict0dict.c: Change print format of FOREIGN KEY constraints spanning multiple databases to databasename.tablename; but when parsing them we must also accept databasename.tablename, because that was the output format in < 4.0.18 --- innobase/dict/dict0dict.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/innobase/dict/dict0dict.c b/innobase/dict/dict0dict.c index 5e4821d7690..87505656d5a 100644 --- a/innobase/dict/dict0dict.c +++ b/innobase/dict/dict0dict.c @@ -52,7 +52,7 @@ rw_lock_t dict_operation_lock; /* table create, drop, etc. reserve hash table fixed size in bytes */ #define DICT_POOL_PER_VARYING 4 /* buffer pool max size per data dictionary varying size in bytes */ - + /************************************************************************** Adds a column to the data dictionary hash table. */ static From 2b9e17449932eed3458e098b23d8686538e21fa3 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 2 Feb 2004 01:30:59 +0200 Subject: [PATCH 062/113] innodb.result, innodb.test: Change tests so that tables are dropped in an order respecting the FOREIGN KEY constraints mysql-test/t/innodb.test: Change tests so that tables are dropped in an order respecting the FOREIGN KEY constraints mysql-test/r/innodb.result: Change tests so that tables are dropped in an order respecting the FOREIGN KEY constraints --- mysql-test/r/innodb.result | 4 ++-- mysql-test/t/innodb.test | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result index ca4a49fea4e..416c583a8d7 100644 --- a/mysql-test/r/innodb.result +++ b/mysql-test/r/innodb.result @@ -1004,7 +1004,7 @@ select * from t1; id select * from t2; id t1_id -drop table t1,t2; +drop table t2,t1; DROP TABLE IF EXISTS t1,t2; CREATE TABLE t1(id INT NOT NULL, PRIMARY KEY (id)) TYPE=INNODB; CREATE TABLE t2(id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id) ) TYPE=INNODB; @@ -1245,4 +1245,4 @@ a drop table t1; CREATE TABLE t1 (`id 1` INT NOT NULL, PRIMARY KEY (`id 1`)) TYPE=INNODB; CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id), FOREIGN KEY (`t1_id`) REFERENCES `t1`(`id 1`) ON DELETE CASCADE ) TYPE=INNODB; -drop table t1,t2; +drop table t2,t1; diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test index 51fadccdc1c..ec9aa83ae16 100644 --- a/mysql-test/t/innodb.test +++ b/mysql-test/t/innodb.test @@ -692,7 +692,7 @@ insert into t2 set id=1, t1_id=1; delete t1,t2 from t1,t2 where t1.id=t2.t1_id; select * from t1; select * from t2; -drop table t1,t2; +drop table t2,t1; DROP TABLE IF EXISTS t1,t2; CREATE TABLE t1(id INT NOT NULL, PRIMARY KEY (id)) TYPE=INNODB; CREATE TABLE t2(id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id) ) TYPE=INNODB; @@ -877,4 +877,4 @@ drop table t1; CREATE TABLE t1 (`id 1` INT NOT NULL, PRIMARY KEY (`id 1`)) TYPE=INNODB; CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id), FOREIGN KEY (`t1_id`) REFERENCES `t1`(`id 1`) ON DELETE CASCADE ) TYPE=INNODB; #show create table t2; -drop table t1,t2; +drop table t2,t1; From 0ba7ef007eb04fbe8e508878d02fb4a987f05250 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 2 Feb 2004 01:41:35 +0200 Subject: [PATCH 063/113] rpl_insert_id.test, rpl_insert_id.result: Change tests so that tables are dropped in an order respecting the FOREIGN KEY constraints mysql-test/r/rpl_insert_id.result: Change tests so that tables are dropped in an order respecting the FOREIGN KEY constraints mysql-test/t/rpl_insert_id.test: Change tests so that tables are dropped in an order respecting the FOREIGN KEY constraints --- mysql-test/r/rpl_insert_id.result | 2 +- mysql-test/t/rpl_insert_id.test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/rpl_insert_id.result b/mysql-test/r/rpl_insert_id.result index 889e7891770..d2dfbb05675 100644 --- a/mysql-test/r/rpl_insert_id.result +++ b/mysql-test/r/rpl_insert_id.result @@ -39,8 +39,8 @@ select * from t2; b c 5 0 6 11 -drop table t1; drop table t2; +drop table t1; create table t1(a int auto_increment, key(a)); create table t2(b int auto_increment, c int, key(b)); insert into t1 values (10); diff --git a/mysql-test/t/rpl_insert_id.test b/mysql-test/t/rpl_insert_id.test index 49fefae72b8..a6da44de456 100644 --- a/mysql-test/t/rpl_insert_id.test +++ b/mysql-test/t/rpl_insert_id.test @@ -42,8 +42,8 @@ connection master; # check if INSERT SELECT in auto_increment is well replicated (bug #490) -drop table t1; drop table t2; +drop table t1; create table t1(a int auto_increment, key(a)); create table t2(b int auto_increment, c int, key(b)); insert into t1 values (10); From 5a5eae1d218a2f9f35f5f3b48ec59f5b5a2698d9 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 2 Feb 2004 12:09:47 +0200 Subject: [PATCH 064/113] Typo fixing s/expection/exception BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted --- BitKeeper/etc/logging_ok | 1 + sql/mysqld.cc | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 5cf95b9fc2a..dae3ea521c3 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -98,6 +98,7 @@ ranger@regul.home.lan root@x3.internalnet salle@geopard.(none) salle@geopard.online.bg +salle@vafla.home salle@vafla.online.bg sasha@mysql.sashanet.com serg@build.mysql2.com diff --git a/sql/mysqld.cc b/sql/mysqld.cc index b2b53e571c3..14db51cf6fd 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -140,7 +140,7 @@ int initgroups(const char *,unsigned int); typedef fp_except fp_except_t; #endif - /* We can't handle floating point expections with threads, so disable + /* We can't handle floating point exceptions with threads, so disable this on freebsd */ @@ -4044,7 +4044,7 @@ this value; if zero (the default): when the size exceeds max_binlog_size. \ (gptr*) &max_system_variables.range_alloc_block_size, 0, GET_ULONG, REQUIRED_ARG, RANGE_ALLOC_BLOCK_SIZE, 1024, ~0L, 0, 1024, 0}, {"read-only", OPT_READONLY, - "Make all tables readonly, with the expections for replications (slave) threads and users with the SUPER privilege", + "Make all tables readonly, with the exception for replication (slave) threads and users with the SUPER privilege", (gptr*) &opt_readonly, (gptr*) &opt_readonly, 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0}, From b3fd7528c5fb39bf567d2af8bc52a5f69022cbf5 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 2 Feb 2004 15:25:20 +0400 Subject: [PATCH 065/113] a fix (#2185: mysql.server script echo bug) thnx Paul. can you get the above into configure and make Makefile.am patch mysql.server.sh with the right values for mysql.server ? or do you think we should just put the above in mysql.server.sh directly as you want the last is kind of hard to do with variables, so lets put the above in mysql.server.sh directly support-files/mysql.server.sh: #2185: mysql.server script echo bug --- support-files/mysql.server.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/support-files/mysql.server.sh b/support-files/mysql.server.sh index d55068db64e..f57e834d045 100644 --- a/support-files/mysql.server.sh +++ b/support-files/mysql.server.sh @@ -59,6 +59,14 @@ export PATH mode=$1 # start or stop +case `echo "testing\c"`,`echo -n testing` in + *c,*) echo_n=-n echo_c= ;; + *,-n*) echo_n= echo_c='\c' ;; + *) echo_n= echo_c=' +' +;; +esac + parse_arguments() { for arg do case "$arg" in @@ -169,7 +177,7 @@ case "$mode" in sleep 1 while [ -s $pid_file -a "$flags" != aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ] do - [ -z "$flags" ] && echo "Wait for mysqld to exit\c" || echo ".\c" + [ -z "$flags" ] && echo $echo_n "Wait for mysqld to exit$echo_c" || echo $echo_n ".echo_c" flags=a$flags sleep 1 done From 883f11b68c402b106dbff2542435782a8af3b55d Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 2 Feb 2004 15:57:57 +0100 Subject: [PATCH 066/113] test added --- mysql-test/r/bigint.result | 3 +++ mysql-test/t/bigint.test | 2 ++ 2 files changed, 5 insertions(+) diff --git a/mysql-test/r/bigint.result b/mysql-test/r/bigint.result index 308adc881f2..f96da579bce 100644 --- a/mysql-test/r/bigint.result +++ b/mysql-test/r/bigint.result @@ -81,3 +81,6 @@ quantity 10000000000000000000 10000000000000000000 drop table t1; +SELECT '0x8000000000000001'+0; +'0x8000000000000001'+0 +0 diff --git a/mysql-test/t/bigint.test b/mysql-test/t/bigint.test index f21f821e45c..0092317dc5e 100644 --- a/mysql-test/t/bigint.test +++ b/mysql-test/t/bigint.test @@ -60,3 +60,5 @@ insert into t1 values ('10000000000000000000'); select * from t1; drop table t1; +SELECT '0x8000000000000001'+0; + From af6141b2f85c72bd1920ba5e6cd7cca1756320c4 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 2 Feb 2004 19:32:05 +0100 Subject: [PATCH 067/113] increase the size of a signal thread's stack (the old one was too small for the thread to be created on some systems) bug#2599 --- sql/mysqld.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 14db51cf6fd..2ab2e33ce2f 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1689,7 +1689,7 @@ static void start_signal_handler(void) (void) pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED); if (!(opt_specialflag & SPECIAL_NO_PRIOR)) my_pthread_attr_setprio(&thr_attr,INTERRUPT_PRIOR); - pthread_attr_setstacksize(&thr_attr,32768); + pthread_attr_setstacksize(&thr_attr,thread_stack); #endif (void) pthread_mutex_lock(&LOCK_thread_count); From e0b0ec6b2c98f05547018655b6030a8d62bc511f Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 2 Feb 2004 23:01:58 +0300 Subject: [PATCH 068/113] Proposed (version #2) fix for bug #1948: "system variable query_prealloc_size can be only global" include/my_sys.h: Fix for bug #1948: - added reset_root_defaults function declaration mysys/my_alloc.c: Fix for bug #1948: - implementation and description of reset_root_defaults sql/set_var.cc: Fix for bug #1948: - fix_thd_mem_root and fix_trans_mem_root after update triggers implemented for variables query_prealloc_size, query_alloc_block_size, trans_prealloc_size, trans_alloc_block_size --- include/my_sys.h | 2 ++ mysys/my_alloc.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++ sql/set_var.cc | 32 ++++++++++++++++++++--- 3 files changed, 96 insertions(+), 4 deletions(-) diff --git a/include/my_sys.h b/include/my_sys.h index e1656cfc626..75e22629a19 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -740,6 +740,8 @@ extern void init_alloc_root(MEM_ROOT *mem_root, uint block_size, extern gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size); extern void free_root(MEM_ROOT *root, myf MyFLAGS); extern void set_prealloc_root(MEM_ROOT *root, char *ptr); +extern void reset_root_defaults(MEM_ROOT *mem_root, uint block_size, + uint prealloc_size); extern char *strdup_root(MEM_ROOT *root,const char *str); extern char *strmake_root(MEM_ROOT *root,const char *str,uint len); extern char *memdup_root(MEM_ROOT *root,const char *str,uint len); diff --git a/mysys/my_alloc.c b/mysys/my_alloc.c index 4d3b0604984..d03ec5841af 100644 --- a/mysys/my_alloc.c +++ b/mysys/my_alloc.c @@ -47,6 +47,72 @@ void init_alloc_root(MEM_ROOT *mem_root, uint block_size, #endif } +/* + SYNOPSIS + reset_root_defaults() + mem_root memory root to change defaults of + block_size new value of block size. Must be + greater than ~68 bytes (the exact value depends on + platform and compilation flags) + pre_alloc_size new size of preallocated block. If not zero, + must be equal to or greater than block size, + otherwise means 'no prealloc'. + DESCRIPTION + Function aligns and assigns new value to block size; then it tries to + reuse one of existing blocks as prealloc block, or malloc new one of + requested size. If no blocks can be reused, all unused blocks are freed + before allocation. + */ + +void reset_root_defaults(MEM_ROOT *mem_root, uint block_size, + uint pre_alloc_size) +{ + mem_root->block_size= block_size-MALLOC_OVERHEAD-sizeof(USED_MEM)-8; +#if !(defined(HAVE_purify) && defined(EXTRA_DEBUG)) + if (pre_alloc_size) + { + uint size= pre_alloc_size + ALIGN_SIZE(sizeof(USED_MEM)); + if (!mem_root->pre_alloc || mem_root->pre_alloc->size != size) + { + USED_MEM *mem, **prev= &mem_root->free; + /* + Free unused blocks, so that consequent calls + to reset_root_defaults won't eat away memory. + */ + while (*prev) + { + mem= *prev; + if (mem->size == size) + { + /* We found a suitable block, no need to do anything else */ + mem_root->pre_alloc= mem; + return; + } + if (mem->left + ALIGN_SIZE(sizeof(USED_MEM)) == mem->size) + { + /* remove block from the list and free it */ + *prev= mem->next; + my_free((gptr) mem, MYF(0)); + } + else + prev= &mem->next; + } + /* Allocate new prealloc block and add it to the end of free list */ + if ((mem= (USED_MEM *) my_malloc(size, MYF(0)))) + { + mem->size= size; + mem->left= pre_alloc_size; + mem->next= *prev; + *prev= mem_root->pre_alloc= mem; + } + } + } + else +#endif + mem_root->pre_alloc= 0; +} + + gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size) { #if defined(HAVE_purify) && defined(EXTRA_DEBUG) diff --git a/sql/set_var.cc b/sql/set_var.cc index 693d8e4c958..475beb798e6 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -88,6 +88,8 @@ static void fix_myisam_max_sort_file_size(THD *thd, enum_var_type type); static void fix_max_binlog_size(THD *thd, enum_var_type type); static void fix_max_relay_log_size(THD *thd, enum_var_type type); static void fix_max_connections(THD *thd, enum_var_type type); +static void fix_thd_mem_root(THD *thd, enum_var_type type); +static void fix_trans_mem_root(THD *thd, enum_var_type type); /* Variable definition list @@ -209,13 +211,17 @@ sys_var_long_ptr sys_query_cache_size("query_cache_size", sys_var_thd_ulong sys_range_alloc_block_size("range_alloc_block_size", &SV::range_alloc_block_size); sys_var_thd_ulong sys_query_alloc_block_size("query_alloc_block_size", - &SV::query_alloc_block_size); + &SV::query_alloc_block_size, + fix_thd_mem_root); sys_var_thd_ulong sys_query_prealloc_size("query_prealloc_size", - &SV::query_prealloc_size); + &SV::query_prealloc_size, + fix_thd_mem_root); sys_var_thd_ulong sys_trans_alloc_block_size("transaction_alloc_block_size", - &SV::trans_alloc_block_size); + &SV::trans_alloc_block_size, + fix_trans_mem_root); sys_var_thd_ulong sys_trans_prealloc_size("transaction_prealloc_size", - &SV::trans_prealloc_size); + &SV::trans_prealloc_size, + fix_trans_mem_root); #ifdef HAVE_QUERY_CACHE sys_var_long_ptr sys_query_cache_limit("query_cache_limit", @@ -763,6 +769,24 @@ static void fix_max_connections(THD *thd, enum_var_type type) } +static void fix_thd_mem_root(THD *thd, enum_var_type type) +{ + if (type != OPT_GLOBAL) + reset_root_defaults(&thd->mem_root, + thd->variables.query_alloc_block_size, + thd->variables.query_prealloc_size); +} + + +static void fix_trans_mem_root(THD *thd, enum_var_type type) +{ + if (type != OPT_GLOBAL) + reset_root_defaults(&thd->transaction.mem_root, + thd->variables.trans_alloc_block_size, + thd->variables.trans_prealloc_size); +} + + bool sys_var_long_ptr::update(THD *thd, set_var *var) { ulonglong tmp= var->value->val_int(); From 619eaee654d213c68f86981bf33dcccf15b52f02 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 3 Feb 2004 09:46:48 +0100 Subject: [PATCH 069/113] Give error if locked table is used twice in query. This fixes strange error message when doing LOCK TABLES t1 WRITE; INSERT TABLE t1 SELECT * from t1 (Bug #2296) client/mysqldump.c: Better help for flush-logs mysql-test/r/lock.result: Test for LOCK TABLES ; INSERT ... SELECT mysql-test/t/lock.test: Test for LOCK TABLES ; INSERT ... SELECT --- client/mysqldump.c | 2 +- mysql-test/r/lock.result | 4 ++++ mysql-test/t/lock.test | 4 ++++ sql/sql_base.cc | 6 +++++- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index 38202a5c253..6078a1e9dc0 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -154,7 +154,7 @@ static struct my_option my_long_options[] = {"first-slave", 'x', "Locks all tables across all databases.", (gptr*) &opt_first_slave, (gptr*) &opt_first_slave, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"flush-logs", 'F', "Flush logs file in server before starting dump.", + {"flush-logs", 'F', "Flush logs file in server before starting dump. Note that if you use this option in combination with the --all-databases (or -A) option, the logs will be flushed for each database dumped.", (gptr*) &flush_logs, (gptr*) &flush_logs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"force", 'f', "Continue even if we get an sql-error.", diff --git a/mysql-test/r/lock.result b/mysql-test/r/lock.result index ad5251b9110..31a18fe6cec 100644 --- a/mysql-test/r/lock.result +++ b/mysql-test/r/lock.result @@ -41,5 +41,9 @@ lock tables t1 write; check table t2; Table Op Msg_type Msg_text test.t2 check error Table 't2' was not locked with LOCK TABLES +insert into t1 select nr from t1; +Table 't1' was not locked with LOCK TABLES unlock tables; +lock tables t1 write, t1 as t1_alias read; +insert into t1 select index1,nr from t1 as t1_alias; drop table t1,t2; diff --git a/mysql-test/t/lock.test b/mysql-test/t/lock.test index 385713174d2..9015ce12fde 100644 --- a/mysql-test/t/lock.test +++ b/mysql-test/t/lock.test @@ -51,5 +51,9 @@ check table t1; # Check error message lock tables t1 write; check table t2; +--error 1100 +insert into t1 select nr from t1; unlock tables; +lock tables t1 write, t1 as t1_alias read; +insert into t1 select index1,nr from t1 as t1_alias; drop table t1,t2; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 40153ad847e..efb008f4a6e 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -824,8 +824,12 @@ TABLE *open_table(THD *thd,const char *db,const char *table_name, { if (table->key_length == key_length && !memcmp(table->table_cache_key,key,key_length) && - !my_strcasecmp(table->table_name,alias)) + !my_strcasecmp(table->table_name,alias) && + table->query_id != thd->query_id) + { + table->query_id=thd->query_id; goto reset; + } } my_printf_error(ER_TABLE_NOT_LOCKED,ER(ER_TABLE_NOT_LOCKED),MYF(0),alias); DBUG_RETURN(0); From 92bcbf9a43e2d74ee323f5e768923bfc289e83ce Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 3 Feb 2004 14:03:01 +0400 Subject: [PATCH 070/113] Thai tis620 crash problem in text comparison routines was fixed. --- mysql-test/r/ctype_tis620.result | 17 +++ mysql-test/t/ctype_tis620-master.opt | 1 + mysql-test/t/ctype_tis620.test | 18 +++ strings/ctype-tis620.c | 177 ++++++++++++++++++--------- 4 files changed, 158 insertions(+), 55 deletions(-) create mode 100644 mysql-test/r/ctype_tis620.result create mode 100644 mysql-test/t/ctype_tis620-master.opt create mode 100644 mysql-test/t/ctype_tis620.test diff --git a/mysql-test/r/ctype_tis620.result b/mysql-test/r/ctype_tis620.result new file mode 100644 index 00000000000..d939fd12e60 --- /dev/null +++ b/mysql-test/r/ctype_tis620.result @@ -0,0 +1,17 @@ +DROP TABLE IF EXISTS t620; +CREATE TABLE t620 ( +recid int(11) NOT NULL auto_increment, +dyninfo text, +PRIMARY KEY (recid) +) TYPE=MyISAM; +INSERT INTO t620 VALUES (1,'color=\"STB,NPG\"\r\nengine=\"J30A13\"\r\nframe=\"MRHCG1640YP4\"\r\ngrade=\"V6\"\r\nmodel=\"ACCORD\"\r\nmodelcode=\"CG164YEN\"\r\ntype=\"VT6\"\r\n'); +INSERT INTO t620 VALUES (2,'color=\"HTM,NPG,DEG,RGS\"\r\nengine=\"F23A5YP1\"\r\nframe=\"MRHCF8640YP3\"\r\ngrade=\"EXi AT\"\r\nmodel=\"ACCORD\"\r\nmodelcode=\"CF864YE\"\r\ntype=\"EXA\"\r\n'); +SELECT DISTINCT +(IF( LOCATE( 'year=\"', dyninfo ) = 1, +SUBSTRING( dyninfo, 6+1, LOCATE('\"\r',dyninfo) - 6 -1), +IF( LOCATE( '\nyear=\"', dyninfo ), +SUBSTRING( dyninfo, LOCATE( '\nyear=\"', dyninfo ) + 7, +LOCATE( '\"\r', SUBSTRING( dyninfo, LOCATE( '\nyear=\"', dyninfo ) +7 )) - 1), '' ))) AS year +FROM t620 +HAVING year != '' ORDER BY year; +year diff --git a/mysql-test/t/ctype_tis620-master.opt b/mysql-test/t/ctype_tis620-master.opt new file mode 100644 index 00000000000..69d47c06e42 --- /dev/null +++ b/mysql-test/t/ctype_tis620-master.opt @@ -0,0 +1 @@ +--default-character-set=tis620 diff --git a/mysql-test/t/ctype_tis620.test b/mysql-test/t/ctype_tis620.test new file mode 100644 index 00000000000..7a0555515e1 --- /dev/null +++ b/mysql-test/t/ctype_tis620.test @@ -0,0 +1,18 @@ +DROP TABLE IF EXISTS t620; +CREATE TABLE t620 ( + recid int(11) NOT NULL auto_increment, + dyninfo text, + PRIMARY KEY (recid) +) TYPE=MyISAM; + +INSERT INTO t620 VALUES (1,'color=\"STB,NPG\"\r\nengine=\"J30A13\"\r\nframe=\"MRHCG1640YP4\"\r\ngrade=\"V6\"\r\nmodel=\"ACCORD\"\r\nmodelcode=\"CG164YEN\"\r\ntype=\"VT6\"\r\n'); +INSERT INTO t620 VALUES (2,'color=\"HTM,NPG,DEG,RGS\"\r\nengine=\"F23A5YP1\"\r\nframe=\"MRHCF8640YP3\"\r\ngrade=\"EXi AT\"\r\nmodel=\"ACCORD\"\r\nmodelcode=\"CF864YE\"\r\ntype=\"EXA\"\r\n'); + +SELECT DISTINCT + (IF( LOCATE( 'year=\"', dyninfo ) = 1, + SUBSTRING( dyninfo, 6+1, LOCATE('\"\r',dyninfo) - 6 -1), + IF( LOCATE( '\nyear=\"', dyninfo ), + SUBSTRING( dyninfo, LOCATE( '\nyear=\"', dyninfo ) + 7, + LOCATE( '\"\r', SUBSTRING( dyninfo, LOCATE( '\nyear=\"', dyninfo ) +7 )) - 1), '' ))) AS year +FROM t620 +HAVING year != '' ORDER BY year; diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c index 7ffc83ea005..5cd718f5944 100644 --- a/strings/ctype-tis620.c +++ b/strings/ctype-tis620.c @@ -15,6 +15,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* + Copyright (C) 2003 by Sathit Jittanupat + * solving bug crash with long text field string + * sorting with different number of space or sign char. within string + Copyright (C) 2001 by Korakot Chaovavanich and Apisilp Trunganont Copyright (C) 1998, 1999 by Pruet Boonma @@ -49,10 +53,6 @@ #include "m_ctype.h" #include "t_ctype.h" -static uchar* thai2sortable(const uchar *tstr,int len); - -#define BUFFER_MULTIPLY 4 -#define buffsize(s) (BUFFER_MULTIPLY * (strlen(s) + 1)) #define M L_MIDDLE #define U L_UPPER #define L L_LOWER @@ -453,13 +453,77 @@ uchar NEAR sort_order_tis620[]= Arg: const source string and length of converted string Ret: Sortable string */ +static void _thai2sortable(uchar *tstr) +{ + uchar *p ; + int len,tlen ; + uchar c,l2bias ; + + tlen= len = strlen (tstr) ; + l2bias = 256 - 8 ; + for (p=tstr; tlen > 0; p++,tlen--) + { + c = *p ; + + if (isthai(c)) + { + int *t_ctype0 = t_ctype[c] ; + + if (isconsnt(c)) + l2bias -= 8 ; + if (isldvowel(c) && isconsnt(p[1])) + { + /* + simply swap between leading-vowel and consonant + */ + *p = p[1]; + p[1]= c ; + tlen-- ; + p++; + continue ; + } + + // if found level 2 char (L2_GARAN,L2_TONE*,L2_TYKHU) move to last + if (t_ctype0[1]>= L2_GARAN) + { + // l2bias use to control position weight of l2char + // example (*=l2char) XX*X must come before X*XX + strcpy (p,p+1) ; + tstr[len-1] = l2bias + t_ctype0[1]- L2_GARAN +1 ; + p-- ; + continue ; + } + } + else + { + l2bias -= 8 ; + *p = to_lower_tis620[c]; + } + /* + this routine skip non-printable char + but not necessary, leave it like raw ascii 8 bits + */ + /* + t_ctype0 = t_ctype[p[0]]; + if ((t_ctype0[0]|t_ctype0[1]|t_ctype0[2])==IGNORE) + { + strcpy(p,p+1); + p-- ; + } + */ + } +} + /* NOTE: isn't it faster to alloc buffer in calling function? - */ +*/ +/* +Sathit's NOTE: we don't use this function anymore static uchar* thai2sortable(const uchar * tstr,int len) { +*/ /* We use only 3 levels (neglect capitalization). */ - +/* const uchar* p= tstr; uchar *outBuf; uchar *pRight1, *pRight2, *pRight3; @@ -526,6 +590,7 @@ static uchar* thai2sortable(const uchar * tstr,int len) memcpy(pRight1, pLeft3, pRight3 - pLeft3); return outBuf; } +*/ /* strncoll() replacement, compare 2 string, both are conveted to sortable string Arg: 2 Strings and it compare length @@ -533,16 +598,27 @@ static uchar* thai2sortable(const uchar * tstr,int len) */ int my_strnncoll_tis620(const uchar * s1, int len1, const uchar * s2, int len2) { - uchar *tc1, *tc2; - int i; - tc1= thai2sortable(s1, len1); - tc2= thai2sortable(s2, len2); - i= strcmp((char*)tc1, (char*)tc2); - if (tc1 != s1) - free(tc1); - if (tc2 != s2) - free(tc2); - return i; + uchar buf[80] ; + uchar *tc1, *tc2; + int i; + + len1= (int) strnlen((char*) s1,len1); + len2= (int) strnlen((char*) s2,len2); + if ((len1 + len2 +2) > (int) sizeof(buf)) + tc1 = (uchar *)malloc(len1+len2) ; + else + tc1 = buf ; + tc2 = tc1 + len1+1 ; + strncpy((char *)tc1,(char *)s1,len1) ; + tc1[len1] = 0; // if s1's length > len1, need to put 'end of string' + strncpy((char *)tc2,(char *)s2,len2) ; + tc2[len2] = 0; // put end of string + _thai2sortable(tc1); + _thai2sortable(tc2); + i= strcmp((char*)tc1, (char*)tc2); + if (tc1 != buf ) + free(tc1); + return i; } /* strnxfrm replacment, convert Thai string to sortable string @@ -551,15 +627,12 @@ int my_strnncoll_tis620(const uchar * s1, int len1, const uchar * s2, int len2) */ int my_strnxfrm_tis620(uchar * dest, const uchar * src, int len, int srclen) { - uint bufSize; - uchar *tmp; - bufSize= (uint) buffsize((char*)src); - tmp= thai2sortable(src,srclen); - set_if_smaller(bufSize,(uint) len); - memcpy((uchar *)dest, tmp, bufSize); - if (tmp != src) - free(tmp); - return (int)bufSize; + if (len > srclen) + len = srclen ; + strncpy (dest,src,len) ; + dest[len] = 0; // if src's length > len, need to put 'end of string' + _thai2sortable(dest); + return strlen(dest); } /* strcoll replacment, compare 2 strings @@ -568,16 +641,7 @@ int my_strnxfrm_tis620(uchar * dest, const uchar * src, int len, int srclen) */ int my_strcoll_tis620(const uchar * s1, const uchar * s2) { - uchar *tc1, *tc2; - int i; - tc1= thai2sortable(s1, (int) strlen((char*)s1)); - tc2= thai2sortable(s2, (int) strlen((char*)s2)); - i= strcmp((char*)tc1, (char*)tc2); - if (tc1 != s1) - free(tc1); - if (tc2 != s2) - free(tc2); - return i; + return my_strnncoll_tis620(s1, strlen((char *)s1),s2,strlen((char *)s2)); } /* strxfrm replacment, convert Thai string to sortable string @@ -586,15 +650,7 @@ int my_strcoll_tis620(const uchar * s1, const uchar * s2) */ int my_strxfrm_tis620(uchar * dest, const uchar * src, int len) { - uint bufSize; - uchar *tmp; - - bufSize= (uint)buffsize((char*) src); - tmp= thai2sortable(src, len); - memcpy((uchar *)dest, tmp, bufSize); - if (tmp != src) - free(tmp); - return bufSize; + return my_strnxfrm_tis620(dest,src,len,strlen((char *)src)); } /* Convert SQL like string to C string @@ -658,20 +714,31 @@ void ThNormalize(uchar* ptr, uint field_length, const uchar* from, uint length) { const uchar* fr= from; uchar* p= ptr; + uint i; if (length > field_length) length= field_length; - while (length--) - if ((istone(*fr) || isdiacrt1(*fr)) && - (islwrvowel(fr[1]) || isuprvowel(fr[1]))) - { - *p= fr[1]; - p[1]= *fr; - fr+= 2; - p+= 2; - length--; + for (i=0;i 0 && (islwrvowel(fr[-1]) || isuprvowel(fr[-1]))) + continue ; + if(islwrvowel(fr[1]) || isuprvowel(fr[1])) + { + *p= fr[1]; + p[1]= *fr; + fr++; + p++; + i++ ; + } } - else - *p++ = *fr++; + + } + } From 2dc266aff4ed8e7c72bb3c01ff370ac4753a21cd Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 3 Feb 2004 16:45:29 +0400 Subject: [PATCH 071/113] another variant (bug #2185: mysql.server script echo bug) --- support-files/mysql.server.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/support-files/mysql.server.sh b/support-files/mysql.server.sh index f57e834d045..405972cb22d 100644 --- a/support-files/mysql.server.sh +++ b/support-files/mysql.server.sh @@ -60,11 +60,9 @@ export PATH mode=$1 # start or stop case `echo "testing\c"`,`echo -n testing` in - *c,*) echo_n=-n echo_c= ;; - *,-n*) echo_n= echo_c='\c' ;; - *) echo_n= echo_c=' -' -;; + *c*,-n*) echo_n= echo_c=' ';; + *c*,*) echo_n=-n echo_c= ;; + *) echo_n= echo_c='\c';; esac parse_arguments() { @@ -177,7 +175,7 @@ case "$mode" in sleep 1 while [ -s $pid_file -a "$flags" != aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ] do - [ -z "$flags" ] && echo $echo_n "Wait for mysqld to exit$echo_c" || echo $echo_n ".echo_c" + [ -z "$flags" ] && echo $echo_n "Wait for mysqld to exit$echo_c" || echo $echo_n ".$echo_c" flags=a$flags sleep 1 done From cbda6835edefb245f883e015b4b3e6761db6171a Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 3 Feb 2004 18:21:48 +0400 Subject: [PATCH 072/113] clean up comments --- sql/item_func.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/item_func.cc b/sql/item_func.cc index 28a1c428cab..037f7861630 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -456,7 +456,7 @@ double Item_func_pow::val() double Item_func_acos::val() { - // this 'volatile' was added as a fix for BUG #2338 to calm optimizer down + // the volatile's for BUG #2338 to calm optimizer down (because of gcc's bug) volatile double value=args[0]->val(); if ((null_value=(args[0]->null_value || (value < -1.0 || value > 1.0)))) return 0.0; @@ -465,7 +465,7 @@ double Item_func_acos::val() double Item_func_asin::val() { - // this 'volatile' was added as a fix for BUG #2338 to calm optimizer down + // the volatile's for BUG #2338 to calm optimizer down (because of gcc's bug) volatile double value=args[0]->val(); if ((null_value=(args[0]->null_value || (value < -1.0 || value > 1.0)))) return 0.0; From ec76183bec12a932e6cce00a7f730d4e9e8cfd03 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 3 Feb 2004 18:10:45 +0000 Subject: [PATCH 073/113] Added new option --sync-frm / --skip-sync-frm Marked --bdb-no-sync as deprecated Added --sync-bdb-logs / --disable-sync-bdb-logs as a synonym / alternative. mysys/my_getopt.c: Changed my_getopt so that disabled_my_option can be used for GET_BOOL type options too. sql/mysql_priv.h: Added opt_sync_frm sql/mysqld.cc: Added sync-frm / disable-sync-frm to mysqld, to be able to disable use of my_sync() (fsync()). This defaults to behavior in 4.0.16 and before, where creating of new tables is quicker than currently. This option is enabled by default. Marked --bdb-no-sync as deprecated option and added another one, --sync-bdb-logs besides. --bdb-no-sync and --disabled-sync-bdb-logs are now synonyms. sql/unireg.cc: One can disable my_sync() by using --disable-sync-frm BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted --- BitKeeper/etc/logging_ok | 1 + mysys/my_getopt.c | 8 +++++--- sql/mysql_priv.h | 2 +- sql/mysqld.cc | 30 ++++++++++++++++++++++++------ sql/unireg.cc | 2 +- 5 files changed, 32 insertions(+), 11 deletions(-) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index dae3ea521c3..e6bfe0ceb36 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -43,6 +43,7 @@ jani@janikt.pp.saunalahti.fi jani@rhols221.adsl.netsonic.fi jani@rhols221.arenanet.fi jani@ua126d19.elisa.omakaista.fi +jani@ua141d10.elisa.omakaista.fi jcole@abel.spaceapes.com jcole@main.burghcom.com jcole@mugatu.spaceapes.com diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 662e33a3a5a..a8c57b4cd1d 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -298,9 +298,11 @@ int handle_options(int *argc, char ***argv, --enable-'option-name'. *optend was set to '0' if one used --disable-option */ - *((my_bool*) optp->value)= (my_bool) (!optend || *optend == '1'); - (*argc)--; - get_one_option(optp->id, optp, argument); + my_bool tmp= (my_bool) (!optend || *optend == '1'); + *((my_bool*) optp->value)= tmp; + (*argc)--; + get_one_option(optp->id, optp, + tmp ? (char*) "1" : disabled_my_option); continue; } argument= optend; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 46f7ece8641..b3c3c5648bf 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -711,7 +711,7 @@ extern my_bool opt_sql_bin_update, opt_safe_user_create, opt_no_mix_types; extern my_bool opt_safe_show_db, opt_local_infile; extern my_bool opt_slave_compressed_protocol, use_temp_pool; extern my_bool opt_readonly; -extern my_bool opt_enable_named_pipe; +extern my_bool opt_enable_named_pipe, opt_sync_frm; extern MYSQL_LOG mysql_log,mysql_update_log,mysql_slow_log,mysql_bin_log; extern FILE *bootstrap_file; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 14db51cf6fd..8f10e298110 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -308,7 +308,7 @@ static my_bool opt_noacl=0, opt_bootstrap=0, opt_myisam_log=0; my_bool opt_safe_user_create = 0, opt_no_mix_types = 0; my_bool opt_show_slave_auth_info, opt_sql_bin_update = 0; my_bool opt_log_slave_updates= 0, opt_console= 0; -my_bool opt_readonly = 0; +my_bool opt_readonly = 0, opt_sync_bdb_logs, opt_sync_frm; volatile bool mqh_used = 0; FILE *bootstrap_file=0; @@ -3158,7 +3158,7 @@ enum options_mysqld { OPT_DELAY_KEY_WRITE_ALL, OPT_SLOW_QUERY_LOG, OPT_DELAY_KEY_WRITE, OPT_CHARSETS_DIR, OPT_BDB_HOME, OPT_BDB_LOG, - OPT_BDB_TMP, OPT_BDB_NOSYNC, + OPT_BDB_TMP, OPT_BDB_SYNC, OPT_BDB_LOCK, OPT_BDB_SKIP, OPT_BDB_NO_RECOVER, OPT_BDB_SHARED, OPT_MASTER_HOST, OPT_MASTER_USER, @@ -3251,7 +3251,8 @@ enum options_mysqld { OPT_DEFAULT_WEEK_FORMAT, OPT_RANGE_ALLOC_BLOCK_SIZE, OPT_QUERY_ALLOC_BLOCK_SIZE, OPT_QUERY_PREALLOC_SIZE, - OPT_TRANS_ALLOC_BLOCK_SIZE, OPT_TRANS_PREALLOC_SIZE + OPT_TRANS_ALLOC_BLOCK_SIZE, OPT_TRANS_PREALLOC_SIZE, + OPT_SYNC_FRM, OPT_BDB_NOSYNC }; @@ -3277,8 +3278,14 @@ struct my_option my_long_options[] = {"bdb-no-recover", OPT_BDB_NO_RECOVER, "Don't try to recover Berkeley DB tables on start", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"bdb-no-sync", OPT_BDB_NOSYNC, "Don't synchronously flush logs", 0, 0, 0, - GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"bdb-no-sync", OPT_BDB_NOSYNC, + "Disable synchronously flushing logs. This option is deprecated, use --skip-sync-bdb-logs or sync-bdb-logs=0 instead", + // (gptr*) &opt_sync_bdb_logs, (gptr*) &opt_sync_bdb_logs, 0, GET_BOOL, + 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"sync-bdb-logs", OPT_BDB_SYNC, + "Synchronously flush logs. Enabled by default", + (gptr*) &opt_sync_bdb_logs, (gptr*) &opt_sync_bdb_logs, 0, GET_BOOL, + NO_ARG, 1, 0, 0, 0, 0, 0}, {"bdb-shared-data", OPT_BDB_SHARED, "Start Berkeley DB in multi-process mode", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -3286,6 +3293,9 @@ struct my_option my_long_options[] = (gptr*) &berkeley_tmpdir, (gptr*) &berkeley_tmpdir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif /* HAVE_BERKELEY_DB */ + {"sync-frm", OPT_SYNC_FRM, "Sync .frm to disk on create. Enabled by default", + (gptr*) &opt_sync_frm, (gptr*) &opt_sync_frm, 0, GET_BOOL, NO_ARG, 1, 0, + 0, 0, 0, 0}, {"skip-bdb", OPT_BDB_SKIP, "Don't use berkeley db (will save memory)", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"big-tables", OPT_BIG_TABLES, @@ -4728,7 +4738,15 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), } #ifdef HAVE_BERKELEY_DB case OPT_BDB_NOSYNC: - berkeley_env_flags|=DB_TXN_NOSYNC; + /* Deprecated option */ + opt_sync_bdb_logs= 0; + /* Fall through */ + case OPT_BDB_SYNC: + if (!opt_sync_bdb_logs) + berkeley_env_flags|= DB_TXN_NOSYNC; + else + berkeley_env_flags&= ~DB_TXN_NOSYNC; + printf("berkeley_env_flags: %d, arg '%s'\n", berkeley_env_flags, argument); break; case OPT_BDB_NO_RECOVER: berkeley_init_flags&= ~(DB_RECOVER); diff --git a/sql/unireg.cc b/sql/unireg.cc index ff42bfae0f0..955e5cfda8a 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -150,7 +150,7 @@ int rea_create_table(my_string file_name, my_free((gptr) screen_buff,MYF(0)); my_afree((gptr) keybuff); - if (my_sync(file, MYF(MY_WME))) + if (opt_sync_frm && my_sync(file, MYF(MY_WME))) goto err2; if (my_close(file,MYF(MY_WME)) || ha_create_table(file_name,create_info,0)) From 313761cb40d7ba89c860e0c823f20f59698dab4c Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 3 Feb 2004 19:17:23 +0100 Subject: [PATCH 074/113] Ensure that privileges are tested properly for multi-table-updates. Now one need only SELECT privilege for tables that are only read in UPDATE statements with many tables. (Bug #2377). sql/sql_acl.cc: Comment cleanup sql/sql_parse.cc: Merged duplicate code. Removed some outdated 'tables->db' tests. Check privileges for multi-updates properly (Bug #2377) sql/sql_show.cc: Remove disabled code sql/sql_update.cc: Ensure that privileges are tested properly for multi-table-updates tests/grant.pl: Added more tests tests/grant.res: updated results --- sql/sql_acl.cc | 2 +- sql/sql_parse.cc | 116 ++++++++++------------ sql/sql_show.cc | 5 - sql/sql_update.cc | 22 ++++- tests/grant.pl | 62 +++++++++++- tests/grant.res | 242 +++++++++++++++++++++++++++++----------------- 6 files changed, 278 insertions(+), 171 deletions(-) diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 6df636386d6..596619b3955 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -2539,7 +2539,7 @@ void grant_reload(THD *thd) /**************************************************************************** Check grants - All errors are written directly to the client if command name is given ! + All errors are written directly to the client if no_errors is given ! ****************************************************************************/ bool check_grant(THD *thd, ulong want_access, TABLE_LIST *tables, diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 0d22704ef3c..f97b1b8f8be 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -63,6 +63,8 @@ static bool append_file_to_dir(THD *thd, const char **filename_ptr, const char *table_name); static bool create_total_list(THD *thd, LEX *lex, TABLE_LIST **result, bool skip_first); +static bool check_one_table_access(THD *thd, ulong want_access, + TABLE_LIST *table, bool no_errors); const char *any_db="*any*"; // Special symbol for check_access @@ -870,11 +872,8 @@ int mysql_table_dump(THD* thd, char* db, char* tbl_name, int fd) if (!(table=open_ltable(thd, table_list, TL_READ_NO_INSERT))) DBUG_RETURN(1); - if (check_access(thd, SELECT_ACL, db, &table_list->grant.privilege)) + if (check_one_table_access(thd, SELECT_ACL, table_list, 0)) goto err; - if (grant_option && check_grant(thd, SELECT_ACL, table_list)) - goto err; - thd->free_list = 0; thd->query_length=(uint) strlen(tbl_name); thd->query = tbl_name; @@ -1102,9 +1101,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd, casedn_str(table_list.real_name); remove_escape(table_list.real_name); // This can't have wildcards - if (check_access(thd,SELECT_ACL,table_list.db,&thd->col_access)) + if (check_access(thd,SELECT_ACL,table_list.db,&table_list.grant.privilege)) break; - table_list.grant.privilege=thd->col_access; if (grant_option && check_grant(thd,SELECT_ACL,&table_list,2)) break; mysqld_list_fields(thd,&table_list,fields); @@ -1693,12 +1691,8 @@ mysql_execute_command(void) break; } case SQLCOM_CREATE_INDEX: - if (!tables->db) - tables->db=thd->db; - if (check_access(thd,INDEX_ACL,tables->db,&tables->grant.privilege)) + if (check_one_table_access(thd, INDEX_ACL, tables, 0)) goto error; /* purecov: inspected */ - if (grant_option && check_grant(thd,INDEX_ACL,tables)) - goto error; if (end_active_trans(thd)) res= -1; else @@ -1753,8 +1747,6 @@ mysql_execute_command(void) res=0; break; } - if (!tables->db) - tables->db=thd->db; if (!select_lex->db) select_lex->db=tables->db; if (check_access(thd,ALTER_ACL,tables->db,&tables->grant.privilege) || @@ -1763,8 +1755,6 @@ mysql_execute_command(void) (TABLE_LIST *) lex->create_info.merge_list.first)) goto error; /* purecov: inspected */ - if (!tables->db) - tables->db=thd->db; if (grant_option) { if (check_grant(thd,ALTER_ACL,tables)) @@ -1909,16 +1899,8 @@ mysql_execute_command(void) break; } case SQLCOM_UPDATE: - TABLE_LIST *table; if (check_db_used(thd,tables)) goto error; - for (table=tables ; table ; table=table->next) - { - if (check_access(thd,UPDATE_ACL,table->db,&table->grant.privilege)) - goto error; - } - if (grant_option && check_grant(thd,UPDATE_ACL,tables)) - goto error; if (select_lex->item_list.elements != lex->value_list.elements) { send_error(&thd->net,ER_WRONG_VALUE_COUNT); @@ -1926,6 +1908,10 @@ mysql_execute_command(void) } if (select_lex->table_list.elements == 1) { + if (check_one_table_access(thd, UPDATE_ACL, tables, 0)) + goto error; /* purecov: inspected */ + + res= mysql_update(thd,tables, select_lex->item_list, lex->value_list, @@ -1937,7 +1923,22 @@ mysql_execute_command(void) else { const char *msg= 0; + TABLE_LIST *table; lex->sql_command= SQLCOM_MULTI_UPDATE; + + /* + Ensure that we have UPDATE or SELECT privilege for each table + The exact privilege is checked in mysql_multi_update() + */ + for (table= tables ; table ; table= table->next) + { + TABLE_LIST *save= table->next; + table->next= 0; + if (check_one_table_access(thd, UPDATE_ACL, table, 1) && + check_one_table_access(thd, SELECT_ACL, table, 0)) + goto error; + table->next= save; + } if (select_lex->order_list.elements) msg="ORDER BY"; else if (select_lex->select_limit && select_lex->select_limit != @@ -1958,21 +1959,14 @@ mysql_execute_command(void) } break; case SQLCOM_INSERT: - if (check_access(thd,INSERT_ACL,tables->db,&tables->grant.privilege)) + if (check_one_table_access(thd, INSERT_ACL, tables, 0)) goto error; /* purecov: inspected */ - if (grant_option && check_grant(thd,INSERT_ACL,tables)) - goto error; res = mysql_insert(thd,tables,lex->field_list,lex->many_values, lex->duplicates); break; case SQLCOM_REPLACE: - if (check_access(thd,INSERT_ACL | DELETE_ACL, - tables->db,&tables->grant.privilege)) + if (check_one_table_access(thd, INSERT_ACL | DELETE_ACL, tables, 0)) goto error; /* purecov: inspected */ - if (grant_option && check_grant(thd,INSERT_ACL | DELETE_ACL, - tables)) - - goto error; res = mysql_insert(thd,tables,lex->field_list,lex->many_values, DUP_REPLACE); break; @@ -1988,9 +1982,7 @@ mysql_execute_command(void) INSERT_ACL : INSERT_ACL | DELETE_ACL); TABLE_LIST *save_next=tables->next; tables->next=0; - if (check_access(thd, privilege, - tables->db,&tables->grant.privilege) || - (grant_option && check_grant(thd, privilege, tables))) + if (check_one_table_access(thd, privilege, tables, 0)) goto error; tables->next=save_next; if ((res=check_table_access(thd, SELECT_ACL, save_next))) @@ -2035,10 +2027,8 @@ mysql_execute_command(void) break; } case SQLCOM_TRUNCATE: - if (check_access(thd,DELETE_ACL,tables->db,&tables->grant.privilege)) + if (check_one_table_access(thd, DELETE_ACL, tables, 0)) goto error; /* purecov: inspected */ - if (grant_option && check_grant(thd,DELETE_ACL,tables)) - goto error; /* Don't allow this within a transaction because we want to use re-generate table @@ -2052,9 +2042,7 @@ mysql_execute_command(void) break; case SQLCOM_DELETE: { - if (check_access(thd,DELETE_ACL,tables->db,&tables->grant.privilege)) - goto error; /* purecov: inspected */ - if (grant_option && check_grant(thd,DELETE_ACL,tables)) + if (check_one_table_access(thd, DELETE_ACL, tables, 0)) goto error; // Set privilege for the WHERE clause tables->grant.want_privilege=(SELECT_ACL & ~tables->grant.privilege); @@ -2139,8 +2127,8 @@ mysql_execute_command(void) DROP / * 40005 TEMPORARY * / TABLE that come from parts of binlogs (likely if we use RESET SLAVE or CHANGE MASTER TO), while the temporary table has already been dropped. - To not generate such irrelevant "table does not exist errors", we silently - add IF EXISTS if TEMPORARY was used. + To not generate such irrelevant "table does not exist errors", + we silently add IF EXISTS if TEMPORARY was used. */ if (thd->slave_thread && lex->drop_temporary) lex->drop_if_exists= 1; @@ -2151,12 +2139,8 @@ mysql_execute_command(void) } break; case SQLCOM_DROP_INDEX: - if (!tables->db) - tables->db=thd->db; - if (check_access(thd,INDEX_ACL,tables->db,&tables->grant.privilege)) - goto error; /* purecov: inspected */ - if (grant_option && check_grant(thd,INDEX_ACL,tables)) - goto error; + if (check_one_table_access(thd, INDEX_ACL, tables, 0)) + goto error; /* purecov: inspected */ if (end_active_trans(thd)) res= -1; else @@ -2242,16 +2226,11 @@ mysql_execute_command(void) #else { char *db=tables->db; - if (!*db) - { - send_error(&thd->net,ER_NO_DB_ERROR); /* purecov: inspected */ - goto error; /* purecov: inspected */ - } remove_escape(db); // Fix escaped '_' remove_escape(tables->real_name); - if (check_access(thd,SELECT_ACL | EXTRA_ACL,db,&thd->col_access)) + if (check_access(thd,SELECT_ACL | EXTRA_ACL,db, + &tables->grant.privilege)) goto error; /* purecov: inspected */ - tables->grant.privilege=thd->col_access; if (grant_option && check_grant(thd,SELECT_ACL,tables,2)) goto error; res= mysqld_show_fields(thd,tables, @@ -2267,18 +2246,10 @@ mysql_execute_command(void) #else { char *db=tables->db; - if (!db) - { - send_error(&thd->net,ER_NO_DB_ERROR); /* purecov: inspected */ - goto error; /* purecov: inspected */ - } remove_escape(db); // Fix escaped '_' remove_escape(tables->real_name); - if (!tables->db) - tables->db=thd->db; - if (check_access(thd,SELECT_ACL,db,&thd->col_access)) + if (check_access(thd,SELECT_ACL,db,&tables->grant.privilege)) goto error; /* purecov: inspected */ - tables->grant.privilege=thd->col_access; if (grant_option && check_grant(thd,SELECT_ACL,tables,2)) goto error; res= mysqld_show_keys(thd,tables); @@ -2306,8 +2277,7 @@ mysql_execute_command(void) send_error(&thd->net,ER_NOT_ALLOWED_COMMAND); goto error; } - if (check_access(thd,privilege,tables->db,&tables->grant.privilege) || - grant_option && check_grant(thd,privilege,tables)) + if (check_one_table_access(thd, privilege, tables, 0)) goto error; } res=mysql_load(thd, lex->exchange, tables, lex->field_list, @@ -2805,6 +2775,18 @@ check_table_access(THD *thd, ulong want_access,TABLE_LIST *tables, } +static bool +check_one_table_access(THD *thd, ulong want_access, TABLE_LIST *table, + bool no_errors) +{ + if (check_access(thd, want_access, table->db, &table->grant.privilege, 0, + no_errors)) + return 1; + return (grant_option && check_grant(thd, want_access, table, 0, + no_errors)); +} + + static bool check_db_used(THD *thd,TABLE_LIST *tables) { for (; tables ; tables=tables->next) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index d34e2e68067..addea958ff6 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -491,11 +491,6 @@ mysqld_show_fields(THD *thd, TABLE_LIST *table_list,const char *wild, { if (!wild || !wild[0] || !wild_case_compare(field->field_name,wild)) { -#ifdef NOT_USED - if (thd->col_access & TABLE_ACLS || - ! check_grant_column(thd,table,field->field_name, - (uint) strlen(field->field_name),1)) -#endif { byte *pos; uint flags=field->flags; diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 4f5f21d61ad..d2ccd02051b 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -15,8 +15,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Update of records - Multi-table updates were introduced by Monty and Sinisa +/* + Single table and multi table updates of tables. + Multi-table updates were introduced by Sinisa & Monty */ #include "mysql_priv.h" @@ -398,20 +399,33 @@ int mysql_multi_update(THD *thd, TABLE_LIST *tl; DBUG_ENTER("mysql_multi_update"); - table_list->grant.want_privilege=(SELECT_ACL & ~table_list->grant.privilege); if ((res=open_and_lock_tables(thd,table_list))) DBUG_RETURN(res); thd->select_limit=HA_POS_ERROR; + + /* + Ensure that we have update privilege for all tables and columns in the + SET part + */ + for (tl= table_list ; tl ; tl=tl->next) + { + TABLE *table= tl->table; + table->grant.want_privilege= (UPDATE_ACL & ~table->grant.privilege); + } + if (setup_fields(thd, table_list, *fields, 1, 0, 0)) DBUG_RETURN(-1); /* Count tables and setup timestamp handling */ - for (tl= (TABLE_LIST*) table_list ; tl ; tl=tl->next) + for (tl= table_list ; tl ; tl=tl->next) { TABLE *table= tl->table; + + /* We only need SELECT privilege for columns in the values list */ + table->grant.want_privilege= (SELECT_ACL & ~table->grant.privilege); if (table->timestamp_field) { table->time_stamp=0; diff --git a/tests/grant.pl b/tests/grant.pl index 3146b7b6c25..eb2d00f3e1d 100644 --- a/tests/grant.pl +++ b/tests/grant.pl @@ -54,7 +54,7 @@ safe_query("delete from columns_priv"); safe_query("lock tables mysql.user write"); # Test lock tables safe_query("flush privileges"); safe_query("unlock tables"); # should already be unlocked -safe_query("drop database $opt_database",2); +safe_query("drop database $opt_database",3); # Don't print possible error safe_query("create database $opt_database"); # check that the user can't login yet @@ -186,6 +186,7 @@ user_query("delete from $opt_database.test where a=3"); user_query("create table $opt_database.test2 (a int not null)"); user_query("alter table $opt_database.test2 add b int"); user_query("create index dummy on $opt_database.test2 (a)"); +user_query("update test,test2 SET test.a=test2.a where test.a=test2.a"); user_query("drop table $opt_database.test2"); user_query("show tables from grant_test"); # These should fail @@ -195,6 +196,20 @@ user_query("insert into mysql.user (host,user) values ('error','$opt_user',0)",1 safe_query("revoke ALL PRIVILEGES on $opt_database.* from $user"); safe_query("select * from mysql.user where user = '$opt_user'"); safe_query("select * from mysql.db where user = '$opt_user'"); + +# Test multi-updates +safe_query("grant CREATE,UPDATE,DROP on $opt_database.* to $user"); +user_connect(0); +user_query("create table $opt_database.test2 (a int not null)"); +user_query("update test,test2 SET test.a=1 where 1"); +user_query("update test,test2 SET test.a=test2.a where 1",1); +safe_query("grant SELECT on $opt_database.* to $user"); +user_connect(0); +user_query("update test,test2 SET test.a=test2.a where test2.a=test.a"); +user_query("drop table $opt_database.test2"); + +# Revoke database privileges +safe_query("revoke ALL PRIVILEGES on $opt_database.* from $user"); user_connect(1); # @@ -216,11 +231,18 @@ user_query("insert into $opt_database.test values (8,0)"); user_query("update $opt_database.test set b=1",1); safe_query("grant update on $opt_database.test to $user"); user_query("update $opt_database.test set b=2"); + +user_query("update $opt_database.test,test2 SET test.b=3",1); +safe_query("grant select on $opt_database.test2 to $user"); +user_query("update $opt_database.test,test2 SET test.b=3"); +safe_query("revoke select on $opt_database.test2 from $user"); + user_query("delete from $opt_database.test",1); safe_query("grant delete on $opt_database.test to $user"); user_query("delete from $opt_database.test where a=1",1); user_query("update $opt_database.test set b=3 where b=1",1); user_query("update $opt_database.test set b=b+1",1); +user_query("update $opt_database.test,test2 SET test.a=test2.a",1); # # Test global SELECT privilege combined with table level privileges @@ -230,6 +252,8 @@ safe_query("grant SELECT on *.* to $user"); user_connect(0); user_query("update $opt_database.test set b=b+1"); user_query("update $opt_database.test set b=b+1 where a > 0"); +user_query("update $opt_database.test,test2 SET test.a=test2.a"); +user_query("update $opt_database.test,test2 SET test2.a=test.a",1); safe_query("revoke SELECT on *.* from $user"); safe_query("grant SELECT on $opt_database.* to $user"); user_connect(0); @@ -252,6 +276,9 @@ user_query("delete from $opt_database.test where a=1"); user_query("update $opt_database.test set b=2 where b=1"); user_query("update $opt_database.test set b=b+1"); user_query("select count(*) from test"); +user_query("update test,test2 SET test.b=4",1); +user_query("update test,test2 SET test2.a=test.a",1); +user_query("update test,test2 SET test.a=test2.a",1); user_query("create table $opt_database.test3 (a int)",1); user_query("alter table $opt_database.test2 add c int",1); @@ -270,10 +297,27 @@ user_query("select count(*) from test2,test",1); user_query("select count(*) from test,test2",1); user_query("replace into test2 SELECT a from test",1); safe_query("grant update on $opt_database.test2 to $user"); +user_query("update test,test2 SET test2.a=test.a"); +user_query("update test,test2 SET test.b=test2.a where 0",1); +user_query("update test,test2 SET test.a=2 where test2.a>100",1); +user_query("update test,test2 SET test.a=test2.a",1); user_query("replace into test2 SELECT a,a from test",1); safe_query("grant DELETE on $opt_database.test2 to $user"); user_query("replace into test2 SELECT a,a from test"); user_query("insert into test (a) SELECT a from test2",1); +safe_query("grant SELECT on $opt_database.test2 to $user"); +user_query("update test,test2 SET test.b=test2.a where 0"); +user_query("update test,test2 SET test.a=test2.a where test2.a>100"); + +safe_query("revoke UPDATE on $opt_database.test2 from $user"); +safe_query("grant UPDATE (c) on $opt_database.test2 to $user"); +user_query("update test,test2 SET test.b=test2.a where 0"); +user_query("update test,test2 SET test.a=test2.a where test2.a>100"); +user_query("update test,test2 SET test2.a=test2.a where test2.a>100",1); +user_query("update test,test2 SET test2.c=test2.a where test2.a>100"); + +safe_query("revoke SELECT,UPDATE on $opt_database.test2 from $user"); +safe_query("grant UPDATE on $opt_database.test2 to $user"); user_query("drop table $opt_database.test2",1); user_query("grant select on $opt_database.test2 to $user with grant option",1); @@ -315,9 +359,13 @@ user_query("select count(a) from test",1); # Test some grants on column level # +safe_query("grant create,update on $opt_database.test2 to $user"); +user_query("create table $opt_database.test2 (a int not null)"); user_query("delete from $opt_database.test where a=2",1); user_query("delete from $opt_database.test where A=2",1); user_query("update test set b=5 where b>0",1); +user_query("update test,test2 SET test.b=5 where b>0",1); + safe_query("grant update(b),delete on $opt_database.test to $user"); safe_query("revoke update(a) on $opt_database.test from $user",1); user_query("delete from $opt_database.test where a=2",1); @@ -327,12 +375,18 @@ user_query("delete from $opt_database.test where a=2"); user_query("delete from $opt_database.test where A=2"); user_query("update test set b=5 where b>0"); user_query("update test set a=11 where b>5",1); +user_query("update test,test2 SET test.b=5 where b>0"); +user_query("update test,test2 SET test.a=11 where b>0",1); +user_query("update test,test2 SET test.b=test2.a where b>0",1); +user_query("update test,test2 SET test.b=11 where test2.a>0",1); user_query("select a,A from test"); safe_query("select $tables_cols from mysql.tables_priv"); safe_query("revoke ALL PRIVILEGES on $opt_database.test from $user"); safe_query("select $tables_cols from mysql.tables_priv"); safe_query("revoke GRANT OPTION on $opt_database.test from $user",1); +safe_query("drop table $opt_database.test2"); +safe_query("revoke create,update on $opt_database.test2 from $user"); # # Test grants on database level @@ -412,7 +466,7 @@ safe_query("select $columns_cols from mysql.columns_priv where user = '$opt_user safe_query("revoke ALL PRIVILEGES on $opt_database.test from $user"); user_query("select count(a) from test",1); -user_query("select * from mysql.user",1); +user_query("select * from mysql.user order by hostname",1); safe_query("select * from mysql.db where user = '$opt_user'"); safe_query("select $tables_cols from mysql.tables_priv where user = '$opt_user'"); safe_query("select $columns_cols from mysql.columns_priv where user = '$opt_user'"); @@ -625,7 +679,7 @@ sub user_query { if (!defined($ignore_error)) { - die "The above should not have failed!"; + die "Query '$query' should not have failed!"; } } elsif (defined($ignore_error) && $ignore_error == 1) @@ -649,7 +703,7 @@ sub do_query if (!$sth->execute) { $fatal_error= ($DBI::errstr =~ /parse error/); - if (!$ignore_error || $opt_verbose || $fatal_error) + if (!$ignore_error || ($opt_verbose && $ignore_error != 3) || $fatal_error) { print "Error in execute: $DBI::errstr\n"; } diff --git a/tests/grant.res b/tests/grant.res index f208241d989..e2832d27817 100644 --- a/tests/grant.res +++ b/tests/grant.res @@ -6,10 +6,9 @@ lock tables mysql.user write flush privileges unlock tables drop database grant_test -Error in execute: Can't drop database 'grant_test'. Database doesn't exist create database grant_test Connecting grant_user -Error on connect: Access denied for user: '@localhost' to database 'grant_test' +Error on connect: Access denied for user: ''@'localhost' to database 'grant_test' grant select(user) on mysql.user to grant_user@localhost revoke select(user) on mysql.user from grant_user@localhost grant select on *.* to grant_user@localhost @@ -17,7 +16,7 @@ set password FOR grant_user2@localhost = password('test') Error in execute: Can't find any matching row in the user table set password FOR grant_user=password('test') Connecting grant_user -Error on connect: Access denied for user: 'grant_user@localhost' (Using password: NO) +Error on connect: Access denied for user: 'grant_user'@'localhost' (Using password: NO) set password FOR grant_user='' Connecting grant_user select * from mysql.user where user = 'grant_user' @@ -30,13 +29,13 @@ GRANT SELECT ON *.* TO 'grant_user'@'localhost' Connecting grant_user insert into mysql.user (host,user) values ('error','grant_user') -Error in execute: insert command denied to user: 'grant_user@localhost' for table 'user' +Error in execute: insert command denied to user: 'grant_user'@'localhost' for table 'user' update mysql.user set host='error' WHERE user='grant_user' -Error in execute: update command denied to user: 'grant_user@localhost' for table 'user' +Error in execute: update command denied to user: 'grant_user'@'localhost' for table 'user' create table grant_test.test (a int,b int) -Error in execute: create command denied to user: 'grant_user@localhost' for table 'test' +Error in execute: create command denied to user: 'grant_user'@'localhost' for table 'test' grant select on *.* to grant_user2@localhost -Error in execute: Access denied for user: 'grant_user@localhost' (Using password: NO) +Error in execute: Access denied for user: 'grant_user'@'localhost' (Using password: NO) revoke select on grant_test.test from grant_user@opt_host Error in execute: There is no such grant defined for user 'grant_user' on host 'opt_host' revoke select on grant_test.* from grant_user@opt_host @@ -46,25 +45,25 @@ Error in execute: There is no such grant defined for user 'grant_user' on host ' grant select on grant_test.not_exists to grant_user Error in execute: Table 'grant_test.not_exists' doesn't exist grant FILE on grant_test.test to grant_user -Error in execute: Illegal GRANT/REVOKE command. Please consult the manual which privileges can be used. +Error in execute: Illegal GRANT/REVOKE command. Please consult the manual which privileges can be used grant select on *.* to wrong___________user_name Error in execute: The host or user argument to GRANT is too long grant select on grant_test.* to wrong___________user_name Error in execute: The host or user argument to GRANT is too long Connecting grant_user grant select on grant_test.test to grant_user with grant option -Error in execute: grant command denied to user: 'grant_user@localhost' for table 'test' +Error in execute: grant command denied to user: 'grant_user'@'localhost' for table 'test' set password FOR ''@''='' Error in execute: Can't find any matching row in the user table set password FOR root@localhost = password('test') -Error in execute: Access denied for user: 'grant_user@localhost' to database 'mysql' +Error in execute: Access denied for user: 'grant_user'@'localhost' to database 'mysql' revoke select on *.* from grant_user@localhost grant create,update on *.* to grant_user@localhost Connecting grant_user flush privileges create table grant_test.test (a int,b int) update grant_test.test set b=b+1 where a > 0 -Error in execute: SELECT command denied to user: 'grant_user@localhost' for column 'a' in table 'test' +Error in execute: SELECT command denied to user: 'grant_user'@'localhost' for column 'a' in table 'test' show grants for grant_user@localhost GRANT UPDATE, CREATE ON *.* TO 'grant_user'@'localhost' @@ -77,12 +76,12 @@ Error in execute: There is no such grant defined for user 'grant_user' on host ' grant select on grant_test.test to wrong___________user_name Error in execute: The host or user argument to GRANT is too long INSERT INTO grant_test.test values (2,0) -Error in execute: insert command denied to user: 'grant_user@localhost' for table 'test' +Error in execute: insert command denied to user: 'grant_user'@'localhost' for table 'test' grant ALL PRIVILEGES on *.* to grant_user@localhost REVOKE INSERT on *.* from grant_user@localhost Connecting grant_user INSERT INTO grant_test.test values (1,0) -Error in execute: insert command denied to user: 'grant_user@localhost' for table 'test' +Error in execute: insert command denied to user: 'grant_user'@'localhost' for table 'test' grant INSERT on *.* to grant_user@localhost Connecting grant_user INSERT INTO grant_test.test values (2,0) @@ -92,7 +91,7 @@ select count(*) from grant_test.test revoke SELECT on *.* from grant_user@localhost Connecting grant_user select count(*) from grant_test.test -Error in execute: select command denied to user: 'grant_user@localhost' for table 'test' +Error in execute: select command denied to user: 'grant_user'@'localhost' for table 'test' INSERT INTO grant_test.test values (3,0) grant SELECT on *.* to grant_user@localhost Connecting grant_user @@ -101,7 +100,7 @@ select count(*) from grant_test.test revoke ALL PRIVILEGES on *.* from grant_user@localhost Connecting grant_user -Error on connect: Access denied for user: 'grant_user@localhost' to database 'grant_test' +Error on connect: Access denied for user: 'grant_user'@'localhost' to database 'grant_test' delete from user where user='grant_user' flush privileges delete from user where user='grant_user' @@ -118,23 +117,23 @@ select count(*) from grant_test.test 2 select * from mysql.user where user = 'grant_user' -Error in execute: Access denied for user: 'grant_user@localhost' to database 'mysql' +Error in execute: Access denied for user: 'grant_user'@'localhost' to database 'mysql' insert into grant_test.test values (4,0) -Error in execute: Access denied for user: 'grant_user@localhost' to database 'grant_test' +Error in execute: Access denied for user: 'grant_user'@'localhost' to database 'grant_test' update grant_test.test set a=1 -Error in execute: Access denied for user: 'grant_user@localhost' to database 'grant_test' +Error in execute: Access denied for user: 'grant_user'@'localhost' to database 'grant_test' delete from grant_test.test -Error in execute: Access denied for user: 'grant_user@localhost' to database 'grant_test' +Error in execute: Access denied for user: 'grant_user'@'localhost' to database 'grant_test' create table grant_test.test2 (a int) -Error in execute: Access denied for user: 'grant_user@localhost' to database 'grant_test' +Error in execute: Access denied for user: 'grant_user'@'localhost' to database 'grant_test' ALTER TABLE grant_test.test add c int -Error in execute: Access denied for user: 'grant_user@localhost' to database 'grant_test' +Error in execute: Access denied for user: 'grant_user'@'localhost' to database 'grant_test' CREATE INDEX dummy ON grant_test.test (a) -Error in execute: Access denied for user: 'grant_user@localhost' to database 'grant_test' +Error in execute: Access denied for user: 'grant_user'@'localhost' to database 'grant_test' drop table grant_test.test -Error in execute: Access denied for user: 'grant_user@localhost' to database 'grant_test' +Error in execute: Access denied for user: 'grant_user'@'localhost' to database 'grant_test' grant ALL PRIVILEGES on grant_test.* to grant_user2@localhost -Error in execute: Access denied for user: 'grant_user@localhost' to database 'grant_test' +Error in execute: Access denied for user: 'grant_user'@'localhost' to database 'grant_test' grant ALL PRIVILEGES on grant_test.* to grant_user@localhost WITH GRANT OPTION Connecting grant_user insert into grant_test.test values (5,0) @@ -145,33 +144,45 @@ REVOKE ALL PRIVILEGES on grant_test.* from grant_user@localhost REVOKE ALL PRIVILEGES on grant_test.* from grant_user@localhost Connecting grant_user insert into grant_test.test values (6,0) -Error in execute: Access denied for user: 'grant_user@localhost' to database 'grant_test' +Error in execute: Access denied for user: 'grant_user'@'localhost' to database 'grant_test' REVOKE GRANT OPTION on grant_test.* from grant_user@localhost Connecting grant_user -Error on connect: Access denied for user: 'grant_user@localhost' to database 'grant_test' +Error on connect: Access denied for user: 'grant_user'@'localhost' to database 'grant_test' grant ALL PRIVILEGES on grant_test.* to grant_user@localhost Connecting grant_user select * from mysql.user where user = 'grant_user' -Error in execute: Access denied for user: 'grant_user@localhost' to database 'mysql' +Error in execute: Access denied for user: 'grant_user'@'localhost' to database 'mysql' insert into grant_test.test values (7,0) update grant_test.test set a=3 where a=2 delete from grant_test.test where a=3 create table grant_test.test2 (a int not null) alter table grant_test.test2 add b int create index dummy on grant_test.test2 (a) +update test,test2 SET test.a=test2.a where test.a=test2.a drop table grant_test.test2 show tables from grant_test test insert into mysql.user (host,user) values ('error','grant_user',0) -Error in execute: Access denied for user: 'grant_user@localhost' to database 'mysql' +Error in execute: Access denied for user: 'grant_user'@'localhost' to database 'mysql' revoke ALL PRIVILEGES on grant_test.* from grant_user@localhost select * from mysql.user where user = 'grant_user' localhost grant_user N N N N N N N N N N N N N N N N N N N N N 0 0 0 select * from mysql.db where user = 'grant_user' +grant CREATE,UPDATE,DROP on grant_test.* to grant_user@localhost Connecting grant_user -Error on connect: Access denied for user: 'grant_user@localhost' to database 'grant_test' +create table grant_test.test2 (a int not null) +update test,test2 SET test.a=1 where 1 +update test,test2 SET test.a=test2.a where 1 +Error in execute: SELECT command denied to user: 'grant_user'@'localhost' for column 'a' in table 'test2' +grant SELECT on grant_test.* to grant_user@localhost +Connecting grant_user +update test,test2 SET test.a=test2.a where test2.a=test.a +drop table grant_test.test2 +revoke ALL PRIVILEGES on grant_test.* from grant_user@localhost +Connecting grant_user +Error on connect: Access denied for user: 'grant_user'@'localhost' to database 'grant_test' grant create on grant_test.test2 to grant_user@localhost Connecting grant_user create table grant_test.test2 (a int not null) @@ -179,15 +190,15 @@ show tables test2 show columns from test -Error in execute: select command denied to user: 'grant_user@localhost' for table 'test' +Error in execute: select command denied to user: 'grant_user'@'localhost' for table 'test' show keys from test -Error in execute: select command denied to user: 'grant_user@localhost' for table 'test' +Error in execute: select command denied to user: 'grant_user'@'localhost' for table 'test' show columns from test2 a int(11) 0 show keys from test2 select * from test -Error in execute: select command denied to user: 'grant_user@localhost' for table 'test' +Error in execute: select command denied to user: 'grant_user'@'localhost' for table 'test' grant insert on grant_test.test to grant_user@localhost show tables test @@ -195,22 +206,32 @@ test2 insert into grant_test.test values (8,0) update grant_test.test set b=1 -Error in execute: update command denied to user: 'grant_user@localhost' for table 'test' +Error in execute: update command denied to user: 'grant_user'@'localhost' for table 'test' grant update on grant_test.test to grant_user@localhost update grant_test.test set b=2 +update grant_test.test,test2 SET test.b=3 +Error in execute: select command denied to user: 'grant_user'@'localhost' for table 'test2' +grant select on grant_test.test2 to grant_user@localhost +update grant_test.test,test2 SET test.b=3 +revoke select on grant_test.test2 from grant_user@localhost delete from grant_test.test -Error in execute: delete command denied to user: 'grant_user@localhost' for table 'test' +Error in execute: delete command denied to user: 'grant_user'@'localhost' for table 'test' grant delete on grant_test.test to grant_user@localhost delete from grant_test.test where a=1 -Error in execute: SELECT command denied to user: 'grant_user@localhost' for column 'a' in table 'test' +Error in execute: SELECT command denied to user: 'grant_user'@'localhost' for column 'a' in table 'test' update grant_test.test set b=3 where b=1 -Error in execute: SELECT command denied to user: 'grant_user@localhost' for column 'b' in table 'test' +Error in execute: SELECT command denied to user: 'grant_user'@'localhost' for column 'b' in table 'test' update grant_test.test set b=b+1 -Error in execute: SELECT command denied to user: 'grant_user@localhost' for column 'b' in table 'test' +Error in execute: SELECT command denied to user: 'grant_user'@'localhost' for column 'b' in table 'test' +update grant_test.test,test2 SET test.a=test2.a +Error in execute: select command denied to user: 'grant_user'@'localhost' for table 'test2' grant SELECT on *.* to grant_user@localhost Connecting grant_user update grant_test.test set b=b+1 update grant_test.test set b=b+1 where a > 0 +update grant_test.test,test2 SET test.a=test2.a +update grant_test.test,test2 SET test2.a=test.a +Error in execute: UPDATE command denied to user: 'grant_user'@'localhost' for column 'a' in table 'test2' revoke SELECT on *.* from grant_user@localhost grant SELECT on grant_test.* to grant_user@localhost Connecting grant_user @@ -224,11 +245,11 @@ revoke UPDATE on *.* from grant_user@localhost revoke SELECT on grant_test.* from grant_user@localhost Connecting grant_user update grant_test.test set b=b+1 where a > 0 -Error in execute: SELECT command denied to user: 'grant_user@localhost' for column 'a' in table 'test' +Error in execute: SELECT command denied to user: 'grant_user'@'localhost' for column 'a' in table 'test' update grant_test.test set b=b+1 -Error in execute: SELECT command denied to user: 'grant_user@localhost' for column 'b' in table 'test' +Error in execute: SELECT command denied to user: 'grant_user'@'localhost' for column 'b' in table 'test' select * from test -Error in execute: select command denied to user: 'grant_user@localhost' for table 'test' +Error in execute: select command denied to user: 'grant_user'@'localhost' for table 'test' grant select on grant_test.test to grant_user@localhost delete from grant_test.test where a=1 update grant_test.test set b=2 where b=1 @@ -236,68 +257,93 @@ update grant_test.test set b=b+1 select count(*) from test 3 +update test,test2 SET test.b=4 +Error in execute: select command denied to user: 'grant_user'@'localhost' for table 'test2' +update test,test2 SET test2.a=test.a +Error in execute: select command denied to user: 'grant_user'@'localhost' for table 'test2' +update test,test2 SET test.a=test2.a +Error in execute: select command denied to user: 'grant_user'@'localhost' for table 'test2' create table grant_test.test3 (a int) -Error in execute: create command denied to user: 'grant_user@localhost' for table 'test3' +Error in execute: create command denied to user: 'grant_user'@'localhost' for table 'test3' alter table grant_test.test2 add c int -Error in execute: alter command denied to user: 'grant_user@localhost' for table 'test2' +Error in execute: alter command denied to user: 'grant_user'@'localhost' for table 'test2' grant alter on grant_test.test2 to grant_user@localhost alter table grant_test.test2 add c int create index dummy ON grant_test.test (a) -Error in execute: index command denied to user: 'grant_user@localhost' for table 'test' +Error in execute: index command denied to user: 'grant_user'@'localhost' for table 'test' grant index on grant_test.test2 to grant_user@localhost create index dummy ON grant_test.test2 (a) insert into test2 SELECT a,a from test -Error in execute: insert command denied to user: 'grant_user@localhost' for table 'test2' +Error in execute: insert command denied to user: 'grant_user'@'localhost' for table 'test2' grant insert on test2 to grant_user@localhost Error in execute: Table 'mysql.test2' doesn't exist grant insert(a) on grant_test.test2 to grant_user@localhost insert into test2 SELECT a,a from test -Error in execute: insert command denied to user: 'grant_user@localhost' for column 'c' in table 'test2' +Error in execute: insert command denied to user: 'grant_user'@'localhost' for column 'c' in table 'test2' grant insert(c) on grant_test.test2 to grant_user@localhost insert into test2 SELECT a,a from test select count(*) from test2,test -Error in execute: select command denied to user: 'grant_user@localhost' for table 'test2' +Error in execute: select command denied to user: 'grant_user'@'localhost' for table 'test2' select count(*) from test,test2 -Error in execute: select command denied to user: 'grant_user@localhost' for table 'test2' +Error in execute: select command denied to user: 'grant_user'@'localhost' for table 'test2' replace into test2 SELECT a from test -Error in execute: delete command denied to user: 'grant_user@localhost' for table 'test2' +Error in execute: delete command denied to user: 'grant_user'@'localhost' for table 'test2' grant update on grant_test.test2 to grant_user@localhost +update test,test2 SET test2.a=test.a +update test,test2 SET test.b=test2.a where 0 +Error in execute: SELECT command denied to user: 'grant_user'@'localhost' for column 'a' in table 'test2' +update test,test2 SET test.a=2 where test2.a>100 +Error in execute: SELECT command denied to user: 'grant_user'@'localhost' for column 'a' in table 'test2' +update test,test2 SET test.a=test2.a +Error in execute: SELECT command denied to user: 'grant_user'@'localhost' for column 'a' in table 'test2' replace into test2 SELECT a,a from test -Error in execute: delete command denied to user: 'grant_user@localhost' for table 'test2' +Error in execute: delete command denied to user: 'grant_user'@'localhost' for table 'test2' grant DELETE on grant_test.test2 to grant_user@localhost replace into test2 SELECT a,a from test insert into test (a) SELECT a from test2 -Error in execute: select command denied to user: 'grant_user@localhost' for table 'test2' +Error in execute: select command denied to user: 'grant_user'@'localhost' for table 'test2' +grant SELECT on grant_test.test2 to grant_user@localhost +update test,test2 SET test.b=test2.a where 0 +update test,test2 SET test.a=test2.a where test2.a>100 +revoke UPDATE on grant_test.test2 from grant_user@localhost +grant UPDATE (c) on grant_test.test2 to grant_user@localhost +update test,test2 SET test.b=test2.a where 0 +update test,test2 SET test.a=test2.a where test2.a>100 +update test,test2 SET test2.a=test2.a where test2.a>100 +Error in execute: UPDATE command denied to user: 'grant_user'@'localhost' for column 'a' in table 'test2' +update test,test2 SET test2.c=test2.a where test2.a>100 +revoke SELECT,UPDATE on grant_test.test2 from grant_user@localhost +grant UPDATE on grant_test.test2 to grant_user@localhost drop table grant_test.test2 -Error in execute: drop command denied to user: 'grant_user@localhost' for table 'test2' +Error in execute: drop command denied to user: 'grant_user'@'localhost' for table 'test2' grant select on grant_test.test2 to grant_user@localhost with grant option -Error in execute: select command denied to user: 'grant_user@localhost' for table 'test2' +Error in execute: select command denied to user: 'grant_user'@'localhost' for table 'test2' grant drop on grant_test.test2 to grant_user@localhost with grant option grant drop on grant_test.test2 to grant_user@localhost with grant option grant select on grant_test.test2 to grant_user@localhost with grant option -Error in execute: select command denied to user: 'grant_user@localhost' for table 'test2' +Error in execute: select command denied to user: 'grant_user'@'localhost' for table 'test2' rename table grant_test.test2 to grant_test.test3 -Error in execute: insert command denied to user: 'grant_user@localhost' for table 'test3' +Error in execute: insert command denied to user: 'grant_user'@'localhost' for table 'test3' grant CREATE,DROP on grant_test.test3 to grant_user@localhost rename table grant_test.test2 to grant_test.test3 -Error in execute: insert command denied to user: 'grant_user@localhost' for table 'test3' +Error in execute: insert command denied to user: 'grant_user'@'localhost' for table 'test3' create table grant_test.test3 (a int) grant INSERT on grant_test.test3 to grant_user@localhost drop table grant_test.test3 rename table grant_test.test2 to grant_test.test3 rename table grant_test.test3 to grant_test.test2 -Error in execute: alter command denied to user: 'grant_user@localhost' for table 'test3' +Error in execute: alter command denied to user: 'grant_user'@'localhost' for table 'test3' grant ALTER on grant_test.test3 to grant_user@localhost rename table grant_test.test3 to grant_test.test2 revoke DROP on grant_test.test2 from grant_user@localhost rename table grant_test.test2 to grant_test.test3 drop table if exists grant_test.test2,grant_test.test3 -Error in execute: drop command denied to user: 'grant_user@localhost' for table 'test2' +Error in execute: drop command denied to user: 'grant_user'@'localhost' for table 'test2' drop table if exists grant_test.test2,grant_test.test3 create database grant_test -Error in execute: Access denied for user: 'grant_user@localhost' to database 'grant_test' +Error in execute: Access denied for user: 'grant_user'@'localhost' to database 'grant_test' drop database grant_test -Error in execute: Access denied for user: 'grant_user@localhost' to database 'grant_test' +Error in execute: Access denied for user: 'grant_user'@'localhost' to database 'grant_test' flush tables Error in execute: Access denied. You need the RELOAD privilege for this operation flush privileges @@ -312,38 +358,54 @@ revoke ALL PRIVILEGES on grant_test.test3 from grant_user@localhost revoke GRANT OPTION on grant_test.test2 from grant_user@localhost select Host, Db, User, Table_name, Grantor, Table_priv, Column_priv from mysql.tables_priv select count(a) from test -Error in execute: select command denied to user: 'grant_user@localhost' for table 'test' +Error in execute: select command denied to user: 'grant_user'@'localhost' for table 'test' +grant create,update on grant_test.test2 to grant_user@localhost +create table grant_test.test2 (a int not null) delete from grant_test.test where a=2 -Error in execute: delete command denied to user: 'grant_user@localhost' for table 'test' +Error in execute: delete command denied to user: 'grant_user'@'localhost' for table 'test' delete from grant_test.test where A=2 -Error in execute: delete command denied to user: 'grant_user@localhost' for table 'test' +Error in execute: delete command denied to user: 'grant_user'@'localhost' for table 'test' update test set b=5 where b>0 -Error in execute: update command denied to user: 'grant_user@localhost' for table 'test' +Error in execute: update command denied to user: 'grant_user'@'localhost' for table 'test' +update test,test2 SET test.b=5 where b>0 +Error in execute: select command denied to user: 'grant_user'@'localhost' for table 'test' grant update(b),delete on grant_test.test to grant_user@localhost revoke update(a) on grant_test.test from grant_user@localhost Error in execute: There is no such grant defined for user 'grant_user' on host 'localhost' on table 'test' delete from grant_test.test where a=2 -Error in execute: SELECT command denied to user: 'grant_user@localhost' for column 'a' in table 'test' +Error in execute: SELECT command denied to user: 'grant_user'@'localhost' for column 'a' in table 'test' update test set b=5 where b>0 -Error in execute: SELECT command denied to user: 'grant_user@localhost' for column 'b' in table 'test' +Error in execute: SELECT command denied to user: 'grant_user'@'localhost' for column 'b' in table 'test' grant select(a),select(b) on grant_test.test to grant_user@localhost delete from grant_test.test where a=2 delete from grant_test.test where A=2 update test set b=5 where b>0 update test set a=11 where b>5 -Error in execute: UPDATE command denied to user: 'grant_user@localhost' for column 'a' in table 'test' +Error in execute: UPDATE command denied to user: 'grant_user'@'localhost' for column 'a' in table 'test' +update test,test2 SET test.b=5 where b>0 +update test,test2 SET test.a=11 where b>0 +Error in execute: UPDATE command denied to user: 'grant_user'@'localhost' for column 'a' in table 'test' +update test,test2 SET test.b=test2.a where b>0 +Error in execute: SELECT command denied to user: 'grant_user'@'localhost' for column 'a' in table 'test2' +update test,test2 SET test.b=11 where test2.a>0 +Error in execute: SELECT command denied to user: 'grant_user'@'localhost' for column 'a' in table 'test2' select a,A from test 8 8 5 5 7 7 select Host, Db, User, Table_name, Grantor, Table_priv, Column_priv from mysql.tables_priv +localhost grant_test grant_user test2 root@localhost Update,Create localhost grant_test grant_user test root@localhost Delete Select,Update revoke ALL PRIVILEGES on grant_test.test from grant_user@localhost select Host, Db, User, Table_name, Grantor, Table_priv, Column_priv from mysql.tables_priv +localhost grant_test grant_user test2 root@localhost Update,Create + revoke GRANT OPTION on grant_test.test from grant_user@localhost Error in execute: There is no such grant defined for user 'grant_user' on host 'localhost' on table 'test' +drop table grant_test.test2 +revoke create,update on grant_test.test2 from grant_user@localhost grant select(a) on grant_test.test to grant_user@localhost show full columns from test a int(11) YES NULL select @@ -363,21 +425,21 @@ insert into test (b) values (5) insert into test (b) values (a) update test set b=3 where a > 0 select * from test -Error in execute: select command denied to user: 'grant_user@localhost' for column 'b' in table 'test' +Error in execute: select command denied to user: 'grant_user'@'localhost' for column 'b' in table 'test' select b from test -Error in execute: SELECT command denied to user: 'grant_user@localhost' for column 'b' in table 'test' +Error in execute: SELECT command denied to user: 'grant_user'@'localhost' for column 'b' in table 'test' select a from test where b > 0 -Error in execute: SELECT command denied to user: 'grant_user@localhost' for column 'b' in table 'test' +Error in execute: SELECT command denied to user: 'grant_user'@'localhost' for column 'b' in table 'test' insert into test (a) values (10) -Error in execute: INSERT command denied to user: 'grant_user@localhost' for column 'a' in table 'test' +Error in execute: INSERT command denied to user: 'grant_user'@'localhost' for column 'a' in table 'test' insert into test (b) values (b) -Error in execute: SELECT command denied to user: 'grant_user@localhost' for column 'b' in table 'test' +Error in execute: SELECT command denied to user: 'grant_user'@'localhost' for column 'b' in table 'test' insert into test (a,b) values (1,5) -Error in execute: INSERT command denied to user: 'grant_user@localhost' for column 'a' in table 'test' +Error in execute: INSERT command denied to user: 'grant_user'@'localhost' for column 'a' in table 'test' insert into test (b) values (1),(b) -Error in execute: SELECT command denied to user: 'grant_user@localhost' for column 'b' in table 'test' +Error in execute: SELECT command denied to user: 'grant_user'@'localhost' for column 'b' in table 'test' update test set b=3 where b > 0 -Error in execute: SELECT command denied to user: 'grant_user@localhost' for column 'b' in table 'test' +Error in execute: SELECT command denied to user: 'grant_user'@'localhost' for column 'b' in table 'test' select Host, Db, User, Table_name, Grantor, Table_priv, Column_priv from mysql.tables_priv localhost grant_test grant_user test root@localhost Select,Insert,Update @@ -393,9 +455,9 @@ select Host, Db, User, Table_name, Column_name, Column_priv from mysql.columns_p localhost grant_test grant_user test b Insert select count(a) from test -Error in execute: select command denied to user: 'grant_user@localhost' for table 'test' +Error in execute: select command denied to user: 'grant_user'@'localhost' for table 'test' update test set b=4 -Error in execute: update command denied to user: 'grant_user@localhost' for table 'test' +Error in execute: update command denied to user: 'grant_user'@'localhost' for table 'test' grant select(a,b), update (a,b) on grant_test.test to grant_user@localhost select count(a),count(b) from test where a+b > 0 3 3 @@ -411,13 +473,13 @@ localhost grant_test grant_user test b Select,Insert,Update localhost grant_test grant_user test a Select,Update insert into test (a,b) values (12,12) -Error in execute: INSERT command denied to user: 'grant_user@localhost' for column 'a' in table 'test' +Error in execute: INSERT command denied to user: 'grant_user'@'localhost' for column 'a' in table 'test' grant insert on grant_test.* to grant_user@localhost Connecting grant_user insert into test (a,b) values (13,13) revoke select(b) on grant_test.test from grant_user@localhost select count(a) from test where a+b > 0 -Error in execute: SELECT command denied to user: 'grant_user@localhost' for column 'b' in table 'test' +Error in execute: SELECT command denied to user: 'grant_user'@'localhost' for column 'b' in table 'test' update test set b=5 where a=2 grant select on grant_test.test to grant_user@localhost Connecting grant_user @@ -431,10 +493,10 @@ select count(a) from test where a+b > 0 revoke select on grant_test.test from grant_user@localhost Connecting grant_user select count(a) from test where a+b > 0 -Error in execute: select command denied to user: 'grant_user@localhost' for table 'test' +Error in execute: select command denied to user: 'grant_user'@'localhost' for table 'test' grant select(a) on grant_test.test to grant_user@localhost select count(a) from test where a+b > 0 -Error in execute: SELECT command denied to user: 'grant_user@localhost' for column 'b' in table 'test' +Error in execute: SELECT command denied to user: 'grant_user'@'localhost' for column 'b' in table 'test' grant select on *.* to grant_user@localhost Connecting grant_user select count(a) from test where a+b > 0 @@ -458,9 +520,9 @@ localhost grant_test grant_user test a Select,Update revoke ALL PRIVILEGES on grant_test.test from grant_user@localhost select count(a) from test -Error in execute: select command denied to user: 'grant_user@localhost' for table 'test' -select * from mysql.user -Error in execute: select command denied to user: 'grant_user@localhost' for table 'user' +Error in execute: select command denied to user: 'grant_user'@'localhost' for table 'test' +select * from mysql.user order by hostname +Error in execute: select command denied to user: 'grant_user'@'localhost' for table 'user' select * from mysql.db where user = 'grant_user' localhost grant_test grant_user N Y N N N N N N N N N N @@ -492,25 +554,25 @@ select a from grant_test.test3 1 select * from grant_test.test3 -Error in execute: select command denied to user: 'grant_user@localhost' for column 'b' in table 'test3' +Error in execute: select command denied to user: 'grant_user'@'localhost' for column 'b' in table 'test3' select a,b from grant_test.test3 -Error in execute: SELECT command denied to user: 'grant_user@localhost' for column 'b' in table 'test3' +Error in execute: SELECT command denied to user: 'grant_user'@'localhost' for column 'b' in table 'test3' select b from grant_test.test3 -Error in execute: SELECT command denied to user: 'grant_user@localhost' for column 'b' in table 'test3' +Error in execute: SELECT command denied to user: 'grant_user'@'localhost' for column 'b' in table 'test3' revoke SELECT(a) on grant_test.test3 from grant_user@localhost revoke FILE on *.* from grant_user@localhost drop table grant_test.test3 create table grant_test.test3 (a int) Connecting grant_user -Error on connect: Access denied for user: 'grant_user@localhost' to database 'grant_test' +Error on connect: Access denied for user: 'grant_user'@'localhost' to database 'grant_test' grant INSERT on grant_test.test3 to grant_user@localhost Connecting grant_user select * into outfile '/tmp/mysql-grant.test' from grant_test.test3 -Error in execute: Access denied for user: 'grant_user@localhost' (Using password: NO) +Error in execute: Access denied for user: 'grant_user'@'localhost' (Using password: NO) grant SELECT on grant_test.test3 to grant_user@localhost Connecting grant_user LOCK TABLES grant_test.test3 READ -Error in execute: Access denied for user: 'grant_user@localhost' to database 'grant_test' +Error in execute: Access denied for user: 'grant_user'@'localhost' to database 'grant_test' grant LOCK TABLES on *.* to grant_user@localhost show grants for grant_user@localhost GRANT LOCK TABLES ON *.* TO 'grant_user'@'localhost' @@ -527,7 +589,7 @@ revoke SELECT,INSERT,UPDATE,DELETE on grant_test.test3 from grant_user@localhost Connecting grant_user revoke LOCK TABLES on *.* from grant_user@localhost Connecting grant_user -Error on connect: Access denied for user: 'grant_user@localhost' to database 'grant_test' +Error on connect: Access denied for user: 'grant_user'@'localhost' to database 'grant_test' drop table grant_test.test3 show grants for grant_user@localhost GRANT USAGE ON *.* TO 'grant_user'@'localhost' From 1e4d0a12d0a4530bb1842f6b96272534987597fe Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 3 Feb 2004 21:15:20 +0100 Subject: [PATCH 075/113] extra newline removed --- support-files/mysql.server.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/support-files/mysql.server.sh b/support-files/mysql.server.sh index 405972cb22d..7f4987be3a8 100644 --- a/support-files/mysql.server.sh +++ b/support-files/mysql.server.sh @@ -60,11 +60,11 @@ export PATH mode=$1 # start or stop case `echo "testing\c"`,`echo -n testing` in - *c*,-n*) echo_n= echo_c=' ';; - *c*,*) echo_n=-n echo_c= ;; - *) echo_n= echo_c='\c';; -esac - + *c*,-n*) echo_n= echo_c= ;; + *c*,*) echo_n=-n echo_c= ;; + *) echo_n= echo_c='\c' ;; +esac + parse_arguments() { for arg do case "$arg" in From 595e46704f57e515e329aae5c4d3860c1160170b Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 3 Feb 2004 22:25:02 +0100 Subject: [PATCH 076/113] - renamed myisam/ft_dump to myisam/mysam_ftdump and added it to the binary distribution and Server RPM myisam/myisam_ftdump.c: Rename: myisam/ft_dump.c -> myisam/myisam_ftdump.c BitKeeper/etc/ignore: Added myisam/myisam_ftdump to the ignore list myisam/Makefile.am: - renamed ft_dump to myisam_ftdump and added it to bin_PROGRAMS scripts/make_binary_distribution.sh: - added myisam_ftdump to the binary distribution support-files/mysql.spec.sh: - added myisam_ftdump to the Server package --- .bzrignore | 1 + myisam/Makefile.am | 6 +++--- myisam/{ft_dump.c => myisam_ftdump.c} | 0 scripts/make_binary_distribution.sh | 1 + support-files/mysql.spec.sh | 5 +++++ 5 files changed, 10 insertions(+), 3 deletions(-) rename myisam/{ft_dump.c => myisam_ftdump.c} (100%) diff --git a/.bzrignore b/.bzrignore index 572f877a49f..356418e3617 100644 --- a/.bzrignore +++ b/.bzrignore @@ -542,3 +542,4 @@ hardcopy.0 scripts/make_sharedlib_distribution sql/udf_example.so man/*.1 +myisam/myisam_ftdump diff --git a/myisam/Makefile.am b/myisam/Makefile.am index aeb3b34ee15..97456edee8d 100644 --- a/myisam/Makefile.am +++ b/myisam/Makefile.am @@ -21,18 +21,18 @@ INCLUDES = @MT_INCLUDES@ -I$(srcdir)/../include -I../include LDADD = @CLIENT_EXTRA_LDFLAGS@ libmyisam.a ../mysys/libmysys.a \ ../dbug/libdbug.a ../strings/libmystrings.a pkglib_LIBRARIES = libmyisam.a -bin_PROGRAMS = myisamchk myisamlog myisampack +bin_PROGRAMS = myisamchk myisamlog myisampack myisam_ftdump myisamchk_DEPENDENCIES= $(LIBRARIES) myisamlog_DEPENDENCIES= $(LIBRARIES) myisampack_DEPENDENCIES=$(LIBRARIES) -noinst_PROGRAMS = mi_test1 mi_test2 mi_test3 ft_dump #ft_test1 ft_eval +noinst_PROGRAMS = mi_test1 mi_test2 mi_test3 #ft_test1 ft_eval noinst_HEADERS = myisamdef.h fulltext.h ftdefs.h ft_test1.h ft_eval.h mi_test1_DEPENDENCIES= $(LIBRARIES) mi_test2_DEPENDENCIES= $(LIBRARIES) mi_test3_DEPENDENCIES= $(LIBRARIES) #ft_test1_DEPENDENCIES= $(LIBRARIES) #ft_eval_DEPENDENCIES= $(LIBRARIES) -ft_dump_DEPENDENCIES= $(LIBRARIES) +myisam_ftdump_DEPENDENCIES= $(LIBRARIES) libmyisam_a_SOURCES = mi_open.c mi_extra.c mi_info.c mi_rkey.c \ mi_rnext.c mi_rnext_same.c \ mi_search.c mi_page.c mi_key.c mi_locking.c \ diff --git a/myisam/ft_dump.c b/myisam/myisam_ftdump.c similarity index 100% rename from myisam/ft_dump.c rename to myisam/myisam_ftdump.c diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh index 300fc4a7020..c7945e31eda 100644 --- a/scripts/make_binary_distribution.sh +++ b/scripts/make_binary_distribution.sh @@ -100,6 +100,7 @@ BIN_FILES="extra/comp_err$BS extra/replace$BS extra/perror$BS \ extra/resolve_stack_dump$BS extra/mysql_waitpid$BS \ isam/isamchk$BS isam/pack_isam$BS \ myisam/myisamchk$BS myisam/myisampack$BS myisam/myisamlog$BS \ + myisam/myisam_ftdump$BS \ sql/mysqld$BS \ client/mysql$BS client/mysqlshow$BS client/mysqladmin$BS \ client/mysqldump$BS client/mysqlimport$BS \ diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index e25a8a40c71..3ee602e7504 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -467,6 +467,7 @@ fi %attr(755, root, root) %{_bindir}/isamlog %attr(755, root, root) %{_bindir}/my_print_defaults %attr(755, root, root) %{_bindir}/myisamchk +%attr(755, root, root) %{_bindir}/myisam_ftdump %attr(755, root, root) %{_bindir}/myisamlog %attr(755, root, root) %{_bindir}/myisampack %attr(755, root, root) %{_bindir}/mysql_convert_table_format @@ -572,6 +573,10 @@ fi # The spec file changelog only includes changes made to the spec file # itself %changelog +* Tue Feb 03 2004 Lenz Grimmer + +- added myisam_ftdump to the Server package + * Mon Dec 22 2003 Lenz Grimmer - marked /etc/logrotate.d/mysql as a config file (BUG 2156) From 796a040d5c4384a2aba3c2fec715e26f9087d1c1 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 4 Feb 2004 00:28:58 +0100 Subject: [PATCH 077/113] Ensure that wait_timeout doesn't overflow on windows. (Bug #2400) --- sql/mysqld.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index b2b53e571c3..c3931eccc0c 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -4093,7 +4093,8 @@ this value; if zero (the default): when the size exceeds max_binlog_size. \ "The number of seconds the server waits for activity on a connection before closing it", (gptr*) &global_system_variables.net_wait_timeout, (gptr*) &max_system_variables.net_wait_timeout, 0, GET_ULONG, - REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0}, + REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, IF_WIN(INT_MAX32/1000, LONG_TIMEOUT), + 0, 1, 0}, { "default-week-format", OPT_DEFAULT_WEEK_FORMAT, "The default week format used by WEEK() functions.", (gptr*) &global_system_variables.default_week_format, From 4d98ab822b241ddc8dbea71db8451bb81a32f2ca Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 4 Feb 2004 10:48:42 +0200 Subject: [PATCH 078/113] Fixed a bug in slave-compressed-protocol. Using this option from command line did not work. --- sql/mysqld.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index da4119a188a..98888783502 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -4043,7 +4043,7 @@ this value; if zero (the default): when the size exceeds max_binlog_size. \ "Use compression on master/slave protocol", (gptr*) &opt_slave_compressed_protocol, (gptr*) &opt_slave_compressed_protocol, - 0, GET_BOOL, REQUIRED_ARG, 0, 0, 1, 0, 1, 0}, + 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0}, {"slave_net_timeout", OPT_SLAVE_NET_TIMEOUT, "Number of seconds to wait for more data from a master/slave connection before aborting the read.", (gptr*) &slave_net_timeout, (gptr*) &slave_net_timeout, 0, From 4b44b849ba7ba7e8c5e7de5de40726888f21f847 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 4 Feb 2004 09:51:13 +0100 Subject: [PATCH 079/113] Fixed problem with range optimization over overlapping ranges (#2448) mysql-test/r/ctype_tis620.result: Cleanup test mysql-test/r/range.result: Test problem with range optimization over overlapping ranges (#2448) mysql-test/t/ctype_tis620.test: Cleanup test mysql-test/t/range.test: Test problem with range optimization over overlapping ranges (#2448) sql/mysqld.cc: Remove debug statement strings/ctype-tis620.c: est problem with range optimization over overlapping ranges (#2448) --- mysql-test/r/ctype_tis620.result | 13 +- mysql-test/r/range.result | 13 ++ mysql-test/t/ctype_tis620.test | 17 +- mysql-test/t/range.test | 16 +- sql/mysqld.cc | 1 - sql/opt_range.cc | 19 +- strings/ctype-tis620.c | 339 +++++++++++++------------------ 7 files changed, 195 insertions(+), 223 deletions(-) diff --git a/mysql-test/r/ctype_tis620.result b/mysql-test/r/ctype_tis620.result index d939fd12e60..811609d4ba9 100644 --- a/mysql-test/r/ctype_tis620.result +++ b/mysql-test/r/ctype_tis620.result @@ -1,17 +1,18 @@ -DROP TABLE IF EXISTS t620; -CREATE TABLE t620 ( +drop table if exists t1; +CREATE TABLE t1 ( recid int(11) NOT NULL auto_increment, dyninfo text, PRIMARY KEY (recid) -) TYPE=MyISAM; -INSERT INTO t620 VALUES (1,'color=\"STB,NPG\"\r\nengine=\"J30A13\"\r\nframe=\"MRHCG1640YP4\"\r\ngrade=\"V6\"\r\nmodel=\"ACCORD\"\r\nmodelcode=\"CG164YEN\"\r\ntype=\"VT6\"\r\n'); -INSERT INTO t620 VALUES (2,'color=\"HTM,NPG,DEG,RGS\"\r\nengine=\"F23A5YP1\"\r\nframe=\"MRHCF8640YP3\"\r\ngrade=\"EXi AT\"\r\nmodel=\"ACCORD\"\r\nmodelcode=\"CF864YE\"\r\ntype=\"EXA\"\r\n'); +) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,'color=\"STB,NPG\"\r\nengine=\"J30A13\"\r\nframe=\"MRHCG1640YP4\"\r\ngrade=\"V6\"\r\nmodel=\"ACCORD\"\r\nmodelcode=\"CG164YEN\"\r\ntype=\"VT6\"\r\n'); +INSERT INTO t1 VALUES (2,'color=\"HTM,NPG,DEG,RGS\"\r\nengine=\"F23A5YP1\"\r\nframe=\"MRHCF8640YP3\"\r\ngrade=\"EXi AT\"\r\nmodel=\"ACCORD\"\r\nmodelcode=\"CF864YE\"\r\ntype=\"EXA\"\r\n'); SELECT DISTINCT (IF( LOCATE( 'year=\"', dyninfo ) = 1, SUBSTRING( dyninfo, 6+1, LOCATE('\"\r',dyninfo) - 6 -1), IF( LOCATE( '\nyear=\"', dyninfo ), SUBSTRING( dyninfo, LOCATE( '\nyear=\"', dyninfo ) + 7, LOCATE( '\"\r', SUBSTRING( dyninfo, LOCATE( '\nyear=\"', dyninfo ) +7 )) - 1), '' ))) AS year -FROM t620 +FROM t1 HAVING year != '' ORDER BY year; year +DROP TABLE t1; diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result index e87df9a6c24..ccfdbd62a42 100644 --- a/mysql-test/r/range.result +++ b/mysql-test/r/range.result @@ -300,3 +300,16 @@ SELECT COUNT(*) FROM t1 WHERE (c=0 and b=1) or (c=0 and a=1); COUNT(*) 6 DROP TABLE t1; +CREATE TABLE t1 ( a int not null, b int not null, INDEX ab(a,b) ); +INSERT INTO t1 VALUES (47,1), (70,1), (15,1), (15, 4); +SELECT * FROM t1 +WHERE +( +( b =1 AND a BETWEEN 14 AND 21 ) OR +( b =2 AND a BETWEEN 16 AND 18 ) OR +( b =3 AND a BETWEEN 15 AND 19 ) OR +(a BETWEEN 19 AND 47) +); +a b +15 1 +47 1 diff --git a/mysql-test/t/ctype_tis620.test b/mysql-test/t/ctype_tis620.test index 7a0555515e1..7314b52e301 100644 --- a/mysql-test/t/ctype_tis620.test +++ b/mysql-test/t/ctype_tis620.test @@ -1,12 +1,15 @@ -DROP TABLE IF EXISTS t620; -CREATE TABLE t620 ( +--disable_warnings +drop table if exists t1; +--enable_warnings + +CREATE TABLE t1 ( recid int(11) NOT NULL auto_increment, dyninfo text, PRIMARY KEY (recid) -) TYPE=MyISAM; +) ENGINE=MyISAM; -INSERT INTO t620 VALUES (1,'color=\"STB,NPG\"\r\nengine=\"J30A13\"\r\nframe=\"MRHCG1640YP4\"\r\ngrade=\"V6\"\r\nmodel=\"ACCORD\"\r\nmodelcode=\"CG164YEN\"\r\ntype=\"VT6\"\r\n'); -INSERT INTO t620 VALUES (2,'color=\"HTM,NPG,DEG,RGS\"\r\nengine=\"F23A5YP1\"\r\nframe=\"MRHCF8640YP3\"\r\ngrade=\"EXi AT\"\r\nmodel=\"ACCORD\"\r\nmodelcode=\"CF864YE\"\r\ntype=\"EXA\"\r\n'); +INSERT INTO t1 VALUES (1,'color=\"STB,NPG\"\r\nengine=\"J30A13\"\r\nframe=\"MRHCG1640YP4\"\r\ngrade=\"V6\"\r\nmodel=\"ACCORD\"\r\nmodelcode=\"CG164YEN\"\r\ntype=\"VT6\"\r\n'); +INSERT INTO t1 VALUES (2,'color=\"HTM,NPG,DEG,RGS\"\r\nengine=\"F23A5YP1\"\r\nframe=\"MRHCF8640YP3\"\r\ngrade=\"EXi AT\"\r\nmodel=\"ACCORD\"\r\nmodelcode=\"CF864YE\"\r\ntype=\"EXA\"\r\n'); SELECT DISTINCT (IF( LOCATE( 'year=\"', dyninfo ) = 1, @@ -14,5 +17,7 @@ SELECT DISTINCT IF( LOCATE( '\nyear=\"', dyninfo ), SUBSTRING( dyninfo, LOCATE( '\nyear=\"', dyninfo ) + 7, LOCATE( '\"\r', SUBSTRING( dyninfo, LOCATE( '\nyear=\"', dyninfo ) +7 )) - 1), '' ))) AS year -FROM t620 +FROM t1 HAVING year != '' ORDER BY year; + +DROP TABLE t1; diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test index b04e614a740..2899c7c99a4 100644 --- a/mysql-test/t/range.test +++ b/mysql-test/t/range.test @@ -238,7 +238,7 @@ SELECT * FROM t1 WHERE a IN(1,2) AND b=5; DROP TABLE t1; # -# Test error with +# Test problem with range optimzer and sub ranges # CREATE TABLE t1 (a int, b int, c int, INDEX (c,a,b)); @@ -249,3 +249,17 @@ SELECT COUNT(*) FROM t1 WHERE (c=0 and a=1) or (c=0 and b=1); SELECT COUNT(*) FROM t1 WHERE (c=0 and b=1) or (c=0 and a=1); DROP TABLE t1; +# +# Test problem with range optimization over overlapping ranges (#2448) +# + +CREATE TABLE t1 ( a int not null, b int not null, INDEX ab(a,b) ); +INSERT INTO t1 VALUES (47,1), (70,1), (15,1), (15, 4); +SELECT * FROM t1 +WHERE +( + ( b =1 AND a BETWEEN 14 AND 21 ) OR + ( b =2 AND a BETWEEN 16 AND 18 ) OR + ( b =3 AND a BETWEEN 15 AND 19 ) OR + (a BETWEEN 19 AND 47) +); diff --git a/sql/mysqld.cc b/sql/mysqld.cc index b0ab59b49e6..68b6b153f5b 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -4747,7 +4747,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), berkeley_env_flags|= DB_TXN_NOSYNC; else berkeley_env_flags&= ~DB_TXN_NOSYNC; - printf("berkeley_env_flags: %d, arg '%s'\n", berkeley_env_flags, argument); break; case OPT_BDB_NO_RECOVER: berkeley_init_flags&= ~(DB_RECOVER); diff --git a/sql/opt_range.cc b/sql/opt_range.cc index bed1b52a79a..188d503b767 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -1710,6 +1710,8 @@ key_or(SEL_ARG *key1,SEL_ARG *key2) return 0; // OOM tmp->copy_max_to_min(&key); tmp->increment_use_count(key1->use_count+1); + /* Increment key count as it may be used for next loop */ + key.increment_use_count(1); new_arg->next_key_part=key_or(tmp->next_key_part,key.next_key_part); key1=key1->insert(new_arg); break; @@ -2708,15 +2710,18 @@ int QUICK_SELECT_DESC::get_next() } else { - /* Heikki changed Sept 11, 2002: since InnoDB does not store the cursor - position if READ_KEY_EXACT is used to a primary key with all - key columns specified, we must use below HA_READ_KEY_OR_NEXT, - so that InnoDB stores the cursor position and is able to move - the cursor one step backward after the search. */ + /* + Heikki changed Sept 11, 2002: since InnoDB does not store the cursor + position if READ_KEY_EXACT is used to a primary key with all + key columns specified, we must use below HA_READ_KEY_OR_NEXT, + so that InnoDB stores the cursor position and is able to move + the cursor one step backward after the search. */ DBUG_ASSERT(range->flag & NEAR_MAX || range_reads_after_key(range)); - /* Note: even if max_key is only a prefix, HA_READ_AFTER_KEY will - * do the right thing - go past all keys which match the prefix */ + /* + Note: even if max_key is only a prefix, HA_READ_AFTER_KEY will + do the right thing - go past all keys which match the prefix + */ result=file->index_read(record, (byte*) range->max_key, range->max_length, ((range->flag & NEAR_MAX) ? diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c index 5cd718f5944..671aa74d806 100644 --- a/strings/ctype-tis620.c +++ b/strings/ctype-tis620.c @@ -449,225 +449,160 @@ uchar NEAR sort_order_tis620[]= (uchar) '\370',(uchar) '\371',(uchar) '\372',(uchar) '\373',(uchar) '\374',(uchar) '\375',(uchar) '\376',(uchar) '\377', }; -/* Convert thai string to "Standard C String Function" sortable string - Arg: const source string and length of converted string - Ret: Sortable string + +/* + Convert thai string to "Standard C String Function" sortable string + Arg: const source string and length of converted string + Ret: Sortable string */ -static void _thai2sortable(uchar *tstr) + +static void _thai2sortable(uchar *tstr) { - uchar *p ; - int len,tlen ; - uchar c,l2bias ; + uchar *p; + int len, tlen; + uchar l2bias; - tlen= len = strlen (tstr) ; - l2bias = 256 - 8 ; - for (p=tstr; tlen > 0; p++,tlen--) - { - c = *p ; - - if (isthai(c)) - { - int *t_ctype0 = t_ctype[c] ; - - if (isconsnt(c)) - l2bias -= 8 ; - if (isldvowel(c) && isconsnt(p[1])) - { - /* - simply swap between leading-vowel and consonant - */ - *p = p[1]; - p[1]= c ; - tlen-- ; - p++; - continue ; - } - - // if found level 2 char (L2_GARAN,L2_TONE*,L2_TYKHU) move to last - if (t_ctype0[1]>= L2_GARAN) - { - // l2bias use to control position weight of l2char - // example (*=l2char) XX*X must come before X*XX - strcpy (p,p+1) ; - tstr[len-1] = l2bias + t_ctype0[1]- L2_GARAN +1 ; - p-- ; - continue ; - } - } - else - { - l2bias -= 8 ; - *p = to_lower_tis620[c]; - } - /* - this routine skip non-printable char - but not necessary, leave it like raw ascii 8 bits - */ - /* - t_ctype0 = t_ctype[p[0]]; - if ((t_ctype0[0]|t_ctype0[1]|t_ctype0[2])==IGNORE) - { - strcpy(p,p+1); - p-- ; - } - */ - } -} - -/* - NOTE: isn't it faster to alloc buffer in calling function? -*/ -/* -Sathit's NOTE: we don't use this function anymore -static uchar* thai2sortable(const uchar * tstr,int len) -{ -*/ -/* We use only 3 levels (neglect capitalization). */ -/* - const uchar* p= tstr; - uchar *outBuf; - uchar *pRight1, *pRight2, *pRight3; - uchar *pLeft1, *pLeft2, *pLeft3; - uint bufSize; - uint RightSize; - - len= (int) strnlen((char*) tstr,len); - bufSize= (uint) buffsize((char*) tstr); - RightSize= sizeof(uchar) * (len + 1); - if (!(outBuf= pLeft1= pRight1= - (uchar *)malloc(sizeof(uchar) * bufSize + RightSize*2))) - return (uchar*) tstr; - pLeft2= pRight2= pRight1 + sizeof(uchar) * bufSize; - pLeft3= pRight3= pRight2 + RightSize; - - while (--len > 0) + tlen= len= strlen (tstr); + l2bias= 256 - 8; + for (p= tstr; tlen > 0; p++, tlen--) { - int *t_ctype0= t_ctype[p[0]]; - if (isldvowel(*p) && isconsnt(p[1])) + uchar c= *p; + + if (isthai(c)) { - int *t_ctype1= t_ctype[p[1]]; - *pRight1++= t_ctype1[0]; - *pRight2++= t_ctype1[1]; - *pRight3++= t_ctype1[2]; - *pRight1++= t_ctype0[0]; - *pRight2++= t_ctype0[1]; - *pRight3++= t_ctype0[2]; - p+= 2; - len--; + int *t_ctype0= t_ctype[c]; + + if (isconsnt(c)) + l2bias -= 8; + if (isldvowel(c) && isconsnt(p[1])) + { + /* simply swap between leading-vowel and consonant */ + *p= p[1]; + p[1]= c; + tlen--; + p++; + continue; + } + + /* if found level 2 char (L2_GARAN,L2_TONE*,L2_TYKHU) move to last */ + if (t_ctype0[1] >= L2_GARAN) + { + /* + l2bias use to control position weight of l2char + example (*=l2char) XX*X must come before X*XX + */ + strmov(p,p+1); + tstr[len-1]= l2bias + t_ctype0[1]- L2_GARAN +1; + p--; + continue; + } } else { - *pRight1= t_ctype0[0]; - if(*pRight1 != IGNORE) - pRight1++; - *pRight2= t_ctype0[1]; - if (*pRight2 != IGNORE) - pRight2++; - *pRight3= t_ctype0[2]; - if(*pRight3 != IGNORE) - pRight3++; - p++; + l2bias-= 8; + *p= to_lower_tis620[c]; } } - if (!len) - { - int *t_ctype0= t_ctype[p[0]]; - *pRight1= t_ctype0[0]; - if (*pRight1 != IGNORE) - pRight1++; - *pRight2= t_ctype0[1]; - if (*pRight2 != IGNORE) - pRight2++; - *pRight3= t_ctype0[2]; - if (*pRight3 != IGNORE) - pRight3++; - } - *pRight1++= L2_BLANK; - *pRight2++= L3_BLANK; - *pRight3++= '\0'; - memcpy(pRight1, pLeft2, pRight2 - pLeft2); - pRight1+= pRight2 - pLeft2; - memcpy(pRight1, pLeft3, pRight3 - pLeft3); - return outBuf; } + + +/* + strncoll() replacement, compare 2 string, both are converted to sortable + string + + Arg: 2 Strings and it compare length + Ret: strcmp result */ -/* strncoll() replacement, compare 2 string, both are conveted to sortable string - Arg: 2 Strings and it compare length - Ret: strcmp result -*/ int my_strnncoll_tis620(const uchar * s1, int len1, const uchar * s2, int len2) { - uchar buf[80] ; - uchar *tc1, *tc2; - int i; + uchar buf[80] ; + uchar *tc1, *tc2; + int i; - len1= (int) strnlen((char*) s1,len1); - len2= (int) strnlen((char*) s2,len2); - if ((len1 + len2 +2) > (int) sizeof(buf)) - tc1 = (uchar *)malloc(len1+len2) ; - else - tc1 = buf ; - tc2 = tc1 + len1+1 ; - strncpy((char *)tc1,(char *)s1,len1) ; - tc1[len1] = 0; // if s1's length > len1, need to put 'end of string' - strncpy((char *)tc2,(char *)s2,len2) ; - tc2[len2] = 0; // put end of string - _thai2sortable(tc1); - _thai2sortable(tc2); - i= strcmp((char*)tc1, (char*)tc2); - if (tc1 != buf ) - free(tc1); - return i; + len1= (int) strnlen((char*) s1,len1); + len2= (int) strnlen((char*) s2,len2); + tc1= buf; + if ((len1 + len2 +2) > (int) sizeof(buf)) + tc1= (uchar*) malloc(len1+len2); + tc2= tc1 + len1+1; + memcpy((char*) tc1, (char*) s1, len1); + tc1[len1]= 0; /* if length(s1)> len1, need to put 'end of string' */ + memcpy((char *)tc2, (char *)s2, len2); + tc2[len2]= 0; /* put end of string */ + _thai2sortable(tc1); + _thai2sortable(tc2); + i= strcmp((char*)tc1, (char*)tc2); + if (tc1 != buf) + free(tc1); + return i; } -/* strnxfrm replacment, convert Thai string to sortable string - Arg: Destination buffer, source string, dest length and source length - Ret: Conveted string size + +/* + strnxfrm replacment, convert Thai string to sortable string + + Arg: Destination buffer, source string, dest length and source length + Ret: Conveted string size */ + int my_strnxfrm_tis620(uchar * dest, const uchar * src, int len, int srclen) { - if (len > srclen) - len = srclen ; - strncpy (dest,src,len) ; - dest[len] = 0; // if src's length > len, need to put 'end of string' - _thai2sortable(dest); - return strlen(dest); + if (len > srclen) + len= srclen ; + strnmov(dest, src, len) ; + dest[len]= 0; /* if length(src) > len, need to put 'end of string' */ + _thai2sortable(dest); + return strlen(dest); } -/* strcoll replacment, compare 2 strings - Arg: 2 strings - Ret: strcmp result + +/* + strcoll replacment, compare 2 strings + Arg: 2 strings + Ret: strcmp result */ + int my_strcoll_tis620(const uchar * s1, const uchar * s2) { - return my_strnncoll_tis620(s1, strlen((char *)s1),s2,strlen((char *)s2)); + return my_strnncoll_tis620(s1, strlen((char *)s1),s2,strlen((char *)s2)); } -/* strxfrm replacment, convert Thai string to sortable string - Arg: Destination buffer, String and dest buffer size - Ret: Converting string size + +/* + strxfrm replacment, convert Thai string to sortable string + + Arg: Destination buffer, String and dest buffer size + Ret: Converting string size */ + int my_strxfrm_tis620(uchar * dest, const uchar * src, int len) { return my_strnxfrm_tis620(dest,src,len,strlen((char *)src)); } -/* Convert SQL like string to C string - Arg: String, its length, escape character, resource length, minimal string and maximum string - Ret: Alway 0 + +/* + Convert SQL LIKE string to C string + + Arg: String, its length, escape character, resource length, + minimal string and maximum string + Ret: Always 0 +*/ + +/* + We just copy this function from opt_range.cc. No need to convert to + thai2sortable string. min_str and max_str will be use for comparison and + converted there. */ -/* We just copy this function from opt_range.cc. No need to convert to - thai2sortable string. min_str and max_str will be use for comparison and - converted there. */ #define max_sort_chr ((char) 255) #define wild_one '_' #define wild_many '%' my_bool my_like_range_tis620(const char *ptr, uint ptr_length, pchar escape, - uint res_length, char *min_str, char *max_str, - uint *min_length, uint *max_length) + uint res_length, char *min_str, char *max_str, + uint *min_length, uint *max_length) { const char *end=ptr+ptr_length; char *min_org=min_str; @@ -692,7 +627,7 @@ my_bool my_like_range_tis620(const char *ptr, uint ptr_length, pchar escape, *min_length= (uint) (min_str - min_org); *max_length=res_length; do { - *min_str++ = ' '; /* Because if key compression */ + *min_str++ = ' '; /* Because of key compression */ *max_str++ = max_sort_chr; } while (min_str != min_end); return 0; @@ -702,18 +637,21 @@ my_bool my_like_range_tis620(const char *ptr, uint ptr_length, pchar escape, *min_length= *max_length = (uint) (min_str - min_org); while (min_str != min_end) - *min_str++ = *max_str++ = ' '; /* Because if key compression */ + *min_str++= *max_str++ = ' '; /* Because of key compression */ return 0; } -/* Thai normalization for input sub system - Arg: Buffer, 's length, String, 'length - Ret: Void + +/* + Thai normalization for input sub system + + Arg: Buffer, 's length, String, 'length */ + void ThNormalize(uchar* ptr, uint field_length, const uchar* from, uint length) { - const uchar* fr= from; - uchar* p= ptr; + const uchar *fr= from; + uchar *p= ptr; uint i; if (length > field_length) @@ -721,24 +659,21 @@ void ThNormalize(uchar* ptr, uint field_length, const uchar* from, uint length) for (i=0;i 0 && (islwrvowel(fr[-1]) || isuprvowel(fr[-1]))) - continue ; - if(islwrvowel(fr[1]) || isuprvowel(fr[1])) - { - *p= fr[1]; - p[1]= *fr; - fr++; - p++; - i++ ; - } + /* Sathit's NOTE: it's better idea not to do any normalize */ + if (istone(*fr) || isdiacrt1(*fr)) + { + if (i > 0 && (islwrvowel(fr[-1]) || isuprvowel(fr[-1]))) + continue; + if(islwrvowel(fr[1]) || isuprvowel(fr[1])) + { + *p= fr[1]; + p[1]= *fr; + fr++; + p++; + i++; + } } - } - } From 180fa5c2047e9162fd82993488257bb138f9d692 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 4 Feb 2004 09:59:18 +0100 Subject: [PATCH 080/113] disabled atof() test as non-portable --- mysql-test/r/bigint.result | 3 --- mysql-test/t/bigint.test | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/bigint.result b/mysql-test/r/bigint.result index f96da579bce..308adc881f2 100644 --- a/mysql-test/r/bigint.result +++ b/mysql-test/r/bigint.result @@ -81,6 +81,3 @@ quantity 10000000000000000000 10000000000000000000 drop table t1; -SELECT '0x8000000000000001'+0; -'0x8000000000000001'+0 -0 diff --git a/mysql-test/t/bigint.test b/mysql-test/t/bigint.test index 0092317dc5e..353e9fd44b1 100644 --- a/mysql-test/t/bigint.test +++ b/mysql-test/t/bigint.test @@ -60,5 +60,6 @@ insert into t1 values ('10000000000000000000'); select * from t1; drop table t1; -SELECT '0x8000000000000001'+0; +# atof() behaviour is different of different systems. to be fixed in 4.1 +#SELECT '0x8000000000000001'+0; From 46f156696fd31e663ed7dbe28583e08e0d06d029 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 4 Feb 2004 14:16:36 +0100 Subject: [PATCH 081/113] Some small enhancements for Do-compile: - more flexible removal of old cruft before creating the new binary distribution - more flexible globbing for the binary tarball (required for QNX, where the file name ends on *.tgz instead of .tar.gz due to file name lenght restrictions Build-tools/Do-compile: Some small enhancements: - more flexible removal of old cruft before creating the new binary distribution - more flexible globbing for the binary tarball (required for QNX, where the file name ends on *.tgz instead of .tar.gz due to file name lenght restrictions --- Build-tools/Do-compile | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Build-tools/Do-compile b/Build-tools/Do-compile index e92654ccffd..bd6c89d7ded 100755 --- a/Build-tools/Do-compile +++ b/Build-tools/Do-compile @@ -280,7 +280,7 @@ if ($opt_stage <= 3) { my $flags= ""; log_timestamp(); - log_system("rm -fr mysql-3* mysql-4* $pwd/$host/*.tar.gz"); + log_system("rm -fr mysql-{3,4,5}* $pwd/$host/mysql*.t*gz"); # No need to add the debug symbols, if the binaries are not stripped (saves space) unless ($opt_with_debug || $opt_no_strip) { @@ -289,7 +289,7 @@ if ($opt_stage <= 3) $flags.= "--no-strip" if ($opt_no_strip || $opt_with_debug); check_system("scripts/make_binary_distribution --tmp=$opt_tmp --suffix=$opt_suffix $flags",".tar.gz created"); - safe_system("mv mysql*.tar.gz $pwd/$host"); + safe_system("mv mysql*.t*gz $pwd/$host"); if (-f "client/.libs/mysqladmin") { safe_system("cp client/.libs/mysqladmin $pwd/$host/bin"); @@ -301,11 +301,8 @@ if ($opt_stage <= 3) safe_system("$make clean") if ($opt_with_small_disk); } -$tar_file=<$pwd/$host/*.tar.gz>; -if (!defined($tar_file)) -{ - $tar_file=<$pwd/$host/*.tgz>; -} +$tar_file=<$pwd/$host/mysql*.t*gz>; +abort ("Could not find tarball!") unless ($tar_file); # # Unpack the binary distribution @@ -318,7 +315,7 @@ if ($opt_stage <= 4 && !$opt_no_test) safe_system("gunzip < $tar_file | $tar xf -"); } -$tar_file =~ /(mysql[^\/]*)\.tar/; +$tar_file =~ /(mysql[^\/]*)\.(tar\.gz|tgz)/; $ver=$1; $test_dir="$pwd/$host/test/$ver"; $ENV{"LD_LIBRARY_PATH"}= ("$test_dir/lib" . From 9d1f86a3a2b19bb6df33475b2fc1712dfe09b744 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 4 Feb 2004 16:50:33 +0100 Subject: [PATCH 082/113] clarify -F help text a bit --- client/mysqldump.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client/mysqldump.c b/client/mysqldump.c index 6078a1e9dc0..34f9b7998d7 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -154,7 +154,10 @@ static struct my_option my_long_options[] = {"first-slave", 'x', "Locks all tables across all databases.", (gptr*) &opt_first_slave, (gptr*) &opt_first_slave, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"flush-logs", 'F', "Flush logs file in server before starting dump. Note that if you use this option in combination with the --all-databases (or -A) option, the logs will be flushed for each database dumped.", + {"flush-logs", 'F', "Flush logs file in server before starting dump. " + "Note that if you dump many databases at once (using the option " + "--databases= or --all-databases), the logs will be flushed for " + "each database dumped.", (gptr*) &flush_logs, (gptr*) &flush_logs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"force", 'f', "Continue even if we get an sql-error.", From c8ff8ec18d96e0482b16a7b40182cfc34fea59db Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 4 Feb 2004 17:42:18 +0100 Subject: [PATCH 083/113] beautify SHOW INDEX --- mysql-test/r/fulltext.result | 6 +++++- mysql-test/t/fulltext.test | 1 + sql/sql_show.cc | 5 ++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result index e8ae9d3063f..651baad266e 100644 --- a/mysql-test/r/fulltext.result +++ b/mysql-test/r/fulltext.result @@ -5,6 +5,10 @@ INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'), ('Only MyISAM tables','support collections'), ('Function MATCH ... AGAINST()','is used to do a search'), ('Full-text search in MySQL', 'implements vector space model'); +SHOW INDEX FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t1 1 a 1 a A NULL NULL NULL YES FULLTEXT +t1 1 a 2 b A NULL NULL NULL YES FULLTEXT select * from t1 where MATCH(a,b) AGAINST ("collections"); a b Only MyISAM tables support collections @@ -183,7 +187,7 @@ id show keys from t2; Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment t2 1 tig 1 ticket A NULL NULL NULL YES BTREE -t2 1 tix 1 inhalt A NULL 1 NULL YES FULLTEXT +t2 1 tix 1 inhalt A NULL NULL NULL YES FULLTEXT show create table t2; Table Create Table t2 CREATE TABLE `t2` ( diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test index e8f5d497692..02657ba3775 100644 --- a/mysql-test/t/fulltext.test +++ b/mysql-test/t/fulltext.test @@ -10,6 +10,7 @@ INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'), ('Only MyISAM tables','support collections'), ('Function MATCH ... AGAINST()','is used to do a search'), ('Full-text search in MySQL', 'implements vector space model'); +SHOW INDEX FROM t1; # nl search diff --git a/sql/sql_show.cc b/sql/sql_show.cc index f62853ce9d6..3d727a33173 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -726,9 +726,8 @@ mysqld_show_keys(THD *thd, TABLE_LIST *table_list) net_store_null(packet); /* Check if we have a key part that only uses part of the field */ - if (!key_part->field || - key_part->length != - table->field[key_part->fieldnr-1]->key_length()) + if (!(key_info->flags & HA_FULLTEXT) && (!key_part->field || + key_part->length != table->field[key_part->fieldnr-1]->key_length())) { end=int10_to_str((long) key_part->length, buff,10); /* purecov: inspected */ net_store_data(packet,convert,buff,(uint) (end-buff)); /* purecov: inspected */ From 22b2067aa5cce55ea4652cb915f5ba99d9caa4a6 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 4 Feb 2004 21:35:20 +0400 Subject: [PATCH 084/113] added checking for bootstrap in select_send::send_data (fixed bug #2526 "--init-file crashes MySQL if contains large select") Such checking usually works in send_ok, send_eof, but in this case large result causes interim flushing. sql/sql_class.cc: added checking for bootstrap in select_send::send_data --- mysql-test/t/init_file-master.opt | 1 + mysql-test/t/init_file.sql | 1 + mysql-test/t/init_file.test | 12 ++++++++++++ sql/sql_class.cc | 2 ++ 4 files changed, 16 insertions(+) create mode 100644 mysql-test/t/init_file-master.opt create mode 100644 mysql-test/t/init_file.sql create mode 100644 mysql-test/t/init_file.test diff --git a/mysql-test/t/init_file-master.opt b/mysql-test/t/init_file-master.opt new file mode 100644 index 00000000000..1542f1f034e --- /dev/null +++ b/mysql-test/t/init_file-master.opt @@ -0,0 +1 @@ +--init-file=$MYSQL_TEST_DIR/t/init_file.sql \ No newline at end of file diff --git a/mysql-test/t/init_file.sql b/mysql-test/t/init_file.sql new file mode 100644 index 00000000000..4236ada1142 --- /dev/null +++ b/mysql-test/t/init_file.sql @@ -0,0 +1 @@ +select * from mysql.user as t1, mysql.user as t2, mysql.user as t3, mysql.user as t4, mysql.user as t5, mysql.user as t6, mysql.user as t7, mysql.user as t8; \ No newline at end of file diff --git a/mysql-test/t/init_file.test b/mysql-test/t/init_file.test new file mode 100644 index 00000000000..8cfb8c490e2 --- /dev/null +++ b/mysql-test/t/init_file.test @@ -0,0 +1,12 @@ +# +# This test is first part of test init_file_part2.test (bug #2526) +# + +#DROP TABLE IF EXISTS t1; + +#CREATE TABLE t1 +#( +# i int(11) default NULL +#) TYPE=MyISAM; + +#INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); \ No newline at end of file diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 3ea61da28fc..fac99be47a8 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -495,6 +495,8 @@ bool select_send::send_data(List &items) } } thd->sent_row_count++; + if (thd->bootstrap) + DBUG_RETURN(0); bool error=my_net_write(&thd->net,(char*) packet->ptr(),packet->length()); DBUG_RETURN(error); } From 883ef70c34c4f899b813841c23f950e44e2a1e7f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 4 Feb 2004 13:39:01 -0400 Subject: [PATCH 085/113] For to export the right functions with changes done from 4.0.16 --- libmysql/libmysql.def | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libmysql/libmysql.def b/libmysql/libmysql.def index 542ab890e95..721097905a8 100644 --- a/libmysql/libmysql.def +++ b/libmysql/libmysql.def @@ -68,8 +68,8 @@ EXPORTS my_memdup my_no_flags_free my_realloc - my_thread_end - my_thread_init + mysql_thread_end + mysql_thread_init net_buffer_length set_dynamic strcend From 91f51913fe8366b0c9c2e008a2a50f535e3b8e2e Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 4 Feb 2004 20:51:26 +0300 Subject: [PATCH 086/113] Fix for bug #2214: "CC: ERROR File = item.h, Line = 401 The identifier strtoll is undefined" (compilation failure on SGI IRIX + MIPSPro 7.41) Compilation script implemented. Tested in 32 and 64 bit mode configure.in: Fix for bug #2214: we should not reset CXXFLAGS on IRIX for build script to work --- BUILD/compile-irix-mips64-mipspro | 84 +++++++++++++++++++++++++++++++ configure.in | 2 +- 2 files changed, 85 insertions(+), 1 deletion(-) create mode 100755 BUILD/compile-irix-mips64-mipspro diff --git a/BUILD/compile-irix-mips64-mipspro b/BUILD/compile-irix-mips64-mipspro new file mode 100755 index 00000000000..d8107ad73c0 --- /dev/null +++ b/BUILD/compile-irix-mips64-mipspro @@ -0,0 +1,84 @@ +#!/bin/sh + +if [ ! -f "sql/mysqld.cc" ]; then + echo "You must run this script from the MySQL top-level directory." + exit 1 +fi + +cflags="-64 -mips4" + +if [ "$#" != 0 ]; then + case "$1" in + --help) + echo "Usage: $0 [options]" + echo "Options:" + echo "--help print this message" + echo "-32 build 32-bit binary" + echo "-64 build 64-bit binary [default]" + exit 0 + ;; + -64) + echo "Building 64-bit binary" + ;; + -32) + echo "Building 32-bit binary" + cflags="" + ;; + *) + echo "$0: invalid option '$1'; use --help to show usage" + exit 1 + ;; + esac +else + echo "Building 64-bit binary" +fi + +set -x +make distclean +aclocal +autoheader +libtoolize --automake --force +automake --force --add-missing +autoconf + +(cd bdb/dist && sh s_all) +(cd innobase && aclocal && autoheader && aclocal && automake && autoconf) + +# C options: +# -apo - auto-parallize for multiprocessors (implies -mp) +# -mp - generate multiprocessor code +# These two common optimization options apparently use 'sproc' model of +# threading, which is not compatible with PTHREADS: don't add them unless you +# know what you're doing. +# +# -c99 - enable C features standardized in C99, such as long long, +# strtoll, stroull etc. +# This option is vital to compile MySQL. +# -woff - turn off some warnings +# -64 - generate 64 bit object (implies -mips4) +# -mips4 - produce code for MIPS R10000, MIPS R12000 and further 64 bit +# processors +# -OPT:Olimit=0 - no limits exists to size of function for compiler to optimize +# it +nowarn="-woff 1064,1188,1460,1552,1681,1682,3303" +cflags="$cflags $nowarn -O3 -c99 -OPT:Olimit=0" + +# C++ only options: +# -LANG:exceptions=OFF - don't generate exception handling code +# MySQL doesn't use exceptions. +# -LANG:std=OFF - don't link standard C++ library, such as +# , , etc. +# -LANG:libc_in_namespace_std=OFF - libstdc functions can be +# declared in namespace 'std', when included +# into C++ code. Switch this feature off. +# This option is vital to compile MySQL + +cxxflags="$cflags -LANG:exceptions=OFF -LANG:std=OFF" +cxxflags="$cxxflags -LANG:libc_in_namespace_std=OFF" + +CC=cc CXX=CC CFLAGS="$cflags" CXXFLAGS="$cxxflags" \ +./configure --prefix=/usr/local/mysql --disable-shared \ + --with-extra-charsets=complex --enable-thread-safe-client \ + --without-extra-tools --disable-dependency-tracking + +make diff --git a/configure.in b/configure.in index fd9f6a4f721..bc9bad931ad 100644 --- a/configure.in +++ b/configure.in @@ -1053,7 +1053,7 @@ case $SYSTEM_TYPE in echo "Using --with-named-thread=-lpthread" with_named_thread="-lpthread" fi - CXXFLAGS="-D_BOOL" + CXXFLAGS="$CXXFLAGS -D_BOOL" ;; *aix4.3*) echo "Adding defines for AIX" From 68d61d5b8fe1ddb2e4a0dd243623528e6aed70fd Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 4 Feb 2004 21:26:52 +0100 Subject: [PATCH 087/113] - don't add merge ChangeSets to the Changelog in Bootstrap (reduce the noise) Build-tools/Bootstrap: - don't add merge ChangeSets to the Changelog (reduce the noise) --- Build-tools/Bootstrap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Build-tools/Bootstrap b/Build-tools/Bootstrap index 930d053b113..a46d83ca91c 100755 --- a/Build-tools/Bootstrap +++ b/Build-tools/Bootstrap @@ -257,7 +257,7 @@ if (defined $opt_changelog) $msg= "Adding $target_dir/ChangeLog"; $msg.= " (down to revision $opt_changelog)" if $opt_changelog ne ""; &logger($msg); - $command= "bk changes -v"; + $command= "bk changes -mv"; $command.= " -r" if ($opt_changelog ne "" || $opt_revision); $command.= $opt_changelog if $opt_changelog ne ""; $command.= ".." if ($opt_changelog ne "" && !$opt_revision); From d295f07c4281a45fc45aff95a151aeee117b2d8a Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 5 Feb 2004 09:12:23 +0100 Subject: [PATCH 088/113] Added testing of pthread_key_delete (to fix compile problem on SCO) (Bug #2461) DROP DATABASE now assumes RAID directories are in hex. (Bug #2627) Don't increment 'select_full_range' and similar statistics for EXPLAIN queries. (Bug #2506) Test in configure if pthread_key_delete() exists (to fix compile problem on SCO) (Bug #2461) BUILD/compile-pentium-max: Added --with-raid configure.in: Added testing of pthread_key_delete (to fix compile problem on SCO) (Bug #2461) include/my_pthread.h: Added testing of pthread_key_delete (to fix compile problem on SCO) (Bug #2461) innobase/include/data0data.ic: Added missing newline mysql-test/r/raid.result: Test of DROP DATABASE with RAID directories in hex mysql-test/t/raid.test: Test of DROP DATABASE with RAID directories in hex sql/sql_db.cc: DROP DATABASE could not drop databases with RAID tables that had more than 9 RAID_CHUNKS because DROP DATABASE assumed raid tables where in decimal while the RAID CREATE code assumed directories was in hex.(Bug #2627) sql/sql_select.cc: Don't increment 'select_full_range' and similar statistics for EXPLAIN queries. (Bug #2506) sql/sql_udf.cc: mysqld crashed if mysql.func table didn't exists (Bug #2577) --- BUILD/compile-pentium-max | 2 +- configure.in | 2 +- include/my_pthread.h | 5 +++++ innobase/include/data0data.ic | 2 +- mysql-test/r/raid.result | 1 + mysql-test/t/raid.test | 1 + sql/sql_db.cc | 7 +++++-- sql/sql_select.cc | 17 ++++++++++++----- sql/sql_udf.cc | 11 ++++++----- 9 files changed, 33 insertions(+), 15 deletions(-) diff --git a/BUILD/compile-pentium-max b/BUILD/compile-pentium-max index d41274d4f5e..34a497807df 100755 --- a/BUILD/compile-pentium-max +++ b/BUILD/compile-pentium-max @@ -9,6 +9,6 @@ strip=yes extra_configs="$extra_configs --with-innodb --with-berkeley-db \ --with-embedded-server --enable-thread-safe-client \ - --with-openssl --with-vio" + --with-openssl --with-vio --with-raid" . "$path/FINISH.sh" diff --git a/configure.in b/configure.in index bc9bad931ad..86a3daf84da 100644 --- a/configure.in +++ b/configure.in @@ -1815,7 +1815,7 @@ AC_CHECK_FUNCS(alarm bmove \ sigset sigthreadmask pthread_sigmask pthread_setprio pthread_setprio_np \ pthread_setschedparam pthread_attr_setprio pthread_attr_setschedparam \ pthread_attr_create pthread_getsequence_np pthread_attr_setstacksize \ - pthread_attr_getstacksize \ + pthread_attr_getstacksize pthread_key_delete \ pthread_condattr_create rwlock_init pthread_rwlock_rdlock \ fsync fdatasync fchmod getpass getpassphrase initgroups mlockall) diff --git a/include/my_pthread.h b/include/my_pthread.h index 59367ee903c..40302f48bd5 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -384,6 +384,11 @@ struct tm *localtime_r(const time_t *clock, struct tm *res); #define pthread_condattr_destroy pthread_condattr_delete #endif +/* FSU THREADS */ +#if !defined(HAVE_PTHREAD_KEY_DELETE) && !defined(pthread_key_delete) +#define pthread_key_delete(A) pthread_dummy(0) +#endif + #ifdef HAVE_CTHREADS_WRAPPER /* For MacOSX */ #define pthread_cond_destroy(A) pthread_dummy(0) #define pthread_mutex_destroy(A) pthread_dummy(0) diff --git a/innobase/include/data0data.ic b/innobase/include/data0data.ic index bc5a93cb2f8..def80d3f430 100644 --- a/innobase/include/data0data.ic +++ b/innobase/include/data0data.ic @@ -430,4 +430,4 @@ dtuple_contains_null( } return(FALSE); -} \ No newline at end of file +} diff --git a/mysql-test/r/raid.result b/mysql-test/r/raid.result index fd47a9451f6..3d27a599cf3 100644 --- a/mysql-test/r/raid.result +++ b/mysql-test/r/raid.result @@ -1,5 +1,6 @@ create database test_raid; create table test_raid.r1 (i int) raid_type=1; +create table test_raid.r2 (i int) raid_type=1 raid_chunks=32; drop database test_raid; DROP TABLE IF EXISTS t1,t2; CREATE TABLE t1 ( diff --git a/mysql-test/t/raid.test b/mysql-test/t/raid.test index 4032993f2da..43ad58ab368 100644 --- a/mysql-test/t/raid.test +++ b/mysql-test/t/raid.test @@ -9,6 +9,7 @@ enable_query_log; create database test_raid; create table test_raid.r1 (i int) raid_type=1; +create table test_raid.r2 (i int) raid_type=1 raid_chunks=32; drop database test_raid; DROP TABLE IF EXISTS t1,t2; CREATE TABLE t1 ( diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 3fa3f5b0907..ca9989d986c 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -219,7 +219,7 @@ exit2: /* Removes files with known extensions plus all found subdirectories that - are 2 digits (raid directories). + are 2 hex digits (raid directories). thd MUST be set when calling this function! */ @@ -245,7 +245,10 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db, DBUG_PRINT("info",("Examining: %s", file->name)); /* Check if file is a raid directory */ - if (isdigit(file->name[0]) && isdigit(file->name[1]) && + if ((isdigit(file->name[0]) || + (file->name[0] >= 'a' && file->name[0] <= 'f')) && + (isdigit(file->name[1]) || + (file->name[1] >= 'a' && file->name[1] <= 'f')) && !file->name[2] && !level) { char newpath[FN_REFLEN]; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 36ef97cbf30..3e824ddc9f5 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2823,6 +2823,8 @@ make_join_readinfo(JOIN *join,uint options) { uint i; SELECT_LEX *select_lex = &(join->thd->lex.select_lex); + bool statistics= test(!(join->select_options & SELECT_DESCRIBE)); + DBUG_ENTER("make_join_readinfo"); for (i=join->const_tables ; i < join->tables ; i++) @@ -2907,7 +2909,8 @@ make_join_readinfo(JOIN *join,uint options) { select_lex->options|=QUERY_NO_GOOD_INDEX_USED; tab->read_first_record= join_init_quick_read_record; - statistic_increment(select_range_check_count, &LOCK_status); + if (statistics) + statistic_increment(select_range_check_count, &LOCK_status); } else { @@ -2916,24 +2919,28 @@ make_join_readinfo(JOIN *join,uint options) { if (tab->select && tab->select->quick) { - statistic_increment(select_range_count, &LOCK_status); + if (statistics) + statistic_increment(select_range_count, &LOCK_status); } else { select_lex->options|=QUERY_NO_INDEX_USED; - statistic_increment(select_scan_count, &LOCK_status); + if (statistics) + statistic_increment(select_scan_count, &LOCK_status); } } else { if (tab->select && tab->select->quick) { - statistic_increment(select_full_range_join_count, &LOCK_status); + if (statistics) + statistic_increment(select_full_range_join_count, &LOCK_status); } else { select_lex->options|=QUERY_NO_INDEX_USED; - statistic_increment(select_full_join_count, &LOCK_status); + if (statistics) + statistic_increment(select_full_join_count, &LOCK_status); } } if (!table->no_keyread) diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index 54613f82f00..431f8a13d28 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -116,6 +116,7 @@ void udf_init() udf_func *tmp; TABLE_LIST tables; READ_RECORD read_record_info; + TABLE *table; int error; DBUG_ENTER("ufd_init"); @@ -148,13 +149,11 @@ void udf_init() if (open_and_lock_tables(new_thd, &tables)) { DBUG_PRINT("error",("Can't open udf table")); - sql_print_error("Can't open mysql/func table"); - close_thread_tables(new_thd); - delete new_thd; - DBUG_VOID_RETURN; + sql_print_error("Can't open the mysql/func table. Please run the mysql_install_db script to create it."); + goto end; } - TABLE *table = tables.table; + table= tables.table; init_read_record(&read_record_info, new_thd, table, NULL,1,0); while (!(error = read_record_info.read_record(&read_record_info))) { @@ -200,6 +199,8 @@ void udf_init() sql_print_error(ER(ER_GET_ERRNO), my_errno); end_read_record(&read_record_info); new_thd->version--; // Force close to free memory + +end: close_thread_tables(new_thd); delete new_thd; /* Remember that we don't have a THD */ From b911f9b0c0783e07f6bc9f091c9b5855730d88ba Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 5 Feb 2004 17:52:41 +0400 Subject: [PATCH 089/113] code cleanup --- mysql-test/t/init_file.test | 12 ++---------- sql/sql_class.cc | 2 +- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/mysql-test/t/init_file.test b/mysql-test/t/init_file.test index 8cfb8c490e2..eb4c24871db 100644 --- a/mysql-test/t/init_file.test +++ b/mysql-test/t/init_file.test @@ -1,12 +1,4 @@ # -# This test is first part of test init_file_part2.test (bug #2526) +# This test is for bug #2526 "--init-file crashes MySQL if contains large select" +# Have a look at code in init_file.sql # - -#DROP TABLE IF EXISTS t1; - -#CREATE TABLE t1 -#( -# i int(11) default NULL -#) TYPE=MyISAM; - -#INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10); \ No newline at end of file diff --git a/sql/sql_class.cc b/sql/sql_class.cc index fac99be47a8..c45167e82da 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -495,7 +495,7 @@ bool select_send::send_data(List &items) } } thd->sent_row_count++; - if (thd->bootstrap) + if (!thd->net.vio) DBUG_RETURN(0); bool error=my_net_write(&thd->net,(char*) packet->ptr(),packet->length()); DBUG_RETURN(error); From e55558150dec973496d153e9804b29518c6704cb Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 5 Feb 2004 16:04:43 +0200 Subject: [PATCH 090/113] sql_load.cc: Added a comment for already pushed bug fix sql/sql_load.cc: Added a comment for already pushed bug fix --- sql/sql_load.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 93dfcd84caf..3b8672188d4 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -93,6 +93,11 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, char *db = table_list->db; // This is never null /* If no current database, use database where table is located */ char *tdb= thd->db ? thd->db : db; + /* + 'tdb' can be NULL only if both table_list->db and thd->db are NULL + 'db' itself can be NULL. but in that case it will generate + an error earlier open_ltable()). + */ bool transactional_table, log_delayed; ulong skip_lines= ex->skip_lines; DBUG_ENTER("mysql_load"); From b40d4e127aea7beab7a81eb2a4588046fd58f129 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 5 Feb 2004 23:13:04 +0100 Subject: [PATCH 091/113] include atomic.h in extern "C" mode --- include/my_global.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/my_global.h b/include/my_global.h index 168961a620d..e4c0fb44337 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -273,7 +273,9 @@ C_MODE_END #ifndef CONFIG_SMP #define CONFIG_SMP #endif +C_MODE_START #include +C_MODE_END #endif #include /* Recommended by debian */ /* We need the following to go around a problem with openssl on solaris */ From 62a4ae0761bc76326e3afc3d4fb7d598e593c3e8 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 5 Feb 2004 23:36:54 +0100 Subject: [PATCH 092/113] - renamed mysql-test/t/init_file.sql to mysql-test/std_data/init_file.dat so it gets picked up by "make dist" and updated init_file test accordingly. mysql-test/std_data/init_file.dat: Rename: mysql-test/t/init_file.sql -> mysql-test/std_data/init_file.dat mysql-test/t/init_file-master.opt: - moved init file to std_data mysql-test/t/init_file.test: - updated info --- mysql-test/{t/init_file.sql => std_data/init_file.dat} | 0 mysql-test/t/init_file-master.opt | 2 +- mysql-test/t/init_file.test | 7 +++++-- 3 files changed, 6 insertions(+), 3 deletions(-) rename mysql-test/{t/init_file.sql => std_data/init_file.dat} (100%) diff --git a/mysql-test/t/init_file.sql b/mysql-test/std_data/init_file.dat similarity index 100% rename from mysql-test/t/init_file.sql rename to mysql-test/std_data/init_file.dat diff --git a/mysql-test/t/init_file-master.opt b/mysql-test/t/init_file-master.opt index 1542f1f034e..825311dabf2 100644 --- a/mysql-test/t/init_file-master.opt +++ b/mysql-test/t/init_file-master.opt @@ -1 +1 @@ ---init-file=$MYSQL_TEST_DIR/t/init_file.sql \ No newline at end of file +--init-file=$MYSQL_TEST_DIR/std_data/init_file.dat diff --git a/mysql-test/t/init_file.test b/mysql-test/t/init_file.test index eb4c24871db..604d0a01794 100644 --- a/mysql-test/t/init_file.test +++ b/mysql-test/t/init_file.test @@ -1,4 +1,7 @@ # -# This test is for bug #2526 "--init-file crashes MySQL if contains large select" -# Have a look at code in init_file.sql +# This is a regression test for bug #2526 "--init-file crashes MySQL if it +# contains a large select" +# +# See mysql-test/std_data/init_file.dat and +# mysql-test/t/init_file-master.opt for the actual test # From 15b89bfc5981ad348220fbf3f7067b7465d71080 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 6 Feb 2004 00:58:15 +0100 Subject: [PATCH 093/113] - updated config.guess, config.sub and ltmain.sh with versions from libtool 1.5 to fix BUG#202 (update config.guess & co for MIPS architecture) config.guess: - upplied diffs from libtool 1.5 config.sub: - upplied diffs from libtool 1.5 ltmain.sh: - upplied diffs from libtool 1.5 --- config.guess | 554 +++++----- config.sub | 303 ++++-- ltmain.sh | 2752 +++++++++++++++++++++++++++++++++++++------------- 3 files changed, 2541 insertions(+), 1068 deletions(-) diff --git a/config.guess b/config.guess index 27ccc69772b..ef65f9b4ea9 100755 --- a/config.guess +++ b/config.guess @@ -1,9 +1,9 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 -# Free Software Foundation, Inc. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003 Free Software Foundation, Inc. -timestamp='2001-08-21' +timestamp='2003-07-02' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -24,8 +24,9 @@ timestamp='2001-08-21' # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. -# Written by Per Bothner . -# Please send patches to . +# Originally written by Per Bothner . +# Please send patches to . Submit a context +# diff and a properly formatted ChangeLog entry. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and @@ -87,30 +88,42 @@ if test $# != 0; then exit 1 fi +trap 'exit 1' 1 2 15 -dummy=dummy-$$ -trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15 +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. -# CC_FOR_BUILD -- compiler used by this script. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. -set_cc_for_build='case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int dummy(){}" > $dummy.c ; - for c in cc gcc c89 ; do - ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 ; - if test $? = 0 ; then +# Portable tmp directory creation inspired by the Autoconf team. + +set_cc_for_build=' +trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +: ${TMPDIR=/tmp} ; + { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; +dummy=$tmp/dummy ; +tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; +case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int x;" > $dummy.c ; + for c in cc gcc c89 c99 ; do + if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; - rm -f $dummy.c $dummy.o $dummy.rel ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac' +esac ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) @@ -136,29 +149,30 @@ esac case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) - # Netbsd (nbsd) targets should (where applicable) match one or + # NetBSD (nbsd) targets should (where applicable) match one or # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. - # Determine the machine/vendor (is the vendor relevant). - case "${UNAME_MACHINE}" in - amiga) machine=m68k-unknown ;; - arm32) machine=arm-unknown ;; - atari*) machine=m68k-atari ;; - sun3*) machine=m68k-sun ;; - mac68k) machine=m68k-apple ;; - macppc) machine=powerpc-apple ;; - hp3[0-9][05]) machine=m68k-hp ;; - ibmrt|romp-ibm) machine=romp-ibm ;; - *) machine=${UNAME_MACHINE}-unknown ;; + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || echo unknown)` + case "${UNAME_MACHINE_ARCH}" in + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. - case "${UNAME_MACHINE}" in - i386|sparc|amiga|arm*|hp300|mvme68k|vax|atari|luna68k|mac68k|news68k|next68k|pc532|sun3*|x68k) + case "${UNAME_MACHINE_ARCH}" in + arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep __ELF__ >/dev/null @@ -175,75 +189,112 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in ;; esac # The OS release - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "${UNAME_VERSION}" in + Debian*) + release='-gnu' + ;; + *) + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + ;; + esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit 0 ;; + amiga:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + arc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + hp300:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mac68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + macppc:OpenBSD:*:*) + echo powerpc-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme88k:OpenBSD:*:*) + echo m88k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvmeppc:OpenBSD:*:*) + echo powerpc-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + pmax:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sgi:OpenBSD:*:*) + echo mipseb-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sun3:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + wgrisc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + *:OpenBSD:*:*) + echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; alpha:OSF1:*:*) if test $UNAME_RELEASE = "V4.0"; then UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` fi + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case "$ALPHA_CPU_TYPE" in + "EV4 (21064)") + UNAME_MACHINE="alpha" ;; + "EV4.5 (21064)") + UNAME_MACHINE="alpha" ;; + "LCA4 (21066/21068)") + UNAME_MACHINE="alpha" ;; + "EV5 (21164)") + UNAME_MACHINE="alphaev5" ;; + "EV5.6 (21164A)") + UNAME_MACHINE="alphaev56" ;; + "EV5.6 (21164PC)") + UNAME_MACHINE="alphapca56" ;; + "EV5.7 (21164PC)") + UNAME_MACHINE="alphapca57" ;; + "EV6 (21264)") + UNAME_MACHINE="alphaev6" ;; + "EV6.7 (21264A)") + UNAME_MACHINE="alphaev67" ;; + "EV6.8CB (21264C)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8AL (21264B)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8CX (21264D)") + UNAME_MACHINE="alphaev68" ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE="alphaev69" ;; + "EV7 (21364)") + UNAME_MACHINE="alphaev7" ;; + "EV7.9 (21364A)") + UNAME_MACHINE="alphaev79" ;; + esac # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. - cat <$dummy.s - .data -\$Lformat: - .byte 37,100,45,37,120,10,0 # "%d-%x\n" - - .text - .globl main - .align 4 - .ent main -main: - .frame \$30,16,\$26,0 - ldgp \$29,0(\$27) - .prologue 1 - .long 0x47e03d80 # implver \$0 - lda \$2,-1 - .long 0x47e20c21 # amask \$2,\$1 - lda \$16,\$Lformat - mov \$0,\$17 - not \$1,\$18 - jsr \$26,printf - ldgp \$29,0(\$26) - mov 0,\$16 - jsr \$26,exit - .end main -EOF - eval $set_cc_for_build - $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null - if test "$?" = 0 ; then - case `./$dummy` in - 0-0) - UNAME_MACHINE="alpha" - ;; - 1-0) - UNAME_MACHINE="alphaev5" - ;; - 1-1) - UNAME_MACHINE="alphaev56" - ;; - 1-101) - UNAME_MACHINE="alphapca56" - ;; - 2-303) - UNAME_MACHINE="alphaev6" - ;; - 2-307) - UNAME_MACHINE="alphaev67" - ;; - 2-1307) - UNAME_MACHINE="alphaev68" - ;; - esac - fi - rm -f $dummy.s $dummy echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` exit 0 ;; + Alpha*:OpenVMS:*:*) + echo alpha-hp-vms + exit 0 ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead @@ -256,29 +307,11 @@ EOF Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit 0;; - amiga:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit 0 ;; - arc64:OpenBSD:*:*) - echo mips64el-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - arc:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - hkmips:OpenBSD:*:*) - echo mips-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - pmax:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - sgi:OpenBSD:*:*) - echo mips-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - wgrisc:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} + *:[Mm]orph[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-morphos exit 0 ;; *:OS/390:*:*) echo i370-ibm-openedition @@ -300,6 +333,13 @@ EOF NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit 0 ;; + DRS?6000:unix:4.0:6*) + echo sparc-icl-nx6 + exit 0 ;; + DRS?6000:UNIX_SV:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7 && exit 0 ;; + esac ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; @@ -328,7 +368,7 @@ EOF echo m68k-sun-sunos${UNAME_RELEASE} exit 0 ;; sun*:*:4.2BSD:*) - UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) @@ -342,12 +382,6 @@ EOF aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit 0 ;; - sparc*:NetBSD:*) - echo `uname -p`-unknown-netbsd${UNAME_RELEASE} - exit 0 ;; - atari*:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor @@ -374,18 +408,6 @@ EOF *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit 0 ;; - sun3*:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mac68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme88k:OpenBSD:*:*) - echo m88k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit 0 ;; @@ -402,6 +424,7 @@ EOF echo clipper-intergraph-clix${UNAME_RELEASE} exit 0 ;; mips:*:*:UMIPS | mips:*:*:RISCos) + eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ @@ -423,16 +446,20 @@ EOF exit (-1); } EOF - eval $set_cc_for_build - $CC_FOR_BUILD $dummy.c -o $dummy \ - && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ - && rm -f $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy + $CC_FOR_BUILD -o $dummy $dummy.c \ + && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ + && exit 0 echo mips-mips-riscos${UNAME_RELEASE} exit 0 ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit 0 ;; + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit 0 ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + echo powerpc-harris-powermax + exit 0 ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit 0 ;; @@ -493,6 +520,7 @@ EOF exit 0 ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include @@ -504,9 +532,7 @@ EOF exit(0); } EOF - eval $set_cc_for_build - $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy + $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 echo rs6000-ibm-aix3.2.5 elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 @@ -515,7 +541,7 @@ EOF fi exit 0 ;; *:AIX:*:[45]) - IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'` + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else @@ -555,10 +581,8 @@ EOF 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) - case "${HPUX_REV}" in - 11.[0-9][0-9]) - if [ -x /usr/bin/getconf ]; then - sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 @@ -567,12 +591,13 @@ EOF case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; + '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac - fi ;; - esac - if [ "${HP_ARCH}" = "" ]; then - sed 's/^ //' << EOF >$dummy.c + fi + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include @@ -605,12 +630,21 @@ EOF exit (0); } EOF - eval $set_cc_for_build - (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy` - if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi - rm -f $dummy.c $dummy - fi ;; + (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; esac + if [ ${HP_ARCH} = "hppa2.0w" ] + then + # avoid double evaluation of $set_cc_for_build + test -n "$CC_FOR_BUILD" || eval $set_cc_for_build + if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ >/dev/null + then + HP_ARCH="hppa2.0w" + else + HP_ARCH="hppa64" + fi + fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit 0 ;; ia64:HP-UX:*:*) @@ -618,6 +652,7 @@ EOF echo ia64-hp-hpux${HPUX_REV} exit 0 ;; 3050*:HI-UX:*:*) + eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int @@ -643,9 +678,7 @@ EOF exit (0); } EOF - eval $set_cc_for_build - $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy + $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 echo unknown-hitachi-hiuxwe2 exit 0 ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) @@ -673,9 +706,6 @@ EOF parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit 0 ;; - hppa*:OpenBSD:*:*) - echo hppa-unknown-openbsd - exit 0 ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit 0 ;; @@ -694,9 +724,6 @@ EOF C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit 0 ;; - CRAY*X-MP:*:*:*) - echo xmp-cray-unicos - exit 0 ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; @@ -709,27 +736,21 @@ EOF CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; - CRAY*T3D:*:*:*) - echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; - CRAY-2:*:*:*) - echo cray2-cray-unicos - exit 0 ;; + *:UNICOS/mp:*:*) + echo nv1-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit 0 ;; - hp300:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit 0 ;; @@ -739,11 +760,22 @@ EOF *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit 0 ;; - *:FreeBSD:*:*) - echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit 0 ;; - *:OpenBSD:*:*) - echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + *:FreeBSD:*:*|*:GNU/FreeBSD:*:*) + # Determine whether the default compiler uses glibc. + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + #if __GLIBC__ >= 2 + LIBC=gnu + #else + LIBC= + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` + # GNU/FreeBSD systems have a "k" prefix to indicate we are using + # FreeBSD's kernel, but not the complete OS. + case ${LIBC} in gnu) kernel_only='k' ;; esac + echo ${UNAME_MACHINE}-unknown-${kernel_only}freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC} exit 0 ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin @@ -754,11 +786,17 @@ EOF i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit 0 ;; + x86:Interix*:[34]*) + echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//' + exit 0 ;; + [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) + echo i${UNAME_MACHINE}-pc-mks + exit 0 ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? - echo i386-pc-interix + echo i586-pc-interix exit 0 ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin @@ -778,6 +816,9 @@ EOF arm*:Linux:*:*) echo ${UNAME_MACHINE}-${VENDOR}-linux exit 0 ;; + cris:Linux:*:*) + echo cris-axis-linux + exit 0 ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-${VENDOR}-linux exit 0 ;; @@ -785,19 +826,48 @@ EOF echo ${UNAME_MACHINE}-${VENDOR}-linux exit 0 ;; mips:Linux:*:*) - case `sed -n '/^byte/s/^.*: \(.*\) endian/\1/p' < /proc/cpuinfo` in - big) echo mips-${VENDOR}-linux && exit 0 ;; - little) echo mipsel-${VENDOR}-linux && exit 0 ;; - esac - case `sed -n '/^system type/s/^.*: \([^ ]*\).*/\1/p' < /proc/cpuinfo` in - SGI|sgi) echo mips-${VENDOR}-linux-gnu && exit 0 ;; - esac + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips + #undef mipsel + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mipsel + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` + test x"${CPU}" != x && echo "${CPU}-${VENDOR}-linux" && exit 0 ;; - ppc:Linux:*:*|ppc64:Linux:*:*) + mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips64 + #undef mips64el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mips64el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips64 + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` + test x"${CPU}" != x && echo "${CPU}-${VENDOR}-linux" && exit 0 + ;; + ppc:Linux:*:*) echo powerpc-${VENDOR}-linux exit 0 ;; ppc64:Linux:*:*) - echo powerpc64-unknown-linux-gnu + echo powerpc64-${VENDOR}-linux exit 0 ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in @@ -810,7 +880,7 @@ EOF EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null - if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi + if test "$?" = 0 ; then LIBC="-libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-${VENDOR}-linux${LIBC} exit 0 ;; parisc:Linux:*:* | hppa:Linux:*:*) @@ -827,6 +897,9 @@ EOF s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit 0 ;; + sh64*:Linux:*:*) + echo ${UNAME_MACHINE}-${VENDOR}-linux + exit 0 ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-${VENDOR}-linux exit 0 ;; @@ -840,7 +913,8 @@ EOF # The BFD linker knows what the default object file format is, so # first see if it will tell us. cd to the root directory to prevent # problems with other programs or directories called `ld' in the path. - ld_supported_targets=`cd /; ld --help 2>&1 \ + # Set LC_ALL=C to ensure ld outputs messages in English. + ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ | sed -ne '/supported targets:/!d s/[ ][ ]*/ /g s/.*supported targets: *// @@ -852,7 +926,7 @@ EOF ;; a.out-i386-linux) echo "${UNAME_MACHINE}-${VENDOR}-linuxaout" - exit 0 ;; + exit 0 ;; coff-i386) echo "${UNAME_MACHINE}-${VENDOR}-linuxcoff" exit 0 ;; @@ -863,33 +937,29 @@ EOF exit 0 ;; esac # Determine whether the default compiler is a.out or elf - cat >$dummy.c < -#ifdef __cplusplus -#include /* for printf() prototype */ - int main (int argc, char *argv[]) { -#else - int main (argc, argv) int argc; char *argv[]; { -#endif -#ifdef __ELF__ -# ifdef __GLIBC__ -# if __GLIBC__ >= 2 - printf ("%s-${VENDOR}-linux\n", argv[1]); -# else - printf ("%s-${VENDOR}-linuxlibc1\n", argv[1]); -# endif -# else - printf ("%s-${VENDOR}-linuxlibc1\n", argv[1]); -# endif -#else - printf ("%s-${VENDOR}-linuxaout\n", argv[1]); -#endif - return 0; -} -EOF eval $set_cc_for_build - $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0 - rm -f $dummy.c $dummy + sed 's/^ //' << EOF >$dummy.c + #include + #ifdef __ELF__ + # ifdef __GLIBC__ + # if __GLIBC__ >= 2 + LIBC=gnu + # else + LIBC=gnulibc1 + # endif + # else + LIBC=gnulibc1 + # endif + #else + #ifdef __INTEL_COMPILER + LIBC=gnu + #else + LIBC=gnuaout + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` + test x"${LIBC}" != x && echo "${UNAME_MACHINE}-${VENDOR}-linux-${LIBC}" | sed 's/linux-gnu/linux/' && exit 0 test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 ;; i*86:DYNIX/ptx:4*:*) @@ -906,6 +976,23 @@ EOF # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit 0 ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit 0 ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit 0 ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit 0 ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit 0 ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then @@ -927,22 +1014,19 @@ EOF UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then - UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` - (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 - (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 - (/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \ + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 - (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \ + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit 0 ;; - i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp - exit 0 ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about @@ -966,9 +1050,15 @@ EOF # "miniframe" echo m68010-convergent-sysv exit 0 ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit 0 ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + exit 0 ;; M68*:*:R3V[567]*:*) test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; - 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0) + 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` @@ -985,9 +1075,6 @@ EOF mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit 0 ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit 0 ;; @@ -1059,6 +1146,9 @@ EOF SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit 0 ;; + SX-6:SUPER-UX:*:*) + echo sx6-nec-superux${UNAME_RELEASE} + exit 0 ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit 0 ;; @@ -1066,18 +1156,24 @@ EOF echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit 0 ;; *:Darwin:*:*) - echo `uname -p`-apple-darwin${UNAME_RELEASE} + case `uname -p` in + *86) UNAME_PROCESSOR=i686 ;; + powerpc) UNAME_PROCESSOR=powerpc ;; + esac + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit 0 ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) - if test "${UNAME_MACHINE}" = "x86pc"; then + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = "x86"; then + UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi - echo `uname -p`-${UNAME_MACHINE}-nto-qnx + echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit 0 ;; *:QNX:*:4*) echo i386-pc-qnx exit 0 ;; - NSR-[KW]:NONSTOP_KERNEL:*:*) + NSR-[DGKLNPTVW]:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit 0 ;; *:NonStop-UX:*:*) @@ -1100,11 +1196,6 @@ EOF fi echo ${UNAME_MACHINE}-unknown-plan9 exit 0 ;; - i*86:OS/2:*:*) - # If we were able to find `uname', then EMX Unix compatibility - # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx - exit 0 ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit 0 ;; @@ -1123,14 +1214,15 @@ EOF *:ITS:*:*) echo pdp10-unknown-its exit 0 ;; - i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop + SEI:*:*:SEIUX) + echo mips-sei-seiux${UNAME_RELEASE} exit 0 ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 +eval $set_cc_for_build cat >$dummy.c < @@ -1245,9 +1337,7 @@ main () } EOF -eval $set_cc_for_build -$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0 -rm -f $dummy.c $dummy +$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0 # Apollos put the system type in the environment. diff --git a/config.sub b/config.sub index 83f4b0151e0..9952c14c714 100755 --- a/config.sub +++ b/config.sub @@ -1,9 +1,9 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 -# Free Software Foundation, Inc. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003 Free Software Foundation, Inc. -timestamp='2001-08-13' +timestamp='2003-07-04' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software @@ -29,7 +29,8 @@ timestamp='2001-08-13' # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. -# Please send patches to . +# Please send patches to . Submit a context +# diff and a properly formatted ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. @@ -117,7 +118,7 @@ esac # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in - nto-qnx* | linux-gnu* | storm-chaos* | os2-emx* | windows32-*) + nto-qnx* | linux-gnu* | kfreebsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; @@ -226,31 +227,44 @@ case $basic_machine in 1750a | 580 \ | a29k \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ | c4x | clipper \ - | d10v | d30v | dsp16xx \ - | fr30 \ + | d10v | d30v | dlx | dsp16xx \ + | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ + | ip2k \ | m32r | m68000 | m68k | m88k | mcore \ - | mips16 | mips64 | mips64el | mips64orion | mips64orionel \ - | mips64vr4100 | mips64vr4100el | mips64vr4300 \ - | mips64vr4300el | mips64vr5000 | mips64vr5000el \ - | mipsbe | mipsel | mipsle | mipstx39 | mipstx39el \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64el \ + | mips64vr | mips64vrel \ + | mips64orion | mips64orionel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ + | msp430 \ | ns16k | ns32k \ - | openrisc \ + | openrisc | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | pyramid \ - | s390 | s390x \ - | sh | sh[34] | sh[34]eb | shbe | shle \ - | sparc | sparc64 | sparclet | sparclite | sparcv9 | sparcv9b \ + | sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ + | sh64 | sh64le \ + | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \ | strongarm \ - | tahoe | thumb | tic80 | tron \ - | v850 \ + | tahoe | thumb | tic4x | tic80 | tron \ + | v850 | v850e \ | we32k \ - | x86 | xscale \ + | x86 | xscale | xstormy16 | xtensa \ | z8k) basic_machine=$basic_machine-unknown ;; @@ -277,38 +291,55 @@ case $basic_machine in 580-* \ | a29k-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alphapca5[67]-* | arc-* \ - | arm-* | armbe-* | armle-* | armv*-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* \ | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c54x-* \ - | clipper-* | cray2-* | cydra-* \ - | d10v-* | d30v-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ + | clipper-* | cydra-* \ + | d10v-* | d30v-* | dlx-* \ | elxsi-* \ - | f30[01]-* | f700-* | fr30-* | fx80-* \ + | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ + | ip2k-* \ | m32r-* \ - | m68000-* | m680[01234]0-* | m68360-* | m683?2-* | m68k-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | mcore-* \ - | mips-* | mips16-* | mips64-* | mips64el-* | mips64orion-* \ - | mips64orionel-* | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* | mipsbe-* | mipsel-* \ - | mipsle-* | mipstx39-* | mipstx39el-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ + | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ + | mips64vr-* | mips64vrel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipstx39-* | mipstx39el-* \ + | msp430-* \ + | none-* | np1-* | nv1-* | ns16k-* | ns32k-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | pyramid-* \ | romp-* | rs6000-* \ - | s390-* | s390x-* \ - | sh-* | sh[34]-* | sh[34]eb-* | shbe-* | shle-* \ - | sparc-* | sparc64-* | sparc86x-* | sparclite-* \ - | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* \ - | t3e-* | tahoe-* | thumb-* | tic30-* | tic54x-* | tic80-* | tron-* \ - | v850-* | vax-* \ + | sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \ + | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ + | tahoe-* | thumb-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tron-* \ + | v850-* | v850e-* | vax-* \ | we32k-* \ - | x86-* | x86_64-* | xmp-* | xps100-* | xscale-* \ + | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \ + | xtensa-* \ | ymp-* \ | z8k-*) ;; @@ -342,6 +373,9 @@ case $basic_machine in basic_machine=a29k-none os=-bsd ;; + amd64) + basic_machine=x86_64-pc + ;; amdahl) basic_machine=580-amdahl os=-sysv @@ -373,6 +407,10 @@ case $basic_machine in basic_machine=ns32k-sequent os=-dynix ;; + c90) + basic_machine=c90-cray + os=-unicos + ;; convex-c1) basic_machine=c1-convex os=-bsd @@ -393,16 +431,8 @@ case $basic_machine in basic_machine=c38-convex os=-bsd ;; - cray | ymp) - basic_machine=ymp-cray - os=-unicos - ;; - cray2) - basic_machine=cray2-cray - os=-unicos - ;; - [cjt]90) - basic_machine=${basic_machine}-cray + cray | j90) + basic_machine=j90-cray os=-unicos ;; crds | unos) @@ -417,6 +447,14 @@ case $basic_machine in decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; + decsystem10* | dec10*) + basic_machine=pdp10-dec + os=-tops10 + ;; + decsystem20* | dec20*) + basic_machine=pdp10-dec + os=-tops20 + ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola @@ -597,12 +635,6 @@ case $basic_machine in basic_machine=m68k-atari os=-mint ;; - mipsel*-linux*) - basic_machine=mipsel-unknown - ;; - mips*-linux*) - basic_machine=mips-unknown - ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; @@ -617,6 +649,10 @@ case $basic_machine in basic_machine=m68k-rom68k os=-coff ;; + morphos) + basic_machine=powerpc-unknown + os=-morphos + ;; msdos) basic_machine=i386-pc os=-msdos @@ -689,6 +725,10 @@ case $basic_machine in np1) basic_machine=np1-gould ;; + nv1) + basic_machine=nv1-cray + os=-unicosmp + ;; nsr-tandem) basic_machine=nsr-tandem ;; @@ -696,6 +736,10 @@ case $basic_machine in basic_machine=hppa1.1-oki os=-proelf ;; + or32 | or32-*) + basic_machine=or32-unknown + os=-coff + ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose @@ -718,51 +762,55 @@ case $basic_machine in pbb) basic_machine=m68k-tti ;; - pc532 | pc532-*) + pc532 | pc532-*) basic_machine=ns32k-pc532 ;; - pentium | p5 | k5 | k6 | nexgen) + pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; - pentiumpro | p6 | 6x86 | athlon) + pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; - pentiumii | pentium2) + pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-*) + pentium4) + basic_machine=i786-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; - pentiumii-* | pentium2-*) + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; + pentium4-*) + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc) basic_machine=powerpc-unknown - ;; - ppc64) basic_machine=powerpc-unknown ;; ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown - ;; + ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown - ;; + ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown - ;; + ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; @@ -783,10 +831,26 @@ case $basic_machine in rtpc | rtpc-*) basic_machine=romp-ibm ;; + s390 | s390-*) + basic_machine=s390-ibm + ;; + s390x | s390x-*) + basic_machine=s390x-ibm + ;; sa29200) basic_machine=a29k-amd os=-udi ;; + sb1) + basic_machine=mipsisa64sb1-unknown + ;; + sb1el) + basic_machine=mipsisa64sb1el-unknown + ;; + sei) + basic_machine=mips-sei + os=-seiux + ;; sequent) basic_machine=i386-sequent ;; @@ -794,7 +858,10 @@ case $basic_machine in basic_machine=sh-hitachi os=-hms ;; - sparclite-wrs) + sh64) + basic_machine=sh64-unknown + ;; + sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; @@ -861,19 +928,35 @@ case $basic_machine in os=-dynix ;; t3e) - basic_machine=t3e-cray + basic_machine=alphaev5-cray + os=-unicos + ;; + t90) + basic_machine=t90-cray os=-unicos ;; tic54x | c54x*) basic_machine=tic54x-unknown os=-coff ;; + tic55x | c55x*) + basic_machine=tic55x-unknown + os=-coff + ;; + tic6x | c6x*) + basic_machine=tic6x-unknown + os=-coff + ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; + toad1) + basic_machine=pdp10-xkl + os=-tops20 + ;; tower | tower-32) basic_machine=m68k-ncr ;; @@ -898,8 +981,8 @@ case $basic_machine in os=-vms ;; vpp*|vx|vx-*) - basic_machine=f301-fujitsu - ;; + basic_machine=f301-fujitsu + ;; vxworks960) basic_machine=i960-wrs os=-vxworks @@ -920,17 +1003,13 @@ case $basic_machine in basic_machine=hppa1.1-winbond os=-proelf ;; - windows32) - basic_machine=i386-pc - os=-windows32-msvcrt - ;; - xmp) - basic_machine=xmp-cray - os=-unicos - ;; - xps | xps100) + xps | xps100) basic_machine=xps100-honeywell ;; + ymp) + basic_machine=ymp-cray + os=-unicos + ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim @@ -951,16 +1030,6 @@ case $basic_machine in op60c) basic_machine=hppa1.1-oki ;; - mips) - case $os in - linux*) - basic_machine=mips-unknown - ;; - *) - basic_machine=mips-mips - ;; - esac - ;; romp) basic_machine=romp-ibm ;; @@ -980,13 +1049,16 @@ case $basic_machine in we32k) basic_machine=we32k-att ;; - sh3 | sh4 | sh3eb | sh4eb) + sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; + sh64) + basic_machine=sh64-unknown + ;; sparc | sparcv9 | sparcv9b) basic_machine=sparc-sun ;; - cydra) + cydra) basic_machine=cydra-cydrome ;; orion) @@ -1001,10 +1073,6 @@ case $basic_machine in pmac | pmac-mpw) basic_machine=powerpc-apple ;; - c4x*) - basic_machine=c4x-none - os=-coff - ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; @@ -1060,17 +1128,19 @@ case $os in | -aos* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ + | -hiux* | -386bsd* | -netbsd* | -openbsd* | -kfreebsd* | -freebsd* | -riscix* \ | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux* | -uxpv* | -beos* | -mpeix* | -udk* \ - | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ - | -os2* | -vos*) + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) @@ -1082,8 +1152,10 @@ case $os in ;; esac ;; + -nto-qnx*) + ;; -nto*) - os=-nto-qnx + os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ @@ -1119,14 +1191,20 @@ case $os in -acis*) os=-aos ;; + -atheos*) + os=-atheos + ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; + -nova*) + os=-rtmk-nova + ;; -ns2 ) - os=-nextstep2 + os=-nextstep2 ;; -nsk*) os=-nsk @@ -1165,8 +1243,14 @@ case $os in -xenix) os=-xenix ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - os=-mint + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -aros*) + os=-aros + ;; + -kaos*) + os=-kaos ;; -none) ;; @@ -1199,10 +1283,14 @@ case $basic_machine in arm*-semi) os=-aout ;; + c4x-* | tic4x-*) + os=-coff + ;; + # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; - pdp11-*) + pdp11-*) os=-none ;; *-dec | vax-*) @@ -1229,6 +1317,9 @@ case $basic_machine in mips*-*) os=-elf ;; + or32-*) + os=-coff + ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; @@ -1292,19 +1383,19 @@ case $basic_machine in *-next) os=-nextstep3 ;; - *-gould) + *-gould) os=-sysv ;; - *-highlevel) + *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; - *-sgi) + *-sgi) os=-irix ;; - *-siemens) + *-siemens) os=-sysv4 ;; *-masscomp) @@ -1376,7 +1467,7 @@ case $basic_machine in -ptx*) vendor=sequent ;; - -vxsim* | -vxworks*) + -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) diff --git a/ltmain.sh b/ltmain.sh index e82e48a9ca0..8bf1b20bc85 100644 --- a/ltmain.sh +++ b/ltmain.sh @@ -1,7 +1,7 @@ # ltmain.sh - Provide generalized library-building support services. # NOTE: Changing this file will not affect anything until you rerun configure. # -# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003 # Free Software Foundation, Inc. # Originally by Gordon Matzigkeit , 1996 # @@ -49,14 +49,14 @@ EOF fi # The name of this program. -progname=`$echo "$0" | sed 's%^.*/%%'` +progname=`$echo "$0" | ${SED} 's%^.*/%%'` modename="$progname" # Constants. PROGRAM=ltmain.sh PACKAGE=libtool -VERSION=1.4.2 -TIMESTAMP=" (1.922.2.53 2001/09/11 03:18:52)" +VERSION=1.5 +TIMESTAMP=" (1.1220.2.1 2003/04/14 22:48:00)" default_mode= help="Try \`$progname --help' for more information." @@ -67,10 +67,19 @@ rm="rm -f" # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. -Xsed='sed -e 1s/^X//' +Xsed="${SED}"' -e 1s/^X//' sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g' -SP2NL='tr \040 \012' -NL2SP='tr \015\012 \040\040' +# test EBCDIC or ASCII +case `echo A|od -x` in + *[Cc]1*) # EBCDIC based system + SP2NL="tr '\100' '\n'" + NL2SP="tr '\r\n' '\100\100'" + ;; + *) # Assume ASCII based system + SP2NL="tr '\040' '\012'" + NL2SP="tr '\015\012' '\040\040'" + ;; +esac # NLS nuisances. # Only set LANG and LC_ALL to C if already set. @@ -88,8 +97,8 @@ fi : ${IFS=" "} if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then - echo "$modename: not configured to build any kind of library" 1>&2 - echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 + $echo "$modename: not configured to build any kind of library" 1>&2 + $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 exit 1 fi @@ -105,8 +114,51 @@ execute_dlfiles= lo2o="s/\\.lo\$/.${objext}/" o2lo="s/\\.${objext}\$/.lo/" +##################################### +# Shell function definitions: +# This seems to be the best place for them + +# Need a lot of goo to handle *both* DLLs and import libs +# Has to be a shell function in order to 'eat' the argument +# that is supplied when $file_magic_command is called. +win32_libid () { + win32_libid_type="unknown" + win32_fileres=`file -L $1 2>/dev/null` + case $win32_fileres in + *ar\ archive\ import\ library*) # definitely import + win32_libid_type="x86 archive import" + ;; + *ar\ archive*) # could be an import, or static + if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \ + grep -E 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then + win32_nmres=`eval $NM -f posix -A $1 | \ + sed -n -e '1,100{/ I /{x;/import/!{s/^/import/;h;p;};x;};}'` + if test "X$win32_nmres" = "Ximport" ; then + win32_libid_type="x86 archive import" + else + win32_libid_type="x86 archive static" + fi + fi + ;; + *DLL*) + win32_libid_type="x86 DLL" + ;; + *executable*) # but shell scripts are "executable" too... + case $win32_fileres in + *MS\ Windows\ PE\ Intel*) + win32_libid_type="x86 DLL" + ;; + esac + ;; + esac + $echo $win32_libid_type +} + +# End of Shell function definitions +##################################### + # Parse our command line options once, thoroughly. -while test $# -gt 0 +while test "$#" -gt 0 do arg="$1" shift @@ -122,6 +174,33 @@ do execute_dlfiles) execute_dlfiles="$execute_dlfiles $arg" ;; + tag) + tagname="$arg" + + # Check whether tagname contains only valid characters + case $tagname in + *[!-_A-Za-z0-9,/]*) + $echo "$progname: invalid tag name: $tagname" 1>&2 + exit 1 + ;; + esac + + case $tagname in + CC) + # Don't test for the "default" C tag, as we know, it's there, but + # not specially marked. + ;; + *) + if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$0" > /dev/null; then + taglist="$taglist $tagname" + # Evaluate the configuration. + eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $0`" + else + $echo "$progname: ignoring unknown tag $tagname" 1>&2 + fi + ;; + esac + ;; *) eval "$prev=\$arg" ;; @@ -139,17 +218,25 @@ do ;; --version) - echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP" + $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP" + $echo + $echo "Copyright (C) 2003 Free Software Foundation, Inc." + $echo "This is free software; see the source for copying conditions. There is NO" + $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." exit 0 ;; --config) - sed -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $0 + ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $0 + # Now print the configurations for the tags. + for tagname in $taglist; do + ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$0" + done exit 0 ;; --debug) - echo "$progname: enabling shell trace mode" + $echo "$progname: enabling shell trace mode" set -x ;; @@ -158,16 +245,16 @@ do ;; --features) - echo "host: $host" + $echo "host: $host" if test "$build_libtool_libs" = yes; then - echo "enable shared libraries" + $echo "enable shared libraries" else - echo "disable shared libraries" + $echo "disable shared libraries" fi if test "$build_old_libs" = yes; then - echo "enable static libraries" + $echo "enable static libraries" else - echo "disable static libraries" + $echo "disable static libraries" fi exit 0 ;; @@ -177,10 +264,19 @@ do --mode) prevopt="--mode" prev=mode ;; --mode=*) mode="$optarg" ;; + --preserve-dup-deps) duplicate_deps="yes" ;; + --quiet | --silent) show=: ;; + --tag) prevopt="--tag" prev=tag ;; + --tag=*) + set tag "$optarg" ${1+"$@"} + shift + prev=tag + ;; + -dlopen) prevopt="-dlopen" prev=execute_dlfiles @@ -214,8 +310,10 @@ if test -z "$show_help"; then # Infer the operation mode. if test -z "$mode"; then + $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2 + $echo "*** Future versions of Libtool will require -mode=MODE be specified." 1>&2 case $nonopt in - *cc | *++ | gcc* | *-gcc*) + *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*) mode=link for arg do @@ -270,158 +368,127 @@ if test -z "$show_help"; then modename="$modename: compile" # Get the compilation command and the source file. base_compile= - prev= - lastarg= - srcfile="$nonopt" + srcfile="$nonopt" # always keep a non-empty value in "srcfile" suppress_output= + arg_mode=normal + libobj= - user_target=no for arg do - case $prev in - "") ;; - xcompiler) - # Aesthetically quote the previous argument. - prev= - lastarg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` - - case $arg in - # Double-quote args containing other shell metacharacters. - # Many Bourne shells cannot handle close brackets correctly - # in scan sets, so we specify it separately. - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - arg="\"$arg\"" - ;; - esac - - # Add the previous argument to base_compile. - if test -z "$base_compile"; then - base_compile="$lastarg" - else - base_compile="$base_compile $lastarg" - fi - continue - ;; - esac - - # Accept any command-line options. - case $arg in - -o) - if test "$user_target" != "no"; then - $echo "$modename: you cannot specify \`-o' more than once" 1>&2 - exit 1 - fi - user_target=next + case "$arg_mode" in + arg ) + # do not "continue". Instead, add this to base_compile + lastarg="$arg" + arg_mode=normal ;; - -static) - build_old_libs=yes - continue - ;; - - -prefer-pic) - pic_mode=yes - continue - ;; - - -prefer-non-pic) - pic_mode=no - continue - ;; - - -Xcompiler) - prev=xcompiler - continue - ;; - - -Wc,*) - args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"` - lastarg= - save_ifs="$IFS"; IFS=',' - for arg in $args; do - IFS="$save_ifs" - - # Double-quote args containing other shell metacharacters. - # Many Bourne shells cannot handle close brackets correctly - # in scan sets, so we specify it separately. - case $arg in - *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") - arg="\"$arg\"" - ;; - esac - lastarg="$lastarg $arg" - done - IFS="$save_ifs" - lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"` - - # Add the arguments to base_compile. - if test -z "$base_compile"; then - base_compile="$lastarg" - else - base_compile="$base_compile $lastarg" - fi - continue - ;; - esac - - case $user_target in - next) - # The next one is the -o target name - user_target=yes - continue - ;; - yes) - # We got the output file - user_target=set + target ) libobj="$arg" + arg_mode=normal continue ;; - esac - # Accept the current argument as the source file. - lastarg="$srcfile" - srcfile="$arg" + normal ) + # Accept any command-line options. + case $arg in + -o) + if test -n "$libobj" ; then + $echo "$modename: you cannot specify \`-o' more than once" 1>&2 + exit 1 + fi + arg_mode=target + continue + ;; + + -static) + build_old_libs=yes + continue + ;; + + -prefer-pic) + pic_mode=yes + continue + ;; + + -prefer-non-pic) + pic_mode=no + continue + ;; + + -Xcompiler) + arg_mode=arg # the next one goes into the "base_compile" arg list + continue # The current "srcfile" will either be retained or + ;; # replaced later. I would guess that would be a bug. + + -Wc,*) + args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"` + lastarg= + save_ifs="$IFS"; IFS=',' + for arg in $args; do + IFS="$save_ifs" + + # Double-quote args containing other shell metacharacters. + # Many Bourne shells cannot handle close brackets correctly + # in scan sets, so we specify it separately. + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + lastarg="$lastarg $arg" + done + IFS="$save_ifs" + lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"` + + # Add the arguments to base_compile. + base_compile="$base_compile $lastarg" + continue + ;; + + * ) + # Accept the current argument as the source file. + # The previous "srcfile" becomes the current argument. + # + lastarg="$srcfile" + srcfile="$arg" + ;; + esac # case $arg + ;; + esac # case $arg_mode # Aesthetically quote the previous argument. - - # Backslashify any backslashes, double quotes, and dollar signs. - # These are the only characters that are still specially - # interpreted inside of double-quoted scrings. lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"` + case $lastarg in # Double-quote args containing other shell metacharacters. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. - case $lastarg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") lastarg="\"$lastarg\"" ;; esac - # Add the previous argument to base_compile. - if test -z "$base_compile"; then - base_compile="$lastarg" - else - base_compile="$base_compile $lastarg" - fi - done + base_compile="$base_compile $lastarg" + done # for arg - case $user_target in - set) + case $arg_mode in + arg) + $echo "$modename: you must specify an argument for -Xcompile" + exit 1 ;; - no) - # Get the name of the library object. - libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'` - ;; - *) + target) $echo "$modename: you must specify a target with \`-o'" 1>&2 exit 1 ;; + *) + # Get the name of the library object. + [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'` + ;; esac # Recognize several different file suffixes. # If the user specifies -o file.o, it is replaced with file.lo - xform='[cCFSfmso]' + xform='[cCFSifmso]' case $libobj in *.ada) xform=ada ;; *.adb) xform=adb ;; @@ -429,10 +496,13 @@ if test -z "$show_help"; then *.asm) xform=asm ;; *.c++) xform=c++ ;; *.cc) xform=cc ;; + *.ii) xform=ii ;; + *.class) xform=class ;; *.cpp) xform=cpp ;; *.cxx) xform=cxx ;; *.f90) xform=f90 ;; *.for) xform=for ;; + *.java) xform=java ;; esac libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"` @@ -445,6 +515,56 @@ if test -z "$show_help"; then ;; esac + # Infer tagged configuration to use if any are available and + # if one wasn't chosen via the "--tag" command line option. + # Only attempt this if the compiler in the base compile + # command doesn't match the default compiler. + if test -n "$available_tags" && test -z "$tagname"; then + case $base_compile in + # Blanks in the command may have been stripped by the calling shell, + # but not from the CC environment variable when configure was run. + " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "*) ;; + # Blanks at the start of $base_compile will cause this to fail + # if we don't check for them as well. + *) + for z in $available_tags; do + if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$0" > /dev/null; then + # Evaluate the configuration. + eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $0`" + case "$base_compile " in + "$CC "* | " $CC "* | "`$echo $CC` "* | " `$echo $CC` "*) + # The compiler in the base compile command matches + # the one in the tagged configuration. + # Assume this is the tagged configuration we want. + tagname=$z + break + ;; + esac + fi + done + # If $tagname still isn't set, then no tagged configuration + # was found and let the user know that the "--tag" command + # line option must be used. + if test -z "$tagname"; then + $echo "$modename: unable to infer tagged configuration" + $echo "$modename: specify a tag with \`--tag'" 1>&2 + exit 1 +# else +# $echo "$modename: using $tagname tagged configuration" + fi + ;; + esac + fi + + objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` + xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$obj"; then + xdir= + else + xdir=$xdir/ + fi + lobj=${xdir}$objdir/$objname + if test -z "$base_compile"; then $echo "$modename: you must specify a compilation command" 1>&2 $echo "$help" 1>&2 @@ -453,9 +573,9 @@ if test -z "$show_help"; then # Delete any leftover library objects. if test "$build_old_libs" = yes; then - removelist="$obj $libobj" + removelist="$obj $lobj $libobj ${libobj}T" else - removelist="$libobj" + removelist="$lobj $libobj ${libobj}T" fi $run $rm $removelist @@ -467,7 +587,7 @@ if test -z "$show_help"; then pic_mode=default ;; esac - if test $pic_mode = no && test "$deplibs_check_method" != pass_all; then + if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then # non-PIC code in shared libraries is not supported pic_mode=default fi @@ -480,6 +600,7 @@ if test -z "$show_help"; then removelist="$removelist $output_obj $lockfile" trap "$run $rm $removelist; exit 1" 1 2 15 else + output_obj= need_locks=no lockfile= fi @@ -493,7 +614,7 @@ if test -z "$show_help"; then done elif test "$need_locks" = warn; then if test -f "$lockfile"; then - echo "\ + $echo "\ *** ERROR, $lockfile exists and contains: `cat $lockfile 2>/dev/null` @@ -507,56 +628,55 @@ compiler." $run $rm $removelist exit 1 fi - echo $srcfile > "$lockfile" + $echo $srcfile > "$lockfile" fi if test -n "$fix_srcfile_path"; then eval srcfile=\"$fix_srcfile_path\" fi + $run $rm "$libobj" "${libobj}T" + + # Create a libtool object file (analogous to a ".la" file), + # but don't create it if we're doing a dry run. + test -z "$run" && cat > ${libobj}T </dev/null`" != x"$srcfile"; then - echo "\ + test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then + $echo "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` @@ -585,9 +705,9 @@ compiler." fi # Just move the object if needed, then go on to compile the next one - if test x"$output_obj" != x"$libobj"; then - $show "$mv $output_obj $libobj" - if $run $mv $output_obj $libobj; then : + if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then + $show "$mv $output_obj $lobj" + if $run $mv $output_obj $lobj; then : else error=$? $run $rm $removelist @@ -595,48 +715,21 @@ compiler." fi fi - # If we have no pic_flag, then copy the object into place and finish. - if (test -z "$pic_flag" || test "$pic_mode" != default) && - test "$build_old_libs" = yes; then - # Rename the .lo from within objdir to obj - if test -f $obj; then - $show $rm $obj - $run $rm $obj - fi + # Append the name of the PIC object to the libtool object file. + test -z "$run" && cat >> ${libobj}T <> ${libobj}T </dev/null`" != x"$srcfile"; then - echo "\ + test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then + $echo "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` @@ -684,7 +775,7 @@ compiler." fi # Just move the object if needed - if test x"$output_obj" != x"$obj"; then + if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then $show "$mv $output_obj $obj" if $run $mv $output_obj $obj; then : else @@ -694,23 +785,25 @@ compiler." fi fi - # Create an invalid libtool object if no PIC, so that we do not - # accidentally link it into a program. - if test "$build_libtool_libs" != yes; then - $show "echo timestamp > $libobj" - $run eval "echo timestamp > \$libobj" || exit $? - else - # Move the .lo from within objdir - $show "$mv $libobj $lo_libobj" - if $run $mv $libobj $lo_libobj; then : - else - error=$? - $run $rm $removelist - exit $error - fi - fi + # Append the name of the non-PIC object the libtool object file. + # Only append if the libtool object file exists. + test -z "$run" && cat >> ${libobj}T <> ${libobj}T <\?\'\ \ ]*|*]*|"") @@ -887,11 +985,123 @@ compiler." prev= continue ;; + inst_prefix) + inst_prefix_dir="$arg" + prev= + continue + ;; release) release="-$arg" prev= continue ;; + objectlist) + if test -f "$arg"; then + save_arg=$arg + moreargs= + for fil in `cat $save_arg` + do +# moreargs="$moreargs $fil" + arg=$fil + # A libtool-controlled object. + + # Check to see that this really is a libtool object. + if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + pic_object= + non_pic_object= + + # Read the .lo file + # If there is no directory component, then add one. + case $arg in + */* | *\\*) . $arg ;; + *) . ./$arg ;; + esac + + if test -z "$pic_object" || \ + test -z "$non_pic_object" || + test "$pic_object" = none && \ + test "$non_pic_object" = none; then + $echo "$modename: cannot find name of object for \`$arg'" 1>&2 + exit 1 + fi + + # Extract subdirectory from the argument. + xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$arg"; then + xdir= + else + xdir="$xdir/" + fi + + if test "$pic_object" != none; then + # Prepend the subdirectory the object is found in. + pic_object="$xdir$pic_object" + + if test "$prev" = dlfiles; then + if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then + dlfiles="$dlfiles $pic_object" + prev= + continue + else + # If libtool objects are unsupported, then we need to preload. + prev=dlprefiles + fi + fi + + # CHECK ME: I think I busted this. -Ossama + if test "$prev" = dlprefiles; then + # Preload the old-style object. + dlprefiles="$dlprefiles $pic_object" + prev= + fi + + # A PIC object. + libobjs="$libobjs $pic_object" + arg="$pic_object" + fi + + # Non-PIC object. + if test "$non_pic_object" != none; then + # Prepend the subdirectory the object is found in. + non_pic_object="$xdir$non_pic_object" + + # A standard non-PIC object + non_pic_objects="$non_pic_objects $non_pic_object" + if test -z "$pic_object" || test "$pic_object" = none ; then + arg="$non_pic_object" + fi + fi + else + # Only an error if not doing a dry-run. + if test -z "$run"; then + $echo "$modename: \`$arg' is not a valid libtool object" 1>&2 + exit 1 + else + # Dry-run case. + + # Extract subdirectory from the argument. + xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$arg"; then + xdir= + else + xdir="$xdir/" + fi + + pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"` + non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"` + libobjs="$libobjs $pic_object" + non_pic_objects="$non_pic_objects $non_pic_object" + fi + fi + done + else + $echo "$modename: link input file \`$save_arg' does not exist" + exit 1 + fi + arg=$save_arg + prev= + continue + ;; rpath | xrpath) # We need an absolute path. case $arg in @@ -930,13 +1140,21 @@ compiler." finalize_command="$finalize_command $wl$qarg" continue ;; + xcclinker) + linker_flags="$linker_flags $qarg" + compiler_flags="$compiler_flags $qarg" + prev= + compile_command="$compile_command $qarg" + finalize_command="$finalize_command $qarg" + continue + ;; *) eval "$prev=\"\$arg\"" prev= continue ;; esac - fi # test -n $prev + fi # test -n "$prev" prevarg="$arg" @@ -988,11 +1206,16 @@ compiler." continue ;; + -inst-prefix-dir) + prev=inst_prefix + continue + ;; + # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* # so, if we see these flags be careful not to treat them like -L -L[A-Z][A-Z]*:*) case $with_gcc/$host in - no/*-*-irix*) + no/*-*-irix* | /*-*-irix*) compile_command="$compile_command $arg" finalize_command="$finalize_command $arg" ;; @@ -1043,18 +1266,22 @@ compiler." # These systems don't actually have a C library (as such) test "X$arg" = "X-lc" && continue ;; - *-*-openbsd*) + *-*-openbsd* | *-*-freebsd*) # Do not include libc due to us having libc/libc_r. test "X$arg" = "X-lc" && continue ;; - esac - elif test "X$arg" = "X-lc_r"; then - case $host in - *-*-openbsd*) - # Do not include libc_r directly, use -pthread flag. + *-*-rhapsody* | *-*-darwin1.[012]) + # Rhapsody C and math libraries are in the System framework + deplibs="$deplibs -framework System" continue - ;; esac + elif test "X$arg" = "X-lc_r"; then + case $host in + *-*-openbsd* | *-*-freebsd*) + # Do not include libc_r directly, use -pthread flag. + continue + ;; + esac fi deplibs="$deplibs $arg" continue @@ -1065,6 +1292,34 @@ compiler." continue ;; + # gcc -m* arguments should be passed to the linker via $compiler_flags + # in order to pass architecture information to the linker + # (e.g. 32 vs 64-bit). This may also be accomplished via -Wl,-mfoo + # but this is not reliable with gcc because gcc may use -mfoo to + # select a different linker, different libraries, etc, while + # -Wl,-mfoo simply passes -mfoo to the linker. + -m*) + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + if test "$with_gcc" = "yes" ; then + compiler_flags="$compiler_flags $arg" + fi + continue + ;; + + -shrext) + prev=shrext + continue + ;; + -no-fast-install) fast_install=no continue @@ -1089,6 +1344,11 @@ compiler." continue ;; + -objectlist) + prev=objectlist + continue + ;; + -o) prev=output ;; -release) @@ -1141,6 +1401,11 @@ compiler." prev=vinfo continue ;; + -version-number) + prev=vinfo + vinfo_number=yes + continue + ;; -Wc,*) args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'` @@ -1189,6 +1454,11 @@ compiler." continue ;; + -XCClinker) + prev=xcclinker + continue + ;; + # Some other compiler flag. -* | +*) # Unknown arguments in both finalize_command and compile_command need @@ -1201,29 +1471,101 @@ compiler." esac ;; - *.lo | *.$objext) - # A library or standard object. - if test "$prev" = dlfiles; then - # This file was specified with -dlopen. - if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then - dlfiles="$dlfiles $arg" - prev= - continue - else - # If libtool objects are unsupported, then we need to preload. - prev=dlprefiles - fi - fi + *.$objext) + # A standard object. + objs="$objs $arg" + ;; - if test "$prev" = dlprefiles; then - # Preload the old-style object. - dlprefiles="$dlprefiles "`$echo "X$arg" | $Xsed -e "$lo2o"` - prev= - else + *.lo) + # A libtool-controlled object. + + # Check to see that this really is a libtool object. + if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + pic_object= + non_pic_object= + + # Read the .lo file + # If there is no directory component, then add one. case $arg in - *.lo) libobjs="$libobjs $arg" ;; - *) objs="$objs $arg" ;; + */* | *\\*) . $arg ;; + *) . ./$arg ;; esac + + if test -z "$pic_object" || \ + test -z "$non_pic_object" || + test "$pic_object" = none && \ + test "$non_pic_object" = none; then + $echo "$modename: cannot find name of object for \`$arg'" 1>&2 + exit 1 + fi + + # Extract subdirectory from the argument. + xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$arg"; then + xdir= + else + xdir="$xdir/" + fi + + if test "$pic_object" != none; then + # Prepend the subdirectory the object is found in. + pic_object="$xdir$pic_object" + + if test "$prev" = dlfiles; then + if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then + dlfiles="$dlfiles $pic_object" + prev= + continue + else + # If libtool objects are unsupported, then we need to preload. + prev=dlprefiles + fi + fi + + # CHECK ME: I think I busted this. -Ossama + if test "$prev" = dlprefiles; then + # Preload the old-style object. + dlprefiles="$dlprefiles $pic_object" + prev= + fi + + # A PIC object. + libobjs="$libobjs $pic_object" + arg="$pic_object" + fi + + # Non-PIC object. + if test "$non_pic_object" != none; then + # Prepend the subdirectory the object is found in. + non_pic_object="$xdir$non_pic_object" + + # A standard non-PIC object + non_pic_objects="$non_pic_objects $non_pic_object" + if test -z "$pic_object" || test "$pic_object" = none ; then + arg="$non_pic_object" + fi + fi + else + # Only an error if not doing a dry-run. + if test -z "$run"; then + $echo "$modename: \`$arg' is not a valid libtool object" 1>&2 + exit 1 + else + # Dry-run case. + + # Extract subdirectory from the argument. + xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$arg"; then + xdir= + else + xdir="$xdir/" + fi + + pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"` + non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"` + libobjs="$libobjs $pic_object" + non_pic_objects="$non_pic_objects $non_pic_object" + fi fi ;; @@ -1277,12 +1619,54 @@ compiler." exit 1 fi + # Infer tagged configuration to use if any are available and + # if one wasn't chosen via the "--tag" command line option. + # Only attempt this if the compiler in the base link + # command doesn't match the default compiler. + if test -n "$available_tags" && test -z "$tagname"; then + case $base_compile in + # Blanks in the command may have been stripped by the calling shell, + # but not from the CC environment variable when configure was run. + "$CC "* | " $CC "* | "`$echo $CC` "* | " `$echo $CC` "*) ;; + # Blanks at the start of $base_compile will cause this to fail + # if we don't check for them as well. + *) + for z in $available_tags; do + if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$0" > /dev/null; then + # Evaluate the configuration. + eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $0`" + case $base_compile in + "$CC "* | " $CC "* | "`$echo $CC` "* | " `$echo $CC` "*) + # The compiler in $compile_command matches + # the one in the tagged configuration. + # Assume this is the tagged configuration we want. + tagname=$z + break + ;; + esac + fi + done + # If $tagname still isn't set, then no tagged configuration + # was found and let the user know that the "--tag" command + # line option must be used. + if test -z "$tagname"; then + $echo "$modename: unable to infer tagged configuration" + $echo "$modename: specify a tag with \`--tag'" 1>&2 + exit 1 +# else +# $echo "$modename: using $tagname tagged configuration" + fi + ;; + esac + fi + if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then eval arg=\"$export_dynamic_flag_spec\" compile_command="$compile_command $arg" finalize_command="$finalize_command $arg" fi + oldlibs= # calculate the name of the file, without its directory outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'` libobjs_save="$libobjs" @@ -1303,11 +1687,11 @@ compiler." output_objdir="$output_objdir/$objdir" fi # Create the object directory. - if test ! -d $output_objdir; then + if test ! -d "$output_objdir"; then $show "$mkdir $output_objdir" $run $mkdir $output_objdir status=$? - if test $status -ne 0 && test ! -d $output_objdir; then + if test "$status" -ne 0 && test ! -d "$output_objdir"; then exit $status fi fi @@ -1325,16 +1709,47 @@ compiler." *) linkmode=prog ;; # Anything else should be a program. esac + case $host in + *cygwin* | *mingw* | *pw32*) + # don't eliminate duplcations in $postdeps and $predeps + duplicate_compiler_generated_deps=yes + ;; + *) + duplicate_compiler_generated_deps=$duplicate_deps + ;; + esac specialdeplibs= + libs= # Find all interdependent deplibs by searching for libraries # that are linked more than once (e.g. -la -lb -la) for deplib in $deplibs; do - case "$libs " in - *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; - esac + if test "X$duplicate_deps" = "Xyes" ; then + case "$libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi libs="$libs $deplib" done + + if test "$linkmode" = lib; then + libs="$predeps $libs $compiler_lib_search_path $postdeps" + + # Compute libraries that are listed more than once in $predeps + # $postdeps and mark them as special (i.e., whose duplicates are + # not to be eliminated). + pre_post_deps= + if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then + for pre_post_dep in $predeps $postdeps; do + case "$pre_post_deps " in + *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;; + esac + pre_post_deps="$pre_post_deps $pre_post_dep" + done + fi + pre_post_deps= + fi + deplibs= newdependency_libs= newlib_search_path= @@ -1366,28 +1781,33 @@ compiler." ;; esac for pass in $passes; do - if test $linkmode = prog; then - # Determine which files to process + if test "$linkmode,$pass" = "lib,link" || + test "$linkmode,$pass" = "prog,scan"; then + libs="$deplibs" + deplibs= + fi + if test "$linkmode" = prog; then case $pass in - dlopen) - libs="$dlfiles" - save_deplibs="$deplibs" # Collect dlpreopened libraries - deplibs= - ;; + dlopen) libs="$dlfiles" ;; dlpreopen) libs="$dlprefiles" ;; link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; esac fi + if test "$pass" = dlopen; then + # Collect dlpreopened libraries + save_deplibs="$deplibs" + deplibs= + fi for deplib in $libs; do lib= found=no case $deplib in -l*) - if test $linkmode = oldlib && test $linkmode = obj; then - $echo "$modename: warning: \`-l' is ignored for archives/objects: $deplib" 1>&2 + if test "$linkmode" != lib && test "$linkmode" != prog; then + $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2 continue fi - if test $pass = conv; then + if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi @@ -1407,25 +1827,61 @@ compiler." finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" - test $linkmode = lib && newdependency_libs="$deplib $newdependency_libs" + test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue + else # deplib is a libtool library + # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, + # We need to do some special things here, and not later. + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + case " $predeps $postdeps " in + *" $deplib "*) + if (${SED} -e '2q' $lib | + grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + library_names= + old_library= + case $lib in + */* | *\\*) . $lib ;; + *) . ./$lib ;; + esac + for l in $old_library $library_names; do + ll="$l" + done + if test "X$ll" = "X$old_library" ; then # only static version available + found=no + ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'` + test "X$ladir" = "X$lib" && ladir="." + lib=$ladir/$old_library + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" + fi + continue + fi + fi + ;; + *) ;; + esac + fi fi ;; # -l -L*) case $linkmode in lib) deplibs="$deplib $deplibs" - test $pass = conv && continue + test "$pass" = conv && continue newdependency_libs="$deplib $newdependency_libs" newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` ;; prog) - if test $pass = conv; then + if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi - if test $pass = scan; then + if test "$pass" = scan; then deplibs="$deplib $deplibs" newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` else @@ -1434,13 +1890,13 @@ compiler." fi ;; *) - $echo "$modename: warning: \`-L' is ignored for archives/objects: $deplib" 1>&2 + $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2 ;; esac # linkmode continue ;; # -L -R*) - if test $pass = link; then + if test "$pass" = link; then dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'` # Make sure the xrpath contains only unique directories. case "$xrpath " in @@ -1453,28 +1909,30 @@ compiler." ;; *.la) lib="$deplib" ;; *.$libext) - if test $pass = conv; then + if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi case $linkmode in lib) if test "$deplibs_check_method" != pass_all; then - echo - echo "*** Warning: This library needs some functionality provided by $deplib." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have." + $echo + $echo "*** Warning: Trying to link with static lib archive $deplib." + $echo "*** I have the capability to make that library automatically link in when" + $echo "*** you link to this library. But I can only do this if you have a" + $echo "*** shared version of the library, which you do not appear to have" + $echo "*** because the file extensions .$libext of this argument makes me believe" + $echo "*** that it is just a static archive that I should not used here." else - echo - echo "*** Warning: Linking the shared library $output against the" - echo "*** static library $deplib is not portable!" + $echo + $echo "*** Warning: Linking the shared library $output against the" + $echo "*** static library $deplib is not portable!" deplibs="$deplib $deplibs" fi continue ;; prog) - if test $pass != link; then + if test "$pass" != link; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" @@ -1485,14 +1943,18 @@ compiler." esac # linkmode ;; # *.$libext *.lo | *.$objext) - if test $pass = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then - # If there is no dlopen support or we're linking statically, - # we need to preload. - newdlprefiles="$newdlprefiles $deplib" - compile_deplibs="$deplib $compile_deplibs" - finalize_deplibs="$deplib $finalize_deplibs" - else - newdlfiles="$newdlfiles $deplib" + if test "$pass" = conv; then + deplibs="$deplib $deplibs" + elif test "$linkmode" = prog; then + if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then + # If there is no dlopen support or we're linking statically, + # we need to preload. + newdlprefiles="$newdlprefiles $deplib" + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + newdlfiles="$newdlfiles $deplib" + fi fi continue ;; @@ -1501,14 +1963,14 @@ compiler." continue ;; esac # case $deplib - if test $found = yes || test -f "$lib"; then : + if test "$found" = yes || test -f "$lib"; then : else $echo "$modename: cannot find the library \`$lib'" 1>&2 exit 1 fi # Check to see that this really is a libtool archive. - if (sed -e '2q' $lib | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : else $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 exit 1 @@ -1524,8 +1986,9 @@ compiler." library_names= old_library= # If the library was installed with an old release of libtool, - # it will not redefine variable installed. + # it will not redefine variables installed, or shouldnotlink installed=yes + shouldnotlink=no # Read the .la file case $lib in @@ -1535,13 +1998,12 @@ compiler." if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan" || - { test $linkmode = oldlib && test $linkmode = obj; }; then - # Add dl[pre]opened files of deplib + { test "$linkmode" != prog && test "$linkmode" != lib; }; then test -n "$dlopen" && dlfiles="$dlfiles $dlopen" test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen" fi - if test $pass = conv; then + if test "$pass" = conv; then # Only check for convenience libraries deplibs="$lib $deplibs" if test -z "$libdir"; then @@ -1555,18 +2017,21 @@ compiler." tmp_libs= for deplib in $dependency_libs; do deplibs="$deplib $deplibs" - case "$tmp_libs " in - *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; - esac + if test "X$duplicate_deps" = "Xyes" ; then + case "$tmp_libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi tmp_libs="$tmp_libs $deplib" done - elif test $linkmode != prog && test $linkmode != lib; then + elif test "$linkmode" != prog && test "$linkmode" != lib; then $echo "$modename: \`$lib' is not a convenience library" 1>&2 exit 1 fi continue fi # $pass = conv + # Get the name of the library we link against. linklib= for l in $old_library $library_names; do @@ -1578,15 +2043,17 @@ compiler." fi # This library was specified with -dlopen. - if test $pass = dlopen; then + if test "$pass" = dlopen; then if test -z "$libdir"; then $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2 exit 1 fi if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlname, no dlopen support or we're linking - # statically, we need to preload. - dlprefiles="$dlprefiles $lib" + # statically, we need to preload. We also need to preload any + # dependent libraries so libltdl's deplib preloader doesn't + # bomb out in the load deplibs phase. + dlprefiles="$dlprefiles $lib $dependency_libs" else newdlfiles="$newdlfiles $lib" fi @@ -1627,7 +2094,7 @@ compiler." name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` # This library was specified with -dlpreopen. - if test $pass = dlpreopen; then + if test "$pass" = dlpreopen; then if test -z "$libdir"; then $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2 exit 1 @@ -1646,18 +2113,19 @@ compiler." if test -z "$libdir"; then # Link the convenience library - if test $linkmode = lib; then + if test "$linkmode" = lib; then deplibs="$dir/$old_library $deplibs" elif test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$dir/$old_library $compile_deplibs" finalize_deplibs="$dir/$old_library $finalize_deplibs" else - deplibs="$lib $deplibs" + deplibs="$lib $deplibs" # used for prog,scan pass fi continue fi - if test $linkmode = prog && test $pass != link; then + + if test "$linkmode" = prog && test "$pass" != link; then newlib_search_path="$newlib_search_path $ladir" deplibs="$lib $deplibs" @@ -1673,28 +2141,36 @@ compiler." -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test esac # Need to link against all dependency_libs? - if test $linkalldeplibs = yes; then + if test "$linkalldeplibs" = yes; then deplibs="$deplib $deplibs" else # Need to hardcode shared library paths # or/and link against static libraries newdependency_libs="$deplib $newdependency_libs" fi - case "$tmp_libs " in - *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; - esac + if test "X$duplicate_deps" = "Xyes" ; then + case "$tmp_libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi tmp_libs="$tmp_libs $deplib" done # for deplib continue fi # $linkmode = prog... - link_static=no # Whether the deplib will be linked statically - if test -n "$library_names" && - { test "$prefer_static_libs" = no || test -z "$old_library"; }; then - # Link against this shared library + if test "$linkmode,$pass" = "prog,link"; then + if test -n "$library_names" && + { test "$prefer_static_libs" = no || test -z "$old_library"; }; then + # We need to hardcode the library path + if test -n "$shlibpath_var"; then + # Make sure the rpath contains only unique directories. + case "$temp_rpath " in + *" $dir "*) ;; + *" $absdir "*) ;; + *) temp_rpath="$temp_rpath $dir" ;; + esac + fi - if test "$linkmode,$pass" = "prog,link" || - { test $linkmode = lib && test $hardcode_into_libs = yes; }; then # Hardcode the library path. # Skip directories that are in the system default run-time # search path. @@ -1716,17 +2192,6 @@ compiler." esac ;; esac - if test $linkmode = prog; then - # We need to hardcode the library path - if test -n "$shlibpath_var"; then - # Make sure the rpath contains only unique directories. - case "$temp_rpath " in - *" $dir "*) ;; - *" $absdir "*) ;; - *) temp_rpath="$temp_rpath $dir" ;; - esac - fi - fi fi # $linkmode,$pass = prog,link... if test "$alldeplibs" = yes && @@ -1736,11 +2201,51 @@ compiler." # We only need to search for static libraries continue fi + fi + link_static=no # Whether the deplib will be linked statically + if test -n "$library_names" && + { test "$prefer_static_libs" = no || test -z "$old_library"; }; then if test "$installed" = no; then notinst_deplibs="$notinst_deplibs $lib" need_relink=yes fi + # This is a shared library + + # Warn about portability, can't link against -module's on some systems (darwin) + if test "$shouldnotlink" = yes && test "$pass" = link ; then + $echo + if test "$linkmode" = prog; then + $echo "*** Warning: Linking the executable $output against the loadable module" + else + $echo "*** Warning: Linking the shared library $output against the loadable module" + fi + $echo "*** $linklib is not portable!" + fi + if test "$linkmode" = lib && + test "$hardcode_into_libs" = yes; then + # Hardcode the library path. + # Skip directories that are in the system default run-time + # search path. + case " $sys_lib_dlsearch_path " in + *" $absdir "*) ;; + *) + case "$compile_rpath " in + *" $absdir "*) ;; + *) compile_rpath="$compile_rpath $absdir" + esac + ;; + esac + case " $sys_lib_dlsearch_path " in + *" $libdir "*) ;; + *) + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" + esac + ;; + esac + fi if test -n "$old_archive_from_expsyms_cmds"; then # figure out the soname @@ -1754,7 +2259,7 @@ compiler." elif test -n "$soname_spec"; then # bleh windows case $host in - *cygwin*) + *cygwin* | mingw*) major=`expr $current - $age` versuffix="-$major" ;; @@ -1766,8 +2271,8 @@ compiler." # Make a new name for the extract_expsyms_cmds to use soroot="$soname" - soname=`echo $soroot | sed -e 's/^.*\///'` - newlib="libimp-`echo $soname | sed 's/^lib//;s/\.dll$//'`.a" + soname=`$echo $soroot | ${SED} -e 's/^.*\///'` + newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a" # If the library has no export list, then create one now if test -f "$output_objdir/$soname-def"; then : @@ -1798,9 +2303,9 @@ compiler." # make sure the library variables are pointing to the new library dir=$output_objdir linklib=$newlib - fi # test -n $old_archive_from_expsyms_cmds + fi # test -n "$old_archive_from_expsyms_cmds" - if test $linkmode = prog || test "$mode" != relink; then + if test "$linkmode" = prog || test "$mode" != relink; then add_shlibpath= add_dir= add= @@ -1809,6 +2314,22 @@ compiler." immediate | unsupported) if test "$hardcode_direct" = no; then add="$dir/$linklib" + case $host in + *-*-sco3.2v5* ) add_dir="-L$dir" ;; + *-*-darwin* ) + # if the lib is a module then we can not link against it, someone + # is ignoring the new warnings I added + if /usr/bin/file -L $add 2> /dev/null | grep "bundle" >/dev/null ; then + $echo "** Warning, lib $linklib is a module, not a shared library" + if test -z "$old_library" ; then + $echo + $echo "** And there doesn't seem to be a static archive available" + $echo "** The link will probably fail, sorry" + else + add="$dir/$old_library" + fi + fi + esac elif test "$hardcode_minus_L" = no; then case $host in *-*-sunos*) add_shlibpath="$dir" ;; @@ -1827,6 +2348,14 @@ compiler." add="$dir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$dir" + # Try looking first in the location we're being installed to. + if test -n "$inst_prefix_dir"; then + case "$libdir" in + [\\/]*) + add_dir="-L$inst_prefix_dir$libdir $add_dir" + ;; + esac + fi add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then add_shlibpath="$dir" @@ -1849,7 +2378,7 @@ compiler." *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;; esac fi - if test $linkmode = prog; then + if test "$linkmode" = prog; then test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" test -n "$add" && compile_deplibs="$add $compile_deplibs" else @@ -1866,7 +2395,7 @@ compiler." fi fi - if test $linkmode = prog || test "$mode" = relink; then + if test "$linkmode" = prog || test "$mode" = relink; then add_shlibpath= add_dir= add= @@ -1882,17 +2411,27 @@ compiler." *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; esac add="-l$name" + elif test "$hardcode_automatic" = yes; then + if test -n "$inst_prefix_dir" && test -f "$inst_prefix_dir$libdir/$linklib" ; then + add="$inst_prefix_dir$libdir/$linklib" + else + add="$libdir/$linklib" + fi else # We cannot seem to hardcode it, guess we'll fake it. - if test "X$installed" = Xyes; then - add_dir="-L$libdir" - else - add_dir="-L$DESTDIR$libdir" + add_dir="-L$libdir" + # Try looking first in the location we're being installed to. + if test -n "$inst_prefix_dir"; then + case "$libdir" in + [\\/]*) + add_dir="-L$inst_prefix_dir$libdir $add_dir" + ;; + esac fi add="-l$name" fi - if test $linkmode = prog; then + if test "$linkmode" = prog; then test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" test -n "$add" && finalize_deplibs="$add $finalize_deplibs" else @@ -1900,16 +2439,7 @@ compiler." test -n "$add" && deplibs="$add $deplibs" fi fi - elif test $linkmode = prog; then - if test "$alldeplibs" = yes && - { test "$deplibs_check_method" = pass_all || - { test "$build_libtool_libs" = yes && - test -n "$library_names"; }; }; then - # We only need to search for static libraries - continue - fi - - # Try to link the static library + elif test "$linkmode" = prog; then # Here we assume that one of hardcode_direct or hardcode_minus_L # is not unsupported. This is valid on all known static and # shared platforms. @@ -1929,20 +2459,21 @@ compiler." # Just print a warning and add the library to dependency_libs so # that the program can be linked against the static library. - echo - echo "*** Warning: This library needs some functionality provided by $lib." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have." + $echo + $echo "*** Warning: This system can not link to static lib archive $lib." + $echo "*** I have the capability to make that library automatically link in when" + $echo "*** you link to this library. But I can only do this if you have a" + $echo "*** shared version of the library, which you do not appear to have." if test "$module" = yes; then - echo "*** Therefore, libtool will create a static module, that should work " - echo "*** as long as the dlopening application is linked with the -dlopen flag." + $echo "*** But as you try to build a module library, libtool will still create " + $echo "*** a static module, that should work as long as the dlopening application" + $echo "*** is linked with the -dlopen flag to resolve symbols at runtime." if test -z "$global_symbol_pipe"; then - echo - echo "*** However, this would only work if libtool was able to extract symbol" - echo "*** lists from a program, using \`nm' or equivalent, but libtool could" - echo "*** not find such a program. So, this module is probably useless." - echo "*** \`nm' from GNU binutils and a full rebuild may help." + $echo + $echo "*** However, this would only work if libtool was able to extract symbol" + $echo "*** lists from a program, using \`nm' or equivalent, but libtool could" + $echo "*** not find such a program. So, this module is probably useless." + $echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then build_libtool_libs=module @@ -1959,10 +2490,10 @@ compiler." fi fi # link shared/static library? - if test $linkmode = lib; then + if test "$linkmode" = lib; then if test -n "$dependency_libs" && - { test $hardcode_into_libs != yes || test $build_old_libs = yes || - test $link_static = yes; }; then + { test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes || + test "$link_static" = yes; }; then # Extract -R from dependency_libs temp_deplibs= for libdir in $dependency_libs; do @@ -1985,13 +2516,15 @@ compiler." tmp_libs= for deplib in $dependency_libs; do newdependency_libs="$deplib $newdependency_libs" - case "$tmp_libs " in - *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; - esac + if test "X$duplicate_deps" = "Xyes" ; then + case "$tmp_libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi tmp_libs="$tmp_libs $deplib" done - if test $link_all_deplibs != no; then + if test "$link_all_deplibs" != no; then # Add the search paths of all dependency libraries for deplib in $dependency_libs; do case $deplib in @@ -2011,9 +2544,9 @@ compiler." ;; esac if grep "^installed=no" $deplib > /dev/null; then - path="-L$absdir/$objdir" + path="$absdir/$objdir" else - eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` if test -z "$libdir"; then $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 exit 1 @@ -2021,12 +2554,53 @@ compiler." if test "$absdir" != "$libdir"; then $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2 fi - path="-L$absdir" + path="$absdir" fi + depdepl= + case $host in + *-*-darwin*) + # we do not want to link against static libs, but need to link against shared + eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` + if test -n "$deplibrary_names" ; then + for tmp in $deplibrary_names ; do + depdepl=$tmp + done + if test -f "$path/$depdepl" ; then + depdepl="$path/$depdepl" + fi + newlib_search_path="$newlib_search_path $path" + path="" + fi + ;; + *) + path="-L$path" + ;; + esac + + ;; + -l*) + case $host in + *-*-darwin*) + # Again, we only want to link against shared libraries + eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"` + for tmp in $newlib_search_path ; do + if test -f "$tmp/lib$tmp_libs.dylib" ; then + eval depdepl="$tmp/lib$tmp_libs.dylib" + break + fi + done + path="" + ;; + *) continue ;; + esac ;; *) continue ;; esac case " $deplibs " in + *" $depdepl "*) ;; + *) deplibs="$deplibs $depdepl" ;; + esac + case " $deplibs " in *" $path "*) ;; *) deplibs="$deplibs $path" ;; esac @@ -2034,15 +2608,15 @@ compiler." fi # link_all_deplibs != no fi # linkmode = lib done # for deplib in $libs - if test $pass = dlpreopen; then + dependency_libs="$newdependency_libs" + if test "$pass" = dlpreopen; then # Link the dlpreopened libraries before other libraries for deplib in $save_deplibs; do deplibs="$deplib $deplibs" done fi - if test $pass != dlopen; then - test $pass != scan && dependency_libs="$newdependency_libs" - if test $pass != conv; then + if test "$pass" != dlopen; then + if test "$pass" != conv; then # Make sure lib_search_path contains only unique directories. lib_search_path= for dir in $newlib_search_path; do @@ -2064,9 +2638,30 @@ compiler." eval tmp_libs=\"\$$var\" new_libs= for deplib in $tmp_libs; do + # FIXME: Pedantically, this is the right thing to do, so + # that some nasty dependency loop isn't accidentally + # broken: + #new_libs="$deplib $new_libs" + # Pragmatically, this seems to cause very few problems in + # practice: case $deplib in -L*) new_libs="$deplib $new_libs" ;; + -R*) ;; *) + # And here is the reason: when a library appears more + # than once as an explicit dependence of a library, or + # is implicitly linked in more than once by the + # compiler, it is considered special, and multiple + # occurrences thereof are not removed. Compare this + # with having the same library being listed as a + # dependency of multiple other libraries: in this case, + # we know (pedantically, we assume) the library does not + # need to be listed more than once, so we keep only the + # last copy. This is not always right, but it is rare + # enough that we require users that really mean to play + # such unportable linking tricks to link the library + # using -Wl,-lname, so that libtool does not consider it + # for duplicate removal. case " $specialdeplibs " in *" $deplib "*) new_libs="$deplib $new_libs" ;; *) @@ -2094,19 +2689,31 @@ compiler." eval $var=\"$tmp_libs\" done # for var fi - if test "$pass" = "conv" && - { test "$linkmode" = "lib" || test "$linkmode" = "prog"; }; then - libs="$deplibs" # reset libs - deplibs= - fi + # Last step: remove runtime libs from dependency_libs (they stay in deplibs) + tmp_libs= + for i in $dependency_libs ; do + case " $predeps $postdeps $compiler_lib_search_path " in + *" $i "*) + i="" + ;; + esac + if test -n "$i" ; then + tmp_libs="$tmp_libs $i" + fi + done + dependency_libs=$tmp_libs done # for pass - if test $linkmode = prog; then + if test "$linkmode" = prog; then dlfiles="$newdlfiles" dlprefiles="$newdlprefiles" fi case $linkmode in oldlib) + if test -n "$deplibs"; then + $echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2 + fi + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2 fi @@ -2120,7 +2727,7 @@ compiler." fi if test -n "$vinfo"; then - $echo "$modename: warning: \`-version-info' is ignored for archives" 1>&2 + $echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2 fi if test -n "$release"; then @@ -2142,6 +2749,7 @@ compiler." case $outputname in lib*) name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` + eval shared_ext=\"$shrext\" eval libname=\"$libname_spec\" ;; *) @@ -2153,6 +2761,7 @@ compiler." if test "$need_lib_prefix" != no; then # Add the "lib" prefix for modules if required name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` + eval shared_ext=\"$shrext\" eval libname=\"$libname_spec\" else libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` @@ -2165,9 +2774,9 @@ compiler." $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1 exit 1 else - echo - echo "*** Warning: Linking the shared library $output against the non-libtool" - echo "*** objects $objs is not portable!" + $echo + $echo "*** Warning: Linking the shared library $output against the non-libtool" + $echo "*** objects $objs is not portable!" libobjs="$libobjs $objs" fi fi @@ -2177,7 +2786,7 @@ compiler." fi set dummy $rpath - if test $# -gt 2; then + if test "$#" -gt 2; then $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2 fi install_libdir="$2" @@ -2186,14 +2795,16 @@ compiler." if test -z "$rpath"; then if test "$build_libtool_libs" = yes; then # Building a libtool convenience library. - libext=al + # Some compilers have problems with a `.al' extension so + # convenience libraries should have the same extension an + # archive normally would. oldlibs="$output_objdir/$libname.$libext $oldlibs" build_libtool_libs=convenience build_old_libs=yes fi if test -n "$vinfo"; then - $echo "$modename: warning: \`-version-info' is ignored for convenience libraries" 1>&2 + $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2 fi if test -n "$release"; then @@ -2212,9 +2823,46 @@ compiler." exit 1 fi - current="$2" - revision="$3" - age="$4" + # convert absolute version numbers to libtool ages + # this retains compatibility with .la files and attempts + # to make the code below a bit more comprehensible + + case $vinfo_number in + yes) + number_major="$2" + number_minor="$3" + number_revision="$4" + # + # There are really only two kinds -- those that + # use the current revision as the major version + # and those that subtract age and use age as + # a minor version. But, then there is irix + # which has an extra 1 added just for fun + # + case $version_type in + darwin|linux|osf|windows) + current=`expr $number_major + $number_minor` + age="$number_minor" + revision="$number_revision" + ;; + freebsd-aout|freebsd-elf|sunos) + current="$number_major" + revision="$number_minor" + age="0" + ;; + irix|nonstopux) + current=`expr $number_major + $number_minor - 1` + age="$number_minor" + revision="$number_minor" + ;; + esac + ;; + no) + current="$2" + revision="$3" + age="$4" + ;; + esac # Check that each of the things are valid numbers. case $current in @@ -2244,7 +2892,7 @@ compiler." ;; esac - if test $age -gt $current; then + if test "$age" -gt "$current"; then $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2 $echo "$modename: \`$vinfo' is not valid version information" 1>&2 exit 1 @@ -2277,16 +2925,21 @@ compiler." versuffix=".$current"; ;; - irix) + irix | nonstopux) major=`expr $current - $age + 1` - verstring="sgi$major.$revision" + + case $version_type in + nonstopux) verstring_prefix=nonstopux ;; + *) verstring_prefix=sgi ;; + esac + verstring="$verstring_prefix$major.$revision" # Add in all the interfaces that we are compatible with. loop=$revision - while test $loop != 0; do + while test "$loop" -ne 0; do iface=`expr $revision - $loop` loop=`expr $loop - 1` - verstring="sgi$major.$iface:$verstring" + verstring="$verstring_prefix$major.$iface:$verstring" done # Before this point, $major must not contain `.'. @@ -2300,13 +2953,13 @@ compiler." ;; osf) - major=`expr $current - $age` + major=.`expr $current - $age` versuffix=".$current.$age.$revision" verstring="$current.$age.$revision" # Add in all the interfaces that we are compatible with. loop=$age - while test $loop != 0; do + while test "$loop" -ne 0; do iface=`expr $current - $loop` loop=`expr $loop - 1` verstring="$verstring:${iface}.0" @@ -2330,7 +2983,7 @@ compiler." *) $echo "$modename: unknown library version type \`$version_type'" 1>&2 - echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 + $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 exit 1 ;; esac @@ -2338,12 +2991,11 @@ compiler." # Clear the version info if we defaulted, and they specified a release. if test -z "$vinfo" && test -n "$release"; then major= - verstring="0.0" case $version_type in darwin) # we can't check for "0.0" in archive_cmds due to quoting # problems, so we reset it completely - verstring="" + verstring= ;; *) verstring="0.0" @@ -2377,9 +3029,24 @@ compiler." fi if test "$mode" != relink; then - # Remove our outputs. - $show "${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.*" - $run ${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.* + # Remove our outputs, but don't remove object files since they + # may have been created when compiling PIC objects. + removelist= + tempremovelist=`$echo "$output_objdir/*"` + for p in $tempremovelist; do + case $p in + *.$objext) + ;; + $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) + removelist="$removelist $p" + ;; + *) ;; + esac + done + if test -n "$removelist"; then + $show "${rm}r $removelist" + $run ${rm}r $removelist + fi fi # Now set the variables for building old libraries. @@ -2392,9 +3059,9 @@ compiler." # Eliminate all temporary directories. for path in $notinst_path; do - lib_search_path=`echo "$lib_search_path " | sed -e 's% $path % %g'` - deplibs=`echo "$deplibs " | sed -e 's% -L$path % %g'` - dependency_libs=`echo "$dependency_libs " | sed -e 's% -L$path % %g'` + lib_search_path=`$echo "$lib_search_path " | ${SED} -e 's% $path % %g'` + deplibs=`$echo "$deplibs " | ${SED} -e 's% -L$path % %g'` + dependency_libs=`$echo "$dependency_libs " | ${SED} -e 's% -L$path % %g'` done if test -n "$xrpath"; then @@ -2407,7 +3074,7 @@ compiler." *) finalize_rpath="$finalize_rpath $libdir" ;; esac done - if test $hardcode_into_libs != yes || test $build_old_libs = yes; then + if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then dependency_libs="$temp_xrpath $dependency_libs" fi fi @@ -2445,12 +3112,13 @@ compiler." *-*-netbsd*) # Don't link with libc until the a.out ld.so is fixed. ;; - *-*-openbsd*) + *-*-openbsd* | *-*-freebsd*) # Do not include libc due to us having libc/libc_r. + test "X$arg" = "X-lc" && continue ;; - *) + *) # Add libc to deplibs on all other systems if necessary. - if test $build_libtool_need_lc = "yes"; then + if test "$build_libtool_need_lc" = "yes"; then deplibs="$deplibs -lc" fi ;; @@ -2477,7 +3145,7 @@ compiler." # This might be a little naive. We might want to check # whether the library exists or not. But this is on # osf3 & osf4 and I'm not really sure... Just - # implementing what was already the behaviour. + # implementing what was already the behavior. newdeplibs=$deplibs ;; test_compile) @@ -2490,43 +3158,22 @@ compiler." int main() { return 0; } EOF $rm conftest - $CC -o conftest conftest.c $deplibs - if test $? -eq 0 ; then + $LTCC -o conftest conftest.c $deplibs + if test "$?" -eq 0 ; then ldd_output=`ldd conftest` for i in $deplibs; do name="`expr $i : '-l\(.*\)'`" # If $name is empty we are operating on a -L argument. - if test -n "$name" && test "$name" != "0"; then - libname=`eval \\$echo \"$libname_spec\"` - deplib_matches=`eval \\$echo \"$library_names_spec\"` - set dummy $deplib_matches - deplib_match=$2 - if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then - newdeplibs="$newdeplibs $i" - else - droppeddeps=yes - echo - echo "*** Warning: This library needs some functionality provided by $i." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have." - fi - else - newdeplibs="$newdeplibs $i" - fi - done - else - # Error occured in the first compile. Let's try to salvage the situation: - # Compile a seperate program for each library. - for i in $deplibs; do - name="`expr $i : '-l\(.*\)'`" - # If $name is empty we are operating on a -L argument. - if test -n "$name" && test "$name" != "0"; then - $rm conftest - $CC -o conftest conftest.c $i - # Did it work? - if test $? -eq 0 ; then - ldd_output=`ldd conftest` + if test "$name" != "" && test "$name" -ne "0"; then + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + case " $predeps $postdeps " in + *" $i "*) + newdeplibs="$newdeplibs $i" + i="" + ;; + esac + fi + if test -n "$i" ; then libname=`eval \\$echo \"$libname_spec\"` deplib_matches=`eval \\$echo \"$library_names_spec\"` set dummy $deplib_matches @@ -2535,19 +3182,64 @@ EOF newdeplibs="$newdeplibs $i" else droppeddeps=yes - echo - echo "*** Warning: This library needs some functionality provided by $i." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have." + $echo + $echo "*** Warning: dynamic linker does not accept needed library $i." + $echo "*** I have the capability to make that library automatically link in when" + $echo "*** you link to this library. But I can only do this if you have a" + $echo "*** shared version of the library, which I believe you do not have" + $echo "*** because a test_compile did reveal that the linker did not use it for" + $echo "*** its dynamic dependency list that programs get resolved with at runtime." + fi + fi + else + newdeplibs="$newdeplibs $i" + fi + done + else + # Error occurred in the first compile. Let's try to salvage + # the situation: Compile a separate program for each library. + for i in $deplibs; do + name="`expr $i : '-l\(.*\)'`" + # If $name is empty we are operating on a -L argument. + if test "$name" != "" && test "$name" != "0"; then + $rm conftest + $LTCC -o conftest conftest.c $i + # Did it work? + if test "$?" -eq 0 ; then + ldd_output=`ldd conftest` + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + case " $predeps $postdeps " in + *" $i "*) + newdeplibs="$newdeplibs $i" + i="" + ;; + esac + fi + if test -n "$i" ; then + libname=`eval \\$echo \"$libname_spec\"` + deplib_matches=`eval \\$echo \"$library_names_spec\"` + set dummy $deplib_matches + deplib_match=$2 + if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then + newdeplibs="$newdeplibs $i" + else + droppeddeps=yes + $echo + $echo "*** Warning: dynamic linker does not accept needed library $i." + $echo "*** I have the capability to make that library automatically link in when" + $echo "*** you link to this library. But I can only do this if you have a" + $echo "*** shared version of the library, which you do not appear to have" + $echo "*** because a test_compile did reveal that the linker did not use this one" + $echo "*** as a dynamic dependency that programs can get resolved with at runtime." + fi fi else droppeddeps=yes - echo - echo "*** Warning! Library $i is needed by this library but I was not able to" - echo "*** make it link in! You will probably need to install it or some" - echo "*** library that it depends on before this library will be fully" - echo "*** functional. Installing it before continuing would be even better." + $echo + $echo "*** Warning! Library $i is needed by this library but I was not able to" + $echo "*** make it link in! You will probably need to install it or some" + $echo "*** library that it depends on before this library will be fully" + $echo "*** functional. Installing it before continuing would be even better." fi else newdeplibs="$newdeplibs $i" @@ -2561,11 +3253,20 @@ EOF for a_deplib in $deplibs; do name="`expr $a_deplib : '-l\(.*\)'`" # If $name is empty we are operating on a -L argument. - if test -n "$name" && test "$name" != "0"; then - libname=`eval \\$echo \"$libname_spec\"` - for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do - potential_libs=`ls $i/$libname[.-]* 2>/dev/null` - for potent_lib in $potential_libs; do + if test "$name" != "" && test "$name" != "0"; then + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + case " $predeps $postdeps " in + *" $a_deplib "*) + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + ;; + esac + fi + if test -n "$a_deplib" ; then + libname=`eval \\$echo \"$libname_spec\"` + for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do + potential_libs=`ls $i/$libname[.-]* 2>/dev/null` + for potent_lib in $potential_libs; do # Follow soft links. if ls -lLd "$potent_lib" 2>/dev/null \ | grep " -> " >/dev/null; then @@ -2578,28 +3279,36 @@ EOF # but so what? potlib="$potent_lib" while test -h "$potlib" 2>/dev/null; do - potliblink=`ls -ld $potlib | sed 's/.* -> //'` + potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` case $potliblink in [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";; esac done if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \ - | sed 10q \ - | egrep "$file_magic_regex" > /dev/null; then + | ${SED} 10q \ + | $EGREP "$file_magic_regex" > /dev/null; then newdeplibs="$newdeplibs $a_deplib" a_deplib="" break 2 fi - done - done + done + done + fi if test -n "$a_deplib" ; then droppeddeps=yes - echo - echo "*** Warning: This library needs some functionality provided by $a_deplib." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have." + $echo + $echo "*** Warning: linker path does not have real file for library $a_deplib." + $echo "*** I have the capability to make that library automatically link in when" + $echo "*** you link to this library. But I can only do this if you have a" + $echo "*** shared version of the library, which you do not appear to have" + $echo "*** because I did check the linker path looking for a file starting" + if test -z "$potlib" ; then + $echo "*** with $libname but no candidates were found. (...for file magic test)" + else + $echo "*** with $libname and none of the candidates passed a file format test" + $echo "*** using a file magic. Last file checked: $potlib" + fi fi else # Add a -L argument. @@ -2614,26 +3323,44 @@ EOF name="`expr $a_deplib : '-l\(.*\)'`" # If $name is empty we are operating on a -L argument. if test -n "$name" && test "$name" != "0"; then - libname=`eval \\$echo \"$libname_spec\"` - for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do - potential_libs=`ls $i/$libname[.-]* 2>/dev/null` - for potent_lib in $potential_libs; do - if eval echo \"$potent_lib\" 2>/dev/null \ - | sed 10q \ - | egrep "$match_pattern_regex" > /dev/null; then - newdeplibs="$newdeplibs $a_deplib" - a_deplib="" - break 2 - fi + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + case " $predeps $postdeps " in + *" $a_deplib "*) + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + ;; + esac + fi + if test -n "$a_deplib" ; then + libname=`eval \\$echo \"$libname_spec\"` + for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do + potential_libs=`ls $i/$libname[.-]* 2>/dev/null` + for potent_lib in $potential_libs; do + potlib="$potent_lib" # see symlink-check above in file_magic test + if eval $echo \"$potent_lib\" 2>/dev/null \ + | ${SED} 10q \ + | $EGREP "$match_pattern_regex" > /dev/null; then + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + break 2 + fi + done done - done + fi if test -n "$a_deplib" ; then droppeddeps=yes - echo - echo "*** Warning: This library needs some functionality provided by $a_deplib." - echo "*** I have the capability to make that library automatically link in when" - echo "*** you link to this library. But I can only do this if you have a" - echo "*** shared version of the library, which you do not appear to have." + $echo + $echo "*** Warning: linker path does not have real file for library $a_deplib." + $echo "*** I have the capability to make that library automatically link in when" + $echo "*** you link to this library. But I can only do this if you have a" + $echo "*** shared version of the library, which you do not appear to have" + $echo "*** because I did check the linker path looking for a file starting" + if test -z "$potlib" ; then + $echo "*** with $libname but no candidates were found. (...for regex pattern test)" + else + $echo "*** with $libname and none of the candidates passed a file format test" + $echo "*** using a regex pattern. Last file checked: $potlib" + fi fi else # Add a -L argument. @@ -2643,16 +3370,23 @@ EOF ;; none | unknown | *) newdeplibs="" - if $echo "X $deplibs" | $Xsed -e 's/ -lc$//' \ - -e 's/ -[LR][^ ]*//g' -e 's/[ ]//g' | - grep . >/dev/null; then - echo + tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \ + -e 's/ -[LR][^ ]*//g'` + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + for i in $predeps $postdeps ; do + # can't use Xsed below, because $i might contain '/' + tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"` + done + fi + if $echo "X $tmp_deplibs" | $Xsed -e 's/[ ]//g' \ + | grep . >/dev/null; then + $echo if test "X$deplibs_check_method" = "Xnone"; then - echo "*** Warning: inter-library dependencies are not supported in this platform." + $echo "*** Warning: inter-library dependencies are not supported in this platform." else - echo "*** Warning: inter-library dependencies are not known to be supported." + $echo "*** Warning: inter-library dependencies are not known to be supported." fi - echo "*** All declared inter-library dependencies are being dropped." + $echo "*** All declared inter-library dependencies are being dropped." droppeddeps=yes fi ;; @@ -2672,17 +3406,17 @@ EOF if test "$droppeddeps" = yes; then if test "$module" = yes; then - echo - echo "*** Warning: libtool could not satisfy all declared inter-library" - echo "*** dependencies of module $libname. Therefore, libtool will create" - echo "*** a static module, that should work as long as the dlopening" - echo "*** application is linked with the -dlopen flag." + $echo + $echo "*** Warning: libtool could not satisfy all declared inter-library" + $echo "*** dependencies of module $libname. Therefore, libtool will create" + $echo "*** a static module, that should work as long as the dlopening" + $echo "*** application is linked with the -dlopen flag." if test -z "$global_symbol_pipe"; then - echo - echo "*** However, this would only work if libtool was able to extract symbol" - echo "*** lists from a program, using \`nm' or equivalent, but libtool could" - echo "*** not find such a program. So, this module is probably useless." - echo "*** \`nm' from GNU binutils and a full rebuild may help." + $echo + $echo "*** However, this would only work if libtool was able to extract symbol" + $echo "*** lists from a program, using \`nm' or equivalent, but libtool could" + $echo "*** not find such a program. So, this module is probably useless." + $echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" @@ -2692,16 +3426,16 @@ EOF build_libtool_libs=no fi else - echo "*** The inter-library dependencies that have been dropped here will be" - echo "*** automatically added whenever a program is linked with this library" - echo "*** or is declared to -dlopen it." + $echo "*** The inter-library dependencies that have been dropped here will be" + $echo "*** automatically added whenever a program is linked with this library" + $echo "*** or is declared to -dlopen it." - if test $allow_undefined = no; then - echo - echo "*** Since this library must not contain undefined symbols," - echo "*** because either the platform does not support them or" - echo "*** it was explicitly requested with -no-undefined," - echo "*** libtool will only create a static version of it." + if test "$allow_undefined" = no; then + $echo + $echo "*** Since this library must not contain undefined symbols," + $echo "*** because either the platform does not support them or" + $echo "*** it was explicitly requested with -no-undefined," + $echo "*** libtool will only create a static version of it." if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module @@ -2723,7 +3457,7 @@ EOF # Test again, we may have decided not to build it any more if test "$build_libtool_libs" = yes; then - if test $hardcode_into_libs = yes; then + if test "$hardcode_into_libs" = yes; then # Hardcode the library paths hardcode_libdirs= dep_rpath= @@ -2759,7 +3493,11 @@ EOF if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" - eval dep_rpath=\"$hardcode_libdir_flag_spec\" + if test -n "$hardcode_libdir_flag_spec_ld"; then + eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" + else + eval dep_rpath=\"$hardcode_libdir_flag_spec\" + fi fi if test -n "$runpath_var" && test -n "$perm_rpath"; then # We should set the runpath_var. @@ -2779,6 +3517,7 @@ EOF fi # Get the real and link names of the library. + eval shared_ext=\"$shrext\" eval library_names=\"$library_names_spec\" set dummy $library_names realname="$2" @@ -2789,7 +3528,9 @@ EOF else soname="$realname" fi - test -z "$dlname" && dlname=$soname + if test -z "$dlname"; then + dlname=$soname + fi lib="$output_objdir/$realname" for link @@ -2797,23 +3538,6 @@ EOF linknames="$linknames $link" done - # Ensure that we have .o objects for linkers which dislike .lo - # (e.g. aix) in case we are running --disable-static - for obj in $libobjs; do - xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` - if test "X$xdir" = "X$obj"; then - xdir="." - else - xdir="$xdir" - fi - baseobj=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` - oldobj=`$echo "X$baseobj" | $Xsed -e "$lo2o"` - if test ! -f $xdir/$oldobj; then - $show "(cd $xdir && ${LN_S} $baseobj $oldobj)" - $run eval '(cd $xdir && ${LN_S} $baseobj $oldobj)' || exit $? - fi - done - # Use standard objects if they are pic test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` @@ -2827,13 +3551,21 @@ EOF save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" - $show "$cmd" - $run eval "$cmd" || exit $? + if len=`expr "X$cmd" : ".*"` && + test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then + $show "$cmd" + $run eval "$cmd" || exit $? + skipped_export=false + else + # The command line is too long to execute in one step. + $show "using reloadable object file for export list..." + skipped_export=: + fi done IFS="$save_ifs" if test -n "$export_symbols_regex"; then - $show "egrep -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\"" - $run eval 'egrep -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' + $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\"" + $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' $show "$mv \"${export_symbols}T\" \"$export_symbols\"" $run eval '$mv "${export_symbols}T" "$export_symbols"' fi @@ -2844,17 +3576,29 @@ EOF $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"' fi + tmp_deplibs= + for test_deplib in $deplibs; do + case " $convenience " in + *" $test_deplib "*) ;; + *) + tmp_deplibs="$tmp_deplibs $test_deplib" + ;; + esac + done + deplibs="$tmp_deplibs" + if test -n "$convenience"; then if test -n "$whole_archive_flag_spec"; then + save_libobjs=$libobjs eval libobjs=\"\$libobjs $whole_archive_flag_spec\" else gentop="$output_objdir/${outputname}x" $show "${rm}r $gentop" $run ${rm}r "$gentop" - $show "mkdir $gentop" - $run mkdir "$gentop" + $show "$mkdir $gentop" + $run $mkdir "$gentop" status=$? - if test $status -ne 0 && test ! -d "$gentop"; then + if test "$status" -ne 0 && test ! -d "$gentop"; then exit $status fi generated="$generated $gentop" @@ -2870,16 +3614,42 @@ EOF $show "${rm}r $xdir" $run ${rm}r "$xdir" - $show "mkdir $xdir" - $run mkdir "$xdir" + $show "$mkdir $xdir" + $run $mkdir "$xdir" status=$? - if test $status -ne 0 && test ! -d "$xdir"; then + if test "$status" -ne 0 && test ! -d "$xdir"; then exit $status fi + # We will extract separately just the conflicting names and we will no + # longer touch any unique names. It is faster to leave these extract + # automatically by $AR in one run. $show "(cd $xdir && $AR x $xabs)" $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? + if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then + : + else + $echo "$modename: warning: object name conflicts; renaming object files" 1>&2 + $echo "$modename: warning: to ensure that they will not overwrite" 1>&2 + $AR t "$xabs" | sort | uniq -cd | while read -r count name + do + i=1 + while test "$i" -le "$count" + do + # Put our $i before any first dot (extension) + # Never overwrite any file + name_to="$name" + while test "X$name_to" = "X$name" || test -f "$xdir/$name_to" + do + name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"` + done + $show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')" + $run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $? + i=`expr $i + 1` + done + done + fi - libobjs="$libobjs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP` + libobjs="$libobjs "`find $xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP` done fi fi @@ -2895,10 +3665,130 @@ EOF fi # Do each of the archive commands. + if test "$module" = yes && test -n "$module_cmds" ; then + if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then + eval cmds=\"$module_expsym_cmds\" + else + eval cmds=\"$module_cmds\" + fi + else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then eval cmds=\"$archive_expsym_cmds\" else eval cmds=\"$archive_cmds\" + fi + fi + + if test "X$skipped_export" != "X:" && len=`expr "X$cmds" : ".*"` && + test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then + : + else + # The command line is too long to link in one step, link piecewise. + $echo "creating reloadable object files..." + + # Save the value of $output and $libobjs because we want to + # use them later. If we have whole_archive_flag_spec, we + # want to use save_libobjs as it was before + # whole_archive_flag_spec was expanded, because we can't + # assume the linker understands whole_archive_flag_spec. + # This may have to be revisited, in case too many + # convenience libraries get linked in and end up exceeding + # the spec. + if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then + save_libobjs=$libobjs + fi + save_output=$output + + # Clear the reloadable object creation command queue and + # initialize k to one. + test_cmds= + concat_cmds= + objlist= + delfiles= + last_robj= + k=1 + output=$output_objdir/$save_output-${k}.$objext + # Loop over the list of objects to be linked. + for obj in $save_libobjs + do + eval test_cmds=\"$reload_cmds $objlist $last_robj\" + if test "X$objlist" = X || + { len=`expr "X$test_cmds" : ".*"` && + test "$len" -le "$max_cmd_len"; }; then + objlist="$objlist $obj" + else + # The command $test_cmds is almost too long, add a + # command to the queue. + if test "$k" -eq 1 ; then + # The first file doesn't have a previous command to add. + eval concat_cmds=\"$reload_cmds $objlist $last_robj\" + else + # All subsequent reloadable object files will link in + # the last one created. + eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\" + fi + last_robj=$output_objdir/$save_output-${k}.$objext + k=`expr $k + 1` + output=$output_objdir/$save_output-${k}.$objext + objlist=$obj + len=1 + fi + done + # Handle the remaining objects by creating one last + # reloadable object file. All subsequent reloadable object + # files will link in the last one created. + test -z "$concat_cmds" || concat_cmds=$concat_cmds~ + eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\" + + if ${skipped_export-false}; then + $show "generating symbol list for \`$libname.la'" + export_symbols="$output_objdir/$libname.exp" + $run $rm $export_symbols + libobjs=$output + # Append the command to create the export file. + eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\" + fi + + # Set up a command to remove the reloadale object files + # after they are used. + i=0 + while test "$i" -lt "$k" + do + i=`expr $i + 1` + delfiles="$delfiles $output_objdir/$save_output-${i}.$objext" + done + + $echo "creating a temporary reloadable object file: $output" + + # Loop through the commands generated above and execute them. + save_ifs="$IFS"; IFS='~' + for cmd in $concat_cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + + libobjs=$output + # Restore the value of output. + output=$save_output + + if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then + eval libobjs=\"\$libobjs $whole_archive_flag_spec\" + fi + # Expand the library linking commands again to reset the + # value of $libobjs for piecewise linking. + + # Do each of the archive commands. + if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then + eval cmds=\"$archive_expsym_cmds\" + else + eval cmds=\"$archive_cmds\" + fi + + # Append the command to remove the reloadable object files + # to the just-reset $cmds. + eval cmds=\"\$cmds~$rm $delfiles\" fi save_ifs="$IFS"; IFS='~' for cmd in $cmds; do @@ -2990,10 +3880,10 @@ EOF gentop="$output_objdir/${obj}x" $show "${rm}r $gentop" $run ${rm}r "$gentop" - $show "mkdir $gentop" - $run mkdir "$gentop" + $show "$mkdir $gentop" + $run $mkdir "$gentop" status=$? - if test $status -ne 0 && test ! -d "$gentop"; then + if test "$status" -ne 0 && test ! -d "$gentop"; then exit $status fi generated="$generated $gentop" @@ -3009,16 +3899,42 @@ EOF $show "${rm}r $xdir" $run ${rm}r "$xdir" - $show "mkdir $xdir" - $run mkdir "$xdir" + $show "$mkdir $xdir" + $run $mkdir "$xdir" status=$? - if test $status -ne 0 && test ! -d "$xdir"; then + if test "$status" -ne 0 && test ! -d "$xdir"; then exit $status fi + # We will extract separately just the conflicting names and we will no + # longer touch any unique names. It is faster to leave these extract + # automatically by $AR in one run. $show "(cd $xdir && $AR x $xabs)" $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? + if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then + : + else + $echo "$modename: warning: object name conflicts; renaming object files" 1>&2 + $echo "$modename: warning: to ensure that they will not overwrite" 1>&2 + $AR t "$xabs" | sort | uniq -cd | while read -r count name + do + i=1 + while test "$i" -le "$count" + do + # Put our $i before any first dot (extension) + # Never overwrite any file + name_to="$name" + while test "X$name_to" = "X$name" || test -f "$xdir/$name_to" + do + name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"` + done + $show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')" + $run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $? + i=`expr $i + 1` + done + done + fi - reload_conv_objs="$reload_objs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP` + reload_conv_objs="$reload_objs "`find $xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP` done fi fi @@ -3054,8 +3970,8 @@ EOF # Create an invalid libtool object if no PIC, so that we don't # accidentally link it into a program. - $show "echo timestamp > $libobj" - $run eval "echo timestamp > $libobj" || exit $? + # $show "echo timestamp > $libobj" + # $run eval "echo timestamp > $libobj" || exit $? exit 0 fi @@ -3071,20 +3987,6 @@ EOF $run eval "$cmd" || exit $? done IFS="$save_ifs" - else - # Just create a symlink. - $show $rm $libobj - $run $rm $libobj - xdir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'` - if test "X$xdir" = "X$libobj"; then - xdir="." - else - xdir="$xdir" - fi - baseobj=`$echo "X$libobj" | $Xsed -e 's%^.*/%%'` - oldobj=`$echo "X$baseobj" | $Xsed -e "$lo2o"` - $show "(cd $xdir && $LN_S $oldobj $baseobj)" - $run eval '(cd $xdir && $LN_S $oldobj $baseobj)' || exit $? fi if test -n "$gentop"; then @@ -3097,7 +3999,7 @@ EOF prog) case $host in - *cygwin*) output=`echo $output | sed -e 's,.exe$,,;s,$,.exe,'` ;; + *cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;; esac if test -n "$vinfo"; then $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2 @@ -3122,6 +4024,16 @@ EOF ;; esac + case $host in + *darwin*) + # Don't allow lazy linking, it breaks C++ global constructors + if test "$tagname" = CXX ; then + compile_command="$compile_command ${wl}-bind_at_load" + finalize_command="$finalize_command ${wl}-bind_at_load" + fi + ;; + esac + compile_command="$compile_command $compile_deplibs" finalize_command="$finalize_command $finalize_deplibs" @@ -3272,12 +4184,12 @@ extern \"C\" { done if test -n "$exclude_expsyms"; then - $run eval 'egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' + $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' $run eval '$mv "$nlist"T "$nlist"' fi if test -n "$export_symbols_regex"; then - $run eval 'egrep -e "$export_symbols_regex" "$nlist" > "$nlist"T' + $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' $run eval '$mv "$nlist"T "$nlist"' fi @@ -3285,9 +4197,9 @@ extern \"C\" { if test -z "$export_symbols"; then export_symbols="$output_objdir/$output.exp" $run $rm $export_symbols - $run eval "sed -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' + $run eval "${SED} -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' else - $run eval "sed -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"' + $run eval "${SED} -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"' $run eval 'grep -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T' $run eval 'mv "$nlist"T "$nlist"' fi @@ -3295,8 +4207,8 @@ extern \"C\" { for arg in $dlprefiles; do $show "extracting global C symbols from \`$arg'" - name=`echo "$arg" | sed -e 's%^.*/%%'` - $run eval 'echo ": $name " >> "$nlist"' + name=`$echo "$arg" | ${SED} -e 's%^.*/%%'` + $run eval '$echo ": $name " >> "$nlist"' $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" done @@ -3305,12 +4217,18 @@ extern \"C\" { test -f "$nlist" || : > "$nlist" if test -n "$exclude_expsyms"; then - egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T + $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T $mv "$nlist"T "$nlist" fi # Try sorting and uniquifying the output. - if grep -v "^: " < "$nlist" | sort +2 | uniq > "$nlist"S; then + if grep -v "^: " < "$nlist" | + if sort -k 3 /dev/null 2>&1; then + sort -k 3 + else + sort +2 + fi | + uniq > "$nlist"S; then : else grep -v "^: " < "$nlist" > "$nlist"S @@ -3319,7 +4237,7 @@ extern \"C\" { if test -f "$nlist"S; then eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"' else - echo '/* NONE */' >> "$output_objdir/$dlsyms" + $echo '/* NONE */' >> "$output_objdir/$dlsyms" fi $echo >> "$output_objdir/$dlsyms" "\ @@ -3371,18 +4289,18 @@ static const void *lt_preloaded_setup() { *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) case "$compile_command " in *" -static "*) ;; - *) pic_flag_for_symtable=" $pic_flag -DPIC -DFREEBSD_WORKAROUND";; + *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";; esac;; *-*-hpux*) case "$compile_command " in *" -static "*) ;; - *) pic_flag_for_symtable=" $pic_flag -DPIC";; + *) pic_flag_for_symtable=" $pic_flag";; esac esac # Now compile the dynamic symbol file. - $show "(cd $output_objdir && $CC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")" - $run eval '(cd $output_objdir && $CC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $? + $show "(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")" + $run eval '(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $? # Clean up the generated files. $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T" @@ -3407,7 +4325,7 @@ static const void *lt_preloaded_setup() { finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` fi - if test $need_relink = no || test "$build_libtool_libs" != yes; then + if test "$need_relink" = no || test "$build_libtool_libs" != yes; then # Replace the output file specification. compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` link_command="$compile_command$compile_rpath" @@ -3532,7 +4450,7 @@ static const void *lt_preloaded_setup() { relink_command="$var=\"$var_value\"; export $var; $relink_command" fi done - relink_command="cd `pwd`; $relink_command" + relink_command="(cd `pwd`; $relink_command)" relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` fi @@ -3552,13 +4470,228 @@ static const void *lt_preloaded_setup() { # win32 will think the script is a binary if it has # a .exe suffix, so we strip it off here. case $output in - *.exe) output=`echo $output|sed 's,.exe$,,'` ;; + *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;; esac # test for cygwin because mv fails w/o .exe extensions case $host in - *cygwin*) exeext=.exe ;; + *cygwin*) + exeext=.exe + outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;; *) exeext= ;; esac + case $host in + *cygwin* | *mingw* ) + cwrappersource=`$echo ${objdir}/lt-${output}.c` + cwrapper=`$echo ${output}.exe` + $rm $cwrappersource $cwrapper + trap "$rm $cwrappersource $cwrapper; exit 1" 1 2 15 + + cat > $cwrappersource <> $cwrappersource<<"EOF" +#include +#include +#include +#include +#include +#include + +#if defined(PATH_MAX) +# define LT_PATHMAX PATH_MAX +#elif defined(MAXPATHLEN) +# define LT_PATHMAX MAXPATHLEN +#else +# define LT_PATHMAX 1024 +#endif + +#ifndef DIR_SEPARATOR +#define DIR_SEPARATOR '/' +#endif + +#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ + defined (__OS2__) +#define HAVE_DOS_BASED_FILE_SYSTEM +#ifndef DIR_SEPARATOR_2 +#define DIR_SEPARATOR_2 '\\' +#endif +#endif + +#ifndef DIR_SEPARATOR_2 +# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) +#else /* DIR_SEPARATOR_2 */ +# define IS_DIR_SEPARATOR(ch) \ + (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) +#endif /* DIR_SEPARATOR_2 */ + +#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) +#define XFREE(stale) do { \ + if (stale) { free ((void *) stale); stale = 0; } \ +} while (0) + +const char *program_name = NULL; + +void * xmalloc (size_t num); +char * xstrdup (const char *string); +char * basename (const char *name); +char * fnqualify(const char *path); +char * strendzap(char *str, const char *pat); +void lt_fatal (const char *message, ...); + +int +main (int argc, char *argv[]) +{ + char **newargz; + int i; + + program_name = (char *) xstrdup ((char *) basename (argv[0])); + newargz = XMALLOC(char *, argc+2); +EOF + + cat >> $cwrappersource <> $cwrappersource <<"EOF" + newargz[1] = fnqualify(argv[0]); + /* we know the script has the same name, without the .exe */ + /* so make sure newargz[1] doesn't end in .exe */ + strendzap(newargz[1],".exe"); + for (i = 1; i < argc; i++) + newargz[i+1] = xstrdup(argv[i]); + newargz[argc+1] = NULL; +EOF + + cat >> $cwrappersource <> $cwrappersource <<"EOF" +} + +void * +xmalloc (size_t num) +{ + void * p = (void *) malloc (num); + if (!p) + lt_fatal ("Memory exhausted"); + + return p; +} + +char * +xstrdup (const char *string) +{ + return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL +; +} + +char * +basename (const char *name) +{ + const char *base; + +#if defined (HAVE_DOS_BASED_FILE_SYSTEM) + /* Skip over the disk name in MSDOS pathnames. */ + if (isalpha (name[0]) && name[1] == ':') + name += 2; +#endif + + for (base = name; *name; name++) + if (IS_DIR_SEPARATOR (*name)) + base = name + 1; + return (char *) base; +} + +char * +fnqualify(const char *path) +{ + size_t size; + char *p; + char tmp[LT_PATHMAX + 1]; + + assert(path != NULL); + + /* Is it qualified already? */ +#if defined (HAVE_DOS_BASED_FILE_SYSTEM) + if (isalpha (path[0]) && path[1] == ':') + return xstrdup (path); +#endif + if (IS_DIR_SEPARATOR (path[0])) + return xstrdup (path); + + /* prepend the current directory */ + /* doesn't handle '~' */ + if (getcwd (tmp, LT_PATHMAX) == NULL) + lt_fatal ("getcwd failed"); + size = strlen(tmp) + 1 + strlen(path) + 1; /* +2 for '/' and '\0' */ + p = XMALLOC(char, size); + sprintf(p, "%s%c%s", tmp, DIR_SEPARATOR, path); + return p; +} + +char * +strendzap(char *str, const char *pat) +{ + size_t len, patlen; + + assert(str != NULL); + assert(pat != NULL); + + len = strlen(str); + patlen = strlen(pat); + + if (patlen <= len) + { + str += len - patlen; + if (strcmp(str, pat) == 0) + *str = '\0'; + } + return str; +} + +static void +lt_error_core (int exit_status, const char * mode, + const char * message, va_list ap) +{ + fprintf (stderr, "%s: %s: ", program_name, mode); + vfprintf (stderr, message, ap); + fprintf (stderr, ".\n"); + + if (exit_status >= 0) + exit (exit_status); +} + +void +lt_fatal (const char *message, ...) +{ + va_list ap; + va_start (ap, message); + lt_error_core (EXIT_FAILURE, "FATAL", message, ap); + va_end (ap); +} +EOF + # we should really use a build-platform specific compiler + # here, but OTOH, the wrappers (shell script and this C one) + # are only useful if you want to execute the "real" binary. + # Since the "real" binary is built for $host, then this + # wrapper might as well be built for $host, too. + $run $LTCC -s -o $cwrapper $cwrappersource + ;; + esac $rm $output trap "$rm $output; exit 1" 1 2 15 @@ -3576,7 +4709,7 @@ static const void *lt_preloaded_setup() { # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. -Xsed='sed -e 1s/^X//' +Xsed='${SED} -e 1s/^X//' sed_quote_subst='$sed_quote_subst' # The HP-UX ksh and POSIX shell print the target directory to stdout @@ -3614,7 +4747,7 @@ else test \"x\$thisdir\" = \"x\$file\" && thisdir=. # Follow symbolic links until we get to the real thisdir. - file=\`ls -ld \"\$file\" | sed -n 's/.*-> //p'\` + file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\` while test -n \"\$file\"; do destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\` @@ -3627,7 +4760,7 @@ else fi file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\` - file=\`ls -ld \"\$thisdir/\$file\" | sed -n 's/.*-> //p'\` + file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\` done # Try to get the absolute directory name. @@ -3636,12 +4769,12 @@ else " if test "$fast_install" = yes; then - echo >> $output "\ + $echo >> $output "\ program=lt-'$outputname'$exeext progdir=\"\$thisdir/$objdir\" if test ! -f \"\$progdir/\$program\" || \\ - { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | sed 1q\`; \\ + { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ test \"X\$file\" != \"X\$progdir/\$program\"; }; then file=\"\$\$-\$program\" @@ -3652,7 +4785,7 @@ else $rm \"\$progdir/\$file\" fi" - echo >> $output "\ + $echo >> $output "\ # relink executable if necessary if test -n \"\$relink_command\"; then @@ -3670,13 +4803,13 @@ else $rm \"\$progdir/\$file\" fi" else - echo >> $output "\ + $echo >> $output "\ program='$outputname' progdir=\"\$thisdir/$objdir\" " fi - echo >> $output "\ + $echo >> $output "\ if test -f \"\$progdir/\$program\"; then" @@ -3707,14 +4840,6 @@ else # Run the actual program with our arguments. " case $host in - # win32 systems need to use the prog path for dll - # lookup to work - *-*-cygwin* | *-*-pw32*) - $echo >> $output "\ - exec \$progdir/\$program \${1+\"\$@\"} -" - ;; - # Backslashes separate directories on plain windows *-*-mingw | *-*-os2*) $echo >> $output "\ @@ -3724,11 +4849,7 @@ else *) $echo >> $output "\ - # Export the path to the program. - PATH=\"\$progdir:\$PATH\" - export PATH - - exec \$program \${1+\"\$@\"} + exec \$progdir/\$program \${1+\"\$@\"} " ;; esac @@ -3740,7 +4861,7 @@ else # The program doesn't exist. \$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2 \$echo \"This script is just a wrapper for \$program.\" 1>&2 - echo \"See the $PACKAGE documentation for more information.\" 1>&2 + $echo \"See the $PACKAGE documentation for more information.\" 1>&2 exit 1 fi fi\ @@ -3763,7 +4884,7 @@ fi\ oldobjs="$libobjs_save" build_libtool_libs=no else - oldobjs="$objs$old_deplibs "`$echo "X$libobjs_save" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP` + oldobjs="$old_deplibs $non_pic_objects" fi addlibs="$old_convenience" fi @@ -3772,10 +4893,10 @@ fi\ gentop="$output_objdir/${outputname}x" $show "${rm}r $gentop" $run ${rm}r "$gentop" - $show "mkdir $gentop" - $run mkdir "$gentop" + $show "$mkdir $gentop" + $run $mkdir "$gentop" status=$? - if test $status -ne 0 && test ! -d "$gentop"; then + if test "$status" -ne 0 && test ! -d "$gentop"; then exit $status fi generated="$generated $gentop" @@ -3792,14 +4913,40 @@ fi\ $show "${rm}r $xdir" $run ${rm}r "$xdir" - $show "mkdir $xdir" - $run mkdir "$xdir" + $show "$mkdir $xdir" + $run $mkdir "$xdir" status=$? - if test $status -ne 0 && test ! -d "$xdir"; then + if test "$status" -ne 0 && test ! -d "$xdir"; then exit $status fi + # We will extract separately just the conflicting names and we will no + # longer touch any unique names. It is faster to leave these extract + # automatically by $AR in one run. $show "(cd $xdir && $AR x $xabs)" $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? + if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then + : + else + $echo "$modename: warning: object name conflicts; renaming object files" 1>&2 + $echo "$modename: warning: to ensure that they will not overwrite" 1>&2 + $AR t "$xabs" | sort | uniq -cd | while read -r count name + do + i=1 + while test "$i" -le "$count" + do + # Put our $i before any first dot (extension) + # Never overwrite any file + name_to="$name" + while test "X$name_to" = "X$name" || test -f "$xdir/$name_to" + do + name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"` + done + $show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')" + $run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $? + i=`expr $i + 1` + done + done + fi oldobjs="$oldobjs "`find $xdir -name \*.${objext} -print -o -name \*.lo -print | $NL2SP` done @@ -3809,25 +4956,65 @@ fi\ if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then eval cmds=\"$old_archive_from_new_cmds\" else - # Ensure that we have .o objects in place in case we decided - # not to build a shared library, and have fallen back to building - # static libs even though --disable-static was passed! - for oldobj in $oldobjs; do - if test ! -f $oldobj; then - xdir=`$echo "X$oldobj" | $Xsed -e 's%/[^/]*$%%'` - if test "X$xdir" = "X$oldobj"; then - xdir="." - else - xdir="$xdir" - fi - baseobj=`$echo "X$oldobj" | $Xsed -e 's%^.*/%%'` - obj=`$echo "X$baseobj" | $Xsed -e "$o2lo"` - $show "(cd $xdir && ${LN_S} $obj $baseobj)" - $run eval '(cd $xdir && ${LN_S} $obj $baseobj)' || exit $? - fi - done - eval cmds=\"$old_archive_cmds\" + + if len=`expr "X$cmds" : ".*"` && + test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then + : + else + # the command line is too long to link in one step, link in parts + $echo "using piecewise archive linking..." + save_RANLIB=$RANLIB + RANLIB=: + objlist= + concat_cmds= + save_oldobjs=$oldobjs + # GNU ar 2.10+ was changed to match POSIX; thus no paths are + # encoded into archives. This makes 'ar r' malfunction in + # this piecewise linking case whenever conflicting object + # names appear in distinct ar calls; check, warn and compensate. + if (for obj in $save_oldobjs + do + $echo "X$obj" | $Xsed -e 's%^.*/%%' + done | sort | sort -uc >/dev/null 2>&1); then + : + else + $echo "$modename: warning: object name conflicts; overriding AR_FLAGS to 'cq'" 1>&2 + $echo "$modename: warning: to ensure that POSIX-compatible ar will work" 1>&2 + AR_FLAGS=cq + fi + # Is there a better way of finding the last object in the list? + for obj in $save_oldobjs + do + last_oldobj=$obj + done + for obj in $save_oldobjs + do + oldobjs="$objlist $obj" + objlist="$objlist $obj" + eval test_cmds=\"$old_archive_cmds\" + if len=`expr "X$test_cmds" : ".*"` && + test "$len" -le "$max_cmd_len"; then + : + else + # the above command should be used before it gets too long + oldobjs=$objlist + if test "$obj" = "$last_oldobj" ; then + RANLIB=$save_RANLIB + fi + test -z "$concat_cmds" || concat_cmds=$concat_cmds~ + eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" + objlist= + fi + done + RANLIB=$save_RANLIB + oldobjs=$objlist + if test "X$oldobjs" = "X" ; then + eval cmds=\"\$concat_cmds\" + else + eval cmds=\"\$concat_cmds~$old_archive_cmds\" + fi + fi fi save_ifs="$IFS"; IFS='~' for cmd in $cmds; do @@ -3862,7 +5049,7 @@ fi\ fi done # Quote the link command for shipping. - relink_command="cd `pwd`; $SHELL $0 --mode=relink $libtool_args" + relink_command="(cd `pwd`; $SHELL $0 --mode=relink $libtool_args @inst_prefix_dir@)" relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` # Only create the output if not a dry run. @@ -3879,7 +5066,7 @@ fi\ case $deplib in *.la) name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'` - eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` if test -z "$libdir"; then $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 exit 1 @@ -3893,7 +5080,7 @@ fi\ newdlfiles= for lib in $dlfiles; do name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` - eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $lib` + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` if test -z "$libdir"; then $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 exit 1 @@ -3904,7 +5091,7 @@ fi\ newdlprefiles= for lib in $dlprefiles; do name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` - eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $lib` + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` if test -z "$libdir"; then $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 exit 1 @@ -3917,7 +5104,7 @@ fi\ # place dlname in correct position for cygwin tdlname=$dlname case $host,$output,$installed,$module,$dlname in - *cygwin*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;; + *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;; esac $echo > $output "\ # $outputname - a libtool library file @@ -3946,13 +5133,16 @@ revision=$revision # Is this an already installed library? installed=$installed +# Should we warn about portability when linking against -modules? +shouldnotlink=$module + # Files to dlopen/dlpreopen dlopen='$dlfiles' dlpreopen='$dlprefiles' # Directory that this library needs to be installed in: libdir='$install_libdir'" - if test "$installed" = no && test $need_relink = yes; then + if test "$installed" = no && test "$need_relink" = yes; then $echo >> $output "\ relink_command=\"$relink_command\"" fi @@ -4088,7 +5278,7 @@ relink_command=\"$relink_command\"" # Not a directory, so check to see that there is only one file specified. set dummy $files - if test $# -gt 2; then + if test "$#" -gt 2; then $echo "$modename: \`$dest' is not a directory" 1>&2 $echo "$help" 1>&2 exit 1 @@ -4128,7 +5318,7 @@ relink_command=\"$relink_command\"" *.la) # Check to see that this really is a libtool archive. - if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : else $echo "$modename: \`$file' is not a valid libtool archive" 1>&2 $echo "$help" 1>&2 @@ -4145,21 +5335,12 @@ relink_command=\"$relink_command\"" esac # Add the libdir to current_libdirs if it is the destination. - DESTDIR= if test "X$destdir" = "X$libdir"; then case "$current_libdirs " in *" $libdir "*) ;; *) current_libdirs="$current_libdirs $libdir" ;; esac else - case "$destdir" in - *"$libdir") - DESTDIR=`$echo "$destdir" | sed -e 's!'"$libdir"'$!!'` - if test "X$destdir" != "X$DESTDIR$libdir"; then - DESTDIR= - fi - ;; - esac # Note the libdir as a future libdir. case "$future_libdirs " in *" $libdir "*) ;; @@ -4172,16 +5353,35 @@ relink_command=\"$relink_command\"" dir="$dir$objdir" if test -n "$relink_command"; then + # Determine the prefix the user has applied to our future dir. + inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"` + + # Don't allow the user to place us outside of our expected + # location b/c this prevents finding dependent libraries that + # are installed to the same prefix. + # At present, this check doesn't affect windows .dll's that + # are installed into $libdir/../bin (currently, that works fine) + # but it's something to keep an eye on. + if test "$inst_prefix_dir" = "$destdir"; then + $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2 + exit 1 + fi + + if test -n "$inst_prefix_dir"; then + # Stick the inst_prefix_dir data into the link command. + relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` + else + relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%%"` + fi + $echo "$modename: warning: relinking \`$file'" 1>&2 - export DESTDIR $show "$relink_command" if $run eval "$relink_command"; then : else $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 - continue + exit 1 fi fi - unset DESTDIR # See the names of the shared library. set dummy $library_names @@ -4201,7 +5401,7 @@ relink_command=\"$relink_command\"" $run eval "$striplib $destdir/$realname" || exit $? fi - if test $# -gt 0; then + if test "$#" -gt 0; then # Delete the old symlinks, and create new ones. for linkname do @@ -4287,20 +5487,48 @@ relink_command=\"$relink_command\"" destfile="$destdir/$destfile" fi + # If the file is missing, and there is a .exe on the end, strip it + # because it is most likely a libtool script we actually want to + # install + stripped_ext="" + case $file in + *.exe) + if test ! -f "$file"; then + file=`$echo $file|${SED} 's,.exe$,,'` + stripped_ext=".exe" + fi + ;; + esac + # Do a test to see if this is really a libtool program. - if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + case $host in + *cygwin*|*mingw*) + wrapper=`$echo $file | ${SED} -e 's,.exe$,,'` + ;; + *) + wrapper=$file + ;; + esac + if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then notinst_deplibs= relink_command= + # To insure that "foo" is sourced, and not "foo.exe", + # finese the cygwin/MSYS system by explicitly sourcing "foo." + # which disallows the automatic-append-.exe behavior. + case $build in + *cygwin* | *mingw*) wrapperdot=${wrapper}. ;; + *) wrapperdot=${wrapper} ;; + esac # If there is no directory component, then add one. case $file in - */* | *\\*) . $file ;; - *) . ./$file ;; + */* | *\\*) . ${wrapperdot} ;; + *) . ./${wrapperdot} ;; esac # Check the variables that should have been set. if test -z "$notinst_deplibs"; then - $echo "$modename: invalid libtool wrapper script \`$file'" 1>&2 + $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2 exit 1 fi @@ -4323,10 +5551,17 @@ relink_command=\"$relink_command\"" done relink_command= + # To insure that "foo" is sourced, and not "foo.exe", + # finese the cygwin/MSYS system by explicitly sourcing "foo." + # which disallows the automatic-append-.exe behavior. + case $build in + *cygwin* | *mingw*) wrapperdot=${wrapper}. ;; + *) wrapperdot=${wrapper} ;; + esac # If there is no directory component, then add one. case $file in - */* | *\\*) . $file ;; - *) . ./$file ;; + */* | *\\*) . ${wrapperdot} ;; + *) . ./${wrapperdot} ;; esac outputname= @@ -4334,13 +5569,14 @@ relink_command=\"$relink_command\"" if test "$finalize" = yes && test -z "$run"; then tmpdir="/tmp" test -n "$TMPDIR" && tmpdir="$TMPDIR" - tmpdir="$tmpdir/libtool-$$" + tmpdir=`mktemp -d $tmpdir/libtool-XXXXXX 2> /dev/null` || + tmpdir="$tmpdir/libtool-$$" if $mkdir -p "$tmpdir" && chmod 700 "$tmpdir"; then : else $echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2 continue fi - file=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'` outputname="$tmpdir/$file" # Replace the output file specification. relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'` @@ -4358,14 +5594,14 @@ relink_command=\"$relink_command\"" fi else # Install the binary that we compiled earlier. - file=`$echo "X$file" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` + file=`$echo "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` fi fi # remove .exe since cygwin /usr/bin/install will append another # one anyways case $install_prog,$host in - /usr/bin/install*,*cygwin*) + */usr/bin/install*,*cygwin*) case $file:$destfile in *.exe:*.exe) # this is ok @@ -4374,7 +5610,7 @@ relink_command=\"$relink_command\"" destfile=$destfile.exe ;; *:*.exe) - destfile=`echo $destfile | sed -e 's,.exe$,,'` + destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'` ;; esac ;; @@ -4459,42 +5695,42 @@ relink_command=\"$relink_command\"" fi # Exit here if they wanted silent mode. - test "$show" = ":" && exit 0 + test "$show" = : && exit 0 - echo "----------------------------------------------------------------------" - echo "Libraries have been installed in:" + $echo "----------------------------------------------------------------------" + $echo "Libraries have been installed in:" for libdir in $libdirs; do - echo " $libdir" + $echo " $libdir" done - echo - echo "If you ever happen to want to link against installed libraries" - echo "in a given directory, LIBDIR, you must either use libtool, and" - echo "specify the full pathname of the library, or use the \`-LLIBDIR'" - echo "flag during linking and do at least one of the following:" + $echo + $echo "If you ever happen to want to link against installed libraries" + $echo "in a given directory, LIBDIR, you must either use libtool, and" + $echo "specify the full pathname of the library, or use the \`-LLIBDIR'" + $echo "flag during linking and do at least one of the following:" if test -n "$shlibpath_var"; then - echo " - add LIBDIR to the \`$shlibpath_var' environment variable" - echo " during execution" + $echo " - add LIBDIR to the \`$shlibpath_var' environment variable" + $echo " during execution" fi if test -n "$runpath_var"; then - echo " - add LIBDIR to the \`$runpath_var' environment variable" - echo " during linking" + $echo " - add LIBDIR to the \`$runpath_var' environment variable" + $echo " during linking" fi if test -n "$hardcode_libdir_flag_spec"; then libdir=LIBDIR eval flag=\"$hardcode_libdir_flag_spec\" - echo " - use the \`$flag' linker flag" + $echo " - use the \`$flag' linker flag" fi if test -n "$admincmds"; then - echo " - have your system administrator run these commands:$admincmds" + $echo " - have your system administrator run these commands:$admincmds" fi if test -f /etc/ld.so.conf; then - echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" + $echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" fi - echo - echo "See any operating system documentation about shared libraries for" - echo "more information, such as the ld(1) and ld.so(8) manual pages." - echo "----------------------------------------------------------------------" + $echo + $echo "See any operating system documentation about shared libraries for" + $echo "more information, such as the ld(1) and ld.so(8) manual pages." + $echo "----------------------------------------------------------------------" exit 0 ;; @@ -4522,7 +5758,7 @@ relink_command=\"$relink_command\"" case $file in *.la) # Check to see that this really is a libtool archive. - if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : else $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 $echo "$help" 1>&2 @@ -4593,7 +5829,7 @@ relink_command=\"$relink_command\"" -*) ;; *) # Do a test to see if this is really a libtool program. - if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then # If there is no directory component, then add one. case $file in */* | *\\*) . $file ;; @@ -4616,7 +5852,7 @@ relink_command=\"$relink_command\"" eval "export $shlibpath_var" fi - # Restore saved enviroment variables + # Restore saved environment variables if test "${save_LC_ALL+set}" = set; then LC_ALL="$save_LC_ALL"; export LC_ALL fi @@ -4625,14 +5861,14 @@ relink_command=\"$relink_command\"" fi # Now prepare to actually exec the command. - exec_cmd='"$cmd"$args' + exec_cmd="\"\$cmd\"$args" else # Display what would be done. if test -n "$shlibpath_var"; then eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\"" $echo "export $shlibpath_var" fi - $echo "$cmd$args" + eval \$echo \"\$cmd\"$args exit 0 fi ;; @@ -4666,19 +5902,20 @@ relink_command=\"$relink_command\"" rmdirs= + origobjdir="$objdir" for file in $files; do dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` if test "X$dir" = "X$file"; then dir=. - objdir="$objdir" + objdir="$origobjdir" else - objdir="$dir/$objdir" + objdir="$dir/$origobjdir" fi name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` - test $mode = uninstall && objdir="$dir" + test "$mode" = uninstall && objdir="$dir" # Remember objdir for removal later, being careful to avoid duplicates - if test $mode = clean; then + if test "$mode" = clean; then case " $rmdirs " in *" $objdir "*) ;; *) rmdirs="$rmdirs $objdir" ;; @@ -4702,7 +5939,7 @@ relink_command=\"$relink_command\"" case $name in *.la) # Possibly a libtool archive, so verify it. - if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then . $dir/$name # Delete the libtool libraries and symlinks. @@ -4710,9 +5947,9 @@ relink_command=\"$relink_command\"" rmfiles="$rmfiles $objdir/$n" done test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library" - test $mode = clean && rmfiles="$rmfiles $objdir/$name $objdir/${name}i" + test "$mode" = clean && rmfiles="$rmfiles $objdir/$name $objdir/${name}i" - if test $mode = uninstall; then + if test "$mode" = uninstall; then if test -n "$library_names"; then # Do each command in the postuninstall commands. eval cmds=\"$postuninstall_cmds\" @@ -4721,7 +5958,7 @@ relink_command=\"$relink_command\"" IFS="$save_ifs" $show "$cmd" $run eval "$cmd" - if test $? != 0 && test "$rmforce" != yes; then + if test "$?" -ne 0 && test "$rmforce" != yes; then exit_status=1 fi done @@ -4736,7 +5973,7 @@ relink_command=\"$relink_command\"" IFS="$save_ifs" $show "$cmd" $run eval "$cmd" - if test $? != 0 && test "$rmforce" != yes; then + if test "$?" -ne 0 && test "$rmforce" != yes; then exit_status=1 fi done @@ -4748,22 +5985,52 @@ relink_command=\"$relink_command\"" ;; *.lo) - if test "$build_old_libs" = yes; then - oldobj=`$echo "X$name" | $Xsed -e "$lo2o"` - rmfiles="$rmfiles $dir/$oldobj" + # Possibly a libtool object, so verify it. + if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + + # Read the .lo file + . $dir/$name + + # Add PIC object to the list of files to remove. + if test -n "$pic_object" \ + && test "$pic_object" != none; then + rmfiles="$rmfiles $dir/$pic_object" + fi + + # Add non-PIC object to the list of files to remove. + if test -n "$non_pic_object" \ + && test "$non_pic_object" != none; then + rmfiles="$rmfiles $dir/$non_pic_object" + fi fi ;; *) - # Do a test to see if this is a libtool program. - if test $mode = clean && - (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then - relink_command= - . $dir/$file + if test "$mode" = clean ; then + noexename=$name + case $file in + *.exe) + file=`$echo $file|${SED} 's,.exe$,,'` + noexename=`$echo $name|${SED} 's,.exe$,,'` + # $file with .exe has already been added to rmfiles, + # add $file without .exe + rmfiles="$rmfiles $file" + ;; + esac + # Do a test to see if this is a libtool program. + if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + relink_command= + . $dir/$noexename - rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" - if test "$fast_install" = yes && test -n "$relink_command"; then - rmfiles="$rmfiles $objdir/lt-$name" + # note $name still contains .exe if it was in $file originally + # as does the version of $file that was added into $rmfiles + rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" + if test "$fast_install" = yes && test -n "$relink_command"; then + rmfiles="$rmfiles $objdir/lt-$name" + fi + if test "X$noexename" != "X$name" ; then + rmfiles="$rmfiles $objdir/lt-${noexename}.c" + fi fi fi ;; @@ -4771,6 +6038,7 @@ relink_command=\"$relink_command\"" $show "$rm $rmfiles" $run $rm $rmfiles || exit_status=1 done + objdir="$origobjdir" # Try to remove the ${objdir}s in the directories where we deleted files for dir in $rmdirs; do @@ -4818,6 +6086,7 @@ Provide generalized library-building support services. --mode=MODE use operation mode MODE [default=inferred from MODE-ARGS] --quiet same as \`--silent' --silent don't print informational messages + --tag=TAG use configuration variables from tag TAG --version print version information MODE must be one of the following: @@ -4831,7 +6100,9 @@ MODE must be one of the following: uninstall remove libraries from an installed directory MODE-ARGS vary depending on the MODE. Try \`$modename --help --mode=MODE' for -a more detailed description of MODE." +a more detailed description of MODE. + +Report bugs to ." exit 0 ;; @@ -4943,6 +6214,7 @@ The following components of LINK-COMMAND are treated specially: -no-install link a not-installable executable -no-undefined declare that a library does not refer to external symbols -o OUTPUT-FILE create OUTPUT-FILE from the specified objects + -objectlist FILE Use a list of object files found in FILE to specify objects -release RELEASE specify package release information -rpath LIBDIR the created library will eventually be installed in LIBDIR -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries @@ -4988,11 +6260,31 @@ Otherwise, only FILE itself is deleted using RM." ;; esac -echo +$echo $echo "Try \`$modename --help' for more information about other modes." exit 0 +# The TAGs below are defined such that we never get into a situation +# in which we disable both kinds of libraries. Given conflicting +# choices, we go for a static library, that is the most portable, +# since we can't tell whether shared libraries were disabled because +# the user asked for that or because the platform doesn't support +# them. This is particularly important on AIX, because we don't +# support having both static and shared libraries enabled at the same +# time on that platform, so we default to a shared-only configuration. +# If a disable-shared tag is given, we'll fallback to a static-only +# configuration. But we'll never go from static-only to shared-only. + +# ### BEGIN LIBTOOL TAG CONFIG: disable-shared +build_libtool_libs=no +build_old_libs=yes +# ### END LIBTOOL TAG CONFIG: disable-shared + +# ### BEGIN LIBTOOL TAG CONFIG: disable-static +build_old_libs=`case $build_libtool_libs in yes) $echo no;; *) $echo yes;; esac` +# ### END LIBTOOL TAG CONFIG: disable-static + # Local Variables: # mode:shell-script # sh-indentation:2 From b5819094a70fa1c4f9c231424af6792da0b7b801 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 6 Feb 2004 14:28:57 +0300 Subject: [PATCH 094/113] Fix for bug #2628 "ALTER TABLE destroys table and reports success" BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted mysql-test/r/alter_table.result: Fix for bug #2628: test result fixed mysql-test/t/alter_table.test: Fix for bug #2628: test case added sql/sql_table.cc: Fix for bug #2628: We need to take into account database name when checking if source and destination table names are equal. Note, that after merge to 4.0 we also need to check for lower_case_table_names. --- BitKeeper/etc/logging_ok | 1 + mysql-test/r/alter_table.result | 8 ++++++++ mysql-test/t/alter_table.test | 17 +++++++++++++++++ sql/sql_table.cc | 18 ++++++++++++------ 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 777c590ce62..11a8f3b8fcd 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -12,6 +12,7 @@ heikki@donna.mysql.fi heikki@hundin.mysql.fi jani@hynda.mysql.fi jorge@linux.jorge.mysql.com +konstantin@mysql.com lenz@mysql.com miguel@hegel.(none) miguel@hegel.br diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result index dbdbb7f57a9..8b104225b9c 100644 --- a/mysql-test/r/alter_table.result +++ b/mysql-test/r/alter_table.result @@ -32,3 +32,11 @@ i 2 3 4 +name +current +name +mysqltest +name +current +name +mysqltest diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test index dbfbd4267d8..cfb4f958372 100644 --- a/mysql-test/t/alter_table.test +++ b/mysql-test/t/alter_table.test @@ -82,3 +82,20 @@ alter table t1 drop i,add i int unsigned not null auto_increment, drop primary k select * from t1; drop table t1; +# +# Bug #2628: 'alter table t1 rename mysqltest.t1' silently drops mysqltest.t1 +# if it exists +# +create table t1 (name char(15)); +insert into t1 (name) values ("current"); +create database mysqltest; +create table mysqltest.t1 (name char(15)); +insert into mysqltest.t1 (name) values ("mysqltest"); +select * from t1; +select * from mysqltest.t1; +--error 1050 +alter table t1 rename mysqltest.t1; +select * from t1; +select * from mysqltest.t1; +drop table t1; +drop database mysqltest; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index f273821c5e0..04dfd8a1fbd 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1151,7 +1151,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, thd->proc_info="init"; table_name=table_list->real_name; db=table_list->db; - if (!new_db) + if (!new_db || !strcmp(new_db, db)) new_db=db; if (!(table=open_ltable(thd,table_list,TL_WRITE_ALLOW_READ))) @@ -1161,14 +1161,20 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, if (new_name) { strmov(new_name_buff,new_name); - fn_same(new_name_buff,table_name,3); if (lower_case_table_names) casedn_str(new_name); - if ((lower_case_table_names && - !my_strcasecmp(new_name_buff,table_name)) || - (!lower_case_table_names && + if (new_db == db && + (lower_case_table_names && + !my_strcasecmp(new_name_buff,table_name) || + !lower_case_table_names && !strcmp(new_name_buff,table_name))) - new_name=table_name; // No. Make later check easier + { + /* + Source and destination table names are equal: make later check + easier. + */ + new_name= table_name; + } else { if (table->tmp_table) From 854076da62146f6cb4861e5c5f49fe245d3efe08 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 6 Feb 2004 16:40:44 +0300 Subject: [PATCH 095/113] 3.23 -> 4.0 merge: after merge fixes --- mysql-test/r/alter_table.result | 13 +++++++++++++ mysql-test/r/func_math.result | 6 ++++++ mysql-test/r/insert_select.result | 19 +++++++++++++++++++ mysql-test/t/insert_select.test | 2 ++ sql/sql_table.cc | 1 + 5 files changed, 41 insertions(+) diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result index b32e100df55..037d3420f76 100644 --- a/mysql-test/r/alter_table.result +++ b/mysql-test/r/alter_table.result @@ -350,11 +350,24 @@ 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 (name char(15)); +insert into t1 (name) values ("current"); +create database mysqltest; +create table mysqltest.t1 (name char(15)); +insert into mysqltest.t1 (name) values ("mysqltest"); +select * from t1; name current +select * from mysqltest.t1; name mysqltest +alter table t1 rename mysqltest.t1; +Table 't1' already exists +select * from t1; name current +select * from mysqltest.t1; name mysqltest +drop table t1; +drop database mysqltest; diff --git a/mysql-test/r/func_math.result b/mysql-test/r/func_math.result index e37862d0176..46ad7a14e25 100644 --- a/mysql-test/r/func_math.result +++ b/mysql-test/r/func_math.result @@ -41,15 +41,21 @@ pi() sin(pi()/2) cos(pi()/2) abs(tan(pi())) cot(1) asin(1) acos(0) atan(1) select degrees(pi()),radians(360); degrees(pi()) radians(360) 180 6.2831853071796 +SELECT ACOS(1.0); ACOS(1.0) 0.000000 +SELECT ASIN(1.0); ASIN(1.0) 1.570796 +SELECT ACOS(0.2*5.0); ACOS(0.2*5.0) 0.000000 +SELECT ACOS(0.5*2.0); ACOS(0.5*2.0) 0.000000 +SELECT ASIN(0.8+0.2); ASIN(0.8+0.2) 1.570796 +SELECT ASIN(1.2-0.2); ASIN(1.2-0.2) 1.570796 diff --git a/mysql-test/r/insert_select.result b/mysql-test/r/insert_select.result index c5b98976fd6..a10e7fc02bb 100644 --- a/mysql-test/r/insert_select.result +++ b/mysql-test/r/insert_select.result @@ -592,15 +592,34 @@ CREATE TABLE t2 ( USID INTEGER UNSIGNED AUTO_INCREMENT, ServerID TINYINT UNSIGNE INSERT INTO t1 VALUES (39,42,'Access-Granted','46','491721000045',2130706433,17690,NULL,NULL,'Localnet','491721000045','49172200000',754974766,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2003-07-18 00:11:21',NULL,NULL,20030718001121); INSERT INTO t2 SELECT USID, ServerID, State, SessionID, User, NASAddr, NASPort, NASPortType, ConnectSpeed, CarrierType, CallingStationID, CalledStationID, AssignedAddr, SessionTime, PacketsIn, OctetsIn, PacketsOut, OctetsOut, TerminateCause, UnauthTime, AccessRequestTime, AcctStartTime, AcctLastTime, LastModification from t1 LIMIT 1; drop table t1,t2; +CREATE TABLE t1( +Month date NOT NULL, +Type tinyint(3) unsigned NOT NULL auto_increment, +Field int(10) unsigned NOT NULL, +Count int(10) unsigned NOT NULL, +UNIQUE KEY Month (Month,Type,Field) +); +insert into t1 Values +(20030901, 1, 1, 100), +(20030901, 1, 2, 100), +(20030901, 2, 1, 100), +(20030901, 2, 2, 100), +(20030901, 3, 1, 100); +select * from t1; Month Type Field Count 2003-09-01 1 1 100 2003-09-01 1 2 100 2003-09-01 2 1 100 2003-09-01 2 2 100 2003-09-01 3 1 100 +Select null, Field, Count From t1 Where Month=20030901 and Type=2; NULL Field Count NULL 1 100 NULL 2 100 +create table t2(No int not null, Field int not null, Count int not null); +insert into t2 Select null, Field, Count From t1 Where Month=20030901 and Type=2; +select * from t2; No Field Count 0 1 100 0 2 100 +drop table t1, t2; diff --git a/mysql-test/t/insert_select.test b/mysql-test/t/insert_select.test index 3a8118f7fff..d9a8cfaf1be 100644 --- a/mysql-test/t/insert_select.test +++ b/mysql-test/t/insert_select.test @@ -132,6 +132,8 @@ CREATE TABLE t2 ( USID INTEGER UNSIGNED AUTO_INCREMENT, ServerID TINYINT UNSIGNE INSERT INTO t1 VALUES (39,42,'Access-Granted','46','491721000045',2130706433,17690,NULL,NULL,'Localnet','491721000045','49172200000',754974766,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2003-07-18 00:11:21',NULL,NULL,20030718001121); INSERT INTO t2 SELECT USID, ServerID, State, SessionID, User, NASAddr, NASPort, NASPortType, ConnectSpeed, CarrierType, CallingStationID, CalledStationID, AssignedAddr, SessionTime, PacketsIn, OctetsIn, PacketsOut, OctetsOut, TerminateCause, UnauthTime, AccessRequestTime, AcctStartTime, AcctLastTime, LastModification from t1 LIMIT 1; drop table t1,t2; + +# # Another problem from Bug #2012 # diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 9aa2180b5dd..16263429e33 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1490,6 +1490,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, if (new_name) { strmov(new_name_buff,new_name); + strmov(new_alias= new_alias_buff, new_name); if (lower_case_table_names) { if (lower_case_table_names != 2) From 7db76e5a16796f4cf55bc95418807644d2dd6d17 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 6 Feb 2004 20:57:11 +0400 Subject: [PATCH 096/113] fixed bug #1378 "mysqlbinlog for remote host is broken" client/mysqlbinlog.cc: fixed bug #1378 "mysqlbinlog for remote host is broken" by using shared part of code for local and remote variant (function process_event) mysql-test/r/mysqlbinlog.result: fixed results for remote variant (they are the same as for local now) mysql-test/t/mysqlbinlog.test: discarded note 'V. Vagin should ...' because V.Vagin done sql/log_event.cc: added special local_fname flag to Load_log_event for using in Load_log_event::check_fname_outside_temp_buf instead of ugly condition sql/log_event.h: added special local_fname flag to Load_log_event for using in Load_log_event::check_fname_outside_temp_buf instead of ugly condition --- client/mysqlbinlog.cc | 421 +++++++++++++++++++------------- mysql-test/r/mysqlbinlog.result | 17 +- mysql-test/t/mysqlbinlog.test | 4 - sql/log_event.cc | 4 +- sql/log_event.h | 4 +- 5 files changed, 264 insertions(+), 186 deletions(-) diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 34b7ae11f74..ecf998c6d96 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -72,15 +72,33 @@ class Load_log_processor int target_dir_name_len; DYNAMIC_ARRAY file_names; - const char *create_file(Create_file_log_event *ce); - void append_to_file(const char* fname, int flags, - gptr data, uint size) + /* + Looking for new uniquie filename that doesn't exist yet by + adding postfix -%x + + SYNOPSIS + create_unique_file() + + filename buffer for filename + file_name_end tail of buffer that should be changed + should point to a memory enough to printf("-%x",..) + + RETURN VALUES + values less than 0 - can't find new filename + values great or equal 0 - created file with found filename + */ + File create_unique_file(char *filename, char *file_name_end) { - File file; - if (((file= my_open(fname,flags,MYF(MY_WME))) < 0) || - my_write(file,(byte*) data,size,MYF(MY_WME|MY_NABP)) || - my_close(file,MYF(MY_WME))) - exit(1); + File res; + /* If we have to try more than 1000 times, something is seriously wrong */ + for (uint version= 0; version<1000; version++) + { + sprintf(file_name_end,"-%x",version); + if ((res= my_create(filename,0, + O_CREAT|O_EXCL|O_BINARY|O_WRONLY,MYF(0)))!=-1) + return res; + } + return -1; } public: @@ -131,20 +149,21 @@ public: *ptr= 0; return res; } - void process(Create_file_log_event *ce) - { - const char *fname= create_file(ce); - append_to_file(fname,O_CREAT|O_EXCL|O_BINARY|O_WRONLY,ce->block, - ce->block_len); - } - void process(Append_block_log_event *ae) + int process(Create_file_log_event *ce); + int process(Append_block_log_event *ae) { + File file; Create_file_log_event* ce= (ae->file_id < file_names.elements) ? *((Create_file_log_event**)file_names.buffer + ae->file_id) : 0; if (ce) - append_to_file(ce->fname,O_APPEND|O_BINARY|O_WRONLY, ae->block, - ae->block_len); + { + if (((file= my_open(ce->fname, + O_APPEND|O_BINARY|O_WRONLY,MYF(MY_WME))) < 0) || + my_write(file,(byte*)ae->block,ae->block_len,MYF(MY_WME|MY_NABP)) || + my_close(file,MYF(MY_WME))) + return -1; + } else { /* @@ -154,60 +173,209 @@ public: */ fprintf(stderr,"Warning: ignoring Append_block as there is no \ Create_file event for file_id: %u\n",ae->file_id); + return -1; } + return 0; } + + File prepare_new_file_for_old_format(Load_log_event *le, char *filename); + int load_old_format_file(NET* net, const char *server_fname, + uint server_fname_len, File file); }; +File Load_log_processor::prepare_new_file_for_old_format(Load_log_event *le, + char *filename) +{ + uint len; + char *tail; + File file; + + fn_format(filename, le->fname, target_dir_name, "", 1); + len= strlen(filename); + tail= filename + len; + + if ((file= create_unique_file(filename,tail)) < 0) + { + sql_print_error("Could not construct local filename %s",filename); + return -1; + } + + le->set_fname_outside_temp_buf(filename,len+strlen(tail)); + + return file; +} -const char *Load_log_processor::create_file(Create_file_log_event *ce) +int Load_log_processor::load_old_format_file(NET* net, const char*server_fname, + uint server_fname_len, File file) +{ + char buf[FN_REFLEN+1]; + buf[0] = 0; + memcpy(buf + 1, server_fname, server_fname_len + 1); + if (my_net_write(net, buf, server_fname_len +2) || net_flush(net)) + { + sql_print_error("Failed requesting the remote dump of %s", server_fname); + return -1; + } + + for (;;) + { + uint packet_len = my_net_read(net); + if (packet_len == 0) + { + if (my_net_write(net, "", 0) || net_flush(net)) + { + sql_print_error("Failed sending the ack packet"); + return -1; + } + /* + we just need to send something, as the server will read but + not examine the packet - this is because mysql_load() sends + an OK when it is done + */ + break; + } + else if (packet_len == packet_error) + { + sql_print_error("Failed reading a packet during the dump of %s ", + server_fname); + return -1; + } + + if (my_write(file, (byte*) net->read_pos, packet_len,MYF(MY_WME|MY_NABP))) + return -1; + } + + return 0; +} + +int Load_log_processor::process(Create_file_log_event *ce) { const char *bname= ce->fname+dirname_length(ce->fname); uint blen= ce->fname_len - (bname-ce->fname); uint full_len= target_dir_name_len + blen + 9 + 9 + 1; - uint version= 0; - char *tmp, *ptr; + char *fname, *ptr; + File file; - if (!(tmp= my_malloc(full_len,MYF(MY_WME))) || + if (!(fname= my_malloc(full_len,MYF(MY_WME))) || set_dynamic(&file_names,(gptr)&ce,ce->file_id)) { - die("Could not construct local filename %s%s",target_dir_name,bname); - return 0; + sql_print_error("Could not construct local filename %s%s", + target_dir_name,bname); + return -1; } - memcpy(tmp, target_dir_name, target_dir_name_len); - ptr= tmp+ target_dir_name_len; + memcpy(fname, target_dir_name, target_dir_name_len); + ptr= fname + target_dir_name_len; memcpy(ptr,bname,blen); ptr+= blen; ptr+= my_sprintf(ptr,(ptr,"-%x",ce->file_id)); - /* - Note that this code has a possible race condition if there was was - many simultaneous clients running which tried to create files at the same - time. Fortunately this should never be the case. - - A better way to do this would be to use 'create_tmp_file() and avoid this - race condition altogether on the expense of getting more cryptic file - names. - */ - for (;;) + if ((file= create_unique_file(fname,ptr)) < 0) { - sprintf(ptr,"-%x",version); - if (access(tmp,F_OK)) - break; - /* If we have to try more than 1000 times, something is seriously wrong */ - if (version++ > 1000) - { - die("Could not construct local filename %s%s",target_dir_name,bname); - return 0; - } + sql_print_error("Could not construct local filename %s%s", + target_dir_name,bname); + return -1; } - ce->set_fname_outside_temp_buf(tmp,strlen(tmp)); - return tmp; + ce->set_fname_outside_temp_buf(fname,strlen(fname)); + + if (my_write(file,(byte*) ce->block,ce->block_len,MYF(MY_WME|MY_NABP)) || + my_close(file,MYF(MY_WME))) + return -1; } - Load_log_processor load_processor; +void process_event(ulonglong *rec_count, char *last_db, Log_event *ev, + my_off_t pos, int old_format) +{ + char ll_buff[21]; + if ((*rec_count) >= offset) + { + if (!short_form) + fprintf(result_file, "# at %s\n",llstr(pos,ll_buff)); + + switch (ev->get_type_code()) { + case QUERY_EVENT: + if (one_database) + { + const char * log_dbname = ((Query_log_event*)ev)->db; + if ((log_dbname != NULL) && (strcmp(log_dbname, database))) + { + (*rec_count)++; + delete ev; + return; // next + } + } + ev->print(result_file, short_form, last_db); + break; + case CREATE_FILE_EVENT: + { + Create_file_log_event* ce= (Create_file_log_event*)ev; + if (one_database) + { + /* + We test if this event has to be ignored. If yes, we don't save + this event; this will have the good side-effect of ignoring all + related Append_block and Exec_load. + Note that Load event from 3.23 is not tested. + */ + const char * log_dbname = ce->db; + if ((log_dbname != NULL) && (strcmp(log_dbname, database))) + { + (*rec_count)++; + delete ev; + return; // next + } + } + /* + We print the event, but with a leading '#': this is just to inform + the user of the original command; the command we want to execute + will be a derivation of this original command (we will change the + filename and use LOCAL), prepared in the 'case EXEC_LOAD_EVENT' + below. + */ + ce->print(result_file, short_form, last_db, true); + if (!old_format) + { + load_processor.process(ce); + ev= 0; + } + break; + } + case APPEND_BLOCK_EVENT: + ev->print(result_file, short_form, last_db); + load_processor.process((Append_block_log_event*)ev); + break; + case EXEC_LOAD_EVENT: + { + ev->print(result_file, short_form, last_db); + Execute_load_log_event *exv= (Execute_load_log_event*)ev; + Create_file_log_event *ce= load_processor.grab_event(exv->file_id); + /* + if ce is 0, it probably means that we have not seen the Create_file + event (a bad binlog, or most probably --position is after the + Create_file event). Print a warning comment. + */ + if (ce) + { + ce->print(result_file, short_form, last_db,true); + my_free((char*)ce->fname,MYF(MY_WME)); + delete ce; + } + else + fprintf(stderr,"Warning: ignoring Exec_load as there is no \ +Create_file event for file_id: %u\n",exv->file_id); + break; + } + default: + ev->print(result_file, short_form, last_db); + } + } + (*rec_count)++; + if (ev) + delete ev; +} + static struct my_option my_long_options[] = { #ifndef DBUG_OFF @@ -243,7 +411,7 @@ static struct my_option my_long_options[] = (gptr*) &short_form, (gptr*) &short_form, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"socket", 'S', "Socket file to use for connection.", - (gptr*) &sock, (gptr*) &sock, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, + (gptr*) &sock, (gptr*) &sock, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"user", 'u', "Connect to the remote server as username.", (gptr*) &user, (gptr*) &user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, @@ -305,37 +473,6 @@ the mysql command line client\n\n"); my_print_variables(my_long_options); } -static void dump_remote_file(NET* net, const char* fname) -{ - char buf[FN_REFLEN+1]; - uint len = (uint) strlen(fname); - buf[0] = 0; - memcpy(buf + 1, fname, len + 1); - if(my_net_write(net, buf, len +2) || net_flush(net)) - die("Failed requesting the remote dump of %s", fname); - for(;;) - { - uint packet_len = my_net_read(net); - if(packet_len == 0) - { - if(my_net_write(net, "", 0) || net_flush(net)) - die("Failed sending the ack packet"); - - // we just need to send something, as the server will read but - // not examine the packet - this is because mysql_load() sends an OK when it is done - break; - } - else if(packet_len == packet_error) - die("Failed reading a packet during the dump of %s ", fname); - - if(!short_form) - (void)my_fwrite(result_file, (byte*) net->read_pos, packet_len,MYF(0)); - } - - fflush(result_file); -} - - extern "C" my_bool get_one_option(int optid, const struct my_option *opt __attribute__((unused)), char *argument) @@ -489,6 +626,10 @@ static void dump_remote_log_entries(const char* logname) if (simple_command(mysql, COM_BINLOG_DUMP, buf, len + 10, 1)) die("Error sending the log dump command"); + my_off_t old_off= 0; + ulonglong rec_count= 0; + char fname[FN_REFLEN+1]; + for (;;) { const char *error; @@ -501,15 +642,40 @@ static void dump_remote_log_entries(const char* logname) len, net->read_pos[5])); Log_event *ev = Log_event::read_log_event((const char*) net->read_pos + 1 , len - 1, &error, old_format); - if (ev) + if (!ev) { - ev->print(result_file, short_form, last_db); - if (ev->get_type_code() == LOAD_EVENT) - dump_remote_file(net, ((Load_log_event*)ev)->fname); - delete ev; - } - else die("Could not construct log event object"); + } + else + { + Log_event_type type= ev->get_type_code(); + if (!old_format || ( type != LOAD_EVENT && type != CREATE_FILE_EVENT ) ) + { + process_event(&rec_count,last_db,ev,old_off,old_format); + } + else + { + Load_log_event *le= (Load_log_event*)ev; + const char *old_fname= le->fname; + uint old_len= le->fname_len; + File file= load_processor.prepare_new_file_for_old_format(le,fname); + if (file >= 0) + { + process_event(&rec_count,last_db,ev,old_off,old_format); + load_processor.load_old_format_file(net,old_fname,old_len,file); + my_close(file,MYF(MY_WME)); + } + } + } + + /* + Let's adjust offset for remote log as for local log to produce + similar text.. + */ + if (old_off) + old_off+= len-1; + else + old_off= BIN_LOG_HEADER_SIZE; } } @@ -599,88 +765,7 @@ Could not read entry at offset %s : Error in log format or read error", // file->error == 0 means EOF, that's OK, we break in this case break; } - if (rec_count >= offset) - { - if (!short_form) - fprintf(result_file, "# at %s\n",llstr(old_off,llbuff)); - - switch (ev->get_type_code()) { - case QUERY_EVENT: - if (one_database) - { - const char * log_dbname = ((Query_log_event*)ev)->db; - if ((log_dbname != NULL) && (strcmp(log_dbname, database))) - { - rec_count++; - delete ev; - continue; // next - } - } - ev->print(result_file, short_form, last_db); - break; - case CREATE_FILE_EVENT: - { - Create_file_log_event* ce= (Create_file_log_event*)ev; - if (one_database) - { - /* - We test if this event has to be ignored. If yes, we don't save this - event; this will have the good side-effect of ignoring all related - Append_block and Exec_load. - Note that Load event from 3.23 is not tested. - */ - const char * log_dbname = ce->db; - if ((log_dbname != NULL) && (strcmp(log_dbname, database))) - { - rec_count++; - delete ev; - continue; // next - } - } - /* - We print the event, but with a leading '#': this is just to inform - the user of the original command; the command we want to execute - will be a derivation of this original command (we will change the - filename and use LOCAL), prepared in the 'case EXEC_LOAD_EVENT' - below. - */ - ce->print(result_file, short_form, last_db, true); - load_processor.process(ce); - ev= 0; - break; - } - case APPEND_BLOCK_EVENT: - ev->print(result_file, short_form, last_db); - load_processor.process((Append_block_log_event*)ev); - break; - case EXEC_LOAD_EVENT: - { - ev->print(result_file, short_form, last_db); - Execute_load_log_event *exv= (Execute_load_log_event*)ev; - Create_file_log_event *ce= load_processor.grab_event(exv->file_id); - /* - if ce is 0, it probably means that we have not seen the Create_file - event (a bad binlog, or most probably --position is after the - Create_file event). Print a warning comment. - */ - if (ce) - { - ce->print(result_file, short_form, last_db,true); - my_free((char*)ce->fname,MYF(MY_WME)); - delete ce; - } - else - fprintf(stderr,"Warning: ignoring Exec_load as there is no \ -Create_file event for file_id: %u\n",exv->file_id); - break; - } - default: - ev->print(result_file, short_form, last_db); - } - } - rec_count++; - if (ev) - delete ev; + process_event(&rec_count,last_db,ev,old_off,false); } if (fd >= 0) my_close(fd, MYF(MY_WME)); diff --git a/mysql-test/r/mysqlbinlog.result b/mysql-test/r/mysqlbinlog.result index eeac31ba40b..f604aa0589e 100644 --- a/mysql-test/r/mysqlbinlog.result +++ b/mysql-test/r/mysqlbinlog.result @@ -54,6 +54,12 @@ insert into t1 values ("abirvalg"); SET INSERT_ID=1; SET TIMESTAMP=1000000000; insert into t2 values (); +LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-1-1' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); +LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-2-1' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); +LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-3-1' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); +LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-4-1' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); +LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-5-1' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); +LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-6-1' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); SET TIMESTAMP=1000000000; insert into t1 values ("Alas"); @@ -63,18 +69,7 @@ SET TIMESTAMP=1000000000; insert into t1 values ("Alas"); --- --database -- -use test; -SET TIMESTAMP=1000000000; -create table t1 (word varchar(20)); -SET TIMESTAMP=1000000000; -create table t2 (id int auto_increment not null primary key); -SET TIMESTAMP=1000000000; -insert into t1 values ("abirvalg"); SET INSERT_ID=1; -SET TIMESTAMP=1000000000; -insert into t2 values (); -SET TIMESTAMP=1000000000; -insert into t1 values ("Alas"); --- --position -- use test; diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test index e22a37fabfd..228233923fe 100644 --- a/mysql-test/t/mysqlbinlog.test +++ b/mysql-test/t/mysqlbinlog.test @@ -64,10 +64,6 @@ select "--- --position --" as ""; # These are tests for remote binlog. # They should return the same as previous test. -# But now they are not. V. Vagin should fix this. -# We test all the same options second time since code for remote case is -# essentially different. If code for both cases will be unified we'll be -# able to throw out most of this. --disable_query_log select "--- Remote --" as ""; diff --git a/sql/log_event.cc b/sql/log_event.cc index cafd1666eac..b5d7b1df038 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1189,7 +1189,7 @@ Load_log_event::Load_log_event(THD* thd_arg, sql_exchange* ex, num_fields(0),fields(0), field_lens(0),field_block_len(0), table_name(table_name_arg ? table_name_arg : ""), - db(db_arg), fname(ex->file_name) + db(db_arg), fname(ex->file_name), local_fname(FALSE) { time_t end_time; time(&end_time); @@ -1265,7 +1265,7 @@ Load_log_event::Load_log_event(const char* buf, int event_len, bool old_format) :Log_event(buf, old_format),num_fields(0),fields(0), field_lens(0),field_block_len(0), - table_name(0),db(0),fname(0) + table_name(0),db(0),fname(0),local_fname(FALSE) { if (!event_len) // derived class, will call copy_log_event() itself return; diff --git a/sql/log_event.h b/sql/log_event.h index a1a7798be34..b610263a462 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -411,17 +411,19 @@ public: const char* fname; uint32 skip_lines; sql_ex_info sql_ex; + bool local_fname; /* fname doesn't point to memory inside Log_event::temp_buf */ void set_fname_outside_temp_buf(const char *afname, uint alen) { fname= afname; fname_len= alen; + local_fname= true; } /* fname doesn't point to memory inside Log_event::temp_buf */ int check_fname_outside_temp_buf() { - return fname < temp_buf || fname > temp_buf+ cached_event_len; + return local_fname; } #ifndef MYSQL_CLIENT From 496cbfe8a9b65e2f77530fff849b98368d6cc47b Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 6 Feb 2004 19:57:13 +0300 Subject: [PATCH 097/113] Delete: COPYING.LIB --- COPYING.LIB | 481 ---------------------------------------------------- 1 file changed, 481 deletions(-) delete mode 100644 COPYING.LIB diff --git a/COPYING.LIB b/COPYING.LIB deleted file mode 100644 index eb685a5ec98..00000000000 --- a/COPYING.LIB +++ /dev/null @@ -1,481 +0,0 @@ - GNU LIBRARY GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1991 Free Software Foundation, Inc. - 675 Mass Ave, Cambridge, MA 02139, USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the library GPL. It is - numbered 2 because it goes with version 2 of the ordinary GPL.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Library General Public License, applies to some -specially designated Free Software Foundation software, and to any -other libraries whose authors decide to use it. You can use it for -your libraries, 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 library, or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link a program with the library, you must provide -complete object files to the recipients so that they can relink them -with the library, after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - Our method of protecting your rights has two steps: (1) copyright -the library, and (2) offer you this license which gives you legal -permission to copy, distribute and/or modify the library. - - Also, for each distributor's protection, we want to make certain -that everyone understands that there is no warranty for this free -library. If the library is modified by someone else and passed on, we -want its recipients to know that what they have is not the original -version, 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 companies distributing free -software will individually obtain patent licenses, thus in effect -transforming the program into proprietary software. To prevent this, -we have made it clear that any patent must be licensed for everyone's -free use or not licensed at all. - - Most GNU software, including some libraries, is covered by the ordinary -GNU General Public License, which was designed for utility programs. This -license, the GNU Library General Public License, applies to certain -designated libraries. This license is quite different from the ordinary -one; be sure to read it in full, and don't assume that anything in it is -the same as in the ordinary license. - - The reason we have a separate public license for some libraries is that -they blur the distinction we usually make between modifying or adding to a -program and simply using it. Linking a program with a library, without -changing the library, is in some sense simply using the library, and is -analogous to running a utility program or application program. However, in -a textual and legal sense, the linked executable is a combined work, a -derivative of the original library, and the ordinary General Public License -treats it as such. - - Because of this blurred distinction, using the ordinary General -Public License for libraries did not effectively promote software -sharing, because most developers did not use the libraries. We -concluded that weaker conditions might promote sharing better. - - However, unrestricted linking of non-free programs would deprive the -users of those programs of all benefit from the free status of the -libraries themselves. This Library General Public License is intended to -permit developers of non-free programs to use free libraries, while -preserving your freedom as a user of such programs to change the free -libraries that are incorporated in them. (We have not seen how to achieve -this as regards changes in header files, but we have achieved it as regards -changes in the actual functions of the Library.) The hope is that this -will lead to faster development of free libraries. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, while the latter only -works together with the library. - - Note that it is possible for a library to be covered by the ordinary -General Public License rather than by this special one. - - GNU LIBRARY GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library which -contains a notice placed by the copyright holder or other authorized -party saying it may be distributed under the terms of this Library -General Public License (also called "this License"). Each licensee is -addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, 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 library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete 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 distribute a copy of this License along with the -Library. - - 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 Library or any portion -of it, thus forming a work based on the Library, 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) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -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 Library, 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 Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you 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. - - If distribution of 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 satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also compile or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - c) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - d) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. 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. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library 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. - - 9. 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 Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -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. - - 11. 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 Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library 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 Library. - -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. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library 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. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Library 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 Library -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 Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -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 - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "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 -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. 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 LIBRARY 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 -LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - Appendix: How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. 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 library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! From b0076aad731e2e2ea12c5261e0b89c27c5e34f2f Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 8 Feb 2004 12:53:31 +0200 Subject: [PATCH 098/113] ha_innodb.cc: If AUTOCOMMIT=1, then we do not need to make a plain SELECT set shared locks even on the SERIALIZABLE isolation level, because we know the transaction is read-only: a read-only transaction can always be performed on the REPEATABLE READ level, and that does not endanger the serializability sql/ha_innodb.cc: If AUTOCOMMIT=1, then we do not need to make a plain SELECT set shared locks even on the SERIALIZABLE isolation level, because we know the transaction is read-only: a read-only transaction can always be performed on the REPEATABLE READ level, and that does not endanger the serializability --- sql/ha_innodb.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 68052014f57..01af07f34ec 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -539,7 +539,7 @@ innobase_query_caching_of_table_permitted( if (thd->variables.tx_isolation == ISO_SERIALIZABLE) { /* In the SERIALIZABLE mode we add LOCK IN SHARE MODE to every - plain SELECT */ + plain SELECT if AUTOCOMMIT is not on. */ return((my_bool)FALSE); } @@ -4483,11 +4483,17 @@ ha_innobase::external_lock( } if (trx->isolation_level == TRX_ISO_SERIALIZABLE - && prebuilt->select_lock_type == LOCK_NONE) { + && prebuilt->select_lock_type == LOCK_NONE + && (thd->options + & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) { - /* To get serializable execution we let InnoDB + /* To get serializable execution, we let InnoDB conceptually add 'LOCK IN SHARE MODE' to all SELECTs - which otherwise would have been consistent reads */ + which otherwise would have been consistent reads. An + exception is consistent reads in the AUTOCOMMIT=1 mode: + we know that they are read-only transactions, and they + can be serialized also if performed as consistent + reads. */ prebuilt->select_lock_type = LOCK_S; } From cd361b41ac673e6d8fb190a87a75419bb7a2317b Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 9 Feb 2004 01:32:00 +0200 Subject: [PATCH 099/113] Many files: Fix bug #2167: generate foreign key id's locally for each table, in the form databasename/tablename_ibfk_number; if the user gives the constraint name explicitly remember it; these changes should ensure that foreign key id's in a slave are the same as in the master, and DROP FOREIGN KEY does not break replication sync0sync.c: UNIV_SYNC_DEBUG caused assertion in the creation of the doublewrite buffer, if we do not allow thousands of latches per thread innobase/dict/dict0crea.c: Fix bug #2167: generate foreign key id's locally for each table, in the form databasename/tablename_ibfk_number; if the user gives the constraint name explicitly remember it; these changes should ensure that foreign key id's in a slave are the same as in the master, and DROP FOREIGN KEY does not break replication innobase/dict/dict0dict.c: Fix bug #2167: generate foreign key id's locally for each table, in the form databasename/tablename_ibfk_number; if the user gives the constraint name explicitly remember it; these changes should ensure that foreign key id's in a slave are the same as in the master, and DROP FOREIGN KEY does not break replication innobase/include/dict0crea.h: Fix bug #2167: generate foreign key id's locally for each table, in the form databasename/tablename_ibfk_number; if the user gives the constraint name explicitly remember it; these changes should ensure that foreign key id's in a slave are the same as in the master, and DROP FOREIGN KEY does not break replication innobase/include/dict0dict.h: Fix bug #2167: generate foreign key id's locally for each table, in the form databasename/tablename_ibfk_number; if the user gives the constraint name explicitly remember it; these changes should ensure that foreign key id's in a slave are the same as in the master, and DROP FOREIGN KEY does not break replication innobase/include/ut0mem.h: Fix bug #2167: generate foreign key id's locally for each table, in the form databasename/tablename_ibfk_number; if the user gives the constraint name explicitly remember it; these changes should ensure that foreign key id's in a slave are the same as in the master, and DROP FOREIGN KEY does not break replication innobase/row/row0mysql.c: Fix bug #2167: generate foreign key id's locally for each table, in the form databasename/tablename_ibfk_number; if the user gives the constraint name explicitly remember it; these changes should ensure that foreign key id's in a slave are the same as in the master, and DROP FOREIGN KEY does not break replication innobase/sync/sync0sync.c: UNIV_SYNC_DEBUG caused assertion in the creation of the doublewrite buffer, if we do not allow thousands of latches per thread innobase/ut/ut0mem.c: Fix bug #2167: generate foreign key id's locally for each table, in the form databasename/tablename_ibfk_number; if the user gives the constraint name explicitly remember it; these changes should ensure that foreign key id's in a slave are the same as in the master, and DROP FOREIGN KEY does not break replication --- innobase/dict/dict0crea.c | 79 ++++++---- innobase/dict/dict0dict.c | 286 ++++++++++++++++++++++++++++++++--- innobase/include/dict0crea.h | 15 +- innobase/include/dict0dict.h | 8 + innobase/include/ut0mem.h | 9 +- innobase/row/row0mysql.c | 84 +++++++++- innobase/sync/sync0sync.c | 2 +- innobase/ut/ut0mem.c | 24 +++ 8 files changed, 440 insertions(+), 67 deletions(-) diff --git a/innobase/dict/dict0crea.c b/innobase/dict/dict0crea.c index 9139e589a0a..0445c339fe9 100644 --- a/innobase/dict/dict0crea.c +++ b/innobase/dict/dict0crea.c @@ -1171,23 +1171,36 @@ dict_create_or_check_foreign_constraint_tables(void) } /************************************************************************ -Adds foreign key definitions to data dictionary tables in the database. */ +Adds foreign key definitions to data dictionary tables in the database. We +look at table->foreign_list, and also generate names to constraints that were +not named by the user. A generated constraint has a name of the format +databasename/tablename_ibfk_, where the numbers start from 1, and are +given locally for this table, that is, the number is not global, as in the +old format constraints < 4.0.18 it used to be. */ ulint dict_create_add_foreigns_to_dictionary( /*===================================*/ /* out: error code or DB_SUCCESS */ + ulint start_id,/* in: if we are actually doing ALTER TABLE + ADD CONSTRAINT, we want to generate constraint + numbers which are bigger than in the table so + far; we number the constraints from + start_id + 1 up; start_id should be set to 0 if + we are creating a new table, or if the table + so far has no constraints for which the name + was generated here */ dict_table_t* table, /* in: table */ trx_t* trx) /* in: transaction */ { dict_foreign_t* foreign; que_thr_t* thr; que_t* graph; - dulint id; + ulint number = start_id + 1; ulint len; ulint error; + char* ebuf = dict_foreign_err_buf; ulint i; - char buf2[50]; char buf[10000]; ut_ad(mutex_own(&(dict_sys->mutex))); @@ -1215,18 +1228,18 @@ loop: "PROCEDURE ADD_FOREIGN_DEFS_PROC () IS\n" "BEGIN\n"); - /* We allocate the new id from the sequence of table id's */ - id = dict_hdr_get_new_id(DICT_HDR_TABLE_ID); + if (foreign->id == NULL) { + /* Generate a new constraint id */ + foreign->id = mem_heap_alloc(foreign->heap, + ut_strlen(table->name) + + 20); + sprintf(foreign->id, "%s_ibfk_%lu", table->name, number); + number++; + } - sprintf(buf2, "%lu_%lu", ut_dulint_get_high(id), - ut_dulint_get_low(id)); - foreign->id = mem_heap_alloc(foreign->heap, ut_strlen(buf2) + 1); - ut_memcpy(foreign->id, buf2, ut_strlen(buf2) + 1); - len += sprintf(buf + len, - "INSERT INTO SYS_FOREIGN VALUES('%lu_%lu', '%s', '%s', %lu);\n", - ut_dulint_get_high(id), - ut_dulint_get_low(id), + "INSERT INTO SYS_FOREIGN VALUES('%s', '%s', '%s', %lu);\n", + foreign->id, table->name, foreign->referenced_table_name, foreign->n_fields @@ -1235,9 +1248,8 @@ loop: for (i = 0; i < foreign->n_fields; i++) { len += sprintf(buf + len, - "INSERT INTO SYS_FOREIGN_COLS VALUES('%lu_%lu', %lu, '%s', '%s');\n", - ut_dulint_get_high(id), - ut_dulint_get_low(id), + "INSERT INTO SYS_FOREIGN_COLS VALUES('%s', %lu, '%s', '%s');\n", + foreign->id, i, foreign->foreign_col_names[i], foreign->referenced_col_names[i]); @@ -1262,29 +1274,30 @@ loop: que_graph_free(graph); + if (error == DB_DUPLICATE_KEY) { + mutex_enter(&dict_foreign_err_mutex); + ut_sprintf_timestamp(dict_foreign_err_buf); + sprintf(ebuf + strlen(ebuf), +" Error in foreign key constraint creation for table %.500s.\n" +"A foreign key constraint of name %.500s\n" +"already exists (note that internally InnoDB adds 'databasename/'\n" +"in front of the user-defined constraint name).\n", table->name, foreign->id); + + ut_a(strlen(ebuf) < DICT_FOREIGN_ERR_BUF_LEN); + + mutex_exit(&dict_foreign_err_mutex); + + return(error); + } + if (error != DB_SUCCESS) { fprintf(stderr, "InnoDB: Foreign key constraint creation failed:\n" "InnoDB: internal error number %lu\n", error); - if (error == DB_DUPLICATE_KEY) { - fprintf(stderr, - "InnoDB: Duplicate key error in system table %s index %s\n", - ((dict_index_t*)trx->error_info)->table_name, - ((dict_index_t*)trx->error_info)->name); - - fprintf(stderr, "%s\n", buf); - - fprintf(stderr, - "InnoDB: Maybe the internal data dictionary of InnoDB is\n" - "InnoDB: out-of-sync from the .frm files of your tables.\n" - "InnoDB: See section 15.1 Troubleshooting data dictionary operations\n" - "InnoDB: at http://www.innodb.com/ibman.html\n"); - } - mutex_enter(&dict_foreign_err_mutex); - ut_sprintf_timestamp(buf); - sprintf(buf + strlen(buf), + ut_sprintf_timestamp(ebuf); + sprintf(ebuf + strlen(ebuf), " Internal error in foreign key constraint creation for table %.500s.\n" "See the MySQL .err log in the datadir for more information.\n", table->name); mutex_exit(&dict_foreign_err_mutex); diff --git a/innobase/dict/dict0dict.c b/innobase/dict/dict0dict.c index 87505656d5a..e0597c66dba 100644 --- a/innobase/dict/dict0dict.c +++ b/innobase/dict/dict0dict.c @@ -235,6 +235,29 @@ dict_remove_db_name( return(NULL); } + +/************************************************************************ +Get the database name length in a table name. */ + +ulint +dict_get_db_name_len( +/*=================*/ + /* out: database name length */ + char* name) /* in: table name in the form dbname '/' tablename */ +{ + ulint i; + + for (i = 0; i < 100000 ; i++) { + if (name[i] == '/') { + + return(i); + } + } + + ut_a(0); + + return(0); +} /************************************************************************ Reserves the dictionary system mutex for MySQL. */ @@ -869,6 +892,7 @@ dict_table_rename_in_cache( ulint fold; ulint old_size; char* name_buf; + char* old_name; ulint i; ut_ad(table); @@ -899,6 +923,9 @@ dict_table_rename_in_cache( /* Remove table from the hash tables of tables */ HASH_DELETE(dict_table_t, name_hash, dict_sys->table_hash, ut_fold_string(table->name), table); + old_name = mem_heap_alloc(table->heap, ut_strlen(table->name) + 1); + + ut_strcpy(old_name, table->name); name_buf = mem_heap_alloc(table->heap, ut_strlen(new_name) + 1); @@ -956,7 +983,9 @@ dict_table_rename_in_cache( return(TRUE); } - /* Update the table name fields in foreign constraints */ + /* Update the table name fields in foreign constraints, and update also + the constraint id of new format >= 4.0.18 constraints. Note that at + this point we have already changed table->name to the new name. */ foreign = UT_LIST_GET_FIRST(table->foreign_list); @@ -965,14 +994,68 @@ dict_table_rename_in_cache( ut_strlen(table->name)) { /* Allocate a longer name buffer; TODO: store buf len to save memory */ + foreign->foreign_table_name = mem_heap_alloc( foreign->heap, ut_strlen(table->name) + 1); } - ut_memcpy(foreign->foreign_table_name, table->name, - ut_strlen(table->name) + 1); - foreign->foreign_table_name[ut_strlen(table->name)] = '\0'; + sprintf(foreign->foreign_table_name, "%s", table->name); + + if (ut_str_contains(foreign->id, '/')) { + ulint db_len; + char old_id[2000]; + + /* This is a >= 4.0.18 format id */ + + ut_a(ut_strlen(foreign->id) < 1999); + + ut_strcpy(old_id, foreign->id); + + if (ut_strlen(foreign->id) > ut_strlen(old_name) + + ut_strlen("_ibfk_") + && 0 == ut_memcmp(foreign->id, old_name, + ut_strlen(old_name)) + && 0 == ut_memcmp( + foreign->id + ut_strlen(old_name), + (char*)"_ibfk_", ut_strlen("_ibfk_"))) { + + /* This is a generated >= 4.0.18 format id */ + + if (ut_strlen(table->name) + > ut_strlen(old_name)) { + foreign->id = mem_heap_alloc( + foreign->heap, + ut_strlen(table->name) + + ut_strlen(old_id) + 1); + } + + /* Replace the prefix 'databasename/tablename' + with the new names */ + sprintf(foreign->id, "%s%s", table->name, + old_id + ut_strlen(old_name)); + } else { + /* This is a >= 4.0.18 format id where the user + gave the id name */ + db_len = dict_get_db_name_len(table->name) + 1; + + if (dict_get_db_name_len(table->name) + > dict_get_db_name_len(foreign->id)) { + + foreign->id = mem_heap_alloc( + foreign->heap, + db_len + ut_strlen(old_id) + 1); + } + + /* Replace the database prefix in id with the + one from table->name */ + + ut_memcpy(foreign->id, table->name, db_len); + + sprintf(foreign->id + db_len, "%s", + dict_remove_db_name(old_id)); + } + } foreign = UT_LIST_GET_NEXT(foreign_list, foreign); } @@ -984,14 +1067,13 @@ dict_table_rename_in_cache( ut_strlen(table->name)) { /* Allocate a longer name buffer; TODO: store buf len to save memory */ + foreign->referenced_table_name = mem_heap_alloc( foreign->heap, ut_strlen(table->name) + 1); } - ut_memcpy(foreign->referenced_table_name, table->name, - ut_strlen(table->name) + 1); - foreign->referenced_table_name[ut_strlen(table->name)] = '\0'; + sprintf(foreign->referenced_table_name, "%s", table->name); foreign = UT_LIST_GET_NEXT(referenced_list, foreign); } @@ -2042,7 +2124,7 @@ static char* dict_scan_to( /*=========*/ - + /* out: scanned up to this */ char* ptr, /* in: scan from */ const char *string) /* in: look for this */ { @@ -2299,12 +2381,7 @@ dict_scan_table_name( database_name = name; - i = 0; - while (name[i] != '/') { - i++; - } - - database_name_len = i; + database_name_len = dict_get_db_name_len(name); } if (table_name_len + database_name_len > 2000) { @@ -2478,6 +2555,52 @@ scan_more: } } +/************************************************************************* +Finds the highest for foreign key constraints of the table. Looks +only at the >= 4.0.18-format id's, which are of the form +databasename/tablename_ibfk_. */ +static +ulint +dict_table_get_highest_foreign_id( +/*==============================*/ + /* out: highest number, 0 if table has no new + format foreign key constraints */ + dict_table_t* table) /* in: table in the dictionary memory cache */ +{ + dict_foreign_t* foreign; + char* endp; + ulint biggest_id = 0; + ulint id; + + ut_a(table); + + foreign = UT_LIST_GET_FIRST(table->foreign_list); + + while (foreign) { + if (ut_strlen(foreign->id) > ut_strlen("_ibfk_") + + ut_strlen(table->name) + && 0 == ut_memcmp(foreign->id, table->name, + ut_strlen(table->name)) + && 0 == ut_memcmp(foreign->id + ut_strlen(table->name), + (char*)"_ibfk_", ut_strlen("_ibfk_"))) { + /* It is of the >= 4.0.18 format */ + + id = strtoul(foreign->id + ut_strlen(table->name) + + ut_strlen("_ibfk_"), + &endp, 10); + ut_a(id != biggest_id); + + if (id > biggest_id) { + biggest_id = id; + } + } + + foreign = UT_LIST_GET_NEXT(foreign_list, foreign); + } + + return(biggest_id); +} + /************************************************************************* Reports a simple foreign key create clause syntax error. */ static @@ -2520,19 +2643,26 @@ dict_create_foreign_constraints_low( FOREIGN KEY (a, b) REFERENCES table2(c, d), table2 can be written also with the database name before it: test.table2; the default - database id the database of parameter name */ + database is the database of parameter name */ char* name) /* in: table full name in the normalized form database_name/table_name */ { dict_table_t* table; dict_table_t* referenced_table; + dict_table_t* table_to_alter; + ulint highest_id_so_far = 0; dict_index_t* index; dict_foreign_t* foreign; char* ptr = sql_string; char* start_of_latest_foreign = sql_string; char* buf = dict_foreign_err_buf; + char* constraint_name; /* this is NOT a null- + terminated string */ + ulint constraint_name_len; ibool success; ulint error; + char* ptr1; + char* ptr2; ulint i; ulint j; ibool is_on_delete; @@ -2559,16 +2689,89 @@ dict_create_foreign_constraints_low( return(DB_ERROR); } + + /* First check if we are actually doing an ALTER TABLE, and in that + case look for the table being altered */ + + ptr = dict_accept(ptr, (char*) "ALTER", &success); + + if (!success) { + + goto loop; + } + + ptr = dict_accept(ptr, (char*) "TABLE", &success); + + if (!success) { + + goto loop; + } + + /* We are doing an ALTER TABLE: scan the table name we are altering; + in the call below we use the buffer 'referenced_table_name' as a dummy + buffer */ + + ptr = dict_scan_table_name(ptr, &table_to_alter, name, + &success, referenced_table_name); + if (!success) { + fprintf(stderr, +"InnoDB: Error: could not find the table being ALTERED in:\n%s\n", sql_string); + + return(DB_ERROR); + } + + /* Starting from 4.0.18 and 4.1.2, we generate foreign key id's in the + format databasename/tablename_ibfk_, where is local + to the table; look for the highest for table_to_alter, so + that we can assign to new constraints higher numbers. */ + + /* If we are altering a temporary table, the table name after ALTER + TABLE does not correspond to the internal table name, and + table_to_alter is NULL. TODO: should we fix this somehow? */ + + if (table_to_alter == NULL) { + highest_id_so_far = 0; + } else { + highest_id_so_far = dict_table_get_highest_foreign_id( + table_to_alter); + } + + /* Scan for foreign key declarations in a loop */ loop: - ptr = dict_scan_to(ptr, (char *) "FOREIGN"); + /* Scan either to "CONSTRAINT" or "FOREIGN", whichever is closer */ + + ptr1 = dict_scan_to(ptr, (char *) "CONSTRAINT"); + ptr2 = dict_scan_to(ptr, (char *) "FOREIGN"); + + constraint_name = NULL; + + if (ptr1 < ptr2) { + /* The user has specified a constraint name. Pick it so + that we can store 'databasename/constraintname' as the id of + the id of the constraint to system tables. */ + ptr = ptr1; + + ptr = dict_accept(ptr, (char *) "CONSTRAINT", &success); + + ut_a(success); + + if (!isspace(*ptr)) { + goto loop; + } + + ptr = dict_scan_id(ptr, &constraint_name, &constraint_name_len, + FALSE); + } else { + ptr = ptr2; + } if (*ptr == '\0') { - + /**********************************************************/ /* The following call adds the foreign key constraints to the data dictionary system tables on disk */ - error = dict_create_add_foreigns_to_dictionary(table, trx); - + error = dict_create_add_foreigns_to_dictionary( + highest_id_so_far, table, trx); return(error); } @@ -2676,6 +2879,28 @@ col_loop1: foreign = dict_mem_foreign_create(); + if (constraint_name) { + ulint db_len; + + /* Catenate 'databasename/' to the constraint name specified + by the user: we conceive the constraint as belonging to the + same MySQL 'database' as the table itself. We store the name + to foreign->id. */ + + db_len = dict_get_db_name_len(table->name); + + foreign->id = mem_heap_alloc(foreign->heap, + db_len + 1 + constraint_name_len + 1); + + ut_memcpy(foreign->id, table->name, db_len); + + foreign->id[db_len] = '/'; + + ut_memcpy(foreign->id + db_len + 1, constraint_name, + constraint_name_len); + foreign->id[db_len + 1 + constraint_name_len] = '\0'; + } + foreign->foreign_table = table; foreign->foreign_table_name = table->name; foreign->foreign_index = index; @@ -2977,7 +3202,7 @@ dict_create_foreign_constraints( FOREIGN KEY (a, b) REFERENCES table2(c, d), table2 can be written also with the database name before it: test.table2; the default - database id the database of parameter name */ + database is the database of parameter name */ char* name) /* in: table full name in the normalized form database_name/table_name */ { @@ -3079,8 +3304,10 @@ loop: foreign = UT_LIST_GET_FIRST(table->foreign_list); while (foreign != NULL) { - if (0 == ut_strcmp(foreign->id, id)) { - + if (0 == ut_strcmp(foreign->id, id) + || (ut_str_contains(foreign->id, '/') + && 0 == ut_strcmp(id, + dict_remove_db_name(foreign->id)))) { /* Found */ break; } @@ -3093,8 +3320,8 @@ loop: ut_sprintf_timestamp(buf); sprintf(buf + strlen(buf), " Error in dropping of a foreign key constraint of table %.500s,\n" -"just before:\n%s\n in SQL command\n%s\nCannot find a constraint with the\n" -"given id %s.\n", table->name, ptr, str, id); +"in SQL command\n%s\nCannot find a constraint with the\n" +"given id %s.\n", table->name, str, id); ut_a(strlen(buf) < DICT_FOREIGN_ERR_BUF_LEN); mutex_exit(&dict_foreign_err_mutex); @@ -3896,11 +4123,20 @@ dict_print_info_on_foreign_key_in_create_format( char* buf) /* in: buffer of at least 5000 bytes */ { char* buf2 = buf; + char* stripped_id; ulint cpy_len; ulint i; + if (ut_str_contains(foreign->id, '/')) { + /* Strip the preceding database name from the constraint id */ + stripped_id = foreign->id + 1 + + dict_get_db_name_len(foreign->id); + } else { + stripped_id = foreign->id; + } + buf2 += sprintf(buf2, ",\n CONSTRAINT `%s` FOREIGN KEY (", - foreign->id); + stripped_id); for (i = 0; i < foreign->n_fields; i++) { if ((ulint)(buf2 - buf) >= 4000) { diff --git a/innobase/include/dict0crea.h b/innobase/include/dict0crea.h index ccdedff42c8..b2c3ad7ca96 100644 --- a/innobase/include/dict0crea.h +++ b/innobase/include/dict0crea.h @@ -81,12 +81,25 @@ dict_create_or_check_foreign_constraint_tables(void); /*================================================*/ /* out: DB_SUCCESS or error code */ /************************************************************************ -Adds foreign key definitions to data dictionary tables in the database. */ +Adds foreign key definitions to data dictionary tables in the database. We +look at table->foreign_list, and also generate names to constraints that were +not named by the user. A generated constraint has a name of the format +databasename/tablename_ibfk_, where the numbers start from 1, and are +given locally for this table, that is, the number is not global, as in the +old format constraints < 4.0.18 it used to be. */ ulint dict_create_add_foreigns_to_dictionary( /*===================================*/ /* out: error code or DB_SUCCESS */ + ulint start_id,/* in: if we are actually doing ALTER TABLE + ADD CONSTRAINT, we want to generate constraint + numbers which are bigger than in the table so + far; we number the constraints from + start_id + 1 up; start_id should be set to 0 if + we are creating a new table, or if the table + so far has no constraints for which the name + was generated here */ dict_table_t* table, /* in: table */ trx_t* trx); /* in: transaction */ diff --git a/innobase/include/dict0dict.h b/innobase/include/dict0dict.h index b5ec5381db2..6f56c54224b 100644 --- a/innobase/include/dict0dict.h +++ b/innobase/include/dict0dict.h @@ -26,6 +26,14 @@ Created 1/8/1996 Heikki Tuuri #include "ut0byte.h" #include "trx0types.h" +/************************************************************************ +Get the database name length in a table name. */ + +ulint +dict_get_db_name_len( +/*=================*/ + /* out: database name length */ + char* name); /* in: table name in the form dbname '/' tablename */ /************************************************************************* Accepts a specified string. Comparisons are case-insensitive. */ diff --git a/innobase/include/ut0mem.h b/innobase/include/ut0mem.h index 4e8566eba1b..fea6fc243d8 100644 --- a/innobase/include/ut0mem.h +++ b/innobase/include/ut0mem.h @@ -85,10 +85,17 @@ ut_str_catenate( /* out, own: catenated null-terminated string */ char* str1, /* in: null-terminated string */ char* str2); /* in: null-terminated string */ +/************************************************************************** +Checks if a null-terminated string contains a certain character. */ + +ibool +ut_str_contains( +/*============*/ + char* str, /* in: null-terminated string */ + char c); /* in: character */ #ifndef UNIV_NONINL #include "ut0mem.ic" #endif #endif - diff --git a/innobase/row/row0mysql.c b/innobase/row/row0mysql.c index 257756ff8aa..8379335178f 100644 --- a/innobase/row/row0mysql.c +++ b/innobase/row/row0mysql.c @@ -2221,6 +2221,7 @@ row_rename_table_for_mysql( ulint keywordlen; ulint len; ulint i; + char* db_name; char buf[10000]; ut_ad(trx->mysql_thread_id == os_thread_get_curr_id()); @@ -2285,6 +2286,15 @@ row_rename_table_for_mysql( "PROCEDURE RENAME_TABLE_PROC () IS\n" "new_table_name CHAR;\n" "old_table_name CHAR;\n" + "gen_constr_prefix CHAR;\n" + "new_db_name CHAR;\n" + "foreign_id CHAR;\n" + "new_foreign_id CHAR;\n" + "old_db_name_len INT;\n" + "old_t_name_len INT;\n" + "new_db_name_len INT;\n" + "id_len INT;\n" + "found INT;\n" "BEGIN\n" "new_table_name :='"; @@ -2311,32 +2321,94 @@ row_rename_table_for_mysql( } str3 = mem_heap_alloc(heap, - 1000 + 500 * n_constraints_to_drop); + 1000 + 1000 * n_constraints_to_drop); *str3 = '\0'; sprintf(str3, "';\n" "UPDATE SYS_TABLES SET NAME = new_table_name\n" "WHERE NAME = old_table_name;\n"); + db_name = mem_heap_alloc(heap, 1 + dict_get_db_name_len( + old_name)); + ut_memcpy(db_name, old_name, dict_get_db_name_len(old_name)); + db_name[dict_get_db_name_len(old_name)] = '\0'; + + /* Internally, old format < 4.0.18 constraints have as the + constraint id _, while new format constraints + have /. */ + for (i = 0; i < n_constraints_to_drop; i++) { + sprintf(str3 + strlen(str3), - "DELETE FROM SYS_FOREIGN_COLS WHERE ID = '%s';\n" - "DELETE FROM SYS_FOREIGN WHERE ID = '%s';\n", + "DELETE FROM SYS_FOREIGN_COLS WHERE ID = '%s/%s';\n" + "DELETE FROM SYS_FOREIGN WHERE ID = '%s/%s';\n", + db_name, constraints_to_drop[i], + db_name, constraints_to_drop[i]); + + if (!ut_str_contains(constraints_to_drop[i], '/')) { + /* If this happens to be an old format + constraint, let us delete it. Since all new + format constraints contain '/', it does no + harm to run these DELETEs anyway. */ + + sprintf(str3 + strlen(str3), + "DELETE FROM SYS_FOREIGN_COLS WHERE ID = '%s';\n" + "DELETE FROM SYS_FOREIGN WHERE ID = '%s';\n", constraints_to_drop[i], constraints_to_drop[i]); + } } sprintf(str3 + strlen(str3), "END;\n"); - ut_a(strlen(str3) < 1000 + 500 * n_constraints_to_drop); + ut_a(strlen(str3) < 1000 + 1000 * n_constraints_to_drop); } else { str3 = (char*) "';\n" "UPDATE SYS_TABLES SET NAME = new_table_name\n" "WHERE NAME = old_table_name;\n" - "UPDATE SYS_FOREIGN SET FOR_NAME = new_table_name\n" - "WHERE FOR_NAME = old_table_name;\n" + "found := 1;\n" + "old_db_name_len := INSTR(old_table_name, '/') - 1;\n" + "new_db_name_len := INSTR(new_table_name, '/') - 1;\n" + "new_db_name := SUBSTR(new_table_name, 0, new_db_name_len);\n" + "old_t_name_len := LENGTH(old_table_name);\n" + "gen_constr_prefix := CONCAT(old_table_name, '_ibfk_');\n" + "WHILE found = 1 LOOP\n" + " SELECT ID INTO foreign_id\n" + " FROM SYS_FOREIGN\n" + " WHERE FOR_NAME = old_table_name;\n" + " IF (SQL % NOTFOUND) THEN\n" + " found := 0;\n" + " ELSE\n" + " UPDATE SYS_FOREIGN\n" + " SET FOR_NAME = new_table_name\n" + " WHERE ID = foreign_id;\n" + " id_len := LENGTH(foreign_id);\n" + " IF (INSTR(foreign_id, '/') > 0) THEN\n" + " IF (INSTR(foreign_id,\n" + " gen_constr_prefix) > 0)\n" + " THEN\n" + " new_foreign_id :=\n" + " CONCAT(new_table_name,\n" + " SUBSTR(foreign_id, old_t_name_len,\n" + " id_len - old_t_name_len));\n" + " ELSE\n" + " new_foreign_id :=\n" + " CONCAT(new_db_name,\n" + " SUBSTR(foreign_id,\n" + " old_db_name_len,\n" + " id_len - old_db_name_len));\n" + " END IF;\n" + " UPDATE SYS_FOREIGN\n" + " SET ID = new_foreign_id\n" + " WHERE ID = foreign_id;\n" + " UPDATE SYS_FOREIGN_COLS\n" + " SET ID = new_foreign_id\n" + " WHERE ID = foreign_id;\n" + " END IF;\n" + " END IF;\n" + "END LOOP;\n" "UPDATE SYS_FOREIGN SET REF_NAME = new_table_name\n" "WHERE REF_NAME = old_table_name;\n" "END;\n"; diff --git a/innobase/sync/sync0sync.c b/innobase/sync/sync0sync.c index 773b239189c..32615ce88ac 100644 --- a/innobase/sync/sync0sync.c +++ b/innobase/sync/sync0sync.c @@ -159,7 +159,7 @@ struct sync_thread_struct{ }; /* Number of slots reserved for each OS thread in the sync level array */ -#define SYNC_THREAD_N_LEVELS 250 +#define SYNC_THREAD_N_LEVELS 10000 struct sync_level_struct{ void* latch; /* pointer to a mutex or an rw-lock; NULL means that diff --git a/innobase/ut/ut0mem.c b/innobase/ut/ut0mem.c index f5d207d8bba..5dee08d64c3 100644 --- a/innobase/ut/ut0mem.c +++ b/innobase/ut/ut0mem.c @@ -221,3 +221,27 @@ ut_str_catenate( return(str); } + +/************************************************************************** +Checks if a null-terminated string contains a certain character. */ + +ibool +ut_str_contains( +/*============*/ + char* str, /* in: null-terminated string */ + char c) /* in: character */ +{ + ulint len; + ulint i; + + len = ut_strlen(str); + + for (i = 0; i < len; i++) { + if (str[i] == c) { + + return(TRUE); + } + } + + return(FALSE); +} \ No newline at end of file From 3da94694b2e53ee273c53a165bd816c864576545 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 9 Feb 2004 14:29:31 +0300 Subject: [PATCH 100/113] follow-up to bug #2628: attempt to make alter table rename a bit more efficient in case of lower_case_table_names. --- sql/sql_table.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 16263429e33..c738eb0a3e7 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1478,8 +1478,12 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, alias= (lower_case_table_names == 2) ? table_list->alias : table_name; db=table_list->db; - if (!new_db || !strcmp(new_db, db)) - new_db=db; + if (!new_db || + lower_case_table_names && !my_strcasecmp(new_db, db) || + !lower_case_table_names && !strcmp(new_db, db)) + { + new_db= db; + } used_fields=create_info->used_fields; mysql_ha_closeall(thd, table_list); From 17d4afc68eb53b13332efb9d579283acd2290744 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 9 Feb 2004 18:56:39 +0200 Subject: [PATCH 101/113] row0mysql.c: Fix crash in InnoDB RENAME TABLE if 'databasename/tablename' is shorter than 5 characters (Bug #2689); reported by Sergey Petrunia innobase/row/row0mysql.c: Fix crash in InnoDB RENAME TABLE if 'databasename/tablename' is shorter than 5 characters (Bug #2689); reported by Sergey Petrunia --- innobase/row/row0mysql.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/innobase/row/row0mysql.c b/innobase/row/row0mysql.c index 8379335178f..ce88bcc5933 100644 --- a/innobase/row/row0mysql.c +++ b/innobase/row/row0mysql.c @@ -2185,7 +2185,7 @@ row_is_mysql_tmp_table_name( { ulint i; - for (i = 0; i <= ut_strlen(name) - 5; i++) { + for (i = 0; i + 5 <= ut_strlen(name); i++) { if (ut_memcmp(name + i, (char*)"/#sql", 5) == 0) { return(TRUE); From e2646f092e0e077dc5ad5440159767eeee2136d1 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 9 Feb 2004 23:57:29 +0200 Subject: [PATCH 102/113] row0mysql.c: Allow always DROPping of a table which is only referenced by FOREIGN KEY constraints from the same table Many files: Do not let REPLACE to perform internally an UPDATE if the table is referenced by a FOREIGN KEY: the manual says that REPLACE must resolve a duplicate key error semantically with DELETE(s) + INSERT, and not by an UPDATE; the internal update caused foreign key checks and cascaded operations to behave in a semantically wrong way sql/ha_innodb.cc: Do not let REPLACE to perform internally an UPDATE if the table is referenced by a FOREIGN KEY: the manual says that REPLACE must resolve a duplicate key error semantically with DELETE(s) + INSERT, and not by an UPDATE; the internal update caused foreign key checks and cascaded operations to behave in a semantically wrong way sql/sql_insert.cc: Do not let REPLACE to perform internally an UPDATE if the table is referenced by a FOREIGN KEY: the manual says that REPLACE must resolve a duplicate key error semantically with DELETE(s) + INSERT, and not by an UPDATE; the internal update caused foreign key checks and cascaded operations to behave in a semantically wrong way sql/ha_innodb.h: Do not let REPLACE to perform internally an UPDATE if the table is referenced by a FOREIGN KEY: the manual says that REPLACE must resolve a duplicate key error semantically with DELETE(s) + INSERT, and not by an UPDATE; the internal update caused foreign key checks and cascaded operations to behave in a semantically wrong way sql/handler.h: Do not let REPLACE to perform internally an UPDATE if the table is referenced by a FOREIGN KEY: the manual says that REPLACE must resolve a duplicate key error semantically with DELETE(s) + INSERT, and not by an UPDATE; the internal update caused foreign key checks and cascaded operations to behave in a semantically wrong way innobase/dict/dict0dict.c: Do not let REPLACE to perform internally an UPDATE if the table is referenced by a FOREIGN KEY: the manual says that REPLACE must resolve a duplicate key error semantically with DELETE(s) + INSERT, and not by an UPDATE; the internal update caused foreign key checks and cascaded operations to behave in a semantically wrong way innobase/include/dict0dict.h: Do not let REPLACE to perform internally an UPDATE if the table is referenced by a FOREIGN KEY: the manual says that REPLACE must resolve a duplicate key error semantically with DELETE(s) + INSERT, and not by an UPDATE; the internal update caused foreign key checks and cascaded operations to behave in a semantically wrong way innobase/row/row0mysql.c: Allow always DROPping of a table which is only referenced by FOREIGN KEY constraints from the same table --- innobase/dict/dict0dict.c | 18 ++++++++++++++++++ innobase/include/dict0dict.h | 9 +++++++++ innobase/row/row0mysql.c | 7 +++++++ sql/ha_innodb.cc | 23 ++++++++++++++++++++++- sql/ha_innodb.h | 1 + sql/handler.h | 2 ++ sql/sql_insert.cc | 10 +++++++++- 7 files changed, 68 insertions(+), 2 deletions(-) diff --git a/innobase/dict/dict0dict.c b/innobase/dict/dict0dict.c index e0597c66dba..5b2a16ce9f3 100644 --- a/innobase/dict/dict0dict.c +++ b/innobase/dict/dict0dict.c @@ -1845,6 +1845,24 @@ dict_index_build_internal_non_clust( /*====================== FOREIGN KEY PROCESSING ========================*/ +/************************************************************************* +Checks if a table is referenced by foreign keys. */ + +ibool +dict_table_referenced_by_foreign_key( +/*=================================*/ + /* out: TRUE if table is referenced by a + foreign key */ + dict_table_t* table) /* in: InnoDB table */ +{ + if (UT_LIST_GET_LEN(table->referenced_list) > 0) { + + return(TRUE); + } + + return(FALSE); +} + /************************************************************************* Frees a foreign key struct. */ static diff --git a/innobase/include/dict0dict.h b/innobase/include/dict0dict.h index 6f56c54224b..7d55521f228 100644 --- a/innobase/include/dict0dict.h +++ b/innobase/include/dict0dict.h @@ -206,6 +206,15 @@ dict_foreign_add_to_cache( /* out: DB_SUCCESS or error code */ dict_foreign_t* foreign); /* in, own: foreign key constraint */ /************************************************************************* +Checks if a table is referenced by foreign keys. */ + +ibool +dict_table_referenced_by_foreign_key( +/*=================================*/ + /* out: TRUE if table is referenced by a + foreign key */ + dict_table_t* table); /* in: InnoDB table */ +/************************************************************************* Scans a table create SQL string and adds to the data dictionary the foreign key constraints declared in the string. This function should be called after the indexes for a table have been created. diff --git a/innobase/row/row0mysql.c b/innobase/row/row0mysql.c index ce88bcc5933..a95d0fc6b95 100644 --- a/innobase/row/row0mysql.c +++ b/innobase/row/row0mysql.c @@ -1997,8 +1997,15 @@ row_drop_table_for_mysql( goto funct_exit; } + /* Check if the table is referenced by foreign key constraints from + some other table (not the table itself) */ + foreign = UT_LIST_GET_FIRST(table->referenced_list); + while (foreign && foreign->foreign_table == table) { + foreign = UT_LIST_GET_NEXT(referenced_list, foreign); + } + if (foreign && trx->check_foreigns) { char* buf = dict_foreign_err_buf; diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 01af07f34ec..73f517285a0 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -4289,7 +4289,28 @@ ha_innobase::get_foreign_key_create_info(void) prebuilt->trx->op_info = (char*)""; return(str); -} +} + +/*********************************************************************** +Checks if a table is referenced by a foreign key. The MySQL manual states that +a REPLACE is either equivalent to an INSERT, or DELETE(s) + INSERT. Only a +delete is then allowed internally to resolve a duplicate key conflict in +REPLACE, not an update. */ + +uint +ha_innobase::referenced_by_foreign_key(void) +/*========================================*/ + /* out: > 0 if referenced by a FOREIGN KEY */ +{ + row_prebuilt_t* prebuilt = (row_prebuilt_t*)innobase_prebuilt; + + if (dict_table_referenced_by_foreign_key(prebuilt->table)) { + + return(1); + } + + return(0); +} /*********************************************************************** Frees the foreign key create info for a table stored in InnoDB, if it is diff --git a/sql/ha_innodb.h b/sql/ha_innodb.h index 8a51019b18e..384b3dec949 100644 --- a/sql/ha_innodb.h +++ b/sql/ha_innodb.h @@ -179,6 +179,7 @@ class ha_innobase: public handler int check(THD* thd, HA_CHECK_OPT* check_opt); char* update_table_comment(const char* comment); char* get_foreign_key_create_info(); + uint referenced_by_foreign_key(); void free_foreign_key_create_info(char* str); THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to, enum thr_lock_type lock_type); diff --git a/sql/handler.h b/sql/handler.h index 60edf539e2c..750db45759e 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -319,6 +319,8 @@ public: virtual void append_create_info(String *packet) {} virtual char* get_foreign_key_create_info() { return(NULL);} /* gets foreign key create string from InnoDB */ + virtual uint referenced_by_foreign_key() { return 0;} /* used in REPLACE; + is > 0 if table is referred by a FOREIGN KEY */ virtual void init_table_handle_for_HANDLER() { return; } /* prepare InnoDB for HANDLER */ virtual void free_foreign_key_create_info(char* str) {} diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 97b7c1db03d..4d7a9f7e508 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -442,7 +442,15 @@ int write_record(TABLE *table,COPY_INFO *info) HA_READ_KEY_EXACT)))) goto err; } - if (last_uniq_key(table,key_nr)) + /* + The manual defines the REPLACE semantics that it is either an INSERT or + DELETE(s) + INSERT; FOREIGN KEY checks do not function in the defined + way if we allow MySQL to convert the latter operation internally to an + UPDATE. + */ + + if (last_uniq_key(table,key_nr) + && !table->file->referenced_by_foreign_key()) { if ((error=table->file->update_row(table->record[1],table->record[0]))) goto err; From 30d52f53d1ca4614726b79f3c582de8c7e6ce67b Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 10 Feb 2004 12:03:08 +0100 Subject: [PATCH 103/113] Code cleanups client/mysqlbinlog.cc: Ensure that errors are returned to upper levels instead of just doing 'exit/die' in sub function. sql/handler.h: Indentation cleanup sql/sql_insert.cc: Indentation cleanup --- client/mysqlbinlog.cc | 236 +++++++++++++++++++++++++++--------------- sql/handler.h | 5 +- sql/sql_insert.cc | 7 +- 3 files changed, 162 insertions(+), 86 deletions(-) diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index ecf998c6d96..90c3cfc98f6 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -59,13 +59,14 @@ static MYSQL* mysql = NULL; static const char* dirname_for_local_load= 0; -static void dump_local_log_entries(const char* logname); -static void dump_remote_log_entries(const char* logname); -static void dump_log_entries(const char* logname); -static void dump_remote_file(NET* net, const char* fname); +static int dump_local_log_entries(const char* logname); +static int dump_remote_log_entries(const char* logname); +static int dump_log_entries(const char* logname); +static int dump_remote_file(NET* net, const char* fname); static void die(const char* fmt, ...); static MYSQL* safe_connect(); + class Load_log_processor { char target_dir_name[MY_NFILE]; @@ -150,39 +151,14 @@ public: return res; } int process(Create_file_log_event *ce); - int process(Append_block_log_event *ae) - { - File file; - Create_file_log_event* ce= (ae->file_id < file_names.elements) ? - *((Create_file_log_event**)file_names.buffer + ae->file_id) : 0; - - if (ce) - { - if (((file= my_open(ce->fname, - O_APPEND|O_BINARY|O_WRONLY,MYF(MY_WME))) < 0) || - my_write(file,(byte*)ae->block,ae->block_len,MYF(MY_WME|MY_NABP)) || - my_close(file,MYF(MY_WME))) - return -1; - } - else - { - /* - There is no Create_file event (a bad binlog or a big - --position). Assuming it's a big --position, we just do nothing and - print a warning. - */ - fprintf(stderr,"Warning: ignoring Append_block as there is no \ -Create_file event for file_id: %u\n",ae->file_id); - return -1; - } - return 0; - } - + int process(Append_block_log_event *ae); File prepare_new_file_for_old_format(Load_log_event *le, char *filename); int load_old_format_file(NET* net, const char *server_fname, uint server_fname_len, File file); }; + + File Load_log_processor::prepare_new_file_for_old_format(Load_log_event *le, char *filename) { @@ -205,6 +181,7 @@ File Load_log_processor::prepare_new_file_for_old_format(Load_log_event *le, return file; } + int Load_log_processor::load_old_format_file(NET* net, const char*server_fname, uint server_fname_len, File file) { @@ -248,21 +225,24 @@ int Load_log_processor::load_old_format_file(NET* net, const char*server_fname, return 0; } + int Load_log_processor::process(Create_file_log_event *ce) { const char *bname= ce->fname+dirname_length(ce->fname); uint blen= ce->fname_len - (bname-ce->fname); uint full_len= target_dir_name_len + blen + 9 + 9 + 1; + int error= 0; char *fname, *ptr; File file; - if (!(fname= my_malloc(full_len,MYF(MY_WME))) || - set_dynamic(&file_names,(gptr)&ce,ce->file_id)) + if (set_dynamic(&file_names,(gptr)&ce,ce->file_id)) { sql_print_error("Could not construct local filename %s%s", target_dir_name,bname); return -1; } + if (!(fname= my_malloc(full_len,MYF(MY_WME)))) + return -1; memcpy(fname, target_dir_name, target_dir_name_len); ptr= fname + target_dir_name_len; @@ -278,15 +258,51 @@ int Load_log_processor::process(Create_file_log_event *ce) } ce->set_fname_outside_temp_buf(fname,strlen(fname)); - if (my_write(file,(byte*) ce->block,ce->block_len,MYF(MY_WME|MY_NABP)) || - my_close(file,MYF(MY_WME))) - return -1; + if (my_write(file,(byte*) ce->block,ce->block_len,MYF(MY_WME|MY_NABP))) + error= -1; + if (my_close(file,MYF(MY_WME))) + error= -1; + return error; } + +int Load_log_processor::process(Append_block_log_event *ae) +{ + Create_file_log_event* ce= ((ae->file_id < file_names.elements) ? + *((Create_file_log_event**)file_names.buffer + + ae->file_id) : + 0); + + if (ce) + { + File file; + int error= 0; + if (((file= my_open(ce->fname, + O_APPEND|O_BINARY|O_WRONLY,MYF(MY_WME))) < 0)) + return -1; + if (my_write(file,(byte*)ae->block,ae->block_len,MYF(MY_WME|MY_NABP))) + error= -1; + if (my_close(file,MYF(MY_WME))) + error= -1; + return error; + } + + /* + There is no Create_file event (a bad binlog or a big + --position). Assuming it's a big --position, we just do nothing and + print a warning. + */ + fprintf(stderr,"Warning: ignoring Append_block as there is no \ +Create_file event for file_id: %u\n",ae->file_id); + return -1; +} + + Load_log_processor load_processor; -void process_event(ulonglong *rec_count, char *last_db, Log_event *ev, - my_off_t pos, int old_format) + +int process_event(ulonglong *rec_count, char *last_db, Log_event *ev, + my_off_t pos, int old_format) { char ll_buff[21]; if ((*rec_count) >= offset) @@ -303,7 +319,7 @@ void process_event(ulonglong *rec_count, char *last_db, Log_event *ev, { (*rec_count)++; delete ev; - return; // next + return 0; // Time for next event } } ev->print(result_file, short_form, last_db); @@ -324,7 +340,7 @@ void process_event(ulonglong *rec_count, char *last_db, Log_event *ev, { (*rec_count)++; delete ev; - return; // next + return 0; // next } } /* @@ -337,14 +353,16 @@ void process_event(ulonglong *rec_count, char *last_db, Log_event *ev, ce->print(result_file, short_form, last_db, true); if (!old_format) { - load_processor.process(ce); + if (load_processor.process(ce)) + break; // Error ev= 0; } break; } case APPEND_BLOCK_EVENT: ev->print(result_file, short_form, last_db); - load_processor.process((Append_block_log_event*)ev); + if (load_processor.process((Append_block_log_event*) ev)) + break; // Error break; case EXEC_LOAD_EVENT: { @@ -374,8 +392,10 @@ Create_file event for file_id: %u\n",exv->file_id); (*rec_count)++; if (ev) delete ev; + return 0; } + static struct my_option my_long_options[] = { #ifndef DBUG_OFF @@ -545,14 +565,15 @@ static MYSQL* safe_connect() return local_mysql; } -static void dump_log_entries(const char* logname) + +static int dump_log_entries(const char* logname) { if (remote_opt) - dump_remote_log_entries(logname); - else - dump_local_log_entries(logname); + return dump_remote_log_entries(logname); + return dump_local_log_entries(logname); } + static int check_master_version(MYSQL* mysql) { MYSQL_RES* res = 0; @@ -601,7 +622,7 @@ static int check_master_version(MYSQL* mysql) } -static void dump_remote_log_entries(const char* logname) +static int dump_remote_log_entries(const char* logname) { char buf[128]; char last_db[FN_REFLEN+1] = ""; @@ -615,7 +636,7 @@ static void dump_remote_log_entries(const char* logname) if (position < BIN_LOG_HEADER_SIZE) { position = BIN_LOG_HEADER_SIZE; - // warn the guity + // warn the user sql_print_error("Warning: The position in the binary log can't be less than %d.\nStarting from position %d\n", BIN_LOG_HEADER_SIZE, BIN_LOG_HEADER_SIZE); } int4store(buf, position); @@ -624,7 +645,10 @@ static void dump_remote_log_entries(const char* logname) int4store(buf + 6, 0); memcpy(buf + 10, logname,len); if (simple_command(mysql, COM_BINLOG_DUMP, buf, len + 10, 1)) - die("Error sending the log dump command"); + { + fprintf(stderr,"Got fatal error sending the log dump command\n"); + return 1; + } my_off_t old_off= 0; ulonglong rec_count= 0; @@ -635,7 +659,11 @@ static void dump_remote_log_entries(const char* logname) const char *error; len = net_safe_read(mysql); if (len == packet_error) - die("Error reading packet from server: %s", mysql_error(mysql)); + { + fprintf(stderr, "Got error reading packet from server: %s\n", + mysql_error(mysql)); + return 1; + } if (len < 8 && net->read_pos[0] == 254) break; // end of data DBUG_PRINT("info",( "len= %u, net->read_pos[5] = %d\n", @@ -644,39 +672,48 @@ static void dump_remote_log_entries(const char* logname) len - 1, &error, old_format); if (!ev) { - die("Could not construct log event object"); + fprintf(stderr, "Could not construct log event object\n"); + return 1; } + + Log_event_type type= ev->get_type_code(); + if (!old_format || ( type != LOAD_EVENT && type != CREATE_FILE_EVENT)) + { + if (process_event(&rec_count,last_db,ev,old_off,old_format)) + return 1; + } else { - Log_event_type type= ev->get_type_code(); - if (!old_format || ( type != LOAD_EVENT && type != CREATE_FILE_EVENT ) ) + Load_log_event *le= (Load_log_event*)ev; + const char *old_fname= le->fname; + uint old_len= le->fname_len; + File file; + + if ((file= load_processor.prepare_new_file_for_old_format(le,fname)) < 0) + return 1; + if (process_event(&rec_count,last_db,ev,old_off,old_format)) { - process_event(&rec_count,last_db,ev,old_off,old_format); + my_close(file,MYF(MY_WME)); + return 1; } - else + if (load_processor.load_old_format_file(net,old_fname,old_len,file)) { - Load_log_event *le= (Load_log_event*)ev; - const char *old_fname= le->fname; - uint old_len= le->fname_len; - File file= load_processor.prepare_new_file_for_old_format(le,fname); - if (file >= 0) - { - process_event(&rec_count,last_db,ev,old_off,old_format); - load_processor.load_old_format_file(net,old_fname,old_len,file); - my_close(file,MYF(MY_WME)); - } + my_close(file,MYF(MY_WME)); + return 1; } + my_close(file,MYF(MY_WME)); } /* - Let's adjust offset for remote log as for local log to produce - similar text.. + Let's adjust offset for remote log as for local log to produce + similar text.. */ if (old_off) old_off+= len-1; else old_off= BIN_LOG_HEADER_SIZE; } + return 0; } @@ -706,7 +743,7 @@ static int check_header(IO_CACHE* file) } -static void dump_local_log_entries(const char* logname) +static int dump_local_log_entries(const char* logname) { File fd = -1; IO_CACHE cache,*file= &cache; @@ -714,23 +751,27 @@ static void dump_local_log_entries(const char* logname) char last_db[FN_REFLEN+1]; byte tmp_buff[BIN_LOG_HEADER_SIZE]; bool old_format = 0; + int error= 0; - last_db[0]=0; + last_db[0]= 0; if (logname && logname[0] != '-') { if ((fd = my_open(logname, O_RDONLY | O_BINARY, MYF(MY_WME))) < 0) - exit(1); + return 1; if (init_io_cache(file, fd, 0, READ_CACHE, (my_off_t) position, 0, MYF(MY_WME | MY_NABP))) + { + my_close(fd, MYF(MY_WME)); exit(1); + } old_format = check_header(file); } else { if (init_io_cache(file, fileno(result_file), 0, READ_CACHE, (my_off_t) 0, 0, MYF(MY_WME | MY_NABP | MY_DONT_CHECK_FILESIZE))) - exit(1); + return 1; old_format = check_header(file); if (position) { @@ -741,7 +782,10 @@ static void dump_local_log_entries(const char* logname) { tmp=min(length,sizeof(buff)); if (my_b_read(file, buff, (uint) tmp)) - exit(1); + { + error= 1; + goto end; + } } } file->pos_in_file=position; @@ -749,7 +793,15 @@ static void dump_local_log_entries(const char* logname) } if (!position) - my_b_read(file, tmp_buff, BIN_LOG_HEADER_SIZE); // Skip header + { + // Skip header + if (my_b_read(file, tmp_buff, BIN_LOG_HEADER_SIZE)) + { + error= 1; + goto end; + } + } + for (;;) { char llbuff[21]; @@ -759,19 +811,31 @@ static void dump_local_log_entries(const char* logname) if (!ev) { if (file->error) - die("\ -Could not read entry at offset %s : Error in log format or read error", - llstr(old_off,llbuff)); + { + fprintf(stderr, + "Could not read entry at offset %s:" + "Error in log format or read error\n", + llstr(old_off,llbuff)); + error= 1; + } // file->error == 0 means EOF, that's OK, we break in this case break; } - process_event(&rec_count,last_db,ev,old_off,false); + if (process_event(&rec_count,last_db,ev,old_off,false)) + { + error= 1; + break; + } } + +end: if (fd >= 0) my_close(fd, MYF(MY_WME)); end_io_cache(file); + return error; } + #if MYSQL_VERSION_ID < 40101 typedef struct st_my_tmpdir @@ -842,9 +906,11 @@ void free_tmpdir(MY_TMPDIR *tmpdir) #endif + int main(int argc, char** argv) { static char **defaults_argv; + int exit_value; MY_INIT(argv[0]); parse_args(&argc, (char***)&argv); @@ -854,7 +920,7 @@ int main(int argc, char** argv) { usage(); free_defaults(defaults_argv); - return -1; + exit(1); } if (remote_opt) @@ -874,8 +940,15 @@ int main(int argc, char** argv) else load_processor.init_by_cur_dir(); + exit_value= 0; while (--argc >= 0) - dump_log_entries(*(argv++)); + { + if (dump_log_entries(*(argv++))) + { + exit_value=1; + break; + } + } if (tmpdir.list) free_tmpdir(&tmpdir); @@ -886,7 +959,8 @@ int main(int argc, char** argv) cleanup(); free_defaults(defaults_argv); my_end(0); - return 0; + exit(exit_value); + return exit_value; // Keep compilers happy } /* diff --git a/sql/handler.h b/sql/handler.h index 750db45759e..ead0ed106c7 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -319,8 +319,9 @@ public: virtual void append_create_info(String *packet) {} virtual char* get_foreign_key_create_info() { return(NULL);} /* gets foreign key create string from InnoDB */ - virtual uint referenced_by_foreign_key() { return 0;} /* used in REPLACE; - is > 0 if table is referred by a FOREIGN KEY */ + + /* used in REPLACE; is > 0 if table is referred by a FOREIGN KEY */ + virtual uint referenced_by_foreign_key() { return 0;} virtual void init_table_handle_for_HANDLER() { return; } /* prepare InnoDB for HANDLER */ virtual void free_foreign_key_create_info(char* str) {} diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 4d7a9f7e508..bf3112bdf10 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -438,7 +438,8 @@ int write_record(TABLE *table,COPY_INFO *info) key_copy((byte*) key,table,key_nr,0); if ((error=(table->file->index_read_idx(table->record[1],key_nr, (byte*) key, - table->key_info[key_nr].key_length, + table->key_info[key_nr]. + key_length, HA_READ_KEY_EXACT)))) goto err; } @@ -449,8 +450,8 @@ int write_record(TABLE *table,COPY_INFO *info) UPDATE. */ - if (last_uniq_key(table,key_nr) - && !table->file->referenced_by_foreign_key()) + if (last_uniq_key(table,key_nr) && + !table->file->referenced_by_foreign_key()) { if ((error=table->file->update_row(table->record[1],table->record[0]))) goto err; From 8ee9f87d2663c53fe17aafacaebf5e0e70825b63 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 10 Feb 2004 14:17:55 +0300 Subject: [PATCH 104/113] compile-irix-mips64-mipspro addded to the source distribution --- BUILD/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/BUILD/Makefile.am b/BUILD/Makefile.am index 9c1ab24fde7..2414d4f3a44 100644 --- a/BUILD/Makefile.am +++ b/BUILD/Makefile.am @@ -37,6 +37,7 @@ EXTRA_DIST = FINISH.sh \ compile-pentium-pgcc \ compile-solaris-sparc \ compile-solaris-sparc-debug \ + compile-irix-mips64-mipspro \ compile-solaris-sparc-forte \ compile-solaris-sparc-purify From 0743e5d6cb2ebe3763834475d2c9d65a2cafbbd9 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 10 Feb 2004 12:27:14 +0100 Subject: [PATCH 105/113] Export CXX and AR to make it easier to invoke other configure scripts with same options. --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 86a3daf84da..5ed2105be89 100644 --- a/configure.in +++ b/configure.in @@ -348,7 +348,7 @@ AC_SUBST(CXXFLAGS) AC_SUBST(LD) AC_SUBST(INSTALL_SCRIPT) -export CC CFLAGS LD LDFLAGS +export CC CXX CFLAGS LD LDFLAGS AR if test "$GXX" = "yes" then From 96634253b7c4b8c6649f14f24b4786ac1996a40f Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 12 Feb 2004 15:53:47 +0100 Subject: [PATCH 106/113] - always use CXX=gcc (not only when using gcc 3) to avoid a dependency on libstdc++ and exceptions --- support-files/mysql.spec.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 3ee602e7504..b69d6961f37 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -258,10 +258,11 @@ export PATH # Build the 4.0 Max binary (includes BDB and UDFs and therefore # cannot be linked statically against the patched glibc) -# If we want to compile with RAID using gcc 3, we need to use -# gcc instead of g++ to avoid linking problems (RAID code is written in C++) -test -z $CXX && test -z $CC && if gcc -v 2>&1 | grep 'gcc version 3' > /dev/null 2>&1 +# Use gcc for C and C++ code (to avoid a dependency on libstdc++ and +# including exceptions into the code +test -z $CXX && test -z $CC then + export CC="gcc" export CXX="gcc" fi @@ -573,6 +574,10 @@ fi # The spec file changelog only includes changes made to the spec file # itself %changelog +* Thu Feb 12 2004 Lenz Grimmer + +- when using gcc, _always_ use CXX=gcc + * Tue Feb 03 2004 Lenz Grimmer - added myisam_ftdump to the Server package From 99472547d45e48a4a1fa4597ac5efd4432325849 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 12 Feb 2004 16:51:52 +0100 Subject: [PATCH 107/113] - fixed broken shellcode --- support-files/mysql.spec.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index b69d6961f37..18f41ed5326 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -260,7 +260,7 @@ export PATH # Use gcc for C and C++ code (to avoid a dependency on libstdc++ and # including exceptions into the code -test -z $CXX && test -z $CC +if [ -z "$CXX" -a -z "$CC" ] then export CC="gcc" export CXX="gcc" From 9c919004589c3c2e0368104a35b039c419d5cb02 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 12 Feb 2004 17:12:08 +0100 Subject: [PATCH 108/113] - Replaced obsolete "Copyright" field with "License" in the RPM spec file support-files/mysql.spec.sh: - Replaced obsolete "Copyright" field with "License" --- support-files/mysql.spec.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/support-files/mysql.spec.sh b/support-files/mysql.spec.sh index 18f41ed5326..cea9c112b8b 100644 --- a/support-files/mysql.spec.sh +++ b/support-files/mysql.spec.sh @@ -16,7 +16,7 @@ Summary(pt_BR): MySQL: Um servidor SQL r Group(pt_BR): Aplicações/Banco_de_Dados Version: @MYSQL_NO_DASH_VERSION@ Release: %{release} -Copyright: GPL +License: GPL Source: http://www.mysql.com/Downloads/MySQL-@MYSQL_BASE_VERSION@/mysql-%{mysql_version}.tar.gz URL: http://www.mysql.com/ Packager: Lenz Grimmer @@ -577,6 +577,7 @@ fi * Thu Feb 12 2004 Lenz Grimmer - when using gcc, _always_ use CXX=gcc +- replaced Copyright with License field (Copyright is obsolete) * Tue Feb 03 2004 Lenz Grimmer From df793ff9bae13bb045c9e1d829cd8e009df8af79 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 12 Feb 2004 19:33:06 +0100 Subject: [PATCH 109/113] - bumped up version number in configure.in from 4.0.18 -> 4.0.19 - Tagged ChangeSet@1.1733 as mysql-4.0.18 configure.in: - bumped up version number from 4.0.18 -> 4.0.19 --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 5ed2105be89..1fa9e1c5a38 100644 --- a/configure.in +++ b/configure.in @@ -4,7 +4,7 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT(sql/mysqld.cc) AC_CANONICAL_SYSTEM # The Docs Makefile.am parses this line! -AM_INIT_AUTOMAKE(mysql, 4.0.18) +AM_INIT_AUTOMAKE(mysql, 4.0.19) AM_CONFIG_HEADER(config.h) PROTOCOL_VERSION=10 From 9c8ca1fa64398ed8679b3aba3a51490ac16fa9c9 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 12 Feb 2004 23:45:39 +0400 Subject: [PATCH 110/113] fixed copying of color in SEL_ARG::clone (fixed bug #2968) mysql-test/r/select_found.result: added new tests for bugs with range optimization (bugs #2448 and #2698) mysql-test/t/select_found.test: added new tests for bugs with range optimization (bugs #2448 and #2698) --- mysql-test/r/select_found.result | 18 ++++++++++++++++++ mysql-test/t/select_found.test | 28 ++++++++++++++++++++++++++++ sql/opt_range.cc | 1 + 3 files changed, 47 insertions(+) diff --git a/mysql-test/r/select_found.result b/mysql-test/r/select_found.result index 419ffb73d59..367bdd798b4 100644 --- a/mysql-test/r/select_found.result +++ b/mysql-test/r/select_found.result @@ -188,3 +188,21 @@ select FOUND_ROWS(); FOUND_ROWS() 0 drop table t1; +CREATE TABLE t1 ( a int not null, b int not null, KEY ab(a,b) ); +INSERT INTO t1 VALUES ( 47, 1 ); +INSERT INTO t1 VALUES ( 70, 1 ); +SELECT * FROM t1 +WHERE +( +( b =1 AND a BETWEEN 14 AND 21 ) OR +( b =2 AND a BETWEEN 16 AND 18 ) OR +( b =3 AND a BETWEEN 15 AND 19 ) +); +a b +DROP TABLE t1; +CREATE TABLE t1 ( a integer, u varchar(15), r integer, key uao_idx( r, a, u)); +DELETE FROM t1 +WHERE ( r = 1 AND a IN ( 1, 2 ) AND ( u = 'w' OR u LIKE 'w/%' ) ) +OR ( r = 1 AND a IN ( 3 ) AND ( u = 'w/U' OR u LIKE 'w/U/%' ) ) +OR ( r = 1 AND a IN ( 1, 2, 3 ) AND ( u = 'w' ) ); +drop table t1; diff --git a/mysql-test/t/select_found.test b/mysql-test/t/select_found.test index f5ee4d5c010..e584fca206f 100644 --- a/mysql-test/t/select_found.test +++ b/mysql-test/t/select_found.test @@ -99,3 +99,31 @@ select FOUND_ROWS(); select SQL_CALC_FOUND_ROWS * from t1 where id > 6 limit 0, 1; select FOUND_ROWS(); drop table t1; + +# +# Other bugs with range optimization +# + +# bug #2448 + +CREATE TABLE t1 ( a int not null, b int not null, KEY ab(a,b) ); +INSERT INTO t1 VALUES ( 47, 1 ); +INSERT INTO t1 VALUES ( 70, 1 ); +SELECT * FROM t1 +WHERE +( + ( b =1 AND a BETWEEN 14 AND 21 ) OR + ( b =2 AND a BETWEEN 16 AND 18 ) OR + ( b =3 AND a BETWEEN 15 AND 19 ) +); +DROP TABLE t1; + +# bug #2698 + +CREATE TABLE t1 ( a integer, u varchar(15), r integer, key uao_idx( r, a, u)); +DELETE FROM t1 +WHERE ( r = 1 AND a IN ( 1, 2 ) AND ( u = 'w' OR u LIKE 'w/%' ) ) + OR ( r = 1 AND a IN ( 3 ) AND ( u = 'w/U' OR u LIKE 'w/U/%' ) ) + OR ( r = 1 AND a IN ( 1, 2, 3 ) AND ( u = 'w' ) ); +drop table t1; + diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 188d503b767..0ed5c447486 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -488,6 +488,7 @@ SEL_ARG *SEL_ARG::clone(SEL_ARG *new_parent,SEL_ARG **next_arg) return 0; // OOM } increment_use_count(1); + tmp->color= color; return tmp; } From 0a95bda23a349639bd51c4b2c71da56ebd13d31f Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 13 Feb 2004 16:05:09 +0200 Subject: [PATCH 111/113] Always use libtool with "--preserve-dup-deps" Always use all LOAD DATA options in replication. Fixed problem in mysqlbinlog where LOAD DATA options could be overwritten. client/mysqlbinlog.cc: Ensure that we don't call init_dynamic_array() before my_init() has been done configure.in: Always use libtool with "--preserve-dup-deps" to prevent link problems with g++ mysql-test/r/mysqlbinlog.result: new results mysql-test/r/range.result: new results mysql-test/t/range.test: add missing DROP TABLE sql/log_event.cc: Always use all LOAD DATA options. This is needed to handle commands of type "FIELDS TERMINATED BY ''" Allocate memory for Create_file_log_event options as these may be overwritten in mysqlbinlog sql/log_event.h: Free buffer --- client/mysqlbinlog.cc | 34 +++++++---- configure.in | 5 ++ mysql-test/r/mysqlbinlog.result | 22 +++---- mysql-test/r/range.result | 1 + mysql-test/t/range.test | 1 + sql/log_event.cc | 101 ++++++++++++-------------------- sql/log_event.h | 6 +- 7 files changed, 81 insertions(+), 89 deletions(-) diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 90c3cfc98f6..71819070a85 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -103,17 +103,18 @@ class Load_log_processor } public: - Load_log_processor() - { - init_dynamic_array(&file_names,sizeof(Create_file_log_event*), - 100,100 CALLER_INFO); - } - + Load_log_processor() {} ~Load_log_processor() - { - destroy(); - delete_dynamic(&file_names); - } + { + destroy(); + delete_dynamic(&file_names); + } + + int init() + { + return init_dynamic_array(&file_names,sizeof(Create_file_log_event*), + 100,100 CALLER_INFO); + } void init_by_dir_name(const char *dir) { @@ -350,7 +351,7 @@ int process_event(ulonglong *rec_count, char *last_db, Log_event *ev, filename and use LOCAL), prepared in the 'case EXEC_LOAD_EVENT' below. */ - ce->print(result_file, short_form, last_db, true); + ce->print(result_file, short_form, last_db, TRUE); if (!old_format) { if (load_processor.process(ce)) @@ -376,7 +377,7 @@ int process_event(ulonglong *rec_count, char *last_db, Log_event *ev, */ if (ce) { - ce->print(result_file, short_form, last_db,true); + ce->print(result_file, short_form, last_db, TRUE); my_free((char*)ce->fname,MYF(MY_WME)); delete ce; } @@ -458,6 +459,10 @@ void sql_print_error(const char *format,...) static void cleanup() { my_free(pass,MYF(MY_ALLOW_ZERO_PTR)); + my_free((char*) database, MYF(MY_ALLOW_ZERO_PTR)); + my_free((char*) host, MYF(MY_ALLOW_ZERO_PTR)); + my_free((char*) user, MYF(MY_ALLOW_ZERO_PTR)); + my_free((char*) dirname_for_local_load, MYF(MY_ALLOW_ZERO_PTR)); } static void die(const char* fmt, ...) @@ -469,12 +474,13 @@ static void die(const char* fmt, ...) fprintf(stderr, "\n"); va_end(args); cleanup(); + my_end(0); exit(1); } static void print_version() { - printf("%s Ver 2.4 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE); + printf("%s Ver 2.5 for %s at %s\n", my_progname, SYSTEM_TYPE, MACHINE_TYPE); } @@ -935,6 +941,8 @@ int main(int argc, char** argv) dirname_for_local_load= my_tmpdir(&tmpdir); } + if (load_processor.init()) + exit(1); if (dirname_for_local_load) load_processor.init_by_dir_name(dirname_for_local_load); else diff --git a/configure.in b/configure.in index 5ed2105be89..ad1feefdd98 100644 --- a/configure.in +++ b/configure.in @@ -194,6 +194,11 @@ AC_PROG_RANLIB #AC_LIBTOOL_WIN32_DLL AC_PROG_LIBTOOL +# Ensure that we have --preserve-dup-deps defines, otherwise we get link +# problems of 'mysql' with CXX=g++ +LIBTOOL="$LIBTOOL --preserve-dup-deps" +AC_SUBST(LIBTOOL)dnl + #AC_LIBTOOL_DLOPEN AC_LIBTOOL_WIN32_DLL AC_DISABLE_FAST_INSTALL AC_DISABLE_SHARED AC_DISABLE_STATIC # AC_PROG_INSTALL diff --git a/mysql-test/r/mysqlbinlog.result b/mysql-test/r/mysqlbinlog.result index f604aa0589e..df472eb9c80 100644 --- a/mysql-test/r/mysqlbinlog.result +++ b/mysql-test/r/mysqlbinlog.result @@ -24,11 +24,11 @@ insert into t1 values ("abirvalg"); SET INSERT_ID=1; SET TIMESTAMP=1000000000; insert into t2 values (); -LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-1-0' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); -LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-2-0' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); -LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-3-0' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); -LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-4-0' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); -LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-5-0' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); +LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-1-0' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); +LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-2-0' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); +LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-3-0' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); +LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-4-0' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); +LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-5-0' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); --- Broken LOAD DATA -- use test; @@ -54,12 +54,12 @@ insert into t1 values ("abirvalg"); SET INSERT_ID=1; SET TIMESTAMP=1000000000; insert into t2 values (); -LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-1-1' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); -LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-2-1' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); -LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-3-1' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); -LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-4-1' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); -LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-5-1' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); -LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-6-1' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); +LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-1-1' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); +LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-2-1' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); +LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-3-1' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); +LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-4-1' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); +LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-5-1' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); +LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-6-1' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word); SET TIMESTAMP=1000000000; insert into t1 values ("Alas"); diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result index ccfdbd62a42..b826dd1b677 100644 --- a/mysql-test/r/range.result +++ b/mysql-test/r/range.result @@ -313,3 +313,4 @@ WHERE a b 15 1 47 1 +DROP TABLE t1; diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test index 2899c7c99a4..40fb402a457 100644 --- a/mysql-test/t/range.test +++ b/mysql-test/t/range.test @@ -263,3 +263,4 @@ WHERE ( b =3 AND a BETWEEN 15 AND 19 ) OR (a BETWEEN 19 AND 47) ); +DROP TABLE t1; diff --git a/sql/log_event.cc b/sql/log_event.cc index b5d7b1df038..1c10a9a798c 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -293,40 +293,21 @@ void Load_log_event::pack_info(String* packet) else if (sql_ex.opt_flags & IGNORE_FLAG) tmp.append(" IGNORE "); - tmp.append("INTO TABLE "); + tmp.append("INTO TABLE `"); tmp.append(table_name); - if (sql_ex.field_term_len) - { - tmp.append(" FIELDS TERMINATED BY "); - pretty_print_str(&tmp, sql_ex.field_term, sql_ex.field_term_len); - } - - if (sql_ex.enclosed_len) - { - if (sql_ex.opt_flags & OPT_ENCLOSED_FLAG ) - tmp.append(" OPTIONALLY "); - tmp.append( " ENCLOSED BY "); - pretty_print_str(&tmp, sql_ex.enclosed, sql_ex.enclosed_len); - } + tmp.append("` FIELDS TERMINATED BY "); + pretty_print_str(&tmp, sql_ex.field_term, sql_ex.field_term_len); + if (sql_ex.opt_flags & OPT_ENCLOSED_FLAG ) + tmp.append(" OPTIONALLY "); + tmp.append( " ENCLOSED BY "); + pretty_print_str(&tmp, sql_ex.enclosed, sql_ex.enclosed_len); + tmp.append( " ESCAPED BY "); + pretty_print_str(&tmp, sql_ex.escaped, sql_ex.escaped_len); - if (sql_ex.escaped_len) - { - tmp.append( " ESCAPED BY "); - pretty_print_str(&tmp, sql_ex.escaped, sql_ex.escaped_len); - } - - bool line_lexem_added= false; - if (sql_ex.line_term_len) - { - tmp.append(" LINES TERMINATED BY "); - pretty_print_str(&tmp, sql_ex.line_term, sql_ex.line_term_len); - line_lexem_added= true; - } - + tmp.append(" LINES TERMINATED BY "); + pretty_print_str(&tmp, sql_ex.line_term, sql_ex.line_term_len); if (sql_ex.line_start_len) { - if (!line_lexem_added) - tmp.append(" LINES"); tmp.append(" STARTING BY "); pretty_print_str(&tmp, sql_ex.line_start, sql_ex.line_start_len); } @@ -1323,7 +1304,8 @@ void Load_log_event::print(FILE* file, bool short_form, char* last_db) print(file, short_form, last_db, 0); } -void Load_log_event::print(FILE* file, bool short_form, char* last_db, bool commented) +void Load_log_event::print(FILE* file, bool short_form, char* last_db, + bool commented) { if (!short_form) { @@ -1354,40 +1336,22 @@ void Load_log_event::print(FILE* file, bool short_form, char* last_db, bool comm fprintf(file," REPLACE "); else if (sql_ex.opt_flags & IGNORE_FLAG ) fprintf(file," IGNORE "); - - fprintf(file, "INTO TABLE %s ", table_name); - if (sql_ex.field_term) - { - fprintf(file, " FIELDS TERMINATED BY "); - pretty_print_str(file, sql_ex.field_term, sql_ex.field_term_len); - } - if (sql_ex.enclosed) - { - if (sql_ex.opt_flags & OPT_ENCLOSED_FLAG ) - fprintf(file," OPTIONALLY "); - fprintf(file, " ENCLOSED BY "); - pretty_print_str(file, sql_ex.enclosed, sql_ex.enclosed_len); - } - - if (sql_ex.escaped) - { - fprintf(file, " ESCAPED BY "); - pretty_print_str(file, sql_ex.escaped, sql_ex.escaped_len); - } - - bool line_lexem_added= false; - if (sql_ex.line_term) - { - fprintf(file," LINES TERMINATED BY "); - pretty_print_str(file, sql_ex.line_term, sql_ex.line_term_len); - line_lexem_added= true; - } + fprintf(file, "INTO TABLE `%s`", table_name); + fprintf(file, " FIELDS TERMINATED BY "); + pretty_print_str(file, sql_ex.field_term, sql_ex.field_term_len); + + if (sql_ex.opt_flags & OPT_ENCLOSED_FLAG ) + fprintf(file," OPTIONALLY "); + fprintf(file, " ENCLOSED BY "); + pretty_print_str(file, sql_ex.enclosed, sql_ex.enclosed_len); + fprintf(file, " ESCAPED BY "); + pretty_print_str(file, sql_ex.escaped, sql_ex.escaped_len); + fprintf(file," LINES TERMINATED BY "); + pretty_print_str(file, sql_ex.line_term, sql_ex.line_term_len); if (sql_ex.line_start) { - if (!line_lexem_added) - fprintf(file," LINES"); fprintf(file," STARTING BY "); pretty_print_str(file, sql_ex.line_start, sql_ex.line_start_len); } @@ -1546,7 +1510,7 @@ Create_file_log_event(THD* thd_arg, sql_exchange* ex, char* block_arg, uint block_len_arg, bool using_trans) :Load_log_event(thd_arg,ex,db_arg,table_name_arg,fields_arg,handle_dup, using_trans), - fake_base(0),block(block_arg),block_len(block_len_arg), + fake_base(0),block(block_arg), event_buf(0), block_len(block_len_arg), file_id(thd_arg->file_id = mysql_bin_log.next_file_id()) { sql_ex.force_new_format(); @@ -1586,8 +1550,16 @@ Create_file_log_event::Create_file_log_event(const char* buf, int len, :Load_log_event(buf,0,old_format),fake_base(0),block(0),inited_from_old(0) { int block_offset; - if (copy_log_event(buf,len,old_format)) - return; + DBUG_ENTER("Create_file_log_event"); + + /* + We must make copy of 'buf' as this event may have to live over a + rotate log entry when used in mysqlbinlog + */ + if (!(event_buf= my_memdup(buf, len, MYF(MY_WME))) || + (copy_log_event(event_buf, len, old_format))) + DBUG_VOID_RETURN; + if (!old_format) { file_id = uint4korr(buf + LOG_EVENT_HEADER_LEN + @@ -1605,6 +1577,7 @@ Create_file_log_event::Create_file_log_event(const char* buf, int len, sql_ex.force_new_format(); inited_from_old = 1; } + DBUG_VOID_RETURN; } diff --git a/sql/log_event.h b/sql/log_event.h index b610263a462..2eaaab260fc 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -644,6 +644,7 @@ protected: bool fake_base; public: char* block; + const char *event_buf; uint block_len; uint file_id; bool inited_from_old; @@ -663,7 +664,10 @@ public: #endif Create_file_log_event(const char* buf, int event_len, bool old_format); - ~Create_file_log_event() {} + ~Create_file_log_event() + { + my_free((char*) event_buf, MYF(MY_ALLOW_ZERO_PTR)); + } Log_event_type get_type_code() { From 40ad9154930ca5d42649b776f84989cc372b060c Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 16 Feb 2004 09:41:13 +0200 Subject: [PATCH 112/113] Cleanup + safety comment sql/share/english/errmsg.txt: Added note to ensure that no one adds new error message to 4.0. This is important as it causes too many problems with test suite in 4.1 sql/sql_load.cc: Removed wrong comment. --- sql/share/english/errmsg.txt | 4 +++- sql/sql_load.cc | 7 +------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt index 7104eb64d56..dca9311b277 100644 --- a/sql/share/english/errmsg.txt +++ b/sql/share/english/errmsg.txt @@ -238,5 +238,7 @@ "Wrong usage/placement of '%s'", "This version of MySQL doesn't yet support '%s'", "Got fatal error %d: '%-.128s' from master when reading data from binary log", -"Slave SQL thread ignored the query because of replicate-*-table rules" +"Slave SQL thread ignored the query because of replicate-*-table rules", "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/sql_load.cc b/sql/sql_load.cc index 3b8672188d4..1603a7eb26a 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -92,12 +92,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, LOAD_FILE_INFO lf_info; char *db = table_list->db; // This is never null /* If no current database, use database where table is located */ - char *tdb= thd->db ? thd->db : db; - /* - 'tdb' can be NULL only if both table_list->db and thd->db are NULL - 'db' itself can be NULL. but in that case it will generate - an error earlier open_ltable()). - */ + char *tdb= thd->db ? thd->db : db; // Result is never null bool transactional_table, log_delayed; ulong skip_lines= ex->skip_lines; DBUG_ENTER("mysql_load"); From a07e48eca04b1564da9868f229ba5d958994db69 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 16 Feb 2004 10:03:25 +0200 Subject: [PATCH 113/113] After merge fixes Added more DBUG statements Ensure that we are comparing end space with BINARY strings Use 'any_db' instead of '' to mean any database. (For HANDLER command) Only strip ' ' when comparing CHAR, not other space-like characters (like \t) BitKeeper/deleted/.del-ctype_tis620.result-old~3578ceb0b8284685: Delete: mysql-test/r/ctype_tis620.result-old BitKeeper/deleted/.del-ctype_tis620.test-old~ffb1bbd2935d1aba: Delete: mysql-test/t/ctype_tis620.test-old client/mysqlbinlog.cc: Added DBUG statements Added call of my_end() to free all used memory on exit heap/hp_info.c: After merge fixes heap/hp_open.c: After merge fixes include/heap.h: After merge fixes include/m_ctype.h: Use pchar instead of 'int' for character parameters. Added 'my_binary_compare()' include/m_string.h: Fixed wrong define innobase/ibuf/ibuf0ibuf.c: After merge fixes innobase/srv/srv0start.c: After merge fixes mysql-test/r/alter_table.result: Fixed results after merge mysql-test/r/auto_increment.result: Fixed results after merge mysql-test/r/bdb.result: Fixed results after merge mysql-test/r/binary.result: Fixed results after merge mysql-test/r/create.result: Fixed results after merge mysql-test/r/ctype_mb.result: Fixed results after merge mysql-test/r/ctype_tis620.result: Fixed results after merge mysql-test/r/ctype_utf8.result: Fixed results after merge mysql-test/r/delete.result: Fixed results after merge mysql-test/r/func_compress.result: Fixed results after merge mysql-test/r/func_gconcat.result: Fixed results after merge mysql-test/r/func_group.result: Fixed results after merge mysql-test/r/func_str.result: Fixed results after merge mysql-test/r/innodb.result: Fixed results after merge mysql-test/r/insert.result: Fixed results after merge mysql-test/r/insert_select.result: Fixed results after merge mysql-test/r/key.result: Fixed results after merge mysql-test/r/loaddata.result: Fixed results after merge mysql-test/r/lock.result: Fixed results after merge mysql-test/r/myisam.result: Fixed results after merge mysql-test/r/null.result: Fixed results after merge mysql-test/r/null_key.result: Fixed results after merge mysql-test/r/order_by.result: Fixed results after merge mysql-test/r/query_cache.result: Fixed results after merge mysql-test/r/range.result: Fixed results after merge mysql-test/r/rpl_multi_delete.result: Fixed results after merge mysql-test/r/rpl_until.result: Fixed results after merge mysql-test/r/subselect.result: Fixed results after merge mysql-test/r/subselect_innodb.result: Fixed results after merge mysql-test/r/type_blob.result: Fixed results after merge mysql-test/r/type_datetime.result: Fixed results after merge mysql-test/r/type_decimal.result: Fixed results after merge mysql-test/r/type_enum.result: Fixed results after merge mysql-test/r/type_float.result: Fixed results after merge mysql-test/r/type_ranges.result: Fixed results after merge mysql-test/r/type_time.result: Fixed results after merge mysql-test/r/type_timestamp.result: Fixed results after merge mysql-test/r/type_uint.result: Fixed results after merge mysql-test/r/type_year.result: Fixed results after merge mysql-test/r/variables.result: Fixed results after merge mysql-test/r/warnings.result: Fixed results after merge mysql-test/t/case.test: Fixed shifted error messages mysql-test/t/create.test: Fixed shifted error messages mysql-test/t/ctype_collate.test: Fixed shifted error messages mysql-test/t/ctype_tis620.test: Merge with 4.0 ctype_tis620 test mysql-test/t/delete.test: Fixed shifted error messages mysql-test/t/derived.test: Fixed shifted error messages mysql-test/t/fulltext.test: Fixed shifted error messages mysql-test/t/func_in.test: Fixed shifted error messages mysql-test/t/func_str.test: Fixed shifted error messages mysql-test/t/func_test.test: Fixed shifted error messages mysql-test/t/grant.test: Fixed shifted error messages mysql-test/t/innodb.test: Change to 4.1 syntax mysql-test/t/key_cache.test: Fixed shifted error messages mysql-test/t/myisam.test: New test of blob and end space mysql-test/t/row.test: Fixed shifted error messages mysql-test/t/rpl_until.test: Fixed shifted error messages mysql-test/t/subselect.test: Fixed shifted error messages mysql-test/t/subselect_innodb.test: Fix test to take into account foreign key constraints mysql-test/t/union.test: Fixed shifted error messages mysql-test/t/user_var.test: Fixed shifted error messages mysql-test/t/variables.test: Fixed shifted error messages mysys/my_handler.c: Merge with 4.0 code sql/ha_heap.cc: After merge fixes sql/handler.cc: After merge fixes sql/item.cc: After merge fixes sql/item_cmpfunc.cc: Ensure that we are comparing end space with BINARY strings sql/item_cmpfunc.h: Ensure that we are comparing end space with BINARY strings sql/log_event.cc: More DBUG statements Ensure that we use all options to LOAD DATA in replication sql/opt_range.cc: After merge fixes sql/sql_db.cc: After merge fixes sql/sql_handler.cc: After merge fixes Use 'any_db' instead of '' to mean 'no database comparison' sql/sql_parse.cc: After merge fixes sql/sql_select.cc: After merge fixes Added function comment for setup_group() sql/sql_string.cc: Added stringcmp() for binary comparison. Added function comments for sortcmp() and stringcmp() sql/sql_string.h: Added stringcmp() sql/sql_table.cc: After merge fixes sql/sql_update.cc: After merge fixes sql/sql_yacc.yy: Use 'any_db' instead of '' to mean any database. Using "" causes a 'wrong db name' error. strings/ctype-big5.c: Strip only end space, not other space characters. strings/ctype-bin.c: Removed some not needed functions. Added function comments Don't remove end space in comparisons Change my_wildcmp_bin() to be 'identical' with other similar code strings/ctype-czech.c: Strip only end space, not other space characters. strings/ctype-gbk.c: Strip only end space, not other space characters. strings/ctype-latin1.c: Strip only end space, not other space characters. strings/ctype-mb.c: Strip only end space, not other space characters. strings/ctype-simple.c: Strip only end space, not other space characters. strings/ctype-sjis.c: Strip only end space, not other space characters. strings/ctype-tis620.c: Added usage of my_instr_simple. This needs to be cleaned up! strings/ctype-utf8.c: Strip only end space, not other space characters. strings/ctype-win1250ch.c: Strip only end space, not other space characters. Fixed indentation strings/strto.c: Code cleanup --- client/mysqlbinlog.cc | 63 ++--- heap/hp_info.c | 1 - heap/hp_open.c | 1 - include/heap.h | 1 - include/m_ctype.h | 5 +- include/m_string.h | 2 +- innobase/ibuf/ibuf0ibuf.c | 8 - innobase/srv/srv0start.c | 25 -- mysql-test/r/alter_table.result | 26 +- mysql-test/r/auto_increment.result | 6 +- mysql-test/r/bdb.result | 12 +- mysql-test/r/binary.result | 2 - mysql-test/r/create.result | 2 +- mysql-test/r/ctype_mb.result | 6 +- mysql-test/r/ctype_tis620.result | 120 +++++++++ mysql-test/r/ctype_tis620.result-old | 113 --------- mysql-test/r/ctype_utf8.result | 2 +- mysql-test/r/delete.result | 8 +- mysql-test/r/func_compress.result | 4 +- mysql-test/r/func_gconcat.result | 4 +- mysql-test/r/func_group.result | 2 +- mysql-test/r/func_str.result | 352 +++++++++++++++++++++++++++ mysql-test/r/innodb.result | 2 +- mysql-test/r/insert.result | 2 +- mysql-test/r/insert_select.result | 3 + mysql-test/r/key.result | 12 +- mysql-test/r/loaddata.result | 34 +-- mysql-test/r/lock.result | 2 +- mysql-test/r/myisam.result | 18 +- mysql-test/r/null.result | 22 +- mysql-test/r/null_key.result | 2 +- mysql-test/r/order_by.result | 8 +- mysql-test/r/query_cache.result | 8 +- mysql-test/r/range.result | 1 + mysql-test/r/rpl_multi_delete.result | 4 +- mysql-test/r/rpl_until.result | 2 +- mysql-test/r/subselect.result | 40 +-- mysql-test/r/subselect_innodb.result | 2 +- mysql-test/r/type_blob.result | 6 +- mysql-test/r/type_datetime.result | 10 +- mysql-test/r/type_decimal.result | 110 ++++----- mysql-test/r/type_enum.result | 4 +- mysql-test/r/type_float.result | 4 +- mysql-test/r/type_ranges.result | 66 ++--- mysql-test/r/type_time.result | 6 +- mysql-test/r/type_timestamp.result | 36 +-- mysql-test/r/type_uint.result | 2 +- mysql-test/r/type_year.result | 2 + mysql-test/r/variables.result | 6 +- mysql-test/r/warnings.result | 98 ++++---- mysql-test/t/case.test | 8 +- mysql-test/t/create.test | 6 +- mysql-test/t/ctype_collate.test | 14 +- mysql-test/t/ctype_tis620.test | 65 +++++ mysql-test/t/ctype_tis620.test-old | 64 ----- mysql-test/t/delete.test | 4 +- mysql-test/t/derived.test | 6 +- mysql-test/t/fulltext.test | 4 +- mysql-test/t/func_in.test | 6 +- mysql-test/t/func_str.test | 48 ++-- mysql-test/t/func_test.test | 12 +- mysql-test/t/grant.test | 4 +- mysql-test/t/innodb.test | 4 +- mysql-test/t/key_cache.test | 4 +- mysql-test/t/myisam.test | 12 + mysql-test/t/row.test | 14 +- mysql-test/t/rpl_until.test | 10 +- mysql-test/t/subselect.test | 58 ++--- mysql-test/t/subselect_innodb.test | 2 +- mysql-test/t/union.test | 4 +- mysql-test/t/user_var.test | 4 +- mysql-test/t/variables.test | 5 +- mysys/my_handler.c | 14 +- sql/ha_heap.cc | 4 +- sql/handler.cc | 4 +- sql/item.cc | 5 +- sql/item_cmpfunc.cc | 57 ++++- sql/item_cmpfunc.h | 2 + sql/log_event.cc | 140 +++++------ sql/opt_range.cc | 4 +- sql/sql_db.cc | 2 +- sql/sql_handler.cc | 4 +- sql/sql_parse.cc | 13 +- sql/sql_select.cc | 28 ++- sql/sql_string.cc | 51 +++- sql/sql_string.h | 1 + sql/sql_table.cc | 4 +- sql/sql_update.cc | 9 +- sql/sql_yacc.yy | 4 +- strings/ctype-big5.c | 12 +- strings/ctype-bin.c | 154 ++++++------ strings/ctype-czech.c | 13 +- strings/ctype-gbk.c | 6 +- strings/ctype-latin1.c | 4 +- strings/ctype-mb.c | 10 +- strings/ctype-simple.c | 65 ++--- strings/ctype-sjis.c | 12 +- strings/ctype-tis620.c | 9 +- strings/ctype-utf8.c | 4 +- strings/ctype-win1250ch.c | 242 ++++++++---------- strings/strto.c | 2 +- 101 files changed, 1483 insertions(+), 1031 deletions(-) delete mode 100644 mysql-test/r/ctype_tis620.result-old delete mode 100644 mysql-test/t/ctype_tis620.test-old diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 9e30b1ae71e..27ad91c8e8a 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -233,15 +233,16 @@ int Load_log_processor::process(Create_file_log_event *ce) int error= 0; char *fname, *ptr; File file; + DBUG_ENTER("Load_log_processor::process"); if (set_dynamic(&file_names,(gptr)&ce,ce->file_id)) { sql_print_error("Could not construct local filename %s%s", target_dir_name,bname); - return -1; + DBUG_RETURN(-1); } if (!(fname= my_malloc(full_len,MYF(MY_WME)))) - return -1; + DBUG_RETURN(-1); memcpy(fname, target_dir_name, target_dir_name_len); ptr= fname + target_dir_name_len; @@ -253,20 +254,21 @@ int Load_log_processor::process(Create_file_log_event *ce) { sql_print_error("Could not construct local filename %s%s", target_dir_name,bname); - return -1; + DBUG_RETURN(-1); } ce->set_fname_outside_temp_buf(fname,strlen(fname)); if (my_write(file,(byte*) ce->block,ce->block_len,MYF(MY_WME|MY_NABP))) error= -1; - if (my_close(file,MYF(MY_WME))) + if (my_close(file, MYF(MY_WME))) error= -1; - return error; + DBUG_RETURN(error); } int Load_log_processor::process(Append_block_log_event *ae) { + DBUG_ENTER("Load_log_processor::process"); Create_file_log_event* ce= ((ae->file_id < file_names.elements) ? *((Create_file_log_event**)file_names.buffer + ae->file_id) : @@ -278,12 +280,12 @@ int Load_log_processor::process(Append_block_log_event *ae) int error= 0; if (((file= my_open(ce->fname, O_APPEND|O_BINARY|O_WRONLY,MYF(MY_WME))) < 0)) - return -1; + DBUG_RETURN(-1); if (my_write(file,(byte*)ae->block,ae->block_len,MYF(MY_WME|MY_NABP))) error= -1; if (my_close(file,MYF(MY_WME))) error= -1; - return error; + DBUG_RETURN(error); } /* @@ -293,7 +295,7 @@ int Load_log_processor::process(Append_block_log_event *ae) */ fprintf(stderr,"Warning: ignoring Append_block as there is no \ Create_file event for file_id: %u\n",ae->file_id); - return -1; + DBUG_RETURN(-1); } @@ -304,6 +306,8 @@ int process_event(ulonglong *rec_count, char *last_db, Log_event *ev, my_off_t pos, int old_format) { char ll_buff[21]; + DBUG_ENTER("process_event"); + if ((*rec_count) >= offset) { if (!short_form) @@ -315,11 +319,7 @@ int process_event(ulonglong *rec_count, char *last_db, Log_event *ev, { const char * log_dbname = ((Query_log_event*)ev)->db; if ((log_dbname != NULL) && (strcmp(log_dbname, database))) - { - (*rec_count)++; - delete ev; - return 0; // Time for next event - } + goto end; } ev->print(result_file, short_form, last_db); break; @@ -336,11 +336,7 @@ int process_event(ulonglong *rec_count, char *last_db, Log_event *ev, */ const char * log_dbname = ce->db; if ((log_dbname != NULL) && (strcmp(log_dbname, database))) - { - (*rec_count)++; - delete ev; - return 0; // next - } + goto end; // Next event } /* We print the event, but with a leading '#': this is just to inform @@ -388,10 +384,12 @@ Create_file event for file_id: %u\n",exv->file_id); ev->print(result_file, short_form, last_db); } } + +end: (*rec_count)++; if (ev) delete ev; - return 0; + DBUG_RETURN(0); } @@ -472,6 +470,7 @@ static void die(const char* fmt, ...) fprintf(stderr, "\n"); va_end(args); cleanup(); + my_end(0); exit(1); } @@ -645,6 +644,8 @@ static int dump_remote_log_entries(const char* logname) uint len; NET* net = &mysql->net; int old_format; + DBUG_ENTER("dump_remote_log_entries"); + old_format = check_master_version(mysql); if (!position) @@ -663,7 +664,7 @@ static int dump_remote_log_entries(const char* logname) if (simple_command(mysql, COM_BINLOG_DUMP, buf, len + 10, 1)) { fprintf(stderr,"Got fatal error sending the log dump command\n"); - return 1; + DBUG_RETURN(1); } my_off_t old_off= 0; @@ -678,7 +679,7 @@ static int dump_remote_log_entries(const char* logname) { fprintf(stderr, "Got error reading packet from server: %s\n", mysql_error(mysql)); - return 1; + DBUG_RETURN(1); } if (len < 8 && net->read_pos[0] == 254) break; // end of data @@ -689,14 +690,14 @@ static int dump_remote_log_entries(const char* logname) if (!ev) { fprintf(stderr, "Could not construct log event object\n"); - return 1; + DBUG_RETURN(1); } Log_event_type type= ev->get_type_code(); if (!old_format || ( type != LOAD_EVENT && type != CREATE_FILE_EVENT)) { if (process_event(&rec_count,last_db,ev,old_off,old_format)) - return 1; + DBUG_RETURN(1); } else { @@ -706,16 +707,17 @@ static int dump_remote_log_entries(const char* logname) File file; if ((file= load_processor.prepare_new_file_for_old_format(le,fname)) < 0) - return 1; + DBUG_RETURN(1); + if (process_event(&rec_count,last_db,ev,old_off,old_format)) { my_close(file,MYF(MY_WME)); - return 1; + DBUG_RETURN(1); } if (load_processor.load_old_format_file(net,old_fname,old_len,file)) { my_close(file,MYF(MY_WME)); - return 1; + DBUG_RETURN(1); } my_close(file,MYF(MY_WME)); } @@ -729,7 +731,7 @@ static int dump_remote_log_entries(const char* logname) else old_off= BIN_LOG_HEADER_SIZE; } - return 0; + DBUG_RETURN(0); } @@ -738,6 +740,7 @@ static int check_header(IO_CACHE* file) byte header[BIN_LOG_HEADER_SIZE]; byte buf[PROBE_HEADER_LEN]; int old_format=0; + DBUG_ENTER("check_header"); my_off_t pos = my_b_tell(file); my_b_seek(file, (my_off_t)0); @@ -755,7 +758,7 @@ static int check_header(IO_CACHE* file) } } my_b_seek(file, pos); - return old_format; + DBUG_RETURN(old_format); } @@ -857,6 +860,8 @@ int main(int argc, char** argv) static char **defaults_argv; int exit_value; MY_INIT(argv[0]); + DBUG_ENTER("main"); + DBUG_PROCESS(argv[0]); parse_args(&argc, (char***)&argv); defaults_argv=argv; @@ -905,7 +910,7 @@ int main(int argc, char** argv) free_defaults(defaults_argv); my_end(0); exit(exit_value); - return exit_value; // Keep compilers happy + DBUG_RETURN(exit_value); // Keep compilers happy } /* diff --git a/heap/hp_info.c b/heap/hp_info.c index a403ff9bb45..2e56d030234 100644 --- a/heap/hp_info.c +++ b/heap/hp_info.c @@ -54,7 +54,6 @@ int heap_info(reg1 HP_INFO *info,reg2 HEAPINFO *x, int flag ) x->index_length = info->s->index_length; x->max_records = info->s->max_records; x->errkey = info->errkey; - x->implicit_emptied= info->implicit_emptied; if (flag & HA_STATUS_AUTO) x->auto_increment= info->s->auto_increment + 1; DBUG_RETURN(0); diff --git a/heap/hp_open.c b/heap/hp_open.c index 497b3e4772d..1fa832208fb 100644 --- a/heap/hp_open.c +++ b/heap/hp_open.c @@ -63,7 +63,6 @@ HP_INFO *heap_open(const char *name, int mode) #ifndef DBUG_OFF info->opt_flag= READ_CHECK_USED; /* Check when changing */ #endif - info->implicit_emptied= 0; DBUG_PRINT("exit",("heap: %lx reclength: %d records_in_block: %d", info,share->reclength,share->block.records_in_block)); DBUG_RETURN(info); diff --git a/include/heap.h b/include/heap.h index cb73b07cd41..c5f2be81fb7 100644 --- a/include/heap.h +++ b/include/heap.h @@ -51,7 +51,6 @@ typedef struct st_heapinfo /* Struct from heap_info */ uint reclength; /* Length of one record */ int errkey; ulonglong auto_increment; - my_bool implicit_emptied; } HEAPINFO; diff --git a/include/m_ctype.h b/include/m_ctype.h index 88c3418fc0d..247b2220920 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -111,7 +111,7 @@ typedef struct my_collation_handler_st uchar *, uint, const uchar *, uint); my_bool (*like_range)(struct charset_info_st *, const char *s, uint s_length, - int w_prefix, int w_one, int w_many, + pchar w_prefix, pchar w_one, pchar w_many, uint res_length, char *min_str, char *max_str, uint *min_len, uint *max_len); @@ -300,7 +300,7 @@ void my_fill_8bit(CHARSET_INFO *cs, char* to, uint l, int fill); my_bool my_like_range_simple(CHARSET_INFO *cs, const char *ptr, uint ptr_length, - int escape, int w_one, int w_many, + pbool escape, pbool w_one, pbool w_many, uint res_length, char *min_str, char *max_str, uint *min_length, uint *max_length); @@ -381,6 +381,7 @@ extern my_bool my_parse_charset_xml(const char *bug, uint len, #define my_isvar(s,c) (my_isalnum(s,c) || (c) == '_') #define my_isvar_start(s,c) (my_isalpha(s,c) || (c) == '_') +#define my_binary_compare(s) ((s)->state & MY_CS_BINSORT) #define use_strnxfrm(s) ((s)->state & MY_CS_STRNXFRM) #define my_strnxfrm(s, a, b, c, d) ((s)->coll->strnxfrm((s), (a), (b), (c), (d))) #define my_strnncoll(s, a, b, c, d) ((s)->coll->strnncoll((s), (a), (b), (c), (d))) diff --git a/include/m_string.h b/include/m_string.h index d72342fb3c1..5db7158f110 100644 --- a/include/m_string.h +++ b/include/m_string.h @@ -126,7 +126,7 @@ extern void bmove_align(gptr dst,const gptr src,uint len); #include #define memcpy_overlap(A,B,C) \ DBUG_ASSERT((A) == (B) || ((A)+(C)) <= (B) || ((B)+(C)) <= (A)); \ -bmove((byte*) key,(byte*) from,(size_t) length); +bmove((byte*) (A),(byte*) (B),(size_t) (C)); #else #define memcpy_overlap(A,B,C) memcpy((A), (B), (C)) #endif /* HAVE_purify */ diff --git a/innobase/ibuf/ibuf0ibuf.c b/innobase/ibuf/ibuf0ibuf.c index 80128c3137d..805f08af361 100644 --- a/innobase/ibuf/ibuf0ibuf.c +++ b/innobase/ibuf/ibuf0ibuf.c @@ -3045,14 +3045,6 @@ loop: goto reset_bit; } - /* Do NOT merge to the 4.1 code base! */ - if (trx_sys_downgrading_from_4_1_1) { - fprintf(stderr, -"InnoDB: Fatal error: you are downgrading from >= 4.1.1 to 4.0, but\n" -"InnoDB: the insert buffer was not empty.\n"); - ut_a(0); - } - if (corruption_noticed) { rec_sprintf(err_buf, 450, ibuf_rec); fprintf(stderr, diff --git a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c index 7b9c7a4066e..e6fdc95fad0 100644 --- a/innobase/srv/srv0start.c +++ b/innobase/srv/srv0start.c @@ -1587,31 +1587,6 @@ NetWare. */ os_fast_mutex_free(&srv_os_test_mutex); - /***********************************************************/ - /* Do NOT merge to the 4.1 code base! */ - if (trx_sys_downgrading_from_4_1_1) { - fprintf(stderr, -"InnoDB: You are downgrading from an InnoDB version which allows multiple\n" -"InnoDB: tablespaces. Wait that purge and insert buffer merge run to\n" -"InnoDB: completion...\n"); - for (;;) { - os_thread_sleep(10000000); - - if (0 == strcmp(srv_main_thread_op_info, - "waiting for server activity")) { - break; - } - } - fprintf(stderr, -"InnoDB: Full purge and insert buffer merge completed.\n"); - - trx_sys_mark_downgraded_from_4_1_1(); - - fprintf(stderr, -"InnoDB: Downgraded from >= 4.1.1 to 4.0\n"); - } - /***********************************************************/ - if (srv_print_verbose_log) { ut_print_timestamp(stderr); fprintf(stderr, diff --git a/mysql-test/r/alter_table.result b/mysql-test/r/alter_table.result index 1891da73d85..703cc59d9a4 100644 --- a/mysql-test/r/alter_table.result +++ b/mysql-test/r/alter_table.result @@ -412,18 +412,6 @@ 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; -Table Create Table -t1 CREATE TABLE `t1` ( - `a` int(11) NOT NULL default '0', - `b` int(11) default NULL, - UNIQUE KEY `b` (`b`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -ALTER TABLE t1 DROP PRIMARY KEY; -ERROR 42000: Can't DROP 'PRIMARY'. Check that column/key exists -DROP TABLE t1; create table t1 (name char(15)); insert into t1 (name) values ("current"); create database mysqltest; @@ -436,7 +424,7 @@ select * from mysqltest.t1; name mysqltest alter table t1 rename mysqltest.t1; -Table 't1' already exists +ERROR 42S01: Table 't1' already exists select * from t1; name current @@ -445,3 +433,15 @@ name mysqltest drop table t1; drop database mysqltest; +CREATE TABLE t1 (a int PRIMARY KEY, b INT UNIQUE); +ALTER TABLE t1 DROP PRIMARY KEY; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL default '0', + `b` int(11) default NULL, + UNIQUE KEY `b` (`b`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +ALTER TABLE t1 DROP PRIMARY KEY; +ERROR 42000: Can't DROP 'PRIMARY'. Check that column/key exists +DROP TABLE t1; diff --git a/mysql-test/r/auto_increment.result b/mysql-test/r/auto_increment.result index 7a7faf0db9a..8f77b306d3e 100644 --- a/mysql-test/r/auto_increment.result +++ b/mysql-test/r/auto_increment.result @@ -162,7 +162,7 @@ last_insert_id() 255 insert into t1 set i = null; Warnings: -Warning 1263 Data truncated, out of range for column 'i' at row 1 +Warning 1264 Data truncated, out of range for column 'i' at row 1 select last_insert_id(); last_insert_id() 255 @@ -213,7 +213,7 @@ a b delete from t1 where a=0; update t1 set a=NULL where b=6; Warnings: -Warning 1262 Data truncated, NULL supplied to NOT NULL column 'a' at row 4 +Warning 1263 Data truncated, NULL supplied to NOT NULL column 'a' at row 4 update t1 set a=300 where b=7; SET SQL_MODE=''; insert into t1(a,b)values(NULL,8); @@ -255,7 +255,7 @@ a b delete from t1 where a=0; update t1 set a=NULL where b=13; Warnings: -Warning 1262 Data truncated, NULL supplied to NOT NULL column 'a' at row 9 +Warning 1263 Data truncated, NULL supplied to NOT NULL column 'a' at row 9 update t1 set a=500 where b=14; select * from t1 order by b; a b diff --git a/mysql-test/r/bdb.result b/mysql-test/r/bdb.result index 44a7b4e03b2..bee40eac30d 100644 --- a/mysql-test/r/bdb.result +++ b/mysql-test/r/bdb.result @@ -1159,23 +1159,23 @@ drop table t1,t2; create table t1 (a char(10), key(a), b int not null, key(b)) engine=bdb; insert into t1 values ('a',1),('A',2); explain select a from t1; -table type possible_keys key key_len ref rows Extra -t1 ALL NULL NULL NULL NULL 2 +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 select a from t1; a a A explain select b from t1; -table type possible_keys key key_len ref rows Extra -t1 index NULL b 4 NULL 2 Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL b 4 NULL 2 Using index select b from t1; b 1 2 alter table t1 modify a char(10) binary; explain select a from t1; -table type possible_keys key key_len ref rows Extra -t1 index NULL a 11 NULL 2 Using index +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 index NULL a 11 NULL 2 Using index select a from t1; a A diff --git a/mysql-test/r/binary.result b/mysql-test/r/binary.result index d4576791aed..9c3174ec606 100644 --- a/mysql-test/r/binary.result +++ b/mysql-test/r/binary.result @@ -59,10 +59,8 @@ concat("-",a,"-",b,"-") -hello-hello- select concat("-",a,"-",b,"-") from t1 where b="hello "; concat("-",a,"-",b,"-") --hello-hello- select concat("-",a,"-",b,"-") from t1 ignore index (b) where b="hello "; concat("-",a,"-",b,"-") --hello-hello- alter table t1 modify b tinytext not null, drop key b, add key (b(100)); select concat("-",a,"-",b,"-") from t1 where b="hello "; concat("-",a,"-",b,"-") diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index 940c9e9a50b..e6a010a7542 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -11,7 +11,7 @@ create table t1 (b char(0) not null); create table if not exists t1 (b char(0) not null); insert into t1 values (""),(null); Warnings: -Warning 1262 Data truncated, NULL supplied to NOT NULL column 'b' at row 2 +Warning 1263 Data truncated, NULL supplied to NOT NULL column 'b' at row 2 select * from t1; b diff --git a/mysql-test/r/ctype_mb.result b/mysql-test/r/ctype_mb.result index edccb047c85..5e273b3c800 100644 --- a/mysql-test/r/ctype_mb.result +++ b/mysql-test/r/ctype_mb.result @@ -17,9 +17,9 @@ t1 CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 INSERT INTO t1 VALUES ('aaaabbbbccccdddd','aaaabbbbccccdddd','aaaabbbbccccdddd'); Warnings: -Warning 1264 Data truncated for column 'c1' at row 1 -Warning 1264 Data truncated for column 'c2' at row 1 -Warning 1264 Data truncated for column 'c3' at row 1 +Warning 1265 Data truncated for column 'c1' at row 1 +Warning 1265 Data truncated for column 'c2' at row 1 +Warning 1265 Data truncated for column 'c3' at row 1 SELECT * FROM t1; c1 c2 c3 aaaa aaaa aaaa diff --git a/mysql-test/r/ctype_tis620.result b/mysql-test/r/ctype_tis620.result index 811609d4ba9..77799717d44 100644 --- a/mysql-test/r/ctype_tis620.result +++ b/mysql-test/r/ctype_tis620.result @@ -1,9 +1,129 @@ drop table if exists t1; +SET @pl0= _tis620 0x000102030405060708090A0B0C0D0E0F; +SET @pl1= _tis620 0x101112131415161718191A1B1C1D1E1F; +SET @pl2= _tis620 0x202122232425262728292A2B2C2D2E2F; +SET @pl3= _tis620 0x303132333435363738393A3B3C3D3E3F; +SET @pl4= _tis620 0x404142434445464748494A4B4C4D4E4F; +SET @pl5= _tis620 0x505152535455565758595A5B5C5D5E5F; +SET @pl6= _tis620 0x606162636465666768696A6B6C6D6E6F; +SET @pl7= _tis620 0x707172737475767778797A7B7C7D7E7F; +SET @pl8= _tis620 0x808182838485868788898A8B8C8D8E8F; +SET @pl9= _tis620 0x909192939495969798999A9B9C9D9E9F; +SET @plA= _tis620 0xA0A1A2A3A4A5A6A7A8A9AAABACADAEAF; +SET @plB= _tis620 0xB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBF; +SET @plC= _tis620 0xC0C1C2C3C4C5C6C7C8C9CACBCCCDCECF; +SET @plD= _tis620 0xD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF; +SET @plE= _tis620 0xE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF; +SET @plF= _tis620 0xF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF; +SELECT hex(@u0:=convert(@pl0 using utf8)); +hex(@u0:=convert(@pl0 using utf8)) +000102030405060708090A0B0C0D0E0F +SELECT hex(@u1:=convert(@pl1 using utf8)); +hex(@u1:=convert(@pl1 using utf8)) +101112131415161718191A1B1C1D1E1F +SELECT hex(@u2:=convert(@pl2 using utf8)); +hex(@u2:=convert(@pl2 using utf8)) +202122232425262728292A2B2C2D2E2F +SELECT hex(@u3:=convert(@pl3 using utf8)); +hex(@u3:=convert(@pl3 using utf8)) +303132333435363738393A3B3C3D3E3F +SELECT hex(@u4:=convert(@pl4 using utf8)); +hex(@u4:=convert(@pl4 using utf8)) +404142434445464748494A4B4C4D4E4F +SELECT hex(@u5:=convert(@pl5 using utf8)); +hex(@u5:=convert(@pl5 using utf8)) +505152535455565758595A5B5C5D5E5F +SELECT hex(@u6:=convert(@pl6 using utf8)); +hex(@u6:=convert(@pl6 using utf8)) +606162636465666768696A6B6C6D6E6F +SELECT hex(@u7:=convert(@pl7 using utf8)); +hex(@u7:=convert(@pl7 using utf8)) +707172737475767778797A7B7C7D7E7F +SELECT hex(@u8:=convert(@pl8 using utf8)); +hex(@u8:=convert(@pl8 using utf8)) +C280C281C282C283C284C285C286C287C288C289C28AC28BC28CC28DC28EC28F +SELECT hex(@u9:=convert(@pl9 using utf8)); +hex(@u9:=convert(@pl9 using utf8)) +C290C291C292C293C294C295C296C297C298C299C29AC29BC29CC29DC29EC29F +SELECT hex(@uA:=convert(@plA using utf8)); +hex(@uA:=convert(@plA using utf8)) +EFBFBDE0B881E0B882E0B883E0B884E0B885E0B886E0B887E0B888E0B889E0B88AE0B88BE0B88CE0B88DE0B88EE0B88F +SELECT hex(@uB:=convert(@plB using utf8)); +hex(@uB:=convert(@plB using utf8)) +E0B890E0B891E0B892E0B893E0B894E0B895E0B896E0B897E0B898E0B899E0B89AE0B89BE0B89CE0B89DE0B89EE0B89F +SELECT hex(@uC:=convert(@plC using utf8)); +hex(@uC:=convert(@plC using utf8)) +E0B8A0E0B8A1E0B8A2E0B8A3E0B8A4E0B8A5E0B8A6E0B8A7E0B8A8E0B8A9E0B8AAE0B8ABE0B8ACE0B8ADE0B8AEE0B8AF +SELECT hex(@uD:=convert(@plD using utf8)); +hex(@uD:=convert(@plD using utf8)) +E0B8B0E0B8B1E0B8B2E0B8B3E0B8B4E0B8B5E0B8B6E0B8B7E0B8B8E0B8B9E0B8BAEFBFBDEFBFBDEFBFBDEFBFBDE0B8BF +SELECT hex(@uE:=convert(@plE using utf8)); +hex(@uE:=convert(@plE using utf8)) +E0B980E0B981E0B982E0B983E0B984E0B985E0B986E0B987E0B988E0B989E0B98AE0B98BE0B98CE0B98DE0B98EE0B98F +SELECT hex(@uF:=convert(@plF using utf8)); +hex(@uF:=convert(@plF using utf8)) +E0B990E0B991E0B992E0B993E0B994E0B995E0B996E0B997E0B998E0B999E0B99AE0B99BEFBFBDEFBFBDEFBFBDEFBFBD +SELECT hex(convert(@u0 USING tis620)); +hex(convert(@u0 USING tis620)) +000102030405060708090A0B0C0D0E0F +SELECT hex(convert(@u1 USING tis620)); +hex(convert(@u1 USING tis620)) +101112131415161718191A1B1C1D1E1F +SELECT hex(convert(@u2 USING tis620)); +hex(convert(@u2 USING tis620)) +202122232425262728292A2B2C2D2E2F +SELECT hex(convert(@u3 USING tis620)); +hex(convert(@u3 USING tis620)) +303132333435363738393A3B3C3D3E3F +SELECT hex(convert(@u4 USING tis620)); +hex(convert(@u4 USING tis620)) +404142434445464748494A4B4C4D4E4F +SELECT hex(convert(@u5 USING tis620)); +hex(convert(@u5 USING tis620)) +505152535455565758595A5B5C5D5E5F +SELECT hex(convert(@u6 USING tis620)); +hex(convert(@u6 USING tis620)) +606162636465666768696A6B6C6D6E6F +SELECT hex(convert(@u7 USING tis620)); +hex(convert(@u7 USING tis620)) +707172737475767778797A7B7C7D7E7F +SELECT hex(convert(@u8 USING tis620)); +hex(convert(@u8 USING tis620)) +808182838485868788898A8B8C8D8E8F +SELECT hex(convert(@u9 USING tis620)); +hex(convert(@u9 USING tis620)) +909192939495969798999A9B9C9D9E9F +SELECT hex(convert(@uA USING tis620)); +hex(convert(@uA USING tis620)) +FFA1A2A3A4A5A6A7A8A9AAABACADAEAF +SELECT hex(convert(@uB USING tis620)); +hex(convert(@uB USING tis620)) +B0B1B2B3B4B5B6B7B8B9BABBBCBDBEBF +SELECT hex(convert(@uC USING tis620)); +hex(convert(@uC USING tis620)) +C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF +SELECT hex(convert(@uD USING tis620)); +hex(convert(@uD USING tis620)) +D0D1D2D3D4D5D6D7D8D9DAFFFFFFFFDF +SELECT hex(convert(@uE USING tis620)); +hex(convert(@uE USING tis620)) +E0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF +SELECT hex(convert(@uF USING tis620)); +hex(convert(@uF USING tis620)) +F0F1F2F3F4F5F6F7F8F9FAFBFFFFFFFF +SET NAMES tis620; CREATE TABLE t1 ( recid int(11) NOT NULL auto_increment, dyninfo text, PRIMARY KEY (recid) ) ENGINE=MyISAM; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `recid` int(11) NOT NULL auto_increment, + `dyninfo` text, + PRIMARY KEY (`recid`) +) ENGINE=MyISAM DEFAULT CHARSET=tis620 INSERT INTO t1 VALUES (1,'color=\"STB,NPG\"\r\nengine=\"J30A13\"\r\nframe=\"MRHCG1640YP4\"\r\ngrade=\"V6\"\r\nmodel=\"ACCORD\"\r\nmodelcode=\"CG164YEN\"\r\ntype=\"VT6\"\r\n'); INSERT INTO t1 VALUES (2,'color=\"HTM,NPG,DEG,RGS\"\r\nengine=\"F23A5YP1\"\r\nframe=\"MRHCF8640YP3\"\r\ngrade=\"EXi AT\"\r\nmodel=\"ACCORD\"\r\nmodelcode=\"CF864YE\"\r\ntype=\"EXA\"\r\n'); SELECT DISTINCT diff --git a/mysql-test/r/ctype_tis620.result-old b/mysql-test/r/ctype_tis620.result-old deleted file mode 100644 index 10164cd07ef..00000000000 --- a/mysql-test/r/ctype_tis620.result-old +++ /dev/null @@ -1,113 +0,0 @@ -drop table if exists t1; -SET @pl0= _tis620 0x000102030405060708090A0B0C0D0E0F; -SET @pl1= _tis620 0x101112131415161718191A1B1C1D1E1F; -SET @pl2= _tis620 0x202122232425262728292A2B2C2D2E2F; -SET @pl3= _tis620 0x303132333435363738393A3B3C3D3E3F; -SET @pl4= _tis620 0x404142434445464748494A4B4C4D4E4F; -SET @pl5= _tis620 0x505152535455565758595A5B5C5D5E5F; -SET @pl6= _tis620 0x606162636465666768696A6B6C6D6E6F; -SET @pl7= _tis620 0x707172737475767778797A7B7C7D7E7F; -SET @pl8= _tis620 0x808182838485868788898A8B8C8D8E8F; -SET @pl9= _tis620 0x909192939495969798999A9B9C9D9E9F; -SET @plA= _tis620 0xA0A1A2A3A4A5A6A7A8A9AAABACADAEAF; -SET @plB= _tis620 0xB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBF; -SET @plC= _tis620 0xC0C1C2C3C4C5C6C7C8C9CACBCCCDCECF; -SET @plD= _tis620 0xD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF; -SET @plE= _tis620 0xE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF; -SET @plF= _tis620 0xF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF; -SELECT hex(@u0:=convert(@pl0 using utf8)); -hex(@u0:=convert(@pl0 using utf8)) -000102030405060708090A0B0C0D0E0F -SELECT hex(@u1:=convert(@pl1 using utf8)); -hex(@u1:=convert(@pl1 using utf8)) -101112131415161718191A1B1C1D1E1F -SELECT hex(@u2:=convert(@pl2 using utf8)); -hex(@u2:=convert(@pl2 using utf8)) -202122232425262728292A2B2C2D2E2F -SELECT hex(@u3:=convert(@pl3 using utf8)); -hex(@u3:=convert(@pl3 using utf8)) -303132333435363738393A3B3C3D3E3F -SELECT hex(@u4:=convert(@pl4 using utf8)); -hex(@u4:=convert(@pl4 using utf8)) -404142434445464748494A4B4C4D4E4F -SELECT hex(@u5:=convert(@pl5 using utf8)); -hex(@u5:=convert(@pl5 using utf8)) -505152535455565758595A5B5C5D5E5F -SELECT hex(@u6:=convert(@pl6 using utf8)); -hex(@u6:=convert(@pl6 using utf8)) -606162636465666768696A6B6C6D6E6F -SELECT hex(@u7:=convert(@pl7 using utf8)); -hex(@u7:=convert(@pl7 using utf8)) -707172737475767778797A7B7C7D7E7F -SELECT hex(@u8:=convert(@pl8 using utf8)); -hex(@u8:=convert(@pl8 using utf8)) -C280C281C282C283C284C285C286C287C288C289C28AC28BC28CC28DC28EC28F -SELECT hex(@u9:=convert(@pl9 using utf8)); -hex(@u9:=convert(@pl9 using utf8)) -C290C291C292C293C294C295C296C297C298C299C29AC29BC29CC29DC29EC29F -SELECT hex(@uA:=convert(@plA using utf8)); -hex(@uA:=convert(@plA using utf8)) -EFBFBDE0B881E0B882E0B883E0B884E0B885E0B886E0B887E0B888E0B889E0B88AE0B88BE0B88CE0B88DE0B88EE0B88F -SELECT hex(@uB:=convert(@plB using utf8)); -hex(@uB:=convert(@plB using utf8)) -E0B890E0B891E0B892E0B893E0B894E0B895E0B896E0B897E0B898E0B899E0B89AE0B89BE0B89CE0B89DE0B89EE0B89F -SELECT hex(@uC:=convert(@plC using utf8)); -hex(@uC:=convert(@plC using utf8)) -E0B8A0E0B8A1E0B8A2E0B8A3E0B8A4E0B8A5E0B8A6E0B8A7E0B8A8E0B8A9E0B8AAE0B8ABE0B8ACE0B8ADE0B8AEE0B8AF -SELECT hex(@uD:=convert(@plD using utf8)); -hex(@uD:=convert(@plD using utf8)) -E0B8B0E0B8B1E0B8B2E0B8B3E0B8B4E0B8B5E0B8B6E0B8B7E0B8B8E0B8B9E0B8BAEFBFBDEFBFBDEFBFBDEFBFBDE0B8BF -SELECT hex(@uE:=convert(@plE using utf8)); -hex(@uE:=convert(@plE using utf8)) -E0B980E0B981E0B982E0B983E0B984E0B985E0B986E0B987E0B988E0B989E0B98AE0B98BE0B98CE0B98DE0B98EE0B98F -SELECT hex(@uF:=convert(@plF using utf8)); -hex(@uF:=convert(@plF using utf8)) -E0B990E0B991E0B992E0B993E0B994E0B995E0B996E0B997E0B998E0B999E0B99AE0B99BEFBFBDEFBFBDEFBFBDEFBFBD -SELECT hex(convert(@u0 USING tis620)); -hex(convert(@u0 USING tis620)) -000102030405060708090A0B0C0D0E0F -SELECT hex(convert(@u1 USING tis620)); -hex(convert(@u1 USING tis620)) -101112131415161718191A1B1C1D1E1F -SELECT hex(convert(@u2 USING tis620)); -hex(convert(@u2 USING tis620)) -202122232425262728292A2B2C2D2E2F -SELECT hex(convert(@u3 USING tis620)); -hex(convert(@u3 USING tis620)) -303132333435363738393A3B3C3D3E3F -SELECT hex(convert(@u4 USING tis620)); -hex(convert(@u4 USING tis620)) -404142434445464748494A4B4C4D4E4F -SELECT hex(convert(@u5 USING tis620)); -hex(convert(@u5 USING tis620)) -505152535455565758595A5B5C5D5E5F -SELECT hex(convert(@u6 USING tis620)); -hex(convert(@u6 USING tis620)) -606162636465666768696A6B6C6D6E6F -SELECT hex(convert(@u7 USING tis620)); -hex(convert(@u7 USING tis620)) -707172737475767778797A7B7C7D7E7F -SELECT hex(convert(@u8 USING tis620)); -hex(convert(@u8 USING tis620)) -808182838485868788898A8B8C8D8E8F -SELECT hex(convert(@u9 USING tis620)); -hex(convert(@u9 USING tis620)) -909192939495969798999A9B9C9D9E9F -SELECT hex(convert(@uA USING tis620)); -hex(convert(@uA USING tis620)) -FFA1A2A3A4A5A6A7A8A9AAABACADAEAF -SELECT hex(convert(@uB USING tis620)); -hex(convert(@uB USING tis620)) -B0B1B2B3B4B5B6B7B8B9BABBBCBDBEBF -SELECT hex(convert(@uC USING tis620)); -hex(convert(@uC USING tis620)) -C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF -SELECT hex(convert(@uD USING tis620)); -hex(convert(@uD USING tis620)) -D0D1D2D3D4D5D6D7D8D9DAFFFFFFFFDF -SELECT hex(convert(@uE USING tis620)); -hex(convert(@uE USING tis620)) -E0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF -SELECT hex(convert(@uF USING tis620)); -hex(convert(@uF USING tis620)) -F0F1F2F3F4F5F6F7F8F9FAFBFFFFFFFF diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index 815ab492fa4..4c699052113 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -83,7 +83,7 @@ set names koi8r; create table t1 (s1 char(1) character set utf8); insert into t1 values (_koi8r'ÁÂ'); Warnings: -Warning 1264 Data truncated for column 's1' at row 1 +Warning 1265 Data truncated for column 's1' at row 1 select s1,hex(s1),char_length(s1),octet_length(s1) from t1; s1 hex(s1) char_length(s1) octet_length(s1) Á D0B0 1 2 diff --git a/mysql-test/r/delete.result b/mysql-test/r/delete.result index 10f2c069429..f1acc5d2dfa 100644 --- a/mysql-test/r/delete.result +++ b/mysql-test/r/delete.result @@ -93,8 +93,8 @@ a b 2 12 delete ignore t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a); Warnings: -Error 1241 Subquery returns more than 1 row -Error 1241 Subquery returns more than 1 row +Error 1242 Subquery returns more than 1 row +Error 1242 Subquery returns more than 1 row select * from t11; a b 0 10 @@ -113,8 +113,8 @@ a b 2 12 delete ignore from t11 where t11.b <> (select b from t2 where t11.a < t2.a); Warnings: -Error 1241 Subquery returns more than 1 row -Error 1241 Subquery returns more than 1 row +Error 1242 Subquery returns more than 1 row +Error 1242 Subquery returns more than 1 row select * from t11; a b 0 10 diff --git a/mysql-test/r/func_compress.result b/mysql-test/r/func_compress.result index 1fcda7748b3..35c1b6ae93f 100644 --- a/mysql-test/r/func_compress.result +++ b/mysql-test/r/func_compress.result @@ -65,6 +65,6 @@ NULL 50000 NULL Warnings: -Error 1258 ZLIB: Input data was corrupted for zlib -Error 1255 Too big size of uncompressed data. The maximum size is 1048576. (probably, length of uncompressed data was corrupted) +Error 1259 ZLIB: Input data was corrupted for zlib +Error 1256 Too big size of uncompressed data. The maximum size is 1048576. (probably, length of uncompressed data was corrupted) drop table t1; diff --git a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result index af6f7956fe3..5807bae6a06 100644 --- a/mysql-test/r/func_gconcat.result +++ b/mysql-test/r/func_gconcat.result @@ -163,10 +163,10 @@ grp group_concat(c) 4 5 NULL Warnings: -Warning 1259 1 line(s) was(were) cut by group_concat() +Warning 1260 1 line(s) was(were) cut by group_concat() show warnings; Level Code Message -Warning 1259 1 line(s) was(were) cut by group_concat() +Warning 1260 1 line(s) was(were) cut by group_concat() set group_concat_max_len = 1024; select group_concat(sum(a)) from t1 group by grp; ERROR HY000: Invalid use of group function diff --git a/mysql-test/r/func_group.result b/mysql-test/r/func_group.result index 6a704f2847d..147d7776e4d 100644 --- a/mysql-test/r/func_group.result +++ b/mysql-test/r/func_group.result @@ -551,7 +551,7 @@ id select_type table type possible_keys key key_len ref rows Extra explain select min(a1) from t1 where a1 between a3 and 'KKK'; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 14 Using where +1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 14 Using where explain select min(a4) from t1 where (a4 + 0.01) between 0.07 and 0.08; id select_type table type possible_keys key key_len ref rows Extra diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index ffa7191f4e5..c9eba2f2505 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -263,3 +263,355 @@ SELECT bugdesc, REPLACE(bugdesc, 'xxxxxxxxxxxxxxxxxxxx', 'bbbbbbbbbbbbbbbbbbbb') bugdesc REPLACE(bugdesc, 'xxxxxxxxxxxxxxxxxxxx', 'bbbbbbbbbbbbbbbbbbbb') aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa drop table t1; +CREATE TABLE t1 (id int(11) NOT NULL auto_increment, tmp text NOT NULL, KEY id (id)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1, 'a545f661efdd1fb66fdee3aab79945bf'); +SELECT 1 FROM t1 WHERE tmp=AES_DECRYPT(tmp,"password"); +1 +DROP TABLE t1; +CREATE TABLE t1 ( +wid int(10) unsigned NOT NULL auto_increment, +data_podp date default NULL, +status_wnio enum('nowy','podp','real','arch') NOT NULL default 'nowy', +PRIMARY KEY(wid), +); +INSERT INTO t1 VALUES (8,NULL,'real'); +INSERT INTO t1 VALUES (9,NULL,'nowy'); +SELECT elt(status_wnio,data_podp) FROM t1 GROUP BY wid; +elt(status_wnio,data_podp) +NULL +NULL +DROP TABLE t1; +CREATE TABLE t1 (title text) ENGINE=MyISAM; +INSERT INTO t1 VALUES ('Congress reconvenes in September to debate welfare and adult education'); +INSERT INTO t1 VALUES ('House passes the CAREERS bill'); +SELECT CONCAT("",RPAD("",(55 - LENGTH(title)),".")) from t1; +CONCAT("",RPAD("",(55 - LENGTH(title)),".")) +NULL +.......................... +DROP TABLE t1; +CREATE TABLE t1 (i int, j int); +INSERT INTO t1 VALUES (1,1),(2,2); +SELECT DISTINCT i, ELT(j, '345', '34') FROM t1; +i ELT(j, '345', '34') +1 345 +2 34 +DROP TABLE t1; +select 1=_latin1'1'; +1=_latin1'1' +1 +select _latin1'1'=1; +_latin1'1'=1 +1 +select _latin2'1'=1; +_latin2'1'=1 +1 +select 1=_latin2'1'; +1=_latin2'1' +1 +select _latin1'1'=_latin2'1'; +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation '=' +select row('a','b','c') = row('a','b','c'); +row('a','b','c') = row('a','b','c') +1 +select row('A','b','c') = row('a','b','c'); +row('A','b','c') = row('a','b','c') +1 +select row('A' COLLATE latin1_bin,'b','c') = row('a','b','c'); +row('A' COLLATE latin1_bin,'b','c') = row('a','b','c') +0 +select row('A','b','c') = row('a' COLLATE latin1_bin,'b','c'); +row('A','b','c') = row('a' COLLATE latin1_bin,'b','c') +0 +select row('A' COLLATE latin1_general_ci,'b','c') = row('a' COLLATE latin1_bin,'b','c'); +ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation '=' +select concat(_latin1'a',_latin2'a'); +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'concat' +select concat(_latin1'a',_latin2'a',_latin5'a'); +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE), (latin5_turkish_ci,COERCIBLE) for operation 'concat' +select concat(_latin1'a',_latin2'a',_latin5'a',_latin7'a'); +ERROR HY000: Illegal mix of collations for operation 'concat' +select FIELD('b','A','B'); +FIELD('b','A','B') +2 +select FIELD('B','A','B'); +FIELD('B','A','B') +2 +select FIELD('b' COLLATE latin1_bin,'A','B'); +FIELD('b' COLLATE latin1_bin,'A','B') +0 +select FIELD('b','A' COLLATE latin1_bin,'B'); +FIELD('b','A' COLLATE latin1_bin,'B') +0 +select FIELD(_latin2'b','A','B'); +ERROR HY000: Illegal mix of collations (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation 'field' +select FIELD('b',_latin2'A','B'); +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation 'field' +select FIELD('b',_latin2'A','B',1); +FIELD('b',_latin2'A','B',1) +1 +select POSITION(_latin1'B' IN _latin1'abcd'); +POSITION(_latin1'B' IN _latin1'abcd') +2 +select POSITION(_latin1'B' IN _latin1'abcd' COLLATE latin1_bin); +POSITION(_latin1'B' IN _latin1'abcd' COLLATE latin1_bin) +0 +select POSITION(_latin1'B' COLLATE latin1_bin IN _latin1'abcd'); +POSITION(_latin1'B' COLLATE latin1_bin IN _latin1'abcd') +0 +select POSITION(_latin1'B' COLLATE latin1_general_ci IN _latin1'abcd' COLLATE latin1_bin); +ERROR HY000: Illegal mix of collations (latin1_bin,EXPLICIT) and (latin1_general_ci,EXPLICIT) for operation 'locate' +select POSITION(_latin1'B' IN _latin2'abcd'); +ERROR HY000: Illegal mix of collations (latin2_general_ci,COERCIBLE) and (latin1_swedish_ci,COERCIBLE) for operation 'locate' +select FIND_IN_SET(_latin1'B',_latin1'a,b,c,d'); +FIND_IN_SET(_latin1'B',_latin1'a,b,c,d') +2 +select FIND_IN_SET(_latin1'B' COLLATE latin1_general_ci,_latin1'a,b,c,d' COLLATE latin1_bin); +ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation 'find_in_set' +select FIND_IN_SET(_latin1'B',_latin2'a,b,c,d'); +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'find_in_set' +select SUBSTRING_INDEX(_latin1'abcdabcdabcd',_latin1'd',2); +SUBSTRING_INDEX(_latin1'abcdabcdabcd',_latin1'd',2) +abcdabc +select SUBSTRING_INDEX(_latin1'abcdabcdabcd',_latin2'd',2); +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'substr_index' +select SUBSTRING_INDEX(_latin1'abcdabcdabcd' COLLATE latin1_general_ci,_latin1'd' COLLATE latin1_bin,2); +ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation 'substr_index' +select _latin1'B' between _latin1'a' and _latin1'c'; +_latin1'B' between _latin1'a' and _latin1'c' +1 +select _latin1'B' collate latin1_bin between _latin1'a' and _latin1'c'; +_latin1'B' collate latin1_bin between _latin1'a' and _latin1'c' +0 +select _latin1'B' between _latin1'a' collate latin1_bin and _latin1'c'; +_latin1'B' between _latin1'a' collate latin1_bin and _latin1'c' +0 +select _latin1'B' between _latin1'a' and _latin1'c' collate latin1_bin; +_latin1'B' between _latin1'a' and _latin1'c' collate latin1_bin +0 +select _latin2'B' between _latin1'a' and _latin1'b'; +ERROR HY000: Illegal mix of collations (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation 'between' +select _latin1'B' between _latin2'a' and _latin1'b'; +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation 'between' +select _latin1'B' between _latin1'a' and _latin2'b'; +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE) for operation 'between' +select _latin1'B' collate latin1_general_ci between _latin1'a' collate latin1_bin and _latin1'b'; +ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT), (latin1_bin,EXPLICIT), (latin1_swedish_ci,COERCIBLE) for operation 'between' +select _latin1'B' in (_latin1'a',_latin1'b'); +_latin1'B' in (_latin1'a',_latin1'b') +1 +select _latin1'B' collate latin1_bin in (_latin1'a',_latin1'b'); +_latin1'B' collate latin1_bin in (_latin1'a',_latin1'b') +0 +select _latin1'B' in (_latin1'a' collate latin1_bin,_latin1'b'); +_latin1'B' in (_latin1'a' collate latin1_bin,_latin1'b') +0 +select _latin1'B' in (_latin1'a',_latin1'b' collate latin1_bin); +_latin1'B' in (_latin1'a',_latin1'b' collate latin1_bin) +0 +select _latin2'B' in (_latin1'a',_latin1'b'); +ERROR HY000: Illegal mix of collations (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation ' IN ' +select _latin1'B' in (_latin2'a',_latin1'b'); +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation ' IN ' +select _latin1'B' in (_latin1'a',_latin2'b'); +ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE) for operation ' IN ' +select _latin1'B' COLLATE latin1_general_ci in (_latin1'a' COLLATE latin1_bin,_latin1'b'); +ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT), (latin1_bin,EXPLICIT), (latin1_swedish_ci,COERCIBLE) for operation ' IN ' +select _latin1'B' COLLATE latin1_general_ci in (_latin1'a',_latin1'b' COLLATE latin1_bin); +ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT), (latin1_swedish_ci,COERCIBLE), (latin1_bin,EXPLICIT) for operation ' IN ' +select collation(bin(130)), coercibility(bin(130)); +collation(bin(130)) coercibility(bin(130)) +latin1_swedish_ci 3 +select collation(oct(130)), coercibility(oct(130)); +collation(oct(130)) coercibility(oct(130)) +latin1_swedish_ci 3 +select collation(conv(130,16,10)), coercibility(conv(130,16,10)); +collation(conv(130,16,10)) coercibility(conv(130,16,10)) +latin1_swedish_ci 3 +select collation(hex(130)), coercibility(hex(130)); +collation(hex(130)) coercibility(hex(130)) +latin1_swedish_ci 3 +select collation(char(130)), coercibility(hex(130)); +collation(char(130)) coercibility(hex(130)) +binary 3 +select collation(format(130,10)), coercibility(format(130,10)); +collation(format(130,10)) coercibility(format(130,10)) +latin1_swedish_ci 3 +select collation(lcase(_latin2'a')), coercibility(lcase(_latin2'a')); +collation(lcase(_latin2'a')) coercibility(lcase(_latin2'a')) +latin2_general_ci 3 +select collation(ucase(_latin2'a')), coercibility(ucase(_latin2'a')); +collation(ucase(_latin2'a')) coercibility(ucase(_latin2'a')) +latin2_general_ci 3 +select collation(left(_latin2'a',1)), coercibility(left(_latin2'a',1)); +collation(left(_latin2'a',1)) coercibility(left(_latin2'a',1)) +latin2_general_ci 3 +select collation(right(_latin2'a',1)), coercibility(right(_latin2'a',1)); +collation(right(_latin2'a',1)) coercibility(right(_latin2'a',1)) +latin2_general_ci 3 +select collation(substring(_latin2'a',1,1)), coercibility(substring(_latin2'a',1,1)); +collation(substring(_latin2'a',1,1)) coercibility(substring(_latin2'a',1,1)) +latin2_general_ci 3 +select collation(concat(_latin2'a',_latin2'b')), coercibility(concat(_latin2'a',_latin2'b')); +collation(concat(_latin2'a',_latin2'b')) coercibility(concat(_latin2'a',_latin2'b')) +latin2_general_ci 3 +select collation(lpad(_latin2'a',4,_latin2'b')), coercibility(lpad(_latin2'a',4,_latin2'b')); +collation(lpad(_latin2'a',4,_latin2'b')) coercibility(lpad(_latin2'a',4,_latin2'b')) +latin2_general_ci 3 +select collation(rpad(_latin2'a',4,_latin2'b')), coercibility(rpad(_latin2'a',4,_latin2'b')); +collation(rpad(_latin2'a',4,_latin2'b')) coercibility(rpad(_latin2'a',4,_latin2'b')) +latin2_general_ci 3 +select collation(concat_ws(_latin2'a',_latin2'b')), coercibility(concat_ws(_latin2'a',_latin2'b')); +collation(concat_ws(_latin2'a',_latin2'b')) coercibility(concat_ws(_latin2'a',_latin2'b')) +latin2_general_ci 3 +select collation(make_set(255,_latin2'a',_latin2'b',_latin2'c')), coercibility(make_set(255,_latin2'a',_latin2'b',_latin2'c')); +collation(make_set(255,_latin2'a',_latin2'b',_latin2'c')) coercibility(make_set(255,_latin2'a',_latin2'b',_latin2'c')) +latin2_general_ci 3 +select collation(export_set(255,_latin2'y',_latin2'n',_latin2' ')), coercibility(export_set(255,_latin2'y',_latin2'n',_latin2' ')); +collation(export_set(255,_latin2'y',_latin2'n',_latin2' ')) coercibility(export_set(255,_latin2'y',_latin2'n',_latin2' ')) +binary 3 +select collation(trim(_latin2' a ')), coercibility(trim(_latin2' a ')); +collation(trim(_latin2' a ')) coercibility(trim(_latin2' a ')) +latin2_general_ci 3 +select collation(ltrim(_latin2' a ')), coercibility(ltrim(_latin2' a ')); +collation(ltrim(_latin2' a ')) coercibility(ltrim(_latin2' a ')) +latin2_general_ci 3 +select collation(rtrim(_latin2' a ')), coercibility(rtrim(_latin2' a ')); +collation(rtrim(_latin2' a ')) coercibility(rtrim(_latin2' a ')) +latin2_general_ci 3 +select collation(trim(LEADING _latin2' ' FROM _latin2'a')), coercibility(trim(LEADING _latin2'a' FROM _latin2'a')); +collation(trim(LEADING _latin2' ' FROM _latin2'a')) coercibility(trim(LEADING _latin2'a' FROM _latin2'a')) +latin2_general_ci 3 +select collation(trim(TRAILING _latin2' ' FROM _latin2'a')), coercibility(trim(TRAILING _latin2'a' FROM _latin2'a')); +collation(trim(TRAILING _latin2' ' FROM _latin2'a')) coercibility(trim(TRAILING _latin2'a' FROM _latin2'a')) +latin2_general_ci 3 +select collation(trim(BOTH _latin2' ' FROM _latin2'a')), coercibility(trim(BOTH _latin2'a' FROM _latin2'a')); +collation(trim(BOTH _latin2' ' FROM _latin2'a')) coercibility(trim(BOTH _latin2'a' FROM _latin2'a')) +latin2_general_ci 3 +select collation(repeat(_latin2'a',10)), coercibility(repeat(_latin2'a',10)); +collation(repeat(_latin2'a',10)) coercibility(repeat(_latin2'a',10)) +latin2_general_ci 3 +select collation(reverse(_latin2'ab')), coercibility(reverse(_latin2'ab')); +collation(reverse(_latin2'ab')) coercibility(reverse(_latin2'ab')) +latin2_general_ci 3 +select collation(quote(_latin2'ab')), coercibility(quote(_latin2'ab')); +collation(quote(_latin2'ab')) coercibility(quote(_latin2'ab')) +latin2_general_ci 3 +select collation(soundex(_latin2'ab')), coercibility(soundex(_latin2'ab')); +collation(soundex(_latin2'ab')) coercibility(soundex(_latin2'ab')) +latin2_general_ci 3 +select collation(substring(_latin2'ab',1)), coercibility(substring(_latin2'ab',1)); +collation(substring(_latin2'ab',1)) coercibility(substring(_latin2'ab',1)) +latin2_general_ci 3 +select collation(insert(_latin2'abcd',2,3,_latin2'ef')), coercibility(insert(_latin2'abcd',2,3,_latin2'ef')); +collation(insert(_latin2'abcd',2,3,_latin2'ef')) coercibility(insert(_latin2'abcd',2,3,_latin2'ef')) +latin2_general_ci 3 +select collation(replace(_latin2'abcd',_latin2'b',_latin2'B')), coercibility(replace(_latin2'abcd',_latin2'b',_latin2'B')); +collation(replace(_latin2'abcd',_latin2'b',_latin2'B')) coercibility(replace(_latin2'abcd',_latin2'b',_latin2'B')) +latin2_general_ci 3 +create table t1 +select +bin(130), +oct(130), +conv(130,16,10), +hex(130), +char(130), +format(130,10), +left(_latin2'a',1), +right(_latin2'a',1), +lcase(_latin2'a'), +ucase(_latin2'a'), +substring(_latin2'a',1,1), +concat(_latin2'a',_latin2'b'), +lpad(_latin2'a',4,_latin2'b'), +rpad(_latin2'a',4,_latin2'b'), +concat_ws(_latin2'a',_latin2'b'), +make_set(255,_latin2'a',_latin2'b',_latin2'c'), +export_set(255,_latin2'y',_latin2'n',_latin2' '), +trim(_latin2' a '), +ltrim(_latin2' a '), +rtrim(_latin2' a '), +trim(LEADING _latin2' ' FROM _latin2' a '), +trim(TRAILING _latin2' ' FROM _latin2' a '), +trim(BOTH _latin2' ' FROM _latin2' a '), +repeat(_latin2'a',10), +reverse(_latin2'ab'), +quote(_latin2'ab'), +soundex(_latin2'ab'), +substring(_latin2'ab',1), +insert(_latin2'abcd',2,3,_latin2'ef'), +replace(_latin2'abcd',_latin2'b',_latin2'B') +; +Warnings: +Warning 1265 Data truncated for column 'format(130,10)' at row 1 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `bin(130)` char(64) NOT NULL default '', + `oct(130)` char(64) NOT NULL default '', + `conv(130,16,10)` char(64) NOT NULL default '', + `hex(130)` char(6) NOT NULL default '', + `char(130)` char(1) NOT NULL default '', + `format(130,10)` char(4) NOT NULL default '', + `left(_latin2'a',1)` char(1) character set latin2 NOT NULL default '', + `right(_latin2'a',1)` char(1) character set latin2 NOT NULL default '', + `lcase(_latin2'a')` char(1) character set latin2 NOT NULL default '', + `ucase(_latin2'a')` char(1) character set latin2 NOT NULL default '', + `substring(_latin2'a',1,1)` char(1) character set latin2 NOT NULL default '', + `concat(_latin2'a',_latin2'b')` char(2) character set latin2 NOT NULL default '', + `lpad(_latin2'a',4,_latin2'b')` char(4) character set latin2 NOT NULL default '', + `rpad(_latin2'a',4,_latin2'b')` char(4) character set latin2 NOT NULL default '', + `concat_ws(_latin2'a',_latin2'b')` char(1) character set latin2 NOT NULL default '', + `make_set(255,_latin2'a',_latin2'b',_latin2'c')` char(5) character set latin2 NOT NULL default '', + `export_set(255,_latin2'y',_latin2'n',_latin2' ')` char(127) character set latin2 NOT NULL default '', + `trim(_latin2' a ')` char(3) character set latin2 NOT NULL default '', + `ltrim(_latin2' a ')` char(3) character set latin2 NOT NULL default '', + `rtrim(_latin2' a ')` char(3) character set latin2 NOT NULL default '', + `trim(LEADING _latin2' ' FROM _latin2' a ')` char(3) character set latin2 NOT NULL default '', + `trim(TRAILING _latin2' ' FROM _latin2' a ')` char(3) character set latin2 NOT NULL default '', + `trim(BOTH _latin2' ' FROM _latin2' a ')` char(3) character set latin2 NOT NULL default '', + `repeat(_latin2'a',10)` char(10) character set latin2 NOT NULL default '', + `reverse(_latin2'ab')` char(2) character set latin2 NOT NULL default '', + `quote(_latin2'ab')` char(6) character set latin2 NOT NULL default '', + `soundex(_latin2'ab')` char(4) character set latin2 NOT NULL default '', + `substring(_latin2'ab',1)` char(2) character set latin2 NOT NULL default '', + `insert(_latin2'abcd',2,3,_latin2'ef')` char(6) character set latin2 NOT NULL default '', + `replace(_latin2'abcd',_latin2'b',_latin2'B')` char(4) character set latin2 NOT NULL default '' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +select SUBSTR('abcdefg',3,2); +SUBSTR('abcdefg',3,2) +cd +select SUBSTRING('abcdefg',3,2); +SUBSTRING('abcdefg',3,2) +cd +select SUBSTR('abcdefg',-3,2) FROM DUAL; +SUBSTR('abcdefg',-3,2) +ef +select SUBSTR('abcdefg',-1,5) FROM DUAL; +SUBSTR('abcdefg',-1,5) +g +select SUBSTR('abcdefg',0,0) FROM DUAL; +SUBSTR('abcdefg',0,0) + +select SUBSTR('abcdefg',-1,-1) FROM DUAL; +SUBSTR('abcdefg',-1,-1) + +select SUBSTR('abcdefg',1,-1) FROM DUAL; +SUBSTR('abcdefg',1,-1) + +create table t7 (s1 char); +select * from t7 +where concat(s1 collate latin1_general_ci,s1 collate latin1_swedish_ci) = 'AA'; +ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT) and (latin1_swedish_ci,EXPLICIT) for operation 'concat' +drop table t7; +select substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2),substring_index("1abcd;2abcd;3abcd;4abcd", ';', -2); +substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2) substring_index("1abcd;2abcd;3abcd;4abcd", ';', -2) +1abcd;2abcd 3abcd;4abcd +explain extended select md5('hello'), sha('abc'), sha1('abc'), soundex(''), 'mood' sounds like 'mud', aes_decrypt(aes_encrypt('abc','1'),'1'),concat('*',space(5),'*'), reverse('abc'), rpad('a',4,'1'), lpad('a',4,'1'), concat_ws(',','',NULL,'a'),make_set(255,_latin2'a',_latin2'b',_latin2'c'),elt(2,1),locate("a","b",2),format(130,10),char(0),conv(130,16,10),hex(130),binary 'HE', export_set(255,_latin2'y',_latin2'n',_latin2' '),FIELD('b' COLLATE latin1_bin,'A','B'),FIND_IN_SET(_latin1'B',_latin1'a,b,c,d'),collation(conv(130,16,10)), coercibility(conv(130,16,10)),length('\n\t\r\b\0\_\%\\'),bit_length('\n\t\r\b\0\_\%\\'),bit_length('\n\t\r\b\0\_\%\\'),concat('monty',' was here ','again'),length('hello'),char(ascii('h')),ord('h'),quote(1/0),crc32("123"),replace('aaaa','a','b'),insert('txs',2,1,'hi'),left(_latin2'a',1),right(_latin2'a',1),lcase(_latin2'a'),ucase(_latin2'a'),SUBSTR('abcdefg',3,2),substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2),trim(_latin2' a '),ltrim(_latin2' a '),rtrim(_latin2' a '), decode(encode(repeat("a",100000),"monty"),"monty"); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 select high_priority md5(_latin1'hello') AS `md5('hello')`,sha(_latin1'abc') AS `sha('abc')`,sha(_latin1'abc') AS `sha1('abc')`,soundex(_latin1'') AS `soundex('')`,(soundex(_latin1'mood') = soundex(_latin1'mud')) AS `'mood' sounds like 'mud'`,aes_decrypt(aes_encrypt(_latin1'abc',_latin1'1'),_latin1'1') AS `aes_decrypt(aes_encrypt('abc','1'),'1')`,concat(_latin1'*',repeat(_latin1' ',5),_latin1'*') AS `concat('*',space(5),'*')`,reverse(_latin1'abc') AS `reverse('abc')`,rpad(_latin1'a',4,_latin1'1') AS `rpad('a',4,'1')`,lpad(_latin1'a',4,_latin1'1') AS `lpad('a',4,'1')`,concat_ws(_latin1',',_latin1'',NULL,_latin1'a') AS `concat_ws(',','',NULL,'a')`,make_set(255,_latin2'a',_latin2'b',_latin2'c') AS `make_set(255,_latin2'a',_latin2'b',_latin2'c')`,elt(2,1) AS `elt(2,1)`,locate(_latin1'a',_latin1'b',2) AS `locate("a","b",2)`,format(130,10) AS `format(130,10)`,char(0) AS `char(0)`,conv(130,16,10) AS `conv(130,16,10)`,hex(130) AS `hex(130)`,(_latin1'HE' collate _latin1'BINARY') AS `binary 'HE'`,export_set(255,_latin2'y',_latin2'n',_latin2' ') AS `export_set(255,_latin2'y',_latin2'n',_latin2' ')`,field((_latin1'b' collate _latin1'latin1_bin'),_latin1'A',_latin1'B') AS `FIELD('b' COLLATE latin1_bin,'A','B')`,find_in_set(_latin1'B',_latin1'a,b,c,d') AS `FIND_IN_SET(_latin1'B',_latin1'a,b,c,d')`,collation(conv(130,16,10)) AS `collation(conv(130,16,10))`,coercibility(conv(130,16,10)) AS `coercibility(conv(130,16,10))`,length(_latin1'\n \r\0\\_\\%\\') AS `length('\n\t\r\b\0\_\%\\')`,bit_length(_latin1'\n \r\0\\_\\%\\') AS `bit_length('\n\t\r\b\0\_\%\\')`,bit_length(_latin1'\n \r\0\\_\\%\\') AS `bit_length('\n\t\r\b\0\_\%\\')`,concat(_latin1'monty',_latin1' was here ',_latin1'again') AS `concat('monty',' was here ','again')`,length(_latin1'hello') AS `length('hello')`,char(ascii(_latin1'h')) AS `char(ascii('h'))`,ord(_latin1'h') AS `ord('h')`,quote((1 / 0)) AS `quote(1/0)`,crc32(_latin1'123') AS `crc32("123")`,replace(_latin1'aaaa',_latin1'a',_latin1'b') AS `replace('aaaa','a','b')`,insert(_latin1'txs',2,1,_latin1'hi') AS `insert('txs',2,1,'hi')`,left(_latin2'a',1) AS `left(_latin2'a',1)`,right(_latin2'a',1) AS `right(_latin2'a',1)`,lcase(_latin2'a') AS `lcase(_latin2'a')`,ucase(_latin2'a') AS `ucase(_latin2'a')`,substr(_latin1'abcdefg',3,2) AS `SUBSTR('abcdefg',3,2)`,substr_index(_latin1'1abcd;2abcd;3abcd;4abcd',_latin1';',2) AS `substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2)`,trim(_latin2' a ') AS `trim(_latin2' a ')`,ltrim(_latin2' a ') AS `ltrim(_latin2' a ')`,rtrim(_latin2' a ') AS `rtrim(_latin2' a ')`,decode(encode(repeat(_latin1'a',100000))) AS `decode(encode(repeat("a",100000),"monty"),"monty")` +SELECT lpad(12345, 5, "#"); +lpad(12345, 5, "#") +12345 diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result index 1c48f5f9048..95dc2ca3a2a 100644 --- a/mysql-test/r/innodb.result +++ b/mysql-test/r/innodb.result @@ -1338,7 +1338,7 @@ CREATE TABLE t2 (col1 int(1),stamp TIMESTAMP,INDEX stamp_idx insert into t1 values (1),(2),(3); insert into t2 values (1, 20020204130000),(2, 20020204130000),(4,20020204310000 ),(5,20020204230000); Warnings: -Warning 1264 Data truncated for column 'stamp' at row 3 +Warning 1265 Data truncated for column 'stamp' at row 3 SELECT col1 FROM t1 UNION SELECT col1 FROM t2 WHERE stamp < '20020204120000' GROUP BY col1; col1 diff --git a/mysql-test/r/insert.result b/mysql-test/r/insert.result index ff5111c552e..38e08d7fbc5 100644 --- a/mysql-test/r/insert.result +++ b/mysql-test/r/insert.result @@ -63,7 +63,7 @@ insert into t1 values(NULL); ERROR 23000: Column 'id' cannot be null insert into t1 values (1), (NULL), (2); Warnings: -Warning 1262 Data truncated, NULL supplied to NOT NULL column 'id' at row 2 +Warning 1263 Data truncated, NULL supplied to NOT NULL column 'id' at row 2 select * from t1; id 1 diff --git a/mysql-test/r/insert_select.result b/mysql-test/r/insert_select.result index 93007a325ba..2e90f8b2d81 100644 --- a/mysql-test/r/insert_select.result +++ b/mysql-test/r/insert_select.result @@ -621,6 +621,9 @@ NULL 1 100 NULL 2 100 create table t2(No int not null, Field int not null, Count int not null); insert into t2 Select null, Field, Count From t1 Where Month=20030901 and Type=2; +Warnings: +Warning 1263 Data truncated, NULL supplied to NOT NULL column 'No' at row 1 +Warning 1263 Data truncated, NULL supplied to NOT NULL column 'No' at row 2 select * from t2; No Field Count 0 1 100 diff --git a/mysql-test/r/key.result b/mysql-test/r/key.result index d8e10fd20c7..dca7b580378 100644 --- a/mysql-test/r/key.result +++ b/mysql-test/r/key.result @@ -34,10 +34,10 @@ INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','N','N','N','N'); INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','N','N','N','N'); INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','','','',''); Warnings: -Warning 1264 Data truncated for column 'transityes' at row 1 -Warning 1264 Data truncated for column 'shopsyes' at row 1 -Warning 1264 Data truncated for column 'schoolsyes' at row 1 -Warning 1264 Data truncated for column 'petsyes' at row 1 +Warning 1265 Data truncated for column 'transityes' at row 1 +Warning 1265 Data truncated for column 'shopsyes' at row 1 +Warning 1265 Data truncated for column 'schoolsyes' at row 1 +Warning 1265 Data truncated for column 'petsyes' at row 1 INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','Y','Y','Y','Y'); INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','Y','Y','Y','Y'); INSERT INTO t1 VALUES (900,'Vancouver','Shared/Roomate','Y','Y','Y','Y'); @@ -156,8 +156,8 @@ CREATE TABLE t1 (c CHAR(10) NOT NULL,i INT NOT NULL AUTO_INCREMENT, UNIQUE (c,i)); INSERT INTO t1 (c) VALUES (NULL),(NULL); Warnings: -Warning 1262 Data truncated, NULL supplied to NOT NULL column 'c' at row 1 -Warning 1262 Data truncated, NULL supplied to NOT NULL column 'c' at row 2 +Warning 1263 Data truncated, NULL supplied to NOT NULL column 'c' at row 1 +Warning 1263 Data truncated, NULL supplied to NOT NULL column 'c' at row 2 SELECT * FROM t1; c i 1 diff --git a/mysql-test/r/loaddata.result b/mysql-test/r/loaddata.result index 0547596dfbd..368055fed99 100644 --- a/mysql-test/r/loaddata.result +++ b/mysql-test/r/loaddata.result @@ -2,12 +2,12 @@ drop table if exists t1; create table t1 (a date, b date, c date not null, d date); load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ','; Warnings: -Warning 1264 Data truncated for column 'a' at row 1 -Warning 1264 Data truncated for column 'c' at row 1 -Warning 1264 Data truncated for column 'd' at row 1 -Warning 1264 Data truncated for column 'a' at row 2 -Warning 1264 Data truncated for column 'b' at row 2 -Warning 1264 Data truncated for column 'd' at row 2 +Warning 1265 Data truncated for column 'a' at row 1 +Warning 1265 Data truncated for column 'c' at row 1 +Warning 1265 Data truncated for column 'd' at row 1 +Warning 1265 Data truncated for column 'a' at row 2 +Warning 1265 Data truncated for column 'b' at row 2 +Warning 1265 Data truncated for column 'd' at row 2 load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',' IGNORE 2 LINES; SELECT * from t1; a b c d @@ -18,10 +18,10 @@ a b c d truncate table t1; load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',' LINES STARTING BY ',' (b,c,d); Warnings: -Warning 1264 Data truncated for column 'c' at row 1 -Warning 1264 Data truncated for column 'd' at row 1 -Warning 1264 Data truncated for column 'b' at row 2 -Warning 1264 Data truncated for column 'd' at row 2 +Warning 1265 Data truncated for column 'c' at row 1 +Warning 1265 Data truncated for column 'd' at row 1 +Warning 1265 Data truncated for column 'b' at row 2 +Warning 1265 Data truncated for column 'd' at row 2 SELECT * from t1; a b c d NULL NULL 0000-00-00 0000-00-00 @@ -31,7 +31,7 @@ drop table t1; create table t1 (a text, b text); load data infile '../../std_data/loaddata2.dat' into table t1 fields terminated by ',' enclosed by ''''; Warnings: -Warning 1260 Row 3 doesn't contain data for all columns +Warning 1261 Row 3 doesn't contain data for all columns select concat('|',a,'|'), concat('|',b,'|') from t1; concat('|',a,'|') concat('|',b,'|') |Field A| |Field B| @@ -43,10 +43,10 @@ drop table t1; create table t1 (a int, b char(10)); load data infile '../../std_data/loaddata3.dat' into table t1 fields terminated by '' enclosed by '' ignore 1 lines; Warnings: -Warning 1264 Data truncated for column 'a' at row 3 -Warning 1261 Row 3 was truncated; It contained more data than there where input columns -Warning 1264 Data truncated for column 'a' at row 5 -Warning 1261 Row 5 was truncated; It contained more data than there where input columns +Warning 1265 Data truncated for column 'a' at row 3 +Warning 1262 Row 3 was truncated; It contained more data than there where input columns +Warning 1265 Data truncated for column 'a' at row 5 +Warning 1262 Row 5 was truncated; It contained more data than there where input columns select * from t1; a b 1 row 1 @@ -57,8 +57,8 @@ a b truncate table t1; load data infile '../../std_data/loaddata4.dat' into table t1 fields terminated by '' enclosed by '' lines terminated by '' ignore 1 lines; Warnings: -Warning 1264 Data truncated for column 'a' at row 4 -Warning 1260 Row 4 doesn't contain data for all columns +Warning 1265 Data truncated for column 'a' at row 4 +Warning 1261 Row 4 doesn't contain data for all columns select * from t1; a b 1 row 1 diff --git a/mysql-test/r/lock.result b/mysql-test/r/lock.result index 2e95c25fd9c..429bc5ed352 100644 --- a/mysql-test/r/lock.result +++ b/mysql-test/r/lock.result @@ -42,7 +42,7 @@ check table t2; Table Op Msg_type Msg_text test.t2 check error Table 't2' was not locked with LOCK TABLES insert into t1 select nr from t1; -Table 't1' was not locked with LOCK TABLES +ERROR HY000: Table 't1' was not locked with LOCK TABLES unlock tables; lock tables t1 write, t1 as t1_alias read; insert into t1 select index1,nr from t1 as t1_alias; diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index 4ab9a3dc8fe..278b9f41480 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -428,6 +428,22 @@ select * from t1 where a='807780' and b='477' and c='165'; a b c 807780 477 165 drop table t1; +create table t1 (a blob); +insert into t1 values('a '),('a'); +select concat(a,'.') from t1 where a='a'; +concat(a,'.') +a. +select concat(a,'.') from t1 where a='a '; +concat(a,'.') +a . +alter table t1 add key(a(2)); +select concat(a,'.') from t1 where a='a'; +concat(a,'.') +a. +select concat(a,'.') from t1 where a='a '; +concat(a,'.') +a . +drop table t1; create table t1 (a int not null auto_increment primary key, b text not null, unique b (b(20))); insert into t1 (b) values ('a'),('a '),('a '); select concat(b,'.') from t1; @@ -437,7 +453,7 @@ a . a . update t1 set b='b ' where a=2; update t1 set b='b ' where a > 1; -Duplicate entry 'b ' for key 2 +ERROR 23000: Duplicate entry 'b ' for key 2 delete from t1 where b='b'; select a,concat(b,'.') from t1; a concat(b,'.') diff --git a/mysql-test/r/null.result b/mysql-test/r/null.result index aa56bce6453..cbd949d6e72 100644 --- a/mysql-test/r/null.result +++ b/mysql-test/r/null.result @@ -91,45 +91,45 @@ drop table t1; CREATE TABLE t1 (a varchar(16) NOT NULL, b smallint(6) NOT NULL, c datetime NOT NULL, d smallint(6) NOT NULL); INSERT INTO t1 SET a = "", d= "2003-01-14 03:54:55"; Warnings: -Warning 1264 Data truncated for column 'd' at row 1 +Warning 1265 Data truncated for column 'd' at row 1 UPDATE t1 SET d=1/NULL; Warnings: -Warning 1264 Data truncated for column 'd' at row 1 +Warning 1265 Data truncated for column 'd' at row 1 UPDATE t1 SET d=NULL; Warnings: -Warning 1262 Data truncated, NULL supplied to NOT NULL column 'd' at row 1 +Warning 1263 Data truncated, NULL supplied to NOT NULL column 'd' at row 1 INSERT INTO t1 (a) values (null); ERROR 23000: Column 'a' cannot be null INSERT INTO t1 (a) values (1/null); ERROR 23000: Column 'a' cannot be null INSERT INTO t1 (a) values (null),(null); Warnings: -Warning 1262 Data truncated, NULL supplied to NOT NULL column 'a' at row 1 -Warning 1262 Data truncated, NULL supplied to NOT NULL column 'a' at row 2 +Warning 1263 Data truncated, NULL supplied to NOT NULL column 'a' at row 1 +Warning 1263 Data truncated, NULL supplied to NOT NULL column 'a' at row 2 INSERT INTO t1 (b) values (null); ERROR 23000: Column 'b' cannot be null INSERT INTO t1 (b) values (1/null); ERROR 23000: Column 'b' cannot be null INSERT INTO t1 (b) values (null),(null); Warnings: -Warning 1262 Data truncated, NULL supplied to NOT NULL column 'b' at row 1 -Warning 1262 Data truncated, NULL supplied to NOT NULL column 'b' at row 2 +Warning 1263 Data truncated, NULL supplied to NOT NULL column 'b' at row 1 +Warning 1263 Data truncated, NULL supplied to NOT NULL column 'b' at row 2 INSERT INTO t1 (c) values (null); ERROR 23000: Column 'c' cannot be null INSERT INTO t1 (c) values (1/null); ERROR 23000: Column 'c' cannot be null INSERT INTO t1 (c) values (null),(null); Warnings: -Warning 1262 Data truncated, NULL supplied to NOT NULL column 'c' at row 1 -Warning 1262 Data truncated, NULL supplied to NOT NULL column 'c' at row 2 +Warning 1263 Data truncated, NULL supplied to NOT NULL column 'c' at row 1 +Warning 1263 Data truncated, NULL supplied to NOT NULL column 'c' at row 2 INSERT INTO t1 (d) values (null); ERROR 23000: Column 'd' cannot be null INSERT INTO t1 (d) values (1/null); ERROR 23000: Column 'd' cannot be null INSERT INTO t1 (d) values (null),(null); Warnings: -Warning 1262 Data truncated, NULL supplied to NOT NULL column 'd' at row 1 -Warning 1262 Data truncated, NULL supplied to NOT NULL column 'd' at row 2 +Warning 1263 Data truncated, NULL supplied to NOT NULL column 'd' at row 1 +Warning 1263 Data truncated, NULL supplied to NOT NULL column 'd' at row 2 select * from t1; a b c d 0 0000-00-00 00:00:00 0 diff --git a/mysql-test/r/null_key.result b/mysql-test/r/null_key.result index 385108216bf..4dfd17991cc 100644 --- a/mysql-test/r/null_key.result +++ b/mysql-test/r/null_key.result @@ -337,7 +337,7 @@ index (id2) ); insert into t1 values(null,null),(1,1); Warnings: -Warning 1262 Data truncated, NULL supplied to NOT NULL column 'id2' at row 1 +Warning 1263 Data truncated, NULL supplied to NOT NULL column 'id2' at row 1 select * from t1; id id2 NULL 0 diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result index c1053087603..4033996b239 100644 --- a/mysql-test/r/order_by.result +++ b/mysql-test/r/order_by.result @@ -333,10 +333,10 @@ a b c 1 NULL NULL alter table t1 modify b int not null, modify c varchar(10) not null; Warnings: -Warning 1264 Data truncated for column 'b' at row 1 -Warning 1264 Data truncated for column 'c' at row 1 -Warning 1264 Data truncated for column 'b' at row 2 -Warning 1264 Data truncated for column 'c' at row 3 +Warning 1265 Data truncated for column 'b' at row 1 +Warning 1265 Data truncated for column 'c' at row 1 +Warning 1265 Data truncated for column 'b' at row 2 +Warning 1265 Data truncated for column 'c' at row 3 explain select * from t1 order by a, b, c; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 index NULL a 18 NULL 11 Using index diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result index 04bcb56d48d..5bbf0bad445 100644 --- a/mysql-test/r/query_cache.result +++ b/mysql-test/r/query_cache.result @@ -593,7 +593,7 @@ select * from t1; a set GLOBAL query_cache_size=1024; Warnings: -Warning 1281 Query cache failed to set size 1024, new query cache size is 0 +Warning 1282 Query cache failed to set size 1024, new query cache size is 0 show global variables like "query_cache_size"; Variable_name Value query_cache_size 0 @@ -601,7 +601,7 @@ select * from t1; a set GLOBAL query_cache_size=10240; Warnings: -Warning 1281 Query cache failed to set size 10240, new query cache size is 0 +Warning 1282 Query cache failed to set size 10240, new query cache size is 0 show global variables like "query_cache_size"; Variable_name Value query_cache_size 0 @@ -609,7 +609,7 @@ select * from t1; a set GLOBAL query_cache_size=20480; Warnings: -Warning 1281 Query cache failed to set size 20480, new query cache size is 0 +Warning 1282 Query cache failed to set size 20480, new query cache size is 0 show global variables like "query_cache_size"; Variable_name Value query_cache_size 0 @@ -617,7 +617,7 @@ select * from t1; a set GLOBAL query_cache_size=40960; Warnings: -Warning 1281 Query cache failed to set size 40960, new query cache size is 0 +Warning 1282 Query cache failed to set size 40960, new query cache size is 0 show global variables like "query_cache_size"; Variable_name Value query_cache_size 0 diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result index 6d924ff9f2e..ab66d786833 100644 --- a/mysql-test/r/range.result +++ b/mysql-test/r/range.result @@ -302,6 +302,7 @@ WHERE a b 15 1 47 1 +DROP TABLE t1; create table t1 (id int(10) primary key); insert into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9); select id from t1 where id in (2,5,9) ; diff --git a/mysql-test/r/rpl_multi_delete.result b/mysql-test/r/rpl_multi_delete.result index fa254d76393..e94a4e7947e 100644 --- a/mysql-test/r/rpl_multi_delete.result +++ b/mysql-test/r/rpl_multi_delete.result @@ -1,9 +1,9 @@ -slave stop; +stop slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; -slave start; +start slave; create table t1 (a int); create table t2 (a int); insert into t1 values (1); diff --git a/mysql-test/r/rpl_until.result b/mysql-test/r/rpl_until.result index 82b1ed233ec..120c3d7a57f 100644 --- a/mysql-test/r/rpl_until.result +++ b/mysql-test/r/rpl_until.result @@ -69,4 +69,4 @@ ERROR HY000: Wrong parameter or combination of parameters for START SLAVE UNTIL start slave sql_thread; start slave until master_log_file='master-bin.000001', master_log_pos=561; Warnings: -Note 1253 Slave is already running +Note 1254 Slave is already running diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index b5ebc8d80db..f8a3251b6f9 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -6,7 +6,7 @@ explain extended select (select 2); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1248 Select 2 was reduced during optimisation +Note 1249 Select 2 was reduced during optimisation Note 1003 select high_priority 2 AS `(select 2)` SELECT (SELECT 1) UNION SELECT (SELECT 2); (SELECT 1) @@ -17,8 +17,8 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used 3 UNION NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1248 Select 2 was reduced during optimisation -Note 1248 Select 4 was reduced during optimisation +Note 1249 Select 2 was reduced during optimisation +Note 1249 Select 4 was reduced during optimisation Note 1003 select high_priority 1 AS `(SELECT 1)` union select 2 AS `(SELECT 2)` SELECT (SELECT (SELECT 0 UNION SELECT 0)); (SELECT (SELECT 0 UNION SELECT 0)) @@ -29,7 +29,7 @@ id select_type table type possible_keys key key_len ref rows Extra 3 SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used 4 UNION NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1248 Select 2 was reduced during optimisation +Note 1249 Select 2 was reduced during optimisation Note 1003 select high_priority (select 0 AS `0` union select 0 AS `0`) AS `(SELECT (SELECT 0 UNION SELECT 0))` SELECT (SELECT 1 FROM (SELECT 1) as b HAVING a=1) as a; ERROR 42S22: Reference 'a' not supported (forward reference in item list) @@ -46,8 +46,8 @@ id select_type table type possible_keys key key_len ref rows Extra 3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used 2 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1275 Field or reference 'a' of SELECT #3 was resolved in SELECT #1 -Note 1275 Field or reference 'b.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 'b.a' of SELECT #3 was resolved in SELECT #1 Note 1003 select high_priority 1 AS `1` from (select 1 AS `a`) b having ((select b.a AS `a`) = 1) SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1; 1 @@ -219,7 +219,7 @@ id select_type table type possible_keys key key_len ref rows Extra 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 Using where Warnings: -Note 1275 Field or reference 't4.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 't4.a' of SELECT #3 was resolved in SELECT #1 Note 1003 select high_priority test.t4.b AS `b`,(select avg((test.t2.a + (select min(test.t3.a) AS `min(t3.a)` from test.t3 where (test.t3.a >= test.t4.a)))) AS `avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a))` from test.t2) AS `(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2)` from test.t4 select * from t3 where exists (select * from t2 where t2.b=t3.a); a @@ -307,8 +307,8 @@ id select_type table type possible_keys key key_len ref rows Extra 2 DEPENDENT SUBQUERY t1 system NULL NULL NULL NULL 1 3 DEPENDENT UNION t5 ALL NULL NULL NULL NULL 2 Using where Warnings: -Note 1275 Field or reference 't2.a' of SELECT #2 was resolved in SELECT #1 -Note 1275 Field or reference 't2.a' of SELECT #3 was resolved in SELECT #1 +Note 1276 Field or reference 't2.a' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 't2.a' of SELECT #3 was resolved in SELECT #1 Note 1003 select high_priority (select test.t1.a AS `a` from test.t1 where (test.t1.a = test.t2.a) union select test.t5.a AS `a` from test.t5 where (test.t5.a = test.t2.a)) AS `(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a)`,test.t2.a AS `a` from test.t2 select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2; ERROR 21000: Subquery returns more than 1 row @@ -326,7 +326,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t6 ALL NULL NULL NULL NULL 4 Using where 2 DEPENDENT SUBQUERY t7 eq_ref PRIMARY PRIMARY 4 test.t6.clinic_uq 1 Warnings: -Note 1275 Field or reference 'clinic_uq' of SELECT #2 was resolved in SELECT #1 +Note 1276 Field or reference 'clinic_uq' of SELECT #2 was resolved in SELECT #1 Note 1003 select high_priority test.t6.patient_uq AS `patient_uq`,test.t6.clinic_uq AS `clinic_uq` from test.t6 where exists(select test.t7.uq AS `uq`,test.t7.name AS `name` from test.t7 where (test.t7.uq = test.t6.clinic_uq) limit 1) select * from t1 where a= (select a from t2,t4 where t2.b=t4.b); ERROR 23000: Column: 'a' in field list is ambiguous @@ -707,7 +707,7 @@ EXPLAIN EXTENDED SELECT * FROM t2 WHERE id IN (SELECT 1); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ref id id 5 const 1 Using where; Using index Warnings: -Note 1248 Select 2 was reduced during optimisation +Note 1249 Select 2 was reduced during optimisation Note 1003 select high_priority test.t2.id AS `id` from test.t2 where (test.t2.id = 1) SELECT * FROM t2 WHERE id IN (SELECT 1 UNION SELECT 3); id @@ -719,8 +719,8 @@ EXPLAIN EXTENDED SELECT * FROM t2 WHERE id IN (SELECT 1+(select 1)); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ref id id 5 const 1 Using where; Using index Warnings: -Note 1248 Select 3 was reduced during optimisation -Note 1248 Select 2 was reduced during optimisation +Note 1249 Select 3 was reduced during optimisation +Note 1249 Select 2 was reduced during optimisation Note 1003 select high_priority test.t2.id AS `id` from test.t2 where (test.t2.id = (1 + 1)) EXPLAIN EXTENDED SELECT * FROM t2 WHERE id IN (SELECT 1 UNION SELECT 3); id select_type table type possible_keys key key_len ref rows Extra @@ -852,8 +852,8 @@ explain extended select (select a+1) from t1; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Warnings: -Note 1275 Field or reference 'a' of SELECT #2 was resolved in SELECT #1 -Note 1248 Select 2 was reduced during optimisation +Note 1276 Field or reference 'a' of SELECT #2 was resolved in SELECT #1 +Note 1249 Select 2 was reduced during optimisation Note 1003 select high_priority (test.t1.a + 1) AS `(select a+1)` from test.t1 select (select a+1) from t1; (select a+1) @@ -1041,12 +1041,12 @@ UNIQUE KEY `maxnumrep` (`maxnumrep`) ) ENGINE=MyISAM CHARSET=latin1; INSERT INTO t1 VALUES ('joce','1','','joce'),('test','2','','test'); Warnings: -Warning 1264 Data truncated for column 'date' at row 1 -Warning 1264 Data truncated for column 'date' at row 2 +Warning 1265 Data truncated for column 'date' at row 1 +Warning 1265 Data truncated for column 'date' at row 2 INSERT INTO t2 VALUES ('joce','1','','joce'),('test','2','','test'); Warnings: -Warning 1264 Data truncated for column 'date' at row 1 -Warning 1264 Data truncated for column 'date' at row 2 +Warning 1265 Data truncated for column 'date' at row 1 +Warning 1265 Data truncated for column 'date' at row 2 INSERT INTO t3 VALUES (1,1); SELECT DISTINCT topic FROM t2 WHERE NOT EXISTS(SELECT * FROM t3 WHERE numeropost=topic); @@ -1238,7 +1238,7 @@ insert into t1 values (1,0), (2,0), (3,0); insert into t2 values (1,1), (2,1), (3,1), (2,2); update ignore t1 set b=(select b from t2 where t1.a=t2.a); Warnings: -Error 1241 Subquery returns more than 1 row +Error 1242 Subquery returns more than 1 row select * from t1; a b 1 1 diff --git a/mysql-test/r/subselect_innodb.result b/mysql-test/r/subselect_innodb.result index b2a055fa72c..9c1816e295c 100644 --- a/mysql-test/r/subselect_innodb.result +++ b/mysql-test/r/subselect_innodb.result @@ -62,7 +62,7 @@ processor_id (SELECT y.yod_id FROM t1 p2, t2 y WHERE p2.processor_id = p1.proces 1 1 2 2 3 3 -drop table t1,t2,t3; +drop table t2,t1,t3; CREATE TABLE t1 ( id int(11) NOT NULL default '0', b int(11) default NULL, diff --git a/mysql-test/r/type_blob.result b/mysql-test/r/type_blob.result index 8538263f7d6..330464fe669 100644 --- a/mysql-test/r/type_blob.result +++ b/mysql-test/r/type_blob.result @@ -9,9 +9,9 @@ d mediumtext YES NULL e longtext YES NULL CREATE TABLE t2 (a char(257), b varchar(70000) binary, c varchar(70000000)); Warnings: -Warning 1245 Converting column 'a' from CHAR to TEXT -Warning 1245 Converting column 'b' from CHAR to BLOB -Warning 1245 Converting column 'c' from CHAR to TEXT +Warning 1246 Converting column 'a' from CHAR to TEXT +Warning 1246 Converting column 'b' from CHAR to BLOB +Warning 1246 Converting column 'c' from CHAR to TEXT show columns from t2; Field Type Null Key Default Extra a text YES NULL diff --git a/mysql-test/r/type_datetime.result b/mysql-test/r/type_datetime.result index c1ee621697d..cc29c676283 100644 --- a/mysql-test/r/type_datetime.result +++ b/mysql-test/r/type_datetime.result @@ -2,11 +2,11 @@ drop table if exists t1; create table t1 (t datetime); insert into t1 values(101),(691231),(700101),(991231),(10000101),(99991231),(101000000),(691231000000),(700101000000),(991231235959),(10000101000000),(99991231235959),(20030102030460),(20030102036301),(20030102240401),(20030132030401),(20031302030460); Warnings: -Warning 1264 Data truncated for column 't' at row 13 -Warning 1264 Data truncated for column 't' at row 14 -Warning 1264 Data truncated for column 't' at row 15 -Warning 1264 Data truncated for column 't' at row 16 -Warning 1264 Data truncated for column 't' at row 17 +Warning 1265 Data truncated for column 't' at row 13 +Warning 1265 Data truncated for column 't' at row 14 +Warning 1265 Data truncated for column 't' at row 15 +Warning 1265 Data truncated for column 't' at row 16 +Warning 1265 Data truncated for column 't' at row 17 select * from t1; t 2000-01-01 00:00:00 diff --git a/mysql-test/r/type_decimal.result b/mysql-test/r/type_decimal.result index fa4cd231129..dc78369f583 100644 --- a/mysql-test/r/type_decimal.result +++ b/mysql-test/r/type_decimal.result @@ -158,17 +158,17 @@ insert into t1 values ("00000000000001"),("+0000000000001"),("-0000000000001"); insert into t1 values ("+111111111.11"),("111111111.11"),("-11111111.11"); insert into t1 values ("-111111111.11"),("+1111111111.11"),("1111111111.11"); Warnings: -Warning 1263 Data truncated, out of range for column 'a' at row 1 -Warning 1263 Data truncated, out of range for column 'a' at row 2 -Warning 1263 Data truncated, out of range for column 'a' at row 3 +Warning 1264 Data truncated, out of range for column 'a' at row 1 +Warning 1264 Data truncated, out of range for column 'a' at row 2 +Warning 1264 Data truncated, out of range for column 'a' at row 3 insert into t1 values ("1e+1000"),("1e-1000"),("-1e+1000"); Warnings: -Warning 1263 Data truncated, out of range for column 'a' at row 1 -Warning 1264 Data truncated for column 'a' at row 2 -Warning 1263 Data truncated, out of range for column 'a' at row 3 +Warning 1264 Data truncated, out of range for column 'a' at row 1 +Warning 1265 Data truncated for column 'a' at row 2 +Warning 1264 Data truncated, out of range for column 'a' at row 3 insert into t1 values ("123.4e"),("123.4e+2"),("123.4e-2"),("123e1"),("123e+0"); Warnings: -Warning 1264 Data truncated for column 'a' at row 3 +Warning 1265 Data truncated for column 'a' at row 3 select * from t1; a 0.00 @@ -201,32 +201,32 @@ drop table t1; create table t1 (a decimal(10,2) unsigned); insert into t1 values ("0.0"),("-0.0"),("+0.0"),("01.0"),("+01.0"),("-01.0"); Warnings: -Warning 1263 Data truncated, out of range for column 'a' at row 2 -Warning 1263 Data truncated, out of range for column 'a' at row 6 +Warning 1264 Data truncated, out of range for column 'a' at row 2 +Warning 1264 Data truncated, out of range for column 'a' at row 6 insert into t1 values ("-.1"),("+.1"),(".1"); Warnings: -Warning 1263 Data truncated, out of range for column 'a' at row 1 +Warning 1264 Data truncated, out of range for column 'a' at row 1 insert into t1 values ("00000000000001"),("+0000000000001"),("-0000000000001"); Warnings: -Warning 1263 Data truncated, out of range for column 'a' at row 3 +Warning 1264 Data truncated, out of range for column 'a' at row 3 insert into t1 values ("+111111111.11"),("111111111.11"),("-11111111.11"); Warnings: -Warning 1263 Data truncated, out of range for column 'a' at row 1 -Warning 1263 Data truncated, out of range for column 'a' at row 2 -Warning 1263 Data truncated, out of range for column 'a' at row 3 +Warning 1264 Data truncated, out of range for column 'a' at row 1 +Warning 1264 Data truncated, out of range for column 'a' at row 2 +Warning 1264 Data truncated, out of range for column 'a' at row 3 insert into t1 values ("-111111111.11"),("+1111111111.11"),("1111111111.11"); Warnings: -Warning 1263 Data truncated, out of range for column 'a' at row 1 -Warning 1263 Data truncated, out of range for column 'a' at row 2 -Warning 1263 Data truncated, out of range for column 'a' at row 3 +Warning 1264 Data truncated, out of range for column 'a' at row 1 +Warning 1264 Data truncated, out of range for column 'a' at row 2 +Warning 1264 Data truncated, out of range for column 'a' at row 3 insert into t1 values ("1e+1000"),("1e-1000"),("-1e+1000"); Warnings: -Warning 1263 Data truncated, out of range for column 'a' at row 1 -Warning 1264 Data truncated for column 'a' at row 2 -Warning 1263 Data truncated, out of range for column 'a' at row 3 +Warning 1264 Data truncated, out of range for column 'a' at row 1 +Warning 1265 Data truncated for column 'a' at row 2 +Warning 1264 Data truncated, out of range for column 'a' at row 3 insert into t1 values ("123.4e"),("123.4e+2"),("123.4e-2"),("123e1"),("123e+0"); Warnings: -Warning 1264 Data truncated for column 'a' at row 3 +Warning 1265 Data truncated for column 'a' at row 3 select * from t1; a 0.00 @@ -259,32 +259,32 @@ drop table t1; create table t1 (a decimal(10,2) zerofill); insert into t1 values ("0.0"),("-0.0"),("+0.0"),("01.0"),("+01.0"),("-01.0"); Warnings: -Warning 1263 Data truncated, out of range for column 'a' at row 2 -Warning 1263 Data truncated, out of range for column 'a' at row 6 +Warning 1264 Data truncated, out of range for column 'a' at row 2 +Warning 1264 Data truncated, out of range for column 'a' at row 6 insert into t1 values ("-.1"),("+.1"),(".1"); Warnings: -Warning 1263 Data truncated, out of range for column 'a' at row 1 +Warning 1264 Data truncated, out of range for column 'a' at row 1 insert into t1 values ("00000000000001"),("+0000000000001"),("-0000000000001"); Warnings: -Warning 1263 Data truncated, out of range for column 'a' at row 3 +Warning 1264 Data truncated, out of range for column 'a' at row 3 insert into t1 values ("+111111111.11"),("111111111.11"),("-11111111.11"); Warnings: -Warning 1263 Data truncated, out of range for column 'a' at row 1 -Warning 1263 Data truncated, out of range for column 'a' at row 2 -Warning 1263 Data truncated, out of range for column 'a' at row 3 +Warning 1264 Data truncated, out of range for column 'a' at row 1 +Warning 1264 Data truncated, out of range for column 'a' at row 2 +Warning 1264 Data truncated, out of range for column 'a' at row 3 insert into t1 values ("-111111111.11"),("+1111111111.11"),("1111111111.11"); Warnings: -Warning 1263 Data truncated, out of range for column 'a' at row 1 -Warning 1263 Data truncated, out of range for column 'a' at row 2 -Warning 1263 Data truncated, out of range for column 'a' at row 3 +Warning 1264 Data truncated, out of range for column 'a' at row 1 +Warning 1264 Data truncated, out of range for column 'a' at row 2 +Warning 1264 Data truncated, out of range for column 'a' at row 3 insert into t1 values ("1e+1000"),("1e-1000"),("-1e+1000"); Warnings: -Warning 1263 Data truncated, out of range for column 'a' at row 1 -Warning 1264 Data truncated for column 'a' at row 2 -Warning 1263 Data truncated, out of range for column 'a' at row 3 +Warning 1264 Data truncated, out of range for column 'a' at row 1 +Warning 1265 Data truncated for column 'a' at row 2 +Warning 1264 Data truncated, out of range for column 'a' at row 3 insert into t1 values ("123.4e"),("123.4e+2"),("123.4e-2"),("123e1"),("123e+0"); Warnings: -Warning 1264 Data truncated for column 'a' at row 3 +Warning 1265 Data truncated for column 'a' at row 3 select * from t1; a 00000000.00 @@ -321,13 +321,13 @@ insert into t1 values (00000000000001),(+0000000000001),(-0000000000001); insert into t1 values (+111111111.11),(111111111.11),(-11111111.11); insert into t1 values (-111111111.11),(+1111111111.11),(1111111111.11); Warnings: -Warning 1263 Data truncated, out of range for column 'a' at row 1 -Warning 1263 Data truncated, out of range for column 'a' at row 2 -Warning 1263 Data truncated, out of range for column 'a' at row 3 +Warning 1264 Data truncated, out of range for column 'a' at row 1 +Warning 1264 Data truncated, out of range for column 'a' at row 2 +Warning 1264 Data truncated, out of range for column 'a' at row 3 insert into t1 values (1e+100),(1e-100),(-1e+100); Warnings: -Warning 1263 Data truncated, out of range for column 'a' at row 1 -Warning 1263 Data truncated, out of range for column 'a' at row 3 +Warning 1264 Data truncated, out of range for column 'a' at row 1 +Warning 1264 Data truncated, out of range for column 'a' at row 3 insert into t1 values (123.4e0),(123.4e+2),(123.4e-2),(123e1),(123e+0); select * from t1; a @@ -361,8 +361,8 @@ drop table t1; create table t1 (a decimal); insert into t1 values (-99999999999999),(-1),('+1'),('01'),('+00000000000001'),('+12345678901'),(99999999999999); Warnings: -Warning 1263 Data truncated, out of range for column 'a' at row 1 -Warning 1263 Data truncated, out of range for column 'a' at row 7 +Warning 1264 Data truncated, out of range for column 'a' at row 1 +Warning 1264 Data truncated, out of range for column 'a' at row 7 select * from t1; a -9999999999 @@ -376,9 +376,9 @@ drop table t1; create table t1 (a decimal unsigned); insert into t1 values (-99999999999999),(-1),('+1'),('01'),('+00000000000001'),('+1234567890'),(99999999999999); Warnings: -Warning 1263 Data truncated, out of range for column 'a' at row 1 -Warning 1263 Data truncated, out of range for column 'a' at row 2 -Warning 1263 Data truncated, out of range for column 'a' at row 7 +Warning 1264 Data truncated, out of range for column 'a' at row 1 +Warning 1264 Data truncated, out of range for column 'a' at row 2 +Warning 1264 Data truncated, out of range for column 'a' at row 7 select * from t1; a 0 @@ -392,9 +392,9 @@ drop table t1; create table t1 (a decimal zerofill); insert into t1 values (-99999999999999),(-1),('+1'),('01'),('+00000000000001'),('+1234567890'),(99999999999999); Warnings: -Warning 1263 Data truncated, out of range for column 'a' at row 1 -Warning 1263 Data truncated, out of range for column 'a' at row 2 -Warning 1263 Data truncated, out of range for column 'a' at row 7 +Warning 1264 Data truncated, out of range for column 'a' at row 1 +Warning 1264 Data truncated, out of range for column 'a' at row 2 +Warning 1264 Data truncated, out of range for column 'a' at row 7 select * from t1; a 0000000000 @@ -408,9 +408,9 @@ drop table t1; create table t1 (a decimal unsigned zerofill); insert into t1 values (-99999999999999),(-1),('+1'),('01'),('+00000000000001'),('+1234567890'),(99999999999999); Warnings: -Warning 1263 Data truncated, out of range for column 'a' at row 1 -Warning 1263 Data truncated, out of range for column 'a' at row 2 -Warning 1263 Data truncated, out of range for column 'a' at row 7 +Warning 1264 Data truncated, out of range for column 'a' at row 1 +Warning 1264 Data truncated, out of range for column 'a' at row 2 +Warning 1264 Data truncated, out of range for column 'a' at row 7 select * from t1; a 0000000000 @@ -424,16 +424,16 @@ drop table t1; create table t1(a decimal(10,0)); insert into t1 values ("1e4294967295"); Warnings: -Warning 1264 Data truncated for column 'a' at row 1 -Warning 1263 Data truncated, out of range for column 'a' at row 1 +Warning 1265 Data truncated for column 'a' at row 1 +Warning 1264 Data truncated, out of range for column 'a' at row 1 select * from t1; a 99999999999 delete from t1; insert into t1 values("1e4294967297"); Warnings: -Warning 1264 Data truncated for column 'a' at row 1 -Warning 1263 Data truncated, out of range for column 'a' at row 1 +Warning 1265 Data truncated for column 'a' at row 1 +Warning 1264 Data truncated, out of range for column 'a' at row 1 select * from t1; a 99999999999 diff --git a/mysql-test/r/type_enum.result b/mysql-test/r/type_enum.result index fe8f78453b7..976c484dabf 100644 --- a/mysql-test/r/type_enum.result +++ b/mysql-test/r/type_enum.result @@ -1639,13 +1639,13 @@ drop table t1; create table t1 (a enum ('0','1')); insert into t1 set a='foobar'; Warnings: -Warning 1264 Data truncated for column 'a' at row 1 +Warning 1265 Data truncated for column 'a' at row 1 select * from t1; a update t1 set a = replace(a,'x','y'); Warnings: -Warning 1264 Data truncated for column 'a' at row 1 +Warning 1265 Data truncated for column 'a' at row 1 select * from t1; a diff --git a/mysql-test/r/type_float.result b/mysql-test/r/type_float.result index 2a461942853..a0c0e0f5503 100644 --- a/mysql-test/r/type_float.result +++ b/mysql-test/r/type_float.result @@ -15,8 +15,8 @@ f1 float NULL YES NULL select,insert,update,references f2 double NULL YES NULL select,insert,update,references insert into t1 values(10,10),(1e+5,1e+5),(1234567890,1234567890),(1e+10,1e+10),(1e+15,1e+15),(1e+20,1e+20),(1e+50,1e+50),(1e+150,1e+150); Warnings: -Warning 1263 Data truncated, out of range for column 'f1' at row 7 -Warning 1263 Data truncated, out of range for column 'f1' at row 8 +Warning 1264 Data truncated, out of range for column 'f1' at row 7 +Warning 1264 Data truncated, out of range for column 'f1' at row 8 insert into t1 values(-10,-10),(1e-5,1e-5),(1e-10,1e-10),(1e-15,1e-15),(1e-20,1e-20),(1e-50,1e-50),(1e-150,1e-150); select * from t1; f1 f2 diff --git a/mysql-test/r/type_ranges.result b/mysql-test/r/type_ranges.result index 512df8fbaa9..4a3206005dd 100644 --- a/mysql-test/r/type_ranges.result +++ b/mysql-test/r/type_ranges.result @@ -89,34 +89,34 @@ insert into t1 values (NULL,2,2,2,2,2,2,2,2,2,2,2,2,2,NULL,NULL,NULL,NULL,NULL,N insert into t1 values (0,1/3,3,3,3,3,3,3,3,3,3,3,3,3,NULL,'19970303','10:10:10','19970303101010','','','','3',3,3); insert into t1 values (0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,NULL,19970807,080706,19970403090807,-1,-1,-1,'-1',-1,-1); Warnings: -Warning 1263 Data truncated, out of range for column 'utiny' at row 1 -Warning 1263 Data truncated, out of range for column 'ushort' at row 1 -Warning 1263 Data truncated, out of range for column 'umedium' at row 1 -Warning 1263 Data truncated, out of range for column 'ulong' at row 1 -Warning 1264 Data truncated for column 'options' at row 1 -Warning 1264 Data truncated for column 'flags' at row 1 +Warning 1264 Data truncated, out of range for column 'utiny' at row 1 +Warning 1264 Data truncated, out of range for column 'ushort' at row 1 +Warning 1264 Data truncated, out of range for column 'umedium' at row 1 +Warning 1264 Data truncated, out of range for column 'ulong' at row 1 +Warning 1265 Data truncated for column 'options' at row 1 +Warning 1265 Data truncated for column 'flags' at row 1 insert into t1 values (0,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,-4294967295,NULL,0,0,0,-4294967295,-4294967295,-4294967295,'-4294967295',0,"one,two,tree"); Warnings: -Warning 1264 Data truncated for column 'string' at row 1 -Warning 1263 Data truncated, out of range for column 'tiny' at row 1 -Warning 1263 Data truncated, out of range for column 'short' at row 1 -Warning 1263 Data truncated, out of range for column 'medium' at row 1 -Warning 1263 Data truncated, out of range for column 'long_int' at row 1 -Warning 1263 Data truncated, out of range for column 'utiny' at row 1 -Warning 1263 Data truncated, out of range for column 'ushort' at row 1 -Warning 1263 Data truncated, out of range for column 'umedium' at row 1 -Warning 1263 Data truncated, out of range for column 'ulong' at row 1 -Warning 1264 Data truncated for column 'options' at row 1 +Warning 1265 Data truncated for column 'string' at row 1 +Warning 1264 Data truncated, out of range for column 'tiny' at row 1 +Warning 1264 Data truncated, out of range for column 'short' at row 1 +Warning 1264 Data truncated, out of range for column 'medium' at row 1 +Warning 1264 Data truncated, out of range for column 'long_int' at row 1 +Warning 1264 Data truncated, out of range for column 'utiny' at row 1 +Warning 1264 Data truncated, out of range for column 'ushort' at row 1 +Warning 1264 Data truncated, out of range for column 'umedium' at row 1 +Warning 1264 Data truncated, out of range for column 'ulong' at row 1 +Warning 1265 Data truncated for column 'options' at row 1 insert into t1 values (0,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,4294967295,NULL,0,0,0,4294967295,4294967295,4294967295,'4294967295',0,0); Warnings: -Warning 1263 Data truncated, out of range for column 'tiny' at row 1 -Warning 1263 Data truncated, out of range for column 'short' at row 1 -Warning 1263 Data truncated, out of range for column 'medium' at row 1 -Warning 1263 Data truncated, out of range for column 'long_int' at row 1 -Warning 1263 Data truncated, out of range for column 'utiny' at row 1 -Warning 1263 Data truncated, out of range for column 'ushort' at row 1 -Warning 1263 Data truncated, out of range for column 'umedium' at row 1 -Warning 1264 Data truncated for column 'options' at row 1 +Warning 1264 Data truncated, out of range for column 'tiny' at row 1 +Warning 1264 Data truncated, out of range for column 'short' at row 1 +Warning 1264 Data truncated, out of range for column 'medium' at row 1 +Warning 1264 Data truncated, out of range for column 'long_int' at row 1 +Warning 1264 Data truncated, out of range for column 'utiny' at row 1 +Warning 1264 Data truncated, out of range for column 'ushort' at row 1 +Warning 1264 Data truncated, out of range for column 'umedium' at row 1 +Warning 1265 Data truncated for column 'options' at row 1 insert into t1 (tiny) values (1); select auto,string,tiny,short,medium,long_int,longlong,real_float,real_double,utiny,ushort,umedium,ulong,ulonglong,mod(floor(time_stamp/1000000),1000000)-mod(curdate(),1000000),date_field,time_field,date_time,blob_col,tinyblob_col,mediumblob_col,longblob_col from t1; auto string tiny short medium long_int longlong real_float real_double utiny ushort umedium ulong ulonglong mod(floor(time_stamp/1000000),1000000)-mod(curdate(),1000000) date_field time_field date_time blob_col tinyblob_col mediumblob_col longblob_col @@ -165,12 +165,12 @@ PRIMARY KEY (auto) ); INSERT INTO t2 (string,mediumblob_col,new_field) SELECT string,mediumblob_col,new_field from t1 where auto > 10; Warnings: -Warning 1264 Data truncated for column 'new_field' at row 2 -Warning 1264 Data truncated for column 'new_field' at row 3 -Warning 1264 Data truncated for column 'new_field' at row 4 -Warning 1264 Data truncated for column 'new_field' at row 5 -Warning 1264 Data truncated for column 'new_field' at row 6 -Warning 1264 Data truncated for column 'new_field' at row 7 +Warning 1265 Data truncated for column 'new_field' at row 2 +Warning 1265 Data truncated for column 'new_field' at row 3 +Warning 1265 Data truncated for column 'new_field' at row 4 +Warning 1265 Data truncated for column 'new_field' at row 5 +Warning 1265 Data truncated for column 'new_field' at row 6 +Warning 1265 Data truncated for column 'new_field' at row 7 select * from t2; auto string mediumblob_col new_field 1 2 2 ne @@ -202,9 +202,9 @@ one one drop table t2; create table t2 select * from t1; Warnings: -Warning 1264 Data truncated for column 'options' at row 4 -Warning 1264 Data truncated for column 'options' at row 5 -Warning 1264 Data truncated for column 'options' at row 6 +Warning 1265 Data truncated for column 'options' at row 4 +Warning 1265 Data truncated for column 'options' at row 5 +Warning 1265 Data truncated for column 'options' at row 6 update t2 set string="changed" where auto=16; show full columns from t1; Field Type Collation Null Key Default Extra Privileges Comment diff --git a/mysql-test/r/type_time.result b/mysql-test/r/type_time.result index 5666e865518..0830179902d 100644 --- a/mysql-test/r/type_time.result +++ b/mysql-test/r/type_time.result @@ -25,9 +25,9 @@ t 36:30:31 insert into t1 values("10.22.22"),(1234567),(123456789),(123456789.10),("10 22:22"),("12.45a"); Warnings: -Warning 1263 Data truncated, out of range for column 't' at row 2 -Warning 1263 Data truncated, out of range for column 't' at row 3 -Warning 1263 Data truncated, out of range for column 't' at row 4 +Warning 1264 Data truncated, out of range for column 't' at row 2 +Warning 1264 Data truncated, out of range for column 't' at row 3 +Warning 1264 Data truncated, out of range for column 't' at row 4 select * from t1; t 10:22:33 diff --git a/mysql-test/r/type_timestamp.result b/mysql-test/r/type_timestamp.result index f704add4ebc..72640a4a802 100644 --- a/mysql-test/r/type_timestamp.result +++ b/mysql-test/r/type_timestamp.result @@ -45,11 +45,11 @@ drop table t1; create table t1 (ix timestamp); insert into t1 values (19991101000000),(19990102030405),(19990630232922),(19990601000000),(19990930232922),(19990531232922),(19990501000000),(19991101000000),(19990501000000),(20030101010160),(20030101016001),(20030101240101),(20030132010101),(20031301010101); Warnings: -Warning 1264 Data truncated for column 'ix' at row 10 -Warning 1264 Data truncated for column 'ix' at row 11 -Warning 1264 Data truncated for column 'ix' at row 12 -Warning 1264 Data truncated for column 'ix' at row 13 -Warning 1264 Data truncated for column 'ix' at row 14 +Warning 1265 Data truncated for column 'ix' at row 10 +Warning 1265 Data truncated for column 'ix' at row 11 +Warning 1265 Data truncated for column 'ix' at row 12 +Warning 1265 Data truncated for column 'ix' at row 13 +Warning 1265 Data truncated for column 'ix' at row 14 select ix+0 from t1; ix+0 19991101000000 @@ -138,31 +138,31 @@ t1 t2 show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `t1` timestamp(14) NOT NULL, - `t2` timestamp(14) NOT NULL default '2003-01-01 00:00:00' -) TYPE=MyISAM + `t1` timestamp NOT NULL, + `t2` timestamp NOT NULL default '2003-01-01 00:00:00' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 show columns from t1; Field Type Null Key Default Extra -t1 timestamp(14) YES NULL -t2 timestamp(14) YES 2003-01-01 00:00:00 +t1 timestamp YES NULL +t2 timestamp YES 2003-01-01 00:00:00 show columns from t1 like 't2'; Field Type Null Key Default Extra -t2 timestamp(14) YES 2003-01-01 00:00:00 +t2 timestamp YES 2003-01-01 00:00:00 create table t2 (select * from t1); show create table t2; Table Create Table t2 CREATE TABLE `t2` ( - `t1` timestamp(14) NOT NULL, - `t2` timestamp(14) NOT NULL default '2003-01-01 00:00:00' -) TYPE=MyISAM + `t1` timestamp NOT NULL, + `t2` timestamp NOT NULL default '2003-01-01 00:00:00' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 alter table t1 add column t0 timestamp first; show create table t1; Table Create Table t1 CREATE TABLE `t1` ( - `t0` timestamp(14) NOT NULL, - `t1` timestamp(14) NOT NULL default '2003-01-01 00:00:00', - `t2` timestamp(14) NOT NULL default '2003-01-01 00:00:00' -) TYPE=MyISAM + `t0` timestamp NOT NULL, + `t1` timestamp NOT NULL default '2003-01-01 00:00:00', + `t2` timestamp NOT NULL default '2003-01-01 00:00:00' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t1,t2; create table t1 (ts1 timestamp, ts2 timestamp); set TIMESTAMP=1000000000; diff --git a/mysql-test/r/type_uint.result b/mysql-test/r/type_uint.result index d948ca47972..f312e9b7f64 100644 --- a/mysql-test/r/type_uint.result +++ b/mysql-test/r/type_uint.result @@ -4,7 +4,7 @@ create table t1 (this int unsigned); insert into t1 values (1); insert into t1 values (-1); Warnings: -Warning 1263 Data truncated, out of range for column 'this' at row 1 +Warning 1264 Data truncated, out of range for column 'this' at row 1 select * from t1; this 1 diff --git a/mysql-test/r/type_year.result b/mysql-test/r/type_year.result index 5ef3c1bba81..84b688429db 100644 --- a/mysql-test/r/type_year.result +++ b/mysql-test/r/type_year.result @@ -28,6 +28,8 @@ y y2 drop table t1; create table t1 (y year); insert into t1 values (now()); +Warnings: +Warning 1265 Data truncated for column 'y' at row 1 select if(y = now(), 1, 0) from t1; if(y = now(), 1, 0) 1 diff --git a/mysql-test/r/variables.result b/mysql-test/r/variables.result index 801b9ccf80f..5355e7ffadc 100644 --- a/mysql-test/r/variables.result +++ b/mysql-test/r/variables.result @@ -236,7 +236,7 @@ ERROR HY000: Unknown collation: 'UNKNOWN_COLLATION' set global autocommit=1; ERROR HY000: Variable 'autocommit' is a LOCAL variable and can't be used with SET GLOBAL select @@global.timestamp; -ERROR HY000: Variable 'timestamp' is a LOCAL variable and can't be used with SET GLOBAL +ERROR HY000: Variable 'timestamp' is a LOCAL variable set @@version=''; ERROR HY000: Unknown system variable 'version' set @@concurrent_insert=1; @@ -244,7 +244,7 @@ ERROR HY000: Variable 'concurrent_insert' is a GLOBAL variable and should be set set @@global.sql_auto_is_null=1; ERROR HY000: Variable 'sql_auto_is_null' is a LOCAL variable and can't be used with SET GLOBAL select @@global.sql_auto_is_null; -ERROR HY000: Variable 'sql_auto_is_null' is a LOCAL variable and can't be used with SET GLOBAL +ERROR HY000: Variable 'sql_auto_is_null' is a LOCAL variable set myisam_max_sort_file_size=100; ERROR HY000: Variable 'myisam_max_sort_file_size' is a GLOBAL variable and should be set with SET GLOBAL set myisam_max_extra_sort_file_size=100; @@ -381,7 +381,7 @@ select 1; 1 1 select @@session.key_buffer_size; -Variable 'key_buffer_size' is a GLOBAL variable +ERROR HY000: Variable 'key_buffer_size' is a GLOBAL variable select @@global.max_user_connections,@@local.max_join_size; @@global.max_user_connections @@session.max_join_size 100 200 diff --git a/mysql-test/r/warnings.result b/mysql-test/r/warnings.result index b675d189d30..bff950584a1 100644 --- a/mysql-test/r/warnings.result +++ b/mysql-test/r/warnings.result @@ -4,19 +4,19 @@ create table t1 (a int); insert into t1 values (1); insert into t1 values ("hej"); Warnings: -Warning 1264 Data truncated for column 'a' at row 1 +Warning 1265 Data truncated for column 'a' at row 1 insert into t1 values ("hej"),("då"); Warnings: -Warning 1264 Data truncated for column 'a' at row 1 -Warning 1264 Data truncated for column 'a' at row 2 +Warning 1265 Data truncated for column 'a' at row 1 +Warning 1265 Data truncated for column 'a' at row 2 set SQL_WARNINGS=1; insert into t1 values ("hej"); Warnings: -Warning 1264 Data truncated for column 'a' at row 1 +Warning 1265 Data truncated for column 'a' at row 1 insert into t1 values ("hej"),("då"); Warnings: -Warning 1264 Data truncated for column 'a' at row 1 -Warning 1264 Data truncated for column 'a' at row 2 +Warning 1265 Data truncated for column 'a' at row 1 +Warning 1265 Data truncated for column 'a' at row 2 drop table t1; set SQL_WARNINGS=0; drop temporary table if exists not_exists; @@ -43,13 +43,13 @@ drop table t1; create table t1(a tinyint, b int not null, c date, d char(5)); load data infile '../../std_data/warnings_loaddata.dat' into table t1 fields terminated by ','; Warnings: -Warning 1262 Data truncated, NULL supplied to NOT NULL column 'b' at row 2 -Warning 1264 Data truncated for column 'd' at row 3 -Warning 1264 Data truncated for column 'c' at row 4 -Warning 1260 Row 5 doesn't contain data for all columns -Warning 1264 Data truncated for column 'b' at row 6 -Warning 1261 Row 7 was truncated; It contained more data than there where input columns -Warning 1263 Data truncated, out of range for column 'a' at row 8 +Warning 1263 Data truncated, NULL supplied to NOT NULL column 'b' at row 2 +Warning 1265 Data truncated for column 'd' at row 3 +Warning 1265 Data truncated for column 'c' at row 4 +Warning 1261 Row 5 doesn't contain data for all columns +Warning 1265 Data truncated for column 'b' at row 6 +Warning 1262 Row 7 was truncated; It contained more data than there where input columns +Warning 1264 Data truncated, out of range for column 'a' at row 8 select @@warning_count; @@warning_count 7 @@ -57,44 +57,44 @@ drop table t1; create table t1(a tinyint NOT NULL, b tinyint unsigned, c char(5)); insert into t1 values(NULL,100,'mysql'),(10,-1,'mysql ab'),(500,256,'open source'),(20,NULL,'test'); Warnings: -Warning 1262 Data truncated, NULL supplied to NOT NULL column 'a' at row 1 -Warning 1263 Data truncated, out of range for column 'b' at row 2 -Warning 1264 Data truncated for column 'c' at row 2 -Warning 1263 Data truncated, out of range for column 'a' at row 3 -Warning 1263 Data truncated, out of range for column 'b' at row 3 -Warning 1264 Data truncated for column 'c' at row 3 +Warning 1263 Data truncated, NULL supplied to NOT NULL column 'a' at row 1 +Warning 1264 Data truncated, out of range for column 'b' at row 2 +Warning 1265 Data truncated for column 'c' at row 2 +Warning 1264 Data truncated, out of range for column 'a' at row 3 +Warning 1264 Data truncated, out of range for column 'b' at row 3 +Warning 1265 Data truncated for column 'c' at row 3 alter table t1 modify c char(4); Warnings: -Warning 1264 Data truncated for column 'c' at row 1 -Warning 1264 Data truncated for column 'c' at row 2 +Warning 1265 Data truncated for column 'c' at row 1 +Warning 1265 Data truncated for column 'c' at row 2 alter table t1 add d char(2); update t1 set a=NULL where a=10; Warnings: -Warning 1262 Data truncated, NULL supplied to NOT NULL column 'a' at row 2 +Warning 1263 Data truncated, NULL supplied to NOT NULL column 'a' at row 2 update t1 set c='mysql ab' where c='test'; Warnings: -Warning 1264 Data truncated for column 'c' at row 4 +Warning 1265 Data truncated for column 'c' at row 4 update t1 set d=c; Warnings: -Warning 1264 Data truncated for column 'd' at row 1 -Warning 1264 Data truncated for column 'd' at row 2 -Warning 1264 Data truncated for column 'd' at row 3 -Warning 1264 Data truncated for column 'd' at row 4 +Warning 1265 Data truncated for column 'd' at row 1 +Warning 1265 Data truncated for column 'd' at row 2 +Warning 1265 Data truncated for column 'd' at row 3 +Warning 1265 Data truncated for column 'd' at row 4 create table t2(a tinyint NOT NULL, b char(3)); insert into t2 select b,c from t1; Warnings: -Warning 1264 Data truncated for column 'b' at row 1 -Warning 1264 Data truncated for column 'b' at row 2 -Warning 1264 Data truncated for column 'b' at row 3 -Warning 1262 Data truncated, NULL supplied to NOT NULL column 'a' at row 4 -Warning 1264 Data truncated for column 'b' at row 4 +Warning 1265 Data truncated for column 'b' at row 1 +Warning 1265 Data truncated for column 'b' at row 2 +Warning 1265 Data truncated for column 'b' at row 3 +Warning 1263 Data truncated, NULL supplied to NOT NULL column 'a' at row 4 +Warning 1265 Data truncated for column 'b' at row 4 insert into t2(b) values('mysqlab'); Warnings: -Warning 1264 Data truncated for column 'b' at row 1 +Warning 1265 Data truncated for column 'b' at row 1 set sql_warnings=1; insert into t2(b) values('mysqlab'); Warnings: -Warning 1264 Data truncated for column 'b' at row 1 +Warning 1265 Data truncated for column 'b' at row 1 set sql_warnings=0; drop table t1, t2; create table t1(a char(10)); @@ -102,34 +102,34 @@ alter table t1 add b char; set max_error_count=10; update t1 set b=a; Warnings: -Warning 1264 Data truncated for column 'b' at row 1 -Warning 1264 Data truncated for column 'b' at row 2 -Warning 1264 Data truncated for column 'b' at row 3 -Warning 1264 Data truncated for column 'b' at row 4 -Warning 1264 Data truncated for column 'b' at row 5 -Warning 1264 Data truncated for column 'b' at row 6 -Warning 1264 Data truncated for column 'b' at row 7 -Warning 1264 Data truncated for column 'b' at row 8 -Warning 1264 Data truncated for column 'b' at row 9 -Warning 1264 Data truncated for column 'b' at row 10 +Warning 1265 Data truncated for column 'b' at row 1 +Warning 1265 Data truncated for column 'b' at row 2 +Warning 1265 Data truncated for column 'b' at row 3 +Warning 1265 Data truncated for column 'b' at row 4 +Warning 1265 Data truncated for column 'b' at row 5 +Warning 1265 Data truncated for column 'b' at row 6 +Warning 1265 Data truncated for column 'b' at row 7 +Warning 1265 Data truncated for column 'b' at row 8 +Warning 1265 Data truncated for column 'b' at row 9 +Warning 1265 Data truncated for column 'b' at row 10 select @@warning_count; @@warning_count 50 drop table t1; create table t1 (id int) engine=isam; Warnings: -Warning 1265 Using storage engine MyISAM for table 't1' +Warning 1266 Using storage engine MyISAM for table 't1' alter table t1 engine=isam; Warnings: -Warning 1265 Using storage engine MyISAM for table 't1' +Warning 1266 Using storage engine MyISAM for table 't1' drop table t1; create table t1 (id int) type=heap; Warnings: -Warning 1286 'TYPE=storage_engine' is deprecated. Use 'ENGINE=storage_engine' instead. +Warning 1287 'TYPE=storage_engine' is deprecated. Use 'ENGINE=storage_engine' instead. alter table t1 type=myisam; Warnings: -Warning 1286 'TYPE=storage_engine' is deprecated. Use 'ENGINE=storage_engine' instead. +Warning 1287 'TYPE=storage_engine' is deprecated. Use 'ENGINE=storage_engine' instead. drop table t1; set table_type=MYISAM; Warnings: -Warning 1286 'table_type' is deprecated. Use 'storage_engine' instead. +Warning 1287 'table_type' is deprecated. Use 'storage_engine' instead. diff --git a/mysql-test/t/case.test b/mysql-test/t/case.test index 9377c6c4aef..87e456baba7 100644 --- a/mysql-test/t/case.test +++ b/mysql-test/t/case.test @@ -63,14 +63,14 @@ CREATE TABLE t1 SELECT SHOW CREATE TABLE t1; DROP TABLE t1; ---error 1266 +--error 1267 SELECT CASE WHEN 1 THEN _latin1'a' COLLATE latin1_danish_ci ELSE _latin1'a' COLLATE latin1_swedish_ci END; ---error 1269 +--error 1270 SELECT CASE _latin1'a' COLLATE latin1_general_ci WHEN _latin1'a' COLLATE latin1_danish_ci THEN 1 WHEN _latin1'a' COLLATE latin1_swedish_ci THEN 2 @@ -93,9 +93,9 @@ CASE _latin1'a' WHEN _latin1'A' COLLATE latin1_bin THEN '1' ELSE 2 END # # Check COALESCE argument types aggregation ---error 1266 +--error 1267 CREATE TABLE t1 SELECT COALESCE(_latin1'a',_latin2'a'); ---error 1266 +--error 1267 CREATE TABLE t1 SELECT COALESCE('a' COLLATE latin1_swedish_ci,'b' COLLATE latin1_bin); CREATE TABLE t1 SELECT COALESCE(1), COALESCE(1.0),COALESCE('a'), diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index 64134fe9990..70fa4173c76 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -74,7 +74,7 @@ create table `` (a int); drop table if exists ``; --error 1166 create table t1 (`` int); ---error 1279 +--error 1280 create table t1 (i int, index `` (i)); # @@ -157,7 +157,7 @@ SELECT @@storage_engine; CREATE TABLE t1 (a int not null); show create table t1; drop table t1; ---error 1285 +--error 1286 SET SESSION storage_engine="gemini"; SELECT @@storage_engine; CREATE TABLE t1 (a int not null); @@ -277,7 +277,7 @@ SELECT @@storage_engine; CREATE TABLE t1 (a int not null); show create table t1; drop table t1; ---error 1285 +--error 1286 SET SESSION storage_engine="gemini"; SELECT @@storage_engine; CREATE TABLE t1 (a int not null); diff --git a/mysql-test/t/ctype_collate.test b/mysql-test/t/ctype_collate.test index 5916e3da241..3599beeacc4 100644 --- a/mysql-test/t/ctype_collate.test +++ b/mysql-test/t/ctype_collate.test @@ -7,12 +7,12 @@ CREATE TABLE t1 ( latin1_f CHAR(32) CHARACTER SET latin1 NOT NULL ); ---error 1252 +--error 1253 CREATE TABLE t2 ( latin1_f CHAR(32) CHARACTER SET latin1 COLLATE koi8r_general_ci NOT NULL ); ---error 1272 +--error 1273 CREATE TABLE t2 ( latin1_f CHAR(32) CHARACTER SET latin1 COLLATE some_non_existing_col NOT NULL ); @@ -66,7 +66,7 @@ SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_swedish_ci; SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_german2_ci; SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_general_ci; SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE latin1_bin; ---error 1252 +--error 1253 SELECT latin1_f FROM t1 ORDER BY latin1_f COLLATE koi8r_general_ci; --SELECT latin1_f COLLATE koi8r FROM t1 ; @@ -76,7 +76,7 @@ SELECT latin1_f COLLATE latin1_swedish_ci AS latin1_f_as FROM t1 ORDER BY latin1 SELECT latin1_f COLLATE latin1_german2_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as; SELECT latin1_f COLLATE latin1_general_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as; SELECT latin1_f COLLATE latin1_bin AS latin1_f_as FROM t1 ORDER BY latin1_f_as; ---error 1252 +--error 1253 SELECT latin1_f COLLATE koi8r_general_ci AS latin1_f_as FROM t1 ORDER BY latin1_f_as; @@ -87,7 +87,7 @@ SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_swedish_ci; SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_german2_ci; SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_general_ci; SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE latin1_bin; ---error 1252 +--error 1253 SELECT latin1_f,count(*) FROM t1 GROUP BY latin1_f COLLATE koi8r_general_ci; @@ -98,7 +98,7 @@ SELECT DISTINCT latin1_f COLLATE latin1_swedish_ci FROM t1; SELECT DISTINCT latin1_f COLLATE latin1_german2_ci FROM t1; SELECT DISTINCT latin1_f COLLATE latin1_general_ci FROM t1; SELECT DISTINCT latin1_f COLLATE latin1_bin FROM t1; ---error 1272 +--error 1273 SELECT DISTINCT latin1_f COLLATE koi8r FROM t1; @@ -153,7 +153,7 @@ DROP TABLE t1; CREATE TABLE t1 (s1 CHAR(5) COLLATE latin1_german1_ci, s2 CHAR(5) COLLATE latin1_swedish_ci); ---error 1266 +--error 1267 SELECT * FROM t1 WHERE s1 = s2; DROP TABLE t1; diff --git a/mysql-test/t/ctype_tis620.test b/mysql-test/t/ctype_tis620.test index 7314b52e301..b30a5fbc95a 100644 --- a/mysql-test/t/ctype_tis620.test +++ b/mysql-test/t/ctype_tis620.test @@ -1,13 +1,78 @@ +-- source include/have_tis620.inc + +# +# Tests with the big5 character set +# --disable_warnings drop table if exists t1; --enable_warnings +# +# Bug 1552: tis620 <-> unicode conversion crashed +# Check tis620 -> utf8 -> tis620 round trip conversion +# + +SET @pl0= _tis620 0x000102030405060708090A0B0C0D0E0F; +SET @pl1= _tis620 0x101112131415161718191A1B1C1D1E1F; +SET @pl2= _tis620 0x202122232425262728292A2B2C2D2E2F; +SET @pl3= _tis620 0x303132333435363738393A3B3C3D3E3F; +SET @pl4= _tis620 0x404142434445464748494A4B4C4D4E4F; +SET @pl5= _tis620 0x505152535455565758595A5B5C5D5E5F; +SET @pl6= _tis620 0x606162636465666768696A6B6C6D6E6F; +SET @pl7= _tis620 0x707172737475767778797A7B7C7D7E7F; +SET @pl8= _tis620 0x808182838485868788898A8B8C8D8E8F; +SET @pl9= _tis620 0x909192939495969798999A9B9C9D9E9F; +SET @plA= _tis620 0xA0A1A2A3A4A5A6A7A8A9AAABACADAEAF; +SET @plB= _tis620 0xB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBF; +SET @plC= _tis620 0xC0C1C2C3C4C5C6C7C8C9CACBCCCDCECF; +SET @plD= _tis620 0xD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF; +SET @plE= _tis620 0xE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF; +SET @plF= _tis620 0xF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF; + +SELECT hex(@u0:=convert(@pl0 using utf8)); +SELECT hex(@u1:=convert(@pl1 using utf8)); +SELECT hex(@u2:=convert(@pl2 using utf8)); +SELECT hex(@u3:=convert(@pl3 using utf8)); +SELECT hex(@u4:=convert(@pl4 using utf8)); +SELECT hex(@u5:=convert(@pl5 using utf8)); +SELECT hex(@u6:=convert(@pl6 using utf8)); +SELECT hex(@u7:=convert(@pl7 using utf8)); +SELECT hex(@u8:=convert(@pl8 using utf8)); +SELECT hex(@u9:=convert(@pl9 using utf8)); +SELECT hex(@uA:=convert(@plA using utf8)); +SELECT hex(@uB:=convert(@plB using utf8)); +SELECT hex(@uC:=convert(@plC using utf8)); +SELECT hex(@uD:=convert(@plD using utf8)); +SELECT hex(@uE:=convert(@plE using utf8)); +SELECT hex(@uF:=convert(@plF using utf8)); + +SELECT hex(convert(@u0 USING tis620)); +SELECT hex(convert(@u1 USING tis620)); +SELECT hex(convert(@u2 USING tis620)); +SELECT hex(convert(@u3 USING tis620)); +SELECT hex(convert(@u4 USING tis620)); +SELECT hex(convert(@u5 USING tis620)); +SELECT hex(convert(@u6 USING tis620)); +SELECT hex(convert(@u7 USING tis620)); +SELECT hex(convert(@u8 USING tis620)); +SELECT hex(convert(@u9 USING tis620)); +SELECT hex(convert(@uA USING tis620)); +SELECT hex(convert(@uB USING tis620)); +SELECT hex(convert(@uC USING tis620)); +SELECT hex(convert(@uD USING tis620)); +SELECT hex(convert(@uE USING tis620)); +SELECT hex(convert(@uF USING tis620)); + +SET NAMES tis620; + CREATE TABLE t1 ( recid int(11) NOT NULL auto_increment, dyninfo text, PRIMARY KEY (recid) ) ENGINE=MyISAM; +show create table t1; + INSERT INTO t1 VALUES (1,'color=\"STB,NPG\"\r\nengine=\"J30A13\"\r\nframe=\"MRHCG1640YP4\"\r\ngrade=\"V6\"\r\nmodel=\"ACCORD\"\r\nmodelcode=\"CG164YEN\"\r\ntype=\"VT6\"\r\n'); INSERT INTO t1 VALUES (2,'color=\"HTM,NPG,DEG,RGS\"\r\nengine=\"F23A5YP1\"\r\nframe=\"MRHCF8640YP3\"\r\ngrade=\"EXi AT\"\r\nmodel=\"ACCORD\"\r\nmodelcode=\"CF864YE\"\r\ntype=\"EXA\"\r\n'); diff --git a/mysql-test/t/ctype_tis620.test-old b/mysql-test/t/ctype_tis620.test-old deleted file mode 100644 index 82c660dfea0..00000000000 --- a/mysql-test/t/ctype_tis620.test-old +++ /dev/null @@ -1,64 +0,0 @@ --- source include/have_tis620.inc - -# -# Tests with the big5 character set -# ---disable_warnings -drop table if exists t1; ---enable_warnings - -# -# Bug 1552: tis620 <-> unicode conversion crashed -# Check tis620 -> utf8 -> tis620 round trip conversion -# - -SET @pl0= _tis620 0x000102030405060708090A0B0C0D0E0F; -SET @pl1= _tis620 0x101112131415161718191A1B1C1D1E1F; -SET @pl2= _tis620 0x202122232425262728292A2B2C2D2E2F; -SET @pl3= _tis620 0x303132333435363738393A3B3C3D3E3F; -SET @pl4= _tis620 0x404142434445464748494A4B4C4D4E4F; -SET @pl5= _tis620 0x505152535455565758595A5B5C5D5E5F; -SET @pl6= _tis620 0x606162636465666768696A6B6C6D6E6F; -SET @pl7= _tis620 0x707172737475767778797A7B7C7D7E7F; -SET @pl8= _tis620 0x808182838485868788898A8B8C8D8E8F; -SET @pl9= _tis620 0x909192939495969798999A9B9C9D9E9F; -SET @plA= _tis620 0xA0A1A2A3A4A5A6A7A8A9AAABACADAEAF; -SET @plB= _tis620 0xB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBF; -SET @plC= _tis620 0xC0C1C2C3C4C5C6C7C8C9CACBCCCDCECF; -SET @plD= _tis620 0xD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDF; -SET @plE= _tis620 0xE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF; -SET @plF= _tis620 0xF0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF; - -SELECT hex(@u0:=convert(@pl0 using utf8)); -SELECT hex(@u1:=convert(@pl1 using utf8)); -SELECT hex(@u2:=convert(@pl2 using utf8)); -SELECT hex(@u3:=convert(@pl3 using utf8)); -SELECT hex(@u4:=convert(@pl4 using utf8)); -SELECT hex(@u5:=convert(@pl5 using utf8)); -SELECT hex(@u6:=convert(@pl6 using utf8)); -SELECT hex(@u7:=convert(@pl7 using utf8)); -SELECT hex(@u8:=convert(@pl8 using utf8)); -SELECT hex(@u9:=convert(@pl9 using utf8)); -SELECT hex(@uA:=convert(@plA using utf8)); -SELECT hex(@uB:=convert(@plB using utf8)); -SELECT hex(@uC:=convert(@plC using utf8)); -SELECT hex(@uD:=convert(@plD using utf8)); -SELECT hex(@uE:=convert(@plE using utf8)); -SELECT hex(@uF:=convert(@plF using utf8)); - -SELECT hex(convert(@u0 USING tis620)); -SELECT hex(convert(@u1 USING tis620)); -SELECT hex(convert(@u2 USING tis620)); -SELECT hex(convert(@u3 USING tis620)); -SELECT hex(convert(@u4 USING tis620)); -SELECT hex(convert(@u5 USING tis620)); -SELECT hex(convert(@u6 USING tis620)); -SELECT hex(convert(@u7 USING tis620)); -SELECT hex(convert(@u8 USING tis620)); -SELECT hex(convert(@u9 USING tis620)); -SELECT hex(convert(@uA USING tis620)); -SELECT hex(convert(@uB USING tis620)); -SELECT hex(convert(@uC USING tis620)); -SELECT hex(convert(@uD USING tis620)); -SELECT hex(convert(@uE USING tis620)); -SELECT hex(convert(@uF USING tis620)); diff --git a/mysql-test/t/delete.test b/mysql-test/t/delete.test index bd5d9e5c0d9..e370b545eff 100644 --- a/mysql-test/t/delete.test +++ b/mysql-test/t/delete.test @@ -84,7 +84,7 @@ insert into t2 values (1, 21),(2, 12),(3, 23); select * from t11; select * from t12; select * from t2; --- error 1241 +-- error 1242 delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select b from t2 where t11.a < t2.a); select * from t11; select * from t12; @@ -92,7 +92,7 @@ delete ignore t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b <> (select select * from t11; select * from t12; insert into t11 values (2, 12); --- error 1241 +-- error 1242 delete from t11 where t11.b <> (select b from t2 where t11.a < t2.a); select * from t11; delete ignore from t11 where t11.b <> (select b from t2 where t11.a < t2.a); diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test index a9341ada416..0ef56191b7c 100644 --- a/mysql-test/t/derived.test +++ b/mysql-test/t/derived.test @@ -116,7 +116,7 @@ select mail_id, if(folder.f_description!='', folder.f_description, folder.f_nam # create table t1 (a int); insert into t1 values (1),(2),(3); --- error 1287 +-- error 1288 update (select * from t1) as t1 set a = 5; -- error 1064 delete from (select * from t1); @@ -151,13 +151,13 @@ CREATE TABLE `t1` ( INSERT INTO `t1` (N, M) VALUES (1, 0),(1, 0),(1, 0),(2, 0),(2, 0),(3, 0); UPDATE `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N SET P1.M = 2; select * from t1; --- error 1287 +-- error 1288 UPDATE `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N SET P1.M = 2, P2.N = 2; -- error 1054 UPDATE `t1` AS P1 INNER JOIN (SELECT aaaa FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N SET P1.M = 2; delete P1.* from `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N; select * from t1; --- error 1287 +-- error 1288 delete P1.*,P2.* from `t1` AS P1 INNER JOIN (SELECT N FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N; -- error 1054 delete P1.* from `t1` AS P1 INNER JOIN (SELECT aaa FROM `t1` GROUP BY N HAVING Count(M) > 1) AS P2 ON P1.N = P2.N; diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test index be75d5ee7cc..98b9eb114ab 100644 --- a/mysql-test/t/fulltext.test +++ b/mysql-test/t/fulltext.test @@ -145,9 +145,9 @@ select * from t2 having MATCH inhalt AGAINST ('foobar'); # check of fulltext errors # ---error 1282 +--error 1283 CREATE TABLE t3 (t int(11),i text,fulltext tix (t,i)); ---error 1282 +--error 1283 CREATE TABLE t3 (t int(11),i text, j varchar(200) CHARACTER SET latin2, fulltext tix (i,j)); diff --git a/mysql-test/t/func_in.test b/mysql-test/t/func_in.test index 9ff768ec76b..855a7cbd28f 100644 --- a/mysql-test/t/func_in.test +++ b/mysql-test/t/func_in.test @@ -61,11 +61,11 @@ c char(1) character set latin1 collate latin1_danish_ci ); insert into t1 values ('A','B','C'); insert into t1 values ('a','c','c'); ---error 1266 +--error 1267 select * from t1 where a in (b); ---error 1269 -select * from t1 where a in (b,c); --error 1270 +select * from t1 where a in (b,c); +--error 1271 select * from t1 where 'a' in (a,b,c); select * from t1 where 'a' in (a); select * from t1 where a in ('a'); diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index 233b58ea9b6..a9c2895206d 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -177,23 +177,22 @@ select 1=_latin1'1'; select _latin1'1'=1; select _latin2'1'=1; select 1=_latin2'1'; ---error 1266 +--error 1267 select _latin1'1'=_latin2'1'; select row('a','b','c') = row('a','b','c'); select row('A','b','c') = row('a','b','c'); select row('A' COLLATE latin1_bin,'b','c') = row('a','b','c'); select row('A','b','c') = row('a' COLLATE latin1_bin,'b','c'); ---error 1266 +--error 1267 select row('A' COLLATE latin1_general_ci,'b','c') = row('a' COLLATE latin1_bin,'b','c'); ---error 1266 +--error 1267 select concat(_latin1'a',_latin2'a'); ---error 1269 -select concat(_latin1'a',_latin2'a',_latin5'a'); --error 1270 +select concat(_latin1'a',_latin2'a',_latin5'a'); +--error 1271 select concat(_latin1'a',_latin2'a',_latin5'a',_latin7'a'); - # # Test FIELD() and collations # @@ -201,65 +200,64 @@ select FIELD('b','A','B'); select FIELD('B','A','B'); select FIELD('b' COLLATE latin1_bin,'A','B'); select FIELD('b','A' COLLATE latin1_bin,'B'); ---error 1269 +--error 1270 select FIELD(_latin2'b','A','B'); ---error 1269 +--error 1270 select FIELD('b',_latin2'A','B'); select FIELD('b',_latin2'A','B',1); - select POSITION(_latin1'B' IN _latin1'abcd'); select POSITION(_latin1'B' IN _latin1'abcd' COLLATE latin1_bin); select POSITION(_latin1'B' COLLATE latin1_bin IN _latin1'abcd'); ---error 1266 +--error 1267 select POSITION(_latin1'B' COLLATE latin1_general_ci IN _latin1'abcd' COLLATE latin1_bin); ---error 1266 +--error 1267 select POSITION(_latin1'B' IN _latin2'abcd'); select FIND_IN_SET(_latin1'B',_latin1'a,b,c,d'); --fix this: --select FIND_IN_SET(_latin1'B',_latin1'a,b,c,d' COLLATE latin1_bin); --select FIND_IN_SET(_latin1'B' COLLATE latin1_bin,_latin1'a,b,c,d'); ---error 1266 +--error 1267 select FIND_IN_SET(_latin1'B' COLLATE latin1_general_ci,_latin1'a,b,c,d' COLLATE latin1_bin); ---error 1266 +--error 1267 select FIND_IN_SET(_latin1'B',_latin2'a,b,c,d'); select SUBSTRING_INDEX(_latin1'abcdabcdabcd',_latin1'd',2); --fix this: --select SUBSTRING_INDEX(_latin1'abcdabcdabcd' COLLATE latin1_bin,_latin1'd',2); --select SUBSTRING_INDEX(_latin1'abcdabcdabcd',_latin1'd' COLLATE latin1_bin,2); ---error 1266 +--error 1267 select SUBSTRING_INDEX(_latin1'abcdabcdabcd',_latin2'd',2); ---error 1266 +--error 1267 select SUBSTRING_INDEX(_latin1'abcdabcdabcd' COLLATE latin1_general_ci,_latin1'd' COLLATE latin1_bin,2); select _latin1'B' between _latin1'a' and _latin1'c'; select _latin1'B' collate latin1_bin between _latin1'a' and _latin1'c'; select _latin1'B' between _latin1'a' collate latin1_bin and _latin1'c'; select _latin1'B' between _latin1'a' and _latin1'c' collate latin1_bin; ---error 1269 +--error 1270 select _latin2'B' between _latin1'a' and _latin1'b'; ---error 1269 +--error 1270 select _latin1'B' between _latin2'a' and _latin1'b'; ---error 1269 +--error 1270 select _latin1'B' between _latin1'a' and _latin2'b'; ---error 1269 +--error 1270 select _latin1'B' collate latin1_general_ci between _latin1'a' collate latin1_bin and _latin1'b'; select _latin1'B' in (_latin1'a',_latin1'b'); select _latin1'B' collate latin1_bin in (_latin1'a',_latin1'b'); select _latin1'B' in (_latin1'a' collate latin1_bin,_latin1'b'); select _latin1'B' in (_latin1'a',_latin1'b' collate latin1_bin); ---error 1269 +--error 1270 select _latin2'B' in (_latin1'a',_latin1'b'); ---error 1269 +--error 1270 select _latin1'B' in (_latin2'a',_latin1'b'); ---error 1269 +--error 1270 select _latin1'B' in (_latin1'a',_latin2'b'); ---error 1269 +--error 1270 select _latin1'B' COLLATE latin1_general_ci in (_latin1'a' COLLATE latin1_bin,_latin1'b'); ---error 1269 +--error 1270 select _latin1'B' COLLATE latin1_general_ci in (_latin1'a',_latin1'b' COLLATE latin1_bin); select collation(bin(130)), coercibility(bin(130)); @@ -345,7 +343,7 @@ select SUBSTR('abcdefg',1,-1) FROM DUAL; # when an error on a lower level (in concat) has accured: # create table t7 (s1 char); ---error 1266 +--error 1267 select * from t7 where concat(s1 collate latin1_general_ci,s1 collate latin1_swedish_ci) = 'AA'; drop table t7; diff --git a/mysql-test/t/func_test.test b/mysql-test/t/func_test.test index 0d055549866..44047491862 100644 --- a/mysql-test/t/func_test.test +++ b/mysql-test/t/func_test.test @@ -51,9 +51,9 @@ explain extended select _koi8r'a' = _koi8r'A' COLLATE koi8r_general_ci; select _koi8r'a' = _koi8r'A' COLLATE koi8r_bin; select _koi8r'a' COLLATE koi8r_general_ci = _koi8r'A'; select _koi8r'a' COLLATE koi8r_bin = _koi8r'A'; ---error 1266 +--error 1267 select _koi8r'a' COLLATE koi8r_bin = _koi8r'A' COLLATE koi8r_general_ci; ---error 1266 +--error 1267 select _koi8r'a' = _latin1'A'; select strcmp(_koi8r'a', _koi8r'A'); @@ -61,9 +61,9 @@ select strcmp(_koi8r'a', _koi8r'A' COLLATE koi8r_general_ci); select strcmp(_koi8r'a', _koi8r'A' COLLATE koi8r_bin); select strcmp(_koi8r'a' COLLATE koi8r_general_ci, _koi8r'A'); select strcmp(_koi8r'a' COLLATE koi8r_bin, _koi8r'A'); ---error 1266 +--error 1267 select strcmp(_koi8r'a' COLLATE koi8r_general_ci, _koi8r'A' COLLATE koi8r_bin); ---error 1266 +--error 1267 select strcmp(_koi8r'a', _latin1'A'); select _koi8r'a' LIKE _koi8r'A'; @@ -71,9 +71,9 @@ select _koi8r'a' LIKE _koi8r'A' COLLATE koi8r_general_ci; select _koi8r'a' LIKE _koi8r'A' COLLATE koi8r_bin; select _koi8r'a' COLLATE koi8r_general_ci LIKE _koi8r'A'; select _koi8r'a' COLLATE koi8r_bin LIKE _koi8r'A'; ---error 1266 +--error 1267 select _koi8r'a' COLLATE koi8r_general_ci LIKE _koi8r'A' COLLATE koi8r_bin; ---error 1266 +--error 1267 select _koi8r'a' LIKE _latin1'A'; # diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index 78221fa4e40..5cf3e10f972 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -110,14 +110,14 @@ show grants for drop_user@localhost; revoke all privileges, grant from drop_user@localhost; show grants for drop_user@localhost; drop user drop_user@localhost; ---error 1268 +--error 1269 revoke all privileges, grant from drop_user@localhost; grant select(a) on test.t1 to drop_user1@localhost; grant select on test.t1 to drop_user2@localhost; grant select on test.* to drop_user3@localhost; grant select on *.* to drop_user4@localhost; ---error 1267 +--error 1268 drop user drop_user1@localhost, drop_user2@localhost, drop_user3@localhost, drop_user4@localhost; revoke all privileges, grant from drop_user1@localhost, drop_user2@localhost, diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test index 92ab6008840..ada2771fdc2 100644 --- a/mysql-test/t/innodb.test +++ b/mysql-test/t/innodb.test @@ -936,8 +936,8 @@ drop table t1; # Test dictionary handling with spaceand quoting # -CREATE TABLE t1 (`id 1` INT NOT NULL, PRIMARY KEY (`id 1`)) TYPE=INNODB; -CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id), FOREIGN KEY (`t1_id`) REFERENCES `t1`(`id 1`) ON DELETE CASCADE ) TYPE=INNODB; +CREATE TABLE t1 (`id 1` INT NOT NULL, PRIMARY KEY (`id 1`)) ENGINE=INNODB; +CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id), FOREIGN KEY (`t1_id`) REFERENCES `t1`(`id 1`) ON DELETE CASCADE ) ENGINE=INNODB; #show create table t2; drop table t2,t1; diff --git a/mysql-test/t/key_cache.test b/mysql-test/t/key_cache.test index d9a2200a636..2bf5cdbcf6f 100644 --- a/mysql-test/t/key_cache.test +++ b/mysql-test/t/key_cache.test @@ -41,7 +41,7 @@ SET @@global.key_buffer_size=@save_key_buffer; --error 1064 SELECT @@default.key_buffer_size; ---error 1271 +--error 1272 SELECT @@skr.storage_engine="test"; select @@keycache1.key_cache_block_size; @@ -99,7 +99,7 @@ explain select a from t2; select a from t2; # Test some error conditions ---error 1283 +--error 1284 cache index t1 in unknown_key_cache; cache index t1 key (unknown_key) in keycache1; diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index 6ced608344b..c407cba4800 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -422,6 +422,18 @@ insert into t1 values('807780', '472', '162'); select * from t1 where a='807780' and b='477' and c='165'; drop table t1; +# +# Verify blob handling +# +create table t1 (a blob); +insert into t1 values('a '),('a'); +select concat(a,'.') from t1 where a='a'; +select concat(a,'.') from t1 where a='a '; +alter table t1 add key(a(2)); +select concat(a,'.') from t1 where a='a'; +select concat(a,'.') from t1 where a='a '; +drop table t1; + # # Test text and unique # diff --git a/mysql-test/t/row.test b/mysql-test/t/row.test index ecb0c6adfc1..62e8eb7991c 100644 --- a/mysql-test/t/row.test +++ b/mysql-test/t/row.test @@ -15,7 +15,7 @@ select row('b',1.5,3) IN (row(3,NULL,3), row('a',1.5,3), row(1,3,3)); select row('b',1.5,3) IN (row('b',NULL,3), row('a',1.5,3), row(1,3,3)); select row('b',1.5,3) IN (row('b',NULL,4), row('a',1.5,3), row(1,3,3)); select (1,2,(3,4)) IN ((3,2,(3,4)), (1,2,(3,4))); --- error 1240 +-- error 1241 select row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,4)); select row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,row(3,NULL))); explain extended select row(1,2,row(3,4)) IN (row(3,2,row(3,4)), row(1,2,row(3,NULL))); @@ -37,12 +37,12 @@ SELECT ROW(NULL,2,3)=ROW(NULL,2,3); SELECT ROW(NULL,2,3)<=>ROW(NULL,2,3); SELECT ROW(1,2,ROW(3,4,5))=ROW(1,2,ROW(3,4,5)); SELECT ROW('test',2,3.33)=ROW('test',2,3.33); --- error 1240 +-- error 1241 SELECT ROW('test',2,3.33)=ROW('test',2,3.33,4); SELECT ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,33)); SELECT ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,3)); SELECT ROW('test',2,ROW(3,33))=ROW('test',2,ROW(3,NULL)); --- error 1240 +-- error 1241 SELECT ROW('test',2,ROW(3,33))=ROW('test',2,4); create table t1 ( a int, b int, c int); @@ -56,15 +56,15 @@ select ROW(a,b,c) IN(row(1,2,3), row(3,2,1)) from t1; select ROW(1,2,3) IN(row(a,b,c), row(1,2,3)) from t1; drop table t1; --- error 1240 +-- error 1241 select ROW(1,1); create table t1 (i int); --- error 1240 +-- error 1241 select 1 from t1 where ROW(1,1); --- error 1240 +-- error 1241 select count(*) from t1 order by ROW(1,1); --- error 1240 +-- error 1241 select count(*) from t1 having (1,1) order by i; drop table t1; diff --git a/mysql-test/t/rpl_until.test b/mysql-test/t/rpl_until.test index 40d36110296..5eaec0727b6 100644 --- a/mysql-test/t/rpl_until.test +++ b/mysql-test/t/rpl_until.test @@ -67,15 +67,15 @@ real_sleep 4 show slave status; #testing various error conditions ---error 1276 +--error 1277 start slave until master_log_file='master-bin', master_log_pos=561; ---error 1276 +--error 1277 start slave until master_log_file='master-bin.000001', master_log_pos=561, relay_log_pos=12; ---error 1276 +--error 1277 start slave until master_log_file='master-bin.000001'; ---error 1276 +--error 1277 start slave until relay_log_file='slave-relay-bin.000002'; ---error 1276 +--error 1277 start slave until relay_log_file='slave-relay-bin.000002', master_log_pos=561; start slave sql_thread; diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 6c53c70c9a0..c5e4ce42ffe 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -9,12 +9,12 @@ SELECT (SELECT 1) UNION SELECT (SELECT 2); explain extended SELECT (SELECT 1) UNION SELECT (SELECT 2); SELECT (SELECT (SELECT 0 UNION SELECT 0)); explain extended SELECT (SELECT (SELECT 0 UNION SELECT 0)); --- error 1246 +-- error 1247 SELECT (SELECT 1 FROM (SELECT 1) as b HAVING a=1) as a; --- error 1246 +-- error 1247 SELECT (SELECT 1 FROM (SELECT 1) as b HAVING b=1) as a,(SELECT 1 FROM (SELECT 1) as c HAVING a=1) as b; SELECT (SELECT 1),MAX(1) FROM (SELECT 1) as a; --- error 1246 +-- error 1247 SELECT (SELECT a) as a; EXPLAIN EXTENDED SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1; SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1; @@ -24,7 +24,7 @@ SELECT 1 as a FROM (SELECT 1) as b HAVING (SELECT a)=1; -- error 1054 SELECT 1 FROM (SELECT (SELECT a) b) c; SELECT * FROM (SELECT 1 as id) b WHERE id IN (SELECT * FROM (SELECT 1 as id) c ORDER BY id); --- error 1240 +-- error 1241 SELECT * FROM (SELECT 1) a WHERE 1 IN (SELECT 1,1); SELECT 1 IN (SELECT 1); SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a)); @@ -51,7 +51,7 @@ SELECT (SELECT 'b',2,'a') = ROW(1.5,2,'a'); SELECT (SELECT 1.5,2,'a') = ROW(1.5,'c','a'); SELECT (SELECT 1.5,'c','a') = ROW(1.5,2,'a'); --- error 1240 +-- error 1241 SELECT (SELECT * FROM (SELECT 'test' a,'test' b) a); SELECT 1 as a,(SELECT a+a) b,(SELECT b); @@ -63,7 +63,7 @@ create table t4 (a int not null, b int not null); insert into t1 values (2); insert into t2 values (1,7),(2,7); insert into t4 values (4,8),(3,8),(5,9); --- error 1246 +-- error 1247 select (select a from t1 where t1.a = a1) as a2, (select b from t2 where t2.b=a2) as a1; select (select a from t1 where t1.a=t2.a), a from t2; select (select a from t1 where t1.a=t2.b), a from t2; @@ -103,9 +103,9 @@ select * from t3 where a >= any (select b from t2); explain extended select * from t3 where a >= any (select b from t2); select * from t3 where a >= all (select b from t2); delete from t2 where a=100; --- error 1240 +-- error 1241 select * from t3 where a in (select a,b from t2); --- error 1240 +-- error 1241 select * from t3 where a in (select * from t2); insert into t4 values (12,7),(1,7),(10,9),(9,6),(7,6),(3,9),(1,10); -- empty set @@ -121,7 +121,7 @@ select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) insert into t5 values (2); select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2; explain extended select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2; --- error 1241 +-- error 1242 select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2; create table t6 (patient_uq int, clinic_uq int, index i1 (clinic_uq)); create table t7( uq int primary key, name char(25)); @@ -158,14 +158,14 @@ INSERT INTO t8 (pseudo,email) VALUES ('joce','test'); INSERT INTO t8 (pseudo,email) VALUES ('joce1','test1'); INSERT INTO t8 (pseudo,email) VALUES ('2joce1','2test1'); EXPLAIN EXTENDED SELECT pseudo,(SELECT email FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce')) FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'); --- error 1240 +-- error 1241 SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo,email FROM t8 WHERE pseudo='joce'); --- error 1240 +-- error 1241 SELECT pseudo FROM t8 WHERE pseudo=(SELECT * FROM t8 WHERE pseudo='joce'); SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo='joce'); --- error 1241 +-- error 1242 SELECT pseudo FROM t8 WHERE pseudo=(SELECT pseudo FROM t8 WHERE pseudo LIKE '%joce%'); drop table if exists t1,t2,t3,t4,t5,t6,t7,t8; @@ -185,7 +185,7 @@ EXPLAIN EXTENDED SELECT (SELECT DISTINCT date FROM t1 WHERE date='2002-08-03'); SELECT DISTINCT date FROM t1 WHERE date='2002-08-03'; SELECT (SELECT DISTINCT date FROM t1 WHERE date='2002-08-03'); SELECT 1 FROM t1 WHERE 1=(SELECT 1 UNION SELECT 1) UNION ALL SELECT 1; --- error 1241 +-- error 1242 SELECT 1 FROM t1 WHERE 1=(SELECT 1 UNION ALL SELECT 1) UNION SELECT 1; EXPLAIN EXTENDED SELECT 1 FROM t1 WHERE 1=(SELECT 1 UNION SELECT 1); drop table t1; @@ -242,9 +242,9 @@ CREATE TABLE `t1` ( ) ENGINE=MyISAM ROW_FORMAT=FIXED; INSERT INTO t1 (numeropost,maxnumrep) VALUES (1,0),(2,1); --- error 1241 +-- error 1242 select numeropost as a FROM t1 GROUP BY (SELECT 1 FROM t1 HAVING a=1); --- error 1241 +-- error 1242 select numeropost as a FROM t1 ORDER BY (SELECT 1 FROM t1 HAVING a=1); drop table t1; @@ -256,7 +256,7 @@ drop table t1; #iftest CREATE TABLE t1 (field char(1) NOT NULL DEFAULT 'b'); INSERT INTO t1 VALUES (); --- error 1241 +-- error 1242 SELECT field FROM t1 WHERE 1=(SELECT 1 UNION ALL SELECT 1 FROM (SELECT 1) a HAVING field='b'); drop table t1; @@ -269,13 +269,13 @@ CREATE TABLE `t1` ( UNIQUE KEY `numreponse` (`numreponse`), KEY `pseudo` (`pseudo`,`numeropost`) ) ENGINE=MyISAM; --- error 1246 +-- error 1247 SELECT (SELECT numeropost FROM t1 HAVING numreponse=a),numreponse FROM (SELECT * FROM t1) as a; -- error 1054 SELECT numreponse, (SELECT numeropost FROM t1 HAVING numreponse=a) FROM (SELECT * FROM t1) as a; SELECT numreponse, (SELECT numeropost FROM t1 HAVING numreponse=1) FROM (SELECT * FROM t1) as a; INSERT INTO t1 (numeropost,numreponse,pseudo) VALUES (1,1,'joce'),(1,2,'joce'),(1,3,'test'); --- error 1241 +-- error 1242 EXPLAIN EXTENDED SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT 1 FROM t1 WHERE numeropost='1'); EXPLAIN EXTENDED SELECT MAX(numreponse) FROM t1 WHERE numeropost='1'; EXPLAIN EXTENDED SELECT numreponse FROM t1 WHERE numeropost='1' AND numreponse=(SELECT MAX(numreponse) FROM t1 WHERE numeropost='1'); @@ -294,7 +294,7 @@ insert into t2 values (1, 21),(2, 22),(3, 23); select * from t1; -- error 1093 update t1 set b= (select b from t1); --- error 1241 +-- error 1242 update t1 set b= (select b from t2); update t1 set b= (select b from t2 where t1.a = t2.a); select * from t1; @@ -309,7 +309,7 @@ select * from t1; select * from t1 where b = (select b from t2 where t1.a = t2.a); -- error 1093 delete from t1 where b = (select b from t1); --- error 1241 +-- error 1242 delete from t1 where b = (select b from t2); delete from t1 where b = (select b from t2 where t1.a = t2.a); select * from t1; @@ -327,7 +327,7 @@ select * from t11; select * from t12; -- error 1093 delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t12 where t11.a = t12.a); --- error 1241 +-- error 1242 delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2); delete t11.*, t12.* from t11,t12 where t11.a = t12.a and t11.b = (select b from t2 where t11.a = t2.a); select * from t11; @@ -342,7 +342,7 @@ insert into t2 values (1); insert into t3 values (1),(2); -- error 1093 INSERT INTO t1 (x) VALUES ((SELECT x FROM t1)); --- error 1241 +-- error 1242 INSERT INTO t1 (x) VALUES ((SELECT b FROM t3)); INSERT INTO t1 (x) VALUES ((SELECT a FROM t2)); select * from t1; @@ -373,7 +373,7 @@ insert into t3 values (1),(2); select * from t1; -- error 1093 replace into t1 (x, y) VALUES ((SELECT x FROM t1), (SELECT a+1 FROM t2)); --- error 1241 +-- error 1242 replace into t1 (x, y) VALUES ((SELECT a FROM t3), (SELECT a+1 FROM t2)); replace into t1 (x, y) VALUES ((SELECT a FROM t2), (SELECT a+1 FROM t2)); select * from t1; @@ -409,7 +409,7 @@ INSERT INTO t2 VALUES ((SELECT id FROM t2)); SELECT * FROM t2; CREATE TABLE t1 (id int(11) default NULL, KEY id (id)) ENGINE=MyISAM CHARSET=latin1; INSERT INTO t1 values (1),(1); --- error 1241 +-- error 1242 UPDATE t2 SET id=(SELECT * FROM t1); drop table t2, t1; @@ -867,9 +867,9 @@ DROP TABLE t1, t2; CREATE TABLE t1 (s1 CHAR(5) COLLATE latin1_german1_ci, s2 CHAR(5) COLLATE latin1_swedish_ci); INSERT INTO t1 VALUES ('z','?'); --- error 1266 +-- error 1267 select * from t1 where s1 > (select max(s2) from t1); --- error 1266 +-- error 1267 select * from t1 where s1 > any (select max(s2) from t1); drop table t1; @@ -887,7 +887,7 @@ drop table t1, t2; # row union # create table t1 (s1 char(5)); --- error 1240 +-- error 1241 select (select 'a','b' from t1 union select 'a','b' from t1) from t1; insert into t1 values ('tttt'); select * from t1 where ('a','b')=(select 'a','b' from t1 union select 'a','b' from t1); @@ -952,7 +952,7 @@ CREATE TABLE t1 (id int(11) default NULL) ENGINE=MyISAM CHARSET=latin1; INSERT INTO t1 VALUES (1),(5); CREATE TABLE t2 (id int(11) default NULL) ENGINE=MyISAM CHARSET=latin1; INSERT INTO t2 VALUES (2),(6); --- error 1240 +-- error 1241 select * from t1 where (1,2,6) in (select * from t2); DROP TABLE t1,t2; @@ -962,7 +962,7 @@ DROP TABLE t1,t2; create table t1 (s1 int); insert into t1 values (1); insert into t1 values (2); --- error 1241 +-- error 1242 set sort_buffer_size = (select s1 from t1); do (select * from t1); drop table t1; diff --git a/mysql-test/t/subselect_innodb.test b/mysql-test/t/subselect_innodb.test index 8e8d41f7653..47642832158 100644 --- a/mysql-test/t/subselect_innodb.test +++ b/mysql-test/t/subselect_innodb.test @@ -67,7 +67,7 @@ INSERT INTO t1 VALUES (1),(2),(3); INSERT INTO t3 VALUES (1,1),(2,2),(3,3); INSERT INTO t2 VALUES (1,1),(2,2),(3,3); SELECT distinct p1.processor_id, (SELECT y.yod_id FROM t1 p2, t2 y WHERE p2.processor_id = p1.processor_id and p2.processor_id = y.processor_id) FROM t1 p1; -drop table t1,t2,t3; +drop table t2,t1,t3; # # innodb locking diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index 8ce4aa997fc..55f53fb4c17 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -23,7 +23,7 @@ select 't1',b,count(*) from t1 group by b UNION select 't2',b,count(*) from t2 g (select a,b from t1 limit 2) union all (select a,b from t2 order by a) limit 4; (select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1); (select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by b desc; ---error 1249 +--error 1250 (select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by t1.b; explain extended (select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by b desc; (select sql_calc_found_rows a,b from t1 limit 2) union all (select a,b from t2 order by a) limit 2; @@ -420,7 +420,7 @@ create table t1 select 1 union select -1; select * from t1; show create table t1; drop table t1; --- error 1266 +-- error 1267 create table t1 select _latin1"test" union select _latin2"testt" ; create table t1 select _latin2"test" union select _latin2"testt" ; show create table t1; diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test index 32ed6fe33db..a28b327cf58 100644 --- a/mysql-test/t/user_var.test +++ b/mysql-test/t/user_var.test @@ -84,7 +84,7 @@ select @a=_latin2'TEST' collate latin2_bin; set @a=_latin2'test' collate latin2_general_ci; select charset(@a),collation(@a),coercibility(@a); select @a=_latin2'TEST'; ---error 1266 +--error 1267 select @a=_latin2'TEST' collate latin2_bin; # @@ -97,5 +97,5 @@ select collation(@a:=_latin2'test' collate latin2_bin); select coercibility(@a:=_latin2'test' collate latin2_bin); select (@a:=_latin2'test' collate latin2_bin) = _latin2'TEST'; select charset(@a),collation(@a),coercibility(@a); ---error 1266 +--error 1267 select (@a:=_latin2'test' collate latin2_bin) = _latin2'TEST' collate latin2_general_ci; diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index 2fec3535739..05ac0427a92 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -124,7 +124,7 @@ set big_tables="OFFF"; set unknown_variable=1; --error 1232 set max_join_size="hello"; ---error 1285 +--error 1286 set storage_engine=UNKNOWN_TABLE_TYPE; --error 1231 set storage_engine=INNODB, big_tables=2; @@ -135,7 +135,7 @@ set SESSION query_cache_size=10000; set GLOBAL storage_engine=DEFAULT; --error 1115 set character_set_client=UNKNOWN_CHARACTER_SET; ---error 1272 +--error 1273 set collation_connection=UNKNOWN_COLLATION; --error 1228 set global autocommit=1; @@ -285,4 +285,3 @@ select @@global.max_user_connections,@@local.max_join_size; set @a=1, @b=2; set @a=@b, @b=@a; select @a, @b; - diff --git a/mysys/my_handler.c b/mysys/my_handler.c index 6ee6167d3c1..190c279aadf 100644 --- a/mysys/my_handler.c +++ b/mysys/my_handler.c @@ -9,7 +9,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - + You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, @@ -184,12 +184,14 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a, break; case HA_KEYTYPE_VARTEXT: { - int a_length,b_length,pack_length; + int a_length,full_a_length,b_length,full_b_length,pack_length; get_key_length(a_length,a); get_key_pack_length(b_length,pack_length,b); + full_a_length= a_length; + full_b_length= b_length; next_key_length=key_length-b_length-pack_length; - if (!(nextflag & (SEARCH_PREFIX | SEARCH_UPDATE))) + if ((nextflag & (SEARCH_FIND | SEARCH_UPDATE)) == SEARCH_FIND) { while (a_length && a[a_length-1] == ' ') a_length--; @@ -202,8 +204,8 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a, (my_bool) ((nextflag & SEARCH_PREFIX) && next_key_length <= 0)))) return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag); - a+=a_length; - b+=b_length; + a+= full_a_length; + b+= full_b_length; break; } break; @@ -308,7 +310,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a, if (keyseg->flag & HA_REVERSE_SORT) { - swap(uchar*,a,b); + swap(uchar*,a,b); swap_flag=1; /* Remember swap of a & b */ end= a+ (int) (end-b); } diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc index 656224d4a7a..807b6e35a29 100644 --- a/sql/ha_heap.cc +++ b/sql/ha_heap.cc @@ -38,7 +38,10 @@ int ha_heap::open(const char *name, int mode, uint test_if_locked) HA_CREATE_INFO create_info; bzero(&create_info, sizeof(create_info)); if (!create(name, table, &create_info)) + { file= heap_open(name, mode); + implicit_emptied= 1; + } } ref_length= sizeof(HEAP_PTR); return (file ? 0 : 1); @@ -174,7 +177,6 @@ void ha_heap::info(uint flag) index_file_length=info.index_length; max_data_file_length= info.max_records* info.reclength; delete_length= info.deleted * info.reclength; - implicit_emptied= info.implicit_emptied; if (flag & HA_STATUS_AUTO) auto_increment_value= info.auto_increment; } diff --git a/sql/handler.cc b/sql/handler.cc index afeec26f034..5aa3967edb6 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -657,7 +657,7 @@ int ha_delete_table(enum db_type table_type, const char *path) { /* Ensure that table handler get path in lower case */ strmov(tmp_path, path); - casedn_str(tmp_path); + my_casedn_str(system_charset_info, tmp_path); path= tmp_path; } int error=file->delete_table(path); @@ -1159,7 +1159,7 @@ int ha_create_table(const char *name, HA_CREATE_INFO *create_info, { /* Ensure that handler gets name in lower case */ strmov(name_buff, name); - casedn_str(name_buff); + my_casedn_str(system_charset_info, name_buff); name= name_buff; } diff --git a/sql/item.cc b/sql/item.cc index 4d06d0d7765..b9a6a164a86 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -175,12 +175,13 @@ bool Item::eq(const Item *item, bool binary_cmp) const !my_strcasecmp(system_charset_info,name,item->name); } + bool Item_string::eq(const Item *item, bool binary_cmp) const { if (type() == item->type()) { if (binary_cmp) - return !sortcmp(&str_value, &item->str_value, &my_charset_bin); + return !stringcmp(&str_value, &item->str_value); return !sortcmp(&str_value, &item->str_value, collation.collation); } return 0; @@ -1823,7 +1824,7 @@ bool field_is_equal_to_item(Field *field,Item *item) if (item->null_value) return 1; // This must be true field->val_str(&field_tmp,&field_tmp); - return !sortcmp(&field_tmp,item_result,&my_charset_bin); + return !stringcmp(&field_tmp,item_result); } if (res_type == INT_RESULT) return 1; // Both where of type int diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 4046a4d6414..1bba934cf8f 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -293,6 +293,17 @@ int Arg_comparator::set_compare_func(Item_bool_func2 *item, Item_result type) my_coll_agg_error((*a)->collation, (*b)->collation, owner->func_name()); return 1; } + if (my_binary_compare(cmp_collation.collation)) + { + /* + We are using binary collation, change to compare byte by byte, + without removing end space + */ + if (func == &Arg_comparator::compare_string) + func= &Arg_comparator::compare_binary_string; + else if (func == &Arg_comparator::compare_e_string) + func= &Arg_comparator::compare_e_binary_string; + } } return 0; } @@ -313,6 +324,39 @@ int Arg_comparator::compare_string() return -1; } + +/* + Compare strings byte by byte. End spaces are also compared. + + RETURN + < 0 *a < *b + 0 *b == *b + > 0 *a > *b +*/ + +int Arg_comparator::compare_binary_string() +{ + String *res1,*res2; + if ((res1= (*a)->val_str(&owner->tmp_value1))) + { + if ((res2= (*b)->val_str(&owner->tmp_value2))) + { + owner->null_value= 0; + uint res1_length= res1->length(); + uint res2_length= res2->length(); + int cmp= memcmp(res1->ptr(), res2->ptr(), min(res1_length,res2_length)); + return cmp ? cmp : (int) (res1_length - res2_length); + } + } + owner->null_value= 1; + return -1; +} + + +/* + Compare strings, but take into account that NULL == NULL +*/ + int Arg_comparator::compare_e_string() { String *res1,*res2; @@ -324,6 +368,17 @@ int Arg_comparator::compare_e_string() } +int Arg_comparator::compare_e_binary_string() +{ + String *res1,*res2; + res1= (*a)->val_str(&owner->tmp_value1); + res2= (*b)->val_str(&owner->tmp_value2); + if (!res1 || !res2) + return test(res1 == res2); + return test(stringcmp(res1, res2) == 0); +} + + int Arg_comparator::compare_real() { double val1= (*a)->val(); @@ -2132,7 +2187,7 @@ longlong Item_func_regex::val_int() null_value=1; return 0; } - if (!regex_compiled || sortcmp(res2,&prev_regexp,&my_charset_bin)) + if (!regex_compiled || stringcmp(res2,&prev_regexp)) { prev_regexp.copy(*res2); if (regex_compiled) diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 4e9628c8db9..3c70a50502a 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -63,10 +63,12 @@ public: inline int compare() { return (this->*func)(); } int compare_string(); // compare args[0] & args[1] + int compare_binary_string(); // compare args[0] & args[1] int compare_real(); // compare args[0] & args[1] int compare_int(); // compare args[0] & args[1] int compare_row(); // compare args[0] & args[1] int compare_e_string(); // compare args[0] & args[1] + int compare_e_binary_string(); // compare args[0] & args[1] int compare_e_real(); // compare args[0] & args[1] int compare_e_int(); // compare args[0] & args[1] int compare_e_row(); // compare args[0] & args[1] diff --git a/sql/log_event.cc b/sql/log_event.cc index 84757a0a1f2..f64f740da30 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1,4 +1,4 @@ -/* Copyright (C) 2000-2003 MySQL AB +/* Copyright (C) 2000-2004 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -290,6 +290,8 @@ Log_event::Log_event(const char* buf, bool old_format) int Log_event::exec_event(struct st_relay_log_info* rli) { + DBUG_ENTER("Log_event::exec_event"); + /* rli is null when (as far as I (Guilhem) know) the caller is @@ -342,7 +344,7 @@ int Log_event::exec_event(struct st_relay_log_info* rli) rli->last_master_timestamp= when; } } - return 0; + DBUG_RETURN(0); } @@ -592,11 +594,13 @@ Error in Log_event::read_log_event(): '%s', data_len: %d, event_type: %d", Log_event* Log_event::read_log_event(const char* buf, int event_len, const char **error, bool old_format) { + DBUG_ENTER("Log_event::read_log_event"); + if (event_len < EVENT_LEN_OFFSET || (uint) event_len != uint4korr(buf+EVENT_LEN_OFFSET)) { *error="Sanity check failed"; // Needed to free buffer - return NULL; // general sanity check - will fail on a partial read + DBUG_RETURN(NULL); // general sanity check - will fail on a partial read } Log_event* ev = NULL; @@ -658,16 +662,16 @@ Log_event* Log_event::read_log_event(const char* buf, int event_len, if (!force_opt) { *error= "Found invalid event in binary log"; - return 0; + DBUG_RETURN(0); } ev= new Unknown_log_event(buf, old_format); #else *error= "Found invalid event in binary log"; - return 0; + DBUG_RETURN(0); #endif } ev->cached_event_len = event_len; - return ev; + DBUG_RETURN(ev); } #ifdef MYSQL_CLIENT @@ -1249,38 +1253,21 @@ void Load_log_event::pack_info(Protocol *protocol) memcpy(pos, table_name, table_name_len); pos+= table_name_len; - if (sql_ex.field_term_len) - { - pos= strmov(pos, " FIELDS TERMINATED BY "); - pos= pretty_print_str(pos, sql_ex.field_term, sql_ex.field_term_len); - } + /* We have to create all optinal fields as the default is not empty */ + pos= strmov(pos, " FIELDS TERMINATED BY "); + pos= pretty_print_str(pos, sql_ex.field_term, sql_ex.field_term_len); + if (sql_ex.opt_flags & OPT_ENCLOSED_FLAG) + pos= strmov(pos, " OPTIONALLY "); + pos= strmov(pos, " ENCLOSED BY "); + pos= pretty_print_str(pos, sql_ex.enclosed, sql_ex.enclosed_len); - if (sql_ex.enclosed_len) - { - if (sql_ex.opt_flags & OPT_ENCLOSED_FLAG) - pos= strmov(pos, " OPTIONALLY "); - pos= strmov(pos, " ENCLOSED BY "); - pos= pretty_print_str(pos, sql_ex.enclosed, sql_ex.enclosed_len); - } - - if (sql_ex.escaped_len) - { - pos= strmov(pos, " ESCAPED BY "); - pos= pretty_print_str(pos, sql_ex.escaped, sql_ex.escaped_len); - } - - bool line_lexem_added= false; - if (sql_ex.line_term_len) - { - pos= strmov(pos, " LINES TERMINATED BY "); - pos= pretty_print_str(pos, sql_ex.line_term, sql_ex.line_term_len); - line_lexem_added= true; - } + pos= strmov(pos, " ESCAPED BY "); + pos= pretty_print_str(pos, sql_ex.escaped, sql_ex.escaped_len); + pos= strmov(pos, " LINES TERMINATED BY "); + pos= pretty_print_str(pos, sql_ex.line_term, sql_ex.line_term_len); if (sql_ex.line_start_len) { - if (!line_lexem_added) - pos= strmov(pos," LINES"); pos= strmov(pos, " STARTING BY "); pos= pretty_print_str(pos, sql_ex.line_start, sql_ex.line_start_len); } @@ -1455,9 +1442,10 @@ Load_log_event::Load_log_event(const char *buf, int event_len, field_lens(0), field_block_len(0), table_name(0), db(0), fname(0), local_fname(FALSE) { - if (!event_len) // derived class, will call copy_log_event() itself - return; - copy_log_event(buf, event_len, old_format); + DBUG_ENTER("Load_log_event"); + if (event_len) // derived class, will call copy_log_event() itself + copy_log_event(buf, event_len, old_format); + DBUG_VOID_RETURN; } @@ -1472,6 +1460,8 @@ int Load_log_event::copy_log_event(const char *buf, ulong event_len, char* buf_end = (char*)buf + event_len; uint header_len= old_format ? OLD_HEADER_LEN : LOG_EVENT_HEADER_LEN; const char* data_head = buf + header_len; + DBUG_ENTER("Load_log_event::copy_log_event"); + slave_proxy_id= thread_id= uint4korr(data_head + L_THREAD_ID_OFFSET); exec_time = uint4korr(data_head + L_EXEC_TIME_OFFSET); skip_lines = uint4korr(data_head + L_SKIP_LINES_OFFSET); @@ -1484,19 +1474,19 @@ int Load_log_event::copy_log_event(const char *buf, ulong event_len, get_data_body_offset()); if ((int) event_len < body_offset) - return 1; + DBUG_RETURN(1); /* Sql_ex.init() on success returns the pointer to the first byte after the sql_ex structure, which is the start of field lengths array. */ if (!(field_lens=(uchar*)sql_ex.init((char*)buf + body_offset, - buf_end, - buf[EVENT_TYPE_OFFSET] != LOAD_EVENT))) - return 1; - + buf_end, + buf[EVENT_TYPE_OFFSET] != LOAD_EVENT))) + DBUG_RETURN(1); + data_len = event_len - body_offset; if (num_fields > data_len) // simple sanity check against corruption - return 1; + DBUG_RETURN(1); for (uint i = 0; i < num_fields; i++) field_block_len += (uint)field_lens[i] + 1; @@ -1506,7 +1496,7 @@ int Load_log_event::copy_log_event(const char *buf, ulong event_len, fname = db + db_len + 1; fname_len = strlen(fname); // null termination is accomplished by the caller doing buf[event_len]=0 - return 0; + DBUG_RETURN(0); } @@ -1524,6 +1514,7 @@ void Load_log_event::print(FILE* file, bool short_form, char* last_db) void Load_log_event::print(FILE* file, bool short_form, char* last_db, bool commented) { + DBUG_ENTER("Load_log_event::print"); if (!short_form) { print_header(file); @@ -1555,42 +1546,26 @@ void Load_log_event::print(FILE* file, bool short_form, char* last_db, fprintf(file," IGNORE "); fprintf(file, "INTO TABLE %s ", table_name); - if (sql_ex.field_term) - { - fprintf(file, " FIELDS TERMINATED BY "); - pretty_print_str(file, sql_ex.field_term, sql_ex.field_term_len); - } + fprintf(file, " FIELDS TERMINATED BY "); + pretty_print_str(file, sql_ex.field_term, sql_ex.field_term_len); - if (sql_ex.enclosed) - { - if (sql_ex.opt_flags & OPT_ENCLOSED_FLAG) - fprintf(file," OPTIONALLY "); - fprintf(file, " ENCLOSED BY "); - pretty_print_str(file, sql_ex.enclosed, sql_ex.enclosed_len); - } + if (sql_ex.opt_flags & OPT_ENCLOSED_FLAG) + fprintf(file," OPTIONALLY "); + fprintf(file, " ENCLOSED BY "); + pretty_print_str(file, sql_ex.enclosed, sql_ex.enclosed_len); - if (sql_ex.escaped) - { - fprintf(file, " ESCAPED BY "); - pretty_print_str(file, sql_ex.escaped, sql_ex.escaped_len); - } + fprintf(file, " ESCAPED BY "); + pretty_print_str(file, sql_ex.escaped, sql_ex.escaped_len); - bool line_lexem_added= false; - if (sql_ex.line_term) - { - fprintf(file," LINES TERMINATED BY "); - pretty_print_str(file, sql_ex.line_term, sql_ex.line_term_len); - line_lexem_added= true; - } + fprintf(file," LINES TERMINATED BY "); + pretty_print_str(file, sql_ex.line_term, sql_ex.line_term_len); + if (sql_ex.line_start) { - if (!line_lexem_added) - fprintf(file," LINES"); fprintf(file," STARTING BY "); pretty_print_str(file, sql_ex.line_start, sql_ex.line_start_len); } - if ((long) skip_lines > 0) fprintf(file, " IGNORE %ld LINES", (long) skip_lines); @@ -1611,6 +1586,7 @@ void Load_log_event::print(FILE* file, bool short_form, char* last_db, } fprintf(file, ";\n"); + DBUG_VOID_RETURN; } #endif /* MYSQL_CLIENT */ @@ -1877,8 +1853,11 @@ Rotate_log_event::Rotate_log_event(const char* buf, int event_len, // The caller will ensure that event_len is what we have at EVENT_LEN_OFFSET int header_size = (old_format) ? OLD_HEADER_LEN : LOG_EVENT_HEADER_LEN; uint ident_offset; + DBUG_ENTER("Rotate_log_event"); + if (event_len < header_size) - return; + DBUG_VOID_RETURN; + buf += header_size; if (old_format) { @@ -1897,8 +1876,9 @@ Rotate_log_event::Rotate_log_event(const char* buf, int event_len, ident_offset, (uint) ident_len, MYF(MY_WME)))) - return; + DBUG_VOID_RETURN; alloced = 1; + DBUG_VOID_RETURN; } @@ -2593,7 +2573,9 @@ Create_file_log_event(THD* thd_arg, sql_exchange* ex, fake_base(0),block(block_arg),block_len(block_len_arg), file_id(thd_arg->file_id = mysql_bin_log.next_file_id()) { + DBUG_ENTER("Create_file_log_event"); sql_ex.force_new_format(); + DBUG_VOID_RETURN; } #endif /* !MYSQL_CLIENT */ @@ -2650,8 +2632,10 @@ Create_file_log_event::Create_file_log_event(const char* buf, int len, :Load_log_event(buf,0,old_format),fake_base(0),block(0),inited_from_old(0) { int block_offset; + DBUG_ENTER("Create_file_log_event"); + if (copy_log_event(buf,len,old_format)) - return; + DBUG_VOID_RETURN; if (!old_format) { file_id = uint4korr(buf + LOG_EVENT_HEADER_LEN + @@ -2669,6 +2653,7 @@ Create_file_log_event::Create_file_log_event(const char* buf, int len, sql_ex.force_new_format(); inited_from_old = 1; } + DBUG_VOID_RETURN; } @@ -2821,11 +2806,13 @@ Append_block_log_event::Append_block_log_event(THD* thd_arg, const char* db_arg, Append_block_log_event::Append_block_log_event(const char* buf, int len) :Log_event(buf, 0),block(0) { + DBUG_ENTER("Append_block_log_event"); if ((uint)len < APPEND_BLOCK_EVENT_OVERHEAD) - return; + DBUG_VOID_RETURN; file_id = uint4korr(buf + LOG_EVENT_HEADER_LEN + AB_FILE_ID_OFFSET); block = (char*)buf + APPEND_BLOCK_EVENT_OVERHEAD; block_len = len - APPEND_BLOCK_EVENT_OVERHEAD; + DBUG_VOID_RETURN; } @@ -2888,6 +2875,7 @@ int Append_block_log_event::exec_event(struct st_relay_log_info* rli) char *p= slave_load_file_stem(fname, file_id, server_id); int fd; int error = 1; + DBUG_ENTER("Append_block_log_event::exec_event"); memcpy(p, ".data", 6); if ((fd = my_open(fname, O_WRONLY|O_APPEND|O_BINARY, MYF(MY_WME))) < 0) @@ -2905,7 +2893,7 @@ int Append_block_log_event::exec_event(struct st_relay_log_info* rli) err: if (fd >= 0) my_close(fd, MYF(0)); - return error ? error : Log_event::exec_event(rli); + DBUG_RETURN(error ? error : Log_event::exec_event(rli)); } #endif diff --git a/sql/opt_range.cc b/sql/opt_range.cc index d1f42ac865e..1dbe883aef4 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -1064,8 +1064,8 @@ get_mm_leaf(PARAM *param, COND *conf_func, Field *field, KEY_PART *key_part, like_error= my_like_range(field->charset(), res->ptr(), res->length(), - ((Item_func_like*)(param->cond))->escape - wild_prefix, wild_one, wild_many, + ((Item_func_like*)(param->cond))->escape, + wild_one, wild_many, field_length, min_str+offset, max_str+offset, &min_length, &max_length); diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 7a1fd091e7c..0323e90a166 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -363,7 +363,7 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) { /* Convert database to lower case */ strmov(tmp_db, db); - casedn_str(tmp_db); + my_casedn_str(system_charset_info, tmp_db); db= tmp_db; } diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index 6db97ab3c41..d0f241b3291 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -288,12 +288,12 @@ static TABLE **find_table_ptr_by_name(THD *thd, const char *db, TABLE **ptr; DBUG_ASSERT(db); - dblen= *db ? strlen(db)+1 : 0; + dblen= strlen(db); ptr= &(thd->handler_tables); for (TABLE *table= *ptr; table ; table= *ptr) { - if ((!dblen || !memcmp(table->table_cache_key, db, dblen)) && + if ((db == any_db || !memcmp(table->table_cache_key, db, dblen)) && !my_strcasecmp(system_charset_info, (is_alias ? table->table_name : table->real_name), table_name)) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index f7bbfdae2b3..dd68337d5dd 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1451,7 +1451,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd, my_casedn_str(files_charset_info, table_list.real_name); remove_escape(table_list.real_name); // This can't have wildcards - if (check_access(thd,SELECT_ACL,table_list.db,&table_list.grant.privilege)) + if (check_access(thd,SELECT_ACL,table_list.db,&table_list.grant.privilege, + 0, 0)) break; if (grant_option && check_grant(thd,SELECT_ACL,&table_list,2,0)) break; @@ -1771,7 +1772,7 @@ mysql_execute_command(THD *thd) */ if (table_rules_on && tables && !tables_ok(thd,tables) && ((lex->sql_command != SQLCOM_DELETE_MULTI) || - !tables_ok(thd,(TABLE_LIST *)thd->lex.auxilliary_table_list.first))) + !tables_ok(thd,(TABLE_LIST *)thd->lex->auxilliary_table_list.first))) { /* we warn the slave SQL thread */ my_error(ER_SLAVE_IGNORED_TABLE, MYF(0)); @@ -2103,7 +2104,7 @@ mysql_execute_command(THD *thd) ulong want_priv= ((lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) ? CREATE_TMP_ACL : CREATE_ACL); - lex->create_info.alias= tables->alias; + lex->create_info.alias= create_table->alias; if (check_access(thd, want_priv, create_table->db, &create_table->grant.privilege, 0, 0) || check_merge_table_access(thd, create_table->db, @@ -2872,7 +2873,7 @@ mysql_execute_command(THD *thd) remove_escape(db); // Fix escaped '_' remove_escape(tables->real_name); if (check_access(thd,SELECT_ACL | EXTRA_ACL,db, - &tables->grant.privilege)) + &tables->grant.privilege, 0, 0)) goto error; /* purecov: inspected */ if (grant_option && check_grant(thd,SELECT_ACL,tables,2,0)) goto error; @@ -2977,7 +2978,7 @@ mysql_execute_command(THD *thd) if (check_access(thd,CREATE_ACL,lex->name,0,1,0)) break; res= mysql_create_db(thd,(lower_case_table_names == 2 ? alias : lex->name), - lex->create_info.options,0); + &lex->create_info, 0); break; } case SQLCOM_DROP_DB: @@ -3393,7 +3394,7 @@ static int check_one_table_access(THD *thd, ulong privilege, if (subselects_tables) { tables->next= subselects_tables; - if ((*res= check_table_access(thd, SELECT_ACL, subselects_tables,0))) + if ((check_table_access(thd, SELECT_ACL, subselects_tables,0))) return 1; } return 0; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 9cb8bb7b768..592820e6e19 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2864,7 +2864,7 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count, If quick_select was used on a part of this key, we know the maximum number of rows that the key can match. */ - if (table->quick_keys & ((key_map) 1 << key) && + if (table->quick_keys.is_set(key) && table->quick_key_parts[key] <= max_key_part && records > (double) table->quick_rows[key]) tmp= records= (double) table->quick_rows[key]; @@ -6717,8 +6717,11 @@ static bool test_if_ref(Item_field *left_item,Item *right_item) /* We can remove binary fields and numerical fields except float, as float comparison isn't 100 % secure + We have to keep binary strings to be able to check for end spaces */ if (field->binary() && + field->real_type() != FIELD_TYPE_STRING && + field->real_type() != FIELD_TYPE_VAR_STRING && (field->type() != FIELD_TYPE_FLOAT || field->decimals() == 0)) { return !store_val_in_field(field,right_item); @@ -7931,6 +7934,29 @@ int setup_order(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, } +/* + Intitialize the GROUP BY list. + + SYNOPSIS + setup_group() + thd Thread handler + ref_pointer_array We store references to all fields that was not in + 'fields' here. + fields All fields in the select part. Any item in 'order' + that is part of these list is replaced by a pointer + to this fields. + all_fields Total list of all unique fields used by the select. + All items in 'order' that was not part of fields will + be added first to this list. + order The fields we should do GROUP BY on. + hidden_group_fields Pointer to flag that is set to 1 if we added any fields + to all_fields. + + RETURN + 0 ok + 1 error (probably out of memory) +*/ + int setup_group(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables, List &fields, List &all_fields, ORDER *order, diff --git a/sql/sql_string.cc b/sql/sql_string.cc index 422b1ec3b4b..83a048297af 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -699,11 +699,56 @@ void String::qs_append(const char &c) } -int sortcmp(const String *x,const String *y, CHARSET_INFO *cs) +/* + Compare strings according to collation, without end space. + + SYNOPSIS + sortcmp() + s First string + t Second string + cs Collation + + NOTE: + Normally this is case sensitive comparison + + RETURN + < 0 s < t + 0 s == t + > 0 s > t +*/ + + +int sortcmp(const String *s,const String *t, CHARSET_INFO *cs) { return cs->coll->strnncollsp(cs, - (unsigned char *) x->ptr(),x->length(), - (unsigned char *) y->ptr(),y->length()); + (unsigned char *) s->ptr(),s->length(), + (unsigned char *) t->ptr(),t->length()); +} + + +/* + Compare strings byte by byte. End spaces are also compared. + + SYNOPSIS + stringcmp() + s First string + t Second string + + NOTE: + Strings are compared as a stream of unsigned chars + + RETURN + < 0 s < t + 0 s == t + > 0 s > t +*/ + + +int stringcmp(const String *s,const String *t) +{ + uint32 s_len=s->length(),t_len=t->length(),len=min(s_len,t_len); + int cmp= memcmp(s->ptr(), t->ptr(), len); + return (cmp) ? cmp : (int) (s_len - t_len); } diff --git a/sql/sql_string.h b/sql/sql_string.h index 163156fdfe2..cdfb00276d4 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -221,6 +221,7 @@ public: inline void caseup() { my_caseup(str_charset,Ptr,str_length); } inline void casedn() { my_casedn(str_charset,Ptr,str_length); } friend int sortcmp(const String *a,const String *b, CHARSET_INFO *cs); + friend int stringcmp(const String *a,const String *b); friend String *copy_if_not_alloced(String *a,String *b,uint32 arg_length); uint32 numchars(); int charpos(int i,uint32 offset=0); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 922775083d5..12494703419 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1152,11 +1152,11 @@ mysql_rename_table(enum db_type base, { /* Table handler expects to get all file names as lower case */ strmov(tmp_from, old_name); - casedn_str(tmp_from); + my_casedn_str(system_charset_info, tmp_from); old_name= tmp_from; strmov(tmp_to, new_name); - casedn_str(tmp_to); + my_casedn_str(system_charset_info, tmp_to); new_name= tmp_to; } (void) sprintf(from,"%s/%s/%s",mysql_data_home,old_db,old_name); diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 1e702a9517c..977dd2595de 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -439,7 +439,14 @@ int mysql_multi_update(THD *thd, for (tl= table_list ; tl ; tl=tl->next) { TABLE *table= tl->table; - table->grant.want_privilege= (UPDATE_ACL & ~table->grant.privilege); + /* + Update of derived tables is checked later + We don't check privileges here, becasue then we would get error + "UPDATE command denided .. for column N" instead of + "Target table ... is not updatable" + */ + if (!tl->derived) + table->grant.want_privilege= (UPDATE_ACL & ~table->grant.privilege); } if (thd->lex->derived_tables) diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index bd51df8810c..7ef5d219f07 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -4626,8 +4626,8 @@ table_ident: ; table_ident_ref: - ident { LEX_STRING db={"",0}; $$=new Table_ident(db,$1,0); } - | ident '.' ident { $$=new Table_ident($1,$3,0);} + ident { LEX_STRING db={(char*) any_db,3}; $$=new Table_ident(YYTHD, db,$1,0); } + | ident '.' ident { $$=new Table_ident(YYTHD, $1,$3,0);} ; IDENT_sys: diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c index 574156a99ed..1b0a235ed57 100644 --- a/strings/ctype-big5.c +++ b/strings/ctype-big5.c @@ -247,8 +247,8 @@ int my_strnncollsp_big5(CHARSET_INFO * cs, const uchar *s, uint slen, const uchar *t, uint tlen) { - for ( ; slen && my_isspace(cs, s[slen-1]) ; slen--); - for ( ; tlen && my_isspace(cs, t[tlen-1]) ; tlen--); + for ( ; slen && s[slen-1] == ' ' ; slen--); + for ( ; tlen && t[tlen-1] == ' ' ; tlen--); return my_strnncoll_big5(cs,s,slen,t,tlen); } @@ -343,10 +343,10 @@ static int my_strxfrm_big5(uchar * dest, const uchar * src, int len) #define max_sort_char ((char) 255) static my_bool my_like_range_big5(CHARSET_INFO *cs __attribute__((unused)), - const char *ptr,uint ptr_length, - int escape, int w_one, int w_many, - uint res_length, char *min_str,char *max_str, - uint *min_length,uint *max_length) + const char *ptr,uint ptr_length, + pbool escape, pbool w_one, pbool w_many, + uint res_length, char *min_str,char *max_str, + uint *min_length,uint *max_length) { const char *end=ptr+ptr_length; char *min_org=min_str; diff --git a/strings/ctype-bin.c b/strings/ctype-bin.c index fc22938d46e..35382b05c88 100644 --- a/strings/ctype-bin.c +++ b/strings/ctype-bin.c @@ -67,6 +67,28 @@ static uchar bin_char_array[] = }; + +/* + Compare two strings. Result is sign(first_argument - second_argument) + + SYNOPSIS + my_strnncoll_binary() + cs Chararacter set + s String to compare + slen Length of 's' + t String to compare + tlen Length of 't' + + NOTE + This is used also when comparing with end space removal, as end space + is significant for binary strings + + RETURN + < 0 s < t + 0 s == t + > 0 s > t +*/ + static int my_strnncoll_binary(CHARSET_INFO * cs __attribute__((unused)), const uchar *s, uint slen, const uchar *t, uint tlen) @@ -75,59 +97,39 @@ static int my_strnncoll_binary(CHARSET_INFO * cs __attribute__((unused)), return cmp ? cmp : (int) (slen - tlen); } -static int my_strnncollsp_binary(CHARSET_INFO * cs, - const uchar *s, uint slen, - const uchar *t, uint tlen) -{ - int len, cmp; - for ( ; slen && my_isspace(cs, s[slen-1]) ; slen--); - for ( ; tlen && my_isspace(cs, t[tlen-1]) ; tlen--); +/* This function is used for all conversion functions */ - len = ( slen > tlen ) ? tlen : slen; - - cmp= memcmp(s,t,len); - return cmp ? cmp : (int) (slen - tlen); -} - -static void my_caseup_str_bin(CHARSET_INFO *cs __attribute__((unused)), - char *str __attribute__((unused))) +static void my_case_str_bin(CHARSET_INFO *cs __attribute__((unused)), + char *str __attribute__((unused))) { } -static void my_casedn_str_bin(CHARSET_INFO * cs __attribute__((unused)), - char *str __attribute__((unused))) +static void my_case_bin(CHARSET_INFO *cs __attribute__((unused)), + char *str __attribute__((unused)), + uint length __attribute__((unused))) { } -static void my_caseup_bin(CHARSET_INFO * cs __attribute__((unused)), - char *str __attribute__((unused)), - uint length __attribute__((unused))) -{ -} - -static void my_casedn_bin(CHARSET_INFO * cs __attribute__((unused)), - char *str __attribute__((unused)), - uint length __attribute__((unused))) -{ -} static int my_strcasecmp_bin(CHARSET_INFO * cs __attribute__((unused)), - const char *s, const char *t) + const char *s, const char *t) { return strcmp(s,t); } + int my_mbcharlen_8bit(CHARSET_INFO *cs __attribute__((unused)), - uint c __attribute__((unused))) + uint c __attribute__((unused))) { return 1; } + static int my_mb_wc_bin(CHARSET_INFO *cs __attribute__((unused)), - my_wc_t *wc, - const unsigned char *str, - const unsigned char *end __attribute__((unused))) + my_wc_t *wc, + const unsigned char *str, + const unsigned char *end __attribute__((unused))) { if (str >= end) return MY_CS_TOOFEW(0); @@ -136,10 +138,11 @@ static int my_mb_wc_bin(CHARSET_INFO *cs __attribute__((unused)), return 1; } + static int my_wc_mb_bin(CHARSET_INFO *cs __attribute__((unused)), - my_wc_t wc, - unsigned char *s, - unsigned char *e __attribute__((unused))) + my_wc_t wc, + unsigned char *s, + unsigned char *e __attribute__((unused))) { if (s >= e) return MY_CS_TOOSMALL; @@ -169,12 +172,21 @@ void my_hash_sort_bin(CHARSET_INFO *cs __attribute__((unused)), } +/* + The following defines is here to keep the following code identical to + the one in ctype-simple.c +*/ + +#define likeconv(s,A) (A) +#define INC_PTR(cs,A,B) (A)++ + + static int my_wildcmp_bin(CHARSET_INFO *cs, const char *str,const char *str_end, const char *wildstr,const char *wildend, int escape, int w_one, int w_many) { - int result= -1; /* Not found, using wildcards */ + int result= -1; /* Not found, using wildcards */ while (wildstr != wildend) { @@ -182,31 +194,26 @@ static int my_wildcmp_bin(CHARSET_INFO *cs, { if (*wildstr == escape && wildstr+1 != wildend) wildstr++; - if (str == str_end || *wildstr++ != *str++) - { - return(1); - } + if (str == str_end || likeconv(cs,*wildstr++) != likeconv(cs,*str++)) + return(1); /* No match */ if (wildstr == wildend) - { - return(str != str_end); /* Match if both are at end */ - } - result=1; /* Found an anchor char */ + return(str != str_end); /* Match if both are at end */ + result=1; /* Found an anchor char */ } if (*wildstr == w_one) { do { - if (str == str_end) /* Skip one char if possible */ + if (str == str_end) /* Skip one char if possible */ return(result); - str++; - } while (*++wildstr == w_one && wildstr != wildend); + INC_PTR(cs,str,str_end); + } while (++wildstr < wildend && *wildstr == w_one); if (wildstr == wildend) break; } if (*wildstr == w_many) - { /* Found w_many */ - char cmp; - + { /* Found w_many */ + uchar cmp; wildstr++; /* Remove any '%' and '_' from the wild search string */ for (; wildstr != wildend ; wildstr++) @@ -216,40 +223,33 @@ static int my_wildcmp_bin(CHARSET_INFO *cs, if (*wildstr == w_one) { if (str == str_end) - { return(-1); - } - str++; + INC_PTR(cs,str,str_end); continue; } - break; /* Not a wild character */ + break; /* Not a wild character */ } if (wildstr == wildend) - { - return(0); /* Ok if w_many is last */ - } + return(0); /* match if w_many is last */ if (str == str_end) - { return(-1); - } if ((cmp= *wildstr) == escape && wildstr+1 != wildend) cmp= *++wildstr; - wildstr++; /* This is compared trough cmp */ + + INC_PTR(cs,wildstr,wildend); /* This is compared through cmp */ + cmp=likeconv(cs,cmp); do { - while (str != str_end && *str != cmp) + while (str != str_end && (uchar) likeconv(cs,*str) != cmp) str++; if (str++ == str_end) - { return(-1); - } { - int tmp=my_wildcmp_bin(cs,str,str_end,wildstr,wildend,escape,w_one,w_many); + int tmp=my_wildcmp_bin(cs,str,str_end,wildstr,wildend,escape,w_one, + w_many); if (tmp <= 0) - { return(tmp); - } } } while (str != str_end && wildstr[0] != w_many); return(-1); @@ -258,6 +258,7 @@ static int my_wildcmp_bin(CHARSET_INFO *cs, return(str != str_end ? 1 : 0); } + static int my_strnxfrm_bin(CHARSET_INFO *cs __attribute__((unused)), uchar * dest, uint len, const uchar *src, @@ -268,11 +269,12 @@ static int my_strnxfrm_bin(CHARSET_INFO *cs __attribute__((unused)), return len; } + static uint my_instr_bin(CHARSET_INFO *cs __attribute__((unused)), - const char *b, uint b_length, - const char *s, uint s_length, - my_match_t *match, uint nmatch) + const char *b, uint b_length, + const char *s, uint s_length, + my_match_t *match, uint nmatch) { register const uchar *str, *search, *end, *search_end; @@ -332,7 +334,7 @@ skip: MY_COLLATION_HANDLER my_collation_8bit_bin_handler = { my_strnncoll_binary, - my_strnncollsp_binary, + my_strnncoll_binary, my_strnxfrm_bin, my_like_range_simple, my_wildcmp_bin, @@ -341,6 +343,7 @@ MY_COLLATION_HANDLER my_collation_8bit_bin_handler = my_hash_sort_bin }; + static MY_CHARSET_HANDLER my_charset_handler= { NULL, /* ismbchar */ @@ -351,10 +354,10 @@ static MY_CHARSET_HANDLER my_charset_handler= my_lengthsp_8bit, my_mb_wc_bin, my_wc_mb_bin, - my_caseup_str_bin, - my_casedn_str_bin, - my_caseup_bin, - my_casedn_bin, + my_case_str_bin, + my_case_str_bin, + my_case_bin, + my_case_bin, my_snprintf_8bit, my_long10_to_str_8bit, my_longlong10_to_str_8bit, @@ -367,6 +370,7 @@ static MY_CHARSET_HANDLER my_charset_handler= my_scan_8bit }; + CHARSET_INFO my_charset_bin = { 63,0,0, /* number */ diff --git a/strings/ctype-czech.c b/strings/ctype-czech.c index 1a07a5eba7e..8aea7358a9c 100644 --- a/strings/ctype-czech.c +++ b/strings/ctype-czech.c @@ -379,10 +379,11 @@ static int my_strnxfrm_czech(CHARSET_INFO *cs __attribute__((unused)), #define EXAMPLE static my_bool my_like_range_czech(CHARSET_INFO *cs __attribute__((unused)), - const char *ptr,uint ptr_length, - int escape, int w_one, int w_many, - uint res_length, char *min_str,char *max_str, - uint *min_length,uint *max_length) + const char *ptr,uint ptr_length, + pbool escape, pbool w_one, pbool w_many, + uint res_length, char *min_str, + char *max_str, + uint *min_length,uint *max_length) { #ifdef EXAMPLE uchar value; @@ -599,8 +600,8 @@ int my_strnncollsp_czech(CHARSET_INFO * cs, const uchar *s, uint slen, const uchar *t, uint tlen) { - for ( ; slen && my_isspace(cs, s[slen-1]) ; slen--); - for ( ; tlen && my_isspace(cs, t[tlen-1]) ; tlen--); + for ( ; slen && s[slen-1] == ' ' ; slen--); + for ( ; tlen && t[tlen-1] == ' ' ; tlen--); return my_strnncoll_czech(cs,s,slen,t,tlen); } diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c index 9e71a18e531..2ebf145f840 100644 --- a/strings/ctype-gbk.c +++ b/strings/ctype-gbk.c @@ -2613,8 +2613,8 @@ int my_strnncollsp_gbk(CHARSET_INFO * cs, const uchar *s, uint slen, const uchar *t, uint tlen) { - for ( ; slen && my_isspace(cs, s[slen-1]) ; slen--); - for ( ; tlen && my_isspace(cs, t[tlen-1]) ; tlen--); + for ( ; slen && s[slen-1] == ' ' ; slen--); + for ( ; tlen && t[tlen-1] == ' ' ; tlen--); return my_strnncoll_gbk(cs,s,slen,t,tlen); } @@ -2663,7 +2663,7 @@ static int my_strnxfrm_gbk(CHARSET_INFO *cs __attribute__((unused)), static my_bool my_like_range_gbk(CHARSET_INFO *cs __attribute__((unused)), const char *ptr,uint ptr_length, - int escape, int w_one, int w_many, + pbool escape, pbool w_one, pbool w_many, uint res_length, char *min_str,char *max_str, uint *min_length,uint *max_length) { diff --git a/strings/ctype-latin1.c b/strings/ctype-latin1.c index 933737b5f61..00d49f40ee4 100644 --- a/strings/ctype-latin1.c +++ b/strings/ctype-latin1.c @@ -360,8 +360,8 @@ static int my_strnncollsp_latin1_de(CHARSET_INFO *cs, const uchar *s, uint slen, const uchar *t, uint tlen) { - for ( ; slen && my_isspace(cs, s[slen-1]) ; slen--); - for ( ; tlen && my_isspace(cs, t[tlen-1]) ; tlen--); + for ( ; slen && s[slen-1] == ' ' ; slen--); + for ( ; tlen && t[tlen-1] == ' ' ; tlen--); return my_strnncoll_latin1_de(cs,s,slen,t,tlen); } diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c index 377bf311d38..323662f023c 100644 --- a/strings/ctype-mb.c +++ b/strings/ctype-mb.c @@ -354,14 +354,14 @@ static int my_strnncoll_mb_bin(CHARSET_INFO * cs __attribute__((unused)), return cmp ? cmp : (int) (slen - tlen); } -static int my_strnncollsp_mb_bin(CHARSET_INFO * cs, - const uchar *s, uint slen, - const uchar *t, uint tlen) +static int my_strnncollsp_mb_bin(CHARSET_INFO * cs __attribute__((unused)), + const uchar *s, uint slen, + const uchar *t, uint tlen) { int len, cmp; - for ( ; slen && my_isspace(cs, s[slen-1]) ; slen--); - for ( ; tlen && my_isspace(cs, t[tlen-1]) ; tlen--); + for ( ; slen && s[slen-1] == ' ' ; slen--); + for ( ; tlen && t[tlen-1] == ' ' ; tlen--); len = ( slen > tlen ) ? tlen : slen; diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index 233251e16a8..ed042c7de1a 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -66,8 +66,8 @@ int my_strnncollsp_simple(CHARSET_INFO * cs, const uchar *s, uint slen, uchar *map= cs->sort_order; int len; - for ( ; slen && my_isspace(cs, s[slen-1]) ; slen--); - for ( ; tlen && my_isspace(cs, t[tlen-1]) ; tlen--); + for ( ; slen && s[slen-1] == ' ' ; slen--); + for ( ; tlen && t[tlen-1] == ' ' ; tlen--); len = ( slen > tlen ) ? tlen : slen; @@ -186,9 +186,9 @@ void my_hash_sort_simple(CHARSET_INFO *cs, } -long my_strntol_8bit(CHARSET_INFO *cs, - const char *nptr, uint l, int base, - char **endptr, int *err) +long my_strntol_8bit(CHARSET_INFO *cs, + const char *nptr, uint l, int base, + char **endptr, int *err) { int negative; register ulong cutoff; @@ -309,9 +309,9 @@ noconv: } -ulong my_strntoul_8bit(CHARSET_INFO *cs, - const char *nptr, uint l, int base, - char **endptr, int *err) +ulong my_strntoul_8bit(CHARSET_INFO *cs, + const char *nptr, uint l, int base, + char **endptr, int *err) { int negative; register ulong cutoff; @@ -423,9 +423,9 @@ noconv: } -longlong my_strntoll_8bit(CHARSET_INFO *cs __attribute__((unused)), - const char *nptr, uint l, int base, - char **endptr,int *err) +longlong my_strntoll_8bit(CHARSET_INFO *cs __attribute__((unused)), + const char *nptr, uint l, int base, + char **endptr,int *err) { int negative; register ulonglong cutoff; @@ -825,7 +825,7 @@ cnv: #define likeconv(s,A) (uchar) (s)->sort_order[(uchar) (A)] #endif -#define INC_PTR(cs,A,B) A++ +#define INC_PTR(cs,A,B) (A)++ int my_wildcmp_8bit(CHARSET_INFO *cs, @@ -833,7 +833,7 @@ int my_wildcmp_8bit(CHARSET_INFO *cs, const char *wildstr,const char *wildend, int escape, int w_one, int w_many) { - int result= -1; /* Not found, using wildcards */ + int result= -1; /* Not found, using wildcards */ while (wildstr != wildend) { @@ -845,7 +845,7 @@ int my_wildcmp_8bit(CHARSET_INFO *cs, if (str == str_end || likeconv(cs,*wildstr++) != likeconv(cs,*str++)) return(1); /* No match */ if (wildstr == wildend) - return (str != str_end); /* Match if both are at end */ + return(str != str_end); /* Match if both are at end */ result=1; /* Found an anchor char */ } if (*wildstr == w_one) @@ -853,7 +853,7 @@ int my_wildcmp_8bit(CHARSET_INFO *cs, do { if (str == str_end) /* Skip one char if possible */ - return (result); + return(result); INC_PTR(cs,str,str_end); } while (++wildstr < wildend && *wildstr == w_one); if (wildstr == wildend) @@ -872,7 +872,7 @@ int my_wildcmp_8bit(CHARSET_INFO *cs, if (*wildstr == w_one) { if (str == str_end) - return (-1); + return(-1); INC_PTR(cs,str,str_end); continue; } @@ -881,28 +881,29 @@ int my_wildcmp_8bit(CHARSET_INFO *cs, if (wildstr == wildend) return(0); /* Ok if w_many is last */ if (str == str_end) - return -1; + return(-1); if ((cmp= *wildstr) == escape && wildstr+1 != wildend) cmp= *++wildstr; - INC_PTR(cs,wildstr,wildend); /* This is compared trough cmp */ - cmp=likeconv(cs,cmp); + INC_PTR(cs,wildstr,wildend); /* This is compared trough cmp */ + cmp=likeconv(cs,cmp); do { - while (str != str_end && likeconv(cs,*str) != cmp) - str++; - if (str++ == str_end) return (-1); + while (str != str_end && (uchar) likeconv(cs,*str) != cmp) + str++; + if (str++ == str_end) return(-1); { - int tmp=my_wildcmp_8bit(cs,str,str_end,wildstr,wildend,escape,w_one,w_many); + int tmp=my_wildcmp_8bit(cs,str,str_end,wildstr,wildend,escape,w_one, + w_many); if (tmp <= 0) - return (tmp); + return(tmp); } } while (str != str_end && wildstr[0] != w_many); return(-1); } } - return (str != str_end ? 1 : 0); + return(str != str_end ? 1 : 0); } @@ -924,11 +925,11 @@ int my_wildcmp_8bit(CHARSET_INFO *cs, */ my_bool my_like_range_simple(CHARSET_INFO *cs, - const char *ptr,uint ptr_length, - int escape, int w_one, int w_many, - uint res_length, - char *min_str,char *max_str, - uint *min_length,uint *max_length) + const char *ptr,uint ptr_length, + pbool escape, pbool w_one, pbool w_many, + uint res_length, + char *min_str,char *max_str, + uint *min_length,uint *max_length) { const char *end=ptr+ptr_length; char *min_org=min_str; @@ -953,7 +954,7 @@ my_bool my_like_range_simple(CHARSET_INFO *cs, *min_length= (uint) (min_str - min_org); *max_length=res_length; do { - *min_str++ = ' '; /* Because if key compression */ + *min_str++ = ' '; /* Because if key compression */ *max_str++ = cs->max_sort_char; } while (min_str != min_end); return 0; @@ -970,7 +971,7 @@ my_bool my_like_range_simple(CHARSET_INFO *cs, } while (min_str != min_end) - *min_str++ = *max_str++ = ' '; /* Because if key compression */ + *min_str++ = *max_str++ = ' '; /* Because if key compression */ return 0; } diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c index feff0fff227..09bd12dcdeb 100644 --- a/strings/ctype-sjis.c +++ b/strings/ctype-sjis.c @@ -227,8 +227,8 @@ int my_strnncollsp_sjis(CHARSET_INFO * cs, const uchar *s, uint slen, const uchar *t, uint tlen) { - for ( ; slen && my_isspace(cs, s[slen-1]) ; slen--); - for ( ; tlen && my_isspace(cs, t[tlen-1]) ; tlen--); + for ( ; slen && s[slen-1] == ' ' ; slen--); + for ( ; tlen && t[tlen-1] == ' ' ; tlen--); return my_strnncoll_sjis(cs,s,slen,t,tlen); } @@ -270,10 +270,10 @@ static int my_strnxfrm_sjis(CHARSET_INFO *cs __attribute__((unused)), #define max_sort_char ((char) 255) static my_bool my_like_range_sjis(CHARSET_INFO *cs __attribute__((unused)), - const char *ptr,uint ptr_length, - int escape, int w_one, int w_many, - uint res_length, char *min_str,char *max_str, - uint *min_length,uint *max_length) + const char *ptr,uint ptr_length, + pbool escape, pbool w_one, pbool w_many, + uint res_length, char *min_str,char *max_str, + uint *min_length,uint *max_length) { const char *end=ptr+ptr_length; char *min_org=min_str; diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c index 9f4c33f86c1..b9856799add 100644 --- a/strings/ctype-tis620.c +++ b/strings/ctype-tis620.c @@ -466,7 +466,7 @@ uchar NEAR sort_order_tis620[]= static uint thai2sortable(uchar *tstr, uint len) { uchar *p; - int len, tlen; + int tlen; uchar l2bias; tlen= len; @@ -572,7 +572,8 @@ int my_strnxfrm_tis620(CHARSET_INFO *cs __attribute__((unused)), uchar * dest, uint len, const uchar * src, uint srclen) { - len= (uint) (strmake(dest, src, min(len,srclen))- dest); + len= (uint) (strmake((char*) dest, (char*) src, min(len, srclen)) - + (char*) dest); return (int) thai2sortable(dest, len); } @@ -610,7 +611,7 @@ int my_strcoll_tis620(const uchar * s1, const uchar * s2) my_bool my_like_range_tis620(CHARSET_INFO *cs __attribute__((unused)), const char *ptr, uint ptr_length, - int escape, int w_one, int w_many, + pbool escape, pbool w_one, pbool w_many, uint res_length, char *min_str, char *max_str, uint *min_length, uint *max_length) { @@ -862,7 +863,7 @@ static MY_COLLATION_HANDLER my_collation_ci_handler = my_like_range_tis620, my_wildcmp_8bit, /* wildcmp */ my_strcasecmp_8bit, - NULL, + my_instr_simple, /* QQ: To be fixed */ my_hash_sort_simple, }; diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index ef9719bf040..64956c872aa 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -1840,8 +1840,8 @@ int my_strnncollsp_utf8(CHARSET_INFO * cs, const uchar *s, uint slen, const uchar *t, uint tlen) { - for ( ; slen && my_isspace(cs, s[slen-1]) ; slen--); - for ( ; tlen && my_isspace(cs, t[tlen-1]) ; tlen--); + for ( ; slen && s[slen-1] == ' ' ; slen--); + for ( ; tlen && t[tlen-1] == ' ' ; tlen--); return my_strnncoll_utf8(cs,s,slen,t,tlen); } diff --git a/strings/ctype-win1250ch.c b/strings/ctype-win1250ch.c index d3b5c9d1796..889cf2d2dae 100644 --- a/strings/ctype-win1250ch.c +++ b/strings/ctype-win1250ch.c @@ -38,7 +38,6 @@ */ #define REAL_MYSQL - #ifdef REAL_MYSQL #include "my_global.h" @@ -445,103 +444,65 @@ static struct wordvalue doubles[] = { break; \ } -#define IS_END(p, src, len) (!(*p)) - -#if UNUSED -static int my_strcoll_win1250ch(const uchar * s1, const uchar * s2) { - int v1, v2; - const uchar * p1, * p2; - int pass1 = 0, pass2 = 0; - int diff; - - p1 = s1; p2 = s2; - - do { - NEXT_CMP_VALUE(s1, p1, pass1, v1, 0); - NEXT_CMP_VALUE(s2, p2, pass2, v2, 0); - diff = v1 - v2; - if (diff != 0) return diff; - } while (v1); - return 0; -} -#endif - -#ifdef UNUSED -static int my_strxfrm_win1250ch(uchar * dest, const uchar * src, int len) { - int value; - const uchar * p; - int pass = 0; - int totlen = 0; - p = src; - - do { - NEXT_CMP_VALUE(src, p, pass, value, 0); - if (totlen <= len) - dest[totlen] = value; - totlen++; - } while (value); - return totlen; -} -#endif - -#undef IS_END - #define IS_END(p, src, len) (((char *)p - (char *)src) >= (len)) static int my_strnncoll_win1250ch(CHARSET_INFO *cs __attribute__((unused)), - const uchar * s1, uint len1, - const uchar * s2, uint len2) { - int v1, v2; - const uchar * p1, * p2; - int pass1 = 0, pass2 = 0; - int diff; + const uchar * s1, uint len1, + const uchar * s2, uint len2) +{ + int v1, v2; + const uchar * p1, * p2; + int pass1 = 0, pass2 = 0; + int diff; - p1 = s1; p2 = s2; + p1 = s1; p2 = s2; - do { - NEXT_CMP_VALUE(s1, p1, pass1, v1, (int)len1); - NEXT_CMP_VALUE(s2, p2, pass2, v2, (int)len2); - diff = v1 - v2; - if (diff != 0) return diff; - } while (v1); - return 0; + do { + NEXT_CMP_VALUE(s1, p1, pass1, v1, (int)len1); + NEXT_CMP_VALUE(s2, p2, pass2, v2, (int)len2); + diff = v1 - v2; + if (diff != 0) return diff; + } while (v1); + return 0; } + static int my_strnncollsp_win1250ch(CHARSET_INFO * cs, - const uchar *s, uint slen, - const uchar *t, uint tlen) + const uchar *s, uint slen, + const uchar *t, uint tlen) { - for ( ; slen && my_isspace(cs, s[slen-1]) ; slen--); - for ( ; tlen && my_isspace(cs, t[tlen-1]) ; tlen--); + for ( ; slen && s[slen-1] == ' ' ; slen--); + for ( ; tlen && t[tlen-1] == ' ' ; tlen--); return my_strnncoll_win1250ch(cs,s,slen,t,tlen); } static int my_strnxfrm_win1250ch(CHARSET_INFO * cs __attribute__((unused)), - uchar * dest, uint len, - const uchar * src, uint srclen) { - int value; - const uchar * p; - int pass = 0; - uint totlen = 0; - p = src; + uchar * dest, uint len, + const uchar * src, uint srclen) +{ + int value; + const uchar * p; + int pass = 0; + uint totlen = 0; + p = src; - do { - NEXT_CMP_VALUE(src, p, pass, value, (int)srclen); - if (totlen <= len) - dest[totlen] = value; - totlen++; - } while (value) ; - return totlen; + do { + NEXT_CMP_VALUE(src, p, pass, value, (int)srclen); + if (totlen <= len) + dest[totlen] = value; + totlen++; + } while (value) ; + return totlen; } #undef IS_END - #ifdef REAL_MYSQL -static uchar NEAR like_range_prefix_min_win1250ch[] = { +static uchar NEAR like_range_prefix_min_win1250ch[] = +{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, @@ -598,87 +559,82 @@ static uchar NEAR like_range_prefix_max_win1250ch[] = { ** optimized ! */ -static my_bool my_like_range_win1250ch(CHARSET_INFO *cs __attribute__((unused)), - const char *ptr, uint ptr_length, - int escape, int w_one, int w_many, - uint res_length, - char *min_str, char *max_str, - uint *min_length, uint *max_length) { +static my_bool +my_like_range_win1250ch(CHARSET_INFO *cs __attribute__((unused)), + const char *ptr, uint ptr_length, + pbool escape, pbool w_one, pbool w_many, + uint res_length, + char *min_str, char *max_str, + uint *min_length, uint *max_length) +{ - int was_other_than_min = 0; - const char *end = ptr + ptr_length; - char *min_org = min_str; - char *min_end = min_str + res_length; + int only_min_found= 1; + const char *end = ptr + ptr_length; + char *min_org = min_str; + char *min_end = min_str + res_length; - /* return 1; */ + /* return 1; */ - for (; ptr != end && min_str != min_end ; ptr++) { - if (*ptr == w_one) { /* '_' in SQL */ - break; - } - if (*ptr == w_many) { /* '%' in SQL */ - break; - } - if (*ptr == escape && ptr + 1 != end) { /* Skip escape */ - ptr++; - } - *min_str = like_range_prefix_min_win1250ch[(uint)(*ptr)]; - if (*min_str != min_sort_char) { - was_other_than_min = 1; - } - min_str++; - *max_str++ = like_range_prefix_max_win1250ch[(uint)(*ptr)]; - } + for (; ptr != end && min_str != min_end ; ptr++) + { + if (*ptr == escape && ptr+1 != end) + ptr++; /* Skip escape */ + else if (*ptr == w_one || *ptr == w_many) /* '_' or '%' in SQL */ + break; + *min_str = like_range_prefix_min_win1250ch[(uint)(*ptr)]; + if (*min_str != min_sort_char) + only_min_found= 0; + min_str++; + *max_str++ = like_range_prefix_max_win1250ch[(uint)(*ptr)]; + } - *min_length = (uint) (min_str - min_org); - *max_length = res_length; - while (min_str != min_end) { - *min_str++ = min_sort_char; - *max_str++ = max_sort_char; - } - if (! was_other_than_min) { - return 1; - } - - return 0; + *min_length = (uint) (min_str - min_org); + *max_length = res_length; + while (min_str != min_end) + { + *min_str++ = min_sort_char; + *max_str++ = max_sort_char; + } + return (only_min_found); } static MY_COLLATION_HANDLER my_collation_czech_ci_handler = { - my_strnncoll_win1250ch, - my_strnncollsp_win1250ch, - my_strnxfrm_win1250ch, - my_like_range_win1250ch, - my_wildcmp_8bit, - my_strcasecmp_8bit, - my_instr_simple, - my_hash_sort_simple + my_strnncoll_win1250ch, + my_strnncollsp_win1250ch, + my_strnxfrm_win1250ch, + my_like_range_win1250ch, + my_wildcmp_8bit, + my_strcasecmp_8bit, + my_instr_simple, + my_hash_sort_simple }; + CHARSET_INFO my_charset_cp1250_czech_ci = { - 34,0,0, /* number */ - MY_CS_COMPILED|MY_CS_STRNXFRM, /* state */ - "cp1250", /* cs name */ - "cp1250_czech_ci", /* name */ - "", /* comment */ - ctype_win1250ch, - to_lower_win1250ch, - to_upper_win1250ch, - sort_order_win1250ch, - tab_cp1250_uni, /* tab_to_uni */ - idx_uni_cp1250, /* tab_from_uni */ - "","", - 2, /* strxfrm_multiply */ - 1, /* mbminlen */ - 1, /* mbmaxlen */ - 0, - &my_charset_8bit_handler, - &my_collation_czech_ci_handler + 34,0,0, /* number */ + MY_CS_COMPILED|MY_CS_STRNXFRM, /* state */ + "cp1250", /* cs name */ + "cp1250_czech_ci", /* name */ + "", /* comment */ + ctype_win1250ch, + to_lower_win1250ch, + to_upper_win1250ch, + sort_order_win1250ch, + tab_cp1250_uni, /* tab_to_uni */ + idx_uni_cp1250, /* tab_from_uni */ + "","", + 2, /* strxfrm_multiply */ + 1, /* mbminlen */ + 1, /* mbmaxlen */ + 0, + &my_charset_8bit_handler, + &my_collation_czech_ci_handler }; -#endif +#endif /* REAL_MYSQL */ -#endif +#endif /* HAVE_CHARSET_cp1250 */ diff --git a/strings/strto.c b/strings/strto.c index 6f12656cb20..52efec6e087 100644 --- a/strings/strto.c +++ b/strings/strto.c @@ -95,7 +95,7 @@ function (const char *nptr,char **endptr,int base) s = nptr; /* Skip white space. */ - while (my_isspace (&my_charset_latin1, *s)) + while (my_isspace(&my_charset_latin1, *s)) ++s; if (*s == '\0') {