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"; diff --git a/include/my_global.h b/include/my_global.h index 9f3acef0ff6..5448aa3e871 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -308,9 +308,15 @@ C_MODE_END #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 */ diff --git a/mysql-test/r/ctype_utf8.result b/mysql-test/r/ctype_utf8.result index 490cde82ca3..8ab24fe550b 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/r/select.result b/mysql-test/r/select.result index fd67903a576..9b3c893aafa 100644 --- a/mysql-test/r/select.result +++ b/mysql-test/r/select.result @@ -2476,3 +2476,13 @@ x NULL 1.0000 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/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/mysql-test/t/range.test b/mysql-test/t/range.test index e86688c4315..5d5f845e2bc 100644 --- a/mysql-test/t/range.test +++ b/mysql-test/t/range.test @@ -437,6 +437,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 '', @@ -445,6 +446,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), diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 64f6674181c..d5efeeb331e 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -2056,3 +2056,19 @@ create table t1 (s1 int); insert into t1 values (null),(1); select distinct avg(s1) as x from t1 group by s1 with rollup; 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/item_strfunc.cc b/sql/item_strfunc.cc index 3fe1b819f36..fb7827ef932 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1013,7 +1013,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) diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index d7c77829cfc..4c44db49489 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 diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 36fc315c3c0..25490b04ab3 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -268,6 +268,9 @@ extern CHARSET_INFO *national_charset_info, *table_alias_charset; #define OPTION_SCHEMA_TABLE (1L << 29) /* Flag set if setup_tables already done */ #define OPTION_SETUP_TABLES_DONE (1L << 30) +/* Thr following is used to detect a conflict with DISTINCT + in the user query has requested */ +#define SELECT_ALL (ULL(1) << 32) /* Maximum length of time zone name that we support diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 2231df3f4c1..25a78178995 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -4000,7 +4000,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 @@ -4020,7 +4028,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: diff --git a/sql/table.cc b/sql/table.cc index 8e0f52e1910..e587660e180 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(THD *thd, const char *name, const char *alias, uint db_stat, @@ -135,10 +136,14 @@ int openfrm(THD *thd, const char *name, const char *alias, uint db_stat, *fn_ext(share->table_name)='\0'; // Remove extension *fn_ext(share->path)='\0'; // Remove extension - if (head[0] != (uchar) 254 || head[1] != 1 || - (head[2] != FRM_VER && head[2] != FRM_VER+1 && - ! (head[2] >= FRM_VER+3 && head[2] <= FRM_VER+4))) + if (head[0] != (uchar) 254 || head[1] != 1) goto err; /* purecov: inspected */ + if (head[2] != FRM_VER && head[2] != FRM_VER+1 && + ! (head[2] >= FRM_VER+3 && head[2] <= FRM_VER+4)) + { + error= 6; + goto err; /* purecov: inspected */ + } new_field_pack_flag=head[27]; new_frm_ver= (head[2] - FRM_VER); field_pack_length= new_frm_ver < 2 ? 11 : 17; @@ -1084,6 +1089,12 @@ static void frm_error(int error, TABLE *form, const char *name, MYF(0), csname, 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, diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c index 9b7fd5097fa..a7d75da42c9 100644 --- a/strings/ctype-sjis.c +++ b/strings/ctype-sjis.c @@ -4591,7 +4591,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) {