diff --git a/include/global.h b/include/global.h index a11600a96fc8bd662e59e158cd242148c1e623eb..f41ac3ed184d8f7c71fd31e49778818c7740c842 100644 --- a/include/global.h +++ b/include/global.h @@ -349,6 +349,7 @@ typedef int pshort; /* Mixed prototypes can't take short int */ typedef double pfloat; /* Mixed prototypes can't take float */ #endif typedef int (*qsort_cmp)(const void *,const void *); +typedef int (*qsort_cmp2)(void*, const void *,const void *); #ifdef HAVE_mit_thread #define qsort_t void #undef QSORT_TYPE_IS_VOID diff --git a/include/my_tree.h b/include/my_tree.h index 0a227ea39448b5b6ae9028aedb016600acbd0216..c0950409588a1479b06d600aade09cfa55af9fa9 100644 --- a/include/my_tree.h +++ b/include/my_tree.h @@ -50,7 +50,8 @@ typedef struct st_tree { TREE_ELEMENT *root,null_element; TREE_ELEMENT **parents[MAX_TREE_HIGHT]; uint offset_to_key,elements_in_tree,size_of_element; - qsort_cmp compare; + qsort_cmp2 compare; + void* cmp_arg; MEM_ROOT mem_root; my_bool with_delete; void (*free)(void *); @@ -58,7 +59,7 @@ typedef struct st_tree { /* Functions on hole tree */ void init_tree(TREE *tree,uint default_alloc_size, int element_size, - qsort_cmp compare, my_bool with_delete, + qsort_cmp2 compare, my_bool with_delete, void (*free_element)(void*)); void delete_tree(TREE*); #define is_tree_inited(tree) ((tree)->root != 0) diff --git a/myisam/ft_boolean_search.c b/myisam/ft_boolean_search.c index 37faaea0a7f7c37d7ed82bd77d2730f9d40e132d..f0865932ca01df801b3bd3afc0127c8439e644f0 100644 --- a/myisam/ft_boolean_search.c +++ b/myisam/ft_boolean_search.c @@ -41,7 +41,8 @@ typedef struct st_ft_superdoc { ALL_IN_ONE *aio; } FT_SUPERDOC; -static int FT_SUPERDOC_cmp(FT_SUPERDOC *p1, FT_SUPERDOC *p2) +static int FT_SUPERDOC_cmp(void* cmp_arg __attribute__((unused)), + FT_SUPERDOC *p1, FT_SUPERDOC *p2) { if (p1->doc.dpos < p2->doc.dpos) return -1; diff --git a/myisam/ft_nlq_search.c b/myisam/ft_nlq_search.c index 3b4937ca4d921d659841c7e60d350e6496bba8fa..6d76fcef6e8f8a8cdf6d5560bde412dfc36db107 100644 --- a/myisam/ft_nlq_search.c +++ b/myisam/ft_nlq_search.c @@ -35,7 +35,8 @@ typedef struct st_ft_superdoc { double tmp_weight; } FT_SUPERDOC; -static int FT_SUPERDOC_cmp(FT_SUPERDOC *p1, FT_SUPERDOC *p2) +static int FT_SUPERDOC_cmp(void* cmp_arg __attribute__((unused)), + FT_SUPERDOC *p1, FT_SUPERDOC *p2) { if (p1->doc.dpos < p2->doc.dpos) return -1; @@ -162,7 +163,7 @@ FT_DOCLIST *ft_nlq_search(MI_INFO *info, uint keynr, byte *query, bzero(&allocated_wtree,sizeof(allocated_wtree)); - init_tree(&aio.dtree,0,sizeof(FT_SUPERDOC),(qsort_cmp)&FT_SUPERDOC_cmp,0, + init_tree(&aio.dtree,0,sizeof(FT_SUPERDOC),(qsort_cmp2)&FT_SUPERDOC_cmp,0, NULL); if(!(wtree=ft_parse(&allocated_wtree,query,query_len))) diff --git a/myisam/ft_parser.c b/myisam/ft_parser.c index d156c8c5556626719f6484fddd7c1bed0b17181e..ee4b5ea7202acc0287cb5b2bfd24e7336b3829f1 100644 --- a/myisam/ft_parser.c +++ b/myisam/ft_parser.c @@ -38,7 +38,8 @@ typedef struct st_ft_docstat { byte *keybuf; } FT_DOCSTAT; -static int FT_WORD_cmp(FT_WORD *w1, FT_WORD *w2) +static int FT_WORD_cmp(void* cmp_arg __attribute__((unused)), + FT_WORD *w1, FT_WORD *w2) { return _mi_compare_text(default_charset_info, (uchar*) w1->pos,w1->len, @@ -225,7 +226,7 @@ TREE * ft_parse(TREE *wtree, byte *doc, int doclen) if (!is_tree_inited(wtree)) { - init_tree(wtree,0,sizeof(FT_WORD),(qsort_cmp)&FT_WORD_cmp,0,NULL); + init_tree(wtree,0,sizeof(FT_WORD),(qsort_cmp2)&FT_WORD_cmp,0,NULL); } while (ft_simple_get_word(&doc,end,&w)) diff --git a/myisam/ft_stopwords.c b/myisam/ft_stopwords.c index 556f52650c8914c1672608334ca14a27aa055537..d3dedc4c4066d32bfc355102f6457e4c75004442 100644 --- a/myisam/ft_stopwords.c +++ b/myisam/ft_stopwords.c @@ -25,7 +25,8 @@ typedef struct st_ft_stopwords { static TREE *stopwords3=NULL; -static int FT_STOPWORD_cmp(FT_STOPWORD *w1, FT_STOPWORD *w2) +static int FT_STOPWORD_cmp(void* cmp_arg __attribute__((unused)), + FT_STOPWORD *w1, FT_STOPWORD *w2) { return _mi_compare_text(default_charset_info, (uchar *)w1->pos,w1->len, @@ -40,7 +41,7 @@ int ft_init_stopwords(const char **sws) if(!stopwords3) { if(!(stopwords3=(TREE *)my_malloc(sizeof(TREE),MYF(0)))) return -1; - init_tree(stopwords3,0,sizeof(FT_STOPWORD),(qsort_cmp)&FT_STOPWORD_cmp,0, + init_tree(stopwords3,0,sizeof(FT_STOPWORD),(qsort_cmp2)&FT_STOPWORD_cmp,0, NULL); } diff --git a/myisam/myisampack.c b/myisam/myisampack.c index 0e4b6eafbdefb4a1ceafcd43e8e2b0eb9e3944a7..90ba655e41f605a912d4fba7fe0a6591faea6a94 100644 --- a/myisam/myisampack.c +++ b/myisam/myisampack.c @@ -124,7 +124,8 @@ static void free_counts_and_tree_and_queue(HUFF_TREE *huff_trees, uint trees, HUFF_COUNTS *huff_counts, uint fields); -static int compare_tree(const uchar *s,const uchar *t); +static int compare_tree(void* cmp_arg __attribute__((unused)), + const uchar *s,const uchar *t); static int get_statistic(MRG_INFO *mrg,HUFF_COUNTS *huff_counts); static void check_counts(HUFF_COUNTS *huff_counts,uint trees, my_off_t records); @@ -673,7 +674,7 @@ static HUFF_COUNTS *init_huff_count(MI_INFO *info,my_off_t records) (type == FIELD_NORMAL || type == FIELD_SKIPP_ZERO)) count[i].max_zero_fill= count[i].field_length; - init_tree(&count[i].int_tree,0,-1,(qsort_cmp) compare_tree,0,NULL); + init_tree(&count[i].int_tree,0,-1,(qsort_cmp2) compare_tree,0,NULL); if (records && type != FIELD_BLOB && type != FIELD_VARCHAR) count[i].tree_pos=count[i].tree_buff = my_malloc(count[i].field_length > 1 ? tree_buff_length : 2, @@ -1289,7 +1290,8 @@ static int make_huff_tree(HUFF_TREE *huff_tree, HUFF_COUNTS *huff_counts) return 0; } -static int compare_tree(register const uchar *s, register const uchar *t) +static int compare_tree(void* cmp_arg __attribute__((unused)), + register const uchar *s, register const uchar *t) { uint length; for (length=global_count->field_length; length-- ;) diff --git a/mysys/tree.c b/mysys/tree.c index a36fd06f3f1c35d7f4f8cd70e0f499df74dbdea1..db2b3989b810338a24c54dd42b09f1eee29917b2 100644 --- a/mysys/tree.c +++ b/mysys/tree.c @@ -63,7 +63,7 @@ static void rb_delete_fixup(TREE *tree,TREE_ELEMENT ***parent); /* The actuall code for handling binary trees */ void init_tree(TREE *tree, uint default_alloc_size, int size, - qsort_cmp compare, my_bool with_delete, + qsort_cmp2 compare, my_bool with_delete, void (*free_element) (void *)) { DBUG_ENTER("init_tree"); @@ -77,6 +77,7 @@ void init_tree(TREE *tree, uint default_alloc_size, int size, tree->size_of_element=size > 0 ? (uint) size : 0; tree->free=free_element; tree->elements_in_tree=0; + tree->cmp_arg = 0; tree->null_element.colour=BLACK; tree->null_element.left=tree->null_element.right=0; if (!free_element && size >= 0 && @@ -152,7 +153,8 @@ TREE_ELEMENT *tree_insert(TREE *tree, void *key, uint key_size) for (;;) { if (element == &tree->null_element || - (cmp=(*tree->compare)(ELEMENT_KEY(tree,element),key)) == 0) + (cmp=(*tree->compare)(tree->cmp_arg, + ELEMENT_KEY(tree,element),key)) == 0) break; if (cmp < 0) { @@ -212,7 +214,8 @@ int tree_delete(TREE *tree, void *key) { if (element == &tree->null_element) return 1; /* Was not in tree */ - if ((cmp=(*tree->compare)(ELEMENT_KEY(tree,element),key)) == 0) + if ((cmp=(*tree->compare)(tree->cmp_arg, + ELEMENT_KEY(tree,element),key)) == 0) break; if (cmp < 0) { @@ -266,7 +269,8 @@ void *tree_search(TREE *tree, void *key) { if (element == &tree->null_element) return (void*) 0; - if ((cmp=(*tree->compare)(ELEMENT_KEY(tree,element),key)) == 0) + if ((cmp=(*tree->compare)(tree->cmp_arg, + ELEMENT_KEY(tree,element),key)) == 0) return ELEMENT_KEY(tree,element); if (cmp < 0) element=element->right; diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc index de367e8c052097442f0319616881fa6397460300..3cc53f1ef49ffa08583e5e8cb8d03aa09bb4c5f0 100644 --- a/sql/sql_analyse.cc +++ b/sql/sql_analyse.cc @@ -38,6 +38,37 @@ #define UINT_MAX24 0xffffff #define UINT_MAX32 0xffffffff +int sortcmp2(void* cmp_arg __attribute__((unused)), + const String *a,const String *b) +{ + return sortcmp(a,b); +} + +int stringcmp2(void* cmp_arg __attribute__((unused)), + const String *a,const String *b) +{ + return stringcmp(a,b); +} + +int compare_double2(void* cmp_arg __attribute__((unused)), + const double *s, const double *t) +{ + return compare_double(s,t); +} + +int compare_longlong2(void* cmp_arg __attribute__((unused)), + const longlong *s, const longlong *t) +{ + return compare_longlong(s,t); +} + +int compare_ulonglong2(void* cmp_arg __attribute__((unused)), + const ulonglong *s, const ulonglong *t) +{ + return compare_ulonglong(s,t); +} + + Procedure * proc_analyse_init(THD *thd, ORDER *param, select_result *result, List<Item> &field_list) diff --git a/sql/sql_analyse.h b/sql/sql_analyse.h index ce5c0af6a9627388139ef5c2f9877dfdbdd7b275..b5554314439dc2081f2b1305211b2dc0d73cf1d4 100644 --- a/sql/sql_analyse.h +++ b/sql/sql_analyse.h @@ -53,8 +53,14 @@ uint check_ulonglong(const char *str, uint length); bool get_ev_num_info(EV_NUM_INFO *ev_info, NUM_INFO *info, const char *num); bool test_if_number(NUM_INFO *info, const char *str, uint str_len); int compare_double(const double *s, const double *t); +int compare_double2(void* cmp_arg __attribute__((unused)), + const double *s, const double *t); int compare_longlong(const longlong *s, const longlong *t); +int compare_longlong2(void* cmp_arg __attribute__((unused)), + const longlong *s, const longlong *t); int compare_ulonglong(const ulonglong *s, const ulonglong *t); +int compare_ulonglong2(void* cmp_arg __attribute__((unused)), + const ulonglong *s, const ulonglong *t); Procedure *proc_analyse_init(THD *thd, ORDER *param, select_result *result, List<Item> &field_list); void free_string(String*); @@ -91,6 +97,11 @@ class field_info :public Sql_alloc int collect_string(String *element, element_count count, TREE_INFO *info); +int sortcmp2(void* cmp_arg __attribute__((unused)), + const String *a,const String *b); +int stringcmp2(void* cmp_arg __attribute__((unused)), + const String *a,const String *b); + class field_str :public field_info { String min_arg, max_arg; @@ -106,7 +117,7 @@ class field_str :public field_info must_be_blob(0), was_zero_fill(0), was_maybe_zerofill(0), can_be_still_num(1) { init_tree(&tree, 0, sizeof(String), a->binary ? - (qsort_cmp) stringcmp : (qsort_cmp) sortcmp, + (qsort_cmp2) stringcmp2 : (qsort_cmp2) sortcmp2, 0, (void (*)(void*)) free_string); }; void add(); @@ -146,7 +157,7 @@ class field_real: public field_info field_real(Item* a, analyse* b) :field_info(a,b), min_arg(0), max_arg(0), sum(0), sum_sqr(0), max_notzero_dec_len(0) { init_tree(&tree, 0, sizeof(double), - (qsort_cmp) compare_double, 0, NULL); } + (qsort_cmp2) compare_double2, 0, NULL); } void add(); void get_opt_type(String*, ha_rows); @@ -192,7 +203,7 @@ class field_longlong: public field_info field_longlong(Item* a, analyse* b) :field_info(a,b), min_arg(0), max_arg(0), sum(0), sum_sqr(0) { init_tree(&tree, 0, sizeof(longlong), - (qsort_cmp) compare_longlong, 0, NULL); } + (qsort_cmp2) compare_longlong2, 0, NULL); } void add(); void get_opt_type(String*, ha_rows); @@ -237,7 +248,7 @@ class field_ulonglong: public field_info field_ulonglong(Item* a, analyse * b) :field_info(a,b), min_arg(0), max_arg(0), sum(0),sum_sqr(0) { init_tree(&tree, 0, sizeof(ulonglong), - (qsort_cmp) compare_ulonglong, 0, NULL); } + (qsort_cmp2) compare_ulonglong2, 0, NULL); } void add(); void get_opt_type(String*, ha_rows); String *get_min_arg(String *s) { s->set(min_arg); return s; }