mirror of
https://github.com/MariaDB/server.git
synced 2025-01-31 02:51:44 +01:00
Merge mysql.com:/home/hf/work/29717/my50-29717
into mysql.com:/home/hf/work/29717/my51-29717
This commit is contained in:
commit
d72a6b1227
6 changed files with 105 additions and 1 deletions
|
@ -824,6 +824,23 @@ a
|
||||||
2
|
2
|
||||||
1
|
1
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
CREATE TABLE t1 (
|
||||||
|
f1 int(10) unsigned NOT NULL auto_increment primary key,
|
||||||
|
f2 varchar(100) NOT NULL default ''
|
||||||
|
);
|
||||||
|
CREATE TABLE t2 (
|
||||||
|
f1 varchar(10) NOT NULL default '',
|
||||||
|
f2 char(3) NOT NULL default '',
|
||||||
|
PRIMARY KEY (`f1`),
|
||||||
|
KEY `k1` (`f2`,`f1`)
|
||||||
|
);
|
||||||
|
INSERT INTO t1 values(NULL, '');
|
||||||
|
INSERT INTO `t2` VALUES ('486878','WDT'),('486910','WDT');
|
||||||
|
SELECT SQL_BUFFER_RESULT avg(t2.f1) FROM t1, t2 where t2.f2 = 'SIR' GROUP BY t1.f1;
|
||||||
|
avg(t2.f1)
|
||||||
|
SELECT avg(t2.f1) FROM t1, t2 where t2.f2 = 'SIR' GROUP BY t1.f1;
|
||||||
|
avg(t2.f1)
|
||||||
|
DROP TABLE t1, t2;
|
||||||
create table t1 (c1 char(3), c2 char(3));
|
create table t1 (c1 char(3), c2 char(3));
|
||||||
create table t2 (c3 char(3), c4 char(3));
|
create table t2 (c3 char(3), c4 char(3));
|
||||||
insert into t1 values ('aaa', 'bb1'), ('aaa', 'bb2');
|
insert into t1 values ('aaa', 'bb1'), ('aaa', 'bb2');
|
||||||
|
|
|
@ -699,6 +699,32 @@ Handler_read_prev 0
|
||||||
Handler_read_rnd 0
|
Handler_read_rnd 0
|
||||||
Handler_read_rnd_next 1
|
Handler_read_rnd_next 1
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
CREATE TABLE t1 (
|
||||||
|
f1 int(10) unsigned NOT NULL auto_increment PRIMARY KEY,
|
||||||
|
f2 varchar(100) NOT NULL default ''
|
||||||
|
);
|
||||||
|
CREATE TABLE t2 (
|
||||||
|
f1 varchar(10) NOT NULL default '',
|
||||||
|
f2 char(3) NOT NULL default '',
|
||||||
|
PRIMARY KEY (`f1`),
|
||||||
|
KEY `k1` (`f2`, `f1`)
|
||||||
|
);
|
||||||
|
INSERT INTO t1 values(NULL, '');
|
||||||
|
INSERT INTO `t2` VALUES ('486878','WDT'),('486910','WDT');
|
||||||
|
SELECT COUNT(*) FROM t1;
|
||||||
|
COUNT(*)
|
||||||
|
1
|
||||||
|
SELECT min(t2.f1) FROM t1, t2 where t2.f2 = 'SIR' GROUP BY t1.f1;
|
||||||
|
min(t2.f1)
|
||||||
|
INSERT INTO t1 (f2)
|
||||||
|
SELECT min(t2.f1) FROM t1, t2 where t2.f2 = 'SIR' GROUP BY t1.f1;
|
||||||
|
SELECT COUNT(*) FROM t1;
|
||||||
|
COUNT(*)
|
||||||
|
1
|
||||||
|
SELECT * FROM t1;
|
||||||
|
f1 f2
|
||||||
|
1
|
||||||
|
DROP TABLE t1, t2;
|
||||||
CREATE TABLE t1 (x int, y int);
|
CREATE TABLE t1 (x int, y int);
|
||||||
CREATE TABLE t2 (z int, y int);
|
CREATE TABLE t2 (z int, y int);
|
||||||
CREATE TABLE t3 (a int, b int);
|
CREATE TABLE t3 (a int, b int);
|
||||||
|
|
|
@ -633,6 +633,28 @@ SELECT a FROM t1 ORDER BY "a" DESC;
|
||||||
SELECT a FROM t1 ORDER BY `a` DESC;
|
SELECT a FROM t1 ORDER BY `a` DESC;
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
|
||||||
|
#
|
||||||
|
# Bug #29717 INSERT INTO SELECT inserts values even if SELECT statement itself
|
||||||
|
# returns empty
|
||||||
|
#
|
||||||
|
CREATE TABLE t1 (
|
||||||
|
f1 int(10) unsigned NOT NULL auto_increment primary key,
|
||||||
|
f2 varchar(100) NOT NULL default ''
|
||||||
|
);
|
||||||
|
CREATE TABLE t2 (
|
||||||
|
f1 varchar(10) NOT NULL default '',
|
||||||
|
f2 char(3) NOT NULL default '',
|
||||||
|
PRIMARY KEY (`f1`),
|
||||||
|
KEY `k1` (`f2`,`f1`)
|
||||||
|
);
|
||||||
|
|
||||||
|
INSERT INTO t1 values(NULL, '');
|
||||||
|
INSERT INTO `t2` VALUES ('486878','WDT'),('486910','WDT');
|
||||||
|
SELECT SQL_BUFFER_RESULT avg(t2.f1) FROM t1, t2 where t2.f2 = 'SIR' GROUP BY t1.f1;
|
||||||
|
SELECT avg(t2.f1) FROM t1, t2 where t2.f2 = 'SIR' GROUP BY t1.f1;
|
||||||
|
DROP TABLE t1, t2;
|
||||||
|
|
||||||
|
|
||||||
# End of 4.1 tests
|
# End of 4.1 tests
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
@ -239,6 +239,34 @@ show status like 'Handler_read%';
|
||||||
|
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
|
||||||
|
#
|
||||||
|
# Bug #29717 INSERT INTO SELECT inserts values even if SELECT statement itself returns empty
|
||||||
|
#
|
||||||
|
|
||||||
|
CREATE TABLE t1 (
|
||||||
|
f1 int(10) unsigned NOT NULL auto_increment PRIMARY KEY,
|
||||||
|
f2 varchar(100) NOT NULL default ''
|
||||||
|
);
|
||||||
|
CREATE TABLE t2 (
|
||||||
|
f1 varchar(10) NOT NULL default '',
|
||||||
|
f2 char(3) NOT NULL default '',
|
||||||
|
PRIMARY KEY (`f1`),
|
||||||
|
KEY `k1` (`f2`, `f1`)
|
||||||
|
);
|
||||||
|
|
||||||
|
INSERT INTO t1 values(NULL, '');
|
||||||
|
INSERT INTO `t2` VALUES ('486878','WDT'),('486910','WDT');
|
||||||
|
SELECT COUNT(*) FROM t1;
|
||||||
|
|
||||||
|
SELECT min(t2.f1) FROM t1, t2 where t2.f2 = 'SIR' GROUP BY t1.f1;
|
||||||
|
|
||||||
|
INSERT INTO t1 (f2)
|
||||||
|
SELECT min(t2.f1) FROM t1, t2 where t2.f2 = 'SIR' GROUP BY t1.f1;
|
||||||
|
|
||||||
|
SELECT COUNT(*) FROM t1;
|
||||||
|
SELECT * FROM t1;
|
||||||
|
DROP TABLE t1, t2;
|
||||||
|
|
||||||
# End of 4.1 tests
|
# End of 4.1 tests
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
@ -1134,6 +1134,7 @@ JOIN::optimize()
|
||||||
order=0; // The output has only one row
|
order=0; // The output has only one row
|
||||||
simple_order=1;
|
simple_order=1;
|
||||||
select_distinct= 0; // No need in distinct for 1 row
|
select_distinct= 0; // No need in distinct for 1 row
|
||||||
|
group_optimized_away= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
calc_group_buffer(this, group_list);
|
calc_group_buffer(this, group_list);
|
||||||
|
@ -11742,7 +11743,8 @@ end_send_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
|
||||||
if (!join->first_record || end_of_records ||
|
if (!join->first_record || end_of_records ||
|
||||||
(idx=test_if_group_changed(join->group_fields)) >= 0)
|
(idx=test_if_group_changed(join->group_fields)) >= 0)
|
||||||
{
|
{
|
||||||
if (join->first_record || (end_of_records && !join->group))
|
if (join->first_record ||
|
||||||
|
(end_of_records && !join->group && !join->group_optimized_away))
|
||||||
{
|
{
|
||||||
if (join->procedure)
|
if (join->procedure)
|
||||||
join->procedure->end_group();
|
join->procedure->end_group();
|
||||||
|
|
|
@ -321,6 +321,14 @@ public:
|
||||||
ROLLUP rollup; // Used with rollup
|
ROLLUP rollup; // Used with rollup
|
||||||
|
|
||||||
bool select_distinct; // Set if SELECT DISTINCT
|
bool select_distinct; // Set if SELECT DISTINCT
|
||||||
|
/*
|
||||||
|
If we have the GROUP BY statement in the query,
|
||||||
|
but the group_list was emptied by optimizer, this
|
||||||
|
flag is TRUE.
|
||||||
|
It happens when fields in the GROUP BY are from
|
||||||
|
constant table
|
||||||
|
*/
|
||||||
|
bool group_optimized_away;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
simple_xxxxx is set if ORDER/GROUP BY doesn't include any references
|
simple_xxxxx is set if ORDER/GROUP BY doesn't include any references
|
||||||
|
@ -429,6 +437,7 @@ public:
|
||||||
zero_result_cause= 0;
|
zero_result_cause= 0;
|
||||||
optimized= 0;
|
optimized= 0;
|
||||||
cond_equal= 0;
|
cond_equal= 0;
|
||||||
|
group_optimized_away= 0;
|
||||||
|
|
||||||
all_fields= fields_arg;
|
all_fields= fields_arg;
|
||||||
fields_list= fields_arg;
|
fields_list= fields_arg;
|
||||||
|
|
Loading…
Add table
Reference in a new issue