3445 Marc Alff 2012-02-22 [merge]
Merge mysql-trunk --> mysql-trunk-wl5767
added:
mysql-test/r/mysql_client_test_embedded.result
mysql-test/t/mysql_client_test_embedded.cnf
mysql-test/t/mysql_client_test_embedded.test
modified:
client/sql_string.cc
client/sql_string.h
mysql-test/r/func_group.result
mysql-test/r/func_set.result
mysql-test/r/group_by.result
mysql-test/r/join_cache_bka.result
mysql-test/r/join_cache_bka_nixbnl.result
mysql-test/r/join_cache_bkaunique.result
mysql-test/r/join_cache_bnl.result
mysql-test/r/join_cache_nojb.result
mysql-test/r/select_found.result
mysql-test/r/subquery_mat_none.result
mysql-test/suite/innodb/t/innodb_bug34300.test
mysql-test/suite/opt_trace/r/bugs_no_prot_all.result
mysql-test/suite/opt_trace/r/bugs_no_prot_none.result
mysql-test/suite/opt_trace/r/bugs_ps_prot_all.result
mysql-test/suite/opt_trace/r/bugs_ps_prot_none.result
mysql-test/suite/opt_trace/r/range_no_prot.result
mysql-test/suite/opt_trace/r/range_ps_prot.result
mysql-test/t/disabled.def
mysql-test/t/func_group.test
mysql-test/t/func_set.test
sql/item_strfunc.cc
sql/item_strfunc.h
sql/log_event.cc
sql/mysqld.cc
sql/rpl_handler.cc
sql/sql_class.cc
sql/sql_class.h
sql/sql_executor.cc
sql/sql_list.h
sql/sql_load.cc
sql/sql_optimizer.cc
sql/sql_optimizer.h
sql/sql_select.cc
sql/sql_show.cc
sql/sql_string.cc
sql/sql_string.h
sql/sys_vars.cc
tests/mysql_client_test.c
unittest/gunit/opt_range-t.cc
3444 Marc Alff 2012-02-21
Code cleanup
modified:
include/mysql/psi/psi.h
include/mysql/psi/psi_abi_v1.h.pp
include/mysql/psi/psi_abi_v2.h.pp
mysql-test/suite/perfschema/r/digest_table_full.result
mysql-test/suite/perfschema/r/statement_digest.result
mysql-test/suite/perfschema/r/statement_digest_consumers.result
mysql-test/suite/perfschema/r/statement_digest_long_query.result
storage/perfschema/pfs.cc
storage/perfschema/pfs_digest.cc
storage/perfschema/pfs_digest.h
storage/perfschema/pfs_events_statements.h
storage/perfschema/pfs_events_waits.h
storage/perfschema/table_events_statements.cc
storage/perfschema/table_helper.cc
storage/perfschema/table_helper.h
=== modified file 'client/sql_string.cc'
--- a/client/sql_string.cc 2012-02-16 09:51:14 +0000
+++ b/client/sql_string.cc 2012-02-22 08:57:27 +0000
@@ -479,7 +479,7 @@ bool String::append_with_prefill(const c
return FALSE;
}
-uint32 String::numchars()
+uint32 String::numchars() const
{
return str_charset->cset->numchars(str_charset, Ptr, Ptr+str_length);
}
=== modified file 'client/sql_string.h'
--- a/client/sql_string.h 2011-06-30 15:50:45 +0000
+++ b/client/sql_string.h 2012-02-22 08:57:27 +0000
@@ -269,7 +269,7 @@ public:
friend int sortcmp(const String *a,const String *b, const CHARSET_INFO *cs);
friend int stringcmp(const String *a,const String *b);
friend String *copy_if_not_alloced(String *a,String *b,uint32 arg_length);
- uint32 numchars();
+ uint32 numchars() const;
int charpos(int i,uint32 offset=0);
int reserve(uint32 space_needed)
=== modified file 'mysql-test/r/func_group.result'
--- a/mysql-test/r/func_group.result 2011-12-22 13:36:08 +0000
+++ b/mysql-test/r/func_group.result 2012-02-22 09:26:19 +0000
@@ -1813,3 +1813,19 @@ SELECT MAX(a) FROM t1 WHERE a NOT BETWEE
MAX(a)
10
DROP TABLE t1;
+#
+# Bug#13724099 1032 BYTE MEMORY LEAK NEW_CACHED_ITEM IN
+# SUBQUERY WITH GROUPING OF OUTER COLUMN
+#
+CREATE TABLE t1 (
+a BLOB,
+b INT)
+engine=innodb;
+INSERT INTO t1 VALUES ('a', 0);
+SELECT 0 FROM t1
+WHERE 0 = (SELECT group_concat(b)
+FROM t1 t GROUP BY t1.a)
+;
+0
+0
+DROP TABLE t1;
=== modified file 'mysql-test/r/func_set.result'
--- a/mysql-test/r/func_set.result 2012-01-10 08:24:24 +0000
+++ b/mysql-test/r/func_set.result 2012-02-22 08:57:27 +0000
@@ -211,3 +211,37 @@ COUNT(*)
2
DROP TABLE t1;
# End of test BUG#12211480
+#
+# Bug#12677197 MAKE_SET() AND MY_EMPTY_STRING BUGS CAUSE CRASHING
+#
+do
+nullif( ( rtrim( make_set((cast(('%S') as unsigned)),
+(point((0xaf),(''))))
+)
+), (''))
+;
+Warnings:
+Warning 1292 Truncated incorrect INTEGER value: '%S'
+do
+dayofmonth( ( not( trim( trailing( convert((''), binary(4)))
+from( make_set( ('>>'), ('`'))))
+)))
+;
+Warnings:
+Warning 1292 Truncated incorrect INTEGER value: '>>'
+Warning 1292 Incorrect datetime value: '1'
+do quote(make_set((''), (cast(('-2147483649.1') as binary(513)))));
+Warnings:
+Warning 1292 Truncated incorrect INTEGER value: ''
+do
+trim( both(-8388607)
+from( make_set( ( extract( minute_second from
+( str_to_date((rpad(1.0,4,1)), ('')))
+)
+),
+( char((connection_id()) using macce)))
+)
+)
+;
+Warnings:
+Warning 1292 Truncated incorrect date value: '1.01'
=== modified file 'mysql-test/r/group_by.result'
--- a/mysql-test/r/group_by.result 2012-02-02 13:44:26 +0000
+++ b/mysql-test/r/group_by.result 2012-02-21 10:31:44 +0000
@@ -1340,10 +1340,10 @@ id select_type table type possible_keys
1 SIMPLE t1 ALL NULL NULL NULL NULL 144
EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (PRIMARY,i2) GROUP BY a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 4 NULL 144 Using index
+1 SIMPLE t1 index NULL PRIMARY 4 NULL 144 Using index; Using filesort
EXPLAIN SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY,i2) ORDER BY a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 4 NULL 144 Using index
+1 SIMPLE t1 index NULL PRIMARY 4 NULL 144 Using index; Using filesort
SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (PRIMARY,i2) ORDER BY a;
a
1
@@ -2166,7 +2166,7 @@ INSERT INTO t1 VALUES (1),(2),(3),(4),(5
EXPLAIN SELECT SQL_BIG_RESULT col1 AS field1, col1 AS field2
FROM t1 GROUP BY field1, field2;;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range NULL idx 5 NULL 6 Using index for group-by; Using filesort
+1 SIMPLE t1 range NULL idx 5 NULL 6 Using index for group-by
SELECT SQL_BIG_RESULT col1 AS field1, col1 AS field2
FROM t1 GROUP BY field1, field2;;
field1 field2
=== modified file 'mysql-test/r/join_cache_bka.result'
--- a/mysql-test/r/join_cache_bka.result 2012-02-08 15:25:17 +0000
+++ b/mysql-test/r/join_cache_bka.result 2012-02-21 10:31:44 +0000
@@ -2233,7 +2233,7 @@ GROUP BY t1.col_int_key
ORDER BY t1.col_int_key, t1.col_datetime
LIMIT 2;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL col_int_key 5 NULL 3 Using temporary; Using filesort
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using temporary; Using filesort
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
SELECT t1.col_int_key, t1.col_datetime
FROM t1 force index (col_int_key), t2 ignore index (col_int_key)
=== modified file 'mysql-test/r/join_cache_bka_nixbnl.result'
--- a/mysql-test/r/join_cache_bka_nixbnl.result 2012-02-08 15:25:17 +0000
+++ b/mysql-test/r/join_cache_bka_nixbnl.result 2012-02-21 10:31:44 +0000
@@ -2233,7 +2233,7 @@ GROUP BY t1.col_int_key
ORDER BY t1.col_int_key, t1.col_datetime
LIMIT 2;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL col_int_key 5 NULL 3 Using temporary; Using filesort
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using temporary; Using filesort
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
SELECT t1.col_int_key, t1.col_datetime
FROM t1 force index (col_int_key), t2 ignore index (col_int_key)
=== modified file 'mysql-test/r/join_cache_bkaunique.result'
--- a/mysql-test/r/join_cache_bkaunique.result 2012-02-08 15:25:17 +0000
+++ b/mysql-test/r/join_cache_bkaunique.result 2012-02-21 10:31:44 +0000
@@ -2234,7 +2234,7 @@ GROUP BY t1.col_int_key
ORDER BY t1.col_int_key, t1.col_datetime
LIMIT 2;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL col_int_key 5 NULL 3 Using temporary; Using filesort
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using temporary; Using filesort
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
SELECT t1.col_int_key, t1.col_datetime
FROM t1 force index (col_int_key), t2 ignore index (col_int_key)
=== modified file 'mysql-test/r/join_cache_bnl.result'
--- a/mysql-test/r/join_cache_bnl.result 2012-02-08 15:25:17 +0000
+++ b/mysql-test/r/join_cache_bnl.result 2012-02-21 10:31:44 +0000
@@ -2216,7 +2216,7 @@ GROUP BY t1.col_int_key
ORDER BY t1.col_int_key, t1.col_datetime
LIMIT 2;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL col_int_key 5 NULL 3 Using temporary; Using filesort
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using temporary; Using filesort
1 SIMPLE t2 ref col_int_key col_int_key 5 const 1 Using where
SELECT t1.col_int_key, t1.col_datetime
FROM t1,t2
@@ -2234,7 +2234,7 @@ GROUP BY t1.col_int_key
ORDER BY t1.col_int_key, t1.col_datetime
LIMIT 2;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL col_int_key 5 NULL 3 Using temporary; Using filesort
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using temporary; Using filesort
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
SELECT t1.col_int_key, t1.col_datetime
FROM t1 force index (col_int_key), t2 ignore index (col_int_key)
=== modified file 'mysql-test/r/join_cache_nojb.result'
--- a/mysql-test/r/join_cache_nojb.result 2012-02-08 15:25:17 +0000
+++ b/mysql-test/r/join_cache_nojb.result 2012-02-21 10:31:44 +0000
@@ -2216,7 +2216,7 @@ GROUP BY t1.col_int_key
ORDER BY t1.col_int_key, t1.col_datetime
LIMIT 2;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL col_int_key 5 NULL 3 Using temporary; Using filesort
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using temporary; Using filesort
1 SIMPLE t2 ref col_int_key col_int_key 5 const 1 Using where
SELECT t1.col_int_key, t1.col_datetime
FROM t1,t2
@@ -2234,7 +2234,7 @@ GROUP BY t1.col_int_key
ORDER BY t1.col_int_key, t1.col_datetime
LIMIT 2;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL col_int_key 5 NULL 3 Using temporary; Using filesort
+1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using temporary; Using filesort
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
SELECT t1.col_int_key, t1.col_datetime
FROM t1 force index (col_int_key), t2 ignore index (col_int_key)
=== added file 'mysql-test/r/mysql_client_test_embedded.result'
--- a/mysql-test/r/mysql_client_test_embedded.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/mysql_client_test_embedded.result 2011-12-05 10:11:58 +0000
@@ -0,0 +1,92 @@
+# Run the start/stop test 17 times (* 64 = 1088 restarts)
+# --silent to avoid printing out server version etc.
+
+
+#####################################
+1 of (1/17): test_embedded_start_stop
+#####################################
+
+
+#####################################
+1 of (2/17): test_embedded_start_stop
+#####################################
+
+
+#####################################
+1 of (3/17): test_embedded_start_stop
+#####################################
+
+
+#####################################
+1 of (4/17): test_embedded_start_stop
+#####################################
+
+
+#####################################
+1 of (5/17): test_embedded_start_stop
+#####################################
+
+
+#####################################
+1 of (6/17): test_embedded_start_stop
+#####################################
+
+
+#####################################
+1 of (7/17): test_embedded_start_stop
+#####################################
+
+
+#####################################
+1 of (8/17): test_embedded_start_stop
+#####################################
+
+
+#####################################
+1 of (9/17): test_embedded_start_stop
+#####################################
+
+
+#####################################
+1 of (10/17): test_embedded_start_stop
+#####################################
+
+
+#####################################
+1 of (11/17): test_embedded_start_stop
+#####################################
+
+
+#####################################
+1 of (12/17): test_embedded_start_stop
+#####################################
+
+
+#####################################
+1 of (13/17): test_embedded_start_stop
+#####################################
+
+
+#####################################
+1 of (14/17): test_embedded_start_stop
+#####################################
+
+
+#####################################
+1 of (15/17): test_embedded_start_stop
+#####################################
+
+
+#####################################
+1 of (16/17): test_embedded_start_stop
+#####################################
+
+
+#####################################
+1 of (17/17): test_embedded_start_stop
+#####################################
+
+
+All '1' tests were successful (in '17' iterations)
+
+!!! SUCCESS !!!
=== modified file 'mysql-test/r/select_found.result'
--- a/mysql-test/r/select_found.result 2011-06-27 07:17:26 +0000
+++ b/mysql-test/r/select_found.result 2012-02-21 10:31:44 +0000
@@ -84,19 +84,19 @@ UNIQUE KEY e_n (email,name)
EXPLAIN SELECT SQL_CALC_FOUND_ROWS DISTINCT email FROM t2 LEFT JOIN t1 ON kid = t2.id WHERE t1.id IS NULL LIMIT 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 system kid NULL NULL NULL 0 const row not found
-1 SIMPLE t2 index NULL e_n 104 NULL 10
+1 SIMPLE t2 ALL NULL NULL NULL NULL 200 Using temporary
SELECT SQL_CALC_FOUND_ROWS DISTINCT email FROM t2 LEFT JOIN t1 ON kid = t2.id WHERE t1.id IS NULL LIMIT 10;
email
email1
+email2
+email3
+email4
+email5
+email6
+email7
+email8
+email9
email10
-email100
-email101
-email102
-email103
-email104
-email105
-email106
-email107
SELECT FOUND_ROWS();
FOUND_ROWS()
200
=== modified file 'mysql-test/r/subquery_mat_none.result'
--- a/mysql-test/r/subquery_mat_none.result 2012-02-08 15:25:17 +0000
+++ b/mysql-test/r/subquery_mat_none.result 2012-02-21 10:31:44 +0000
@@ -137,7 +137,7 @@ explain extended
select * from t1 where (a1, a2) in (select b1, max(b2) from t2i group by b1);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where
-2 DEPENDENT SUBQUERY t2i index NULL it2i3 18 NULL 3 100.00 Using index
+2 DEPENDENT SUBQUERY t2i index NULL it2i3 18 NULL 5 60.00 Using index
Warnings:
Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(/* select#2 */ select `test`.`t2i`.`b1`,max(`test`.`t2i`.`b2`) from `test`.`t2i` group by `test`.`t2i`.`b1` having (((<cache>(`test`.`t1`.`a1`) = `test`.`t2i`.`b1`) or isnull(`test`.`t2i`.`b1`)) and ((<cache>(`test`.`t1`.`a2`) = max(`test`.`t2i`.`b2`)) or isnull(max(`test`.`t2i`.`b2`))) and <is_not_null_test>(`test`.`t2i`.`b1`) and <is_not_null_test>(max(`test`.`t2i`.`b2`)))))
select * from t1 where (a1, a2) in (select b1, max(b2) from t2i group by b1);
@@ -148,11 +148,11 @@ prepare st1 from "explain select * from
execute st1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
-2 DEPENDENT SUBQUERY t2i index NULL it2i3 18 NULL 3 Using index
+2 DEPENDENT SUBQUERY t2i index NULL it2i3 18 NULL 5 Using index
execute st1;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where
-2 DEPENDENT SUBQUERY t2i index NULL it2i3 18 NULL 3 Using index
+2 DEPENDENT SUBQUERY t2i index NULL it2i3 18 NULL 5 Using index
prepare st2 from "select * from t1 where (a1, a2) in (select b1, max(b2) from t2i group by b1)";
execute st2;
a1 a2
@@ -764,7 +764,7 @@ EXPLAIN
SELECT * FROM t1 WHERE (a,b) = ANY (SELECT a, max(b) FROM t1 GROUP BY a);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 9 Using where
-2 DEPENDENT SUBQUERY t1 index NULL a 8 NULL 1 Using filesort
+2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 9 Using temporary; Using filesort
DROP TABLE t1;
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2);
@@ -1277,7 +1277,7 @@ HAVING COUNT(*) > 0
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY table1 system NULL NULL NULL NULL 1
1 PRIMARY table2 system PRIMARY NULL NULL NULL 1
-2 DEPENDENT SUBQUERY innr index NULL col_int_key 5 NULL 2 Using where; Using filesort
+2 DEPENDENT SUBQUERY innr ALL NULL NULL NULL NULL 2 Using where; Using temporary; Using filesort
SELECT table1.pk, table2.pk
FROM t2 AS table1 LEFT JOIN t2 AS table2
ON table2.pk = table1.pk AND
=== modified file 'mysql-test/suite/innodb/t/innodb_bug34300.test'
--- a/mysql-test/suite/innodb/t/innodb_bug34300.test 2012-02-02 10:27:45 +0000
+++ b/mysql-test/suite/innodb/t/innodb_bug34300.test 2012-02-21 16:23:52 +0000
@@ -9,6 +9,7 @@
-- disable_result_log
call mtr.add_suppression("InnoDB: Warning: a long semaphore wait:");
+call mtr.add_suppression("the age of the last checkpoint is");
# set packet size and reconnect
let $max_packet=`select @@global.max_allowed_packet`;
=== modified file 'mysql-test/suite/opt_trace/r/bugs_no_prot_all.result'
--- a/mysql-test/suite/opt_trace/r/bugs_no_prot_all.result 2012-02-14 15:18:33 +0000
+++ b/mysql-test/suite/opt_trace/r/bugs_no_prot_all.result 2012-02-21 10:31:44 +0000
@@ -2290,14 +2290,7 @@ SELECT 1 FROM t1 WHERE 1 LIKE
"table": "t1"
}
] /* refine_plan */
- }
- ] /* steps */
- } /* join_optimization */
- },
- {
- "join_execution": {
- "select#": 2,
- "steps": [
+ },
{
"reconsidering_access_paths_for_index_ordering": {
"index_order_summary": {
@@ -2311,6 +2304,13 @@ SELECT 1 FROM t1 WHERE 1 LIKE
} /* reconsidering_access_paths_for_index_ordering */
}
] /* steps */
+ } /* join_optimization */
+ },
+ {
+ "join_execution": {
+ "select#": 2,
+ "steps": [
+ ] /* steps */
} /* join_execution */
}
] /* steps */
=== modified file 'mysql-test/suite/opt_trace/r/bugs_no_prot_none.result'
--- a/mysql-test/suite/opt_trace/r/bugs_no_prot_none.result 2012-02-14 15:18:33 +0000
+++ b/mysql-test/suite/opt_trace/r/bugs_no_prot_none.result 2012-02-21 10:31:44 +0000
@@ -1757,14 +1757,7 @@ SELECT 1 FROM t1 WHERE 1 LIKE
"table": "t1"
}
] /* refine_plan */
- }
- ] /* steps */
- } /* join_optimization */
- },
- {
- "join_execution": {
- "select#": 2,
- "steps": [
+ },
{
"reconsidering_access_paths_for_index_ordering": {
"index_order_summary": {
@@ -1778,6 +1771,13 @@ SELECT 1 FROM t1 WHERE 1 LIKE
} /* reconsidering_access_paths_for_index_ordering */
}
] /* steps */
+ } /* join_optimization */
+ },
+ {
+ "join_execution": {
+ "select#": 2,
+ "steps": [
+ ] /* steps */
} /* join_execution */
}
] /* steps */
=== modified file 'mysql-test/suite/opt_trace/r/bugs_ps_prot_all.result'
--- a/mysql-test/suite/opt_trace/r/bugs_ps_prot_all.result 2012-02-14 15:18:33 +0000
+++ b/mysql-test/suite/opt_trace/r/bugs_ps_prot_all.result 2012-02-21 10:31:44 +0000
@@ -2290,14 +2290,7 @@ SELECT 1 FROM t1 WHERE 1 LIKE
"table": "t1"
}
] /* refine_plan */
- }
- ] /* steps */
- } /* join_optimization */
- },
- {
- "join_execution": {
- "select#": 2,
- "steps": [
+ },
{
"reconsidering_access_paths_for_index_ordering": {
"index_order_summary": {
@@ -2311,6 +2304,13 @@ SELECT 1 FROM t1 WHERE 1 LIKE
} /* reconsidering_access_paths_for_index_ordering */
}
] /* steps */
+ } /* join_optimization */
+ },
+ {
+ "join_execution": {
+ "select#": 2,
+ "steps": [
+ ] /* steps */
} /* join_execution */
}
] /* steps */
=== modified file 'mysql-test/suite/opt_trace/r/bugs_ps_prot_none.result'
--- a/mysql-test/suite/opt_trace/r/bugs_ps_prot_none.result 2012-02-14 15:18:33 +0000
+++ b/mysql-test/suite/opt_trace/r/bugs_ps_prot_none.result 2012-02-21 10:31:44 +0000
@@ -1737,14 +1737,7 @@ SELECT 1 FROM t1 WHERE 1 LIKE
"table": "t1"
}
] /* refine_plan */
- }
- ] /* steps */
- } /* join_optimization */
- },
- {
- "join_execution": {
- "select#": 2,
- "steps": [
+ },
{
"reconsidering_access_paths_for_index_ordering": {
"index_order_summary": {
@@ -1758,6 +1751,13 @@ SELECT 1 FROM t1 WHERE 1 LIKE
} /* reconsidering_access_paths_for_index_ordering */
}
] /* steps */
+ } /* join_optimization */
+ },
+ {
+ "join_execution": {
+ "select#": 2,
+ "steps": [
+ ] /* steps */
} /* join_execution */
}
] /* steps */
=== modified file 'mysql-test/suite/opt_trace/r/range_no_prot.result'
--- a/mysql-test/suite/opt_trace/r/range_no_prot.result 2012-02-14 15:18:33 +0000
+++ b/mysql-test/suite/opt_trace/r/range_no_prot.result 2012-02-21 10:31:44 +0000
@@ -878,10 +878,6 @@ EXPLAIN SELECT key2, MIN(key2_1) FROM t2
"join_explain": {
"select#": 1,
"steps": [
- {
- "reconsidering_access_paths_for_index_ordering": {
- } /* reconsidering_access_paths_for_index_ordering */
- }
] /* steps */
} /* join_explain */
}
@@ -1417,10 +1413,6 @@ GROUP BY key2 {
"join_explain": {
"select#": 1,
"steps": [
- {
- "reconsidering_access_paths_for_index_ordering": {
- } /* reconsidering_access_paths_for_index_ordering */
- }
] /* steps */
} /* join_explain */
}
@@ -4645,14 +4637,7 @@ EXPLAIN SELECT * FROM t1 WHERE i1 > '2'
"access_type": "range"
}
] /* refine_plan */
- }
- ] /* steps */
- } /* join_optimization */
- },
- {
- "join_explain": {
- "select#": 1,
- "steps": [
+ },
{
"reconsidering_access_paths_for_index_ordering": {
"rows_estimation": {
@@ -4732,6 +4717,13 @@ EXPLAIN SELECT * FROM t1 WHERE i1 > '2'
} /* reconsidering_access_paths_for_index_ordering */
}
] /* steps */
+ } /* join_optimization */
+ },
+ {
+ "join_explain": {
+ "select#": 1,
+ "steps": [
+ ] /* steps */
} /* join_explain */
}
] /* steps */
@@ -5077,18 +5069,6 @@ EXPLAIN SELECT DISTINCT i1 FROM t1 WHERE
"join_explain": {
"select#": 1,
"steps": [
- {
- "reconsidering_access_paths_for_index_ordering": {
- "index_order_summary": {
- "database": "test",
- "table": "t1",
- "index": "k1",
- "order_direction": "desc",
- "plan_changed": true,
- "access_type": "index_scan"
- } /* index_order_summary */
- } /* reconsidering_access_paths_for_index_ordering */
- }
] /* steps */
} /* join_explain */
}
@@ -6237,14 +6217,7 @@ EXPLAIN SELECT * FROM t1 WHERE c1 = '1'
"table_condition_attached": null
}
] /* refine_plan */
- }
- ] /* steps */
- } /* join_optimization */
- },
- {
- "join_explain": {
- "select#": 1,
- "steps": [
+ },
{
"reconsidering_access_paths_for_index_ordering": {
"index_order_summary": {
@@ -6259,6 +6232,13 @@ EXPLAIN SELECT * FROM t1 WHERE c1 = '1'
} /* reconsidering_access_paths_for_index_ordering */
}
] /* steps */
+ } /* join_optimization */
+ },
+ {
+ "join_explain": {
+ "select#": 1,
+ "steps": [
+ ] /* steps */
} /* join_explain */
}
] /* steps */
=== modified file 'mysql-test/suite/opt_trace/r/range_ps_prot.result'
--- a/mysql-test/suite/opt_trace/r/range_ps_prot.result 2012-02-14 15:18:33 +0000
+++ b/mysql-test/suite/opt_trace/r/range_ps_prot.result 2012-02-21 10:31:44 +0000
@@ -878,10 +878,6 @@ EXPLAIN SELECT key2, MIN(key2_1) FROM t2
"join_explain": {
"select#": 1,
"steps": [
- {
- "reconsidering_access_paths_for_index_ordering": {
- } /* reconsidering_access_paths_for_index_ordering */
- }
] /* steps */
} /* join_explain */
}
@@ -1417,10 +1413,6 @@ GROUP BY key2 {
"join_explain": {
"select#": 1,
"steps": [
- {
- "reconsidering_access_paths_for_index_ordering": {
- } /* reconsidering_access_paths_for_index_ordering */
- }
] /* steps */
} /* join_explain */
}
@@ -4645,14 +4637,7 @@ EXPLAIN SELECT * FROM t1 WHERE i1 > '2'
"access_type": "range"
}
] /* refine_plan */
- }
- ] /* steps */
- } /* join_optimization */
- },
- {
- "join_explain": {
- "select#": 1,
- "steps": [
+ },
{
"reconsidering_access_paths_for_index_ordering": {
"rows_estimation": {
@@ -4732,6 +4717,13 @@ EXPLAIN SELECT * FROM t1 WHERE i1 > '2'
} /* reconsidering_access_paths_for_index_ordering */
}
] /* steps */
+ } /* join_optimization */
+ },
+ {
+ "join_explain": {
+ "select#": 1,
+ "steps": [
+ ] /* steps */
} /* join_explain */
}
] /* steps */
@@ -5077,18 +5069,6 @@ EXPLAIN SELECT DISTINCT i1 FROM t1 WHERE
"join_explain": {
"select#": 1,
"steps": [
- {
- "reconsidering_access_paths_for_index_ordering": {
- "index_order_summary": {
- "database": "test",
- "table": "t1",
- "index": "k1",
- "order_direction": "desc",
- "plan_changed": true,
- "access_type": "index_scan"
- } /* index_order_summary */
- } /* reconsidering_access_paths_for_index_ordering */
- }
] /* steps */
} /* join_explain */
}
@@ -6237,14 +6217,7 @@ EXPLAIN SELECT * FROM t1 WHERE c1 = '1'
"table_condition_attached": null
}
] /* refine_plan */
- }
- ] /* steps */
- } /* join_optimization */
- },
- {
- "join_explain": {
- "select#": 1,
- "steps": [
+ },
{
"reconsidering_access_paths_for_index_ordering": {
"index_order_summary": {
@@ -6259,6 +6232,13 @@ EXPLAIN SELECT * FROM t1 WHERE c1 = '1'
} /* reconsidering_access_paths_for_index_ordering */
}
] /* steps */
+ } /* join_optimization */
+ },
+ {
+ "join_explain": {
+ "select#": 1,
+ "steps": [
+ ] /* steps */
} /* join_explain */
}
] /* steps */
=== modified file 'mysql-test/t/disabled.def'
--- a/mysql-test/t/disabled.def 2012-02-15 11:09:43 +0000
+++ b/mysql-test/t/disabled.def 2012-02-22 16:21:18 +0000
@@ -14,4 +14,3 @@ read_many_rows_innodb : Bug#11748886
sum_distinct-big : Bug#11764126 2010-11-15 mattiasj was not tested
archive-big : Bug#11817185 2011-03-10 Anitha Disabled since this leads to timeout on Solaris Sparc
log_tables-big : Bug#11756699 2010-11-15 mattiasj report already exists
-events_restart @windows : Bug#11748899 2012-02-15 agopi The test started failing on windows after the fix for bug#11748899
=== modified file 'mysql-test/t/func_group.test'
--- a/mysql-test/t/func_group.test 2011-12-22 13:36:08 +0000
+++ b/mysql-test/t/func_group.test 2012-02-22 09:26:19 +0000
@@ -1193,3 +1193,21 @@ INSERT INTO t1 VALUES (1),(2),(3),(4),(5
SELECT MAX(a) FROM t1 WHERE a NOT BETWEEN 3 AND 9;
DROP TABLE t1;
+
+--echo #
+--echo # Bug#13724099 1032 BYTE MEMORY LEAK NEW_CACHED_ITEM IN
+--echo # SUBQUERY WITH GROUPING OF OUTER COLUMN
+--echo #
+
+CREATE TABLE t1 (
+ a BLOB,
+ b INT)
+engine=innodb;
+
+INSERT INTO t1 VALUES ('a', 0);
+
+SELECT 0 FROM t1
+WHERE 0 = (SELECT group_concat(b)
+ FROM t1 t GROUP BY t1.a)
+;
+DROP TABLE t1;
=== modified file 'mysql-test/t/func_set.test'
--- a/mysql-test/t/func_set.test 2012-01-10 08:24:24 +0000
+++ b/mysql-test/t/func_set.test 2012-02-22 08:57:27 +0000
@@ -131,3 +131,33 @@ SELECT COUNT(*) FROM t1 GROUP BY MAKE_SE
DROP TABLE t1;
--echo # End of test BUG#12211480
+
+--echo #
+--echo # Bug#12677197 MAKE_SET() AND MY_EMPTY_STRING BUGS CAUSE CRASHING
+--echo #
+
+do
+nullif( ( rtrim( make_set((cast(('%S') as unsigned)),
+ (point((0xaf),(''))))
+ )
+ ), (''))
+;
+
+do
+dayofmonth( ( not( trim( trailing( convert((''), binary(4)))
+ from( make_set( ('>>'), ('`'))))
+ )))
+;
+
+do quote(make_set((''), (cast(('-2147483649.1') as binary(513)))));
+
+do
+trim( both(-8388607)
+ from( make_set( ( extract( minute_second from
+ ( str_to_date((rpad(1.0,4,1)), ('')))
+ )
+ ),
+ ( char((connection_id()) using macce)))
+ )
+ )
+;
=== added file 'mysql-test/t/mysql_client_test_embedded.cnf'
--- a/mysql-test/t/mysql_client_test_embedded.cnf 1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/mysql_client_test_embedded.cnf 2011-12-05 10:11:58 +0000
@@ -0,0 +1,6 @@
+# Include original my.cnf
+!include include/default_my.cnf
+
+[embedded]
+# Can't run with innodb currently, since mysqltest_embedded have it locked
+innodb=OFF
=== added file 'mysql-test/t/mysql_client_test_embedded.test'
--- a/mysql-test/t/mysql_client_test_embedded.test 1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/mysql_client_test_embedded.test 2011-12-05 10:11:58 +0000
@@ -0,0 +1,8 @@
+--source include/is_embedded.inc
+
+--echo # Run the start/stop test 17 times (* 64 = 1088 restarts)
+--echo # --silent to avoid printing out server version etc.
+--exec $MYSQL_CLIENT_TEST --silent --count=17 test_embedded_start_stop 2>&1
+# TODO: Test all other tests once.
+# (Currently not done, since many fail with embedded server).
+#--exec $MYSQL_CLIENT_TEST 2>&1
=== modified file 'sql/item_strfunc.cc'
--- a/sql/item_strfunc.cc 2012-02-17 10:30:31 +0000
+++ b/sql/item_strfunc.cc 2012-02-22 08:57:27 +0000
@@ -58,11 +58,6 @@ C_MODE_END
using std::min;
using std::max;
-/**
- @todo Remove this. It is not safe to use a shared String object.
- */
-String my_empty_string("",default_charset_info);
-
/*
For the Items which have only val_str_ascii() method
and don't have their own "native" val_str(),
@@ -2599,7 +2594,7 @@ String *Item_func_make_set::val_str(Stri
ulonglong bits;
bool first_found=0;
Item **ptr=args;
- String *result=&my_empty_string;
+ String *result= NULL;
bits=item->val_int();
if ((null_value=item->null_value))
@@ -2631,17 +2626,21 @@ String *Item_func_make_set::val_str(Stri
{
if (result != &tmp_str)
{ // Copy data to tmp_str
- if (tmp_str.alloc(result->length()+res->length()+1) ||
+ if (tmp_str.alloc((result != NULL ? result->length() : 0) +
+ res->length() + 1) ||
tmp_str.copy(*result))
return make_empty_result();
result= &tmp_str;
}
- if (tmp_str.append(STRING_WITH_LEN(","), &my_charset_bin) || tmp_str.append(*res))
+ if (tmp_str.append(STRING_WITH_LEN(","), &my_charset_bin) ||
+ tmp_str.append(*res))
return make_empty_result();
}
}
}
}
+ if (result == NULL)
+ return make_empty_result();
return result;
}
=== modified file 'sql/item_strfunc.h'
--- a/sql/item_strfunc.h 2012-01-10 08:24:24 +0000
+++ b/sql/item_strfunc.h 2012-02-22 08:57:27 +0000
@@ -989,6 +989,4 @@ public:
String *val_str(String *);
};
-extern String my_empty_string;
-
#endif /* ITEM_STRFUNC_INCLUDED */
=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc 2012-02-07 23:33:54 +0000
+++ b/sql/log_event.cc 2012-02-22 08:57:27 +0000
@@ -6113,6 +6113,7 @@ int Load_log_event::do_apply_event(NET*
String line_term(sql_ex.line_term,sql_ex.line_term_len,log_cs);
String line_start(sql_ex.line_start,sql_ex.line_start_len,log_cs);
String escaped(sql_ex.escaped,sql_ex.escaped_len, log_cs);
+ const String empty_str("", 0, log_cs);
ex.field_term= &field_term;
ex.enclosed= &enclosed;
ex.line_term= &line_term;
@@ -6121,7 +6122,7 @@ int Load_log_event::do_apply_event(NET*
ex.opt_enclosed = (sql_ex.opt_flags & OPT_ENCLOSED_FLAG);
if (sql_ex.empty_flags & FIELD_TERM_EMPTY)
- ex.field_term->length(0);
+ ex.field_term= &empty_str;
ex.skip_lines = skip_lines;
List<Item> field_list;
=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc 2012-02-17 13:18:29 +0000
+++ b/sql/mysqld.cc 2012-02-21 14:51:02 +0000
@@ -588,6 +588,9 @@ uint mysql_real_data_home_len, mysql_dat
uint reg_ext_length;
const key_map key_map_empty(0);
key_map key_map_full(0); // Will be initialized later
+char logname_path[FN_REFLEN];
+char slow_logname_path[FN_REFLEN];
+char secure_file_real_path[FN_REFLEN];
DATE_TIME_FORMAT global_date_format, global_datetime_format, global_time_format;
Time_zone *default_tz;
@@ -1647,6 +1650,12 @@ void clean_up(bool print_message)
#endif
free_list(opt_plugin_load_list_ptr);
+ if (THR_THD)
+ (void) pthread_key_delete(THR_THD);
+
+ if (THR_MALLOC)
+ (void) pthread_key_delete(THR_MALLOC);
+
/*
The following lines may never be executed as the main thread may have
killed us
@@ -3224,7 +3233,6 @@ rpl_make_log_name(const char *opt,
int init_common_variables()
{
- char buff[FN_REFLEN];
umask(((~my_umask) & 0666));
my_decimal_set_zero(&decimal_zero); // set decimal_zero constant;
tzset(); // Set tzname
@@ -3599,13 +3607,13 @@ int init_common_variables()
if (!VAR || !*VAR) \
{ \
my_free(VAR); /* it could be an allocated empty string "" */ \
- VAR= my_strdup(ALT, MYF(0)); \
+ VAR= ALT; \
}
FIX_LOG_VAR(opt_logname,
- make_default_log_name(buff, ".log"));
+ make_default_log_name(logname_path, ".log"));
FIX_LOG_VAR(opt_slow_logname,
- make_default_log_name(buff, "-slow.log"));
+ make_default_log_name(slow_logname_path, "-slow.log"));
#if defined(ENABLED_DEBUG_SYNC)
/* Initialize the debug sync facility. See debug_sync.cc. */
@@ -7282,6 +7290,7 @@ static int mysql_init_variables(void)
opt_logname= opt_update_logname= opt_binlog_index_name= opt_slow_logname= 0;
opt_tc_log_file= (char *)"tc.log"; // no hostname in tc_log file name !
opt_secure_auth= 0;
+ opt_secure_file_priv= NULL;
opt_bootstrap= opt_myisam_log= 0;
mqh_used= 0;
kill_in_progress= 0;
@@ -7356,7 +7365,12 @@ static int mysql_init_variables(void)
relay_log_info_file= (char*) "relay-log.info";
report_user= report_password = report_host= 0; /* TO BE DELETED */
opt_relay_logname= opt_relaylog_index_name= 0;
+ log_bin_basename= NULL;
+ log_bin_index= NULL;
+ /* Handler variables */
+ total_ha= 0;
+ total_ha_2pc= 0;
/* Variables in libraries */
charsets_dir= 0;
default_character_set_name= (char*) MYSQL_DEFAULT_CHARSET_NAME;
@@ -8227,10 +8241,7 @@ static int fix_paths(void)
if (opt_secure_file_priv)
{
if (*opt_secure_file_priv == 0)
- {
- my_free(opt_secure_file_priv);
- opt_secure_file_priv= 0;
- }
+ opt_secure_file_priv= NULL;
else
{
if (strlen(opt_secure_file_priv) >= FN_REFLEN)
@@ -8240,9 +8251,7 @@ static int fix_paths(void)
sql_print_warning("Failed to normalize the argument for --secure-file-priv.");
return 1;
}
- char *secure_file_real_path= (char *)my_malloc(FN_REFLEN, MYF(MY_FAE));
convert_dirname(secure_file_real_path, buff, NullS);
- my_free(opt_secure_file_priv);
opt_secure_file_priv= secure_file_real_path;
}
}
=== modified file 'sql/rpl_handler.cc'
--- a/sql/rpl_handler.cc 2011-10-02 08:25:38 +0000
+++ b/sql/rpl_handler.cc 2011-12-05 10:11:58 +0000
@@ -164,6 +164,8 @@ void delegates_destroy()
if (binlog_relay_io_delegate)
binlog_relay_io_delegate->~Binlog_relay_IO_delegate();
#endif /* HAVE_REPLICATION */
+ if (RPL_TRANS_BINLOG_INFO)
+ pthread_key_delete(RPL_TRANS_BINLOG_INFO);
}
/*
=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc 2012-02-17 18:30:34 +0000
+++ b/sql/sql_class.cc 2012-02-22 08:57:27 +0000
@@ -2167,10 +2167,12 @@ bool select_result::check_simple_select(
}
-static String default_line_term("\n",default_charset_info);
-static String default_escaped("\\",default_charset_info);
-static String default_field_term("\t",default_charset_info);
-static String default_xml_row_term("<row>", default_charset_info);
+static const String default_line_term("\n",default_charset_info);
+static const String default_escaped("\\",default_charset_info);
+static const String default_field_term("\t",default_charset_info);
+static const String default_xml_row_term("<row>", default_charset_info);
+static const String my_empty_string("",default_charset_info);
+
sql_exchange::sql_exchange(char *name, bool flag,
enum enum_filetype filetype_arg)
=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h 2012-02-15 13:57:17 +0000
+++ b/sql/sql_class.h 2012-02-22 08:57:27 +0000
@@ -3878,7 +3878,7 @@ class sql_exchange :public Sql_alloc
public:
enum enum_filetype filetype; /* load XML, Added by Arnold & Erik */
char *file_name;
- String *field_term,*enclosed,*line_term,*line_start,*escaped;
+ const String *field_term, *enclosed, *line_term, *line_start, *escaped;
bool opt_enclosed;
bool dumpfile;
ulong skip_lines;
=== modified file 'sql/sql_executor.cc'
--- a/sql/sql_executor.cc 2012-02-07 14:50:31 +0000
+++ b/sql/sql_executor.cc 2012-02-21 10:31:44 +0000
@@ -117,11 +117,6 @@ static bool setup_copy_fields(THD *thd,
Execute select, executor entry point.
@todo
- Note, that create_sort_index calls test_if_skip_sort_order and may
- finally replace sorting with index scan if there is a LIMIT clause in
- the query. It's never shown in EXPLAIN!
-
- @todo
When can we have here thd->net.report_error not zero?
*/
@@ -606,6 +601,9 @@ JOIN::execute(JOIN *parent)
Note: here we call make_cond_for_table() a second time in order
to get sort_table_cond. An alternative could be to use
Item::copy_andor_structure() to make a copy of sort_table_cond.
+
+ TODO: This is now obsolete as test_if_skip_sort_order()
+ is not any longer called as part of JOIN::execute() !
*/
if (curr_table->pre_idx_push_cond)
{
@@ -664,9 +662,6 @@ JOIN::execute(JOIN *parent)
Here we sort rows for ORDER BY/GROUP BY clause, if the optimiser
chose FILESORT to be faster than INDEX SCAN or there is no
suitable index present.
- Note, that create_sort_index calls test_if_skip_sort_order and may
- finally replace sorting with index scan if there is a LIMIT clause in
- the query. XXX: it's never shown in EXPLAIN!
OPTION_FOUND_ROWS supersedes LIMIT and is taken into account.
*/
DBUG_PRINT("info",("Sorting for order by/group by"));
@@ -936,11 +931,9 @@ JOIN::optimize_distinct()
/* Optimize "select distinct b from t1 order by key_part_1 limit #" */
if (order && skip_sort_order)
{
- /* Should always succeed */
- if (test_if_skip_sort_order(&join_tab[const_tables],
- order, unit->select_limit_cnt, false,
- &join_tab[const_tables].table->
- keys_in_use_for_order_by))
+ /* Should already have been optimized away */
+ DBUG_ASSERT(ordered_index_usage == ordered_index_order_by);
+ if (ordered_index_usage == ordered_index_order_by)
order= NULL;
}
}
@@ -3861,19 +3854,25 @@ create_sort_index(THD *thd, JOIN *join,
select= tab->select;
/*
- When there is SQL_BIG_RESULT do not sort using index for GROUP BY,
- and thus force sorting on disk unless a group min-max optimization
- is going to be used as it is applied now only for one table queries
- with covering indexes.
+ JOIN::optimize may have prepared an access path which makes
+ either the GROUP BY or ORDER BY sorting obsolete by using an
+ ordered index for the access. If the requested 'order' match
+ the prepared 'ordered_index_usage', we don't have to build
+ a temporary sort index now.
*/
- if ((order != join->group_list ||
- !(join->select_options & SELECT_BIG_RESULT) ||
- (select && select->quick &&
- select->quick->get_type() == QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX)) &&
- test_if_skip_sort_order(tab,order,select_limit,0,
- is_order_by ? &table->keys_in_use_for_order_by :
- &table->keys_in_use_for_group_by))
- DBUG_RETURN(0);
+ {
+ DBUG_ASSERT((is_order_by) == (order == join->order)); // Obsolete arg !
+ const bool is_skippable= (is_order_by) ?
+ ( join->simple_order &&
+ join->ordered_index_usage == JOIN::ordered_index_order_by )
+ :
+ ( join->simple_group &&
+ join->ordered_index_usage == JOIN::ordered_index_group_by );
+
+ if (is_skippable)
+ DBUG_RETURN(0);
+ }
+
for (ORDER *ord= join->order; ord; ord= ord->next)
length++;
if (!(join->sortorder=
=== modified file 'sql/sql_list.h'
--- a/sql/sql_list.h 2012-02-15 13:57:17 +0000
+++ b/sql/sql_list.h 2012-02-22 09:26:19 +0000
@@ -185,6 +185,14 @@ protected:
public:
uint elements;
+ bool operator==(const base_list &rhs) const
+ {
+ return
+ elements == rhs.elements &&
+ first == rhs.first &&
+ last == rhs.last;
+ }
+
inline void empty() { elements=0; first= &end_of_list; last=&first;}
inline base_list() { empty(); }
/**
@@ -521,17 +529,8 @@ public:
}
empty();
}
- /**
- @brief
- Sort the list according to provided comparison function
- @param cmp node comparison function
- @param arg additional info to be passed to comparison function
- * /
- inline void sort(Node_cmp_func cmp, void *arg)
- {
- base_list::sort(cmp, arg);
- }*/
+ using base_list::sort;
};
=== modified file 'sql/sql_load.cc'
--- a/sql/sql_load.cc 2012-02-16 09:51:14 +0000
+++ b/sql/sql_load.cc 2012-02-22 08:57:27 +0000
@@ -67,7 +67,7 @@ class READ_INFO {
*end_of_buff; /* Data in bufferts ends here */
uint buff_length, /* Length of buffert */
max_length; /* Max length of row */
- char *field_term_ptr,*line_term_ptr,*line_start_ptr,*line_start_end;
+ const char *field_term_ptr, *line_term_ptr, *line_start_ptr, *line_start_end;
uint field_term_length,line_term_length,enclosed_length;
int field_term_char,line_term_char,enclosed_char,escape_char;
int *stack,*stack_pos;
@@ -84,14 +84,17 @@ public:
const CHARSET_INFO *read_charset;
READ_INFO(File file,uint tot_length,const CHARSET_INFO *cs,
- String &field_term,String &line_start,String &line_term,
- String &enclosed,int escape,bool get_it_from_net, bool is_fifo);
+ const String &field_term,
+ const String &line_start,
+ const String &line_term,
+ const String &enclosed,
+ int escape,bool get_it_from_net, bool is_fifo);
~READ_INFO();
int read_field();
int read_fixed_length(void);
int next_line(void);
char unescape(char chr);
- int terminator(char *ptr,uint length);
+ int terminator(const char *ptr,uint length);
bool find_start_of_fields();
/* load xml */
List<XML_TAG> taglist;
@@ -125,13 +128,13 @@ static int read_fixed_length(THD *thd, C
static int read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
List<Item> &fields_vars, List<Item> &set_fields,
List<Item> &set_values, READ_INFO &read_info,
- String &enclosed, ulong skip_lines,
+ const String &enclosed, ulong skip_lines,
bool ignore_check_option_errors);
static int read_xml_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
List<Item> &fields_vars, List<Item> &set_fields,
List<Item> &set_values, READ_INFO &read_info,
- String &enclosed, ulong skip_lines,
+ ulong skip_lines,
bool ignore_check_option_errors);
#ifndef EMBEDDED_LIBRARY
@@ -176,8 +179,9 @@ int mysql_load(THD *thd,sql_exchange *ex
File file;
TABLE *table= NULL;
int error= 0;
- String *field_term=ex->field_term,*escaped=ex->escaped;
- String *enclosed=ex->enclosed;
+ const String *field_term= ex->field_term;
+ const String *escaped= ex->escaped;
+ const String *enclosed= ex->enclosed;
bool is_fifo=0;
#ifndef EMBEDDED_LIBRARY
LOAD_FILE_INFO lf_info;
@@ -493,7 +497,7 @@ int mysql_load(THD *thd,sql_exchange *ex
if (ex->filetype == FILETYPE_XML) /* load xml */
error= read_xml_field(thd, info, table_list, fields_vars,
set_fields, set_values, read_info,
- *(ex->line_term), skip_lines, ignore);
+ skip_lines, ignore);
else if (!field_term->length() && !enclosed->length())
error= read_fixed_length(thd, info, table_list, fields_vars,
set_fields, set_values, read_info,
@@ -922,7 +926,7 @@ static int
read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
List<Item> &fields_vars, List<Item> &set_fields,
List<Item> &set_values, READ_INFO &read_info,
- String &enclosed, ulong skip_lines,
+ const String &enclosed, ulong skip_lines,
bool ignore_check_option_errors)
{
List_iterator_fast<Item> it(fields_vars);
@@ -1134,7 +1138,7 @@ static int
read_xml_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list,
List<Item> &fields_vars, List<Item> &set_fields,
List<Item> &set_values, READ_INFO &read_info,
- String &row_tag, ulong skip_lines,
+ ulong skip_lines,
bool ignore_check_option_errors)
{
List_iterator_fast<Item> it(fields_vars);
@@ -1317,16 +1321,18 @@ READ_INFO::unescape(char chr)
READ_INFO::READ_INFO(File file_par, uint tot_length, const CHARSET_INFO *cs,
- String &field_term, String &line_start, String &line_term,
- String &enclosed_par, int escape, bool get_it_from_net,
- bool is_fifo)
+ const String &field_term,
+ const String &line_start,
+ const String &line_term,
+ const String &enclosed_par,
+ int escape, bool get_it_from_net, bool is_fifo)
:file(file_par), buff_length(tot_length), escape_char(escape),
found_end_of_line(false), eof(false), need_end_io_cache(false),
error(false), line_cuted(false), found_null(false), read_charset(cs)
{
- field_term_ptr=(char*) field_term.ptr();
+ field_term_ptr= field_term.ptr();
field_term_length= field_term.length();
- line_term_ptr=(char*) line_term.ptr();
+ line_term_ptr= line_term.ptr();
line_term_length= line_term.length();
level= 0; /* for load xml */
if (line_start.length() == 0)
@@ -1412,7 +1418,7 @@ READ_INFO::~READ_INFO()
#define PUSH(A) *(stack_pos++)=(A)
-inline int READ_INFO::terminator(char *ptr,uint length)
+inline int READ_INFO::terminator(const char *ptr,uint length)
{
int chr=0; // Keep gcc happy
uint i;
@@ -1732,7 +1738,7 @@ bool READ_INFO::find_start_of_fields()
return 1;
}
} while ((char) chr != line_start_ptr[0]);
- for (char *ptr=line_start_ptr+1 ; ptr != line_start_end ; ptr++)
+ for (const char *ptr=line_start_ptr+1 ; ptr != line_start_end ; ptr++)
{
chr=GET; // Eof will be checked later
if ((char) chr != *ptr)
=== modified file 'sql/sql_optimizer.cc'
--- a/sql/sql_optimizer.cc 2012-02-16 13:09:08 +0000
+++ b/sql/sql_optimizer.cc 2012-02-21 10:31:44 +0000
@@ -591,15 +591,21 @@ JOIN::optimize()
JOIN_TAB *tab= &join_tab[const_tables];
bool all_order_fields_used;
if (order)
- skip_sort_order= test_if_skip_sort_order(tab, order, m_select_limit, 1,
- &tab->table->keys_in_use_for_order_by);
+ {
+ skip_sort_order=
+ test_if_skip_sort_order(tab, order, m_select_limit,
+ true, // no_changes
+ &tab->table->keys_in_use_for_order_by);
+ }
if ((group_list=create_distinct_group(thd, ref_ptrs,
order, fields_list, all_fields,
&all_order_fields_used)))
{
- bool skip_group= (skip_sort_order &&
- test_if_skip_sort_order(tab, group_list, m_select_limit, 1,
- &tab->table->keys_in_use_for_group_by) != 0);
+ const bool skip_group=
+ skip_sort_order &&
+ test_if_skip_sort_order(tab, group_list, m_select_limit,
+ true, // no_changes
+ &tab->table->keys_in_use_for_group_by);
count_field_types(select_lex, &tmp_table_param, all_fields, 0);
if ((skip_group && all_order_fields_used) ||
m_select_limit == HA_POS_ERROR ||
@@ -820,6 +826,26 @@ JOIN::optimize()
if (const_tables != tables)
{
+ JOIN_TAB *tab= &join_tab[const_tables];
+
+ if (order)
+ {
+ /*
+ Force using of tmp table if sorting by a SP or UDF function due to
+ their expensive and probably non-deterministic nature.
+ */
+ for (ORDER *tmp_order= order; tmp_order ; tmp_order=tmp_order->next)
+ {
+ Item *item= *tmp_order->item;
+ if (item->is_expensive())
+ {
+ /* Force tmp table without sort */
+ need_tmp=1; simple_order=simple_group=0;
+ break;
+ }
+ }
+ }
+
/*
Because filesort always does a full table scan or a quick range scan
we must add the removed reference to the select for the table.
@@ -827,54 +853,80 @@ JOIN::optimize()
as in other cases the join is done before the sort.
*/
if ((order || group_list) &&
- join_tab[const_tables].type != JT_ALL &&
- join_tab[const_tables].type != JT_FT &&
- join_tab[const_tables].type != JT_REF_OR_NULL &&
+ tab->type != JT_ALL &&
+ tab->type != JT_FT &&
+ tab->type != JT_REF_OR_NULL &&
((order && simple_order) || (group_list && simple_group)))
{
- if (add_ref_to_table_cond(thd,&join_tab[const_tables])) {
+ if (add_ref_to_table_cond(thd,tab)) {
DBUG_RETURN(1);
}
}
- if (!(select_options & SELECT_BIG_RESULT) &&
- ((group_list &&
- (!simple_group ||
- !test_if_skip_sort_order(&join_tab[const_tables], group_list,
- unit->select_limit_cnt, 0,
- &join_tab[const_tables].table->
- keys_in_use_for_group_by))) ||
- select_distinct) &&
- tmp_table_param.quick_group && !procedure)
- {
- need_tmp=1; simple_order=simple_group=0; // Force tmp table without sort
- }
- if (order)
+ /*
+ Investigate whether we may use an ordered index as part of either
+ DISTINCT, GROUP BY or ORDER BY execution. An ordered index may be
+ used for only the first of any of these terms to be executed. This
+ is reflected in the order which we check for test_if_skip_sort_order()
+ below. However we do not check for DISTINCT here, as it would have
+ been transformed to a GROUP BY at this stage if it is a candidate for
+ ordered index optimization.
+ If a decision was made to use an ordered index, the availability
+ if such an access path is stored in 'ordered_index_usage' for later
+ use by 'execute' or 'explain'
+ */
+ DBUG_ASSERT(ordered_index_usage == ordered_index_void);
+
+ if (group_list) // GROUP BY honoured first
+ // (DISTINCT was rewritten to GROUP BY if skippable)
{
/*
- Do we need a temporary table due to the ORDER BY not being equal to
- the GROUP BY? The call to test_if_skip_sort_order above tests for the
- GROUP BY clause only and hence is not valid in this case. So the
- estimated number of rows to be read from the first table is not valid.
- We clear it here so that it doesn't show up in EXPLAIN.
- */
- if (need_tmp && (select_options & SELECT_DESCRIBE) != 0)
- join_tab[const_tables].limit= 0;
- /*
- Force using of tmp table if sorting by a SP or UDF function due to
- their expensive and probably non-deterministic nature.
+ When there is SQL_BIG_RESULT do not sort using index for GROUP BY,
+ and thus force sorting on disk unless a group min-max optimization
+ is going to be used as it is applied now only for one table queries
+ with covering indexes.
*/
- for (ORDER *tmp_order= order; tmp_order ; tmp_order=tmp_order->next)
+ if (!(select_options & SELECT_BIG_RESULT) ||
+ (tab->select &&
+ tab->select->quick &&
+ tab->select->quick->get_type() ==
+ QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX))
{
- Item *item= *tmp_order->item;
- if (item->is_expensive())
+ if (simple_group && // GROUP BY is possibly skippable
+ !select_distinct) // .. if not preceded by a DISTINCT
{
- /* Force tmp table without sort */
- need_tmp=1; simple_order=simple_group=0;
- break;
+ /*
+ Calculate a possible 'limit' of table rows for 'GROUP BY':
+ A specified 'LIMIT' is relative to the final resultset.
+ 'need_tmp' implies that there will be more postprocessing
+ so the specified 'limit' should not be enforced yet.
+ */
+ const ha_rows limit = need_tmp ? HA_POS_ERROR : m_select_limit;
+
+ if (test_if_skip_sort_order(tab, group_list, limit, false,
+ &tab->table->keys_in_use_for_group_by))
+ {
+ ordered_index_usage= ordered_index_group_by;
+ }
+ }
+
+ if ((ordered_index_usage != ordered_index_group_by) &&
+ tmp_table_param.quick_group && !procedure)
+ {
+ need_tmp=1;
+ simple_order= simple_group= false; // Force tmp table without sort
}
}
}
+ else if (order && // ORDER BY wo/ preceeding GROUP BY
+ (simple_order || skip_sort_order)) // which is possibly skippable
+ {
+ if (test_if_skip_sort_order(tab, order, m_select_limit, false,
+ &tab->table->keys_in_use_for_order_by))
+ {
+ ordered_index_usage= ordered_index_order_by;
+ }
+ }
}
tmp_having= having;
=== modified file 'sql/sql_optimizer.h'
--- a/sql/sql_optimizer.h 2012-02-16 11:36:03 +0000
+++ b/sql/sql_optimizer.h 2012-02-21 11:38:19 +0000
@@ -187,6 +187,19 @@ public:
GROUP/ORDER BY.
*/
bool simple_order, simple_group;
+
+ /*
+ ordered_index_usage is set if an ordered index access
+ should be used instead of a filesort when computing
+ ORDER/GROUP BY.
+ */
+ enum
+ {
+ ordered_index_void, // No ordered index avail.
+ ordered_index_group_by, // Use index for GROUP BY
+ ordered_index_order_by // Use index for ORDER BY
+ } ordered_index_usage;
+
/**
Is set only in case if we have a GROUP BY clause
and no ORDER BY after constant elimination of 'order'.
@@ -323,6 +336,7 @@ public:
no_order= 0;
simple_order= 0;
simple_group= 0;
+ ordered_index_usage= ordered_index_void;
skip_sort_order= 0;
need_tmp= 0;
hidden_group_fields= 0; /*safety*/
=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc 2012-02-16 10:52:45 +0000
+++ b/sql/sql_select.cc 2012-02-22 09:26:19 +0000
@@ -700,6 +700,8 @@ static int clear_sj_tmp_tables(JOIN *joi
*/
void JOIN::restore_tmp()
{
+ DBUG_PRINT("info", ("restore_tmp this %p tmp_join %p", this, tmp_join));
+ DBUG_ASSERT(tmp_join != this);
memcpy(tmp_join, this, (size_t) sizeof(JOIN));
}
@@ -862,6 +864,7 @@ JOIN::explain()
table to resolve ORDER BY: in that case, we only may need to do
filesort for GROUP BY.
*/
+ bool is_order_by= true;
if (!order && !no_order && (!skip_sort_order || !need_tmp))
{
/*
@@ -871,21 +874,32 @@ JOIN::explain()
order= group_list;
simple_order= simple_group;
skip_sort_order= 0;
+ is_order_by= false;
}
- if (order &&
- (order != group_list || !(select_options & SELECT_BIG_RESULT)) &&
- (const_tables == tables ||
- ((simple_order || skip_sort_order) &&
- test_if_skip_sort_order(&join_tab[const_tables], order,
- m_select_limit, 0,
- &join_tab[const_tables].table->
- keys_in_use_for_query))))
- order=0;
+
having= tmp_having;
if (tables)
+ {
+ /*
+ JOIN::optimize may have prepared an access patch which makes
+ either the GROUP BY or ORDER BY sorting obsolete by using an
+ ordered index for the access. If the required 'order' match
+ the available 'ordered_index_usage' we will use ordered index
+ access instead of doing a filesort.
+
+ NOTE: This code is intentional similar to 'is_skippable' code
+ in create_sort_index() which is the ::execute()
+ counterpart of what we 'explain' here.
+ */
+ const bool is_skippable= (is_order_by) ?
+ ( simple_order && ordered_index_usage == ordered_index_order_by )
+ :
+ ( simple_group && ordered_index_usage == ordered_index_group_by );
+
explain_query_specification(thd, this, need_tmp,
- order != 0 && !skip_sort_order,
+ (order != NULL) && !is_skippable,
select_distinct);
+ }
else
explain_no_table(thd, this, "No tables used");
@@ -3139,13 +3153,18 @@ void JOIN::cleanup(bool full)
{
if (tmp_join)
tmp_table_param.copy_field= 0;
- group_fields.delete_elements();
+
/*
- Ensure that the above delete_elements() would not be called
+ Ensure that the following delete_elements() would not be called
twice for the same list.
*/
- if (tmp_join && tmp_join != this)
- tmp_join->group_fields= group_fields;
+ if (tmp_join && tmp_join != this &&
+ tmp_join->group_fields == this->group_fields)
+ tmp_join->group_fields.empty();
+
+ // Run Cached_item DTORs!
+ group_fields.delete_elements();
+
/*
We can't call delete_elements() on copy_funcs as this will cause
problems in free_elements() as some of the elements are then deleted.
=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc 2012-02-16 10:57:29 +0000
+++ b/sql/sql_show.cc 2012-02-21 14:51:02 +0000
@@ -510,7 +510,10 @@ void
ignore_db_dirs_free()
{
if (opt_ignore_db_dirs)
+ {
my_free(opt_ignore_db_dirs);
+ opt_ignore_db_dirs= NULL;
+ }
ignore_db_dirs_reset();
delete_dynamic(&ignore_db_dirs_array);
my_hash_free(&ignore_db_dirs_hash);
=== modified file 'sql/sql_string.cc'
--- a/sql/sql_string.cc 2012-02-16 09:51:14 +0000
+++ b/sql/sql_string.cc 2012-02-22 08:57:27 +0000
@@ -539,7 +539,7 @@ bool String::append_with_prefill(const c
return FALSE;
}
-uint32 String::numchars()
+uint32 String::numchars() const
{
return str_charset->cset->numchars(str_charset, Ptr, Ptr+str_length);
}
=== modified file 'sql/sql_string.h'
--- a/sql/sql_string.h 2011-11-01 11:52:24 +0000
+++ b/sql/sql_string.h 2012-02-22 08:57:27 +0000
@@ -320,7 +320,7 @@ public:
friend int sortcmp(const String *a,const String *b, const CHARSET_INFO *cs);
friend int stringcmp(const String *a,const String *b);
friend String *copy_if_not_alloced(String *a,String *b,uint32 arg_length);
- uint32 numchars();
+ uint32 numchars() const;
int charpos(int i,uint32 offset=0);
int reserve(uint32 space_needed)
=== modified file 'sql/sys_vars.cc'
--- a/sql/sys_vars.cc 2012-02-20 18:05:15 +0000
+++ b/sql/sys_vars.cc 2012-02-22 16:43:06 +0000
@@ -2362,7 +2362,7 @@ static Sys_var_charptr Sys_secure_file_p
"secure_file_priv",
"Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to files "
"within specified directory",
- PREALLOCATED READ_ONLY GLOBAL_VAR(opt_secure_file_priv),
+ READ_ONLY GLOBAL_VAR(opt_secure_file_priv),
CMD_LINE(REQUIRED_ARG), IN_FS_CHARSET, DEFAULT(0));
static bool fix_server_id(sys_var *self, THD *thd, enum_var_type type)
@@ -3360,7 +3360,7 @@ static bool fix_general_log_file(sys_var
}
static Sys_var_charptr Sys_general_log_path(
"general_log_file", "Log connections and queries to given file",
- PREALLOCATED GLOBAL_VAR(opt_logname), CMD_LINE(REQUIRED_ARG),
+ GLOBAL_VAR(opt_logname), CMD_LINE(REQUIRED_ARG),
IN_FS_CHARSET, DEFAULT(0), NO_MUTEX_GUARD, NOT_IN_BINLOG,
ON_CHECK(check_log_path), ON_UPDATE(fix_general_log_file));
@@ -3378,7 +3378,7 @@ static Sys_var_charptr Sys_slow_log_path
"slow_query_log_file", "Log slow queries to given log file. "
"Defaults logging to hostname-slow.log. Must be enabled to activate "
"other slow log options",
- PREALLOCATED GLOBAL_VAR(opt_slow_logname), CMD_LINE(REQUIRED_ARG),
+ GLOBAL_VAR(opt_slow_logname), CMD_LINE(REQUIRED_ARG),
IN_FS_CHARSET, DEFAULT(0), NO_MUTEX_GUARD, NOT_IN_BINLOG,
ON_CHECK(check_log_path), ON_UPDATE(fix_slow_log_file));
=== modified file 'tests/mysql_client_test.c'
--- a/tests/mysql_client_test.c 2012-02-13 15:23:37 +0000
+++ b/tests/mysql_client_test.c 2012-02-21 14:51:02 +0000
@@ -58,6 +58,7 @@ static MYSQL *mysql= 0;
static char current_db[]= "client_test_db";
static unsigned int test_count= 0;
static unsigned int opt_count= 0;
+static unsigned int opt_count_read= 0;
static unsigned int iter_count= 0;
static my_bool have_innodb= FALSE;
static char *opt_plugin_dir= 0, *opt_default_auth= 0;
@@ -67,6 +68,9 @@ static const char *opt_vardir= "mysql-te
static longlong opt_getopt_ll_test= 0;
+static char **defaults_argv;
+static int original_argc;
+static char **original_argv;
static int embedded_server_arg_count= 0;
static char *embedded_server_args[MAX_SERVER_ARGS];
@@ -82,6 +86,11 @@ static double total_time;
const char *default_dbug_option= "d:t:o,/tmp/mysql_client_test.trace";
+/*
+ Read and parse arguments and MySQL options from my.cnf
+*/
+static const char *client_test_load_default_groups[]= { "client", 0 };
+
struct my_tests_st
{
const char *name;
@@ -110,6 +119,7 @@ if (!opt_silent) \
static void print_error(const char *msg);
static void print_st_error(MYSQL_STMT *stmt, const char *msg);
static void client_disconnect(MYSQL* mysql, my_bool drop_db);
+static void get_options(int *argc, char ***argv);
/*
@@ -268,7 +278,7 @@ static my_bool check_have_innodb(MYSQL *
MYSQL_RES *res;
MYSQL_ROW row;
int rc;
- my_bool result;
+ my_bool result= FALSE;
rc= mysql_query(conn,
"SELECT (support = 'YES' or support = 'DEFAULT' or support = 'ENABLED') "
@@ -280,7 +290,8 @@ static my_bool check_have_innodb(MYSQL *
row= mysql_fetch_row(res);
DIE_UNLESS(row);
- result= strcmp(row[1], "1") == 0;
+ if (row[0] && row[1])
+ result= strcmp(row[1], "1") == 0;
mysql_free_result(res);
return result;
}
@@ -8265,6 +8276,119 @@ static void test_set_option()
}
+#ifdef EMBEDDED_LIBRARY
+static void test_embedded_start_stop()
+{
+ MYSQL *mysql_emb=NULL;
+ int i, j;
+ int argc= original_argc; // Start with the original args
+ char **argv, **my_argv;
+ char test_name[]= "test_embedded_start_stop";
+#define EMBEDDED_RESTARTS 64
+
+ myheader("test_embedded_start_stop");
+
+ /* Must stop the main embedded server, since we use the same config. */
+ client_disconnect(mysql, 0); /* disconnect from server */
+ free_defaults(defaults_argv);
+ mysql_server_end();
+ /* Free everything allocated by my_once_alloc */
+ my_end(0);
+
+ /*
+ Use a copy of the original arguments.
+ The arguments will be altered when reading the configs and parsing
+ options.
+ */
+ my_argv= malloc((argc + 1) * sizeof(char*));
+ if (!my_argv)
+ exit(1);
+
+ /* Test restarting the embedded library many times. */
+ for (i= 1; i <= EMBEDDED_RESTARTS; i++)
+ {
+ argv= my_argv;
+ argv[0]= test_name;
+ for (j= 1; j < argc; j++)
+ argv[j]= original_argv[j];
+
+ /* Initialize everything again. */
+ MY_INIT(argv[0]);
+
+ /* Load the client defaults from the .cnf file[s]. */
+ if (load_defaults("my", client_test_load_default_groups, &argc, &argv))
+ {
+ myerror("load_defaults failed");
+ exit(1);
+ }
+
+ /* Parse the options (including the ones given from defaults files). */
+ get_options(&argc, &argv);
+
+ /* mysql_library_init is the same as mysql_server_init. */
+ if (mysql_library_init(embedded_server_arg_count,
+ embedded_server_args,
+ (char**) embedded_server_groups))
+ {
+ myerror("mysql_library_init failed");
+ exit(1);
+ }
+
+ /* Create a client connection. */
+ if (!(mysql_emb= mysql_client_init(NULL)))
+ {
+ myerror("mysql_client_init failed");
+ exit(1);
+ }
+
+ /* Connect it and see if we can use the database. */
+ if (!(mysql_real_connect(mysql_emb, opt_host, opt_user,
+ opt_password, current_db, 0,
+ NULL, 0)))
+ {
+ myerror("mysql_real_connect failed");
+ }
+
+ /* Close the client connection */
+ mysql_close(mysql_emb);
+ mysql_emb = NULL;
+ /* Free arguments allocated for defaults files. */
+ free_defaults(defaults_argv);
+ /* mysql_library_end is a define for mysql_server_end. */
+ mysql_library_end();
+ /* Free everything allocated by my_once_alloc */
+ my_end(0);
+ }
+
+ argc= original_argc;
+ argv= my_argv;
+ argv[0]= test_name;
+ for (j= 1; j < argc; j++)
+ argv[j]= original_argv[j];
+
+ MY_INIT(argv[0]);
+
+ if (load_defaults("my", client_test_load_default_groups, &argc, &argv))
+ {
+ myerror("load_defaults failed \n ");
+ exit(1);
+ }
+
+ get_options(&argc, &argv);
+
+ /* Must start the main embedded server again after the test. */
+ if (mysql_server_init(embedded_server_arg_count,
+ embedded_server_args,
+ (char**) embedded_server_groups))
+ DIE("Can't initialize MySQL server");
+
+ /* connect to server with no flags, default protocol, auto reconnect true */
+ mysql= client_connect(0, MYSQL_PROTOCOL_DEFAULT, 1);
+ free(my_argv);
+}
+#endif /* EMBEDDED_LIBRARY */
+
+
/*
Test a misc GRANT option
bug #89 (reported by mark@stripped)
@@ -20008,19 +20132,12 @@ static void test_bug13001491()
}
-/*
- Read and parse arguments and MySQL options from my.cnf
-*/
-
-static const char *client_test_load_default_groups[]= { "client", 0 };
-static char **defaults_argv;
-
static struct my_option client_test_long_options[] =
{
{"basedir", 'b', "Basedir for tests.", &opt_basedir,
&opt_basedir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
- {"count", 't', "Number of times test to be executed", &opt_count,
- &opt_count, 0, GET_UINT, REQUIRED_ARG, 1, 0, 0, 0, 0, 0},
+ {"count", 't', "Number of times test to be executed", &opt_count_read,
+ &opt_count_read, 0, GET_UINT, REQUIRED_ARG, 1, 0, 0, 0, 0, 0},
{"database", 'D', "Database to use", &opt_db, &opt_db,
0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"debug", '#', "Output debug log", &default_dbug_option,
@@ -20176,6 +20293,9 @@ static struct my_tests_st my_tests[]= {
{ "test_stiny_bug", test_stiny_bug },
{ "test_field_misc", test_field_misc },
{ "test_set_option", test_set_option },
+#ifdef EMBEDDED_LIBRARY
+ { "test_embedded_start_stop", test_embedded_start_stop },
+#endif
#ifndef EMBEDDED_LIBRARY
{ "test_prepare_grant", test_prepare_grant },
#endif
@@ -20434,6 +20554,11 @@ static void get_options(int *argc, char
{
int ho_error;
+ /* Copy argv from load_defaults, so we can free it when done. */
+ defaults_argv= *argv;
+ /* reset --silent option */
+ opt_silent= 0;
+
if ((ho_error= handle_options(argc, argv, client_test_long_options,
get_one_option)))
exit(ho_error);
@@ -20454,9 +20579,12 @@ static void print_test_output()
fprintf(stdout, "\n\n");
fprintf(stdout, "All '%d' tests were successful (in '%d' iterations)",
test_count-1, opt_count);
- fprintf(stdout, "\n Total execution time: %g SECS", total_time);
- if (opt_count > 1)
- fprintf(stdout, " (Avg: %g SECS)", total_time/opt_count);
+ if (!opt_silent)
+ {
+ fprintf(stdout, "\n Total execution time: %g SECS", total_time);
+ if (opt_count > 1)
+ fprintf(stdout, " (Avg: %g SECS)", total_time/opt_count);
+ }
fprintf(stdout, "\n\n!!! SUCCESS !!!\n");
}
@@ -20469,16 +20597,39 @@ static void print_test_output()
int main(int argc, char **argv)
{
+ int i;
+ char **tests_to_run= NULL, **curr_test;
struct my_tests_st *fptr;
MY_INIT(argv[0]);
+ /* Copy the original arguments, so it can be reused for restarting. */
+ original_argc= argc;
+ original_argv= malloc(argc * sizeof(char*));
+ if (argc && !original_argv)
+ exit(1);
+ for (i= 0; i < argc; i++)
+ original_argv[i]= strdup(argv[i]);
+
if (load_defaults("my", client_test_load_default_groups, &argc, &argv))
exit(1);
- defaults_argv= argv;
get_options(&argc, &argv);
+ /* Set main opt_count. */
+ opt_count= opt_count_read;
+
+ /* If there are any arguments left (named tests), save them. */
+ if (argc)
+ {
+ tests_to_run= malloc((argc + 1) * sizeof(char*));
+ if (!tests_to_run)
+ exit(1);
+ for (i= 0; i < argc; i++)
+ tests_to_run[i]= strdup(argv[i]);
+ tests_to_run[i]= NULL;
+ }
+
if (mysql_server_init(embedded_server_arg_count,
embedded_server_args,
(char**) embedded_server_groups))
@@ -20493,18 +20644,18 @@ int main(int argc, char **argv)
/* Start of tests */
test_count= 1;
start_time= time((time_t *)0);
- if (!argc)
+ if (!tests_to_run)
{
for (fptr= my_tests; fptr->name; fptr++)
(*fptr->function)();
}
else
{
- for ( ; *argv ; argv++)
+ for (curr_test= tests_to_run ; *curr_test ; curr_test++)
{
for (fptr= my_tests; fptr->name; fptr++)
{
- if (!strcmp(fptr->name, *argv))
+ if (!strcmp(fptr->name, *curr_test))
{
(*fptr->function)();
break;
@@ -20517,6 +20668,7 @@ int main(int argc, char **argv)
my_progname);
client_disconnect(mysql, 1);
free_defaults(defaults_argv);
+ mysql_server_end();
exit(1);
}
}
@@ -20540,5 +20692,17 @@ int main(int argc, char **argv)
my_end(0);
+ for (i= 0; i < original_argc; i++)
+ free(original_argv[i]);
+ if (original_argc)
+ free(original_argv);
+ if (tests_to_run)
+ {
+ for (curr_test= tests_to_run ; *curr_test ; curr_test++)
+ free(*curr_test);
+ free(tests_to_run);
+ }
+ my_free(opt_password);
+ my_free(opt_host);
exit(0);
}
=== modified file 'unittest/gunit/opt_range-t.cc'
--- a/unittest/gunit/opt_range-t.cc 2012-02-09 11:22:17 +0000
+++ b/unittest/gunit/opt_range-t.cc 2012-02-22 14:30:56 +0000
@@ -140,7 +140,13 @@ public:
if (item)
item->save_in_field_no_warnings(this, true);
}
-
+ ~Mock_field_long()
+ {
+ bitmap_free(&share_allset);
+ bitmap_free(&tbl_readset);
+ bitmap_free(&tbl_writeset);
+ }
+
// #bytes to store the value - see Field_long::key_lenght()
static const int KEY_LENGTH= 4;
const char *m_table_name;
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-trunk-wl5767 branch (marc.alff:3444 to 3445) | Marc Alff | 24 Feb |