summaryrefslogtreecommitdiff
path: root/sql/uniques.cc
diff options
context:
space:
mode:
authorunknown <Sinisa@sinisa.nasamreza.org>2001-06-03 17:07:26 +0300
committerunknown <Sinisa@sinisa.nasamreza.org>2001-06-03 17:07:26 +0300
commit4e886689b2095185cd675ec88f4e40f77b6074b1 (patch)
tree117457cc851c63311919cde097c85f86ae4d9995 /sql/uniques.cc
parent020160f83f62d6171c57a4021e21e68049c2a4e8 (diff)
downloadmariadb-git-4e886689b2095185cd675ec88f4e40f77b6074b1.tar.gz
These are actually two changesets. One for splitting LEX in two and
the other for multi-table delete sql/filesort.cc: Fixed some bugs for Unique class sql/item.cc: Changes caused by splitting lex into two parts, in order to implement UNION's etc sql/item_sum.cc: Changes caused by splitting lex into two parts, in order to implement UNION's etc sql/mysql_priv.h: Changes caused by splitting lex into two parts, in order to implement UNION's etc sql/sql_class.h: Adding multi table delete sql/sql_delete.cc: Added multi-table delete sql/sql_lex.cc: Changes caused by splitting lex into two parts, in order to implement UNION's etc sql/sql_lex.h: Changes caused by splitting lex into two parts, in order to implement UNION's etc sql/sql_parse.cc: Changes caused by splitting lex into two parts, in order to implement UNION's etc, plus added multi-table delete sql/sql_select.cc: Changes caused by splitting lex into two parts, in order to implement UNION's etc sql/sql_update.cc: Changes caused by splitting lex into two parts, in order to implement UNION's etc sql/sql_yacc.yy: Changes caused by splitting lex into two parts, in order to implement UNION's etc, plus added multi-table delete sql/uniques.cc: Fixed some bugs in duplicate stripping BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted
Diffstat (limited to 'sql/uniques.cc')
-rw-r--r--sql/uniques.cc22
1 files changed, 15 insertions, 7 deletions
diff --git a/sql/uniques.cc b/sql/uniques.cc
index 78fd8fe6e60..36a395dfa5d 100644
--- a/sql/uniques.cc
+++ b/sql/uniques.cc
@@ -34,11 +34,14 @@
#include "mysql_priv.h"
#include "sql_sort.h"
-Unique::Unique(qsort_cmp2 comp_func, uint size, ulong max_in_memory_size_arg)
+
+Unique::Unique(qsort_cmp2 comp_func, void * comp_func_fixed_arg,
+ uint size, ulong max_in_memory_size_arg)
:max_in_memory_size(max_in_memory_size_arg),elements(0)
{
my_b_clear(&file);
init_tree(&tree, max_in_memory_size / 16, size, comp_func, 0, 0);
+ tree.cmp_arg=comp_func_fixed_arg;
/* If the following fail's the next add will also fail */
init_dynamic_array(&file_ptrs, sizeof(BUFFPEK), 16, 16);
max_elements= max_in_memory_size / ALIGN_SIZE(sizeof(TREE_ELEMENT)+size);
@@ -69,12 +72,14 @@ bool Unique::flush()
}
-int unique_write_to_file(gptr key, Unique *unique, element_count count)
+int unique_write_to_file(gptr key, element_count count, Unique *unique)
{
+ if (!my_b_inited(&unique->file) && open_cached_file(&unique->file, mysql_tmpdir,TEMP_PREFIX, DISK_BUFFER_SIZE, MYF(MY_WME)))
+ return 1;
return my_b_write(&unique->file, key, unique->tree.size_of_element) ? 1 : 0;
}
-int unique_write_to_ptrs(gptr key, Unique *unique, element_count count)
+int unique_write_to_ptrs(gptr key, element_count count, Unique *unique)
{
memcpy(unique->record_pointers, key, unique->tree.size_of_element);
unique->record_pointers+=unique->tree.size_of_element;
@@ -109,7 +114,7 @@ bool Unique::get(TABLE *table)
IO_CACHE *outfile=table->io_cache, tempfile;
BUFFPEK *file_ptr= (BUFFPEK*) file_ptrs.buffer;
- uint maxbuffer= file_ptrs.elements;
+ uint maxbuffer= file_ptrs.elements - 1; // I added -1 .....
uchar *sort_buffer;
my_off_t save_pos;
bool error=1;
@@ -117,18 +122,21 @@ bool Unique::get(TABLE *table)
my_b_clear(&tempfile);
/* Open cached file if it isn't open */
+ if (!outfile) outfile= (IO_CACHE *) sql_calloc(sizeof(IO_CACHE));
if (! my_b_inited(outfile) &&
open_cached_file(outfile,mysql_tmpdir,TEMP_PREFIX,READ_RECORD_BUFFER,
MYF(MY_WME)))
return 1;
reinit_io_cache(outfile,WRITE_CACHE,0L,0,0);
-
- sort_param.keys=elements;
+
+// sort_param.keys=elements;
+ sort_param.max_rows= elements;
+ sort_param.examined_rows=0;
sort_param.sort_form=table;
sort_param.sort_length=sort_param.ref_length=tree.size_of_element;
sort_param.keys= max_in_memory_size / sort_param.sort_length;
- if (!(sort_buffer=(uchar*) my_malloc((sort_param.keys+1) *
+ if (!(sort_buffer=(uchar*) my_malloc((sort_param.keys+1) *
sort_param.sort_length,
MYF(0))))
return 1;