Commit 8dc81f47 authored by Sergey Petrunya's avatar Sergey Petrunya

Use reverse/backwards buffer for keys (now works)

- don't allocate space for rowid buffer when we don't really need it.
- fix buffer iterator
parent 0276757d
......@@ -352,14 +352,14 @@ Thimble Smith Happy 3 3
Lilliana Angelovska NULL NULL NULL
select t1.name, t2.name, t2.id,t3.id from t1 right join t2 on (t1.id = t2.owner) right join t1 as t3 on t3.id=t2.owner;
name name id id
Antonio Paz El Gato 1 1
Antonio Paz Perrito 2 1
Antonio Paz El Gato 1 1
Thimble Smith Happy 3 3
NULL NULL NULL 2
select t1.name, t2.name, t2.id, t2.owner, t3.id from t1 left join t2 on (t1.id = t2.owner) right join t1 as t3 on t3.id=t2.owner;
name name id owner id
Antonio Paz El Gato 1 1 1
Antonio Paz Perrito 2 1 1
Antonio Paz El Gato 1 1 1
Thimble Smith Happy 3 3 3
NULL NULL NULL NULL 2
drop table t1,t2;
......@@ -413,9 +413,9 @@ insert into t2 values (1, 2, 3),(2, 2, 8), (4,3,9),(3,2,10);
select t1.*, t2.* from t1 left join t2 on t1.n = t2.n and
t1.m = t2.m where t1.n = 1;
n m o n m o
1 2 11 1 2 3
1 2 7 1 2 3
1 2 9 1 2 3
1 2 7 1 2 3
1 2 11 1 2 3
1 3 9 NULL NULL NULL
select t1.*, t2.* from t1 left join t2 on t1.n = t2.n and
t1.m = t2.m where t1.n = 1 order by t1.o;
......
......@@ -420,7 +420,8 @@ int DsMrr_impl::dsmrr_init(handler *h_arg, RANGE_SEQ_IF *seq_funcs,
}
do_rowid_fetch= FALSE;
doing_cpk_scan= check_cpk_scan(h->active_index, mode);
doing_cpk_scan= check_cpk_scan(h->inited == handler::INDEX?
h->active_index: h2->active_index, mode);
if (!doing_cpk_scan /* && !index_only_read */)
{
/* Will use rowid buffer to store/sort rowids, etc */
......@@ -754,7 +755,21 @@ void DsMrr_impl::setup_buffer_sizes(key_range *sample_key)
key_tuple_length;
key_buff_elem_size= key_size_in_keybuf +
(int)is_mrr_assoc * sizeof(void*);
if (!do_rowid_fetch)
{
/* Give all space to key buffer. */
key_buffer.set_buffer_space(full_buf, full_buf_end, 1);
/* Just in case, tell rowid buffer that it has zero size: */
rowid_buffer.set_buffer_space(full_buf_end, full_buf_end, 1);
return;
}
/*
Ok if we got here we need to allocate one part of the buffer
for keys and another part for rowids.
*/
uint rowid_buf_elem_size= h->ref_length +
(int)is_mrr_assoc * sizeof(char*);
......@@ -790,9 +805,11 @@ void DsMrr_impl::setup_buffer_sizes(key_range *sample_key)
(h->ref_length + (int)is_mrr_assoc * sizeof(char*) + 1));
}
//rowid_buffer.set_buffer_space(full_buf, full_buf + bytes_for_rowids, 1);
//key_buffer.set_buffer_space(full_buf + bytes_for_rowids, full_buf_end, 1);
rowid_buffer.set_buffer_space(full_buf, full_buf + bytes_for_rowids, 1);
key_buffer.set_buffer_space(full_buf + bytes_for_rowids, full_buf_end, 1);
key_buffer.set_buffer_space(full_buf + bytes_for_rowids, full_buf_end, -1);
index_ranges_unique= test(key_info->flags & HA_NOSAME &&
key_info->key_parts ==
my_count_bits(sample_key->keypart_map));
......
......@@ -118,7 +118,7 @@ class SimpleBuffer
}
else
{
if (pos - nbytes <= sb->write_pos)
if (pos - nbytes < sb->write_pos)
return NULL;
pos -= nbytes;
return pos;
......
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