summaryrefslogtreecommitdiff
path: root/sql/opt_sum.cc
diff options
context:
space:
mode:
authorunknown <monty@tik.mysql.fi>2002-04-12 21:35:46 +0300
committerunknown <monty@tik.mysql.fi>2002-04-12 21:35:46 +0300
commit6326ec9944e8ab44fceff629d6681700573ab686 (patch)
tree0060cbed8a1f7a8adaca0a4dc2e74b3372e28361 /sql/opt_sum.cc
parent40a27740878e945bbdf667c3735a41727d343ed1 (diff)
downloadmariadb-git-6326ec9944e8ab44fceff629d6681700573ab686.tar.gz
Update for BTREE keys in HEAP tables
Split handler->option_flag() to handler->table_flags() and handler->index_flags() Docs/manual.texi: Updated standard binary options include/my_base.h: Update for BTREE keys in HEAP tables libmysql/net.c: merge with net_serv.cc mysql-test/r/func_misc.result: Update for new behaviour of inet_ntoa sql/field.cc: Update for BTREE keys in HEAP tables sql/field.h: Update for BTREE keys in HEAP tables sql/filesort.cc: Update for BTREE keys in HEAP tables sql/ha_berkeley.h: Update for BTREE keys in HEAP tables sql/ha_heap.h: Update for BTREE keys in HEAP tables sql/ha_innodb.h: Update for BTREE keys in HEAP tables sql/ha_isam.cc: Update for BTREE keys in HEAP tables sql/ha_isam.h: Update for BTREE keys in HEAP tables sql/ha_isammrg.h: Update for BTREE keys in HEAP tables sql/ha_myisam.cc: Update for BTREE keys in HEAP tables sql/ha_myisam.h: Update for BTREE keys in HEAP tables sql/ha_myisammrg.h: Update for BTREE keys in HEAP tables sql/handler.cc: Update for BTREE keys in HEAP tables sql/handler.h: Update for BTREE keys in HEAP tables sql/log.cc: Update for BTREE keys in HEAP tables sql/net_serv.cc: Update for BTREE keys in HEAP tables sql/opt_range.cc: Update for BTREE keys in HEAP tables sql/opt_sum.cc: Update for BTREE keys in HEAP tables sql/records.cc: Update for BTREE keys in HEAP tables sql/sql_class.h: Update for BTREE keys in HEAP tables sql/sql_handler.cc: Update for BTREE keys in HEAP tables sql/sql_insert.cc: Update for BTREE keys in HEAP tables sql/sql_select.cc: Update for BTREE keys in HEAP tables sql/sql_show.cc: Update for BTREE keys in HEAP tables sql/sql_table.cc: Update for BTREE keys in HEAP tables sql/structs.h: Update for BTREE keys in HEAP tables sql/table.cc: Update for BTREE keys in HEAP tables sql/unireg.cc: Update for BTREE keys in HEAP tables
Diffstat (limited to 'sql/opt_sum.cc')
-rw-r--r--sql/opt_sum.cc22
1 files changed, 15 insertions, 7 deletions
diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc
index 78878c40b37..efb4c4916a5 100644
--- a/sql/opt_sum.cc
+++ b/sql/opt_sum.cc
@@ -55,7 +55,7 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
TABLE_LIST *table;
for (table=tables; table ; table=table->next)
{
- if (table->on_expr || (table->table->file->option_flag() &
+ if (table->on_expr || (table->table->file->table_flags() &
HA_NOT_EXACT_COUNT))
{
const_result=0; // Can't optimize left join
@@ -141,7 +141,7 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
break;
}
TABLE *table=((Item_field*) expr)->field->table;
- if ((table->file->option_flag() & HA_NOT_READ_AFTER_KEY))
+ if ((table->file->table_flags() & HA_NOT_READ_AFTER_KEY))
{
const_result=0;
break;
@@ -294,16 +294,22 @@ static bool find_range_key(TABLE_REF *ref, Field* field, COND *cond)
return 0; // Not part of a key. Skip it
TABLE *table=field->table;
- if (table->file->option_flag() & HA_WRONG_ASCII_ORDER)
- return(0); // Can't use key to find last row
uint idx=0;
/* Check if some key has field as first key part */
if ((field->key_start & field->table->keys_in_use_for_query) &&
(! cond || ! (cond->used_tables() & table->map)))
{
- for (key_map key=field->key_start ; !(key & 1) ; idx++)
- key>>=1;
+ for (key_map key=field->key_start ;;)
+ {
+ for (; !(key & 1) ; idx++)
+ key>>=1;
+ if (!(table->file->index_flags(idx) & HA_WRONG_ASCII_ORDER))
+ break; // Key is ok
+ /* Can't use this key, for looking up min() or max(), end if last one */
+ if (key == 1)
+ return 0;
+ }
ref->key_length=0;
ref->key=idx;
if (field->part_of_key & ((key_map) 1 << idx))
@@ -323,6 +329,7 @@ static bool find_range_key(TABLE_REF *ref, Field* field, COND *cond)
return 0;
KEY *keyinfo,*keyinfo_end;
+ idx=0;
for (keyinfo=table->key_info, keyinfo_end=keyinfo+table->keys ;
keyinfo != keyinfo_end;
keyinfo++,idx++)
@@ -338,7 +345,8 @@ static bool find_range_key(TABLE_REF *ref, Field* field, COND *cond)
part++)
{
if (!part_of_cond(cond,part->field) ||
- left_length < part->store_length)
+ left_length < part->store_length ||
+ (table->file->index_flags(idx) & HA_WRONG_ASCII_ORDER))
break;
// Save found constant
if (part->null_bit)