mirror of
https://github.com/MariaDB/server.git
synced 2025-01-26 16:54:15 +01:00
MDEV-12404: Add assertions about Index Condition Pushdown use
Add assertions about limitations one has when using Index Condition Pushdown: - add handler::assert_icp_limitations() - call this function from functions that may attempt violations. Verified that assert_icp_limitations() as well as calls to it are compiled away in release build.
This commit is contained in:
parent
ee3d4ec414
commit
159b7ca3f2
2 changed files with 23 additions and 0 deletions
|
@ -3688,6 +3688,7 @@ int handler::ha_index_read_map(uchar *buf, const uchar *key,
|
||||||
DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE ||
|
DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE ||
|
||||||
m_lock_type != F_UNLCK);
|
m_lock_type != F_UNLCK);
|
||||||
DBUG_ASSERT(inited==INDEX);
|
DBUG_ASSERT(inited==INDEX);
|
||||||
|
assert_icp_limitations(buf);
|
||||||
|
|
||||||
TABLE_IO_WAIT(tracker, PSI_TABLE_FETCH_ROW, active_index, result,
|
TABLE_IO_WAIT(tracker, PSI_TABLE_FETCH_ROW, active_index, result,
|
||||||
{ result= index_read_map(buf, key, keypart_map, find_flag); })
|
{ result= index_read_map(buf, key, keypart_map, find_flag); })
|
||||||
|
@ -3738,6 +3739,7 @@ int handler::ha_index_next(uchar * buf)
|
||||||
DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE ||
|
DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE ||
|
||||||
m_lock_type != F_UNLCK);
|
m_lock_type != F_UNLCK);
|
||||||
DBUG_ASSERT(inited==INDEX);
|
DBUG_ASSERT(inited==INDEX);
|
||||||
|
assert_icp_limitations(buf);
|
||||||
|
|
||||||
TABLE_IO_WAIT(tracker, PSI_TABLE_FETCH_ROW, active_index, result,
|
TABLE_IO_WAIT(tracker, PSI_TABLE_FETCH_ROW, active_index, result,
|
||||||
{ result= index_next(buf); })
|
{ result= index_next(buf); })
|
||||||
|
@ -3755,6 +3757,23 @@ int handler::ha_index_next(uchar * buf)
|
||||||
DBUG_RETURN(result);
|
DBUG_RETURN(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void handler::assert_icp_limitations(uchar *buf)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
If we are using ICP, we must read the row to table->record[0], as
|
||||||
|
pushed_idx_cond has Item_field objects that refer to table->record[0].
|
||||||
|
*/
|
||||||
|
DBUG_ASSERT(!(pushed_idx_cond && active_index == pushed_idx_cond_keyno) ||
|
||||||
|
(buf == table->record[0]));
|
||||||
|
/*
|
||||||
|
Also check that table fields were not "moved" with move_fields(). InnoDB
|
||||||
|
calls Field::offset() and null_offset() which require this.
|
||||||
|
*/
|
||||||
|
DBUG_ASSERT(table->field[0]->ptr >= table->record[0] &&
|
||||||
|
table->field[0]->ptr <= table->record[0] + table->s->reclength);
|
||||||
|
}
|
||||||
|
|
||||||
int handler::ha_index_prev(uchar * buf)
|
int handler::ha_index_prev(uchar * buf)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
@ -3782,6 +3801,7 @@ int handler::ha_index_first(uchar * buf)
|
||||||
DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE ||
|
DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE ||
|
||||||
m_lock_type != F_UNLCK);
|
m_lock_type != F_UNLCK);
|
||||||
DBUG_ASSERT(inited==INDEX);
|
DBUG_ASSERT(inited==INDEX);
|
||||||
|
assert_icp_limitations(buf);
|
||||||
|
|
||||||
TABLE_IO_WAIT(tracker, PSI_TABLE_FETCH_ROW, active_index, result,
|
TABLE_IO_WAIT(tracker, PSI_TABLE_FETCH_ROW, active_index, result,
|
||||||
{ result= index_first(buf); })
|
{ result= index_first(buf); })
|
||||||
|
@ -3822,6 +3842,7 @@ int handler::ha_index_next_same(uchar *buf, const uchar *key, uint keylen)
|
||||||
DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE ||
|
DBUG_ASSERT(table_share->tmp_table != NO_TMP_TABLE ||
|
||||||
m_lock_type != F_UNLCK);
|
m_lock_type != F_UNLCK);
|
||||||
DBUG_ASSERT(inited==INDEX);
|
DBUG_ASSERT(inited==INDEX);
|
||||||
|
assert_icp_limitations(buf);
|
||||||
|
|
||||||
TABLE_IO_WAIT(tracker, PSI_TABLE_FETCH_ROW, active_index, result,
|
TABLE_IO_WAIT(tracker, PSI_TABLE_FETCH_ROW, active_index, result,
|
||||||
{ result= index_next_same(buf, key, keylen); })
|
{ result= index_next_same(buf, key, keylen); })
|
||||||
|
|
|
@ -4772,6 +4772,8 @@ public:
|
||||||
in_range_check_pushed_down= false;
|
in_range_check_pushed_down= false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void assert_icp_limitations(uchar *buf);
|
||||||
|
|
||||||
virtual void cancel_pushed_rowid_filter()
|
virtual void cancel_pushed_rowid_filter()
|
||||||
{
|
{
|
||||||
pushed_rowid_filter= NULL;
|
pushed_rowid_filter= NULL;
|
||||||
|
|
Loading…
Add table
Reference in a new issue