#At file:///export/home/tmp/ss156133/z/45387-pe/ based on revid:patrick.crews@stripped
3356 Staale Smedseng 2009-06-12 [merge]
Merge from 5.1
added:
mysql-test/r/log_tables_debug.result
mysql-test/t/log_tables_debug.test
modified:
mysql-test/r/group_min_max.result
mysql-test/t/group_min_max.test
sql/log.cc
sql/opt_range.cc
support-files/build-tags
=== modified file 'mysql-test/r/group_min_max.result'
--- a/mysql-test/r/group_min_max.result 2009-02-27 15:47:32 +0000
+++ b/mysql-test/r/group_min_max.result 2009-06-12 14:37:49 +0000
@@ -2462,4 +2462,43 @@ c
1
2
DROP TABLE t1;
+#
+# Bug #45386: Wrong query result with MIN function in field list,
+# WHERE and GROUP BY clause
+#
+CREATE TABLE t (a INT, b INT, INDEX (a,b));
+INSERT INTO t VALUES (2,0), (2,0), (2,1), (2,1);
+INSERT INTO t SELECT * FROM t;
+# test MIN
+#should use range with index for group by
+EXPLAIN
+SELECT a, MIN(b) FROM t WHERE b <> 0 GROUP BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t range NULL a 10 NULL 9 Using where; Using index for group-by
+#should return 1 row
+SELECT a, MIN(b) FROM t WHERE b <> 0 GROUP BY a;
+a MIN(b)
+2 1
+# test MAX
+#should use range with index for group by
+EXPLAIN
+SELECT a, MAX(b) FROM t WHERE b <> 1 GROUP BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t range NULL a 10 NULL 9 Using where; Using index for group-by
+#should return 1 row
+SELECT a, MAX(b) FROM t WHERE b <> 1 GROUP BY a;
+a MAX(b)
+2 0
+# test 3 ranges and use the middle one
+INSERT INTO t SELECT a, 2 FROM t;
+#should use range with index for group by
+EXPLAIN
+SELECT a, MAX(b) FROM t WHERE b > 0 AND b < 2 GROUP BY a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t range NULL a 10 NULL 9 Using where; Using index for group-by
+#should return 1 row
+SELECT a, MAX(b) FROM t WHERE b > 0 AND b < 2 GROUP BY a;
+a MAX(b)
+2 1
+DROP TABLE t;
End of 5.0 tests
=== added file 'mysql-test/r/log_tables_debug.result'
--- a/mysql-test/r/log_tables_debug.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/log_tables_debug.result 2009-06-12 14:28:10 +0000
@@ -0,0 +1,23 @@
+SET @old_general_log= @@global.general_log;
+SET @old_general_log_file= @@global.general_log_file;
+SET @old_slow_query_log= @@global.slow_query_log;
+SET @old_slow_query_log_file= @@global.slow_query_log_file;
+#
+# Bug#45387 Information about statement id for prepared
+# statements missed from general log
+#
+SET @@global.general_log = ON;
+SET @@global.general_log_file = 'bug45387_general.log';
+SET SESSION debug='+d,reset_log_last_time';
+SET @@global.general_log = @old_general_log;
+SET @@global.general_log_file = @old_general_log_file;
+SET SESSION debug='';
+Bug#45387: ID match.
+End of 5.1 tests
+#
+# Cleanup
+#
+SET global general_log = @old_general_log;
+SET global general_log_file = @old_general_log_file;
+SET global slow_query_log = @old_slow_query_log;
+SET global slow_query_log_file = @old_slow_query_log_file;
=== modified file 'mysql-test/t/group_min_max.test'
--- a/mysql-test/t/group_min_max.test 2009-02-27 15:07:27 +0000
+++ b/mysql-test/t/group_min_max.test 2009-06-12 13:58:48 +0000
@@ -982,4 +982,39 @@ SELECT DISTINCT c FROM t1 WHERE d=4;
DROP TABLE t1;
+--echo #
+--echo # Bug #45386: Wrong query result with MIN function in field list,
+--echo # WHERE and GROUP BY clause
+--echo #
+
+CREATE TABLE t (a INT, b INT, INDEX (a,b));
+INSERT INTO t VALUES (2,0), (2,0), (2,1), (2,1);
+INSERT INTO t SELECT * FROM t;
+
+--echo # test MIN
+--echo #should use range with index for group by
+EXPLAIN
+SELECT a, MIN(b) FROM t WHERE b <> 0 GROUP BY a;
+--echo #should return 1 row
+SELECT a, MIN(b) FROM t WHERE b <> 0 GROUP BY a;
+
+--echo # test MAX
+--echo #should use range with index for group by
+EXPLAIN
+SELECT a, MAX(b) FROM t WHERE b <> 1 GROUP BY a;
+--echo #should return 1 row
+SELECT a, MAX(b) FROM t WHERE b <> 1 GROUP BY a;
+
+--echo # test 3 ranges and use the middle one
+INSERT INTO t SELECT a, 2 FROM t;
+
+--echo #should use range with index for group by
+EXPLAIN
+SELECT a, MAX(b) FROM t WHERE b > 0 AND b < 2 GROUP BY a;
+--echo #should return 1 row
+SELECT a, MAX(b) FROM t WHERE b > 0 AND b < 2 GROUP BY a;
+
+DROP TABLE t;
+
+
--echo End of 5.0 tests
=== added file 'mysql-test/t/log_tables_debug.test'
--- a/mysql-test/t/log_tables_debug.test 1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/log_tables_debug.test 2009-06-12 14:37:49 +0000
@@ -0,0 +1,74 @@
+### t/log_tables_debug.test
+#
+# Log-related tests requiring a debug-build server.
+#
+
+--source include/have_debug.inc
+
+# Several subtests modify global variables. Save the initial values only here,
+# but reset to the initial values per subtest.
+SET @old_general_log= @@global.general_log;
+SET @old_general_log_file= @@global.general_log_file;
+SET @old_slow_query_log= @@global.slow_query_log;
+SET @old_slow_query_log_file= @@global.slow_query_log_file;
+
+
+--echo #
+--echo # Bug#45387 Information about statement id for prepared
+--echo # statements missed from general log
+--echo #
+
+let MYSQLD_DATADIR= `SELECT @@datadir`;
+
+# set logging to our specific bug log to control the entries added
+SET @@global.general_log = ON;
+SET @@global.general_log_file = 'bug45387_general.log';
+
+# turn on output of timestamps on all log file entries,
+SET SESSION debug='+d,reset_log_last_time';
+
+let CONN_ID= `SELECT CONNECTION_ID()`;
+
+# reset log settings
+SET @@global.general_log = @old_general_log;
+SET @@global.general_log_file = @old_general_log_file;
+SET SESSION debug='';
+
+perl;
+ # get the relevant info from the surrounding perl invocation
+ $datadir= $ENV{'MYSQLD_DATADIR'};
+ $conn_id= $ENV{'CONN_ID'};
+
+ # loop through the log file looking for the stmt querying for conn id
+ open(FILE, "$datadir/bug45387_general.log") or
+ die("Unable to read log file $datadir/bug45387_general.log: $!\n");
+ while(<FILE>) {
+ if (/\d{6} \d\d:\d\d:\d\d[ \t]+(\d+)[ \t]+Query[ \t]+SELECT CONNECTION_ID/) {
+ $found= $1;
+ break;
+ }
+ }
+ close(FILE);
+
+ # print the result
+ if ($found == $conn_id) {
+ print "Bug#45387: ID match.\n";
+ } else {
+ print "Bug#45387: Expected ID '$conn_id', found '$found' in log file.\n";
+ }
+EOF
+
+--remove_file $MYSQLD_DATADIR/bug45387_general.log
+
+--echo End of 5.1 tests
+
+
+--echo #
+--echo # Cleanup
+--echo #
+
+# Reset global system variables to initial values if forgotten somewhere above.
+SET global general_log = @old_general_log;
+SET global general_log_file = @old_general_log_file;
+SET global slow_query_log = @old_slow_query_log;
+SET global slow_query_log_file = @old_slow_query_log_file;
=== modified file 'sql/log.cc'
--- a/sql/log.cc 2009-06-08 14:58:33 +0000
+++ b/sql/log.cc 2009-06-12 14:37:49 +0000
@@ -3387,6 +3387,9 @@ bool MYSQL_QUERY_LOG::write(time_t event
/* Test if someone closed between the is_open test and lock */
if (is_open())
{
+ /* for testing output of timestamp and thread id */
+ DBUG_EXECUTE_IF("reset_log_last_time", last_time= 0;);
+
/* Note that my_b_write() assumes it knows the length for this */
if (event_time != last_time)
{
@@ -3395,7 +3398,7 @@ bool MYSQL_QUERY_LOG::write(time_t event
localtime_r(&event_time, &start);
time_buff_len= my_snprintf(local_time_buff, MAX_TIME_SIZE,
- "%02d%02d%02d %2d:%02d:%02d",
+ "%02d%02d%02d %2d:%02d:%02d\t",
start.tm_year % 100, start.tm_mon + 1,
start.tm_mday, start.tm_hour,
start.tm_min, start.tm_sec);
=== modified file 'sql/opt_range.cc'
--- a/sql/opt_range.cc 2009-06-09 16:53:34 +0000
+++ b/sql/opt_range.cc 2009-06-12 14:37:49 +0000
@@ -11002,8 +11002,14 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_min
/* Compare the found key with max_key. */
int cmp_res= key_cmp(index_info->key_part, max_key,
real_prefix_len + min_max_arg_len);
- if (!(((cur_range->flag & NEAR_MAX) && (cmp_res == -1)) ||
- (cmp_res <= 0)))
+ /*
+ The key is outside of the range if:
+ the interval is open and the key is equal to the maximum boundry
+ or
+ the key is greater than the maximum
+ */
+ if (((cur_range->flag & NEAR_MAX) && cmp_res == 0) ||
+ cmp_res > 0)
{
result= HA_ERR_KEY_NOT_FOUND;
continue;
@@ -11120,8 +11126,14 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_max
/* Compare the found key with min_key. */
int cmp_res= key_cmp(index_info->key_part, min_key,
real_prefix_len + min_max_arg_len);
- if (!(((cur_range->flag & NEAR_MIN) && (cmp_res == 1)) ||
- (cmp_res >= 0)))
+ /*
+ The key is outside of the range if:
+ the interval is open and the key is equal to the minimum boundry
+ or
+ the key is less than the minimum
+ */
+ if (((cur_range->flag & NEAR_MIN) && cmp_res == 0) ||
+ cmp_res < 0)
continue;
}
/* If we got to this point, the current key qualifies as MAX. */
=== modified file 'support-files/build-tags'
--- a/support-files/build-tags 2008-12-24 10:48:24 +0000
+++ b/support-files/build-tags 2009-06-12 14:37:49 +0000
@@ -4,7 +4,7 @@ rm -f TAGS
filter='\.cc$\|\.c$\|\.h$\|\.yy$\|\.[ch]pp$'
list="find . -type f"
-bzr root >/dev/null 2>/dev/null && list="bzr ls --kind=file --versioned"
+bzr root >/dev/null 2>/dev/null && list="bzr ls --from-root -R --kind=file --versioned"
$list |grep $filter |while read f;
do
Attachment: [text/bzr-bundle] bzr/staale.smedseng@sun.com-20090612143749-adpp61ymvcegk1u0.bundle
| Thread |
|---|
| • bzr commit into mysql-pe branch (staale.smedseng:3356) | Staale Smedseng | 12 Jun |