Below is the list of changes that have just been committed into a local
5.1 repository of kgeorge. When kgeorge does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-05-04 16:37:30+03:00, gkodinov@stripped +11 -0
Merge magare.gmz:/home/kgeorge/mysql/work/B27531-5.0-opt
into magare.gmz:/home/kgeorge/mysql/work/B27531-5.1-opt
MERGE: 1.1810.2866.31
mysql-test/r/cast.result@stripped, 2007-05-04 16:34:44+03:00, gkodinov@stripped +0 -0
Auto merged
MERGE: 1.39.1.10
mysql-test/r/join_outer.result@stripped, 2007-05-04 16:34:44+03:00, gkodinov@stripped +0
-0
Auto merged
MERGE: 1.44.1.10
mysql-test/r/subselect.result@stripped, 2007-05-04 16:37:28+03:00, gkodinov@stripped +8
-7
merge of 5.0-opt -> 5.1-opt
MERGE: 1.134.1.55
mysql-test/t/cast.test@stripped, 2007-05-04 16:34:44+03:00, gkodinov@stripped +0 -0
Auto merged
MERGE: 1.31.1.4
mysql-test/t/join_outer.test@stripped, 2007-05-04 16:34:44+03:00, gkodinov@stripped +0 -0
Auto merged
MERGE: 1.37.1.3
mysql-test/t/subselect.test@stripped, 2007-05-04 16:37:28+03:00, gkodinov@stripped +8 -10
merge of 5.0-opt -> 5.1-opt
MERGE: 1.129.1.22
sql/item_func.cc@stripped, 2007-05-04 16:34:44+03:00, gkodinov@stripped +0 -0
Auto merged
MERGE: 1.270.1.65
sql/item_subselect.cc@stripped, 2007-05-04 16:34:44+03:00, gkodinov@stripped +0 -0
Auto merged
MERGE: 1.113.1.43
sql/sql_parse.cc@stripped, 2007-05-04 16:34:45+03:00, gkodinov@stripped +0 -0
Auto merged
MERGE: 1.426.1.193
sql/sql_select.cc@stripped, 2007-05-04 16:34:45+03:00, gkodinov@stripped +0 -0
Auto merged
MERGE: 1.312.1.205
sql/sql_select.h@stripped, 2007-05-04 16:34:45+03:00, gkodinov@stripped +0 -0
Auto merged
MERGE: 1.92.1.26
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: gkodinov
# Host: magare.gmz
# Root: /home/kgeorge/mysql/work/B27531-5.1-opt/RESYNC
--- 1.380/sql/item_func.cc 2007-04-26 23:33:08 +03:00
+++ 1.381/sql/item_func.cc 2007-05-04 16:34:44 +03:00
@@ -945,7 +945,8 @@ longlong Item_func_signed::val_int()
longlong value;
int error;
- if (args[0]->cast_to_int_type() != STRING_RESULT)
+ if (args[0]->cast_to_int_type() != STRING_RESULT ||
+ args[0]->result_as_longlong())
{
value= args[0]->val_int();
null_value= args[0]->null_value;
@@ -984,7 +985,8 @@ longlong Item_func_unsigned::val_int()
my_decimal2int(E_DEC_FATAL_ERROR, dec, 1, &value);
return value;
}
- else if (args[0]->cast_to_int_type() != STRING_RESULT)
+ else if (args[0]->cast_to_int_type() != STRING_RESULT ||
+ args[0]->result_as_longlong())
{
value= args[0]->val_int();
null_value= args[0]->null_value;
--- 1.663/sql/sql_parse.cc 2007-04-29 16:47:35 +03:00
+++ 1.664/sql/sql_parse.cc 2007-05-04 16:34:45 +03:00
@@ -4570,7 +4570,8 @@ check_access(THD *thd, ulong want_access
if (schema_db)
{
- if (want_access & ~(SELECT_ACL | EXTRA_ACL))
+ if (!(sctx->master_access & FILE_ACL) && (want_access & FILE_ACL)
||
+ (want_access & ~(SELECT_ACL | EXTRA_ACL | FILE_ACL)))
{
if (!no_errors)
{
--- 1.517/sql/sql_select.cc 2007-05-01 11:38:56 +03:00
+++ 1.518/sql/sql_select.cc 2007-05-04 16:34:45 +03:00
@@ -1436,14 +1436,13 @@ JOIN::optimize()
}
}
- if (select_lex->uncacheable && !is_top_level_join())
- {
- /* If this join belongs to an uncacheable subquery */
- if (!(tmp_join= (JOIN*)thd->alloc(sizeof(JOIN))))
- DBUG_RETURN(-1);
- error= 0; // Ensure that tmp_join.error= 0
- restore_tmp();
- }
+ /*
+ If this join belongs to an uncacheable subquery save
+ the original join
+ */
+ if (select_lex->uncacheable && !is_top_level_join() &&
+ init_save_join_tab())
+ DBUG_RETURN(-1);
}
error= 0;
@@ -1505,6 +1504,27 @@ JOIN::reinit()
DBUG_RETURN(0);
}
+/**
+ @brief Save the original join layout
+
+ @details Saves the original join layout so it can be reused in
+ re-execution and for EXPLAIN.
+
+ @return Operation status
+ @retval 0 success.
+ @retval 1 error occurred.
+*/
+
+bool
+JOIN::init_save_join_tab()
+{
+ if (!(tmp_join= (JOIN*)thd->alloc(sizeof(JOIN))))
+ return 1;
+ error= 0; // Ensure that tmp_join.error= 0
+ restore_tmp();
+ return 0;
+}
+
bool
JOIN::save_join_tab()
@@ -10768,7 +10788,6 @@ static enum_nested_loop_state
evaluate_join_record(JOIN *join, JOIN_TAB *join_tab,
int error, my_bool *report_error)
{
- bool not_exists_optimize= join_tab->table->reginfo.not_exists_optimize;
bool not_used_in_distinct=join_tab->not_used_in_distinct;
ha_rows found_records=join->found_records;
COND *select_cond= join_tab->select_cond;
@@ -10805,6 +10824,8 @@ evaluate_join_record(JOIN *join, JOIN_TA
first_unmatched->found= 1;
for (JOIN_TAB *tab= first_unmatched; tab <= join_tab; tab++)
{
+ if (tab->table->reginfo.not_exists_optimize)
+ return NESTED_LOOP_NO_MORE_ROWS;
/* Check all predicates that has just been activated. */
/*
Actually all predicates non-guarded by first_unmatched->found
@@ -10850,8 +10871,6 @@ evaluate_join_record(JOIN *join, JOIN_TA
if (found)
{
enum enum_nested_loop_state rc;
- if (not_exists_optimize)
- return NESTED_LOOP_NO_MORE_ROWS;
/* A match from join_tab is found for the current partial join. */
rc= (*join_tab->next_select)(join, join_tab+1, 0);
if (rc != NESTED_LOOP_OK && rc != NESTED_LOOP_NO_MORE_ROWS)
--- 1.121/sql/sql_select.h 2007-03-22 21:55:44 +02:00
+++ 1.122/sql/sql_select.h 2007-05-04 16:34:45 +03:00
@@ -473,6 +473,7 @@ public:
void cleanup(bool full);
void clear();
bool save_join_tab();
+ bool init_save_join_tab();
bool send_row_on_empty_set()
{
return (do_send_rows && tmp_table_param.sum_func_count != 0 &&
--- 1.183/mysql-test/r/subselect.result 2007-04-29 16:46:03 +03:00
+++ 1.184/mysql-test/r/subselect.result 2007-05-04 16:37:28 +03:00
@@ -4034,6 +4034,14 @@ SUM( (SELECT AVG( (SELECT COUNT(*) FROM
FROM t1;
ERROR HY000: Invalid use of group function
DROP TABLE t1,t2;
+CREATE TABLE t1 (a int, b int, KEY (a));
+INSERT INTO t1 VALUES (1,1),(2,1);
+EXPLAIN SELECT 1 FROM t1 WHERE a = (SELECT COUNT(*) FROM t1 GROUP BY b);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ref a a 5 const 1 Using where; Using index
+2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
+DROP TABLE t1;
+End of 5.0 tests.
End of 5.0 tests.
CREATE TABLE t1 (a int, b int);
INSERT INTO t1 VALUES (2,22),(1,11),(2,22);
--- 1.153/mysql-test/t/subselect.test 2007-04-29 11:13:05 +03:00
+++ 1.154/mysql-test/t/subselect.test 2007-05-04 16:37:28 +03:00
@@ -2874,6 +2874,14 @@ FROM t1;
DROP TABLE t1,t2;
+#
+# Bug #27807: Server crash when executing subquery with EXPLAIN
+#
+CREATE TABLE t1 (a int, b int, KEY (a));
+INSERT INTO t1 VALUES (1,1),(2,1);
+EXPLAIN SELECT 1 FROM t1 WHERE a = (SELECT COUNT(*) FROM t1 GROUP BY b);
+DROP TABLE t1;
+
--echo End of 5.0 tests.
#
--- 1.153/sql/item_subselect.cc 2007-04-24 16:03:02 +03:00
+++ 1.154/sql/item_subselect.cc 2007-05-04 16:34:44 +03:00
@@ -1817,6 +1817,21 @@ int subselect_single_select_engine::exec
thd->lex->current_select= save_select;
DBUG_RETURN(join->error ? join->error : 1);
}
+ if (!select_lex->uncacheable && thd->lex->describe &&
+ !(join->select_options & SELECT_DESCRIBE) &&
+ join->need_tmp && item->const_item())
+ {
+ /*
+ Force join->join_tmp creation, because this subquery will be replaced
+ by a simple select from the materialization temp table by optimize()
+ called by EXPLAIN and we need to preserve the initial query structure
+ so we can display it.
+ */
+ select_lex->uncacheable|= UNCACHEABLE_EXPLAIN;
+ select_lex->master_unit()->uncacheable|= UNCACHEABLE_EXPLAIN;
+ if (join->init_save_join_tab())
+ DBUG_RETURN(1);
+ }
if (item->engine_changed)
{
DBUG_RETURN(1);
--- 1.54/mysql-test/r/join_outer.result 2007-02-13 10:29:59 +02:00
+++ 1.55/mysql-test/r/join_outer.result 2007-05-04 16:34:44 +03:00
@@ -1214,3 +1214,28 @@ SELECT * FROM t1 LEFT JOIN t2 USING(f1)
f1 f2 f3
bla blah sheep
DROP TABLE t1,t2;
+CREATE TABLE t1 (id int PRIMARY KEY, a varchar(8));
+CREATE TABLE t2 (id int NOT NULL, b int NOT NULL, INDEX idx(id));
+INSERT INTO t1 VALUES
+(1,'aaaaaaa'), (5,'eeeeeee'), (4,'ddddddd'), (2,'bbbbbbb'), (3,'ccccccc');
+INSERT INTO t2 VALUES
+(3,10), (2,20), (5,30), (3,20), (5,10), (3,40), (3,30), (2,10), (2,40);
+EXPLAIN
+SELECT t1.id, a FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE t2.b IS NULL;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 5
+1 SIMPLE t2 ref idx idx 4 test.t1.id 2 Using where; Not exists
+flush status;
+SELECT t1.id, a FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE t2.b IS NULL;
+id a
+1 aaaaaaa
+4 ddddddd
+show status like 'Handler_read%';
+Variable_name Value
+Handler_read_first 0
+Handler_read_key 5
+Handler_read_next 0
+Handler_read_prev 0
+Handler_read_rnd 0
+Handler_read_rnd_next 6
+DROP TABLE t1,t2;
--- 1.41/mysql-test/t/join_outer.test 2007-02-13 10:29:59 +02:00
+++ 1.42/mysql-test/t/join_outer.test 2007-05-04 16:34:44 +03:00
@@ -831,3 +831,23 @@ SELECT * FROM t1 LEFT JOIN t2 USING(f1)
SELECT * FROM t1 LEFT JOIN t2 USING(f1) WHERE f1='Bla';
DROP TABLE t1,t2;
+
+#
+# Bug 28188: 'not exists' optimization for outer joins
+#
+
+CREATE TABLE t1 (id int PRIMARY KEY, a varchar(8));
+CREATE TABLE t2 (id int NOT NULL, b int NOT NULL, INDEX idx(id));
+INSERT INTO t1 VALUES
+ (1,'aaaaaaa'), (5,'eeeeeee'), (4,'ddddddd'), (2,'bbbbbbb'), (3,'ccccccc');
+INSERT INTO t2 VALUES
+ (3,10), (2,20), (5,30), (3,20), (5,10), (3,40), (3,30), (2,10), (2,40);
+
+EXPLAIN
+SELECT t1.id, a FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE t2.b IS NULL;
+
+flush status;
+SELECT t1.id, a FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE t2.b IS NULL;
+show status like 'Handler_read%';
+
+DROP TABLE t1,t2;
--- 1.49/mysql-test/r/cast.result 2007-02-06 21:24:39 +02:00
+++ 1.50/mysql-test/r/cast.result 2007-05-04 16:34:44 +03:00
@@ -351,6 +351,12 @@ DROP TABLE t1;
select isnull(date(NULL)), isnull(cast(NULL as DATE));
isnull(date(NULL)) isnull(cast(NULL as DATE))
1 1
+SELECT CAST(cast('01-01-01' as date) AS UNSIGNED);
+CAST(cast('01-01-01' as date) AS UNSIGNED)
+20010101
+SELECT CAST(cast('01-01-01' as date) AS SIGNED);
+CAST(cast('01-01-01' as date) AS SIGNED)
+20010101
End of 4.1 tests
select cast('1.2' as decimal(3,2));
cast('1.2' as decimal(3,2))
--- 1.36/mysql-test/t/cast.test 2007-02-06 21:24:39 +02:00
+++ 1.37/mysql-test/t/cast.test 2007-05-04 16:34:44 +03:00
@@ -182,6 +182,12 @@ DROP TABLE t1;
select isnull(date(NULL)), isnull(cast(NULL as DATE));
+#
+# Bug#23656: Wrong result of CAST from DATE to int
+#
+SELECT CAST(cast('01-01-01' as date) AS UNSIGNED);
+SELECT CAST(cast('01-01-01' as date) AS SIGNED);
+
--echo End of 4.1 tests
| Thread |
|---|
| • bk commit into 5.1 tree (gkodinov:1.2509) | kgeorge | 4 May |