summaryrefslogtreecommitdiff
path: root/sql/sql_update.cc
diff options
context:
space:
mode:
authorjani@ua141d10.elisa.omakaista.fi <>2005-10-27 23:43:20 +0300
committerjani@ua141d10.elisa.omakaista.fi <>2005-10-27 23:43:20 +0300
commitcbe21a8eb6c53ed4eb7f6228a322d642abacde95 (patch)
treeff71298ae3c57caff8ca7c70666d60292290e366 /sql/sql_update.cc
parent2025b35544f2a43322a9fd3574d19469383009c2 (diff)
parenta57c08d46815c13c09e713a3ea05076c19001a0e (diff)
downloadmariadb-git-cbe21a8eb6c53ed4eb7f6228a322d642abacde95.tar.gz
Merge ua141d10.elisa.omakaista.fi:/home/my/bk/mysql-4.1
into ua141d10.elisa.omakaista.fi:/home/my/bk/mysql-5.0-tmp
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 a8e21177338..620b9676dde 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -244,7 +244,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 */
@@ -267,14 +267,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)
{
@@ -286,11 +286,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
@@ -300,6 +300,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)) ||
@@ -366,10 +367,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)
{