mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Fixes after last merge of MySQL 5.1
- INSERT with RAND() doesn't require row based logging again - Some bugs fixed in opt_range() where we table->key_read was wrongly used .bzrignore: Ignore new xtstat binary mysql-test/r/index_merge_myisam.result: Update results (old result was wrong) mysql-test/suite/binlog/r/binlog_stm_binlog.result: Added drop table first mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result: Added test for when RAND() requires row based logging mysql-test/suite/binlog/t/binlog_stm_binlog.test: Added drop table first mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test: Added test for when RAND() requires row based logging scripts/make_binary_distribution.sh: Removed type from last commit sql/item_create.cc: Don't require row based logging when using RAND() with INSERT sql/opt_range.cc: Revert wrong patch from Oracle: - As QUICK_RANGE_SELECT uses it's own 'file' handler to the tables, one can't use 'table->key_read' as a flag to detect if index only read (keyread) is used or not - Don't set keyread if keyread is already enabled - Don't disable key read, if we didn't enable it ourselves - Simplify code (and ensure that we do proper cleanup of index only read) sql/opt_range.h: Added flags to detect if the range optimizer enabled index only read (key read) or not sql/opt_sum.cc: Use our more optimized macros sql/sql_lex.h: Added 'readable' function to check if we are in a sub query function or not (not normal query or sub query in FROM clause) sql/sql_select.cc: Use our more optimized keyread macros Added ASSERTS early Simplify code on eliminate_item_equal() Fixed that substitute_for_best_equal_field() doesn't core dump in case of out of memory conditions. Removed not needed test for 'field->maybe_null()' Replaced master_unit()->item with is_subquery_function() (More readable) sql/sql_update.cc: Use our more optimized keyread macros sql/table.cc: Use our more optimized keyread macros sql/table.h: Use separate functions to enable/disable Index only reads - Safer, more readable, better logging and faster.
This commit is contained in:
@ -1100,7 +1100,7 @@ QUICK_SELECT_I::QUICK_SELECT_I()
|
||||
|
||||
QUICK_RANGE_SELECT::QUICK_RANGE_SELECT(THD *thd, TABLE *table, uint key_nr,
|
||||
bool no_alloc, MEM_ROOT *parent_alloc)
|
||||
:dont_free(0),error(0),free_file(0),in_range(0),cur_range(NULL),last_range(0)
|
||||
:dont_free(0),doing_key_read(0),error(0),free_file(0),in_range(0),cur_range(NULL),last_range(0)
|
||||
{
|
||||
my_bitmap_map *bitmap;
|
||||
DBUG_ENTER("QUICK_RANGE_SELECT::QUICK_RANGE_SELECT");
|
||||
@ -1171,7 +1171,8 @@ QUICK_RANGE_SELECT::~QUICK_RANGE_SELECT()
|
||||
if (file)
|
||||
{
|
||||
range_end();
|
||||
head->set_keyread(FALSE);
|
||||
if (doing_key_read)
|
||||
file->extra(HA_EXTRA_NO_KEYREAD);
|
||||
if (free_file)
|
||||
{
|
||||
DBUG_PRINT("info", ("Freeing separate handler 0x%lx (free: %d)", (long) file,
|
||||
@ -1311,6 +1312,7 @@ int QUICK_ROR_INTERSECT_SELECT::init()
|
||||
int QUICK_RANGE_SELECT::init_ror_merged_scan(bool reuse_handler)
|
||||
{
|
||||
handler *save_file= file, *org_file;
|
||||
my_bool org_key_read;
|
||||
THD *thd;
|
||||
DBUG_ENTER("QUICK_RANGE_SELECT::init_ror_merged_scan");
|
||||
|
||||
@ -1370,12 +1372,17 @@ end:
|
||||
The now bitmap is stored in 'column_bitmap' which is used in ::get_next()
|
||||
*/
|
||||
org_file= head->file;
|
||||
org_key_read= head->key_read;
|
||||
head->file= file;
|
||||
/* We don't have to set 'head->keyread' here as the 'file' is unique */
|
||||
head->key_read= 0;
|
||||
if (!head->no_keyread)
|
||||
{
|
||||
doing_key_read= 1;
|
||||
head->mark_columns_used_by_index(index);
|
||||
}
|
||||
head->prepare_for_position();
|
||||
head->file= org_file;
|
||||
head->key_read= org_key_read;
|
||||
bitmap_copy(&column_bitmap, head->read_set);
|
||||
head->column_bitmaps_set(&column_bitmap, &column_bitmap);
|
||||
|
||||
@ -8154,12 +8161,15 @@ int QUICK_INDEX_MERGE_SELECT::read_keys_and_merge()
|
||||
List_iterator_fast<QUICK_RANGE_SELECT> cur_quick_it(quick_selects);
|
||||
QUICK_RANGE_SELECT* cur_quick;
|
||||
int result;
|
||||
Unique *unique;
|
||||
Unique *unique= 0;
|
||||
handler *file= head->file;
|
||||
DBUG_ENTER("QUICK_INDEX_MERGE_SELECT::read_keys_and_merge");
|
||||
|
||||
/* We're going to just read rowids. */
|
||||
head->set_keyread(TRUE);
|
||||
if (!head->key_read)
|
||||
{
|
||||
head->enable_keyread();
|
||||
}
|
||||
head->prepare_for_position();
|
||||
|
||||
cur_quick_it.rewind();
|
||||
@ -8171,13 +8181,13 @@ int QUICK_INDEX_MERGE_SELECT::read_keys_and_merge()
|
||||
reset here.
|
||||
*/
|
||||
if (cur_quick->init() || cur_quick->reset())
|
||||
DBUG_RETURN(1);
|
||||
goto err;
|
||||
|
||||
unique= new Unique(refpos_order_cmp, (void *)file,
|
||||
file->ref_length,
|
||||
thd->variables.sortbuff_size);
|
||||
if (!unique)
|
||||
DBUG_RETURN(1);
|
||||
goto err;
|
||||
for (;;)
|
||||
{
|
||||
while ((result= cur_quick->get_next()) == HA_ERR_END_OF_FILE)
|
||||
@ -8190,10 +8200,7 @@ int QUICK_INDEX_MERGE_SELECT::read_keys_and_merge()
|
||||
if (cur_quick->file->inited != handler::NONE)
|
||||
cur_quick->file->ha_index_end();
|
||||
if (cur_quick->init() || cur_quick->reset())
|
||||
{
|
||||
delete unique;
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (result)
|
||||
@ -8201,29 +8208,21 @@ int QUICK_INDEX_MERGE_SELECT::read_keys_and_merge()
|
||||
if (result != HA_ERR_END_OF_FILE)
|
||||
{
|
||||
cur_quick->range_end();
|
||||
delete unique;
|
||||
DBUG_RETURN(result);
|
||||
goto err;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (thd->killed)
|
||||
{
|
||||
delete unique;
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
goto err;
|
||||
|
||||
/* skip row if it will be retrieved by clustered PK scan */
|
||||
if (pk_quick_select && pk_quick_select->row_in_ranges())
|
||||
continue;
|
||||
|
||||
cur_quick->file->position(cur_quick->record);
|
||||
result= unique->unique_add((char*)cur_quick->file->ref);
|
||||
if (result)
|
||||
{
|
||||
delete unique;
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
if (unique->unique_add((char*)cur_quick->file->ref))
|
||||
goto err;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -8234,10 +8233,17 @@ int QUICK_INDEX_MERGE_SELECT::read_keys_and_merge()
|
||||
result= unique->get(head);
|
||||
delete unique;
|
||||
doing_pk_scan= FALSE;
|
||||
/* index_merge currently doesn't support "using index" at all */
|
||||
head->set_keyread(FALSE);
|
||||
/*
|
||||
index_merge currently doesn't support "using index" at all
|
||||
*/
|
||||
head->disable_keyread();
|
||||
init_read_record(&read_record, thd, head, (SQL_SELECT*) 0, 1 , 1, TRUE);
|
||||
DBUG_RETURN(result);
|
||||
|
||||
err:
|
||||
delete unique;
|
||||
head->disable_keyread();
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
||||
|
||||
@ -10308,7 +10314,7 @@ QUICK_GROUP_MIN_MAX_SELECT(TABLE *table, JOIN *join_arg, bool have_min_arg,
|
||||
:join(join_arg), index_info(index_info_arg),
|
||||
group_prefix_len(group_prefix_len_arg),
|
||||
group_key_parts(group_key_parts_arg), have_min(have_min_arg),
|
||||
have_max(have_max_arg), seen_first_key(FALSE),
|
||||
have_max(have_max_arg), seen_first_key(FALSE), doing_key_read(FALSE),
|
||||
min_max_arg_part(min_max_arg_part_arg), key_infix(key_infix_arg),
|
||||
key_infix_len(key_infix_len_arg), min_functions_it(NULL),
|
||||
max_functions_it(NULL)
|
||||
@ -10439,7 +10445,12 @@ QUICK_GROUP_MIN_MAX_SELECT::~QUICK_GROUP_MIN_MAX_SELECT()
|
||||
{
|
||||
DBUG_ENTER("QUICK_GROUP_MIN_MAX_SELECT::~QUICK_GROUP_MIN_MAX_SELECT");
|
||||
if (file->inited != handler::NONE)
|
||||
{
|
||||
DBUG_ASSERT(file == head->file);
|
||||
if (doing_key_read)
|
||||
head->disable_keyread();
|
||||
file->ha_index_end();
|
||||
}
|
||||
if (min_max_arg_part)
|
||||
delete_dynamic(&min_max_ranges);
|
||||
free_root(&alloc,MYF(0));
|
||||
@ -10622,7 +10633,11 @@ int QUICK_GROUP_MIN_MAX_SELECT::reset(void)
|
||||
int result;
|
||||
DBUG_ENTER("QUICK_GROUP_MIN_MAX_SELECT::reset");
|
||||
|
||||
head->set_keyread(TRUE); /* We need only the key attributes */
|
||||
if (!head->key_read)
|
||||
{
|
||||
doing_key_read= 1;
|
||||
head->enable_keyread(); /* We need only the key attributes */
|
||||
}
|
||||
if ((result= file->ha_index_init(index,1)))
|
||||
DBUG_RETURN(result);
|
||||
if (quick_prefix_select && quick_prefix_select->reset())
|
||||
|
Reference in New Issue
Block a user