summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorAlexey Botchkov <holyfoot@askmonty.org>2011-11-20 12:30:43 +0400
committerAlexey Botchkov <holyfoot@askmonty.org>2011-11-20 12:30:43 +0400
commit5a4c91003a73c551d89e0c6878edfe03704352fe (patch)
tree2be110dc992f0631b422ea2ea9a55fe64e8beb28 /sql
parent8ea398292e9c5ae8e8efcaccde8e781317855d13 (diff)
downloadmariadb-git-5a4c91003a73c551d89e0c6878edfe03704352fe.tar.gz
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.
Diffstat (limited to 'sql')
-rw-r--r--sql/gcalc_slicescan.cc4
-rw-r--r--sql/gcalc_slicescan.h7
-rw-r--r--sql/gcalc_tools.cc2
-rw-r--r--sql/gcalc_tools.h1
-rw-r--r--sql/item_geofunc.cc6
-rw-r--r--sql/item_geofunc.h2
6 files changed, 17 insertions, 5 deletions
diff --git a/sql/gcalc_slicescan.cc b/sql/gcalc_slicescan.cc
index a294a792490..624ca1aff56 100644
--- a/sql/gcalc_slicescan.cc
+++ b/sql/gcalc_slicescan.cc
@@ -1078,6 +1078,7 @@ void Gcalc_scan_iterator::init(Gcalc_heap *points)
#ifndef GCALC_DBUG_OFF
m_cur_thread= 0;
#endif /*GCALC_DBUG_OFF*/
+ GCALC_SET_TERMINATED(killed, 0);
}
void Gcalc_scan_iterator::reset()
@@ -1263,6 +1264,9 @@ int Gcalc_scan_iterator::step()
GCALC_DBUG_ENTER("Gcalc_scan_iterator::step");
GCALC_DBUG_ASSERT(more_points());
+ if (GCALC_TERMINATED(killed))
+ GCALC_DBUG_RETURN(0xFFFF);
+
/* Clear the old event marks. */
if (m_bottom_points)
{
diff --git a/sql/gcalc_slicescan.h b/sql/gcalc_slicescan.h
index 812b6e6e923..9fc4cea5199 100644
--- a/sql/gcalc_slicescan.h
+++ b/sql/gcalc_slicescan.h
@@ -38,6 +38,11 @@
#define GCALC_DBUG_ASSERT(r) do {} while(0)
#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
with the possible efficiency.
@@ -448,6 +453,8 @@ public:
public:
Gcalc_scan_iterator(size_t blk_size= 8192);
+ GCALC_DECL_TERMINATED_STATE(killed)
+
void init(Gcalc_heap *points); /* Iterator can be reused */
void reset();
int step();
diff --git a/sql/gcalc_tools.cc b/sql/gcalc_tools.cc
index b4b01767f5f..161fa385f16 100644
--- a/sql/gcalc_tools.cc
+++ b/sql/gcalc_tools.cc
@@ -637,6 +637,7 @@ void Gcalc_operation_reducer::init(Gcalc_function *fn, modes mode)
m_lines_hook= (Gcalc_dyn_list::Item **) &m_lines;
m_poly_borders= NULL;
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)
Gcalc_scan_iterator si;
GCALC_DBUG_ENTER("Gcalc_operation_reducer::count_all");
si.init(hp);
+ GCALC_SET_TERMINATED(si.killed, killed);
while (si.more_points())
{
if (si.step())
diff --git a/sql/gcalc_tools.h b/sql/gcalc_tools.h
index b89a9a45e07..eed9be0803f 100644
--- a/sql/gcalc_tools.h
+++ b/sql/gcalc_tools.h
@@ -218,6 +218,7 @@ public:
void init(Gcalc_function *fn, modes mode= default_mode);
Gcalc_operation_reducer(Gcalc_function *fn, modes mode= default_mode,
size_t blk_size=8192);
+ GCALC_DECL_TERMINATED_STATE(killed)
int count_slice(Gcalc_scan_iterator *si);
int count_all(Gcalc_heap *hp);
int get_result(Gcalc_result_receiver *storage);
diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc
index 23b9483233d..acaa50536ff 100644
--- a/sql/item_geofunc.cc
+++ b/sql/item_geofunc.cc
@@ -896,6 +896,8 @@ longlong Item_func_spatial_rel::val_int()
collector.prepare_operation();
scan_it.init(&collector);
+ scan_it.killed= (int *) &(current_thd->killed);
+
#ifdef TMP_BLOCK
if (spatial_rel == SP_EQUALS_FUNC)
{
@@ -950,7 +952,6 @@ String *Item_func_spatial_operation::val_str(String *str_value)
collector.prepare_operation();
- scan_it.init(&collector);
if (func.alloc_states())
goto exit;
@@ -973,7 +974,6 @@ String *Item_func_spatial_operation::val_str(String *str_value)
exit:
collector.reset();
func.reset();
- scan_it.reset();
res_receiver.reset();
DBUG_RETURN(str_value);
}
@@ -1399,6 +1399,7 @@ String *Item_func_buffer::val_str(String *str_value)
if (func.alloc_states())
goto mem_error;
operation.init(&func);
+ operation.killed= (int *) &(current_thd->killed);
if (operation.count_all(&collector) ||
operation.get_result(&res_receiver))
@@ -1419,7 +1420,6 @@ String *Item_func_buffer::val_str(String *str_value)
mem_error:
collector.reset();
func.reset();
- scan_it.reset();
res_receiver.reset();
DBUG_RETURN(str_result);
}
diff --git a/sql/item_geofunc.h b/sql/item_geofunc.h
index f3208c5b4d4..d2030ee7bb9 100644
--- a/sql/item_geofunc.h
+++ b/sql/item_geofunc.h
@@ -266,7 +266,6 @@ public:
Gcalc_function::op_type spatial_op;
Gcalc_heap collector;
Gcalc_function func;
- Gcalc_scan_iterator scan_it;
Gcalc_result_receiver res_receiver;
Gcalc_operation_reducer operation;
@@ -323,7 +322,6 @@ protected:
};
Gcalc_heap collector;
Gcalc_function func;
- Gcalc_scan_iterator scan_it;
Gcalc_result_receiver res_receiver;
Gcalc_operation_reducer operation;