mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 20:12:31 +01:00
Re-initialization reworked
This commit is contained in:
parent
430f63c271
commit
b76a8595c6
2 changed files with 54 additions and 23 deletions
|
@ -333,6 +333,9 @@ int Mrr_ordered_index_reader::get_next(char **range_info_arg)
|
||||||
{
|
{
|
||||||
DBUG_ENTER("Mrr_ordered_index_reader::get_next");
|
DBUG_ENTER("Mrr_ordered_index_reader::get_next");
|
||||||
|
|
||||||
|
if (!know_key_tuple_params) /* We're in startup phase */
|
||||||
|
DBUG_RETURN(HA_ERR_END_OF_FILE);
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
bool have_record= FALSE;
|
bool have_record= FALSE;
|
||||||
|
@ -352,7 +355,7 @@ int Mrr_ordered_index_reader::get_next(char **range_info_arg)
|
||||||
{
|
{
|
||||||
if (key_buffer->is_empty())
|
if (key_buffer->is_empty())
|
||||||
{
|
{
|
||||||
if (auto_refill)
|
/*if (auto_refill)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
if ((res= refill_buffer()))
|
if ((res= refill_buffer()))
|
||||||
|
@ -364,6 +367,7 @@ int Mrr_ordered_index_reader::get_next(char **range_info_arg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
*/
|
||||||
{
|
{
|
||||||
/* Buffer refills are managed by somebody else for us */
|
/* Buffer refills are managed by somebody else for us */
|
||||||
index_scan_eof= TRUE;
|
index_scan_eof= TRUE;
|
||||||
|
@ -522,9 +526,10 @@ int Mrr_ordered_rndpos_reader::init(handler *h_arg,
|
||||||
//if (!(mode & HA_MRR_NO_ASSOCIATION))
|
//if (!(mode & HA_MRR_NO_ASSOCIATION))
|
||||||
// rowid_buff_elem_size += sizeof(char*);
|
// rowid_buff_elem_size += sizeof(char*);
|
||||||
|
|
||||||
int res= index_reader->refill_buffer();
|
index_reader_exhausted= FALSE;
|
||||||
if (res && res!=HA_ERR_END_OF_FILE)
|
///int res= index_reader->refill_buffer();
|
||||||
return res;
|
///if (res && res!=HA_ERR_END_OF_FILE)
|
||||||
|
/// return res;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -547,12 +552,35 @@ int Mrr_ordered_rndpos_reader::init(handler *h_arg,
|
||||||
@retval other Error
|
@retval other Error
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
int Mrr_ordered_rndpos_reader::refill_buffer()
|
int Mrr_ordered_rndpos_reader::refill_buffer()
|
||||||
|
{
|
||||||
|
int res;
|
||||||
|
DBUG_ENTER("Mrr_ordered_rndpos_reader::refill_buffer");
|
||||||
|
|
||||||
|
if (index_reader_exhausted)
|
||||||
|
DBUG_RETURN(HA_ERR_END_OF_FILE);
|
||||||
|
|
||||||
|
while ((res= refill2() == HA_ERR_END_OF_FILE))
|
||||||
|
{
|
||||||
|
if ((res= index_reader->refill_buffer()))
|
||||||
|
{
|
||||||
|
if (res == HA_ERR_END_OF_FILE)
|
||||||
|
index_reader_exhausted= TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DBUG_RETURN(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* This one refills without calling index_reader->refill_buffer(). */
|
||||||
|
int Mrr_ordered_rndpos_reader::refill2()
|
||||||
{
|
{
|
||||||
char *range_info;
|
char *range_info;
|
||||||
uchar **range_info_ptr= (uchar**)&range_info;
|
uchar **range_info_ptr= (uchar**)&range_info;
|
||||||
int res;
|
int res;
|
||||||
DBUG_ENTER("Mrr_ordered_rndpos_reader::refill_buffer");
|
DBUG_ENTER("Mrr_ordered_rndpos_reader::refill2");
|
||||||
|
|
||||||
DBUG_ASSERT(rowid_buffer->is_empty());
|
DBUG_ASSERT(rowid_buffer->is_empty());
|
||||||
index_rowid= index_reader->get_rowid_ptr();
|
index_rowid= index_reader->get_rowid_ptr();
|
||||||
|
@ -563,9 +591,6 @@ int Mrr_ordered_rndpos_reader::refill_buffer()
|
||||||
|
|
||||||
last_identical_rowid= NULL;
|
last_identical_rowid= NULL;
|
||||||
|
|
||||||
if (index_reader->eof())
|
|
||||||
DBUG_RETURN(HA_ERR_END_OF_FILE);
|
|
||||||
|
|
||||||
while (rowid_buffer->can_write())
|
while (rowid_buffer->can_write())
|
||||||
{
|
{
|
||||||
res= index_reader->get_next(&range_info);
|
res= index_reader->get_next(&range_info);
|
||||||
|
@ -579,17 +604,13 @@ int Mrr_ordered_rndpos_reader::refill_buffer()
|
||||||
rowid_buffer->write();
|
rowid_buffer->write();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res && res != HA_ERR_END_OF_FILE)
|
|
||||||
DBUG_RETURN(res);
|
|
||||||
|
|
||||||
|
|
||||||
/* Sort the buffer contents by rowid */
|
/* Sort the buffer contents by rowid */
|
||||||
rowid_buffer->sort((qsort2_cmp)rowid_cmp_reverse, (void*)h);
|
rowid_buffer->sort((qsort2_cmp)rowid_cmp_reverse, (void*)h);
|
||||||
|
|
||||||
rowid_buffer->setup_reading(&rowid, h->ref_length,
|
rowid_buffer->setup_reading(&rowid, h->ref_length,
|
||||||
is_mrr_assoc? (uchar**)&rowids_range_id: NULL,
|
is_mrr_assoc? (uchar**)&rowids_range_id: NULL,
|
||||||
sizeof(void*));
|
sizeof(void*));
|
||||||
DBUG_RETURN((rowid_buffer->is_empty() && res) ? HA_ERR_END_OF_FILE : 0);
|
DBUG_RETURN(rowid_buffer->is_empty()? HA_ERR_END_OF_FILE : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -630,6 +651,7 @@ int Mrr_ordered_rndpos_reader::get_next(char **range_info)
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
if (rowid_buffer->is_empty()) /* We're out of rowids */
|
if (rowid_buffer->is_empty()) /* We're out of rowids */
|
||||||
{
|
{
|
||||||
/* First, finish off the sorted keys we have */
|
/* First, finish off the sorted keys we have */
|
||||||
|
@ -647,12 +669,12 @@ int Mrr_ordered_rndpos_reader::get_next(char **range_info)
|
||||||
reader, then refill us.
|
reader, then refill us.
|
||||||
*/
|
*/
|
||||||
// TODO: if key buffer is empty, too, redistribute the buffer space.
|
// TODO: if key buffer is empty, too, redistribute the buffer space.
|
||||||
|
|
||||||
if ((res= index_reader->refill_buffer()) ||
|
if ((res= index_reader->refill_buffer()) ||
|
||||||
(res= refill_buffer()))
|
(res= refill_buffer()))
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
last_identical_rowid= NULL;
|
last_identical_rowid= NULL;
|
||||||
|
|
||||||
|
@ -795,8 +817,8 @@ int DsMrr_impl::dsmrr_init(handler *h_arg, RANGE_SEQ_IF *seq_funcs,
|
||||||
|
|
||||||
if (strategy == index_strategy)
|
if (strategy == index_strategy)
|
||||||
{
|
{
|
||||||
if (ordered_idx_reader)
|
///if (ordered_idx_reader)
|
||||||
ordered_idx_reader->auto_refill= TRUE;
|
// ordered_idx_reader->auto_refill= TRUE;
|
||||||
/* Index strategy serves it all. We don't need two handlers, etc */
|
/* Index strategy serves it all. We don't need two handlers, etc */
|
||||||
/* Give the buffer to index strategy */
|
/* Give the buffer to index strategy */
|
||||||
if ((res= index_strategy->init(h, seq_funcs, seq_init_param, n_ranges,
|
if ((res= index_strategy->init(h, seq_funcs, seq_init_param, n_ranges,
|
||||||
|
@ -815,8 +837,8 @@ int DsMrr_impl::dsmrr_init(handler *h_arg, RANGE_SEQ_IF *seq_funcs,
|
||||||
if ((res= setup_two_handlers()))
|
if ((res= setup_two_handlers()))
|
||||||
DBUG_RETURN(res);
|
DBUG_RETURN(res);
|
||||||
|
|
||||||
if (ordered_idx_reader)
|
///if (ordered_idx_reader)
|
||||||
ordered_idx_reader->auto_refill= FALSE;
|
/// ordered_idx_reader->auto_refill= FALSE;
|
||||||
|
|
||||||
if ((res= index_strategy->init(h2, seq_funcs, seq_init_param, n_ranges,
|
if ((res= index_strategy->init(h2, seq_funcs, seq_init_param, n_ranges,
|
||||||
mode, this)) ||
|
mode, this)) ||
|
||||||
|
@ -827,7 +849,7 @@ int DsMrr_impl::dsmrr_init(handler *h_arg, RANGE_SEQ_IF *seq_funcs,
|
||||||
}
|
}
|
||||||
|
|
||||||
res= strategy->refill_buffer();
|
res= strategy->refill_buffer();
|
||||||
if (res && res != HA_ERR_END_OF_FILE)
|
if (res && res != HA_ERR_END_OF_FILE) //psergey-todo: remove EOF check here
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1215,7 +1237,14 @@ void Key_value_records_iterator::close()
|
||||||
|
|
||||||
int DsMrr_impl::dsmrr_next(char **range_info)
|
int DsMrr_impl::dsmrr_next(char **range_info)
|
||||||
{
|
{
|
||||||
return strategy->get_next(range_info);
|
int res;
|
||||||
|
while ((res= strategy->get_next(range_info)) == HA_ERR_END_OF_FILE)
|
||||||
|
{
|
||||||
|
if ((res= strategy->refill_buffer()))
|
||||||
|
break; /* EOF or error */
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
//return strategy->get_next(range_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -233,7 +233,7 @@ private:
|
||||||
RANGE_SEQ_IF mrr_funcs;
|
RANGE_SEQ_IF mrr_funcs;
|
||||||
range_seq_t mrr_iter;
|
range_seq_t mrr_iter;
|
||||||
|
|
||||||
bool auto_refill;
|
//bool auto_refill;
|
||||||
|
|
||||||
bool index_scan_eof;
|
bool index_scan_eof;
|
||||||
|
|
||||||
|
@ -256,6 +256,7 @@ public:
|
||||||
Lifo_buffer *buf);
|
Lifo_buffer *buf);
|
||||||
int get_next(char **range_info);
|
int get_next(char **range_info);
|
||||||
int refill_buffer();
|
int refill_buffer();
|
||||||
|
int refill2();
|
||||||
void cleanup();
|
void cleanup();
|
||||||
private:
|
private:
|
||||||
handler *h;
|
handler *h;
|
||||||
|
@ -264,6 +265,7 @@ private:
|
||||||
/* This what we get (rowid, range_info) pairs from */
|
/* This what we get (rowid, range_info) pairs from */
|
||||||
Mrr_index_reader *index_reader;
|
Mrr_index_reader *index_reader;
|
||||||
uchar *index_rowid;
|
uchar *index_rowid;
|
||||||
|
bool index_reader_exhausted;
|
||||||
|
|
||||||
/* TRUE <=> need range association, buffers hold {rowid, range_id} pairs */
|
/* TRUE <=> need range association, buffers hold {rowid, range_id} pairs */
|
||||||
bool is_mrr_assoc;
|
bool is_mrr_assoc;
|
||||||
|
|
Loading…
Reference in a new issue