1
0
mirror of https://github.com/MariaDB/server.git synced 2025-12-24 11:21:21 +03:00

Added more tests for new UPDATE ... ORDER BY ... LIMIT optimization

heap/_check.c:
  Change arguments to ha_key_cmp
heap/hp_create.c:
  Change arguments to ha_key_cmp
include/my_base.h:
  Remove SEARCH_RETURN_B_POS and instead always send an array to ha_key_cmp() as last argument
myisam/mi_check.c:
  Change arguments to ha_key_cmp
myisam/mi_rnext_same.c:
  Change arguments to ha_key_cmp
myisam/mi_search.c:
  Change arguments to ha_key_cmp
myisam/mi_write.c:
  Change arguments to ha_key_cmp
myisammrg/myrg_queue.c:
  Change arguments to ha_key_cmp
mysys/my_handler.c:
  Remove SEARCH_RETURN_B_POS and instead always send an array to ha_key_cmp() as last argument
  (This removes an if in a loop at the expensive of an int on the stack)
sql/records.cc:
  Simplify new rr_index() code
  Create common error handling function for rr_() functions.
  Remove loop from rr_index() as handler::index_next() can never return HA_ERR_RECORD_DELETED
sql/sql_load.cc:
  Simplify
sql/sql_update.cc:
  Simplify code
  Fixed bug when one is updating an index column that could be used with ORDER BY
sql/structs.h:
  Removed not needed structure element
This commit is contained in:
unknown
2005-10-25 02:27:40 +03:00
parent 3c02a0534d
commit 8d6634c9e0
15 changed files with 170 additions and 182 deletions

View File

@@ -148,7 +148,7 @@ int mysql_update(THD *thd,
}
if (!select && limit != HA_POS_ERROR)
{
if (MAX_KEY != (used_index= get_index_for_order(table, order, limit)))
if ((used_index= get_index_for_order(table, order, limit)) != MAX_KEY)
need_sort= FALSE;
}
/* If running in safe sql mode, don't allow updates without keys */
@@ -171,14 +171,14 @@ int mysql_update(THD *thd,
used_key_is_modified= (!select->quick->unique_key_range() &&
check_if_key_used(table, used_index, fields));
}
else if (used_index != MAX_KEY)
{
used_key_is_modified= check_if_key_used(table, used_index, fields);
}
else if ((used_index=table->file->key_used_on_scan) < MAX_KEY)
used_key_is_modified=check_if_key_used(table, used_index, fields);
else
used_key_is_modified=0;
{
used_key_is_modified= 0;
if (used_index == MAX_KEY) // no index for sort order
used_index= table->file->key_used_on_scan;
if (used_index != MAX_KEY)
used_key_is_modified= check_if_key_used(table, used_index, fields);
}
if (used_key_is_modified || order)
{
@@ -190,11 +190,11 @@ int mysql_update(THD *thd,
if (used_index < MAX_KEY && old_used_keys.is_set(used_index))
{
table->key_read=1;
table->file->extra(HA_EXTRA_KEYREAD); //todo: psergey: check
table->file->extra(HA_EXTRA_KEYREAD);
}
/* note: can actually avoid sorting below.. */
if (order && need_sort)
if (order && (need_sort || used_key_is_modified))
{
/*
Doing an ORDER BY; Let filesort find and sort the rows we are going
@@ -204,6 +204,7 @@ int mysql_update(THD *thd,
SORT_FIELD *sortorder;
ha_rows examined_rows;
used_index= MAX_KEY; // For call to init_read_record()
table->sort.io_cache = (IO_CACHE *) my_malloc(sizeof(IO_CACHE),
MYF(MY_FAE | MY_ZEROFILL));
if (!(sortorder=make_unireg_sortorder(order, &length)) ||
@@ -265,10 +266,7 @@ int mysql_update(THD *thd,
error= 1; // Aborted
limit= tmp_limit;
end_read_record(&info);
/* if we got here we must not use index in the main update loop below */
used_index= MAX_KEY;
/* Change select to use tempfile */
if (select)
{