2699 Sergey Petrunia 2008-11-01 [merge]
mysql-6.0 -> mysql-6.0-opt merge
modified:
.bzrignore
BUILD/compile-dist
configure.in
zlib/gzio.c
=== modified file '.bzr-mysql/default.conf'
--- a/.bzr-mysql/default.conf 2008-10-31 14:01:41 +0000
+++ b/.bzr-mysql/default.conf 2008-11-01 17:24:56 +0000
@@ -1,5 +1,5 @@
[MYSQL]
-tree_location = bzr+ssh://bk-internal.mysql.com/bzrroot/server/mysql-6.0
+tree_location = bzr+ssh://bk-internal.mysql.com/bzrroot/server/mysql-6.0-opt
post_commit_to = commits@stripped
post_push_to = commits@stripped
-tree_name = mysql-6.0
+tree_name = mysql-6.0-opt
=== modified file 'mysql-test/r/group_by.result'
--- a/mysql-test/r/group_by.result 2008-04-01 15:13:57 +0000
+++ b/mysql-test/r/group_by.result 2008-09-09 19:36:23 +0000
@@ -1624,7 +1624,7 @@ b
NULL
1
2
-DROP TABLE t1;
+DROP TABLE t1, t2;
CREATE TABLE t1 ( a INT, b INT );
SELECT b c, (SELECT a FROM t1 WHERE b = c)
FROM t1;
@@ -1661,3 +1661,33 @@ FROM t1;
ERROR 21000: Subquery returns more than 1 row
DROP TABLE t1;
SET @@sql_mode = @old_sql_mode;
+
+BUG#38072: Wrong result: HAVING not observed in a query with aggregate
+
+CREATE TABLE t1 (
+pk int(11) NOT NULL AUTO_INCREMENT,
+int_nokey int(11) NOT NULL,
+int_key int(11) NOT NULL,
+varchar_key varchar(1) NOT NULL,
+varchar_nokey varchar(1) NOT NULL,
+PRIMARY KEY (pk),
+KEY int_key (int_key),
+KEY varchar_key (varchar_key)
+);
+INSERT INTO t1 VALUES
+(1,5,5, 'h','h'),
+(2,1,1, '{','{'),
+(3,1,1, 'z','z'),
+(4,8,8, 'x','x'),
+(5,7,7, 'o','o'),
+(6,3,3, 'p','p'),
+(7,9,9, 'c','c'),
+(8,0,0, 'k','k'),
+(9,6,6, 't','t'),
+(10,0,0,'c','c');
+explain SELECT COUNT(varchar_key) AS X FROM t1 WHERE pk = 8 having 'foo'='bar';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible HAVING
+SELECT COUNT(varchar_key) AS X FROM t1 WHERE pk = 8 having 'foo'='bar';
+X
+drop table t1;
=== modified file 'mysql-test/r/innodb_mrr.result'
--- a/mysql-test/r/innodb_mrr.result 2008-01-24 00:46:18 +0000
+++ b/mysql-test/r/innodb_mrr.result 2008-09-05 14:36:37 +0000
@@ -314,3 +314,40 @@ f1 f2 f3 f4
9 9 9 A
10 10 10 A
drop table t1;
+
+BUG#37977: Wrong result returned on GROUP BY + OR + Innodb
+
+CREATE TABLE t1 (
+`pk` int(11) NOT NULL AUTO_INCREMENT,
+`int_nokey` int(11) NOT NULL,
+`int_key` int(11) NOT NULL,
+`date_key` date NOT NULL,
+`date_nokey` date NOT NULL,
+`time_key` time NOT NULL,
+`time_nokey` time NOT NULL,
+`datetime_key` datetime NOT NULL,
+`datetime_nokey` datetime NOT NULL,
+`varchar_key` varchar(5) DEFAULT NULL,
+`varchar_nokey` varchar(5) DEFAULT NULL,
+PRIMARY KEY (`pk`),
+KEY `int_key` (`int_key`),
+KEY `date_key` (`date_key`),
+KEY `time_key` (`time_key`),
+KEY `datetime_key` (`datetime_key`),
+KEY `varchar_key` (`varchar_key`)
+) ENGINE=InnoDB;
+INSERT INTO t1 VALUES
+(1,5,5,'2009-10-16','2009-10-16','09:28:15','09:28:15','2007-09-14 05:34:08','2007-09-14 05:34:08','qk','qk'),
+(2,6,6,'0000-00-00','0000-00-00','23:06:39','23:06:39','0000-00-00 00:00:00','0000-00-00 00:00:00','j','j'),
+(3,10,10,'2000-12-18','2000-12-18','22:16:19','22:16:19','2006-11-04 15:42:50','2006-11-04 15:42:50','aew','aew'),
+(4,0,0,'2001-09-18','2001-09-18','00:00:00','00:00:00','2004-03-23 13:23:35','2004-03-23 13:23:35',NULL,NULL),
+(5,6,6,'2007-08-16','2007-08-16','22:13:38','22:13:38','2004-08-19 11:01:28','2004-08-19 11:01:28','qu','qu');
+select pk from t1 WHERE `varchar_key` > 'kr' group by pk;
+pk
+1
+5
+select pk from t1 WHERE `int_nokey` IS NULL OR `varchar_key` > 'kr' group by pk;
+pk
+1
+5
+drop table t1;
=== modified file 'mysql-test/r/myisam_mrr.result'
--- a/mysql-test/r/myisam_mrr.result 2008-01-10 22:04:59 +0000
+++ b/mysql-test/r/myisam_mrr.result 2008-09-05 19:23:07 +0000
@@ -303,3 +303,32 @@ ID col1 key1 key2 text1 text2 col2 col3
3 NULL 1130 NULL red NULL 100 bodyandsubject 0
4 NULL 1130 NULL yellow NULL 100 bodyandsubject 0
drop table t1;
+
+BUG#37851: Crash in test_if_skip_sort_order tab->select is zero
+
+CREATE TABLE t1 (
+pk int(11) NOT NULL AUTO_INCREMENT,
+PRIMARY KEY (pk)
+);
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 (
+pk int(11) NOT NULL AUTO_INCREMENT,
+int_key int(11) DEFAULT NULL,
+PRIMARY KEY (pk),
+KEY int_key (int_key)
+);
+INSERT INTO t2 VALUES (1,1),(2,6),(3,0);
+EXPLAIN EXTENDED
+SELECT MIN(t1.pk)
+FROM t1 WHERE EXISTS (
+SELECT t2.pk
+FROM t2
+WHERE t2.int_key IS NULL
+GROUP BY t2.pk
+);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+2 SUBQUERY t2 ALL int_key int_key 5 3 33.33 Using index condition; Using filesort
+Warnings:
+Note 1003 select min(`test`.`t1`.`pk`) AS `MIN(t1.pk)` from `test`.`t1` where 0
+DROP TABLE t1, t2;
=== modified file 'mysql-test/r/ps_ddl.result'
--- a/mysql-test/r/ps_ddl.result 2008-08-13 20:05:34 +0000
+++ b/mysql-test/r/ps_ddl.result 2008-09-13 14:16:20 +0000
@@ -1655,6 +1655,18 @@ SQL statement where it is needed.
#
# SQLCOM_SELECT
#
+drop table if exists t1;
+create table t1 (a int);
+prepare stmt from "select 1 as res from dual where (1) in (select * from t1)";
+drop table t1;
+create table t1 (x int);
+execute stmt;
+res
+drop table t1;
+deallocate prepare stmt;
+call p_verify_reprepare_count(1);
+SUCCESS
+
#
# SQLCOM_CREATE_TABLE
#
=== modified file 'mysql-test/r/subselect3.result'
--- a/mysql-test/r/subselect3.result 2008-08-20 01:52:25 +0000
+++ b/mysql-test/r/subselect3.result 2008-09-13 14:16:20 +0000
@@ -1,4 +1,4 @@
-drop table if exists t0, t1, t2, t3, t4, t5;
+drop table if exists t0, t1, t2, t3, t4;
create table t1 (oref int, grp int, ie int) ;
insert into t1 (oref, grp, ie) values
(1, 1, 1),
@@ -789,29 +789,10 @@ a b
1 0.123
drop table t1;
End of 5.0 tests
-create table t0 (a int);
-insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
-create table t1 (
-a int(11) default null,
-b int(11) default null,
-key (a)
-);
-insert into t1 select A.a+10*(B.a+10*C.a),A.a+10*(B.a+10*C.a) from t0 A, t0 B, t0 C;
-create table t2 (a int(11) default null);
-insert into t2 values (0),(1);
-create table t3 (a int(11) default null);
-insert into t3 values (0),(1);
-create table t4 (a int(11) default null);
-insert into t4 values (0),(1);
-create table t5 (a int(11) default null);
-insert into t5 values (0),(1),(0),(1);
-select * from t2, t3
-where
-t2.a < 10 and
-t3.a+1 = 2 and
-t3.a in (select t1.b from t1
-where t1.a+1=t1.a+1 and
-t1.a < (select t4.a+10
-from t4, t5 limit 2));
-ERROR 21000: Subquery returns more than 1 row
-drop table t0, t1, t2, t3, t4, t5;
+#
+# BUG#36896: Server crash on SELECT FROM DUAL
+#
+create table t1 (a int);
+select 1 as res from dual where (1) in (select * from t1);
+res
+drop table t1;
=== modified file 'mysql-test/r/sum_distinct.result'
--- a/mysql-test/r/sum_distinct.result 2005-04-07 16:24:14 +0000
+++ b/mysql-test/r/sum_distinct.result 2008-09-05 19:01:46 +0000
@@ -95,3 +95,26 @@ SELECT SUM(DISTINCT id % 11) FROM t1;
SUM(DISTINCT id % 11)
55
DROP TABLE t1;
+
+BUG#37891: Column cannot be null error with aggregate in a subquery
+
+CREATE TABLE t1 (
+pk int(11) NOT NULL AUTO_INCREMENT,
+int_key int(11) DEFAULT NULL,
+PRIMARY KEY (pk),
+KEY int_key (int_key)
+);
+INSERT INTO t1 VALUES (1,10);
+CREATE TABLE t2 (
+pk int(11) NOT NULL AUTO_INCREMENT,
+time_nokey time DEFAULT NULL,
+datetime_key time DEFAULT NULL,
+PRIMARY KEY (pk),
+KEY datetime_key (datetime_key)
+);
+INSERT INTO t2 VALUES (1,'18:19:29',NOW());
+SELECT * FROM t1 WHERE int_key IN ( SELECT SUM(DISTINCT pk) FROM t2 WHERE time_nokey = datetime_key );
+pk int_key
+SELECT * FROM t1 WHERE int_key IN ( SELECT AVG(DISTINCT pk) FROM t2 WHERE time_nokey = datetime_key );
+pk int_key
+drop table t1,t2;
=== modified file 'mysql-test/t/group_by.test'
--- a/mysql-test/t/group_by.test 2008-04-01 15:13:57 +0000
+++ b/mysql-test/t/group_by.test 2008-09-09 19:36:23 +0000
@@ -1062,7 +1062,7 @@ SELECT a from t2 GROUP BY a;
EXPLAIN SELECT b from t2 GROUP BY b;
SELECT b from t2 GROUP BY b;
-DROP TABLE t1;
+DROP TABLE t1, t2;
#
# Bug #31797: error while parsing subqueries -- WHERE is parsed as HAVING
@@ -1109,5 +1109,32 @@ FROM t1;
DROP TABLE t1;
SET @@sql_mode = @old_sql_mode;
-
+--echo
+--echo BUG#38072: Wrong result: HAVING not observed in a query with aggregate
+--echo
+CREATE TABLE t1 (
+ pk int(11) NOT NULL AUTO_INCREMENT,
+ int_nokey int(11) NOT NULL,
+ int_key int(11) NOT NULL,
+ varchar_key varchar(1) NOT NULL,
+ varchar_nokey varchar(1) NOT NULL,
+ PRIMARY KEY (pk),
+ KEY int_key (int_key),
+ KEY varchar_key (varchar_key)
+);
+INSERT INTO t1 VALUES
+(1,5,5, 'h','h'),
+(2,1,1, '{','{'),
+(3,1,1, 'z','z'),
+(4,8,8, 'x','x'),
+(5,7,7, 'o','o'),
+(6,3,3, 'p','p'),
+(7,9,9, 'c','c'),
+(8,0,0, 'k','k'),
+(9,6,6, 't','t'),
+(10,0,0,'c','c');
+
+explain SELECT COUNT(varchar_key) AS X FROM t1 WHERE pk = 8 having 'foo'='bar';
+SELECT COUNT(varchar_key) AS X FROM t1 WHERE pk = 8 having 'foo'='bar';
+drop table t1;
=== modified file 'mysql-test/t/innodb_mrr.test'
--- a/mysql-test/t/innodb_mrr.test 2008-01-24 00:46:18 +0000
+++ b/mysql-test/t/innodb_mrr.test 2008-09-05 14:36:37 +0000
@@ -66,3 +66,36 @@ select * from t1 where (f3>=5 and f3<=10
drop table t1;
+--echo
+--echo BUG#37977: Wrong result returned on GROUP BY + OR + Innodb
+--echo
+CREATE TABLE t1 (
+ `pk` int(11) NOT NULL AUTO_INCREMENT,
+ `int_nokey` int(11) NOT NULL,
+ `int_key` int(11) NOT NULL,
+ `date_key` date NOT NULL,
+ `date_nokey` date NOT NULL,
+ `time_key` time NOT NULL,
+ `time_nokey` time NOT NULL,
+ `datetime_key` datetime NOT NULL,
+ `datetime_nokey` datetime NOT NULL,
+ `varchar_key` varchar(5) DEFAULT NULL,
+ `varchar_nokey` varchar(5) DEFAULT NULL,
+ PRIMARY KEY (`pk`),
+ KEY `int_key` (`int_key`),
+ KEY `date_key` (`date_key`),
+ KEY `time_key` (`time_key`),
+ KEY `datetime_key` (`datetime_key`),
+ KEY `varchar_key` (`varchar_key`)
+) ENGINE=InnoDB;
+
+INSERT INTO t1 VALUES
+(1,5,5,'2009-10-16','2009-10-16','09:28:15','09:28:15','2007-09-14 05:34:08','2007-09-14 05:34:08','qk','qk'),
+(2,6,6,'0000-00-00','0000-00-00','23:06:39','23:06:39','0000-00-00 00:00:00','0000-00-00 00:00:00','j','j'),
+(3,10,10,'2000-12-18','2000-12-18','22:16:19','22:16:19','2006-11-04 15:42:50','2006-11-04 15:42:50','aew','aew'),
+(4,0,0,'2001-09-18','2001-09-18','00:00:00','00:00:00','2004-03-23 13:23:35','2004-03-23 13:23:35',NULL,NULL),
+(5,6,6,'2007-08-16','2007-08-16','22:13:38','22:13:38','2004-08-19 11:01:28','2004-08-19 11:01:28','qu','qu');
+select pk from t1 WHERE `varchar_key` > 'kr' group by pk;
+select pk from t1 WHERE `int_nokey` IS NULL OR `varchar_key` > 'kr' group by pk;
+drop table t1;
+
=== modified file 'mysql-test/t/myisam_mrr.test'
--- a/mysql-test/t/myisam_mrr.test 2008-01-10 22:04:59 +0000
+++ b/mysql-test/t/myisam_mrr.test 2008-09-05 19:23:07 +0000
@@ -45,3 +45,32 @@ select * FROM t1 WHERE key1=1130 AND col
drop table t1;
+
+--echo
+--echo BUG#37851: Crash in test_if_skip_sort_order tab->select is zero
+--echo
+CREATE TABLE t1 (
+ pk int(11) NOT NULL AUTO_INCREMENT,
+ PRIMARY KEY (pk)
+);
+INSERT INTO t1 VALUES (1);
+
+CREATE TABLE t2 (
+ pk int(11) NOT NULL AUTO_INCREMENT,
+ int_key int(11) DEFAULT NULL,
+ PRIMARY KEY (pk),
+ KEY int_key (int_key)
+);
+INSERT INTO t2 VALUES (1,1),(2,6),(3,0);
+
+EXPLAIN EXTENDED
+SELECT MIN(t1.pk)
+FROM t1 WHERE EXISTS (
+ SELECT t2.pk
+ FROM t2
+ WHERE t2.int_key IS NULL
+ GROUP BY t2.pk
+);
+
+DROP TABLE t1, t2;
+
=== modified file 'mysql-test/t/ps_ddl.test'
--- a/mysql-test/t/ps_ddl.test 2008-08-13 20:05:34 +0000
+++ b/mysql-test/t/ps_ddl.test 2008-09-13 14:16:20 +0000
@@ -1407,17 +1407,17 @@ deallocate prepare stmt_sp;
--echo # SQLCOM_SELECT
--echo #
-#--disable_warnings
-#drop table if exists t1;
-#--enable_warnings
-#create table t1 (a int);
-#prepare stmt from "select 1 as res from dual where (1) in (select * from t1)";
-#drop table t1;
-#create table t1 (x int);
-#execute stmt;
-#drop table t1;
-#deallocate prepare stmt;
-#call p_verify_reprepare_count(1);
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+create table t1 (a int);
+prepare stmt from "select 1 as res from dual where (1) in (select * from t1)";
+drop table t1;
+create table t1 (x int);
+execute stmt;
+drop table t1;
+deallocate prepare stmt;
+call p_verify_reprepare_count(1);
--echo #
--echo # SQLCOM_CREATE_TABLE
=== modified file 'mysql-test/t/subselect3.test'
--- a/mysql-test/t/subselect3.test 2008-10-09 10:58:51 +0000
+++ b/mysql-test/t/subselect3.test 2008-10-24 03:46:27 +0000
@@ -1,5 +1,5 @@
--disable_warnings
-drop table if exists t0, t1, t2, t3, t4, t5;
+drop table if exists t0, t1, t2, t3, t4;
--enable_warnings
#
@@ -634,41 +634,10 @@ let $datadir=`select @@datadir`;
--echo End of 5.0 tests
-#
-# BUG#36135 "void Diagnostics_area::set_eof_status(THD*): Assertion `!is_set()' failed."
-#
-create table t0 (a int);
-insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
-
-create table t1 (
- a int(11) default null,
- b int(11) default null,
- key (a)
-);
-# produce numbers 0..999
-insert into t1 select A.a+10*(B.a+10*C.a),A.a+10*(B.a+10*C.a) from t0 A, t0 B, t0 C;
-
-create table t2 (a int(11) default null);
-insert into t2 values (0),(1);
-
-create table t3 (a int(11) default null);
-insert into t3 values (0),(1);
-
-create table t4 (a int(11) default null);
-insert into t4 values (0),(1);
-
-create table t5 (a int(11) default null);
-insert into t5 values (0),(1),(0),(1);
-
-# this must not fail assertion
---error 1242
-select * from t2, t3
-where
- t2.a < 10 and
- t3.a+1 = 2 and
- t3.a in (select t1.b from t1
- where t1.a+1=t1.a+1 and
- t1.a < (select t4.a+10
- from t4, t5 limit 2));
+--echo #
+--echo # BUG#36896: Server crash on SELECT FROM DUAL
+--echo #
+create table t1 (a int);
+select 1 as res from dual where (1) in (select * from t1);
+drop table t1;
-drop table t0, t1, t2, t3, t4, t5;
=== modified file 'mysql-test/t/sum_distinct.test'
--- a/mysql-test/t/sum_distinct.test 2005-04-07 16:24:14 +0000
+++ b/mysql-test/t/sum_distinct.test 2008-09-05 19:01:46 +0000
@@ -93,3 +93,28 @@ SELECT SUM(DISTINCT id) FROM t1;
SELECT SUM(DISTINCT id % 11) FROM t1;
DROP TABLE t1;
+
+--echo
+--echo BUG#37891: Column cannot be null error with aggregate in a subquery
+--echo
+CREATE TABLE t1 (
+ pk int(11) NOT NULL AUTO_INCREMENT,
+ int_key int(11) DEFAULT NULL,
+ PRIMARY KEY (pk),
+ KEY int_key (int_key)
+);
+INSERT INTO t1 VALUES (1,10);
+
+CREATE TABLE t2 (
+ pk int(11) NOT NULL AUTO_INCREMENT,
+ time_nokey time DEFAULT NULL,
+ datetime_key time DEFAULT NULL,
+ PRIMARY KEY (pk),
+ KEY datetime_key (datetime_key)
+);
+INSERT INTO t2 VALUES (1,'18:19:29',NOW());
+
+SELECT * FROM t1 WHERE int_key IN ( SELECT SUM(DISTINCT pk) FROM t2 WHERE time_nokey = datetime_key );
+SELECT * FROM t1 WHERE int_key IN ( SELECT AVG(DISTINCT pk) FROM t2 WHERE time_nokey = datetime_key );
+drop table t1,t2;
+
=== modified file 'sql/hostname.cc'
--- a/sql/hostname.cc 2008-09-01 10:11:50 +0000
+++ b/sql/hostname.cc 2008-10-24 03:46:27 +0000
@@ -49,7 +49,6 @@ public:
};
static hash_filo *hostname_cache;
-static pthread_mutex_t LOCK_hostname;
void hostname_cache_refresh()
{
@@ -66,7 +65,6 @@ bool hostname_cache_init()
&my_charset_bin)))
return 1;
hostname_cache->clear();
- (void) pthread_mutex_init(&LOCK_hostname,MY_MUTEX_INIT_SLOW);
return 0;
}
@@ -75,7 +73,6 @@ void hostname_cache_free()
{
if (hostname_cache)
{
- (void) pthread_mutex_destroy(&LOCK_hostname);
delete hostname_cache;
hostname_cache= 0;
}
=== modified file 'sql/item_sum.cc'
--- a/sql/item_sum.cc 2008-06-26 16:17:05 +0000
+++ b/sql/item_sum.cc 2008-09-05 19:01:46 +0000
@@ -978,6 +978,17 @@ void Item_sum_distinct::fix_length_and_d
}
+bool Item_sum_distinct::fix_fields(THD *thd, Item **ref)
+{
+ int res= Item_sum_num::fix_fields(thd, ref);
+ /*
+ SUM(DISTINCT x) and AVG(DISTINCT x) may have NULL value even when x is
+ not nullable:
+ */
+ maybe_null= TRUE;
+ return res;
+}
+
/**
@todo
check that the case of CHAR(0) works OK
=== modified file 'sql/item_sum.h'
--- a/sql/item_sum.h 2008-06-12 19:04:52 +0000
+++ b/sql/item_sum.h 2008-09-05 19:01:46 +0000
@@ -488,6 +488,7 @@ public:
void reset_field() {} // not used
void update_field() {} // not used
virtual void no_rows_in_result() {}
+ bool fix_fields(THD *thd, Item **ref);
void fix_length_and_dec();
enum Item_result result_type () const { return val.traits->type(); }
virtual void calculate_val_and_count();
=== modified file 'sql/mysql_priv.h'
--- a/sql/mysql_priv.h 2008-10-22 11:51:28 +0000
+++ b/sql/mysql_priv.h 2008-10-29 20:39:29 +0000
@@ -2083,14 +2083,14 @@ extern FILE *bootstrap_file;
extern int bootstrap_error;
extern FILE *stderror_file;
extern pthread_key(MEM_ROOT**,THR_MALLOC);
-extern pthread_mutex_t LOCK_mysql_create_db,LOCK_Acl,LOCK_open, LOCK_lock_db,
+extern pthread_mutex_t LOCK_mysql_create_db, LOCK_open, LOCK_lock_db,
LOCK_thread_count,LOCK_mapped_file,LOCK_user_locks, LOCK_status,
LOCK_error_log, LOCK_delayed_insert, LOCK_uuid_short,
LOCK_delayed_status, LOCK_delayed_create, LOCK_crypt, LOCK_timezone,
LOCK_slave_list, LOCK_active_mi, LOCK_manager, LOCK_global_read_lock,
LOCK_global_system_variables, LOCK_user_conn,
LOCK_prepared_stmt_count,
- LOCK_bytes_sent, LOCK_bytes_received, LOCK_connection_count;
+ LOCK_connection_count;
#ifdef HAVE_OPENSSL
extern pthread_mutex_t LOCK_des_key_file;
#endif
=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc 2008-10-29 14:20:12 +0000
+++ b/sql/mysqld.cc 2008-11-01 17:24:56 +0000
@@ -686,11 +686,11 @@ SHOW_COMP_OPTION have_community_features
pthread_key(MEM_ROOT**,THR_MALLOC);
pthread_key(THD*, THR_THD);
-pthread_mutex_t LOCK_mysql_create_db, LOCK_Acl, LOCK_open, LOCK_thread_count,
+pthread_mutex_t LOCK_mysql_create_db, LOCK_open, LOCK_thread_count,
LOCK_mapped_file, LOCK_status, LOCK_global_read_lock,
LOCK_error_log,
LOCK_delayed_insert, LOCK_delayed_status, LOCK_delayed_create,
- LOCK_crypt, LOCK_bytes_sent, LOCK_bytes_received,
+ LOCK_crypt,
LOCK_global_system_variables,
LOCK_user_conn, LOCK_slave_list, LOCK_active_mi,
LOCK_connection_count;
@@ -1460,7 +1460,6 @@ static void clean_up_mutexes()
{
(void) pthread_mutex_destroy(&LOCK_mysql_create_db);
(void) pthread_mutex_destroy(&LOCK_lock_db);
- (void) pthread_mutex_destroy(&LOCK_Acl);
(void) rwlock_destroy(&LOCK_grant);
(void) pthread_mutex_destroy(&LOCK_open);
(void) pthread_mutex_destroy(&LOCK_thread_count);
@@ -1472,8 +1471,6 @@ static void clean_up_mutexes()
(void) pthread_mutex_destroy(&LOCK_delayed_create);
(void) pthread_mutex_destroy(&LOCK_manager);
(void) pthread_mutex_destroy(&LOCK_crypt);
- (void) pthread_mutex_destroy(&LOCK_bytes_sent);
- (void) pthread_mutex_destroy(&LOCK_bytes_received);
(void) pthread_mutex_destroy(&LOCK_user_conn);
(void) pthread_mutex_destroy(&LOCK_connection_count);
Events::destroy_mutexes();
@@ -3703,7 +3700,6 @@ static int init_thread_environment()
{
(void) pthread_mutex_init(&LOCK_mysql_create_db,MY_MUTEX_INIT_SLOW);
(void) pthread_mutex_init(&LOCK_lock_db,MY_MUTEX_INIT_SLOW);
- (void) pthread_mutex_init(&LOCK_Acl,MY_MUTEX_INIT_SLOW);
(void) pthread_mutex_init(&LOCK_open, NULL);
(void) pthread_mutex_init(&LOCK_thread_count,MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_mapped_file,MY_MUTEX_INIT_SLOW);
@@ -3714,8 +3710,6 @@ static int init_thread_environment()
(void) pthread_mutex_init(&LOCK_delayed_create,MY_MUTEX_INIT_SLOW);
(void) pthread_mutex_init(&LOCK_manager,MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_crypt,MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_bytes_sent,MY_MUTEX_INIT_FAST);
- (void) pthread_mutex_init(&LOCK_bytes_received,MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_user_conn, MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_active_mi, MY_MUTEX_INIT_FAST);
(void) pthread_mutex_init(&LOCK_global_system_variables, MY_MUTEX_INIT_FAST);
=== modified file 'sql/net_serv.cc'
--- a/sql/net_serv.cc 2008-10-02 12:08:09 +0000
+++ b/sql/net_serv.cc 2008-10-24 03:46:27 +0000
@@ -97,7 +97,6 @@ void sql_print_error(const char *format,
*/
extern uint test_flags;
extern ulong bytes_sent, bytes_received, net_big_packet_count;
-extern pthread_mutex_t LOCK_bytes_sent , LOCK_bytes_received;
#ifndef MYSQL_INSTANCE_MANAGER
#ifdef HAVE_QUERY_CACHE
#define USE_QUERY_CACHE
=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc 2008-10-20 19:13:22 +0000
+++ b/sql/sql_select.cc 2008-10-30 18:02:08 +0000
@@ -570,7 +570,7 @@ JOIN::prepare(Item ***rref_pointer_array
4. Subquery does not use aggregate functions or HAVING
5. Subquery predicate is at the AND-top-level of ON/WHERE clause
6. No execution method was already chosen (by a prepared statement).
-
+ 7. Parent SELECT is not a confluent "SELECT ... FROM DUAL" w/o tables
(*). We are not in a subquery of a single table UPDATE/DELETE that
doesn't have a JOIN (TODO: We should handle this at some
point by switching to multi-table UPDATE/DELETE)
@@ -586,7 +586,8 @@ JOIN::prepare(Item ***rref_pointer_array
select_lex->outer_select()->join && // (*)
select_lex->master_unit()->first_select()->leaf_tables && // (**)
do_semijoin &&
- in_subs->exec_method == Item_in_subselect::NOT_TRANSFORMED) // 6
+ in_subs->exec_method == Item_in_subselect::NOT_TRANSFORMED && // 6
+ select_lex->outer_select()->leaf_tables) // 7
{
DBUG_PRINT("info", ("Subquery is semi-join conversion candidate"));
@@ -634,6 +635,11 @@ JOIN::prepare(Item ***rref_pointer_array
2. Subquery is a single SELECT (not a UNION)
3. Subquery is not a table-less query. In this case there is no
point in materializing.
+ 3A The upper query is not a confluent SELECT ... FROM DUAL. We
+ can't do materialization for SELECT .. FROM DUAL because it
+ does not call setup_subquery_materialization(). We could make
+ SELECT ... FROM DUAL call that function but that doesn't seem
+ to be the case that is worth handling.
4. Subquery predicate is a top-level predicate
(this implies it is not negated)
TODO: this is a limitation that should be lifeted once we
@@ -660,7 +666,8 @@ JOIN::prepare(Item ***rref_pointer_array
in_subs && // 1
!select_lex->master_unit()->first_select()->next_select() && // 2
select_lex->master_unit()->first_select()->leaf_tables && // 3
- thd->lex->sql_command == SQLCOM_SELECT) // *
+ thd->lex->sql_command == SQLCOM_SELECT && // *
+ select_lex->outer_select()->leaf_tables) // 3A
{
if (in_subs->is_top_level_item() && // 4
!in_subs->is_correlated && // 5
@@ -2431,8 +2438,7 @@ JOIN::exec()
if (!items1)
{
items1= items0 + all_fields.elements;
- if (sort_and_group || curr_tmp_table->group ||
- tmp_table_param.precomputed_group_by)
+ if (sort_and_group || curr_tmp_table->group)
{
if (change_to_use_tmp_fields(thd, items1,
tmp_fields_list1, tmp_all_fields1,
@@ -3628,10 +3634,10 @@ bool find_eq_ref_candidate(TABLE *table,
- It is accessed
POSTCONDITIONS
- * Pulled out tables have JOIN_TAB::emb_sj_nest == NULL (like the outer
- tables)
- * Tables that were not pulled out have JOIN_TAB::emb_sj_nest.
- * Semi-join nests TABLE_LIST::sj_inner_tables
+ * Tables that were pulled out have JOIN_TAB::emb_sj_nest == NULL
+ * Tables that were not pulled out have JOIN_TAB::emb_sj_nest pointing
+ to semi-join nest they are in.
+ * Semi-join nests' TABLE_LIST::sj_inner_tables is updated accordingly
This operation is (and should be) performed at each PS execution since
tables may become/cease to be constant across PS reexecutions.
@@ -11701,8 +11707,6 @@ create_tmp_table(THD *thd,TMP_TABLE_PARA
ENGINE_COLUMNDEF *recinfo;
uint total_uneven_bit_length= 0;
bool force_copy_fields= param->force_copy_fields;
- /* Treat sum functions as normal ones when loose index scan is used. */
- save_sum_fields|= param->precomputed_group_by;
DBUG_ENTER("create_tmp_table");
DBUG_PRINT("enter",
("distinct: %d save_sum_fields: %d rows_limit: %lu group: %d",
@@ -13004,8 +13008,7 @@ static bool create_internal_tmp_table(TA
bool create_internal_tmp_table_from_heap(THD *thd, TABLE *table,
ENGINE_COLUMNDEF *start_recinfo,
ENGINE_COLUMNDEF **recinfo,
- int error,
- bool ignore_last_dupp_key_error)
+ int error, bool ignore_last_dupp_key_error)
{
return create_internal_tmp_table_from_heap2(thd, table,
start_recinfo, recinfo, error,
@@ -15916,7 +15919,11 @@ test_if_skip_sort_order(JOIN_TAB *tab,OR
if (table->covering_keys.is_set(ref_key))
usable_keys.intersect(table->covering_keys);
if (tab->pre_idx_push_select_cond)
- tab->select_cond= tab->select->cond= tab->pre_idx_push_select_cond;
+ {
+ tab->select_cond= tab->pre_idx_push_select_cond;
+ if (tab->select)
+ tab->select->cond= tab->select_cond;
+ }
if ((new_ref_key= test_if_subkey(order, table, ref_key, ref_key_parts,
&usable_keys)) < MAX_KEY)
{
@@ -16184,7 +16191,12 @@ test_if_skip_sort_order(JOIN_TAB *tab,OR
table->key_read= 0;
table->file->extra(HA_EXTRA_NO_KEYREAD);
}
-
+ if (tab->pre_idx_push_select_cond)
+ {
+ if (tab->select)
+ tab->select->cond= tab->select_cond;
+ tab->select_cond= tab->pre_idx_push_select_cond;
+ }
table->file->ha_index_or_rnd_end();
if (join->select_options & SELECT_DESCRIBE)
{
=== modified file 'sql/sql_select.h'
--- a/sql/sql_select.h 2008-09-04 18:30:34 +0000
+++ b/sql/sql_select.h 2008-10-24 03:46:27 +0000
@@ -683,7 +683,7 @@ public:
bool send_row_on_empty_set()
{
return (do_send_rows && tmp_table_param.sum_func_count != 0 &&
- !group_list);
+ !group_list && having_value != Item::COND_FALSE);
}
bool change_result(select_result *result);
bool is_top_level_join() const
=== modified file 'storage/myisam/ha_myisam.cc'
--- a/storage/myisam/ha_myisam.cc 2008-10-20 09:16:47 +0000
+++ b/storage/myisam/ha_myisam.cc 2008-10-29 20:39:29 +0000
@@ -1482,7 +1482,6 @@ C_MODE_START
my_bool index_cond_func_myisam(void *arg)
{
ha_myisam *h= (ha_myisam*)arg;
- /*if (h->in_range_read)*/
if (h->end_range)
{
if (h->compare_key2(h->end_range) > 0)
@@ -1497,7 +1496,6 @@ C_MODE_END
int ha_myisam::index_init(uint idx, bool sorted)
{
active_index=idx;
- //in_range_read= FALSE;
if (pushed_idx_cond_keyno == idx)
mi_set_index_cond_func(file, index_cond_func_myisam, this);
return 0;
@@ -1605,13 +1603,7 @@ int ha_myisam::read_range_first(const ke
bool sorted /* ignored */)
{
int res;
- //if (!eq_range_arg)
- // in_range_read= TRUE;
-
res= handler::read_range_first(start_key, end_key, eq_range_arg, sorted);
-
- //if (res)
- // in_range_read= FALSE;
return res;
}
@@ -1619,8 +1611,6 @@ int ha_myisam::read_range_first(const ke
int ha_myisam::read_range_next()
{
int res= handler::read_range_next();
- //if (res)
- // in_range_read= FALSE;
return res;
}
| Thread |
|---|
| • bzr push into mysql-6.0-opt branch (sergefp:2699) | Sergey Petrunia | 1 Nov |