summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2012-02-17 13:27:41 +0100
committerSergei Golubchik <sergii@pisem.net>2012-02-17 13:27:41 +0100
commitbbb3527635627a404ab4a16be7598339e8e41139 (patch)
treed86404d94d3bd4b04cc2514e1e007ab7b4d918d8
parent2d19b077d5816dcd3a8c84bb682cf2d83fa055f5 (diff)
downloadmariadb-git-bbb3527635627a404ab4a16be7598339e8e41139.tar.gz
Remove engine-specific (but identical) icp callbacks. create one reusable
common icp callback in the handler.cc. It can also increment status counters, without making the engine dependent on the exact THD layout (that is different in embedded).
-rw-r--r--sql/handler.cc21
-rw-r--r--sql/handler.h4
-rw-r--r--storage/maria/ha_maria.cc27
-rw-r--r--storage/myisam/ha_myisam.cc28
-rw-r--r--storage/xtradb/handler/ha_innodb.cc28
-rw-r--r--storage/xtradb/handler/ha_innodb.h1
-rw-r--r--storage/xtradb/include/ha_prototypes.h2
-rw-r--r--storage/xtradb/row/row0sel.c2
8 files changed, 33 insertions, 80 deletions
diff --git a/sql/handler.cc b/sql/handler.cc
index e165a16b544..4a8cd77ebc3 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -4555,6 +4555,27 @@ int handler::compare_key2(key_range *range)
}
+/**
+ ICP callback - to be called by an engine to check the pushed condition
+*/
+extern "C" enum icp_result handler_index_cond_check(void* h_arg)
+{
+ handler *h= (handler*)h_arg;
+ THD *thd= h->table->in_use;
+ enum icp_result res;
+
+ if (thd_killed(thd))
+ return ICP_ABORTED_BY_USER;
+
+ if (h->end_range && h->compare_key2(h->end_range) > 0)
+ return ICP_OUT_OF_RANGE;
+ h->increment_statistics(&SSV::ha_pushed_index_cond_checks);
+ if ((res= h->pushed_idx_cond->val_int()? ICP_MATCH : ICP_NO_MATCH) ==
+ ICP_NO_MATCH)
+ h->increment_statistics(&SSV::ha_pushed_index_cond_filtered);
+ return res;
+}
+
int handler::index_read_idx_map(uchar * buf, uint index, const uchar * key,
key_part_map keypart_map,
enum ha_rkey_function find_flag)
diff --git a/sql/handler.h b/sql/handler.h
index 87ac1ab9ef3..28d8a96a895 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -1553,6 +1553,8 @@ public:
{}
};
+extern "C" enum icp_result handler_index_cond_check(void* h_arg);
+
uint calculate_key_len(TABLE *, uint, const uchar *, key_part_map);
/*
bitmap with first N+1 bits set
@@ -2632,6 +2634,8 @@ public:
{ return ht; }
inline int ha_write_tmp_row(uchar *buf);
inline int ha_update_tmp_row(const uchar * old_data, uchar * new_data);
+
+ friend enum icp_result handler_index_cond_check(void* h_arg);
};
#include "multi_range_read.h"
diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc
index bee7888eb5d..407350900bf 100644
--- a/storage/maria/ha_maria.cc
+++ b/storage/maria/ha_maria.cc
@@ -2243,27 +2243,6 @@ int ha_maria::delete_row(const uchar * buf)
return maria_delete(file, buf);
}
-C_MODE_START
-
-ICP_RESULT index_cond_func_maria(void *arg)
-{
- ha_maria *h= (ha_maria*)arg;
- THD *thd= ((TABLE*) h->file->external_ref)->in_use;
- ICP_RESULT res;
- if (h->end_range)
- {
- if (h->compare_key2(h->end_range) > 0)
- return ICP_OUT_OF_RANGE; /* caller should return HA_ERR_END_OF_FILE already */
- }
- status_var_increment(thd->status_var.ha_pushed_index_cond_checks);
- if ((res= h->pushed_idx_cond->val_int() ? ICP_MATCH : ICP_NO_MATCH) ==
- ICP_NO_MATCH)
- status_var_increment(thd->status_var.ha_pushed_index_cond_filtered);
- return res;
-}
-
-C_MODE_END
-
int ha_maria::index_read_map(uchar * buf, const uchar * key,
key_part_map keypart_map,
enum ha_rkey_function find_flag)
@@ -2283,7 +2262,7 @@ int ha_maria::index_read_idx_map(uchar * buf, uint index, const uchar * key,
/* Use the pushed index condition if it matches the index we're scanning */
end_range= NULL;
if (index == pushed_idx_cond_keyno)
- ma_set_index_cond_func(file, index_cond_func_maria, this);
+ ma_set_index_cond_func(file, handler_index_cond_check, this);
error= maria_rkey(file, buf, index, key, keypart_map, find_flag);
@@ -2364,7 +2343,7 @@ int ha_maria::index_init(uint idx, bool sorted)
{
active_index=idx;
if (pushed_idx_cond_keyno == idx)
- ma_set_index_cond_func(file, index_cond_func_maria, this);
+ ma_set_index_cond_func(file, handler_index_cond_check, this);
return 0;
}
@@ -3797,7 +3776,7 @@ Item *ha_maria::idx_cond_push(uint keyno_arg, Item* idx_cond_arg)
pushed_idx_cond= idx_cond_arg;
in_range_check_pushed_down= TRUE;
if (active_index == pushed_idx_cond_keyno)
- ma_set_index_cond_func(file, index_cond_func_maria, this);
+ ma_set_index_cond_func(file, handler_index_cond_check, this);
return NULL;
}
diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc
index 1f6e1fd6838..a6ece45734a 100644
--- a/storage/myisam/ha_myisam.cc
+++ b/storage/myisam/ha_myisam.cc
@@ -1765,33 +1765,11 @@ int ha_myisam::delete_row(const uchar *buf)
}
-C_MODE_START
-
-ICP_RESULT index_cond_func_myisam(void *arg)
-{
- ha_myisam *h= (ha_myisam*)arg;
- THD *thd= ((TABLE*) h->file->external_ref)->in_use;
- ICP_RESULT res;
- if (h->end_range)
- {
- if (h->compare_key2(h->end_range) > 0)
- return ICP_OUT_OF_RANGE; /* caller should return HA_ERR_END_OF_FILE already */
- }
- status_var_increment(thd->status_var.ha_pushed_index_cond_checks);
- if ((res= (ICP_RESULT) test(h->pushed_idx_cond->val_int())) ==
- ICP_NO_MATCH)
- status_var_increment(thd->status_var.ha_pushed_index_cond_filtered);
- return res;
-}
-
-C_MODE_END
-
-
int ha_myisam::index_init(uint idx, bool sorted)
{
active_index=idx;
if (pushed_idx_cond_keyno == idx)
- mi_set_index_cond_func(file, index_cond_func_myisam, this);
+ mi_set_index_cond_func(file, handler_index_cond_check, this);
return 0;
}
@@ -1827,7 +1805,7 @@ int ha_myisam::index_read_idx_map(uchar *buf, uint index, const uchar *key,
/* Use the pushed index condition if it matches the index we're scanning */
end_range= NULL;
if (index == pushed_idx_cond_keyno)
- mi_set_index_cond_func(file, index_cond_func_myisam, this);
+ mi_set_index_cond_func(file, handler_index_cond_check, this);
res= mi_rkey(file, buf, index, key, keypart_map, find_flag);
mi_set_index_cond_func(file, NULL, 0);
return res;
@@ -2346,7 +2324,7 @@ Item *ha_myisam::idx_cond_push(uint keyno_arg, Item* idx_cond_arg)
pushed_idx_cond= idx_cond_arg;
in_range_check_pushed_down= TRUE;
if (active_index == pushed_idx_cond_keyno)
- mi_set_index_cond_func(file, index_cond_func_myisam, this);
+ mi_set_index_cond_func(file, handler_index_cond_check, this);
return NULL;
}
diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc
index 9db7e9a715b..0d64a3f8b14 100644
--- a/storage/xtradb/handler/ha_innodb.cc
+++ b/storage/xtradb/handler/ha_innodb.cc
@@ -12573,34 +12573,6 @@ bool ha_innobase::is_thd_killed()
* Index Condition Pushdown interface implementation
*/
-/*************************************************************//**
-InnoDB index push-down condition check
-@return ICP_NO_MATCH, ICP_MATCH, or ICP_OUT_OF_RANGE */
-extern "C" UNIV_INTERN
-enum icp_result
-innobase_index_cond(
-/*================*/
- void* file) /*!< in/out: pointer to ha_innobase */
-{
- ha_innobase *h= (ha_innobase*) file;
- THD *thd= h->thd();
- enum icp_result res;
-
- if (h->is_thd_killed())
- return ICP_ABORTED_BY_USER;
-
- if (h->end_range)
- {
- if (h->compare_key2(h->end_range) > 0)
- return ICP_OUT_OF_RANGE; /* caller should return HA_ERR_END_OF_FILE already */
- }
- status_var_increment(thd->status_var.ha_pushed_index_cond_checks);
- if ((res= h->pushed_idx_cond->val_int()? ICP_MATCH : ICP_NO_MATCH) ==
- ICP_NO_MATCH)
- status_var_increment(thd->status_var.ha_pushed_index_cond_filtered);
- return res;
-}
-
/** Attempt to push down an index condition.
* @param[in] keyno MySQL key number
* @param[in] idx_cond Index condition to be checked
diff --git a/storage/xtradb/handler/ha_innodb.h b/storage/xtradb/handler/ha_innodb.h
index 6ec036eb8cc..d234a7236e3 100644
--- a/storage/xtradb/handler/ha_innodb.h
+++ b/storage/xtradb/handler/ha_innodb.h
@@ -224,7 +224,6 @@ class ha_innobase: public handler
uint table_changes);
bool check_if_supported_virtual_columns(void) { return TRUE; }
- THD *thd() { return user_thd; }
private:
/** Builds a 'template' to the prebuilt struct.
diff --git a/storage/xtradb/include/ha_prototypes.h b/storage/xtradb/include/ha_prototypes.h
index db71c37afc3..28c28838400 100644
--- a/storage/xtradb/include/ha_prototypes.h
+++ b/storage/xtradb/include/ha_prototypes.h
@@ -252,7 +252,7 @@ InnoDB index push-down condition check
@return ICP_NO_MATCH, ICP_MATCH, or ICP_OUT_OF_RANGE */
UNIV_INTERN
enum icp_result
-innobase_index_cond(
+handler_index_cond_check(
/*================*/
void* file) /*!< in/out: pointer to ha_innobase */
__attribute__((nonnull, warn_unused_result));
diff --git a/storage/xtradb/row/row0sel.c b/storage/xtradb/row/row0sel.c
index fca3c90109f..52a6263efe5 100644
--- a/storage/xtradb/row/row0sel.c
+++ b/storage/xtradb/row/row0sel.c
@@ -3443,7 +3443,7 @@ row_search_idx_cond_check(
index, if the case of the column has been updated in
the past, or a record has been deleted and a record
inserted in a different case. */
- result = innobase_index_cond(prebuilt->idx_cond);
+ result = handler_index_cond_check(prebuilt->idx_cond);
switch (result) {
case ICP_MATCH:
/* Convert the remaining fields to MySQL format.