Commit 68929e8e authored by Igor Babaev's avatar Igor Babaev

Some corrections of the merge for the partition code.

parent 4aa9b285
...@@ -3674,27 +3674,31 @@ int ha_partition::start_stmt(THD *thd, thr_lock_type lock_type) ...@@ -3674,27 +3674,31 @@ int ha_partition::start_stmt(THD *thd, thr_lock_type lock_type)
} }
/* /**
Get number of lock objects returned in store_lock Get number of lock objects returned in store_lock
SYNOPSIS @returns Number of locks returned in call to store_lock
lock_count()
RETURN VALUE
Number of locks returned in call to store_lock
DESCRIPTION @desc
Returns the number of store locks needed in call to store lock. Returns the number of store locks needed in call to store lock.
We return number of partitions since we call store_lock on each We return number of partitions we will lock multiplied with number of
underlying handler. Assists the above functions in allocating locks needed by each partition. Assists the above functions in allocating
sufficient space for lock structures. sufficient space for lock structures.
*/ */
uint ha_partition::lock_count() const uint ha_partition::lock_count() const
{ {
DBUG_ENTER("ha_partition::lock_count"); DBUG_ENTER("ha_partition::lock_count");
DBUG_PRINT("info", ("m_num_locks %d", m_num_locks)); /*
DBUG_RETURN(m_num_locks); The caller want to know the upper bound, to allocate enough memory.
There is no performance lost if we simply return maximum number locks
needed, only some minor over allocation of memory in get_lock_data().
Also notice that this may be called for another thread != table->in_use,
when mysql_lock_abort_for_thread() is called. So this is more safe, then
using number of partitions after pruning.
*/
DBUG_RETURN(m_tot_parts * m_num_locks);
} }
...@@ -5785,7 +5789,7 @@ int ha_partition::handle_ordered_index_scan(uchar *buf, bool reverse_order) ...@@ -5785,7 +5789,7 @@ int ha_partition::handle_ordered_index_scan(uchar *buf, bool reverse_order)
*/ */
queue_set_max_at_top(&m_queue, reverse_order); queue_set_max_at_top(&m_queue, reverse_order);
queue_set_cmp_arg(&m_queue, (void*)m_curr_key_info); queue_set_cmp_arg(&m_queue, (void*)m_curr_key_info);
m_queue.elements= j; m_queue.elements= j - queue_first_element(&m_queue);
queue_fix(&m_queue); queue_fix(&m_queue);
return_top_record(buf); return_top_record(buf);
table->status= 0; table->status= 0;
......
...@@ -1359,6 +1359,9 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, ...@@ -1359,6 +1359,9 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
share->db_type()))) share->db_type())))
goto err; goto err;
if (handler_file->set_ha_share_ref(&share->ha_share))
goto err;
record= share->default_values-1; /* Fieldstart = 1 */ record= share->default_values-1; /* Fieldstart = 1 */
null_bits_are_used= share->null_fields != 0; null_bits_are_used= share->null_fields != 0;
if (share->null_field_first) if (share->null_field_first)
...@@ -2362,6 +2365,9 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias, ...@@ -2362,6 +2365,9 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias,
if (!(outparam->file= get_new_handler(share, &outparam->mem_root, if (!(outparam->file= get_new_handler(share, &outparam->mem_root,
share->db_type()))) share->db_type())))
goto err; goto err;
if (outparam->file->set_ha_share_ref(&share->ha_share))
goto err;
} }
else else
{ {
......
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