Skip to content

Commit 9715545

Browse files
author
Sergey Glukhov
committed
5.1-bugteam->5.5-bugteam merge
--BZR-- revision-id: [email protected] property-branch-nick: mysql-5.5-bugteam property-file-info: ld7:file_id67:sp1f-derived.result-20020326130604-7h5qgv4t7i62th7ufm74tv3o2mtgqoqg7:message30:5.1-bugteam->5.5-bugteam merge4:path27:mysql-test/r/derived.resulted7:file_id72:sp1f-multi_update.result-20010611232825-7f2vetuxiyd3bu5lefd5a2ze43xed33y7:message30:5.1-bugteam->5.5-bugteam merge4:path32:mysql-test/r/multi_update.resulted7:file_id64:sp1f-view.result-20040715221517-nqk3l34grrhprjiitidhfjyjqlgh6a5v7:message30:5.1-bugteam->5.5-bugteam merge4:path24:mysql-test/r/view.resulted7:file_id54:innodb_multi_update.-20100505110047-w87u39xlb6di17k1-27:message30:5.1-bugteam->5.5-bugteam merge4:path52:mysql-test/suite/innodb/r/innodb_multi_update.resulted7:file_id54:innodb_multi_update.-20100505110047-w87u39xlb6di17k1-17:message30:5.1-bugteam->5.5-bugteam merge4:path50:mysql-test/suite/innodb/t/innodb_multi_update.tested7:file_id65:sp1f-derived.test-20020326130604-mdjuldldv4iv2xqkrt4c4xbvxdwnljpw7:message30:5.1-bugteam->5.5-bugteam merge4:path25:mysql-test/t/derived.tested7:file_id70:sp1f-multi_update.test-20010611232825-wkkm3vvyawipiowjzwqmkqegx6wd6aiw7:message30:5.1-bugteam->5.5-bugteam merge4:path30:mysql-test/t/multi_update.tested7:file_id62:sp1f-view.test-20040715221517-2kxb7l4itrpl4mw266xe5gby4vftru3z7:message30:5.1-bugteam->5.5-bugteam merge4:path22:mysql-test/t/view.tested7:file_id60:sp1f-item.cc-19700101030959-u7hxqopwpfly4kf5ctlyk2dvrq4l3dhn7:message30:5.1-bugteam->5.5-bugteam merge4:path11:sql/item.cced7:file_id68:sp1f-item_cmpfunc.cc-19700101030959-hrk7pi2n6qpwxauufnkizirsoucdcx2e7:message30:5.1-bugteam->5.5-bugteam merge4:path19:sql/item_cmpfunc.cced7:file_id65:sp1f-item_func.cc-19700101030959-3wmsx76yvc25sroqpfrx2n77kqdxxn3y7:message30:5.1-bugteam->5.5-bugteam merge4:path16:sql/item_func.cced7:file_id64:sp1f-item_row.cc-20021115183204-24uyecwm52gv5pn6jtszpqpfufhwmisq7:message30:5.1-bugteam->5.5-bugteam merge4:path15:sql/item_row.cced7:file_id70:sp1f-item_subselect.cc-20020512204640-qep43aqhsfrwkqmrobni6czc3fqj36oo7:message30:5.1-bugteam->5.5-bugteam merge4:path21:sql/item_subselect.cced7:file_id69:sp1f-item_subselect.h-20020512204640-qdg77wil56cxyhtc2bjjdrppxq3wqgh37:message30:5.1-bugteam->5.5-bugteam merge4:path20:sql/item_subselect.hed7:file_id64:sp1f-sql_class.h-19700101030959-jnqnbrjyqsvgncsibnumsmg3lyi7pa5s7:message30:5.1-bugteam->5.5-bugteam merge4:path15:sql/sql_class.hed7:file_id67:sp1f-sql_derived.cc-20020326130604-4qz6ovo2xa6w5eslbmcx76agmnyyvsfh7:message30:5.1-bugteam->5.5-bugteam merge4:path18:sql/sql_derived.cced7:file_id63:sp1f-sql_lex.cc-19700101030959-4pizwlu5rqkti27gcwsvxkawq6bc2kph7:message30:5.1-bugteam->5.5-bugteam merge4:path14:sql/sql_lex.cced7:file_id62:sp1f-sql_lex.h-19700101030959-sgldb2sooc7twtw5q7pgjx7qzqiaa3sn7:message30:5.1-bugteam->5.5-bugteam merge4:path13:sql/sql_lex.hed7:file_id65:sp1f-sql_parse.cc-19700101030959-ehcre3rwhv5l3mlxqhaxg36ujenxnrcd7:message30:5.1-bugteam->5.5-bugteam merge4:path16:sql/sql_parse.cced7:file_id67:sp1f-sql_prepare.cc-20020612210720-gtqjjiu7vpmfxb5xct2qke7urmqcabli7:message30:5.1-bugteam->5.5-bugteam merge4:path18:sql/sql_prepare.cced7:file_id65:sp1f-mysql_priv.h-19700101030959-4fl65tqpop5zfgxaxkqotu2fa2ree5ci7:message30:5.1-bugteam->5.5-bugteam merge4:path14:sql/sql_priv.hed7:file_id66:sp1f-sql_select.cc-19700101030959-egb7whpkh76zzvikycs5nsnuviu4fdlb7:message30:5.1-bugteam->5.5-bugteam merge4:path17:sql/sql_select.cced7:file_id64:sp1f-sql_show.cc-19700101030959-umlljfnpplg452h7reeyqr4xnbmlkvfj7:message30:5.1-bugteam->5.5-bugteam merge4:path15:sql/sql_show.cced7:file_id64:sp1f-sql_view.cc-20040715221517-nw4p4mja6nzzlvwwhzfgfqb4umxqobe47:message30:5.1-bugteam->5.5-bugteam merge4:path15:sql/sql_view.ccee testament3-sha1: 35ea9e75debb24d9e42c99751d44786b30804eb2
2 parents 1ba752c + 807aa1c commit 9715545

24 files changed

+153
-83
lines changed

mysql-test/r/derived.result

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,4 +400,15 @@ SELECT 0 FROM
400400
(SELECT 0) t61;
401401
0
402402
0
403+
#
404+
# A nested materialized derived table is used before being populated.
405+
# (addon for bug#19077)
406+
#
407+
CREATE TABLE t1 (i INT, j BIGINT);
408+
INSERT INTO t1 VALUES (1, 2), (2, 2), (3, 2);
409+
SELECT * FROM (SELECT MIN(i) FROM t1
410+
WHERE j = SUBSTRING('12', (SELECT * FROM (SELECT MIN(j) FROM t1) t2))) t3;
411+
MIN(i)
412+
1
413+
DROP TABLE t1;
403414
# End of 5.0 tests

mysql-test/r/multi_update.result

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,4 +669,15 @@ Error 1242 Subquery returns more than 1 row
669669
Error 1242 Subquery returns more than 1 row
670670
DROP TABLE t1, t2, t3;
671671
SET SESSION sql_safe_updates = DEFAULT;
672+
#
673+
# Bug#52157 various crashes and assertions with multi-table update, stored function
674+
#
675+
CREATE FUNCTION f1 () RETURNS BLOB RETURN 1;
676+
CREATE TABLE t1 (f1 DATE);
677+
INSERT INTO t1 VALUES('2001-01-01');
678+
UPDATE (SELECT 1 FROM t1 WHERE f1 = (SELECT f1() FROM t1)) x, t1 SET f1 = 1;
679+
Warnings:
680+
Warning 1292 Truncated incorrect datetime value: '1'
681+
DROP FUNCTION f1;
682+
DROP TABLE t1;
672683
end of tests

mysql-test/r/view.result

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3999,6 +3999,19 @@ CREATE VIEW v1 AS SELECT 1 from t1
39993999
WHERE t1.b <=> (SELECT a FROM t1 WHERE a < SOME(SELECT '1'));
40004000
DROP VIEW v1;
40014001
DROP TABLE t1;
4002+
#
4003+
# Bug#57703 create view cause Assertion failed: 0, file .\item_subselect.cc, line 846
4004+
#
4005+
CREATE TABLE t1(a int);
4006+
CREATE VIEW v1 AS SELECT 1 FROM t1 GROUP BY
4007+
SUBSTRING(1 FROM (SELECT 3 FROM t1 WHERE a >= ANY(SELECT 1)));
4008+
DROP VIEW v1;
4009+
DROP TABLE t1;
4010+
#
4011+
# Bug#57352 valgrind warnings when creating view
4012+
#
4013+
CREATE VIEW v1 AS SELECT 1 IN (1 LIKE 2,0) AS f;
4014+
DROP VIEW v1;
40024015
# -----------------------------------------------------------------
40034016
# -- End of 5.1 tests.
40044017
# -----------------------------------------------------------------

mysql-test/suite/innodb/r/innodb_multi_update.result

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,11 @@ a b
7474
4 14
7575
5 15
7676
drop table bug38999_1,bug38999_2;
77+
#
78+
# Bug#54475 improper error handling causes cascading crashing failures in innodb/ndb
79+
#
80+
CREATE TABLE t1(f1 INT) ENGINE=INNODB;
81+
INSERT INTO t1 VALUES(1);
82+
UPDATE (SELECT ((SELECT 1 FROM t1), 1) FROM t1 WHERE (SELECT 1 FROM t1)) x, (SELECT 1) AS d SET d.f1 = 1;
83+
ERROR 21000: Operand should contain 1 column(s)
84+
DROP TABLE t1;

mysql-test/suite/innodb/t/innodb_multi_update.test

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,12 @@ select * from bug38999_1;
2727
select * from bug38999_2;
2828

2929
drop table bug38999_1,bug38999_2;
30+
31+
--echo #
32+
--echo # Bug#54475 improper error handling causes cascading crashing failures in innodb/ndb
33+
--echo #
34+
CREATE TABLE t1(f1 INT) ENGINE=INNODB;
35+
INSERT INTO t1 VALUES(1);
36+
--error ER_OPERAND_COLUMNS
37+
UPDATE (SELECT ((SELECT 1 FROM t1), 1) FROM t1 WHERE (SELECT 1 FROM t1)) x, (SELECT 1) AS d SET d.f1 = 1;
38+
DROP TABLE t1;

mysql-test/t/derived.test

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,4 +301,15 @@ SELECT 0 FROM
301301
(SELECT 0) t56, (SELECT 0) t57, (SELECT 0) t58, (SELECT 0) t59, (SELECT 0) t60,
302302
(SELECT 0) t61; # 61 == MAX_TABLES
303303

304+
--echo #
305+
--echo # A nested materialized derived table is used before being populated.
306+
--echo # (addon for bug#19077)
307+
--echo #
308+
309+
CREATE TABLE t1 (i INT, j BIGINT);
310+
INSERT INTO t1 VALUES (1, 2), (2, 2), (3, 2);
311+
SELECT * FROM (SELECT MIN(i) FROM t1
312+
WHERE j = SUBSTRING('12', (SELECT * FROM (SELECT MIN(j) FROM t1) t2))) t3;
313+
DROP TABLE t1;
314+
304315
--echo # End of 5.0 tests

mysql-test/t/multi_update.test

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,4 +672,15 @@ SET t3.a = 0;
672672
DROP TABLE t1, t2, t3;
673673
SET SESSION sql_safe_updates = DEFAULT;
674674

675+
--echo #
676+
--echo # Bug#52157 various crashes and assertions with multi-table update, stored function
677+
--echo #
678+
679+
CREATE FUNCTION f1 () RETURNS BLOB RETURN 1;
680+
CREATE TABLE t1 (f1 DATE);
681+
INSERT INTO t1 VALUES('2001-01-01');
682+
UPDATE (SELECT 1 FROM t1 WHERE f1 = (SELECT f1() FROM t1)) x, t1 SET f1 = 1;
683+
DROP FUNCTION f1;
684+
DROP TABLE t1;
685+
675686
--echo end of tests

mysql-test/t/view.test

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3963,6 +3963,22 @@ WHERE t1.b <=> (SELECT a FROM t1 WHERE a < SOME(SELECT '1'));
39633963
DROP VIEW v1;
39643964
DROP TABLE t1;
39653965

3966+
--echo #
3967+
--echo # Bug#57703 create view cause Assertion failed: 0, file .\item_subselect.cc, line 846
3968+
--echo #
3969+
3970+
CREATE TABLE t1(a int);
3971+
CREATE VIEW v1 AS SELECT 1 FROM t1 GROUP BY
3972+
SUBSTRING(1 FROM (SELECT 3 FROM t1 WHERE a >= ANY(SELECT 1)));
3973+
DROP VIEW v1;
3974+
DROP TABLE t1;
3975+
3976+
--echo #
3977+
--echo # Bug#57352 valgrind warnings when creating view
3978+
--echo #
3979+
CREATE VIEW v1 AS SELECT 1 IN (1 LIKE 2,0) AS f;
3980+
DROP VIEW v1;
3981+
39663982
--echo # -----------------------------------------------------------------
39673983
--echo # -- End of 5.1 tests.
39683984
--echo # -----------------------------------------------------------------

sql/item.cc

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1812,16 +1812,7 @@ bool agg_item_set_converter(DTCollation &coll, const char *fname,
18121812

18131813
if (!(conv= (*arg)->safe_charset_converter(coll.collation)) &&
18141814
((*arg)->collation.repertoire == MY_REPERTOIRE_ASCII))
1815-
{
1816-
/*
1817-
We should disable const subselect item evaluation because
1818-
subselect transformation does not happen in view_prepare_mode
1819-
and thus val_...() methods can not be called for const items.
1820-
*/
1821-
bool resolve_const= ((*arg)->type() == Item::SUBSELECT_ITEM &&
1822-
thd->lex->view_prepare_mode) ? FALSE : TRUE;
1823-
conv= new Item_func_conv_charset(*arg, coll.collation, resolve_const);
1824-
}
1815+
conv= new Item_func_conv_charset(*arg, coll.collation, 1);
18251816

18261817
if (!conv)
18271818
{

sql/item_cmpfunc.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ static bool convert_constant_item(THD *thd, Item_field *field_item,
403403
Field *field= field_item->field;
404404
int result= 0;
405405

406-
if (!(*item)->with_subselect && (*item)->const_item())
406+
if ((*item)->const_item())
407407
{
408408
TABLE *table= field->table;
409409
ulonglong orig_sql_mode= thd->variables.sql_mode;
@@ -499,7 +499,7 @@ void Item_bool_func2::fix_length_and_dec()
499499
}
500500

501501
thd= current_thd;
502-
if (!thd->is_context_analysis_only())
502+
if (!thd->lex->is_ps_or_view_context_analysis())
503503
{
504504
if (args[0]->real_item()->type() == FIELD_ITEM)
505505
{
@@ -803,7 +803,7 @@ Arg_comparator::can_compare_as_dates(Item *a, Item *b, ulonglong *const_value)
803803
confuse storage engines since in context analysis mode tables
804804
aren't locked.
805805
*/
806-
if (!thd->is_context_analysis_only() &&
806+
if (!thd->lex->is_ps_or_view_context_analysis() &&
807807
cmp_type != CMP_DATE_WITH_DATE && str_arg->const_item() &&
808808
(str_arg->type() != Item::FUNC_ITEM ||
809809
((Item_func*)str_arg)->functype() != Item_func::GUSERVAR_FUNC))
@@ -1036,7 +1036,7 @@ Item** Arg_comparator::cache_converted_constant(THD *thd_arg, Item **value,
10361036
Item_result type)
10371037
{
10381038
/* Don't need cache if doing context analysis only. */
1039-
if (!thd_arg->is_context_analysis_only() &&
1039+
if (!thd->lex->is_ps_or_view_context_analysis() &&
10401040
(*value)->const_item() && type != (*value)->result_type())
10411041
{
10421042
Item_cache *cache= Item_cache::get_cache(*value, type);
@@ -4714,7 +4714,7 @@ bool Item_func_like::fix_fields(THD *thd, Item **ref)
47144714
return TRUE;
47154715
}
47164716

4717-
if (escape_item->const_item() && !thd->lex->view_prepare_mode)
4717+
if (escape_item->const_item())
47184718
{
47194719
/* If we are on execution stage */
47204720
String *escape_str= escape_item->val_str(&cmp.value1);

0 commit comments

Comments
 (0)