Commit 0d5d68f6 authored by Sergey Petrunya's avatar Sergey Petrunya

Merge in MRR interface fixes.

parents e59d5603 e6bd643c
......@@ -543,11 +543,13 @@ typedef struct st_key_range
enum ha_rkey_function flag;
} key_range;
typedef void *range_id_t;
typedef struct st_key_multi_range
{
key_range start_key;
key_range end_key;
char *ptr; /* Free to use by caller (ptr to row etc) */
range_id_t ptr; /* Free to use by caller (ptr to row etc) */
uint range_flag; /* key range flags see above */
} KEY_MULTI_RANGE;
......
......@@ -1218,7 +1218,7 @@ typedef struct st_range_seq_if
out from the stream of records returned by multi_range_read_next()
0 - The record shall be left in the stream
*/
bool (*skip_record) (range_seq_t seq, char *range_info, uchar *rowid);
bool (*skip_record) (range_seq_t seq, range_id_t range_info, uchar *rowid);
/*
Check if the record combination matches the index condition
......@@ -1231,10 +1231,10 @@ typedef struct st_range_seq_if
0 - The record combination satisfies the index condition
1 - Otherwise
*/
bool (*skip_index_tuple) (range_seq_t seq, char *range_info);
bool (*skip_index_tuple) (range_seq_t seq, range_id_t range_info);
} RANGE_SEQ_IF;
typedef bool (*SKIP_INDEX_TUPLE_FUNC) (range_seq_t seq, char *range_info);
typedef bool (*SKIP_INDEX_TUPLE_FUNC) (range_seq_t seq, range_id_t range_info);
class COST_VECT
{
......@@ -1870,7 +1870,7 @@ public:
virtual int multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param,
uint n_ranges, uint mode,
HANDLER_BUFFER *buf);
virtual int multi_range_read_next(char **range_info);
virtual int multi_range_read_next(range_id_t *range_info);
virtual int read_range_first(const key_range *start_key,
const key_range *end_key,
bool eq_range, bool sorted);
......
......@@ -227,7 +227,7 @@ handler::multi_range_read_init(RANGE_SEQ_IF *seq_funcs, void *seq_init_param,
@retval other Error code
*/
int handler::multi_range_read_next(char **range_info)
int handler::multi_range_read_next(range_id_t *range_info)
{
int result= HA_ERR_END_OF_FILE;
bool range_res;
......@@ -306,7 +306,7 @@ int Mrr_simple_index_reader::init(handler *h_arg, RANGE_SEQ_IF *seq_funcs,
}
int Mrr_simple_index_reader::get_next(char **range_info)
int Mrr_simple_index_reader::get_next(range_id_t *range_info)
{
int res;
while (!(res= file->handler::multi_range_read_next(range_info)))
......@@ -338,7 +338,7 @@ int Mrr_simple_index_reader::get_next(char **range_info)
@retval Other Some other error; Error is printed
*/
int Mrr_ordered_index_reader::get_next(char **range_info)
int Mrr_ordered_index_reader::get_next(range_id_t *range_info)
{
int res;
DBUG_ENTER("Mrr_ordered_index_reader::get_next");
......@@ -481,7 +481,7 @@ int Mrr_ordered_index_reader::refill_buffer(bool initial)
buf_manager->reset_buffer_sizes(buf_manager->arg);
key_buffer->reset();
key_buffer->setup_writing(keypar.key_size_in_keybuf,
is_mrr_assoc? sizeof(char*) : 0);
is_mrr_assoc? sizeof(range_id_t) : 0);
while (key_buffer->can_write() &&
!(source_exhausted= mrr_funcs.next(mrr_iter, &cur_range)))
......@@ -610,7 +610,7 @@ void Mrr_index_reader::position()
int Mrr_ordered_rndpos_reader::refill_from_index_reader()
{
char *range_info;
range_id_t range_info;
int res;
DBUG_ENTER("Mrr_ordered_rndpos_reader::refill_from_index_reader");
......@@ -618,7 +618,7 @@ int Mrr_ordered_rndpos_reader::refill_from_index_reader()
index_rowid= index_reader->get_rowid_ptr();
rowid_buffer->reset();
rowid_buffer->setup_writing(file->ref_length,
is_mrr_assoc? sizeof(char*) : 0);
is_mrr_assoc? sizeof(range_id_t) : 0);
last_identical_rowid= NULL;
......@@ -648,7 +648,7 @@ int Mrr_ordered_rndpos_reader::refill_from_index_reader()
rowid_buffer->sort((qsort2_cmp)rowid_cmp_reverse, (void*)file);
rowid_buffer->setup_reading(file->ref_length,
is_mrr_assoc ? sizeof(char*) : 0);
is_mrr_assoc ? sizeof(range_id_t) : 0);
DBUG_RETURN(rowid_buffer->is_empty()? HA_ERR_END_OF_FILE : 0);
}
......@@ -661,7 +661,7 @@ int Mrr_ordered_rndpos_reader::refill_from_index_reader()
with the same rowid value.
*/
int Mrr_ordered_rndpos_reader::get_next(char **range_info)
int Mrr_ordered_rndpos_reader::get_next(range_id_t *range_info)
{
int res;
......@@ -684,8 +684,8 @@ int Mrr_ordered_rndpos_reader::get_next(char **range_info)
if (!is_mrr_assoc)
return 0;
memcpy(range_info, rowid_buffer->read_ptr2, sizeof(uchar*));
if (!index_reader->skip_record((char*)*range_info, rowid_buffer->read_ptr1))
memcpy(range_info, rowid_buffer->read_ptr2, sizeof(range_id_t));
if (!index_reader->skip_record(*range_info, rowid_buffer->read_ptr1))
return 0;
}
......@@ -701,7 +701,7 @@ int Mrr_ordered_rndpos_reader::get_next(char **range_info)
if (is_mrr_assoc)
{
memcpy(range_info, rowid_buffer->read_ptr2, sizeof(uchar*));
memcpy(range_info, rowid_buffer->read_ptr2, sizeof(range_id_t));
if (index_reader->skip_record(*range_info, rowid_buffer->read_ptr1))
continue;
}
......@@ -899,7 +899,7 @@ int DsMrr_impl::dsmrr_init(handler *h_arg, RANGE_SEQ_IF *seq_funcs,
/* index strategy doesn't need buffer, give all space to rowids*/
rowid_buffer.set_buffer_space(full_buf, full_buf_end);
if (!rowid_buffer.have_space_for(primary_file->ref_length +
(int)is_mrr_assoc * sizeof(char*)))
(int)is_mrr_assoc * sizeof(range_id_t)))
goto use_default_impl;
}
......@@ -1139,7 +1139,7 @@ bool DsMrr_impl::setup_buffer_sharing(uint key_size_in_keybuf,
key_part_map key_tuple_map)
{
long key_buff_elem_size= key_size_in_keybuf +
(int)is_mrr_assoc * sizeof(void*);
(int)is_mrr_assoc * sizeof(range_id_t);
KEY *key_info= &primary_file->get_table()->key_info[keyno];
/*
......@@ -1147,7 +1147,7 @@ bool DsMrr_impl::setup_buffer_sharing(uint key_size_in_keybuf,
for keys and another part for rowids.
*/
ulonglong rowid_buf_elem_size= primary_file->ref_length +
(int)is_mrr_assoc * sizeof(char*);
(int)is_mrr_assoc * sizeof(range_id_t);
/*
Use rec_per_key statistics as a basis to find out how many rowids
......@@ -1284,7 +1284,7 @@ int Key_value_records_iterator::init(Mrr_ordered_index_reader *owner_arg)
}
int Key_value_records_iterator::get_next(char **range_info)
int Key_value_records_iterator::get_next(range_id_t *range_info)
{
int res;
......@@ -1310,7 +1310,7 @@ int Key_value_records_iterator::get_next(char **range_info)
}
identical_key_it.read(); /* This gets us next range_id */
memcpy(range_info, identical_key_it.read_ptr2, sizeof(char*));
memcpy(range_info, identical_key_it.read_ptr2, sizeof(range_id_t));
if (!last_identical_key_ptr ||
(identical_key_it.read_ptr1 == last_identical_key_ptr))
......@@ -1339,7 +1339,7 @@ void Key_value_records_iterator::move_to_next_key_value()
Calling convention is like multi_range_read_next() has.
*/
int DsMrr_impl::dsmrr_next(char **range_info)
int DsMrr_impl::dsmrr_next(range_id_t *range_info)
{
int res;
if (strategy_exhausted)
......
......@@ -135,7 +135,7 @@ class Key_value_records_iterator
public:
int init(Mrr_ordered_index_reader *owner_arg);
int get_next(char **range_info);
int get_next(range_id_t *range_info);
void move_to_next_key_value();
};
......@@ -186,7 +186,7 @@ public:
class Mrr_reader
{
public:
virtual int get_next(char **range_info) = 0;
virtual int get_next(range_id_t *range_info) = 0;
virtual int refill_buffer(bool initial) = 0;
virtual ~Mrr_reader() {}; /* just to remove compiler warning */
};
......@@ -211,7 +211,7 @@ public:
virtual uchar *get_rowid_ptr() = 0;
/* Get the rowid (call this after get_next() call) */
virtual void position();
virtual bool skip_record(char *range_id, uchar *rowid) = 0;
virtual bool skip_record(range_id_t range_id, uchar *rowid) = 0;
virtual void interrupt_read() {}
virtual void resume_read() {}
......@@ -232,10 +232,10 @@ public:
uint mode, Key_parameters *key_par,
Lifo_buffer *key_buffer,
Buffer_manager *buf_manager_arg);
int get_next(char **range_info);
int get_next(range_id_t *range_info);
int refill_buffer(bool initial) { return initial? 0: HA_ERR_END_OF_FILE; }
uchar *get_rowid_ptr() { return file->ref; }
bool skip_record(char *range_id, uchar *rowid)
bool skip_record(range_id_t range_id, uchar *rowid)
{
return (file->mrr_funcs.skip_record &&
file->mrr_funcs.skip_record(file->mrr_iter, range_id, rowid));
......@@ -255,17 +255,17 @@ public:
uint mode, Key_parameters *key_par,
Lifo_buffer *key_buffer,
Buffer_manager *buf_manager_arg);
int get_next(char **range_info);
int get_next(range_id_t *range_info);
int refill_buffer(bool initial);
uchar *get_rowid_ptr() { return file->ref; }
bool skip_record(char *range_info, uchar *rowid)
bool skip_record(range_id_t range_info, uchar *rowid)
{
return (mrr_funcs.skip_record &&
mrr_funcs.skip_record(mrr_iter, range_info, rowid));
}
bool skip_index_tuple(char *range_info)
bool skip_index_tuple(range_id_t range_info)
{
return (mrr_funcs.skip_index_tuple &&
mrr_funcs.skip_index_tuple(mrr_iter, range_info));
......@@ -343,7 +343,7 @@ class Mrr_ordered_rndpos_reader : public Mrr_reader
public:
int init(handler *file, Mrr_index_reader *index_reader, uint mode,
Lifo_buffer *buf);
int get_next(char **range_info);
int get_next(range_id_t *range_info);
int refill_buffer(bool initial);
private:
handler *file; /* Handler to use */
......@@ -540,7 +540,7 @@ public:
void *seq_init_param, uint n_ranges, uint mode,
HANDLER_BUFFER *buf);
void dsmrr_close();
int dsmrr_next(char **range_info);
int dsmrr_next(range_id_t *range_info);
ha_rows dsmrr_info(uint keyno, uint n_ranges, uint keys, uint key_parts,
uint *bufsz, uint *flags, COST_VECT *cost);
......
......@@ -10519,7 +10519,7 @@ int QUICK_RANGE_SELECT::reset()
int QUICK_RANGE_SELECT::get_next()
{
char *dummy;
range_id_t dummy;
DBUG_ENTER("QUICK_RANGE_SELECT::get_next");
if (in_ror_merged_scan)
{
......
......@@ -3712,7 +3712,9 @@ int JOIN_TAB_SCAN_MRR::open()
int JOIN_TAB_SCAN_MRR::next()
{
char **ptr= (char **) cache->get_curr_association_ptr();
int rc= join_tab->table->file->multi_range_read_next(ptr) ? -1 : 0;
DBUG_ASSERT(sizeof(range_id_t) == sizeof(*ptr));
int rc= join_tab->table->file->multi_range_read_next((range_id_t*)ptr) ? -1 : 0;
if (!rc)
{
/*
......@@ -3836,7 +3838,7 @@ bool bka_range_seq_next(range_seq_t rseq, KEY_MULTI_RANGE *range)
*/
static
bool bka_range_seq_skip_record(range_seq_t rseq, char *range_info, uchar *rowid)
bool bka_range_seq_skip_record(range_seq_t rseq, range_id_t range_info, uchar *rowid)
{
DBUG_ENTER("bka_range_seq_skip_record");
JOIN_CACHE_BKA *cache= (JOIN_CACHE_BKA *) rseq;
......@@ -3867,7 +3869,7 @@ bool bka_range_seq_skip_record(range_seq_t rseq, char *range_info, uchar *rowid)
*/
static
bool bka_skip_index_tuple(range_seq_t rseq, char *range_info)
bool bka_skip_index_tuple(range_seq_t rseq, range_id_t range_info)
{
DBUG_ENTER("bka_skip_index_tuple");
JOIN_CACHE_BKA *cache= (JOIN_CACHE_BKA *) rseq;
......@@ -4203,7 +4205,7 @@ start:
0 otherwise
*/
bool JOIN_CACHE_BKA::skip_index_tuple(char *range_info)
bool JOIN_CACHE_BKA::skip_index_tuple(range_id_t range_info)
{
DBUG_ENTER("JOIN_CACHE_BKA::skip_index_tuple");
get_record_by_pos((uchar*)range_info);
......@@ -4311,7 +4313,7 @@ bool bkah_range_seq_next(range_seq_t rseq, KEY_MULTI_RANGE *range)
*/
static
bool bkah_range_seq_skip_record(range_seq_t rseq, char *range_info,
bool bkah_range_seq_skip_record(range_seq_t rseq, range_id_t range_info,
uchar *rowid)
{
DBUG_ENTER("bkah_range_seq_skip_record");
......@@ -4342,7 +4344,7 @@ bool bkah_range_seq_skip_record(range_seq_t rseq, char *range_info,
*/
static
bool bkah_skip_index_tuple(range_seq_t rseq, char *range_info)
bool bkah_skip_index_tuple(range_seq_t rseq, range_id_t range_info)
{
DBUG_ENTER("bka_unique_skip_index_tuple");
JOIN_CACHE_BKAH *cache= (JOIN_CACHE_BKAH *) rseq;
......@@ -4456,7 +4458,7 @@ int JOIN_CACHE_BKAH::init()
*/
bool JOIN_CACHE_BKAH::skip_index_tuple(char *range_info)
bool JOIN_CACHE_BKAH::skip_index_tuple(range_id_t range_info)
{
uchar *last_rec_ref_ptr= get_next_rec_ref((uchar*) range_info);
uchar *next_rec_ref_ptr= last_rec_ref_ptr;
......
......@@ -1313,7 +1313,7 @@ public:
uint get_next_key(uchar **key);
/* Check index condition of the joined table for a record from BKA cache */
bool skip_index_tuple(char *range_info);
bool skip_index_tuple(range_id_t range_info);
};
......@@ -1403,5 +1403,5 @@ public:
enum Join_algorithm get_join_alg() { return BKAH_JOIN_ALG; }
/* Check index condition of the joined table for a record from BKAH cache */
bool skip_index_tuple(char *range_info);
bool skip_index_tuple(range_id_t range_info);
};
......@@ -3633,7 +3633,7 @@ int ha_maria::multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param,
return ds_mrr.dsmrr_init(this, seq, seq_init_param, n_ranges, mode, buf);
}
int ha_maria::multi_range_read_next(char **range_info)
int ha_maria::multi_range_read_next(range_id_t *range_info)
{
return ds_mrr.dsmrr_next(range_info);
}
......
......@@ -178,7 +178,7 @@ public:
*/
int multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param,
uint n_ranges, uint mode, HANDLER_BUFFER *buf);
int multi_range_read_next(char **range_info);
int multi_range_read_next(range_id_t *range_info);
ha_rows multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,
void *seq_init_param,
uint n_ranges, uint *bufsz,
......
......@@ -2245,7 +2245,7 @@ int ha_myisam::multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param,
return ds_mrr.dsmrr_init(this, seq, seq_init_param, n_ranges, mode, buf);
}
int ha_myisam::multi_range_read_next(char **range_info)
int ha_myisam::multi_range_read_next(range_id_t *range_info)
{
return ds_mrr.dsmrr_next(range_info);
}
......
......@@ -162,7 +162,7 @@ public:
*/
int multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param,
uint n_ranges, uint mode, HANDLER_BUFFER *buf);
int multi_range_read_next(char **range_info);
int multi_range_read_next(range_id_t *range_info);
ha_rows multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,
void *seq_init_param,
uint n_ranges, uint *bufsz,
......
......@@ -12052,7 +12052,7 @@ int ha_innobase::multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param,
return ds_mrr.dsmrr_init(this, seq, seq_init_param, n_ranges, mode, buf);
}
int ha_innobase::multi_range_read_next(char **range_info)
int ha_innobase::multi_range_read_next(range_id_t *range_info)
{
return ds_mrr.dsmrr_next(range_info);
}
......
......@@ -229,7 +229,7 @@ public:
*/
int multi_range_read_init(RANGE_SEQ_IF *seq, void *seq_init_param,
uint n_ranges, uint mode, HANDLER_BUFFER *buf);
int multi_range_read_next(char **range_info);
int multi_range_read_next(range_id_t *range_info);
ha_rows multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,
void *seq_init_param,
uint n_ranges, uint *bufsz,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment