diff options
author | Alexander Nozdrin <alik@ibmvm> | 2010-07-20 12:09:51 +0400 |
---|---|---|
committer | Alexander Nozdrin <alik@ibmvm> | 2010-07-20 12:09:51 +0400 |
commit | fdfbb82964959b21dd3fa7d6ddaea38b8726006d (patch) | |
tree | 4c5953434e9453c414d8de2ec5f034fba794e607 /sql | |
parent | 4777370bb3f141a594ba9b6b81ea5554f3b37fbb (diff) | |
parent | 84d2ae22fe0a0cf6c2edc894f6e8b80963c95ed7 (diff) | |
download | mariadb-git-fdfbb82964959b21dd3fa7d6ddaea38b8726006d.tar.gz |
Auto-merge from mysql-trunk-merge.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/filesort.cc | 4 | ||||
-rw-r--r-- | sql/opt_range.h | 6 | ||||
-rw-r--r-- | sql/sql_delete.cc | 3 | ||||
-rw-r--r-- | sql/sql_select.cc | 32 | ||||
-rw-r--r-- | sql/sql_table.cc | 20 | ||||
-rw-r--r-- | sql/sql_update.cc | 12 |
6 files changed, 47 insertions, 30 deletions
diff --git a/sql/filesort.cc b/sql/filesort.cc index 2398785a038..b98a7f780f4 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -511,6 +511,7 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, volatile THD::killed_state *killed= &thd->killed; handler *file; MY_BITMAP *save_read_set, *save_write_set; + bool skip_record; DBUG_ENTER("find_all_keys"); DBUG_PRINT("info",("using: %s", (select ? select->quick ? "ranges" : "where": @@ -603,7 +604,8 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, } if (error == 0) param->examined_rows++; - if (error == 0 && (!select || select->skip_record() == 0)) + if (!error && (!select || + (!select->skip_record(thd, &skip_record) && !skip_record))) { if (idx == param->keys) { diff --git a/sql/opt_range.h b/sql/opt_range.h index 0d4000002b0..33b3d561ad8 100644 --- a/sql/opt_range.h +++ b/sql/opt_range.h @@ -825,7 +825,11 @@ class SQL_SELECT :public Sql_alloc { tmp.set_all(); return test_quick_select(thd, tmp, 0, limit, force_quick_range) < 0; } - inline bool skip_record() { return cond ? cond->val_int() == 0 : 0; } + inline bool skip_record(THD *thd, bool *skip_record) + { + *skip_record= cond ? cond->val_int() == FALSE : FALSE; + return thd->is_error(); + } int test_quick_select(THD *thd, key_map keys, table_map prev_tables, ha_rows limit, bool force_quick_range); }; diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index c94ea1302c8..00666bc85b4 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -59,6 +59,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, bool const_cond_result; ha_rows deleted= 0; bool reverse= FALSE; + bool skip_record; ORDER *order= (ORDER *) ((order_list && order_list->elements) ? order_list->first : NULL); uint usable_index= MAX_KEY; @@ -298,7 +299,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, { thd->examined_row_count++; // thd->is_error() is tested to disallow delete row on error - if (!(select && select->skip_record())&& ! thd->is_error() ) + if (!select || (!select->skip_record(thd, &skip_record) && !skip_record)) { if (table->triggers && diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 11378ac0d11..74d05780f81 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -11941,38 +11941,30 @@ flush_cached_records(JOIN *join,JOIN_TAB *join_tab,bool skip_last) SQL_SELECT *select=join_tab->select; if (rc == NESTED_LOOP_OK) { - bool consider_record= !join_tab->cache.select || - !join_tab->cache.select->skip_record(); - - /* - Check for error: skip_record() can execute code by calling - Item_subselect::val_*. We need to check for errors (if any) - after such call. - */ - if (join->thd->is_error()) + bool skip_record= FALSE; + if (join_tab->cache.select && + join_tab->cache.select->skip_record(join->thd, &skip_record)) { reset_cache_write(&join_tab->cache); return NESTED_LOOP_ERROR; } - if (consider_record) + if (!skip_record) { uint i; reset_cache_read(&join_tab->cache); for (i=(join_tab->cache.records- (skip_last ? 1 : 0)) ; i-- > 0 ;) { read_cached_record(join_tab); - if (!select || !select->skip_record()) + skip_record= FALSE; + if (select && select->skip_record(join->thd, &skip_record)) { - /* - Check for error: skip_record() can execute code by calling - Item_subselect::val_*. We need to check for errors (if any) - after such call. - */ - if (join->thd->is_error()) - rc= NESTED_LOOP_ERROR; - else - rc= (join_tab->next_select)(join,join_tab+1,0); + reset_cache_write(&join_tab->cache); + return NESTED_LOOP_ERROR; + } + if (!skip_record) + { + rc= (join_tab->next_select)(join,join_tab+1,0); if (rc != NESTED_LOOP_OK && rc != NESTED_LOOP_NO_MORE_ROWS) { reset_cache_write(&join_tab->cache); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index fa9f9b7f633..d28b4859ab5 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -7339,12 +7339,22 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, if (table->s->tmp_table != NO_TMP_TABLE) { /* Close lock if this is a transactional table */ - if (thd->lock && - ! (thd->locked_tables_mode == LTM_LOCK_TABLES || - thd->locked_tables_mode == LTM_PRELOCKED_UNDER_LOCK_TABLES)) + if (thd->lock) { - mysql_unlock_tables(thd, thd->lock); - thd->lock=0; + if (thd->locked_tables_mode != LTM_LOCK_TABLES && + thd->locked_tables_mode != LTM_PRELOCKED_UNDER_LOCK_TABLES) + { + mysql_unlock_tables(thd, thd->lock); + thd->lock=0; + } + else + { + /* + If LOCK TABLES list is not empty and contains this table, + unlock the table and remove the table from this list. + */ + mysql_lock_remove(thd, thd->lock, table); + } } /* Remove link to old table and rename the new one */ close_temporary_table(thd, table, 1, 1); diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 25c1fd6fa1e..c52467531a9 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -477,7 +477,14 @@ int mysql_update(THD *thd, while (!(error=info.read_record(&info)) && !thd->killed) { thd->examined_row_count++; - if (!(select && select->skip_record())) + bool skip_record= FALSE; + if (select && select->skip_record(thd, &skip_record)) + { + error= 1; + table->file->unlock_row(); + break; + } + if (!skip_record) { if (table->file->was_semi_consistent_read()) continue; /* repeat the read of the same row if it still exists */ @@ -584,7 +591,8 @@ int mysql_update(THD *thd, while (!(error=info.read_record(&info)) && !thd->killed) { thd->examined_row_count++; - if (!(select && select->skip_record())) + bool skip_record; + if (!select || (!select->skip_record(thd, &skip_record) && !skip_record)) { if (table->file->was_semi_consistent_read()) continue; /* repeat the read of the same row if it still exists */ |