Commit 15853680 authored by Davi Arnaut's avatar Davi Arnaut

Merge from mysql-5.0-bugteam into mysql-5.1-bugteam

parents 2bf160b0 5fd99149
...@@ -1274,6 +1274,36 @@ tt ...@@ -1274,6 +1274,36 @@ tt
41 41
SET sql_mode=@save_sql_mode; SET sql_mode=@save_sql_mode;
DROP TABLE t1, t2; DROP TABLE t1, t2;
#
# 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;
End of 5.0 tests End of 5.0 tests
CREATE TABLE t1 (a INT, b INT, CREATE TABLE t1 (a INT, b INT,
PRIMARY KEY (a), PRIMARY KEY (a),
......
...@@ -24,8 +24,8 @@ data directory='/not/existing' ...@@ -24,8 +24,8 @@ data directory='/not/existing'
index directory='/not/existing' index directory='/not/existing'
); );
Warnings: Warnings:
Warning 1616 <DATA DIRECTORY> option ignored Warning 1618 <DATA DIRECTORY> option ignored
Warning 1616 <INDEX DIRECTORY> option ignored Warning 1618 <INDEX DIRECTORY> option ignored
show create table t2; show create table t2;
Table Create Table Table Create Table
t2 CREATE TABLE `t2` ( t2 CREATE TABLE `t2` (
......
...@@ -101,8 +101,8 @@ data directory='/not/existing' ...@@ -101,8 +101,8 @@ data directory='/not/existing'
index directory='/not/existing' index directory='/not/existing'
); );
Warnings: Warnings:
Warning 1616 <DATA DIRECTORY> option ignored Warning 1618 <DATA DIRECTORY> option ignored
Warning 1616 <INDEX DIRECTORY> option ignored Warning 1618 <INDEX DIRECTORY> option ignored
show create table t2; show create table t2;
Table Create Table Table Create Table
t2 CREATE TABLE `t2` ( t2 CREATE TABLE `t2` (
......
...@@ -79,7 +79,7 @@ drop database mysqltest; ...@@ -79,7 +79,7 @@ drop database mysqltest;
create table t1 (a int not null) engine=myisam; create table t1 (a int not null) engine=myisam;
alter table t1 data directory="MYSQLTEST_VARDIR/tmp"; alter table t1 data directory="MYSQLTEST_VARDIR/tmp";
Warnings: Warnings:
Warning 1616 <DATA DIRECTORY> option ignored Warning 1618 <DATA DIRECTORY> option ignored
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
...@@ -88,7 +88,7 @@ t1 CREATE TABLE `t1` ( ...@@ -88,7 +88,7 @@ t1 CREATE TABLE `t1` (
alter table t1 add b int; alter table t1 add b int;
alter table t1 data directory="MYSQLTEST_VARDIR/log"; alter table t1 data directory="MYSQLTEST_VARDIR/log";
Warnings: Warnings:
Warning 1616 <DATA DIRECTORY> option ignored Warning 1618 <DATA DIRECTORY> option ignored
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
...@@ -97,7 +97,7 @@ t1 CREATE TABLE `t1` ( ...@@ -97,7 +97,7 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
alter table t1 index directory="MYSQLTEST_VARDIR/log"; alter table t1 index directory="MYSQLTEST_VARDIR/log";
Warnings: Warnings:
Warning 1616 <INDEX DIRECTORY> option ignored Warning 1618 <INDEX DIRECTORY> option ignored
show create table t1; show create table t1;
Table Create Table Table Create Table
t1 CREATE TABLE `t1` ( t1 CREATE TABLE `t1` (
...@@ -164,8 +164,8 @@ ERROR HY000: Can't create/write to file 'TEST_DIR/master-data_var/t1.MYI' (Errco ...@@ -164,8 +164,8 @@ ERROR HY000: Can't create/write to file 'TEST_DIR/master-data_var/t1.MYI' (Errco
SET @OLD_SQL_MODE=@@SQL_MODE, @@SQL_MODE='NO_DIR_IN_CREATE'; SET @OLD_SQL_MODE=@@SQL_MODE, @@SQL_MODE='NO_DIR_IN_CREATE';
CREATE TABLE t1(a INT) DATA DIRECTORY='MYSQLTEST_VARDIR/tmp' INDEX DIRECTORY='MYSQLTEST_VARDIR/tmp'; CREATE TABLE t1(a INT) DATA DIRECTORY='MYSQLTEST_VARDIR/tmp' INDEX DIRECTORY='MYSQLTEST_VARDIR/tmp';
Warnings: Warnings:
Warning 1616 <DATA DIRECTORY> option ignored Warning 1618 <DATA DIRECTORY> option ignored
Warning 1616 <INDEX DIRECTORY> option ignored Warning 1618 <INDEX DIRECTORY> option ignored
DROP TABLE t1; DROP TABLE t1;
SET @@SQL_MODE=@OLD_SQL_MODE; SET @@SQL_MODE=@OLD_SQL_MODE;
End of 5.1 tests End of 5.1 tests
...@@ -940,6 +940,35 @@ select (select sum(outr.a + t1.a) from t1 limit 1) as tt from t1 as outr order b ...@@ -940,6 +940,35 @@ select (select sum(outr.a + t1.a) from t1 limit 1) as tt from t1 as outr order b
SET sql_mode=@save_sql_mode; SET sql_mode=@save_sql_mode;
DROP TABLE t1, t2; DROP TABLE t1, t2;
--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;
--echo End of 5.0 tests --echo End of 5.0 tests
# Bug #21174: Index degrades sort performance and # Bug #21174: Index degrades sort performance and
# optimizer does not honor IGNORE INDEX. # optimizer does not honor IGNORE INDEX.
......
...@@ -514,7 +514,7 @@ public: ...@@ -514,7 +514,7 @@ public:
bool send_row_on_empty_set() bool send_row_on_empty_set()
{ {
return (do_send_rows && tmp_table_param.sum_func_count != 0 && 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 change_result(select_result *result);
bool is_top_level_join() const bool is_top_level_join() const
......
...@@ -7,6 +7,11 @@ ...@@ -7,6 +7,11 @@
/* @(#) $Id$ */ /* @(#) $Id$ */
/* Need to be included "early" to control other headers */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h> #include <stdio.h>
#include "zutil.h" #include "zutil.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment