diff options
author | unknown <monty@mashka.mysql.fi> | 2003-06-26 07:56:55 +0300 |
---|---|---|
committer | unknown <monty@mashka.mysql.fi> | 2003-06-26 07:56:55 +0300 |
commit | 7539980eb1e70144c8f1232271e4f24311426312 (patch) | |
tree | 80a9ea494fdef18a20b754a4ce6bfd8179e5cfe0 /sql | |
parent | a3beaaa3af7af26aabadda6836618d32d6c90e51 (diff) | |
download | mariadb-git-7539980eb1e70144c8f1232271e4f24311426312.tar.gz |
Fixed memory allocation in Unique to not allocate too much memory
myisam/mi_info.c:
Updated comments
mysys/tree.c:
Added comment
sql/net_serv.cc:
Added comment
Diffstat (limited to 'sql')
-rw-r--r-- | sql/net_serv.cc | 3 | ||||
-rw-r--r-- | sql/sql_class.h | 42 | ||||
-rw-r--r-- | sql/uniques.cc | 6 |
3 files changed, 28 insertions, 23 deletions
diff --git a/sql/net_serv.cc b/sql/net_serv.cc index a8bc559e3a0..13f786e0e75 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -21,6 +21,9 @@ Read packets are reallocated dynamicly when reading big packets. Each logical packet has the following pre-info: 3 byte length & 1 byte package-number. + + This file needs to be written in C as it's used by the libmysql client as a + C file. */ #ifdef __WIN__ diff --git a/sql/sql_class.h b/sql/sql_class.h index a8a24451ecc..3246f77c77a 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -781,11 +781,12 @@ class Unique :public Sql_alloc TREE tree; byte *record_pointers; bool flush(); + uint size; public: ulong elements; Unique(qsort_cmp2 comp_func, void * comp_func_fixed_arg, - uint size, ulong max_in_memory_size_arg); + uint size_arg, ulong max_in_memory_size_arg); ~Unique(); inline bool unique_add(gptr ptr) { @@ -800,26 +801,27 @@ public: friend int unique_write_to_ptrs(gptr key, element_count count, Unique *unique); }; - class multi_delete : public select_result { - TABLE_LIST *delete_tables, *table_being_deleted; - Unique **tempfiles; - THD *thd; - ha_rows deleted; - uint num_of_tables; - int error; - bool do_delete, transactional_tables, log_delayed, normal_tables; - public: - multi_delete(THD *thd, TABLE_LIST *dt, uint num_of_tables); - ~multi_delete(); - int prepare(List<Item> &list); - bool send_fields(List<Item> &list, +class multi_delete : public select_result +{ + TABLE_LIST *delete_tables, *table_being_deleted; + Unique **tempfiles; + THD *thd; + ha_rows deleted; + uint num_of_tables; + int error; + bool do_delete, transactional_tables, log_delayed, normal_tables; +public: + multi_delete(THD *thd, TABLE_LIST *dt, uint num_of_tables); + ~multi_delete(); + int prepare(List<Item> &list); + bool send_fields(List<Item> &list, uint flag) { return 0; } - bool send_data(List<Item> &items); - bool initialize_tables (JOIN *join); - void send_error(uint errcode,const char *err); - int do_deletes (bool from_send_error); - bool send_eof(); - }; + bool send_data(List<Item> &items); + bool initialize_tables (JOIN *join); + void send_error(uint errcode,const char *err); + int do_deletes (bool from_send_error); + bool send_eof(); +}; class multi_update : public select_result { diff --git a/sql/uniques.cc b/sql/uniques.cc index ed256a4b791..d00893a8605 100644 --- a/sql/uniques.cc +++ b/sql/uniques.cc @@ -49,8 +49,8 @@ int unique_write_to_ptrs(gptr key, element_count count, Unique *unique) } 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) + uint size_arg, ulong max_in_memory_size_arg) + :max_in_memory_size(max_in_memory_size_arg), size(size_arg), elements(0) { my_b_clear(&file); init_tree(&tree, max_in_memory_size / 16, 0, size, comp_func, 0, NULL, @@ -101,7 +101,7 @@ bool Unique::get(TABLE *table) { /* Whole tree is in memory; Don't use disk if you don't need to */ if ((record_pointers=table->record_pointers= (byte*) - my_malloc(tree.size_of_element * tree.elements_in_tree, MYF(0)))) + my_malloc(size * tree.elements_in_tree, MYF(0)))) { (void) tree_walk(&tree, (tree_walk_action) unique_write_to_ptrs, this, left_root_right); |