summaryrefslogtreecommitdiff
path: root/sql/item_sum.cc
diff options
context:
space:
mode:
authorunknown <sasha@mysql.sashanet.com>2001-05-29 18:53:37 -0600
committerunknown <sasha@mysql.sashanet.com>2001-05-29 18:53:37 -0600
commit7a8520640a93758684dfa2cd859ba591f8923ee1 (patch)
tree42f41e1efa80a528b784080d3adbf953e1712214 /sql/item_sum.cc
parent020160f83f62d6171c57a4021e21e68049c2a4e8 (diff)
downloadmariadb-git-7a8520640a93758684dfa2cd859ba591f8923ee1.tar.gz
count(distinct) cleanup
mysql-test/t/count_distinct2.test: make default NULL in tree->MyISAM test to make sure restore_record() does not give a bad surprise sql/item_sum.cc: cleanup according to Monty's suggestions sql/item_sum.h: cleanup according to Monty's suggestions
Diffstat (limited to 'sql/item_sum.cc')
-rw-r--r--sql/item_sum.cc10
1 files changed, 8 insertions, 2 deletions
diff --git a/sql/item_sum.cc b/sql/item_sum.cc
index 879c27178e5..914d9f2791c 100644
--- a/sql/item_sum.cc
+++ b/sql/item_sum.cc
@@ -839,7 +839,8 @@ int dump_leaf(byte* key, uint32 count __attribute__((unused)),
{
char* buf = item->table->record[0];
int error;
- memset(buf, 0xff, item->rec_offset); // make up for cheating in the tree
+ // the first item->rec_offset bytes are taken care of with
+ // restore_record(table,2) in setup()
memcpy(buf + item->rec_offset, key, item->tree.size_of_element);
if ((error = item->table->file->write_row(buf)))
{
@@ -888,12 +889,17 @@ bool Item_sum_count_distinct::setup(THD *thd)
table->file->extra(HA_EXTRA_NO_ROWS); // Don't update rows
table->no_rows=1;
+
if(table->db_type == DB_TYPE_HEAP) // no blobs, otherwise it would be
// MyISAM
{
qsort_cmp2 compare_key;
void* cmp_arg;
int key_len;
+
+ // to make things easier for dump_leaf if we ever have to dump to
+ // MyISAM
+ restore_record(table,2);
if(table->fields == 1) // if we have only one field, which is
// the most common use of count(distinct), it is much faster
@@ -941,7 +947,7 @@ bool Item_sum_count_distinct::setup(THD *thd)
// but this has to be handled - otherwise someone can crash
// the server with a DoS attack
max_elements_in_tree = (key_len) ? max_heap_table_size/key_len :
- max_heap_table_size;
+ 1;
}
return 0;