mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 20:12:31 +01:00
33fc0d53b5
BitKeeper/etc/gone: auto-union BitKeeper/etc/ignore: auto-union BitKeeper/etc/logging_ok: auto-union BitKeeper/deleted/.del-.my_sys.h.swp~f6a4a7f8dae03f18: Auto merged BitKeeper/etc/config: Auto merged acconfig.h: Auto merged acinclude.m4: Auto merged Docs/manual.texi: Auto merged client/mysqlcheck.c: Auto merged client/mysqlshow.c: Auto merged include/myisam.h: Auto merged include/violite.h: Auto merged isam/pack_isam.c: Auto merged libmysql/libmysql.c: Auto merged libmysqld/lib_sql.cc: Auto merged myisam/Makefile.am: Auto merged myisam/ft_nlq_search.c: Auto merged myisam/mi_open.c: Auto merged myisam/mi_write.c: Auto merged myisam/sort.c: Auto merged mysql-test/mysql-test-run.sh: Auto merged mysql-test/r/fulltext.result: Auto merged mysql-test/r/func_test.result: Auto merged mysql-test/r/isam.result: Auto merged mysql-test/r/rpl_replicate_do.result: Auto merged mysql-test/r/variables.result: Auto merged mysql-test/t/func_test.test: Auto merged mysql-test/t/myisam.test: Auto merged mysql-test/t/rpl_rotate_logs.test: Auto merged mysql-test/t/variables.test: Auto merged mysys/hash.c: Auto merged mysys/tree.c: Auto merged scripts/Makefile.am: Auto merged sql/Makefile.am: Auto merged sql/filesort.cc: Auto merged sql/gen_lex_hash.cc: Auto merged sql/ha_berkeley.cc: Auto merged sql/ha_innodb.cc: Auto merged sql/handler.cc: Auto merged sql/handler.h: Auto merged sql/hash_filo.h: Auto merged sql/hostname.cc: Auto merged sql/item_func.cc: Auto merged sql/item_func.h: Auto merged sql/item_timefunc.cc: Auto merged sql/lex.h: Auto merged sql/lock.cc: Auto merged sql/log.cc: Auto merged sql/log_event.h: Auto merged sql/mini_client.cc: Auto merged sql/opt_range.cc: Auto merged sql/opt_sum.cc: Auto merged sql/repl_failsafe.cc: Auto merged sql/set_var.h: Auto merged sql/slave.h: Auto merged sql/sql_acl.cc: Auto merged sql/sql_analyse.cc: Auto merged sql/sql_cache.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_load.cc: Auto merged sql/sql_rename.cc: Auto merged sql/sql_repl.cc: Auto merged sql/sql_show.cc: Auto merged sql/sql_table.cc: Auto merged sql/sql_udf.cc: Auto merged sql/share/czech/errmsg.txt: Auto merged sql/share/danish/errmsg.txt: Auto merged sql/share/dutch/errmsg.txt: Auto merged sql/share/english/errmsg.txt: Auto merged sql/share/estonian/errmsg.txt: Auto merged sql/share/french/errmsg.txt: Auto merged sql/share/german/errmsg.txt: Auto merged sql/share/greek/errmsg.txt: Auto merged sql/share/hungarian/errmsg.txt: Auto merged sql/share/italian/errmsg.txt: Auto merged sql/share/japanese/errmsg.txt: Auto merged sql/share/korean/errmsg.txt: Auto merged sql/share/norwegian/errmsg.txt: Auto merged sql/table.h: Auto merged sql/unireg.cc: Auto merged sql-bench/server-cfg.sh: Auto merged sql/share/norwegian-ny/errmsg.txt: Auto merged sql/share/polish/errmsg.txt: Auto merged sql/share/portuguese/errmsg.txt: Auto merged sql/share/romanian/errmsg.txt: Auto merged sql/share/russian/errmsg.txt: Auto merged sql/share/slovak/errmsg.txt: Auto merged sql/share/spanish/errmsg.txt: Auto merged sql/share/swedish/errmsg.txt: Auto merged sql/share/ukrainian/errmsg.txt: Auto merged sql/ha_myisam.cc: Merge with 4.0 Removed some commented code sql/sql_db.cc: Merge with 4.0 Optimized the logging of the drop db call a bit sql/sql_update.cc: Added comment
101 lines
3.5 KiB
C
101 lines
3.5 KiB
C
/* Copyright (C) 2000 MySQL AB
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
#ifndef _tree_h
|
|
#define _tree_h
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include "my_base.h" /* get 'enum ha_rkey_function' */
|
|
|
|
#define MAX_TREE_HEIGHT 40 /* = max 1048576 leafs in tree */
|
|
#define ELEMENT_KEY(tree,element)\
|
|
(tree->offset_to_key ? (void*)((byte*) element+tree->offset_to_key) :\
|
|
*((void**) (element+1)))
|
|
|
|
#define tree_set_pointer(element,ptr) *((byte **) (element+1))=((byte*) (ptr))
|
|
|
|
#define TREE_NO_DUPS 1
|
|
|
|
typedef enum { left_root_right, right_root_left } TREE_WALK;
|
|
typedef uint32 element_count;
|
|
typedef int (*tree_walk_action)(void *,element_count,void *);
|
|
|
|
typedef enum { free_init, free_free, free_end } TREE_FREE;
|
|
typedef void (*tree_element_free)(void*, TREE_FREE, void *);
|
|
|
|
#ifdef MSDOS
|
|
typedef struct st_tree_element {
|
|
struct st_tree_element *left,*right;
|
|
unsigned long count;
|
|
uchar colour; /* black is marked as 1 */
|
|
} TREE_ELEMENT;
|
|
#else
|
|
typedef struct st_tree_element {
|
|
struct st_tree_element *left,*right;
|
|
uint32 count:31,
|
|
colour:1; /* black is marked as 1 */
|
|
} TREE_ELEMENT;
|
|
#endif /* MSDOS */
|
|
|
|
#define ELEMENT_CHILD(element, offs) (*(TREE_ELEMENT**)((char*)element + offs))
|
|
|
|
typedef struct st_tree {
|
|
TREE_ELEMENT *root,null_element;
|
|
TREE_ELEMENT **parents[MAX_TREE_HEIGHT];
|
|
uint offset_to_key,elements_in_tree,size_of_element,memory_limit,allocated;
|
|
qsort_cmp2 compare;
|
|
void *custom_arg;
|
|
MEM_ROOT mem_root;
|
|
my_bool with_delete;
|
|
tree_element_free free;
|
|
uint flag;
|
|
} TREE;
|
|
|
|
/* Functions on whole tree */
|
|
void init_tree(TREE *tree, uint default_alloc_size, uint memory_limit,
|
|
int size, qsort_cmp2 compare, my_bool with_delete,
|
|
tree_element_free free_element, void *custom_arg);
|
|
void delete_tree(TREE*);
|
|
void reset_tree(TREE*);
|
|
/* similar to delete tree, except we do not my_free() blocks in mem_root
|
|
*/
|
|
#define is_tree_inited(tree) ((tree)->root != 0)
|
|
|
|
/* Functions on leafs */
|
|
TREE_ELEMENT *tree_insert(TREE *tree,void *key, uint key_size,
|
|
void *custom_arg);
|
|
void *tree_search(TREE *tree, void *key, void *custom_arg);
|
|
int tree_walk(TREE *tree,tree_walk_action action,
|
|
void *argument, TREE_WALK visit);
|
|
int tree_delete(TREE *tree, void *key, void *custom_arg);
|
|
void *tree_search_key(TREE *tree, const void *key,
|
|
TREE_ELEMENT **parents, TREE_ELEMENT ***last_pos,
|
|
enum ha_rkey_function flag, void *custom_arg);
|
|
void *tree_search_edge(TREE *tree, TREE_ELEMENT **parents,
|
|
TREE_ELEMENT ***last_pos, int child_offs);
|
|
void *tree_search_next(TREE *tree, TREE_ELEMENT ***last_pos, int l_offs,
|
|
int r_offs);
|
|
ha_rows tree_record_pos(TREE *tree, const void *key,
|
|
enum ha_rkey_function search_flag, void *custom_arg);
|
|
|
|
#define TREE_ELEMENT_EXTRA_SIZE (sizeof(TREE_ELEMENT) + sizeof(void*))
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#endif
|