Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
9d09389c
Commit
9d09389c
authored
Aug 01, 2007
by
tsmith@ramayana.hindu.god
Browse files
Options
Browse Files
Download
Plain Diff
Merge tsmith@bk-internal.mysql.com:/home/bk/mysql-4.1-opt
into ramayana.hindu.god:/home/tsmith/m/bk/maint/41
parents
c2399f04
288ab1aa
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
106 additions
and
1 deletion
+106
-1
mysql-test/r/group_by.result
mysql-test/r/group_by.result
+17
-0
mysql-test/r/insert_select.result
mysql-test/r/insert_select.result
+26
-0
mysql-test/t/group_by.test
mysql-test/t/group_by.test
+23
-0
mysql-test/t/insert_select.test
mysql-test/t/insert_select.test
+28
-0
sql/sql_select.cc
sql/sql_select.cc
+3
-1
sql/sql_select.h
sql/sql_select.h
+9
-0
No files found.
mysql-test/r/group_by.result
View file @
9d09389c
...
...
@@ -818,3 +818,20 @@ a
2
1
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;
mysql-test/r/insert_select.result
View file @
9d09389c
...
...
@@ -690,3 +690,29 @@ CREATE TABLE t1 (a int PRIMARY KEY);
INSERT INTO t1 values (1), (2);
INSERT INTO t1 SELECT a + 2 FROM t1 LIMIT 1;
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;
mysql-test/t/group_by.test
View file @
9d09389c
...
...
@@ -633,4 +633,27 @@ 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
;
#
# 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
mysql-test/t/insert_select.test
View file @
9d09389c
...
...
@@ -239,4 +239,32 @@ INSERT INTO t1 SELECT a + 2 FROM t1 LIMIT 1;
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
sql/sql_select.cc
View file @
9d09389c
...
...
@@ -777,6 +777,7 @@ JOIN::optimize()
order
=
0
;
// The output has only one row
simple_order
=
1
;
select_distinct
=
0
;
// No need in distinct for 1 row
group_optimized_away
=
1
;
}
calc_group_buffer
(
this
,
group_list
);
...
...
@@ -6896,7 +6897,8 @@ end_send_group(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)),
if
(
!
join
->
first_record
||
end_of_records
||
(
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
)
join
->
procedure
->
end_group
();
...
...
sql/sql_select.h
View file @
9d09389c
...
...
@@ -180,6 +180,14 @@ class JOIN :public Sql_alloc
ROLLUP
rollup
;
// Used with rollup
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
...
...
@@ -276,6 +284,7 @@ class JOIN :public Sql_alloc
ref_pointer_array_size
=
0
;
zero_result_cause
=
0
;
optimized
=
0
;
group_optimized_away
=
0
;
fields_list
=
fields_arg
;
bzero
((
char
*
)
&
keyuse
,
sizeof
(
keyuse
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment