Skip to content

Commit 067f83e

Browse files
author
Tor Didriksen
committed
Bug#13519724 63793: CRASH IN DTCOLLATION::SET(DTCOLLATION &SET)
Backport of fix for: Bug#53236 Segfault in DTCollation::set(DTCollation&)
1 parent ad35745 commit 067f83e

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

mysql-test/r/cast.result

+9
Original file line numberDiff line numberDiff line change
@@ -468,4 +468,13 @@ NULL
468468
Warnings:
469469
Warning 1301 Result of cast_as_char() was larger than max_allowed_packet (2048) - truncated
470470
SET @@GLOBAL.max_allowed_packet=default;
471+
#
472+
# Bug#13519724 63793: CRASH IN DTCOLLATION::SET(DTCOLLATION &SET)
473+
#
474+
CREATE TABLE t1 (a VARCHAR(50));
475+
SELECT a FROM t1
476+
WHERE CAST(a as BINARY)=x'62736D697468'
477+
AND CAST(a AS BINARY)=x'65736D697468';
478+
a
479+
DROP TABLE t1;
471480
End of 5.1 tests

mysql-test/t/cast.test

+12
Original file line numberDiff line numberDiff line change
@@ -297,4 +297,16 @@ connection default;
297297
disconnect newconn;
298298
SET @@GLOBAL.max_allowed_packet=default;
299299

300+
--echo #
301+
--echo # Bug#13519724 63793: CRASH IN DTCOLLATION::SET(DTCOLLATION &SET)
302+
--echo #
303+
304+
CREATE TABLE t1 (a VARCHAR(50));
305+
306+
SELECT a FROM t1
307+
WHERE CAST(a as BINARY)=x'62736D697468'
308+
AND CAST(a AS BINARY)=x'65736D697468';
309+
310+
DROP TABLE t1;
311+
300312
--echo End of 5.1 tests

sql/sql_select.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -8546,10 +8546,10 @@ change_cond_ref_to_const(THD *thd, I_List<COND_CMP> *save_list,
85468546
left_item->collation.collation == value->collation.collation))
85478547
{
85488548
Item *tmp=value->clone_item();
8549-
tmp->collation.set(right_item->collation);
85508549

85518550
if (tmp)
85528551
{
8552+
tmp->collation.set(right_item->collation);
85538553
thd->change_item_tree(args + 1, tmp);
85548554
func->update_used_tables();
85558555
if ((functype == Item_func::EQ_FUNC || functype == Item_func::EQUAL_FUNC)
@@ -8570,10 +8570,10 @@ change_cond_ref_to_const(THD *thd, I_List<COND_CMP> *save_list,
85708570
right_item->collation.collation == value->collation.collation))
85718571
{
85728572
Item *tmp= value->clone_item();
8573-
tmp->collation.set(left_item->collation);
85748573

85758574
if (tmp)
85768575
{
8576+
tmp->collation.set(left_item->collation);
85778577
thd->change_item_tree(args, tmp);
85788578
value= tmp;
85798579
func->update_used_tables();

0 commit comments

Comments
 (0)