From d1a745b0bad74f7a500b8bb8e066cef1156f1873 Mon Sep 17 00:00:00 2001 From: "jimw@mysql.com" <> Date: Sat, 7 May 2005 13:57:22 -0700 Subject: [PATCH 1/9] Add special error message for .frm files with an un-understood version, like those from 5.0 with new datatypes. (Bug #10435) --- sql/table.cc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/sql/table.cc b/sql/table.cc index cdcd5148787..012defa116d 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -59,6 +59,7 @@ static byte* get_field_name(Field **buff,uint *length, 3 Wrong data in .frm file 4 Error (see frm_error) 5 Error (see frm_error: charset unavailable) + 6 Unknown .frm version */ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, @@ -118,9 +119,13 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, *fn_ext(outparam->path)='\0'; // Remove extension if (my_read(file,(byte*) head,64,MYF(MY_NABP))) goto err_not_open; - if (head[0] != (uchar) 254 || head[1] != 1 || - (head[2] != FRM_VER && head[2] != FRM_VER+1 && head[2] != FRM_VER+3)) + if (head[0] != (uchar) 254 || head[1] != 1) goto err_not_open; /* purecov: inspected */ + if (head[2] != FRM_VER && head[2] != FRM_VER+1 && head[2] != FRM_VER+3) + { + error= 6; + goto err_not_open; /* purecov: inspected */ + } new_field_pack_flag=head[27]; new_frm_ver= (head[2] - FRM_VER); field_pack_length= new_frm_ver < 2 ? 11 : 17; @@ -1033,6 +1038,12 @@ static void frm_error(int error, TABLE *form, const char *name, MYF(0), csname, form->real_name); break; } + case 6: + my_printf_error(ER_NOT_FORM_FILE, + "Table '%-.64s' was created with a different version " + "of MySQL and cannot be read", + MYF(0), name); + break; default: /* Better wrong error than none */ case 4: my_error(ER_NOT_FORM_FILE,errortype, From cc3bfc6ff1f27e5054715472657fc987c0f85f70 Mon Sep 17 00:00:00 2001 From: "antony@ltantony.mysql.com" <> Date: Mon, 9 May 2005 14:31:46 +0100 Subject: [PATCH 2/9] Bug#8733 - server accepts malformed query (multiply mentioned distinct) Detect conflicting options in SELECT --- mysql-test/r/select.result | 10 ++++++++++ mysql-test/t/select.test | 16 ++++++++++++++++ sql/mysql_priv.h | 3 +++ sql/sql_yacc.yy | 20 ++++++++++++++++++-- 4 files changed, 47 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result index 9df5efc66d6..50300ed9b76 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -2445,3 +2445,13 @@ cast((a - b) as unsigned) 1 18446744073709551615 drop table t1; +create table t1 (a int(11)); +select all all * from t1; +a +select distinct distinct * from t1; +a +select all distinct * from t1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'distinct * from t1' at line 1 +select distinct all * from t1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'all * from t1' at line 1 +drop table t1; diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index f58a78205ec..6d6d5f6b6e1 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -1979,3 +1979,19 @@ select a-b , (a-b < 0) from t1 order by 1; select a-b as d, (a-b >= 0), b from t1 group by b having d >= 0; select cast((a - b) as unsigned) from t1 order by 1; drop table t1; + + +# +# Bug#8733 server accepts malformed query (multiply mentioned distinct) +# +create table t1 (a int(11)); +select all all * from t1; +select distinct distinct * from t1; +--error 1064 +select all distinct * from t1; +--error 1064 +select distinct all * from t1; +drop table t1; + + +# diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index f5d4464ce68..ca282ee2444 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -211,6 +211,9 @@ extern CHARSET_INFO *national_charset_info, *table_alias_charset; key checks in some cases */ #define OPTION_RELAXED_UNIQUE_CHECKS (1L << 27) #define SELECT_NO_UNLOCK (1L << 28) +/* Thr following is used to detect a conflict with DISTINCT + in the user query has requested */ +#define SELECT_ALL (1L << 29) /* If set to 0, then the thread will ignore all warnings with level notes. Set by executing SET SQL_NOTES=1 */ diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 594077dd4f3..a5e3cd1243c 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -2481,7 +2481,15 @@ select_option: YYABORT; Lex->lock_option= TL_READ_HIGH_PRIORITY; } - | DISTINCT { Select->options|= SELECT_DISTINCT; } + | DISTINCT + { + if (Select->options & SELECT_ALL) + { + yyerror(ER(ER_SYNTAX_ERROR)); + YYABORT; + } + Select->options|= SELECT_DISTINCT; + } | SQL_SMALL_RESULT { Select->options|= SELECT_SMALL_RESULT; } | SQL_BIG_RESULT { Select->options|= SELECT_BIG_RESULT; } | SQL_BUFFER_RESULT @@ -2501,7 +2509,15 @@ select_option: { Lex->select_lex.options|= OPTION_TO_QUERY_CACHE; } - | ALL {} + | ALL + { + if (Select->options & SELECT_DISTINCT) + { + yyerror(ER(ER_SYNTAX_ERROR)); + YYABORT; + } + Select->options|= SELECT_ALL; + } ; select_lock_type: From 8d30d300730699c7f44afcb6e2fb76df6b8e3510 Mon Sep 17 00:00:00 2001 From: "ramil@ram-book.(none)" <> Date: Mon, 9 May 2005 18:33:21 +0500 Subject: [PATCH 3/9] a fix (bug #10438: Raid stopped working because of change in atomic add detection). --- include/my_global.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/my_global.h b/include/my_global.h index a9468f6561e..62c6a5d1e4a 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -287,9 +287,15 @@ C_MODE_START int __cxa_pure_virtual() {\ #ifndef CONFIG_SMP #define CONFIG_SMP #endif +#if defined(__ia64__) +#define new my_arg_new +#endif C_MODE_START #include C_MODE_END +#if defined(__ia64__) +#undef new +#endif #endif #include /* Recommended by debian */ /* We need the following to go around a problem with openssl on solaris */ From c783cb3d7eac5a901d1d2a28742f77f25f9785f7 Mon Sep 17 00:00:00 2001 From: "bar@noter.(none)" <> Date: Mon, 9 May 2005 20:55:06 +0500 Subject: [PATCH 4/9] SUBSTR with negative argument didn't work with multi-byte strings, length() instead of numchars() where used in a mistake. --- mysql-test/r/ctype_utf8.result | 3 +++ mysql-test/t/ctype_utf8.test | 6 ++++++ sql/item_strfunc.cc | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index 78c56bffbd3..ffdb7cb0f3d 100644 --- a/mysql-test/r/ctype_utf8.result +++ b/mysql-test/r/ctype_utf8.result @@ -817,6 +817,9 @@ drop table t1; select 'c' like '\_' as want0; want0 0 +SELECT SUBSTR('вася',-2); +SUBSTR('вася',-2) +ся create table t1 (id integer, a varchar(100) character set utf8 collate utf8_unicode_ci); insert into t1 values (1, 'Test'); select * from t1 where soundex(a) = soundex('Test'); diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index 194354f8718..02024adb34e 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -666,6 +666,12 @@ drop table t1; # select 'c' like '\_' as want0; +# +# SUBSTR with negative offset didn't work with multi-byte strings +# +SELECT SUBSTR('вася',-2); + + # # Bug #7730 Server crash using soundex on an utf8 table # diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 8b9351d95a5..baba4d9b786 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1023,7 +1023,7 @@ String *Item_func_substr::val_str(String *str) if ((null_value=(args[0]->null_value || args[1]->null_value || (arg_count == 3 && args[2]->null_value)))) return 0; /* purecov: inspected */ - start= (int32)((start < 0) ? res->length() + start : start -1); + start= (int32)((start < 0) ? res->numchars() + start : start -1); start=res->charpos(start); length=res->charpos(length,start); if (start < 0 || (uint) start+1 > res->length() || length <= 0) From 2f9a28b4cca7c4ed1d64f5bb72549a6eea6e07e4 Mon Sep 17 00:00:00 2001 From: "kent@mysql.com" <> Date: Mon, 9 May 2005 18:14:10 +0200 Subject: [PATCH 5/9] configure.in: Bumped up version number to indicate 4.1.12 was branched off --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 00ec737e76f..1f36a45d40c 100644 --- a/configure.in +++ b/configure.in @@ -5,7 +5,7 @@ AC_INIT(sql/mysqld.cc) AC_CANONICAL_SYSTEM # The Docs Makefile.am parses this line! # remember to also change ndb version below and update version.c in ndb -AM_INIT_AUTOMAKE(mysql, 4.1.12) +AM_INIT_AUTOMAKE(mysql, 4.1.13) AM_CONFIG_HEADER(config.h) PROTOCOL_VERSION=10 From 7366c218396bf82b0b7114cf01cf0c5d9d1bd034 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Mon, 9 May 2005 21:59:03 +0200 Subject: [PATCH 6/9] Add compiler settings for Pentium M --- BUILD/check-cpu | 3 +++ 1 file changed, 3 insertions(+) diff --git a/BUILD/check-cpu b/BUILD/check-cpu index dfdf96d6b29..3cce4b1ab3d 100755 --- a/BUILD/check-cpu +++ b/BUILD/check-cpu @@ -55,6 +55,9 @@ case "$cpu_family--$model_name" in *Pentium*III*CPU*) cpu_flag="pentium3"; ;; + *Pentium*M*pro*) + cpu_flag="pentium-m"; + ;; *Athlon*64*) cpu_flag="athlon64"; cpu_flag_old="athlon"; From 1851a38b2f1bd0d2be665fa1abbbd17e4d37fd64 Mon Sep 17 00:00:00 2001 From: "holyfoot@hf-ibm.(none)" <> Date: Tue, 10 May 2005 02:15:59 +0500 Subject: [PATCH 7/9] Fix for bug #10493 (SJIS fields are not correctly saved) --- BitKeeper/etc/logging_ok | 1 + strings/ctype-sjis.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 2143d0f2492..246de2fffa2 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -75,6 +75,7 @@ hf@bisonxp.(none) hf@deer.(none) hf@deer.mysql.r18.ru hf@genie.(none) +holyfoot@mysql.com igor@hundin.mysql.fi igor@linux.local igor@rurik.mysql.com diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c index 35182db3345..b018e148ffe 100644 --- a/strings/ctype-sjis.c +++ b/strings/ctype-sjis.c @@ -4576,7 +4576,7 @@ uint my_well_formed_len_sjis(CHARSET_INFO *cs __attribute__((unused)), { const char *b0= b; *error= 0; - while (pos && b < e) + while (pos-- && b < e) { if ((uchar) b[0] < 128) { From d1e9d9b981bbc6cc1c4412b0d17097b56c2e19e3 Mon Sep 17 00:00:00 2001 From: "sergefp@mysql.com" <> Date: Tue, 10 May 2005 00:40:41 +0200 Subject: [PATCH 8/9] Fix for BUG#10070: Make the test not to produce warnings if InnoDB is not available --- mysql-test/t/range.test | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test index 3d3d4748fe3..b51a79fba77 100644 --- a/mysql-test/t/range.test +++ b/mysql-test/t/range.test @@ -448,6 +448,7 @@ explain select * from t1 where a='aaa' collate latin1_german1_ci; drop table t1; # Test for BUG#9348 "result for WHERE A AND (B OR C) differs from WHERE a AND (C OR B)" +--disable_warnings CREATE TABLE t1 ( `CLIENT` char(3) character set latin1 collate latin1_bin NOT NULL default '000', `ARG1` char(3) character set latin1 collate latin1_bin NOT NULL default '', @@ -456,6 +457,7 @@ CREATE TABLE t1 ( `FUNCTINT` int(11) NOT NULL default '0', KEY `VERI_CLNT~2` (`ARG1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; +--enable_warnings INSERT INTO t1 VALUES ('000',' 0',' 0','Text 001',0), ('000',' 0',' 1','Text 002',0), ('000',' 1',' 2','Text 003',0), ('000',' 2',' 3','Text 004',0), From 7133dc5a2209e7ba99465fe09801dc897da14bb7 Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Tue, 10 May 2005 10:45:16 +0200 Subject: [PATCH 9/9] Remove testcode --- sql/item_strfunc.h | 1 - 1 file changed, 1 deletion(-) diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index e576b2c2a7e..6f6af415086 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -18,7 +18,6 @@ /* This file defines all string functions */ #ifdef USE_PRAGMA_INTERFACE -#error PRAGMA #pragma interface /* gcc class implementation */ #endif