Skip to content

Commit b534a7b

Browse files
committed
Merge branch '10.3' into bb-10.3-fix_len_dec
2 parents 083279f + 956b296 commit b534a7b

File tree

5 files changed

+207
-0
lines changed

5 files changed

+207
-0
lines changed

mysql-test/main/derived_view.result

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2977,5 +2977,45 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
29772977
Warnings:
29782978
Note 1003 /* select#1 */ select straight_join `test`.`t1`.`c1` AS `c1` from `test`.`t1` where <in_optimizer>(`test`.`t1`.`c1`,<exists>(/* select#3 */ select `test`.`t2`.`c2` from `test`.`t2` where <cache>(`test`.`t1`.`c1`) = `test`.`t2`.`c2`))
29792979
DROP TABLE t1, t2;
2980+
#
2981+
# Bug mdev-16420: materialized view that renames columns
2982+
# in inner part of outer join
2983+
#
2984+
CREATE TABLE t1 (id int, PRIMARY KEY (id));
2985+
INSERT INTO t1 VALUES (2), (3), (7), (1);
2986+
CREATE VIEW v1 AS SELECT * FROM t1;
2987+
CREATE VIEW v2 AS SELECT v1.id AS order_pk FROM v1 GROUP BY v1.id;
2988+
CREATE VIEW v3 AS
2989+
SELECT t.id AS order_pk FROM (SELECT * FROM t1) AS t GROUP BY t.id;
2990+
SELECT * FROM t1 LEFT JOIN v2 ON t1.id=v2.order_pk;
2991+
id order_pk
2992+
1 1
2993+
2 2
2994+
3 3
2995+
7 7
2996+
EXPLAIN EXTENDED
2997+
SELECT * FROM t1 LEFT JOIN v2 ON t1.id=v2.order_pk;
2998+
id select_type table type possible_keys key key_len ref rows filtered Extra
2999+
1 PRIMARY t1 index NULL PRIMARY 4 NULL 4 100.00 Using index
3000+
1 PRIMARY <derived2> ref key0 key0 5 test.t1.id 2 100.00
3001+
2 DERIVED t1 index PRIMARY PRIMARY 4 NULL 4 100.00 Using index; Using filesort
3002+
Warnings:
3003+
Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`v2`.`order_pk` AS `order_pk` from `test`.`t1` left join `test`.`v2` on(`v2`.`order_pk` = `test`.`t1`.`id`) where 1
3004+
SELECT * FROM t1 LEFT JOIN v3 ON t1.id=v3.order_pk;
3005+
id order_pk
3006+
1 1
3007+
2 2
3008+
3 3
3009+
7 7
3010+
EXPLAIN EXTENDED
3011+
SELECT * FROM t1 LEFT JOIN v3 ON t1.id=v3.order_pk;
3012+
id select_type table type possible_keys key key_len ref rows filtered Extra
3013+
1 PRIMARY t1 index NULL PRIMARY 4 NULL 4 100.00 Using index
3014+
1 PRIMARY <derived2> ref key0 key0 5 test.t1.id 2 100.00
3015+
2 DERIVED t1 index PRIMARY PRIMARY 4 NULL 4 100.00 Using index; Using filesort
3016+
Warnings:
3017+
Note 1003 /* select#1 */ select `test`.`t1`.`id` AS `id`,`v3`.`order_pk` AS `order_pk` from `test`.`t1` left join `test`.`v3` on(`v3`.`order_pk` = `test`.`t1`.`id`) where 1
3018+
DROP VIEW v1,v2,v3;
3019+
DROP TABLE t1;
29803020
set optimizer_switch=@exit_optimizer_switch;
29813021
set join_cache_level=@exit_join_cache_level;

mysql-test/main/derived_view.test

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,6 +1949,30 @@ eval EXPLAIN EXTENDED $q;
19491949

19501950
DROP TABLE t1, t2;
19511951

1952+
--echo #
1953+
--echo # Bug mdev-16420: materialized view that renames columns
1954+
--echo # in inner part of outer join
1955+
--echo #
1956+
1957+
CREATE TABLE t1 (id int, PRIMARY KEY (id));
1958+
INSERT INTO t1 VALUES (2), (3), (7), (1);
1959+
1960+
CREATE VIEW v1 AS SELECT * FROM t1;
1961+
CREATE VIEW v2 AS SELECT v1.id AS order_pk FROM v1 GROUP BY v1.id;
1962+
CREATE VIEW v3 AS
1963+
SELECT t.id AS order_pk FROM (SELECT * FROM t1) AS t GROUP BY t.id;
1964+
1965+
SELECT * FROM t1 LEFT JOIN v2 ON t1.id=v2.order_pk;
1966+
EXPLAIN EXTENDED
1967+
SELECT * FROM t1 LEFT JOIN v2 ON t1.id=v2.order_pk;
1968+
1969+
SELECT * FROM t1 LEFT JOIN v3 ON t1.id=v3.order_pk;
1970+
EXPLAIN EXTENDED
1971+
SELECT * FROM t1 LEFT JOIN v3 ON t1.id=v3.order_pk;
1972+
1973+
DROP VIEW v1,v2,v3;
1974+
DROP TABLE t1;
1975+
19521976
# The following command must be the last one the file
19531977
set optimizer_switch=@exit_optimizer_switch;
19541978
set join_cache_level=@exit_join_cache_level;

sql/sql_select.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16814,7 +16814,10 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
1681416814
if (result && modify_item)
1681516815
field->result_field= result;
1681616816
if (orig_item)
16817+
{
1681716818
item->maybe_null= save_maybe_null;
16819+
result->field_name= orig_item->name;
16820+
}
1681816821
}
1681916822
else if (table_cant_handle_bit_fields && field->field->type() ==
1682016823
MYSQL_TYPE_BIT)

storage/spider/mysql-test/spider/r/spider_fixes_part.result

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,37 @@ id
214214
10000
215215
connection master_1;
216216

217+
Crash from b4a2baffa82e5c07b96a1c752228560dcac1359b (MDEV-11084)
218+
Fixed with 4968049799193394d442f26b4e3a8d95b185be72
219+
Spider crashed if the first partition was not used first
220+
connection master_1;
221+
CREATE TABLE ta_l2 (
222+
a INT,
223+
b CHAR(1),
224+
c DATETIME,
225+
PRIMARY KEY(a)
226+
) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1
227+
INSERT INTO ta_l2 SELECT a, b, c FROM tb_l;
228+
Query a Spider table only using the second partition
229+
SELECT a,b,c FROM ta_l2 PARTITION (pt2);
230+
a b c
231+
4 d 2003-11-30 05:01:03
232+
5 c 2001-12-31 23:59:59
233+
Query a Spider table only using the first partition
234+
SELECT a,b,c FROM ta_l2 PARTITION (pt1);
235+
a b c
236+
1 a 2008-08-01 10:21:39
237+
2 b 2000-01-01 00:00:00
238+
3 e 2007-06-04 20:03:11
239+
Query a Spider table by all paritions, then the second partition
240+
SELECT min(a), max(a), min(b), max(b) FROM ta_l2;
241+
min(a) max(a) min(b) max(b)
242+
1 5 a e
243+
SELECT a,b,c FROM ta_l2 PARTITION (pt2);
244+
a b c
245+
4 d 2003-11-30 05:01:03
246+
5 c 2001-12-31 23:59:59
247+
217248
deinit
218249
connection master_1;
219250
DROP DATABASE IF EXISTS auto_test_local;

storage/spider/mysql-test/spider/t/spider_fixes_part.test

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,115 @@ if ($HAVE_PARTITION)
616616
}
617617
}
618618

619+
--echo
620+
--echo Crash from b4a2baffa82e5c07b96a1c752228560dcac1359b (MDEV-11084)
621+
--echo Fixed with 4968049799193394d442f26b4e3a8d95b185be72
622+
--echo Spider crashed if the first partition was not used first
623+
if ($HAVE_PARTITION)
624+
{
625+
if ($USE_CHILD_GROUP2)
626+
{
627+
if (!$OUTPUT_CHILD_GROUP2)
628+
{
629+
--disable_query_log
630+
--disable_result_log
631+
}
632+
--connection child2_2
633+
if ($OUTPUT_CHILD_GROUP2)
634+
{
635+
--disable_query_log
636+
echo CHILD2_2_DROP_TABLES;
637+
echo CHILD2_2_CREATE_TABLES;
638+
}
639+
--disable_warnings
640+
eval $CHILD2_2_DROP_TABLES;
641+
--enable_warnings
642+
eval $CHILD2_2_CREATE_TABLES;
643+
if ($OUTPUT_CHILD_GROUP2)
644+
{
645+
--enable_query_log
646+
}
647+
if ($USE_GENERAL_LOG)
648+
{
649+
TRUNCATE TABLE mysql.general_log;
650+
}
651+
--connection child2_1
652+
if ($OUTPUT_CHILD_GROUP2)
653+
{
654+
--disable_query_log
655+
echo CHILD2_1_DROP_TABLES2;
656+
echo CHILD2_1_CREATE_TABLES2;
657+
}
658+
--disable_warnings
659+
eval $CHILD2_1_DROP_TABLES2;
660+
--enable_warnings
661+
eval $CHILD2_1_CREATE_TABLES2;
662+
if ($OUTPUT_CHILD_GROUP2)
663+
{
664+
--enable_query_log
665+
}
666+
if ($USE_GENERAL_LOG)
667+
{
668+
TRUNCATE TABLE mysql.general_log;
669+
}
670+
if (!$OUTPUT_CHILD_GROUP2)
671+
{
672+
--enable_query_log
673+
--enable_result_log
674+
}
675+
}
676+
--connection master_1
677+
--disable_query_log
678+
--disable_warnings
679+
DROP TABLE IF EXISTS ta_l2;
680+
--enable_warnings
681+
echo CREATE TABLE ta_l2 (
682+
a INT,
683+
b CHAR(1),
684+
c DATETIME,
685+
PRIMARY KEY(a)
686+
) MASTER_1_ENGINE MASTER_1_COMMENT2_P_2_1;
687+
eval CREATE TABLE ta_l2 (
688+
a INT,
689+
b CHAR(1),
690+
c DATETIME,
691+
PRIMARY KEY(a)
692+
) $MASTER_1_ENGINE $MASTER_1_COMMENT2_P_2_1;
693+
--enable_query_log
694+
INSERT INTO ta_l2 SELECT a, b, c FROM tb_l;
695+
--echo Query a Spider table only using the second partition
696+
SELECT a,b,c FROM ta_l2 PARTITION (pt2);
697+
--echo Query a Spider table only using the first partition
698+
SELECT a,b,c FROM ta_l2 PARTITION (pt1);
699+
--echo Query a Spider table by all paritions, then the second partition
700+
SELECT min(a), max(a), min(b), max(b) FROM ta_l2;
701+
SELECT a,b,c FROM ta_l2 PARTITION (pt2);
702+
if ($USE_CHILD_GROUP2)
703+
{
704+
if (!$OUTPUT_CHILD_GROUP2)
705+
{
706+
--disable_query_log
707+
--disable_result_log
708+
}
709+
--connection child2_2
710+
if ($USE_GENERAL_LOG)
711+
{
712+
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
713+
}
714+
eval $CHILD2_2_SELECT_TABLES;
715+
--connection child2_1
716+
if ($USE_GENERAL_LOG)
717+
{
718+
SELECT argument FROM mysql.general_log WHERE argument LIKE '%select %';
719+
}
720+
eval $CHILD2_1_SELECT_TABLES2;
721+
if (!$OUTPUT_CHILD_GROUP2)
722+
{
723+
--enable_query_log
724+
--enable_result_log
725+
}
726+
}
727+
}
619728

620729
--echo
621730
--echo deinit

0 commit comments

Comments
 (0)