Skip to content

Commit 617ab59

Browse files
committed
WL#2489: Better ONLY_FULL_GROUP_BY mode
Complete patch. See sql/aggregate_check.h or the WL for design. Moreover, this contains changes (not written in the WL page): 1) Item_ident::alias_name_used used to convey the two pieces of information below; it's removed and replaced with: * m_alias_of_expr tells if this is a reference, through an alias, to a SELECTed expression which has "AS alias" * to know if this is a reference to a column of an aliased table, we consult table->alias_name_used 2) only_full_group_by checks are now done after simplify_joins(); the latter function may convert outer joins to inner joins, and inner joins allow more functional dependency detection; so with this change we can allow more queries. 3) moved JOIN::outer_join to SELECT_LEX::outer_join; indeed, this is constant through executions, and we now need it for FD detection so computing this variable at optimization time was too late. 4) in trunk we eliminate DISTINCT if all group expressions are in the select list, but we do it at optimization stage; in this WL we do it at preparation stage. This makes only_full_group_by distinct-related checks to allow more queries, like SELECT distinct a, min(b) FROM t1 group by a order by count(*)-count(*); (which otherwise would yield the new error ER_AGGREGATE_IN_ORDER_NOT_SELECT): and it allows the optimizer in general to choose better plans (see the change in group_min_max.result). 5) a new class Bool3 for holding true/false/unknown values.
1 parent d777879 commit 617ab59

File tree

214 files changed

+8658
-1412
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

214 files changed

+8658
-1412
lines changed

mysql-test/extra/rpl_tests/rpl_insert_ignore_gtid_on.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
if (!`SELECT COUNT(*) = 0 OR VARIABLE_VALUE != 'ON' FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME = 'GTID_MODE'`)
1+
if (!`SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME = 'GTID_MODE' AND VARIABLE_VALUE = 'ON'`)
22
{
33
--let $i=1
44
--let $j=1

mysql-test/extra/rpl_tests/rpl_log.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ select count(*) from t1;
3434
source include/show_binlog_events.inc;
3535

3636
let $binlog_limit= 1;
37-
if (!`SELECT COUNT(*) = 0 OR VARIABLE_VALUE != 'ON' FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME = 'GTID_MODE'`)
37+
if (`SELECT COUNT(*) > 0 FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME = 'GTID_MODE' AND VARIABLE_VALUE = 'ON'`)
3838
{
3939
# if GTID_MODE=ON, there is the extra event entry the binary log: Gtid_log_event
4040
--let $binlog_limit= 2,1
@@ -43,7 +43,7 @@ if (!`SELECT COUNT(*) = 0 OR VARIABLE_VALUE != 'ON' FROM INFORMATION_SCHEMA.GLOB
4343
source include/show_binlog_events.inc;
4444
--let $from_event= 1
4545
--let $number_of_events= 4
46-
if (!`SELECT COUNT(*) = 0 OR VARIABLE_VALUE != 'ON' FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME = 'GTID_MODE'`)
46+
if (`SELECT COUNT(*) > 0 FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME = 'GTID_MODE' AND VARIABLE_VALUE = 'ON'`)
4747
{
4848
# if GTID_MODE=ON, there is the extra event entry the binary log: Gtid_log_event
4949
--let $from_event= `SELECT $from_event * 2 + 1`

mysql-test/include/bug13581713.inc

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
2+
3+
--source include/turn_off_only_full_group_by.inc
4+
5+
insert into t1 values(100,1,2),(200,1,1),(300,2,1),(400,2,2);
6+
analyze table t1;
7+
8+
eval select distinct b from $source order by c;
9+
eval select distinct min(b) from $source group by a order by min(c);
10+
# just to see that if source is a view, it is merged
11+
--replace_column 9 #
12+
eval explain select distinct min(b) from $source group by a order by min(c);
13+
14+
--echo Insert rows in different order:
15+
delete from t1;
16+
insert into t1 values(200,1,1),(100,1,2),(400,2,2),(300,2,1);
17+
analyze table t1;
18+
19+
--echo And get a different order. Query is executed like this:
20+
--echo - First, DISTINCT, using a tmp MEMORY table with a unique
21+
--echo index, thus if two rows have the same 'b' but a different 'c',
22+
--echo the second row is rejected, so the first value of 'c' wins
23+
--echo (=> randomness of 'c')
24+
--echo - Second, ORDER BY on the random 'c'.
25+
eval select distinct b from $source order by c;
26+
27+
--echo Random order too (same reason):
28+
eval select distinct min(b) from $source group by a order by min(c);
29+
30+
--source include/restore_sql_mode_after_turn_off_only_full_group_by.inc
31+
32+
--echo This query gives random order:
33+
--error ER_FIELD_IN_ORDER_NOT_SELECT
34+
eval select distinct b from $source order by c;
35+
--echo and this one too:
36+
--error ER_FIELD_IN_ORDER_NOT_SELECT
37+
eval select distinct b from $source order by b-1,b+1,c;
38+
39+
--echo and this one too:
40+
--error ER_AGGREGATE_IN_ORDER_NOT_SELECT
41+
eval select distinct min(b) from $source group by a order by min(c);
42+
43+
--echo Not random (though Standard bans aggregates from ORDER BY):
44+
eval select distinct min(b) from $source group by a order by min(b);
45+
--error ER_AGGREGATE_IN_ORDER_NOT_SELECT
46+
eval select distinct min(b) from $source group by a order by -min(b);
47+
--echo All group exprs are in select list => DISTINCT is removed => no error
48+
eval select distinct a, min(b) from $source group by a order by max(b-2)-min(c*5);
49+
50+
--echo This one is standard:
51+
eval select distinct min(b) as z from $source group by a order by z;
52+
53+
--echo Other queries:
54+
eval select distinct b from $source where b<0 order by rand();
55+
eval select distinct b from $source order by 45.0+3;
56+
eval select (select distinct b from $source_no_alias as S2 where b=7 order by S3.a) from $source_no_alias as S3;
57+
eval select distinct b from $source order by abs(b);
58+
eval select distinct b as z from $source order by abs(z);
59+
60+
--error ER_FIELD_IN_ORDER_NOT_SELECT
61+
eval select distinct b from $source order by abs(b+a);
62+
63+
eval select distinct abs(b) as z from $source order by z;
64+
eval select distinct abs(b) as z from $source order by abs(b);
65+
eval select distinct abs(b) from $source order by abs(b);
66+
67+
--echo Not ok: ABS(b)+1 is neither a SELECTed expression nor an alias
68+
--echo to one, and mentions a column of FROM tables.
69+
--error ER_FIELD_IN_ORDER_NOT_SELECT
70+
eval select distinct abs(b) as z from $source order by abs(b)+1;
71+
eval select distinct abs(b) as z from $source order by z+1;
72+
--error ER_FIELD_IN_ORDER_NOT_SELECT
73+
eval select distinct abs(b) from $source order by abs(b)+1;
74+
--error ER_FIELD_IN_ORDER_NOT_SELECT
75+
eval select distinct abs(b) as z from $source order by floor(10*b);
76+
--error ER_FIELD_IN_ORDER_NOT_SELECT
77+
eval select distinct abs(b) from $source order by floor(10*b);
78+
--echo Two offending columns; error message needs to report only one
79+
--error ER_FIELD_IN_ORDER_NOT_SELECT
80+
eval select distinct abs(b) from $source order by floor(10*b),floor(10*a);
81+
--error ER_FIELD_IN_ORDER_NOT_SELECT
82+
eval select distinct abs(b) from $source_no_alias as S2 order by
83+
(select floor(10*S2.b) from $source_no_alias as S3 limit 1);
84+
--echo Ok as S2.b in SELECT list
85+
eval select distinct abs(b),b from $source_no_alias as S2 order by
86+
(select floor(10*S2.b) from $source_no_alias as S3 limit 1);
87+
--echo Ok as subq does not use columns of FROM clause of ordered Q.
88+
eval select distinct abs(b) from $source_no_alias as S2 order by
89+
(select floor(10*S3.b) from $source_no_alias as S3 limit 1);
90+
--echo Subq as alias => ok
91+
eval select distinct abs(b),
92+
(select floor(10*S3.b) from $source_no_alias as S3 limit 1) as subq
93+
from $source_no_alias as S2 order by subq;
94+
--echo Bad field in left or right argument of ALL/ANY(subq):
95+
--error ER_FIELD_IN_ORDER_NOT_SELECT
96+
eval select distinct abs(b) from $source_no_alias as S2 order by
97+
floor(10*S2.b) IN (select floor(10*S3.b) from $source_no_alias as S3);
98+
--error ER_FIELD_IN_ORDER_NOT_SELECT
99+
eval select distinct abs(b) from $source_no_alias as S2 order by
100+
floor(10*S2.b) > ALL(select floor(10*S3.b) from $source_no_alias as S3);
101+
--error ER_FIELD_IN_ORDER_NOT_SELECT
102+
eval select distinct abs(b) from $source_no_alias as S2 order by
103+
floor(10*10) IN (select floor(10*S2.b) from $source_no_alias as S3);
104+
--error ER_FIELD_IN_ORDER_NOT_SELECT
105+
eval select distinct abs(b) from $source_no_alias as S2 order by
106+
floor(10*10) > ALL(select floor(10*S2.b) from $source_no_alias as S3);
107+
108+
--echo Aggregates:
109+
--error ER_AGGREGATE_IN_ORDER_NOT_SELECT
110+
SELECT distinct 1 FROM t1 group by a order by count(*);
111+
--error ER_AGGREGATE_IN_ORDER_NOT_SELECT
112+
SELECT distinct 1 FROM t1 group by a order by count(*)-count(*);
113+
--echo Test ANY_VALUE
114+
SELECT distinct 1 FROM t1 group by a order by any_value(count(*)-count(b));
115+
SELECT distinct 1 FROM t1 group by a order by any_value(count(*))-any_value(count(b));
116+
--echo All group exprs are in select list => DISTINCT is removed => no error
117+
--sorted_result
118+
SELECT distinct a, min(b) FROM t1 group by a order by count(*)-count(*);
119+
--error ER_AGGREGATE_IN_ORDER_NOT_SELECT
120+
SELECT distinct 1 FROM t1 group by a order by count(*)-count(b);
121+
--echo aggregation in outer Q => constant in inner Q
122+
select * from t1 as t2 where t2.a in
123+
(SELECT distinct 1 FROM t1 group by a order by count(t2.a)-max(t2.a));
124+
--echo ORDER BY expressions are in SELECT list => ok
125+
SELECT distinct 1, count(*)-count(b) FROM t1 group by a order by count(*)-count(b);
126+
--echo Without GROUP BY, aggregates yield a single row, no random order
127+
SELECT distinct sum(a) FROM t1 order by count(*)-count(*);
128+
SELECT distinct sum(a) FROM t1 order by count(*)-count(b);
129+
130+
--echo Verify that DISTINCT is optimized away even if the aggregate
131+
--echo function is hidden in a subquery
132+
EXPLAIN SELECT DISTINCT MAX(b) FROM t1;
133+
EXPLAIN SELECT DISTINCT (SELECT MAX(t1.b) FROM t1 AS t2 LIMIT 1) FROM t1;
134+
--echo but if the subquery is the aggregation query, DISTINCT must stay:
135+
EXPLAIN SELECT DISTINCT (SELECT MAX(t1.b+0*t2.a) FROM t1 AS t2 LIMIT 1) FROM t1;
136+
--echo QA's query is properly rejected:
137+
--error ER_FIELD_IN_ORDER_NOT_SELECT
138+
eval SELECT DISTINCT GP1.a AS g1 FROM $source_no_alias AS GP1
139+
WHERE GP1.a >= 0
140+
ORDER BY GP1.b LIMIT 8;
141+
142+
--echo result order does change depending on chosen plan.
143+
--sorted_result
144+
eval SELECT DISTINCT GP1.a AS g1 FROM $source_no_alias AS GP1
145+
WHERE GP1.a >= 0
146+
ORDER BY 2+ANY_VALUE(GP1.b) LIMIT 8;
147+
148+
truncate table t1;

mysql-test/include/common-tests.inc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,7 +1416,9 @@ drop table tmp;
14161416
SET BIG_TABLES=1;
14171417
select distinct concat(fld3," ",fld3) as namn from t2,t3 where t2.fld1=t3.t2nr order by namn limit 10;
14181418
SET BIG_TABLES=0;
1419+
--source include/turn_off_only_full_group_by.inc
14191420
select distinct concat(fld3," ",fld3) from t2,t3 where t2.fld1=t3.t2nr order by fld3 limit 10;
1421+
--source include/restore_sql_mode_after_turn_off_only_full_group_by.inc
14201422
select distinct fld5 from t2 limit 10;
14211423

14221424
#
@@ -1644,7 +1646,10 @@ select t2.fld3,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 grou
16441646
# Group with extra not group fields.
16451647
#
16461648

1649+
--source include/turn_off_only_full_group_by.inc
16471650
select companynr|0,companyname from t4 group by 1;
1651+
--source include/restore_sql_mode_after_turn_off_only_full_group_by.inc
1652+
16481653
select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by t2.companynr order by companyname;
16491654
select t2.fld1,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name;
16501655

@@ -1748,7 +1753,9 @@ select t1.period as "Nuvarande period" from t1 as t1 limit 1;
17481753
select period as ok_period from t1 limit 1;
17491754
select period as ok_period from t1 group by ok_period limit 1;
17501755
select 1+1 as summa from t1 group by summa limit 1;
1756+
--source include/turn_off_only_full_group_by.inc
17511757
select period as "Nuvarande period" from t1 group by "Nuvarande period" limit 1;
1758+
--source include/restore_sql_mode_after_turn_off_only_full_group_by.inc
17521759

17531760
#
17541761
# Some simple show commands
@@ -1827,7 +1834,11 @@ INSERT INTO t1 VALUES (3359360,0,0,'Mustermann Musterfrau',29674907,'2000-05-20'
18271834
INSERT INTO t1 VALUES (3359361,406,3359361,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag storniert','','(7001-84):Storno, Kd. möchte nicht mehr','privat',NULL,0,'+','','P',1909150,'MobilComSuper92000D1(Akquise)',NULL,NULL,'MS9ND1',325,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','','');
18281835
INSERT INTO t1 VALUES (3359362,406,3359362,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1509984,2145874,'+','','P',1909154,'MobilComSuper92000D1(Akquise)',NULL,NULL,'MS9ND1',327,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','','');
18291836

1837+
--source include/turn_off_only_full_group_by.inc
1838+
18301839
--disable_ps_protocol
18311840
SELECT ELT(FIELD(kundentyp,'PP','PPA','PG','PGA','FK','FKA','FP','FPA','K','KA','V','VA',''), 'Privat (Private Nutzung)','Privat (Private Nutzung) Sitz im Ausland','Privat (geschaeftliche Nutzung)','Privat (geschaeftliche Nutzung) Sitz im Ausland','Firma (Kapitalgesellschaft)','Firma (Kapitalgesellschaft) Sitz im Ausland','Firma (Personengesellschaft)','Firma (Personengesellschaft) Sitz im Ausland','oeff. rechtl. Koerperschaft','oeff. rechtl. Koerperschaft Sitz im Ausland','Eingetragener Verein','Eingetragener Verein Sitz im Ausland','Typ unbekannt') AS Kundentyp ,kategorie FROM t1 WHERE hdl_nr < 2000000 AND kategorie IN ('Prepaid','Mobilfunk') AND st_klasse = 'Workflow' GROUP BY kundentyp ORDER BY kategorie;
18321841
--enable_ps_protocol
1842+
1843+
--source include/restore_sql_mode_after_turn_off_only_full_group_by.inc
18331844
drop table t1;

mysql-test/include/ctype_utf8mb4.inc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1581,19 +1581,25 @@ select (_utf8mb4 X'616263FF');
15811581
#
15821582
eval CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL) ENGINE $engine;
15831583
INSERT INTO t1 VALUES (70000, 1092), (70001, 1085), (70002, 1065);
1584+
--source include/turn_off_only_full_group_by.inc
15841585
--sorted_result
15851586
SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b;
15861587
--sorted_result
15871588
SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1;
1589+
# We will make 'b' unique, so GROUP BY will be ok.
1590+
--source include/restore_sql_mode_after_turn_off_only_full_group_by.inc
15881591
ALTER TABLE t1 ADD UNIQUE (b);
15891592
--sorted_result
15901593
SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b;
1594+
# Not unique anymore:
1595+
--source include/turn_off_only_full_group_by.inc
15911596
DROP INDEX b ON t1;
15921597
--sorted_result
15931598
SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b;
15941599
ALTER TABLE t1 ADD INDEX (b);
15951600
--sorted_result
15961601
SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) from t1 GROUP BY b;
1602+
--source include/restore_sql_mode_after_turn_off_only_full_group_by.inc
15971603
DROP TABLE t1;
15981604

15991605
--echo #

mysql-test/include/explain_for_connection_rqg.inc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ create view view_aa as select * from aa;
245245
create view view_bb as select * from bb;
246246
create view view_cc as select * from cc;
247247

248+
# Lots of bad queries:
249+
--source include/turn_off_only_full_group_by.inc
250+
248251
let $query=SELECT DISTINCT alias2.col_time_key AS field1 , alias2.col_varchar_key AS field2 , alias2.col_varchar_key AS field3 , alias2.col_int_nokey AS field4 FROM ( c AS alias1 , ( view_a AS alias2 , c AS alias3 ) ) GROUP BY field1, field2, field3, field4 HAVING (field1 < 'w' OR field1 != 'ni') ORDER BY field3 ;
249252

250253
--source include/explain_for_connection.inc
@@ -299,7 +302,7 @@ let $query=SELECT CONCAT( table1.col_varchar_nokey , table1.col_varchar_key )
299302
--source include/explain_for_connection.inc
300303
let $query=SELECT CONCAT( table2.col_varchar_key , table1.col_varchar_key ) AS field1 , table2.pk AS field2 , table1.pk AS field3 FROM ( cc AS table1 STRAIGHT_JOIN ( ( ( SELECT SQL_SMALL_RESULT subquery1_t2.* FROM ( cc AS subquery1_t1 RIGHT OUTER JOIN bb AS subquery1_t2 ON (subquery1_t2.col_int_nokey = subquery1_t1.pk ) ) ) AS table2 INNER JOIN cc AS table3 ON (table3.pk = table2.pk ) ) ) ON (table3.col_int_key = table2.col_int_nokey ) ) WHERE ( EXISTS (SELECT subquery2_t1.col_int_nokey AS subquery2_field1 FROM ( c AS subquery2_t1 INNER JOIN ( c AS subquery2_t2 STRAIGHT_JOIN b AS subquery2_t3 ON (subquery2_t3.col_int_key = subquery2_t2.pk AND subquery2_t2.col_int_key NOT IN (SELECT child_subquery1_t1.col_int_nokey AS child_subquery1_field1 FROM ( cc AS child_subquery1_t1 LEFT JOIN c AS child_subquery1_t2 ON (child_subquery1_t2.col_int_nokey = child_subquery1_t1.col_int_key ) ) ) ) ) ON (subquery2_t3.col_varchar_key = subquery2_t2.col_varchar_key ) ) WHERE subquery2_t3.col_varchar_nokey <= table2.col_varchar_nokey AND subquery2_t3.pk <= table2.pk ) ) OR ( table3.col_varchar_nokey <= 'c' AND table2.col_varchar_key != table2.col_varchar_nokey ) ORDER BY table1.col_varchar_key /*+JavaDB:Postgres: NULLS FIRST*/ , table1 .pk DESC /*+JavaDB:Postgres: NULLS LAST */, field1 /*+JavaDB:Postgres: NULLS FIRST */, field2 /*+JavaDB:Postgres: NULLS FIRST */, field3 /*+JavaDB:Postgres: NULLS FIRST */ ;
301304
--source include/explain_for_connection.inc
302-
let $query=SELECT (SELECT MAX( DISTINCT sq1_alias1.col_int_key ) AS sq1_field1 FROM ( cc AS sq1_alias1 , bb AS sq1_alias2 ) WHERE sq1_alias2.pk <> alias1.pk AND sq1_alias2.pk <= alias1.col_int_key ) AS field1 , COUNT( alias1.col_varchar_key ) AS field2 FROM ( bb AS alias1 LEFT OUTER JOIN ( ( cc AS alias2 INNER JOIN cc AS alias3 ON (alias3.col_int_key = alias2.col_int_key ) ) ) ON (alias3.col_varchar_nokey = alias2.col_varchar_key ) ) WHERE ( EXISTS ( (SELECT sq2_alias1.col_varchar_nokey AS sq2_field1 FROM c AS sq2_alias1 WHERE ( sq2_alias1.col_varchar_nokey , sq2_alias1.col_varchar_nokey ) IN (SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1 , MAX( c_sq1_alias1.col_varchar_nokey ) AS c_sq1_field2 FROM cc AS c_sq1_alias1 ) GROUP BY sq2_field1 ) ) ) OR ( alias1.col_int_key > 51 AND alias1.col_int_key < ( 51 + 209 ) OR alias1.col_int_key > 51 AND alias1.col_int_key < ( 51 + 159 ) ) OR (SELECT SQL_SMALL_RESULT MIN( sq3_alias1.pk ) AS sq3_field1 FROM ( c AS sq3_alias1 RIGHT OUTER JOIN c AS sq3_alias2 ON (sq3_alias2.col_int_key = sq3_alias1.pk ) ) ) IS NOT NULL GROUP BY field1 HAVING field2 <> 5 ORDER BY alias1.col_time_key ASC , field2 , CONCAT( alias2.col_varchar_key, alias3.col_varchar_key );
305+
let $query=SELECT (SELECT MAX( DISTINCT sq1_alias1.col_int_key ) AS sq1_field1 FROM ( cc AS sq1_alias1 , bb AS sq1_alias2 ) WHERE sq1_alias2.pk <> alias1.pk AND sq1_alias2.pk <= alias1.col_int_key ) AS field1 , COUNT( alias1.col_varchar_key ) AS field2 FROM ( bb AS alias1 LEFT OUTER JOIN ( ( cc AS alias2 INNER JOIN cc AS alias3 ON (alias3.col_int_key = alias2.col_int_key ) ) ) ON (alias3.col_varchar_nokey = alias2.col_varchar_key ) ) WHERE ( EXISTS ( (SELECT sq2_alias1.col_varchar_nokey AS sq2_field1 FROM c AS sq2_alias1 WHERE ( sq2_alias1.col_varchar_nokey , sq2_alias1.col_varchar_nokey ) IN (SELECT c_sq1_alias1.col_varchar_key AS c_sq1_field1 , MAX( c_sq1_alias1.col_varchar_nokey ) AS c_sq1_field2 FROM cc AS c_sq1_alias1 ) GROUP BY sq2_field1 ) ) ) OR ( alias1.col_int_key > 51 AND alias1.col_int_key < ( 51 + 209 ) OR alias1.col_int_key > 51 AND alias1.col_int_key < ( 51 + 159 ) ) OR (SELECT SQL_SMALL_RESULT MIN( sq3_alias1.pk ) AS sq3_field1 FROM ( c AS sq3_alias1 RIGHT OUTER JOIN c AS sq3_alias2 ON (sq3_alias2.col_int_key = sq3_alias1.pk ) ) ) IS NOT NULL GROUP BY field1 HAVING field2 <> 5 ORDER BY alias1.col_time_key ASC , field2 , CONCAT( alias2.col_varchar_key, alias3.col_varchar_key );
303306
--source include/explain_for_connection.inc
304307
let $query=SELECT (SELECT 5 FROM dummy ) AS field1 FROM ( b AS table1 INNER JOIN ( ( ( SELECT subquery2_t1.* FROM ( cc AS subquery2_t1 INNER JOIN cc AS subquery2_t2 ON (subquery2_t2.col_varchar_key = subquery2_t1.col_varchar_key ) ) ) AS table2 LEFT JOIN cc AS table3 ON (table3.col_int_key = table2.pk ) ) ) ON (table3.col_varchar_key = table2.col_varchar_key ) ) WHERE ( EXISTS ( (SELECT subquery3_t2.col_varchar_nokey AS subquery3_field1 FROM ( d AS subquery3_t1 INNER JOIN bb AS subquery3_t2 ON (subquery3_t2.col_int_key = subquery3_t1.pk ) ) ) ) ) OR ( table1.col_varchar_key = 'w' AND table1.col_varchar_key = table3.col_varchar_key ) ORDER BY table1.col_varchar_key DESC /*+JavaDB:Postgres: NULLS LAST */ , field1 /*+JavaDB:Postgres: NULLS FIRST */ LIMIT 10 OFFSET 6;
305308
--source include/explain_for_connection.inc
@@ -331,6 +334,7 @@ let $query=SELECT table2.pk AS field1 FROM ( ( SELECT subquery1_t1.* FROM (
331334
--source include/explain_for_connection.inc
332335
let $query=SELECT CONCAT( table2.col_varchar_key , table2.col_varchar_nokey ) AS field1 FROM ( ( SELECT subquery1_t1.* FROM ( c AS subquery1_t1 INNER JOIN bb AS subquery1_t2 ON (subquery1_t2.col_int_key = subquery1_t1.pk OR subquery1_t1.col_int_nokey >= ALL (SELECT 3 FROM dummy UNION SELECT 4 FROM dummy ) ) ) WHERE NOT EXISTS (SELECT SQL_SMALL_RESULT child_subquery2_t1.col_int_key AS child_subquery1_field1 FROM ( a AS child_subquery2_t1 STRAIGHT_JOIN ( ( cc AS child_subquery2_t2 INNER JOIN c AS child_subquery2_t3 ON (child_subquery2_t3.col_varchar_key = child_subquery2_t2.col_varchar_nokey ) ) ) ON (child_subquery2_t3.col_int_nokey = child_subquery2_t2.pk ) ) WHERE child_subquery2_t1.pk <= subquery1_t2.col_int_key ) ) AS table1 INNER JOIN ( SELECT subquery2_t1.* FROM c AS subquery2_t1 ) AS table2 ON (table2.pk = table1.pk ) ) WHERE ( (SELECT SQL_SMALL_RESULT SUM( DISTINCT subquery3_t1.col_int_key ) AS subquery3_field1 FROM ( bb AS subquery3_t1 INNER JOIN cc AS subquery3_t2 ON (subquery3_t2.col_varchar_key = subquery3_t1.col_varchar_nokey ) ) ) IS NULL ) AND ( table1.col_varchar_key IN ('g', 'z', 'w', 'v', 't') OR table1.pk > 39 AND table1.pk < ( 39 + 233 ) ) OR table1.col_varchar_key IS NULL ORDER BY table1.col_int_key ASC /*+JavaDB:Postgres: NULLS FIRST */ , field1 /*+JavaDB:Postgres: NULLS FIRST */ LIMIT 100;
333336
--source include/explain_for_connection.inc
337+
334338
DROP TABLE a;
335339
DROP TABLE aa;
336340
DROP TABLE b;
@@ -348,4 +352,4 @@ DROP VIEW view_bb;
348352
DROP VIEW view_c;
349353
DROP VIEW view_cc;
350354
DROP VIEW view_d;
351-
355+
--source include/restore_sql_mode_after_turn_off_only_full_group_by.inc

0 commit comments

Comments
 (0)