diff options
67 files changed, 416 insertions, 302 deletions
diff --git a/client/sql_string.cc b/client/sql_string.cc index be4354227a5..51f802e7465 100644 --- a/client/sql_string.cc +++ b/client/sql_string.cc @@ -16,12 +16,11 @@ /* This file is originally from the mysql distribution. Coded by monty */ -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif +#include <my_global.h> #include <my_sys.h> #include <m_string.h> #include <m_ctype.h> diff --git a/configure.in b/configure.in index 936e4ed22e1..3e196cf8507 100644 --- a/configure.in +++ b/configure.in @@ -1765,12 +1765,23 @@ if test "$ac_cv_sizeof_off_t" -eq 0 then AC_MSG_ERROR("MySQL needs a off_t type.") fi + +# do we need #pragma interface/#pragma implementation ? +# yes if it's gcc 2.x, and not icc pretending to be gcc, and not cygwin +AC_MSG_CHECKING(the need for @%:@pragma interface/implementation) +# instead of trying to match SYSTEM_TYPE and CC_VERSION (that doesn't +# follow any standard), we'll use well-defined preprocessor macros: +AC_TRY_CPP([ +#if !defined(__CYGWIN__) && !defined(__INTEL_COMPILER) && defined(__GNUC__) && (__GNUC__ < 3) +#error USE_PRAGMA_IMPLEMENTATION +#endif +],AC_MSG_RESULT(no) ,AC_MSG_RESULT(yes) ; CXXFLAGS="$CXXFLAGS -DUSE_PRAGMA_IMPLEMENTATION") + # This always gives a warning. Ignore it unless you are cross compiling AC_C_BIGENDIAN #---START: Used in for client configure # Check base type of last arg to accept MYSQL_TYPE_ACCEPT - #---END: # Figure out what type of struct rlimit to use with setrlimit MYSQL_TYPE_STRUCT_RLIMIT diff --git a/include/my_global.h b/include/my_global.h index b4dfb5b7f7d..195d208c93b 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -43,16 +43,11 @@ #define HAVE_ERRNO_AS_DEFINE #endif /* __CYGWIN__ */ -/* Determine when to use "#pragma interface" */ -#if !defined(__CYGWIN__) && !defined(__INTEL_COMPILER) && defined(__GNUC__) && (__GNUC__ < 3) +/* to make command line shorter we'll define USE_PRAGMA_INTERFACE here */ +#ifdef USE_PRAGMA_IMPLEMENTATION #define USE_PRAGMA_INTERFACE #endif -/* Determine when to use "#pragma implementation" */ -#if !defined(__INTEL_COMPILER) && defined(__GNUC__) && (__GNUC__ < 3) -#define USE_PRAGMA_IMPLEMENTATION -#endif - #if defined(i386) && !defined(__i386__) #define __i386__ #endif @@ -306,13 +301,6 @@ C_MODE_END #include <alloca.h> #endif #ifdef HAVE_ATOMIC_ADD -#define __SMP__ -#ifdef HAVE_LINUX_CONFIG_H -#include <linux/config.h> /* May define CONFIG_SMP */ -#endif -#ifndef CONFIG_SMP -#define CONFIG_SMP -#endif #if defined(__ia64__) #define new my_arg_new #define need_to_restore_new 1 diff --git a/mysql-test/lib/mtr_misc.pl b/mysql-test/lib/mtr_misc.pl index 5f80864d1f7..efa1b3bec21 100644 --- a/mysql-test/lib/mtr_misc.pl +++ b/mysql-test/lib/mtr_misc.pl @@ -25,7 +25,7 @@ sub mtr_full_hostname () { if ( $hostname !~ /\./ ) { my $address= gethostbyname($hostname) - or die "Couldn't resolve $hostname : $!"; + or mtr_error("Couldn't resolve $hostname : $!"); my $fullname= gethostbyaddr($address, AF_INET); $hostname= $fullname if $fullname; } diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl index 78758e54aa4..7bca422773c 100644 --- a/mysql-test/lib/mtr_process.pl +++ b/mysql-test/lib/mtr_process.pl @@ -17,6 +17,7 @@ sub mtr_spawn ($$$$$$); sub mtr_stop_mysqld_servers ($); sub mtr_kill_leftovers (); sub mtr_record_dead_children (); +sub mtr_exit ($); sub sleep_until_file_created ($$$); # static in C @@ -784,4 +785,17 @@ sub sleep_until_file_created ($$$) { } +############################################################################## +# +# When we exit, we kill off all children +# +############################################################################## + +sub mtr_exit ($) { + my $code= shift; + local $SIG{HUP} = 'IGNORE'; + kill('HUP', -$$); + exit($code); +} + 1; diff --git a/mysql-test/lib/mtr_report.pl b/mysql-test/lib/mtr_report.pl index cb41549422f..a258d139bb1 100644 --- a/mysql-test/lib/mtr_report.pl +++ b/mysql-test/lib/mtr_report.pl @@ -268,7 +268,8 @@ sub mtr_warning (@) { } sub mtr_error (@) { - die "mysql-test-run: *** ERROR: ",join(" ", @_),"\n"; + print STDERR "mysql-test-run: *** ERROR: ",join(" ", @_),"\n"; + mtr_exit(1); } sub mtr_debug (@) { diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 52ffff088b5..7b57108466d 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -398,7 +398,7 @@ sub main () { } } - exit(0); + mtr_exit(0); } ############################################################################## @@ -568,7 +568,9 @@ sub command_line_setup () { $opt_vardir= "$glob_mysql_test_dir/var"; } - if ( $opt_vardir !~ m,^/, ) + # We make the path absolute, as the server will do a chdir() before usage + unless ( $opt_vardir =~ m,^/, or + ($glob_win32 and $opt_vardir =~ m,^[a-z]:/,i) ) { # Make absolute path, relative test dir $opt_vardir= "$glob_mysql_test_dir/$opt_vardir"; @@ -1292,9 +1294,9 @@ sub install_db ($$) { mtr_report("Installing \u$type Databases"); open(IN, $init_db_sql) - or error("Can't open $init_db_sql: $!"); + or mtr_error("Can't open $init_db_sql: $!"); open(OUT, ">", $init_db_sql_tmp) - or error("Can't write to $init_db_sql_tmp: $!"); + or mtr_error("Can't write to $init_db_sql_tmp: $!"); while (<IN>) { chomp; @@ -1568,7 +1570,7 @@ sub report_failure_and_restart ($) { { stop_masters_slaves(); } - exit(1); + mtr_exit(1); } # FIXME always terminate on failure?! @@ -2267,5 +2269,5 @@ Options not yet described, or that I want to look into more with-openssl HERE - exit(1); + mtr_exit(1); } diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index ae09b8d730c..be527630078 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -513,9 +513,9 @@ drop database mysqltest; select database(); database() NULL -select database(); -database() -NULL +select database(), user(); +database() user() +NULL mysqltest_1@localhost use test; create table t1 (a int, index `primary` (a)); ERROR 42000: Incorrect index name 'primary' @@ -579,7 +579,6 @@ select * from t2; b 1 drop table t1,t2; -use test; create table t1 (a int); create table t1 select * from t1; ERROR HY000: You can't specify target table 't1' for update in FROM clause diff --git a/mysql-test/r/ctype_cp1250_ch.result b/mysql-test/r/ctype_cp1250_ch.result index 62936b84caf..7b2ca7d7e0e 100644 --- a/mysql-test/r/ctype_cp1250_ch.result +++ b/mysql-test/r/ctype_cp1250_ch.result @@ -7,3 +7,15 @@ SELECT a, length(a), a='', a=' ', a=' ' FROM t1; a length(a) a='' a=' ' a=' ' 0 1 1 1 DROP TABLE t1; +CREATE TABLE t1 ( +popisek varchar(30) collate cp1250_general_ci NOT NULL default '', +PRIMARY KEY (`popisek`) +); +INSERT INTO t1 VALUES ('2005-01-1'); +SELECT * FROM t1 WHERE popisek = '2005-01-1'; +popisek +2005-01-1 +SELECT * FROM t1 WHERE popisek LIKE '2005-01-1'; +popisek +2005-01-1 +drop table t1; diff --git a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result index 09ff3fc5a6e..10afb61ba1d 100644 --- a/mysql-test/r/func_gconcat.result +++ b/mysql-test/r/func_gconcat.result @@ -343,18 +343,6 @@ GROUP_CONCAT(b ORDER BY b) First Row Second Row DROP TABLE t1; -CREATE TABLE t1 (a_id tinyint(4) NOT NULL default '0', PRIMARY KEY (a_id)) ENGINE=InnoDB DEFAULT CHARSET=latin1; -INSERT INTO t1 VALUES (1),(2),(3); -CREATE TABLE t2 (b_id tinyint(4) NOT NULL default '0',b_a tinyint(4) NOT NULL default '0', PRIMARY KEY (b_id), KEY (b_a), -CONSTRAINT fk_b_a FOREIGN KEY (b_a) REFERENCES t1 (a_id) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE=InnoDB DEFAULT CHARSET=latin1; -INSERT INTO t2 VALUES (1,1),(2,1),(3,1),(4,2),(5,2); -SELECT * FROM (SELECT t1.*,GROUP_CONCAT(t2.b_id SEPARATOR ',') as b_list FROM (t1 LEFT JOIN (t2) on t1.a_id = t2.b_a) GROUP BY t1.a_id ) AS xyz; -a_id b_list -1 1,2,3 -2 4,5 -3 NULL -DROP TABLE t2; -DROP TABLE t1; CREATE TABLE t1 (A_ID INT NOT NULL,A_DESC CHAR(3) NOT NULL,PRIMARY KEY (A_ID)); INSERT INTO t1 VALUES (1,'ABC'), (2,'EFG'), (3,'HIJ'); CREATE TABLE t2 (A_ID INT NOT NULL,B_DESC CHAR(3) NOT NULL,PRIMARY KEY (A_ID,B_DESC)); @@ -462,6 +450,49 @@ SELECT GROUP_CONCAT(id) AS gc FROM t1 HAVING gc IS NULL; gc NULL DROP TABLE t1; +create table t2 (a int, b int); +insert into t2 values (1,1), (2,2); +select b x, (select group_concat(x) from t2) from t2; +x (select group_concat(x) from t2) +1 1,1 +2 2,2 +drop table t2; +create table t1 (d int not null auto_increment,primary key(d), a int, b int, c int); +insert into t1(a,b) values (1,3), (1,4), (1,2), (2,7), (1,1), (1,2), (2,3), (2,3); +select d,a,b from t1 order by a; +d a b +1 1 3 +2 1 4 +3 1 2 +5 1 1 +6 1 2 +4 2 7 +7 2 3 +8 2 3 +explain select a, group_concat(b) from t1 group by a with rollup; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 8 Using filesort +select a, group_concat(b) from t1 group by a with rollup; +a group_concat(b) +1 3,4,2,1,2 +2 7,3,3 +NULL 3,4,2,1,2,7,3,3 +select a, group_concat(distinct b) from t1 group by a with rollup; +a group_concat(distinct b) +1 3,4,2,1 +2 7,3 +NULL 3,4,2,1,7 +select a, group_concat(b order by b) from t1 group by a with rollup; +a group_concat(b order by b) +1 1,2,2,3,4 +2 3,3,7 +NULL 1,2,2,3,3,3,4,7 +select a, group_concat(distinct b order by b) from t1 group by a with rollup; +a group_concat(distinct b order by b) +1 1,2,3,4 +2 3,7 +NULL 1,2,3,4,7 +drop table t1; create table t1 (a char(3), b char(20), primary key (a, b)); insert into t1 values ('ABW', 'Dutch'), ('ABW', 'English'); select group_concat(a) from t1 group by b; @@ -469,10 +500,3 @@ group_concat(a) ABW ABW drop table t1; -create table r2 (a int, b int); -insert into r2 values (1,1), (2,2); -select b x, (select group_concat(x) from r2) from r2; -x (select group_concat(x) from r2) -1 1,1 -2 2,2 -drop table r2; diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result index 53dbf2a39e1..1f26aa7d7f7 100644 --- a/mysql-test/r/innodb.result +++ b/mysql-test/r/innodb.result @@ -931,7 +931,6 @@ a 1 2 truncate table t1; -truncate table t1; insert into t1 values(1),(2); delete from t1; select * from t1; @@ -1654,6 +1653,46 @@ show status like "binlog_cache_disk_use"; Variable_name Value Binlog_cache_disk_use 1 drop table t1; +create table t1 (c char(10), index (c,c)) engine=innodb; +ERROR 42S21: Duplicate column name 'c' +create table t1 (c1 char(10), c2 char(10), index (c1,c2,c1)) engine=innodb; +ERROR 42S21: Duplicate column name 'c1' +create table t1 (c1 char(10), c2 char(10), index (c1,c1,c2)) engine=innodb; +ERROR 42S21: Duplicate column name 'c1' +create table t1 (c1 char(10), c2 char(10), index (c2,c1,c1)) engine=innodb; +ERROR 42S21: Duplicate column name 'c1' +create table t1 (c1 char(10), c2 char(10)) engine=innodb; +alter table t1 add key (c1,c1); +ERROR 42S21: Duplicate column name 'c1' +alter table t1 add key (c2,c1,c1); +ERROR 42S21: Duplicate column name 'c1' +alter table t1 add key (c1,c2,c1); +ERROR 42S21: Duplicate column name 'c1' +alter table t1 add key (c1,c1,c2); +ERROR 42S21: Duplicate column name 'c1' +drop table t1; +create table t1(a int(1) , b int(1)) engine=innodb; +insert into t1 values ('1111', '3333'); +select distinct concat(a, b) from t1; +concat(a, b) +11113333 +drop table t1; +CREATE TABLE t1 ( a char(10) ) ENGINE=InnoDB; +SELECT a FROM t1 WHERE MATCH (a) AGAINST ('test' IN BOOLEAN MODE); +ERROR HY000: The used table type doesn't support FULLTEXT indexes +DROP TABLE t1; +CREATE TABLE t1 (a_id tinyint(4) NOT NULL default '0', PRIMARY KEY (a_id)) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES (1),(2),(3); +CREATE TABLE t2 (b_id tinyint(4) NOT NULL default '0',b_a tinyint(4) NOT NULL default '0', PRIMARY KEY (b_id), KEY (b_a), +CONSTRAINT fk_b_a FOREIGN KEY (b_a) REFERENCES t1 (a_id) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t2 VALUES (1,1),(2,1),(3,1),(4,2),(5,2); +SELECT * FROM (SELECT t1.*,GROUP_CONCAT(t2.b_id SEPARATOR ',') as b_list FROM (t1 LEFT JOIN (t2) on t1.a_id = t2.b_a) GROUP BY t1.a_id ) AS xyz; +a_id b_list +1 1,2,3 +2 4,5 +3 NULL +DROP TABLE t2; +DROP TABLE t1; create table t1 (x bigint unsigned not null primary key) engine=innodb; insert into t1(x) values (0xfffffffffffffff0),(0xfffffffffffffff1); select * from t1; @@ -1688,24 +1727,6 @@ select count(*) from t1 where x = 18446744073709551601; count(*) 1 drop table t1; -create table t1 (c char(10), index (c,c)) engine=innodb; -ERROR 42S21: Duplicate column name 'c' -create table t1 (c1 char(10), c2 char(10), index (c1,c2,c1)) engine=innodb; -ERROR 42S21: Duplicate column name 'c1' -create table t1 (c1 char(10), c2 char(10), index (c1,c1,c2)) engine=innodb; -ERROR 42S21: Duplicate column name 'c1' -create table t1 (c1 char(10), c2 char(10), index (c2,c1,c1)) engine=innodb; -ERROR 42S21: Duplicate column name 'c1' -create table t1 (c1 char(10), c2 char(10)) engine=innodb; -alter table t1 add key (c1,c1); -ERROR 42S21: Duplicate column name 'c1' -alter table t1 add key (c2,c1,c1); -ERROR 42S21: Duplicate column name 'c1' -alter table t1 add key (c1,c2,c1); -ERROR 42S21: Duplicate column name 'c1' -alter table t1 add key (c1,c1,c2); -ERROR 42S21: Duplicate column name 'c1' -drop table t1; show status like "Innodb_buffer_pool_pages_total"; Variable_name Value Innodb_buffer_pool_pages_total 512 @@ -2391,16 +2412,6 @@ drop table t1; set storage_engine=MyISAM; create table t1 (v varchar(16384)) engine=innodb; drop table t1; -create table t1(a int(1) , b int(1)) engine=innodb; -insert into t1 values ('1111', '3333'); -select distinct concat(a, b) from t1; -concat(a, b) -11113333 -drop table t1; -CREATE TABLE t1 ( a char(10) ) ENGINE=InnoDB; -SELECT a FROM t1 WHERE MATCH (a) AGAINST ('test' IN BOOLEAN MODE); -ERROR HY000: The used table type doesn't support FULLTEXT indexes -DROP TABLE t1; create table t1 (a char(1), b char(1), key(a, b)) engine=innodb; insert into t1 values ('8', '6'), ('4', '7'); select min(a) from t1; diff --git a/mysql-test/r/olap.result b/mysql-test/r/olap.result index 5ba2bc80484..c37a42d3fa7 100644 --- a/mysql-test/r/olap.result +++ b/mysql-test/r/olap.result @@ -88,7 +88,7 @@ TV NULL NULL 600 NULL NULL NULL 7785 explain extended select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup; id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 15 Using temporary; Using filesort +1 SIMPLE t1 ALL NULL NULL NULL NULL 15 Using filesort Warnings: Note 1003 select `test`.`t1`.`product` AS `product`,`test`.`t1`.`country_id` AS `country_id`,`test`.`t1`.`year` AS `year`,sum(`test`.`t1`.`profit`) AS `sum(profit)` from `test`.`t1` group by `test`.`t1`.`product`,`test`.`t1`.`country_id`,`test`.`t1`.`year` with rollup select product, country_id , sum(profit) from t1 group by product desc, country_id with rollup; diff --git a/mysql-test/r/warnings.result b/mysql-test/r/warnings.result index 442d0784953..6803c3a40ef 100644 --- a/mysql-test/r/warnings.result +++ b/mysql-test/r/warnings.result @@ -181,3 +181,56 @@ drop table t1; set table_type=MYISAM; Warnings: Warning 1287 'table_type' is deprecated; use 'storage_engine' instead +create table t1 (a int); +insert into t1 (a) values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +update t1 set a='abc'; +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +Warning 1265 Data truncated for column 'a' at row 2 +Warning 1265 Data truncated for column 'a' at row 3 +Warning 1265 Data truncated for column 'a' at row 4 +Warning 1265 Data truncated for column 'a' at row 5 +Warning 1265 Data truncated for column 'a' at row 6 +Warning 1265 Data truncated for column 'a' at row 7 +Warning 1265 Data truncated for column 'a' at row 8 +Warning 1265 Data truncated for column 'a' at row 9 +Warning 1265 Data truncated for column 'a' at row 10 +show warnings limit 2, 1; +Level Code Message +Warning 1265 Data truncated for column 'a' at row 3 +show warnings limit 0, 10; +Level Code Message +Warning 1265 Data truncated for column 'a' at row 1 +Warning 1265 Data truncated for column 'a' at row 2 +Warning 1265 Data truncated for column 'a' at row 3 +Warning 1265 Data truncated for column 'a' at row 4 +Warning 1265 Data truncated for column 'a' at row 5 +Warning 1265 Data truncated for column 'a' at row 6 +Warning 1265 Data truncated for column 'a' at row 7 +Warning 1265 Data truncated for column 'a' at row 8 +Warning 1265 Data truncated for column 'a' at row 9 +Warning 1265 Data truncated for column 'a' at row 10 +show warnings limit 9, 1; +Level Code Message +Warning 1265 Data truncated for column 'a' at row 10 +show warnings limit 10, 1; +Level Code Message +show warnings limit 9, 2; +Level Code Message +Warning 1265 Data truncated for column 'a' at row 10 +show warnings limit 0, 0; +Level Code Message +show warnings limit 1; +Level Code Message +Warning 1265 Data truncated for column 'a' at row 1 +show warnings limit 0; +Level Code Message +show warnings limit 1, 0; +Level Code Message +select * from t1 limit 0; +a +select * from t1 limit 1, 0; +a +select * from t1 limit 0, 0; +a +drop table t1; diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index d9712a28788..487fa2ea76b 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -414,14 +414,17 @@ drop database mysqltest; select database(); # Connect without a database -connect (user4,localhost,mysqltest_1,,*NO-ONE*); -select database(); +connect (user1,localhost,mysqltest_1,,*NO-ONE*); +connection user1; +select database(), user(); +connection default; +disconnect user1; +use test; # # Test for Bug 856 'Naming a key "Primary" causes trouble' # -use test; --error 1280 create table t1 (a int, index `primary` (a)); --error 1280 @@ -478,8 +481,6 @@ drop table t1,t2; # This tests two additional possible errors and a hang if # an improper fix is present. # -connection default; -use test; create table t1 (a int); --error 1093 create table t1 select * from t1; @@ -501,3 +502,4 @@ create table t1(xyz.t1.name int); create table t1(t1.name int); create table t2(test.t2.name int); drop table t1,t2; + diff --git a/mysql-test/t/ctype_cp1250_ch.test b/mysql-test/t/ctype_cp1250_ch.test index 06aea7b9979..814da628fb7 100644 --- a/mysql-test/t/ctype_cp1250_ch.test +++ b/mysql-test/t/ctype_cp1250_ch.test @@ -10,3 +10,15 @@ CREATE TABLE t1 (a char(16)) character set cp1250 collate cp1250_czech_cs; INSERT INTO t1 VALUES (''); SELECT a, length(a), a='', a=' ', a=' ' FROM t1; DROP TABLE t1; + +# +# Bug#9759 Empty result with 'LIKE' and cp1250_czech_cs +# +CREATE TABLE t1 ( + popisek varchar(30) collate cp1250_general_ci NOT NULL default '', + PRIMARY KEY (`popisek`) +); +INSERT INTO t1 VALUES ('2005-01-1'); +SELECT * FROM t1 WHERE popisek = '2005-01-1'; +SELECT * FROM t1 WHERE popisek LIKE '2005-01-1'; +drop table t1; diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test index 694e0223753..96cd51f58db 100644 --- a/mysql-test/t/func_gconcat.test +++ b/mysql-test/t/func_gconcat.test @@ -214,21 +214,6 @@ SELECT GROUP_CONCAT(b ORDER BY b) FROM t1 GROUP BY a; DROP TABLE t1; # -# check null values #1 -# - ---disable_warnings -CREATE TABLE t1 (a_id tinyint(4) NOT NULL default '0', PRIMARY KEY (a_id)) ENGINE=InnoDB DEFAULT CHARSET=latin1; -INSERT INTO t1 VALUES (1),(2),(3); -CREATE TABLE t2 (b_id tinyint(4) NOT NULL default '0',b_a tinyint(4) NOT NULL default '0', PRIMARY KEY (b_id), KEY (b_a), - CONSTRAINT fk_b_a FOREIGN KEY (b_a) REFERENCES t1 (a_id) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE=InnoDB DEFAULT CHARSET=latin1; ---enable_warnings -INSERT INTO t2 VALUES (1,1),(2,1),(3,1),(4,2),(5,2); -SELECT * FROM (SELECT t1.*,GROUP_CONCAT(t2.b_id SEPARATOR ',') as b_list FROM (t1 LEFT JOIN (t2) on t1.a_id = t2.b_a) GROUP BY t1.a_id ) AS xyz; -DROP TABLE t2; -DROP TABLE t1; - -# # check null values #2 # @@ -286,18 +271,31 @@ SELECT GROUP_CONCAT(id) AS gc FROM t1 HAVING gc IS NULL; DROP TABLE t1; # +# Bug #8656: Crash with group_concat on alias in outer table +# +create table t2 (a int, b int); +insert into t2 values (1,1), (2,2); +select b x, (select group_concat(x) from t2) from t2; +drop table t2; + +# +# Bug #7405: problems with rollup +# + +create table t1 (d int not null auto_increment,primary key(d), a int, b int, c int); +insert into t1(a,b) values (1,3), (1,4), (1,2), (2,7), (1,1), (1,2), (2,3), (2,3); +select d,a,b from t1 order by a; +explain select a, group_concat(b) from t1 group by a with rollup; +select a, group_concat(b) from t1 group by a with rollup; +select a, group_concat(distinct b) from t1 group by a with rollup; +select a, group_concat(b order by b) from t1 group by a with rollup; +select a, group_concat(distinct b order by b) from t1 group by a with rollup; +drop table t1; + +# # Bug #6475 # create table t1 (a char(3), b char(20), primary key (a, b)); insert into t1 values ('ABW', 'Dutch'), ('ABW', 'English'); select group_concat(a) from t1 group by b; drop table t1; - -# -# Bug #8656: Crash with group_concat on alias in outer table -# -create table r2 (a int, b int); -insert into r2 values (1,1), (2,2); -select b x, (select group_concat(x) from r2) from r2; -drop table r2; - diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test index e3edcdfa5fc..e2d098618f5 100644 --- a/mysql-test/t/innodb.test +++ b/mysql-test/t/innodb.test @@ -615,7 +615,6 @@ truncate table t1; insert into t1 values(1),(2); select * from t1; truncate table t1; -truncate table t1; insert into t1 values(1),(2); delete from t1; select * from t1; @@ -1056,8 +1055,8 @@ insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, ""); insert t2 select * from t1; insert t3 select * from t1; checksum table t1, t2, t3, t4 quick; -checksum table t1, t2, t3; -checksum table t1, t2, t3 extended; +checksum table t1, t2, t3, t4; +checksum table t1, t2, t3, t4 extended; #show table status; drop table t1,t2,t3; @@ -1177,28 +1176,6 @@ show status like "binlog_cache_disk_use"; drop table t1; # -# range optimizer problem -# - -create table t1 (x bigint unsigned not null primary key) engine=innodb; -insert into t1(x) values (0xfffffffffffffff0),(0xfffffffffffffff1); -select * from t1; -select count(*) from t1 where x>0; -select count(*) from t1 where x=0; -select count(*) from t1 where x<0; -select count(*) from t1 where x < -16; -select count(*) from t1 where x = -16; -explain select count(*) from t1 where x > -16; - -# The following result should be (2). To be fixed when we add 'unsigned flag' to -# Field::store(longlong) -select count(*) from t1 where x > -16; -select * from t1 where x > -16; -select count(*) from t1 where x = 18446744073709551601; - -drop table t1; - -# # Bug #6126: Duplicate columns in keys gives misleading error message # --error 1060 @@ -1220,6 +1197,62 @@ alter table t1 add key (c1,c2,c1); alter table t1 add key (c1,c1,c2); drop table t1; +# +# Bug #4082: integer truncation +# + +create table t1(a int(1) , b int(1)) engine=innodb; +insert into t1 values ('1111', '3333'); +select distinct concat(a, b) from t1; +drop table t1; + +# +# BUG#7709 test case - Boolean fulltext query against unsupported +# engines does not fail +# + +CREATE TABLE t1 ( a char(10) ) ENGINE=InnoDB; +--error 1214; +SELECT a FROM t1 WHERE MATCH (a) AGAINST ('test' IN BOOLEAN MODE); +DROP TABLE t1; + +# +# check null values #1 +# + +--disable_warnings +CREATE TABLE t1 (a_id tinyint(4) NOT NULL default '0', PRIMARY KEY (a_id)) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES (1),(2),(3); +CREATE TABLE t2 (b_id tinyint(4) NOT NULL default '0',b_a tinyint(4) NOT NULL default '0', PRIMARY KEY (b_id), KEY (b_a), + CONSTRAINT fk_b_a FOREIGN KEY (b_a) REFERENCES t1 (a_id) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE=InnoDB DEFAULT CHARSET=latin1; +--enable_warnings +INSERT INTO t2 VALUES (1,1),(2,1),(3,1),(4,2),(5,2); +SELECT * FROM (SELECT t1.*,GROUP_CONCAT(t2.b_id SEPARATOR ',') as b_list FROM (t1 LEFT JOIN (t2) on t1.a_id = t2.b_a) GROUP BY t1.a_id ) AS xyz; +DROP TABLE t2; +DROP TABLE t1; + +# +# range optimizer problem +# + +create table t1 (x bigint unsigned not null primary key) engine=innodb; +insert into t1(x) values (0xfffffffffffffff0),(0xfffffffffffffff1); +select * from t1; +select count(*) from t1 where x>0; +select count(*) from t1 where x=0; +select count(*) from t1 where x<0; +select count(*) from t1 where x < -16; +select count(*) from t1 where x = -16; +explain select count(*) from t1 where x > -16; + +# The following result should be (2). To be fixed when we add 'unsigned flag' to +# Field::store(longlong) +select count(*) from t1 where x > -16; +select * from t1 where x > -16; +select count(*) from t1 where x = 18446744073709551601; +drop table t1; + + # Test for testable InnoDB status variables. This test # uses previous ones(pages_created, rows_deleted, ...). show status like "Innodb_buffer_pool_pages_total"; @@ -1302,25 +1335,6 @@ create table t1 (v varchar(16384)) engine=innodb; drop table t1; # -# Bug #4082: integer truncation -# - -create table t1(a int(1) , b int(1)) engine=innodb; -insert into t1 values ('1111', '3333'); -select distinct concat(a, b) from t1; -drop table t1; - -# -# BUG#7709 test case - Boolean fulltext query against unsupported -# engines does not fail -# - -CREATE TABLE t1 ( a char(10) ) ENGINE=InnoDB; ---error 1214; -SELECT a FROM t1 WHERE MATCH (a) AGAINST ('test' IN BOOLEAN MODE); -DROP TABLE t1; - -# # BUG#11039 Wrong key length in min() # diff --git a/mysql-test/t/warnings.test b/mysql-test/t/warnings.test index 69284b4c6e4..314432af83e 100644 --- a/mysql-test/t/warnings.test +++ b/mysql-test/t/warnings.test @@ -129,3 +129,25 @@ drop table t1; # Test for deprecated table_type variable # set table_type=MYISAM; + +# +# Tests for show warnings limit a, b +# +create table t1 (a int); +insert into t1 (a) values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +# should generate 10 warnings +update t1 set a='abc'; +show warnings limit 2, 1; +show warnings limit 0, 10; +show warnings limit 9, 1; +show warnings limit 10, 1; +show warnings limit 9, 2; +show warnings limit 0, 0; +show warnings limit 1; +show warnings limit 0; +show warnings limit 1, 0; +# make sure behaviour is consistent with select ... limit +select * from t1 limit 0; +select * from t1 limit 1, 0; +select * from t1 limit 0, 0; +drop table t1; diff --git a/mysys/raid.cc b/mysys/raid.cc index a645c0109db..29819a878c4 100644 --- a/mysys/raid.cc +++ b/mysys/raid.cc @@ -70,8 +70,6 @@ tonu@mysql.com & monty@mysql.com */ -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/examples/ha_archive.cc b/sql/examples/ha_archive.cc index 4f0cfb91d20..93cedcbf251 100644 --- a/sql/examples/ha_archive.cc +++ b/sql/examples/ha_archive.cc @@ -14,8 +14,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/examples/ha_example.cc b/sql/examples/ha_example.cc index 66d1a801333..9da297ccd1f 100644 --- a/sql/examples/ha_example.cc +++ b/sql/examples/ha_example.cc @@ -63,8 +63,6 @@ -Brian */ -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/examples/ha_tina.cc b/sql/examples/ha_tina.cc index 6ca7f67ef66..a030960d08a 100644 --- a/sql/examples/ha_tina.cc +++ b/sql/examples/ha_tina.cc @@ -38,8 +38,6 @@ TODO: -Brian */ -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/field.cc b/sql/field.cc index c87b613cb12..38fdfe4c3b3 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -19,8 +19,6 @@ ** This file implements classes defined in field.h *****************************************************************************/ -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc index 46f510bb905..16cbd782f0c 100644 --- a/sql/ha_berkeley.cc +++ b/sql/ha_berkeley.cc @@ -47,13 +47,12 @@ */ -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif #include "mysql_priv.h" + #ifdef HAVE_BERKELEY_DB #include <m_ctype.h> #include <myisampack.h> diff --git a/sql/ha_blackhole.cc b/sql/ha_blackhole.cc index 00128d3d3b6..6abbe983f48 100644 --- a/sql/ha_blackhole.cc +++ b/sql/ha_blackhole.cc @@ -15,14 +15,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION -#pragma implementation // gcc: Class implementation +#pragma implementation // gcc: Class implementation #endif #include "mysql_priv.h" - #ifdef HAVE_BLACKHOLE_DB #include "ha_blackhole.h" diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc index 3581b26a585..cd655eeb0a9 100644 --- a/sql/ha_heap.cc +++ b/sql/ha_heap.cc @@ -15,8 +15,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index d956e692152..ecd7a8d42c2 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -27,8 +27,6 @@ have disables the InnoDB inlining in this file. */ in Windows? */ -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index 3b17512c6c2..1352fd84d9d 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -15,8 +15,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc index d4dc365a163..0796ded3ac0 100644 --- a/sql/ha_myisammrg.cc +++ b/sql/ha_myisammrg.cc @@ -15,8 +15,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index e4345f87c48..b727609f7ef 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -20,10 +20,8 @@ NDB Cluster */ -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION -#pragma implementation // gcc: Class implementation +#pragma implementation // gcc: Class implementation #endif #include "mysql_priv.h" diff --git a/sql/handler.cc b/sql/handler.cc index ffd6fbc5916..965c3d26f49 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -17,8 +17,6 @@ /* Handler-calling-functions */ -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/hash_filo.cc b/sql/hash_filo.cc index 34f3cd6b035..ec200768222 100644 --- a/sql/hash_filo.cc +++ b/sql/hash_filo.cc @@ -20,8 +20,6 @@ ** to usage. */ -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/item.cc b/sql/item.cc index 4f971d952fd..5f6fa6bd50f 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -15,12 +15,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif - #include "mysql_priv.h" #include <m_ctype.h> #include "my_dir.h" diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 3f25d473792..28ab38c5aed 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -17,8 +17,6 @@ /* This file defines all compare functions */ -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/item_func.cc b/sql/item_func.cc index 432675f90dc..bf202124d1e 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -17,8 +17,6 @@ /* This file defines all numerical functions */ -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif @@ -2373,7 +2371,7 @@ longlong Item_func_field::val_int() return 0; for (uint i=1; i < arg_count ; i++) { - if (!args[i]->is_null() && val == args[i]->val_int()) + if (val == args[i]->val_int() && !args[i]->null_value) return (longlong) (i); } } @@ -2386,7 +2384,7 @@ longlong Item_func_field::val_int() for (uint i=1; i < arg_count; i++) { dec_arg= args[i]->val_decimal(&dec_arg_buf); - if (!args[i]->is_null() && !my_decimal_cmp(dec_arg, dec)) + if (!args[i]->null_value && !my_decimal_cmp(dec_arg, dec)) return (longlong) (i); } } @@ -2397,7 +2395,7 @@ longlong Item_func_field::val_int() return 0; for (uint i=1; i < arg_count ; i++) { - if (!args[i]->is_null() && val == args[i]->val_real()) + if (val == args[i]->val() && !args[i]->null_value) return (longlong) (i); } } diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc index 3173994f90f..4a6ceb4bf7d 100644 --- a/sql/item_geofunc.cc +++ b/sql/item_geofunc.cc @@ -17,14 +17,11 @@ /* This file defines all spatial functions */ -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif #include "mysql_priv.h" - #ifdef HAVE_SPATIAL #include <m_ctype.h> diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index c43f65c731c..d3327a0e41f 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -20,8 +20,6 @@ ** (This shouldn't be needed) */ -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 4c2f17e94e0..1569b6f2f12 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -22,8 +22,6 @@ SUBSELECT TODO: (sql_select.h/sql_select.cc) */ -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 6d5b3248fc3..9da915c8c2a 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -17,8 +17,6 @@ /* Sum functions (COUNT, MIN...) */ -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index b07de7eb21d..564c5e4b9cc 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -17,8 +17,6 @@ /* This file defines all time functions */ -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/item_uniq.cc b/sql/item_uniq.cc index f6cf83ebb10..79b2ca68f4f 100644 --- a/sql/item_uniq.cc +++ b/sql/item_uniq.cc @@ -16,10 +16,8 @@ /* Compability file */ -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION -#pragma implementation +#pragma implementation // gcc: Class implementation #endif #include "mysql_priv.h" diff --git a/sql/log_event.cc b/sql/log_event.cc index d4225b39704..db631f756bd 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -17,11 +17,10 @@ #ifndef MYSQL_CLIENT -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif + #include "mysql_priv.h" #include "slave.h" #include <my_dir.h> diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 87d27a4bea2..cf60a33e70d 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -53,7 +53,7 @@ inline query_id_t next_query_id() { return query_id++; } /* useful constants */ extern const key_map key_map_empty; -extern const key_map key_map_full; +extern key_map key_map_full; /* Should be threaded as const */ extern const char *primary_key_name; #include "mysql_com.h" diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 6625696c911..a0c35b58a4d 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -381,6 +381,9 @@ char mysql_real_data_home[FN_REFLEN], *opt_init_file, *opt_tc_log_file, def_ft_boolean_syntax[sizeof(ft_boolean_syntax)]; +const key_map key_map_empty(0); +key_map key_map_full(0); // Will be initialized later + const char *opt_date_time_formats[3]; char *mysql_data_home= mysql_real_data_home; @@ -5931,7 +5934,8 @@ static void mysql_init_variables(void) bzero((gptr) &mysql_tmpdir_list, sizeof(mysql_tmpdir_list)); bzero((char *) &global_status_var, sizeof(global_status_var)); opt_large_pages= 0; - + key_map_full.set_all(); + /* Character sets */ system_charset_info= &my_charset_utf8_general_ci; files_charset_info= &my_charset_utf8_general_ci; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 0e034564bf7..b3301d17655 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -36,8 +36,6 @@ QUICK_RANGEs are also created in this step. */ -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/opt_range.h b/sql/opt_range.h index b639ba6efa7..37d77033c8d 100644 --- a/sql/opt_range.h +++ b/sql/opt_range.h @@ -691,10 +691,14 @@ class SQL_SELECT :public Sql_alloc { ~SQL_SELECT(); void cleanup(); bool check_quick(THD *thd, bool force_quick_range, ha_rows limit) - { return test_quick_select(thd, key_map(~(uint)0), 0, limit, force_quick_range) < 0; } + { + key_map tmp; + tmp.set_all(); + return test_quick_select(thd, tmp, 0, limit, force_quick_range) < 0; + } inline bool skip_record() { return cond ? cond->val_int() == 0 : 0; } int test_quick_select(THD *thd, key_map keys, table_map prev_tables, - ha_rows limit, bool force_quick_range=0); + ha_rows limit, bool force_quick_range); }; diff --git a/sql/procedure.cc b/sql/procedure.cc index 38a043300bc..554e2cd0565 100644 --- a/sql/procedure.cc +++ b/sql/procedure.cc @@ -17,8 +17,6 @@ /* Procedures (functions with changes output of select) */ -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/protocol.cc b/sql/protocol.cc index 8019f3a123b..57922cdc677 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -19,8 +19,6 @@ The actual communction is handled by the net_xxx functions in net_serv.cc */ -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/protocol_cursor.cc b/sql/protocol_cursor.cc index c38a7cdecae..ed2d0b583d0 100644 --- a/sql/protocol_cursor.cc +++ b/sql/protocol_cursor.cc @@ -19,8 +19,6 @@ The actual communction is handled by the net_xxx functions in net_serv.cc */ -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/set_var.cc b/sql/set_var.cc index 0d743f99b73..3f8c8ea2508 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -48,8 +48,6 @@ new attribute. */ -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc index 55e6dfb3cbe..6706cee8e9d 100644 --- a/sql/sql_analyse.cc +++ b/sql/sql_analyse.cc @@ -23,8 +23,6 @@ ** - type set is out of optimization yet */ -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 96700e96363..37236735460 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2096,7 +2096,7 @@ bool open_and_lock_tables(THD *thd, TABLE_LIST *tables) SYNOPSIS open_normal_and_derived_tables thd - thread handler - tables - list of tables for open&locking + tables - list of tables for open RETURN FALSE - ok diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 862cf940173..438bfdbcb73 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -22,8 +22,6 @@ ** *****************************************************************************/ -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/sql_crypt.cc b/sql/sql_crypt.cc index eda7f0f6bbb..f21a109e95d 100644 --- a/sql/sql_crypt.cc +++ b/sql/sql_crypt.cc @@ -23,8 +23,6 @@ needs something like 'ssh'. */ -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/sql_error.cc b/sql/sql_error.cc index 3bda16202b9..293b695d199 100644 --- a/sql/sql_error.cc +++ b/sql/sql_error.cc @@ -239,6 +239,8 @@ bool mysqld_show_warnings(THD *thd, ulong levels_to_show) offset--; continue; } + if (limit-- == 0) + break; protocol->prepare_for_resend(); protocol->store(warning_level_names[err->level], warning_level_length[err->level], system_charset_info); @@ -246,8 +248,6 @@ bool mysqld_show_warnings(THD *thd, ulong levels_to_show) protocol->store(err->msg, strlen(err->msg), system_charset_info); if (protocol->write()) DBUG_RETURN(TRUE); - if (!--limit) - break; } send_eof(thd); DBUG_RETURN(FALSE); diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 6fb871cbc9d..5ca75554c6f 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1094,7 +1094,7 @@ public: volatile bool status,dead; COPY_INFO info; I_List<delayed_row> rows; - uint group_count; + ulong group_count; TABLE_LIST table_list; // Argument delayed_insert() @@ -1766,7 +1766,7 @@ static void free_delayed_insert_blobs(register TABLE *table) bool delayed_insert::handle_inserts(void) { int error; - uint max_rows; + ulong max_rows; bool using_ignore=0, using_bin_log=mysql_bin_log.is_open(); delayed_row *row; DBUG_ENTER("handle_inserts"); @@ -1785,11 +1785,11 @@ bool delayed_insert::handle_inserts(void) } thd.proc_info="insert"; - max_rows=delayed_insert_limit; + max_rows= delayed_insert_limit; if (thd.killed || table->s->version != refresh_version) { thd.killed= THD::KILL_CONNECTION; - max_rows= ~(uint)0; // Do as much as possible + max_rows= ~(ulong)0; // Do as much as possible } /* diff --git a/sql/sql_list.cc b/sql/sql_list.cc index 485c569f49c..d57a7dfe4e3 100644 --- a/sql/sql_list.cc +++ b/sql/sql_list.cc @@ -15,8 +15,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/sql_map.cc b/sql/sql_map.cc index 556d37a405c..9346f3df305 100644 --- a/sql/sql_map.cc +++ b/sql/sql_map.cc @@ -15,8 +15,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/sql_olap.cc b/sql/sql_olap.cc index b349eda0e2e..831b15cf7ef 100644 --- a/sql/sql_olap.cc +++ b/sql/sql_olap.cc @@ -28,8 +28,6 @@ #ifdef DISABLED_UNTIL_REWRITTEN_IN_4_1 -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 91db0f50f24..7957c9388c6 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2747,7 +2747,7 @@ mysql_execute_command(THD *thd) TABLE_LIST *select_tables= lex->query_tables; if ((res= create_table_precheck(thd, select_tables, create_table))) - goto unsent_create_error; + goto end_with_restore_list; #ifndef HAVE_READLINK lex->create_info.data_file_name=lex->create_info.index_file_name=0; @@ -2757,7 +2757,7 @@ mysql_execute_command(THD *thd) create_table->table_name) || append_file_to_dir(thd, &lex->create_info.index_file_name, create_table->table_name)) - goto unsent_create_error; + goto end_with_restore_list; #endif /* If we are using SET CHARSET without DEFAULT, add an implicit @@ -2787,8 +2787,8 @@ mysql_execute_command(THD *thd) */ if (wait_if_global_read_lock(thd, 0, 1)) { - res= -1; - goto unsent_create_error; + res= 1; + goto end_with_restore_list; } if (select_lex->item_list.elements) // With select { @@ -2807,7 +2807,8 @@ mysql_execute_command(THD *thd) unique_table(create_table, select_tables)) { my_error(ER_UPDATE_TABLE_USED, MYF(0), create_table->table_name); - goto unsent_create_error1; + res= 1; + goto end_with_restart_wait; } /* If we create merge table, we have to test tables in merge, too */ if (lex->create_info.used_fields & HA_CREATE_USED_UNION) @@ -2820,7 +2821,8 @@ mysql_execute_command(THD *thd) if (unique_table(tab, select_tables)) { my_error(ER_UPDATE_TABLE_USED, MYF(0), tab->table_name); - goto unsent_create_error1; + res= 1; + goto end_with_restart_wait; } } } @@ -2863,15 +2865,8 @@ mysql_execute_command(THD *thd) if (!res) send_ok(thd); } - /* - Release the protection against the global read lock and wake - everyone, who might want to set a global read lock. - */ - start_waiting_global_read_lock(thd); - lex->link_first_table_back(create_table, link_to_local); - break; -unsent_create_error1: +end_with_restart_wait: /* Release the protection against the global read lock and wake everyone, who might want to set a global read lock. @@ -2879,9 +2874,9 @@ unsent_create_error1: start_waiting_global_read_lock(thd); /* put tables back for PS rexecuting */ -unsent_create_error: +end_with_restore_list: lex->link_first_table_back(create_table, link_to_local); - goto error; + break; } case SQLCOM_CREATE_INDEX: DBUG_ASSERT(first_table == all_tables && first_table != 0); diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 71cebb61ae6..9e82661d790 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -84,7 +84,7 @@ static int send_file(THD *thd) char fname[FN_REFLEN+1]; const char *errmsg = 0; int old_timeout; - uint packet_len; + unsigned long packet_len; char buf[IO_SIZE]; // It's safe to alloc this DBUG_ENTER("send_file"); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 2f1761387ae..e6702faa4e3 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -17,8 +17,6 @@ /* mysql_select and join optimization */ -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif @@ -36,9 +34,6 @@ const char *join_type_str[]={ "UNKNOWN","system","const","eq_ref","ref", "index_merge" }; -const key_map key_map_empty(0); -const key_map key_map_full(~(uint)0); - static void optimize_keyuse(JOIN *join, DYNAMIC_ARRAY *keyuse_array); static bool make_join_statistics(JOIN *join, TABLE_LIST *leaves, COND *conds, DYNAMIC_ARRAY *keyuse); @@ -88,7 +83,7 @@ static bool only_eq_ref_tables(JOIN *join, ORDER *order, table_map tables); static void update_depend_map(JOIN *join); static void update_depend_map(JOIN *join, ORDER *order); static ORDER *remove_const(JOIN *join,ORDER *first_order,COND *cond, - bool *simple_order); + bool change_list, bool *simple_order); static int return_zero_rows(JOIN *join, select_result *res,TABLE_LIST *tables, List<Item> &fields, bool send_row, uint select_options, const char *info, @@ -749,7 +744,7 @@ JOIN::optimize() /* Optimize distinct away if possible */ { ORDER *org_order= order; - order=remove_const(this, order,conds,&simple_order); + order=remove_const(this, order,conds,1, &simple_order); /* If we are using ORDER BY NULL or ORDER BY const_expression, return result in any order (even if we are using a GROUP BY) @@ -817,8 +812,9 @@ JOIN::optimize() DBUG_RETURN(1); } simple_group= 0; - if (rollup.state == ROLLUP::STATE_NONE) - group_list= remove_const(this, group_list, conds, &simple_group); + group_list= remove_const(this, group_list, conds, + rollup.state == ROLLUP::STATE_NONE, + &simple_group); if (!group_list && group) { order=0; // The output has only one row @@ -830,7 +826,7 @@ JOIN::optimize() if (procedure && procedure->group) { group_list= procedure->group= remove_const(this, procedure->group, conds, - &simple_group); + 1, &simple_group); calc_group_buffer(this, group_list); } @@ -2088,8 +2084,8 @@ static ha_rows get_quick_record_count(THD *thd, SQL_SELECT *select, { select->head=table; table->reginfo.impossible_range=0; - if ((error=select->test_quick_select(thd, *(key_map *)keys,(table_map) 0, - limit)) == 1) + if ((error= select->test_quick_select(thd, *(key_map *)keys,(table_map) 0, + limit, 0)) == 1) DBUG_RETURN(select->quick->records); if (error == -1) { @@ -5091,7 +5087,8 @@ make_simple_join(JOIN *join,TABLE *tmp_table) join_tab->select_cond=0; join_tab->quick=0; join_tab->type= JT_ALL; /* Map through all records */ - join_tab->keys.init(~(uint)0); /* test everything in quick */ + join_tab->keys.init(); + join_tab->keys.set_all(); /* test everything in quick */ join_tab->info=0; join_tab->on_expr_ref=0; join_tab->last_inner= 0; @@ -5540,7 +5537,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) (join->select_options & OPTION_FOUND_ROWS ? HA_POS_ERROR : - join->unit->select_limit_cnt)) < 0) + join->unit->select_limit_cnt), 0) < 0) { /* Before reporting "Impossible WHERE" for the whole query @@ -5553,7 +5550,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) (join->select_options & OPTION_FOUND_ROWS ? HA_POS_ERROR : - join->unit->select_limit_cnt)) < 0) + join->unit->select_limit_cnt),0) < 0) DBUG_RETURN(1); // Impossible WHERE } else @@ -6122,20 +6119,39 @@ static void update_depend_map(JOIN *join, ORDER *order) /* - simple_order is set to 1 if sort_order only uses fields from head table - and the head table is not a LEFT JOIN table + Remove all constants and check if ORDER only contains simple expressions + + SYNOPSIS + remove_const() + join Join handler + first_order List of SORT or GROUP order + cond WHERE statement + change_list Set to 1 if we should remove things from list + If this is not set, then only simple_order is + calculated + simple_order Set to 1 if we are only using simple expressions + + RETURN + Returns new sort order + + simple_order is set to 1 if sort_order only uses fields from head table + and the head table is not a LEFT JOIN table + */ static ORDER * -remove_const(JOIN *join,ORDER *first_order, COND *cond, bool *simple_order) +remove_const(JOIN *join,ORDER *first_order, COND *cond, + bool change_list, bool *simple_order) { if (join->tables == join->const_tables) - return 0; // No need to sort - DBUG_ENTER("remove_const"); + return change_list ? 0 : first_order; // No need to sort + ORDER *order,**prev_ptr; table_map first_table= join->join_tab[join->const_tables].table->map; table_map not_const_tables= ~join->const_table_map; table_map ref; + DBUG_ENTER("remove_const"); + prev_ptr= &first_order; *simple_order= *join->join_tab[join->const_tables].on_expr_ref ? 0 : 1; @@ -6166,7 +6182,8 @@ remove_const(JOIN *join,ORDER *first_order, COND *cond, bool *simple_order) } if ((ref=order_tables & (not_const_tables ^ first_table))) { - if (!(order_tables & first_table) && only_eq_ref_tables(join,first_order,ref)) + if (!(order_tables & first_table) && + only_eq_ref_tables(join,first_order, ref)) { DBUG_PRINT("info",("removing: %s", order->item[0]->full_name())); continue; @@ -6175,11 +6192,13 @@ remove_const(JOIN *join,ORDER *first_order, COND *cond, bool *simple_order) } } } - *prev_ptr= order; // use this entry + if (change_list) + *prev_ptr= order; // use this entry prev_ptr= &order->next; } - *prev_ptr=0; - if (!first_order) // Nothing to sort/group + if (change_list) + *prev_ptr=0; + if (prev_ptr == &first_order) // Nothing to sort/group *simple_order=1; DBUG_PRINT("exit",("simple_order: %d",(int) *simple_order)); DBUG_RETURN(first_order); @@ -9829,7 +9848,7 @@ test_if_quick_select(JOIN_TAB *tab) delete tab->select->quick; tab->select->quick=0; return tab->select->test_quick_select(tab->join->thd, tab->keys, - (table_map) 0, HA_POS_ERROR); + (table_map) 0, HA_POS_ERROR, 0); } @@ -10865,12 +10884,15 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, parameres are set correctly by the range optimizer. */ key_map new_ref_key_map; - new_ref_key_map.clear_all(); /* Force the creation of quick select */ - new_ref_key_map.set_bit(new_ref_key); /* only for new_ref_key. */ + new_ref_key_map.clear_all(); // Force the creation of quick select + new_ref_key_map.set_bit(new_ref_key); // only for new_ref_key. if (select->test_quick_select(tab->join->thd, new_ref_key_map, 0, - (tab->join->select_options & OPTION_FOUND_ROWS) ? - HA_POS_ERROR : tab->join->unit->select_limit_cnt) <= 0) + (tab->join->select_options & + OPTION_FOUND_ROWS) ? + HA_POS_ERROR : + tab->join->unit->select_limit_cnt,0) <= + 0) DBUG_RETURN(0); } ref_key= new_ref_key; @@ -12528,6 +12550,8 @@ bool JOIN::make_sum_func_list(List<Item> &field_list, List<Item> &send_fields, for (uint i=0 ; i <= send_group_parts ;i++) sum_funcs_end[i]= func; } + else if (rollup.state == ROLLUP::STATE_READY) + DBUG_RETURN(FALSE); // Don't put end marker *func=0; // End marker DBUG_RETURN(FALSE); } @@ -13070,12 +13094,12 @@ bool JOIN::rollup_make_fields(List<Item> &fields_arg, List<Item> &sel_fields, This is an element that is used by the GROUP BY and should be set to NULL in this level */ + Item_null_result *null_item; item->maybe_null= 1; // Value will be null sometimes null_item= rollup.null_items[i]; DBUG_ASSERT(null_item->result_field == 0 || - null_item->result_field == - ((Item_field *) item)->result_field); - null_item->result_field= ((Item_field *) item)->result_field; + null_item->result_field == item->get_tmp_table_field()); + null_item->result_field= item->get_tmp_table_field(); item= null_item; break; } diff --git a/sql/sql_string.cc b/sql/sql_string.cc index be4354227a5..51f802e7465 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -16,12 +16,11 @@ /* This file is originally from the mysql distribution. Coded by monty */ -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif +#include <my_global.h> #include <my_sys.h> #include <m_string.h> #include <m_ctype.h> diff --git a/sql/sql_table.cc b/sql/sql_table.cc index d98ae778bcf..dcc307ff813 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -346,7 +346,7 @@ int quick_rm_table(enum db_type base,const char *db, build_table_path(path, sizeof(path), db, table_name, reg_ext); if (my_delete(path,MYF(0))) error=1; /* purecov: inspected */ - build_table_path(path, sizeof(path), db, table_name, ""); + *fn_ext(path)= 0; // Remove reg_ext return ha_delete_table(current_thd, base, path, table_name, 0) || error; } @@ -1556,7 +1556,7 @@ bool mysql_create_table(THD *thd,const char *db, const char *table_name, /* Check if table exists */ if (create_info->options & HA_LEX_CREATE_TMP_TABLE) { - char tmp_table_name[NAME_LEN+1]; + char tmp_table_name[tmp_file_prefix_length+22+22+22+3]; my_snprintf(tmp_table_name, sizeof(tmp_table_name), "%s%lx_%lx_%x", tmp_file_prefix, current_pid, thd->thread_id, thd->tmp_table++); @@ -2909,7 +2909,7 @@ int mysql_create_indexes(THD *thd, TABLE_LIST *table_list, List<Key> &keys) build_table_path(path, sizeof(path), table_list->db, (lower_case_table_names == 2) ? table_list->alias : table_list->table_name, - reg_ext) != 0 || + reg_ext) == 0 || mysql_create_frm(thd, path, &create_info, fields, key_count, key_info_buffer, table->file)) /* don't need to free((gptr) key_info_buffer);*/ @@ -3010,7 +3010,7 @@ int mysql_drop_indexes(THD *thd, TABLE_LIST *table_list, build_table_path(path, sizeof(path), table_list->db, (lower_case_table_names == 2) ? table_list->alias : table_list->table_name, - reg_ext) != 0 || + reg_ext) == 0 || mysql_create_frm(thd, path, &create_info, fields, key_count, key_info_buffer, table->file)) /*don't need to free((gptr) key_numbers);*/ diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index 7c6e88306d9..e0c3034a58a 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -28,10 +28,8 @@ dynamic functions, so this shouldn't be a real problem. */ -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION -#pragma implementation // gcc: implement sql_udf.h +#pragma implementation // gcc: Class implementation #endif #include "mysql_priv.h" diff --git a/sql/tztime.cc b/sql/tztime.cc index a52b9701e8e..f5111459da2 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -25,12 +25,11 @@ it creates unsolved link dependencies on some platforms. */ -#include <my_global.h> - #ifdef USE_PRAGMA_IMPLEMENTATION #pragma implementation // gcc: Class implementation #endif +#include <my_global.h> #if !defined(TZINFO2SQL) && !defined(TESTTIME) #include "mysql_priv.h" #else diff --git a/strings/ctype-win1250ch.c b/strings/ctype-win1250ch.c index 8ac80ed392b..b840a58a499 100644 --- a/strings/ctype-win1250ch.c +++ b/strings/ctype-win1250ch.c @@ -552,7 +552,7 @@ static uchar NEAR like_range_prefix_max_win1250ch[] = { 240, 242, 242, 245, 245, 245, 245, 247, 248, 251, 251, 251, 251, 253, 254, 255, }; -#define min_sort_char '\x00' +#define min_sort_char '\x20' #define max_sort_char '\xff' /* |