1
0
mirror of https://github.com/MariaDB/server.git synced 2026-01-06 05:22:24 +03:00

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"
- Adjust test results (checked)
- Code cleanup.
This commit is contained in:
Sergey Petrunya
2009-12-15 20:23:55 +03:00
parent 2a496c4dcf
commit 59b6472010
22 changed files with 86 additions and 214 deletions

View File

@@ -4193,136 +4193,6 @@ double handler::index_only_read_time(uint keynr, double records)
return read_time;
}
#if 0
// psergey-mrr
/**
Read the first row of a multi-range set.
@param found_range_p Returns a pointer to the element in 'ranges' that
corresponds to the returned row.
@param ranges An array of KEY_MULTI_RANGE range descriptions.
@param range_count Number of ranges in 'ranges'.
@param sorted If result should be sorted per key.
@param buffer A HANDLER_BUFFER for internal handler usage.
@note
- Record is read into table->record[0].
- *found_range_p returns a valid value only if read_multi_range_first()
returns 0.
- Sorting is done within each range. If you want an overall sort, enter
'ranges' with sorted ranges.
@retval
0 OK, found a row
@retval
HA_ERR_END_OF_FILE No rows in range
@retval
\# Error code
*/
int handler::read_multi_range_first(KEY_MULTI_RANGE **found_range_p,
KEY_MULTI_RANGE *ranges, uint range_count,
bool sorted, HANDLER_BUFFER *buffer)
{
int result= HA_ERR_END_OF_FILE;
DBUG_ENTER("handler::read_multi_range_first");
multi_range_sorted= sorted;
multi_range_buffer= buffer;
table->mark_columns_used_by_index_no_reset(active_index, table->read_set);
table->column_bitmaps_set(table->read_set, table->write_set);
for (multi_range_curr= ranges, multi_range_end= ranges + range_count;
multi_range_curr < multi_range_end;
multi_range_curr++)
{
result= read_range_first(multi_range_curr->start_key.keypart_map ?
&multi_range_curr->start_key : 0,
multi_range_curr->end_key.keypart_map ?
&multi_range_curr->end_key : 0,
test(multi_range_curr->range_flag & EQ_RANGE),
multi_range_sorted);
if (result != HA_ERR_END_OF_FILE)
break;
}
*found_range_p= multi_range_curr;
DBUG_PRINT("exit",("result %d", result));
DBUG_RETURN(result);
}
/**
Read the next row of a multi-range set.
@param found_range_p Returns a pointer to the element in 'ranges' that
corresponds to the returned row.
@note
- Record is read into table->record[0].
- *found_range_p returns a valid value only if read_multi_range_next()
returns 0.
@retval
0 OK, found a row
@retval
HA_ERR_END_OF_FILE No (more) rows in range
@retval
\# Error code
*/
int handler::read_multi_range_next(KEY_MULTI_RANGE **found_range_p)
{
int result;
DBUG_ENTER("handler::read_multi_range_next");
/* We should not be called after the last call returned EOF. */
DBUG_ASSERT(multi_range_curr < multi_range_end);
do
{
/* Save a call if there can be only one row in range. */
if (multi_range_curr->range_flag != (UNIQUE_RANGE | EQ_RANGE))
{
result= read_range_next();
/* On success or non-EOF errors jump to the end. */
if (result != HA_ERR_END_OF_FILE)
break;
}
else
{
if (was_semi_consistent_read())
goto scan_it_again;
/*
We need to set this for the last range only, but checking this
condition is more expensive than just setting the result code.
*/
result= HA_ERR_END_OF_FILE;
}
multi_range_curr++;
scan_it_again:
/* Try the next range(s) until one matches a record. */
for (; multi_range_curr < multi_range_end; multi_range_curr++)
{
result= read_range_first(multi_range_curr->start_key.keypart_map ?
&multi_range_curr->start_key : 0,
multi_range_curr->end_key.keypart_map ?
&multi_range_curr->end_key : 0,
test(multi_range_curr->range_flag & EQ_RANGE),
multi_range_sorted);
if (result != HA_ERR_END_OF_FILE)
break;
}
}
while ((result == HA_ERR_END_OF_FILE) &&
(multi_range_curr < multi_range_end));
*found_range_p= multi_range_curr;
DBUG_PRINT("exit",("handler::read_multi_range_next: result %d", result));
DBUG_RETURN(result);
}
#endif
/**
Read first row between two ranges.