Commit 5a4c9100 authored by Alexey Botchkov's avatar Alexey Botchkov

Fix for bug #809849 spatial operations must be KILL-able.

  Checks for thd->killed state added to the long loops in geometry calculations.

per-file comments:
  sql/gcalc_slicescan.cc
Fix for bug #809849 spatial operations must be KILL-able.
        checks for TERMINATED_STATE added.
  sql/gcalc_slicescan.h
Fix for bug #809849 spatial operations must be KILL-able.
        defines added to include checks for termination in the
        library.
  sql/gcalc_tools.cc
Fix for bug #809849 spatial operations must be KILL-able.
        checks for TERMINATED_STATE added.
  sql/gcalc_tools.h
Fix for bug #809849 spatial operations must be KILL-able.
        TERMINATED_STATE pointers added.
  sql/item_geofunc.cc
Fix for bug #809849 spatial operations must be KILL-able.
  sql/item_geofunc.h
Fix for bug #809849 spatial operations must be KILL-able.
parent 8ea39829
...@@ -1078,6 +1078,7 @@ void Gcalc_scan_iterator::init(Gcalc_heap *points) ...@@ -1078,6 +1078,7 @@ void Gcalc_scan_iterator::init(Gcalc_heap *points)
#ifndef GCALC_DBUG_OFF #ifndef GCALC_DBUG_OFF
m_cur_thread= 0; m_cur_thread= 0;
#endif /*GCALC_DBUG_OFF*/ #endif /*GCALC_DBUG_OFF*/
GCALC_SET_TERMINATED(killed, 0);
} }
void Gcalc_scan_iterator::reset() void Gcalc_scan_iterator::reset()
...@@ -1263,6 +1264,9 @@ int Gcalc_scan_iterator::step() ...@@ -1263,6 +1264,9 @@ int Gcalc_scan_iterator::step()
GCALC_DBUG_ENTER("Gcalc_scan_iterator::step"); GCALC_DBUG_ENTER("Gcalc_scan_iterator::step");
GCALC_DBUG_ASSERT(more_points()); GCALC_DBUG_ASSERT(more_points());
if (GCALC_TERMINATED(killed))
GCALC_DBUG_RETURN(0xFFFF);
/* Clear the old event marks. */ /* Clear the old event marks. */
if (m_bottom_points) if (m_bottom_points)
{ {
......
...@@ -38,6 +38,11 @@ ...@@ -38,6 +38,11 @@
#define GCALC_DBUG_ASSERT(r) do {} while(0) #define GCALC_DBUG_ASSERT(r) do {} while(0)
#endif /*GCALC_DBUG_OFF*/ #endif /*GCALC_DBUG_OFF*/
#define GCALC_TERMINATED(state_var) (state_var && (*state_var))
#define GCALC_SET_TERMINATED(state_var, val) state_var= val
#define GCALC_DECL_TERMINATED_STATE(varname) \
volatile int *varname;
/* /*
Gcalc_dyn_list class designed to manage long lists of same-size objects Gcalc_dyn_list class designed to manage long lists of same-size objects
with the possible efficiency. with the possible efficiency.
...@@ -448,6 +453,8 @@ public: ...@@ -448,6 +453,8 @@ public:
public: public:
Gcalc_scan_iterator(size_t blk_size= 8192); Gcalc_scan_iterator(size_t blk_size= 8192);
GCALC_DECL_TERMINATED_STATE(killed)
void init(Gcalc_heap *points); /* Iterator can be reused */ void init(Gcalc_heap *points); /* Iterator can be reused */
void reset(); void reset();
int step(); int step();
......
...@@ -637,6 +637,7 @@ void Gcalc_operation_reducer::init(Gcalc_function *fn, modes mode) ...@@ -637,6 +637,7 @@ void Gcalc_operation_reducer::init(Gcalc_function *fn, modes mode)
m_lines_hook= (Gcalc_dyn_list::Item **) &m_lines; m_lines_hook= (Gcalc_dyn_list::Item **) &m_lines;
m_poly_borders= NULL; m_poly_borders= NULL;
m_poly_borders_hook= (Gcalc_dyn_list::Item **) &m_poly_borders; m_poly_borders_hook= (Gcalc_dyn_list::Item **) &m_poly_borders;
GCALC_SET_TERMINATED(killed, 0);
} }
...@@ -1218,6 +1219,7 @@ int Gcalc_operation_reducer::count_all(Gcalc_heap *hp) ...@@ -1218,6 +1219,7 @@ int Gcalc_operation_reducer::count_all(Gcalc_heap *hp)
Gcalc_scan_iterator si; Gcalc_scan_iterator si;
GCALC_DBUG_ENTER("Gcalc_operation_reducer::count_all"); GCALC_DBUG_ENTER("Gcalc_operation_reducer::count_all");
si.init(hp); si.init(hp);
GCALC_SET_TERMINATED(si.killed, killed);
while (si.more_points()) while (si.more_points())
{ {
if (si.step()) if (si.step())
......
...@@ -218,6 +218,7 @@ public: ...@@ -218,6 +218,7 @@ public:
void init(Gcalc_function *fn, modes mode= default_mode); void init(Gcalc_function *fn, modes mode= default_mode);
Gcalc_operation_reducer(Gcalc_function *fn, modes mode= default_mode, Gcalc_operation_reducer(Gcalc_function *fn, modes mode= default_mode,
size_t blk_size=8192); size_t blk_size=8192);
GCALC_DECL_TERMINATED_STATE(killed)
int count_slice(Gcalc_scan_iterator *si); int count_slice(Gcalc_scan_iterator *si);
int count_all(Gcalc_heap *hp); int count_all(Gcalc_heap *hp);
int get_result(Gcalc_result_receiver *storage); int get_result(Gcalc_result_receiver *storage);
......
...@@ -896,6 +896,8 @@ longlong Item_func_spatial_rel::val_int() ...@@ -896,6 +896,8 @@ longlong Item_func_spatial_rel::val_int()
collector.prepare_operation(); collector.prepare_operation();
scan_it.init(&collector); scan_it.init(&collector);
scan_it.killed= (int *) &(current_thd->killed);
#ifdef TMP_BLOCK #ifdef TMP_BLOCK
if (spatial_rel == SP_EQUALS_FUNC) if (spatial_rel == SP_EQUALS_FUNC)
{ {
...@@ -950,7 +952,6 @@ String *Item_func_spatial_operation::val_str(String *str_value) ...@@ -950,7 +952,6 @@ String *Item_func_spatial_operation::val_str(String *str_value)
collector.prepare_operation(); collector.prepare_operation();
scan_it.init(&collector);
if (func.alloc_states()) if (func.alloc_states())
goto exit; goto exit;
...@@ -973,7 +974,6 @@ String *Item_func_spatial_operation::val_str(String *str_value) ...@@ -973,7 +974,6 @@ String *Item_func_spatial_operation::val_str(String *str_value)
exit: exit:
collector.reset(); collector.reset();
func.reset(); func.reset();
scan_it.reset();
res_receiver.reset(); res_receiver.reset();
DBUG_RETURN(str_value); DBUG_RETURN(str_value);
} }
...@@ -1399,6 +1399,7 @@ String *Item_func_buffer::val_str(String *str_value) ...@@ -1399,6 +1399,7 @@ String *Item_func_buffer::val_str(String *str_value)
if (func.alloc_states()) if (func.alloc_states())
goto mem_error; goto mem_error;
operation.init(&func); operation.init(&func);
operation.killed= (int *) &(current_thd->killed);
if (operation.count_all(&collector) || if (operation.count_all(&collector) ||
operation.get_result(&res_receiver)) operation.get_result(&res_receiver))
...@@ -1419,7 +1420,6 @@ String *Item_func_buffer::val_str(String *str_value) ...@@ -1419,7 +1420,6 @@ String *Item_func_buffer::val_str(String *str_value)
mem_error: mem_error:
collector.reset(); collector.reset();
func.reset(); func.reset();
scan_it.reset();
res_receiver.reset(); res_receiver.reset();
DBUG_RETURN(str_result); DBUG_RETURN(str_result);
} }
......
...@@ -266,7 +266,6 @@ public: ...@@ -266,7 +266,6 @@ public:
Gcalc_function::op_type spatial_op; Gcalc_function::op_type spatial_op;
Gcalc_heap collector; Gcalc_heap collector;
Gcalc_function func; Gcalc_function func;
Gcalc_scan_iterator scan_it;
Gcalc_result_receiver res_receiver; Gcalc_result_receiver res_receiver;
Gcalc_operation_reducer operation; Gcalc_operation_reducer operation;
...@@ -323,7 +322,6 @@ protected: ...@@ -323,7 +322,6 @@ protected:
}; };
Gcalc_heap collector; Gcalc_heap collector;
Gcalc_function func; Gcalc_function func;
Gcalc_scan_iterator scan_it;
Gcalc_result_receiver res_receiver; Gcalc_result_receiver res_receiver;
Gcalc_operation_reducer operation; Gcalc_operation_reducer operation;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment