summaryrefslogtreecommitdiff
path: root/sql/sql_update.cc
diff options
context:
space:
mode:
authorbell@sanja.is.com.ua <>2005-10-28 10:12:36 +0300
committerbell@sanja.is.com.ua <>2005-10-28 10:12:36 +0300
commitb5d2e34572b90dda030e5b750c30d38fc3bc8628 (patch)
treec0a710cd157405baf40b3e18db1740f006bc16e8 /sql/sql_update.cc
parentc399932a72f9724e8dcc160d1705d74df47c6904 (diff)
parent74b8b449a4d70858758994114b9b559f3275e005 (diff)
downloadmariadb-git-b5d2e34572b90dda030e5b750c30d38fc3bc8628.tar.gz
Merge sanja.is.com.ua:/home/bell/mysql/bk/mysql-5.0
into sanja.is.com.ua:/home/bell/mysql/bk/work-owner7-5.0
Diffstat (limited to 'sql/sql_update.cc')
-rw-r--r--sql/sql_update.cc24
1 files changed, 11 insertions, 13 deletions
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index 9900625f208..4de73f7b789 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -245,7 +245,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 */
@@ -268,14 +268,14 @@ int mysql_update(THD *thd,
used_key_is_modified= (!select->quick->unique_key_range() &&
select->quick->check_if_keys_used(&fields));
}
- else if (used_index != MAX_KEY)
+ else
{
- used_key_is_modified= check_if_key_used(table, used_index, fields);
+ 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);
}
- 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;
if (used_key_is_modified || order)
{
@@ -287,11 +287,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
@@ -301,6 +301,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)) ||
@@ -367,10 +368,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)
{