mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Backport of Bug#53236 Segfault in DTCollation::set(DTCollation&)
Don't call member functions for a NIL pointer. mysql-test/r/subselect4.result: Add test case. mysql-test/t/subselect4.test: Add test case. sql/sql_select.cc: If the (virtual) member function clone_item() returns NULL, there is no substitution to be made, and we don't need to set the collation. The test was invoking Item_cache::clone_item()
This commit is contained in:
@ -59,3 +59,28 @@ FROM t3 WHERE 1 = 0 GROUP BY 1;
|
|||||||
(SELECT 1 FROM t1,t2 WHERE t2.b > t3.b)
|
(SELECT 1 FROM t1,t2 WHERE t2.b > t3.b)
|
||||||
DROP TABLE t1,t2,t3;
|
DROP TABLE t1,t2,t3;
|
||||||
End of 5.0 tests.
|
End of 5.0 tests.
|
||||||
|
#
|
||||||
|
# Bug#53236 Segfault in DTCollation::set(DTCollation&)
|
||||||
|
#
|
||||||
|
CREATE TABLE t1 (
|
||||||
|
pk INTEGER AUTO_INCREMENT,
|
||||||
|
col_varchar VARCHAR(1),
|
||||||
|
PRIMARY KEY (pk)
|
||||||
|
)
|
||||||
|
;
|
||||||
|
INSERT INTO t1 (col_varchar)
|
||||||
|
VALUES
|
||||||
|
('w'),
|
||||||
|
('m')
|
||||||
|
;
|
||||||
|
SELECT table1.pk
|
||||||
|
FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar =
|
||||||
|
table2.col_varchar) )
|
||||||
|
WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1,
|
||||||
|
SUBQUERY1_t1.pk AS SUBQUERY1_field2
|
||||||
|
FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2
|
||||||
|
ON (SUBQUERY1_t2.col_varchar =
|
||||||
|
SUBQUERY1_t1.col_varchar) ) )
|
||||||
|
;
|
||||||
|
pk
|
||||||
|
drop table t1;
|
||||||
|
@ -62,3 +62,32 @@ FROM t3 WHERE 1 = 0 GROUP BY 1;
|
|||||||
DROP TABLE t1,t2,t3;
|
DROP TABLE t1,t2,t3;
|
||||||
|
|
||||||
--echo End of 5.0 tests.
|
--echo End of 5.0 tests.
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # Bug#53236 Segfault in DTCollation::set(DTCollation&)
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
CREATE TABLE t1 (
|
||||||
|
pk INTEGER AUTO_INCREMENT,
|
||||||
|
col_varchar VARCHAR(1),
|
||||||
|
PRIMARY KEY (pk)
|
||||||
|
)
|
||||||
|
;
|
||||||
|
|
||||||
|
INSERT INTO t1 (col_varchar)
|
||||||
|
VALUES
|
||||||
|
('w'),
|
||||||
|
('m')
|
||||||
|
;
|
||||||
|
|
||||||
|
SELECT table1.pk
|
||||||
|
FROM ( t1 AS table1 JOIN t1 AS table2 ON (table1.col_varchar =
|
||||||
|
table2.col_varchar) )
|
||||||
|
WHERE ( 1, 2 ) IN ( SELECT SUBQUERY1_t1.pk AS SUBQUERY1_field1,
|
||||||
|
SUBQUERY1_t1.pk AS SUBQUERY1_field2
|
||||||
|
FROM ( t1 AS SUBQUERY1_t1 JOIN t1 AS SUBQUERY1_t2
|
||||||
|
ON (SUBQUERY1_t2.col_varchar =
|
||||||
|
SUBQUERY1_t1.col_varchar) ) )
|
||||||
|
;
|
||||||
|
|
||||||
|
drop table t1;
|
||||||
|
@ -8629,10 +8629,9 @@ change_cond_ref_to_const(THD *thd, I_List<COND_CMP> *save_list,
|
|||||||
left_item->collation.collation == value->collation.collation))
|
left_item->collation.collation == value->collation.collation))
|
||||||
{
|
{
|
||||||
Item *tmp=value->clone_item();
|
Item *tmp=value->clone_item();
|
||||||
tmp->collation.set(right_item->collation);
|
|
||||||
|
|
||||||
if (tmp)
|
if (tmp)
|
||||||
{
|
{
|
||||||
|
tmp->collation.set(right_item->collation);
|
||||||
thd->change_item_tree(args + 1, tmp);
|
thd->change_item_tree(args + 1, tmp);
|
||||||
func->update_used_tables();
|
func->update_used_tables();
|
||||||
if ((functype == Item_func::EQ_FUNC || functype == Item_func::EQUAL_FUNC)
|
if ((functype == Item_func::EQ_FUNC || functype == Item_func::EQUAL_FUNC)
|
||||||
@ -8653,10 +8652,9 @@ change_cond_ref_to_const(THD *thd, I_List<COND_CMP> *save_list,
|
|||||||
right_item->collation.collation == value->collation.collation))
|
right_item->collation.collation == value->collation.collation))
|
||||||
{
|
{
|
||||||
Item *tmp= value->clone_item();
|
Item *tmp= value->clone_item();
|
||||||
tmp->collation.set(left_item->collation);
|
|
||||||
|
|
||||||
if (tmp)
|
if (tmp)
|
||||||
{
|
{
|
||||||
|
tmp->collation.set(left_item->collation);
|
||||||
thd->change_item_tree(args, tmp);
|
thd->change_item_tree(args, tmp);
|
||||||
value= tmp;
|
value= tmp;
|
||||||
func->update_used_tables();
|
func->update_used_tables();
|
||||||
|
Reference in New Issue
Block a user