diff options
author | Sergey Petrunya <psergey@askmonty.org> | 2009-12-15 10:16:46 +0300 |
---|---|---|
committer | Sergey Petrunya <psergey@askmonty.org> | 2009-12-15 10:16:46 +0300 |
commit | 96e092dc73529978053c1e41aa09b70fd2c7c408 (patch) | |
tree | b6e8286b05a0b2e8772ec6da055337812d60b3e8 /storage/maria/ma_rkey.c | |
parent | e4e1ae0d13da399d53bd91df791b149f3eae796b (diff) | |
download | mariadb-git-96e092dc73529978053c1e41aa09b70fd2c7c408.tar.gz |
Backport into MariaDB-5.2 the following:
WL#2474 "Multi Range Read: Change the default MRR implementation to implement new MRR interface"
WL#2475 "Batched range read functions for MyISAM/InnoDb"
"Index condition pushdown for MyISAM/InnoDB"
Igor's fix from sp1r-igor@olga.mysql.com-20080330055902-07614:
There could be observed the following problems:
1. EXPLAIN did not mention pushdown conditions from on expressions in the
'extra' column. As a result if a query had no where conditions pushed
down to a table, but had on conditions pushed to this table the 'extra'
column in the EXPLAIN for the table missed 'using where'.
2. Conditions for ref access were not eliminated from on expressions
though such conditions were eliminated from the where condition.
Diffstat (limited to 'storage/maria/ma_rkey.c')
-rw-r--r-- | storage/maria/ma_rkey.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/storage/maria/ma_rkey.c b/storage/maria/ma_rkey.c index 9e529aca666..32a0e141b1d 100644 --- a/storage/maria/ma_rkey.c +++ b/storage/maria/ma_rkey.c @@ -34,6 +34,7 @@ int maria_rkey(MARIA_HA *info, uchar *buf, int inx, const uchar *key_data, HA_KEYSEG *last_used_keyseg; uint32 nextflag; MARIA_KEY key; + int icp_res= 1; DBUG_ENTER("maria_rkey"); DBUG_PRINT("enter", ("base: 0x%lx buf: 0x%lx inx: %d search_flag: %d", (long) info, (long) buf, inx, search_flag)); @@ -106,9 +107,13 @@ int maria_rkey(MARIA_HA *info, uchar *buf, int inx, const uchar *key_data, are inserted by other threads after we got our table lock ("concurrent inserts"). The record may not even be present yet. Keys are inserted into the index(es) before the record is - inserted into the data file. + inserted into the data file. + + If index condition is present, it must be either satisfied or + not satisfied with an out-of-range condition. */ - if ((*share->row_is_visible)(info)) + if ((*share->row_is_visible)(info) && + ((icp_res= ma_check_index_cond(info, inx, buf)) != 0)) break; /* The key references a concurrently inserted record. */ @@ -120,7 +125,7 @@ int maria_rkey(MARIA_HA *info, uchar *buf, int inx, const uchar *key_data, info->cur_row.lastpos= HA_OFFSET_ERROR; break; } - + do { uint not_used[2]; @@ -151,18 +156,25 @@ int maria_rkey(MARIA_HA *info, uchar *buf, int inx, const uchar *key_data, break; /* purecov: end */ } - } while (!(*share->row_is_visible)(info)); + + } while (!(*share->row_is_visible)(info) || + ((icp_res= ma_check_index_cond(info, inx, buf)) == 0)); } } if (share->lock_key_trees) rw_unlock(&keyinfo->root_lock); - if (info->cur_row.lastpos == HA_OFFSET_ERROR) + if (info->cur_row.lastpos == HA_OFFSET_ERROR || (icp_res != 1)) { + if (icp_res == 2) + { + info->cur_row.lastpos= HA_OFFSET_ERROR; + my_errno= HA_ERR_KEY_NOT_FOUND; + } fast_ma_writeinfo(info); goto err; } - + /* Calculate length of the found key; Used by maria_rnext_same */ if ((keyinfo->flag & HA_VAR_LENGTH_KEY)) info->last_rkey_length= _ma_keylength_part(keyinfo, info->lastkey_buff, |