revision-id: e89b611dc9535183d617391c4d1229f0bca66d31 (mariadb-10.2.16-141-ge89b611) parent(s): 7419f72b7183e40a24cd53a139b78aeaf41503d2 committer: Alexey Botchkov timestamp: 2018-09-16 10:22:32 +0400 message: MDEV-16050 cte + geometry functions lead to crash. Structures based on Gcalc_dyn_list need to be treated properly when copied in Item::get_copy(). --- mysql-test/r/gis-precise.result | 3 +++ mysql-test/t/gis-precise.test | 4 ++++ sql/gcalc_slicescan.cc | 11 +++++++++++ sql/gcalc_slicescan.h | 7 +++++++ sql/gcalc_tools.cc | 11 +++++++++++ sql/gcalc_tools.h | 1 + 6 files changed, 37 insertions(+) diff --git a/mysql-test/r/gis-precise.result b/mysql-test/r/gis-precise.result index 89e5c23..56c9472 100644 --- a/mysql-test/r/gis-precise.result +++ b/mysql-test/r/gis-precise.result @@ -505,6 +505,9 @@ GEOMETRYFROMTEXT('POINT(4599 60359)'), ) as relate_res; relate_res 0 +with cte1 as( select (st_symdifference(point(1,1),point(1,1))) as a1 ), cte2 as(select 1 as a2) select 1 from cte1 where cte1.a1 < '1'; +1 +1 DROP TABLE IF EXISTS p1; CREATE PROCEDURE p1(dist DOUBLE, geom TEXT) BEGIN diff --git a/mysql-test/t/gis-precise.test b/mysql-test/t/gis-precise.test index 7391b21..39a35e1 100644 --- a/mysql-test/t/gis-precise.test +++ b/mysql-test/t/gis-precise.test @@ -381,5 +381,9 @@ SELECT ST_RELATE( 'F*FFFF**F' ) as relate_res; +# MDEV- 16050 cte + geometry functions lead to crash. + +with cte1 as( select (st_symdifference(point(1,1),point(1,1))) as a1 ), cte2 as(select 1 as a2) select 1 from cte1 where cte1.a1 < '1'; + --source include/gis_debug.inc diff --git a/sql/gcalc_slicescan.cc b/sql/gcalc_slicescan.cc index ab48542..6876420 100644 --- a/sql/gcalc_slicescan.cc +++ b/sql/gcalc_slicescan.cc @@ -177,6 +177,17 @@ Gcalc_dyn_list::Gcalc_dyn_list(size_t blk_size, size_t sizeof_item): {} +Gcalc_dyn_list::Gcalc_dyn_list(const Gcalc_dyn_list &dl) +{ + m_blk_size= dl.m_blk_size; + m_sizeof_item= dl.m_sizeof_item; + m_points_per_blk= dl.m_points_per_blk; + m_blk_hook= &m_first_blk; + m_free= NULL; + m_keep= NULL; +} + + void Gcalc_dyn_list::format_blk(void* block) { Item *pi_end, *cur_pi, *first_pi; diff --git a/sql/gcalc_slicescan.h b/sql/gcalc_slicescan.h index b9516fc..ebf173c 100644 --- a/sql/gcalc_slicescan.h +++ b/sql/gcalc_slicescan.h @@ -63,6 +63,7 @@ class Gcalc_dyn_list }; Gcalc_dyn_list(size_t blk_size, size_t sizeof_item); + Gcalc_dyn_list(const Gcalc_dyn_list &dl); ~Gcalc_dyn_list(); Item *new_item() { @@ -229,6 +230,12 @@ class Gcalc_heap : public Gcalc_dyn_list Gcalc_dyn_list(blk_size, sizeof(Info)), m_hook(&m_first), m_n_points(0) {} + + Gcalc_heap(const Gcalc_heap &gh) : + Gcalc_dyn_list(gh), + m_hook(&m_first), m_n_points(0) + {} + void set_extent(double xmin, double xmax, double ymin, double ymax); Info *new_point_info(double x, double y, gcalc_shape_info shape); void free_point_info(Info *i, Gcalc_dyn_list::Item **i_hook); diff --git a/sql/gcalc_tools.cc b/sql/gcalc_tools.cc index 71118ae..b472665 100644 --- a/sql/gcalc_tools.cc +++ b/sql/gcalc_tools.cc @@ -663,6 +663,17 @@ Gcalc_operation_reducer::Gcalc_operation_reducer(size_t blk_size) : {} +Gcalc_operation_reducer::Gcalc_operation_reducer( + const Gcalc_operation_reducer &gor) : + Gcalc_dyn_list(gor), +#ifndef GCALC_DBUG_OFF + n_res_points(0), +#endif /*GCALC_DBUG_OFF*/ + m_res_hook((Gcalc_dyn_list::Item **)&m_result), + m_first_active_thread(NULL) +{} + + void Gcalc_operation_reducer::init(Gcalc_function *fn, modes mode) { m_fn= fn; diff --git a/sql/gcalc_tools.h b/sql/gcalc_tools.h index 8bda3c1..4d5aec0 100644 --- a/sql/gcalc_tools.h +++ b/sql/gcalc_tools.h @@ -224,6 +224,7 @@ class Gcalc_operation_reducer : public Gcalc_dyn_list }; Gcalc_operation_reducer(size_t blk_size=8192); + Gcalc_operation_reducer(const Gcalc_operation_reducer &gor); void init(Gcalc_function *fn, modes mode= default_mode); Gcalc_operation_reducer(Gcalc_function *fn, modes mode= default_mode, size_t blk_size=8192);