summaryrefslogtreecommitdiff
path: root/storage/myisam/mi_key.c
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2020-05-09 20:43:36 +0200
committerSergei Golubchik <serg@mariadb.org>2020-05-09 20:43:36 +0200
commit13038e4705ed55e24362dfad977a1ee454cfebfd (patch)
treeac3d37fe69e802dec8008748b86cc901f116eead /storage/myisam/mi_key.c
parent72c7b4eb4cc86ca2f6bdb9e105b67d39df018a40 (diff)
parentf5844e7c4bc693783f088a5fc9c399b786ddc8c1 (diff)
downloadmariadb-git-13038e4705ed55e24362dfad977a1ee454cfebfd.tar.gz
Merge branch '10.4' into 10.5
Diffstat (limited to 'storage/myisam/mi_key.c')
-rw-r--r--storage/myisam/mi_key.c89
1 files changed, 57 insertions, 32 deletions
diff --git a/storage/myisam/mi_key.c b/storage/myisam/mi_key.c
index 496fa852f14..ff07920caa8 100644
--- a/storage/myisam/mi_key.c
+++ b/storage/myisam/mi_key.c
@@ -492,58 +492,83 @@ int _mi_read_key_record(MI_INFO *info, my_off_t filepos, uchar *buf)
}
+static
+int mi_unpack_index_tuple(MI_INFO *info, uint keynr, uchar *record)
+{
+ if (_mi_put_key_in_record(info, keynr, FALSE, record))
+ {
+ /* Impossible case; Can only happen if bug in code */
+ mi_print_error(info->s, HA_ERR_CRASHED);
+ info->lastpos= HA_OFFSET_ERROR; /* No active record */
+ my_errno= HA_ERR_CRASHED;
+ return 1;
+ }
+ return 0;
+}
+
+
+static int mi_check_rowid_filter_is_active(MI_INFO *info)
+{
+ if (info->rowid_filter_is_active_func == NULL)
+ return 0;
+ return info->rowid_filter_is_active_func(info->rowid_filter_func_arg);
+}
+
+
/*
- Save current key tuple to record and call index condition check function
+ Check the current index tuple: Check ICP condition and/or Rowid Filter
SYNOPSIS
- mi_check_index_cond()
+ mi_check_index_tuple()
info MyISAM handler
keynr Index we're running a scan on
record Record buffer to use (it is assumed that index check function
will look for column values there)
RETURN
- ICP_ERROR Error
- ICP_NO_MATCH Index condition is not satisfied, continue scanning
- ICP_MATCH Index condition is satisfied
- ICP_OUT_OF_RANGE Index condition is not satisfied, end the scan.
+ Check result according to check_result_t definition
*/
-ICP_RESULT mi_check_index_cond(register MI_INFO *info, uint keynr,
- uchar *record)
+check_result_t mi_check_index_tuple(MI_INFO *info, uint keynr, uchar *record)
{
- ICP_RESULT res;
- if (_mi_put_key_in_record(info, keynr, FALSE, record))
+ int need_unpack= TRUE;
+ check_result_t res= CHECK_POS;
+
+ if (info->index_cond_func)
{
- /* Impossible case; Can only happen if bug in code */
- mi_print_error(info->s, HA_ERR_CRASHED);
- info->lastpos= HA_OFFSET_ERROR; /* No active record */
- my_errno= HA_ERR_CRASHED;
- res= ICP_ERROR;
+ if (mi_unpack_index_tuple(info, keynr, record))
+ res= CHECK_ERROR;
+ else if ((res= info->index_cond_func(info->index_cond_func_arg)) ==
+ CHECK_OUT_OF_RANGE)
+ {
+ /* We got beyond the end of scanned range */
+ info->lastpos= HA_OFFSET_ERROR; /* No active record */
+ my_errno= HA_ERR_END_OF_FILE;
+ }
+
+ /*
+ If we got an error, out-of-range condition, or ICP condition computed to
+ FALSE - we don't need to check the Rowid Filter.
+ */
+ if (res != CHECK_POS)
+ return res;
+
+ need_unpack= FALSE;
}
- else if ((res= info->index_cond_func(info->index_cond_func_arg)) ==
- ICP_OUT_OF_RANGE)
+
+ /* Check the Rowid Filter, if present */
+ if (mi_check_rowid_filter_is_active(info))
{
- /* We got beyond the end of scanned range */
- info->lastpos= HA_OFFSET_ERROR; /* No active record */
- my_errno= HA_ERR_END_OF_FILE;
+ /* Unpack the index tuple if we haven't done it already */
+ if (need_unpack && mi_unpack_index_tuple(info, keynr, record))
+ res= CHECK_ERROR;
+ else
+ res= info->rowid_filter_func(info->rowid_filter_func_arg);
}
return res;
}
-int mi_check_rowid_filter(MI_INFO *info)
-{
- return info->rowid_filter_func(info->rowid_filter_func_arg);
-}
-
-int mi_check_rowid_filter_is_active(MI_INFO *info)
-{
- if (info->rowid_filter_is_active_func == NULL)
- return 0;
- return info->rowid_filter_is_active_func(info->rowid_filter_func_arg);
-}
-
/*
Retrieve auto_increment info