MDEV-34348: Consolidate cmp function declarations

Partial commit of the greater MDEV-34348 scope.
MDEV-34348: MariaDB is violating clang-16 -Wcast-function-type-strict

The functions queue_compare, qsort2_cmp, and qsort_cmp2
all had similar interfaces, and were used interchangable
and unsafely cast to one another.

This patch consolidates the functions all into the
qsort_cmp2 interface.

Reviewed By:
============
Marko Mäkelä <marko.makela@mariadb.com>
This commit is contained in:
Brandon Nesterenko 2024-10-26 08:17:03 -06:00
parent 3997d28f48
commit dbfee9fc2b
83 changed files with 678 additions and 524 deletions

View file

@ -12077,8 +12077,10 @@ void replace_dynstr_append_uint(DYNAMIC_STRING *ds, uint val)
keep_header If header should not be sorted
*/
static int comp_lines(const char **a, const char **b)
static int comp_lines(const void *a_, const void *b_)
{
auto a= static_cast<const char *const *>(a_);
auto b= static_cast<const char *const *>(b_);
return (strcmp(*a,*b));
}

View file

@ -42,6 +42,7 @@ SET(HEADERS
my_dbug.h
m_string.h
my_sys.h
my_cmp.h
my_xml.h
mysql_embed.h
my_decimal_limits.h

25
include/my_cmp.h Normal file
View file

@ -0,0 +1,25 @@
/* Copyright (c) 2024, MariaDB Corporation.
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; version 2 of the License.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
typedef int (*qsort_cmp)(const void *, const void *);
typedef int (*qsort_cmp2)(void *param, const void *a, const void *b);
#ifdef __cplusplus
}
#endif

View file

@ -528,10 +528,7 @@ typedef int pbool; /* Mixed prototypes can't take char */
typedef int pshort; /* Mixed prototypes can't take short int */
typedef double pfloat; /* Mixed prototypes can't take float */
#endif
C_MODE_START
typedef int (*qsort_cmp)(const void *,const void *);
typedef int (*qsort_cmp2)(void*, const void *,const void *);
C_MODE_END
#include <my_cmp.h>
#define qsort_t RETQSORTTYPE /* Broken GCC can't handle typedef !!!! */
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>

View file

@ -29,6 +29,7 @@ C_MODE_START
#include <stdarg.h>
#include <typelib.h>
#include <my_alloca.h>
#include <my_cmp.h>
#include <mysql/plugin.h>
#include <mysql/service_my_print_error.h>
@ -462,8 +463,6 @@ typedef struct st_io_cache /* Used when caching files */
size_t alloced_buffer;
} IO_CACHE;
typedef int (*qsort2_cmp)(const void *, const void *, const void *);
typedef void (*my_error_reporter)(enum loglevel level, const char *format, ...)
ATTRIBUTE_FORMAT_FPTR(printf, 2, 3);
@ -763,8 +762,8 @@ extern void radixsort_for_str_ptr(uchar* base[], uint number_of_elements,
extern qsort_t my_qsort(void *base_ptr, size_t total_elems, size_t size,
qsort_cmp cmp);
extern qsort_t my_qsort2(void *base_ptr, size_t total_elems, size_t size,
qsort2_cmp cmp, void *cmp_argument);
extern qsort2_cmp get_ptr_compare(size_t);
qsort_cmp2 cmp, void *cmp_argument);
extern qsort_cmp2 get_ptr_compare(size_t);
void my_store_ptr(uchar *buff, size_t pack_length, my_off_t pos);
my_off_t my_get_ptr(uchar *ptr, size_t pack_length);
extern int init_io_cache(IO_CACHE *info,File file,size_t cachesize,

View file

@ -373,7 +373,7 @@ typedef struct st_mi_sort_param
my_bool fix_datafile, master;
my_bool calc_checksum; /* calculate table checksum */
int (*key_cmp)(struct st_mi_sort_param *, const void *, const void *);
int (*key_cmp)(void *, const void *, const void *);
int (*key_read)(struct st_mi_sort_param *,void *);
int (*key_write)(struct st_mi_sort_param *, const void *);
void (*lock_in_memory)(HA_CHECK *);

View file

@ -31,6 +31,8 @@
#ifndef _queues_h
#define _queues_h
#include <my_cmp.h>
#ifdef __cplusplus
extern "C" {
#endif
@ -44,7 +46,7 @@ typedef struct st_queue {
uint offset_to_queue_pos; /* If we want to store position in element */
uint auto_extent;
int max_at_top; /* Normally 1, set to -1 if queue_top gives max */
int (*compare)(void *, uchar *,uchar *);
qsort_cmp2 compare;
} QUEUE;
#define queue_first_element(queue) 1
@ -58,14 +60,13 @@ typedef struct st_queue {
#define queue_set_max_at_top(queue, set_arg) \
(queue)->max_at_top= set_arg ? -1 : 1
#define queue_remove_top(queue_arg) queue_remove((queue_arg), queue_first_element(queue_arg))
typedef int (*queue_compare)(void *,uchar *, uchar *);
int init_queue(QUEUE *queue,uint max_elements,uint offset_to_key,
my_bool max_at_top, queue_compare compare,
my_bool max_at_top, qsort_cmp2 compare,
void *first_cmp_arg, uint offset_to_queue_pos,
uint auto_extent);
int reinit_queue(QUEUE *queue,uint max_elements,uint offset_to_key,
my_bool max_at_top, queue_compare compare,
my_bool max_at_top, qsort_cmp2 compare,
void *first_cmp_arg, uint offset_to_queue_pos,
uint auto_extent);
int resize_queue(QUEUE *queue, uint max_elements);

View file

@ -3753,8 +3753,10 @@ static void free_block(SIMPLE_KEY_CACHE_CB *keycache, BLOCK_LINK *block)
}
static int cmp_sec_link(BLOCK_LINK **a, BLOCK_LINK **b)
static int cmp_sec_link(const void *_a, const void *_b)
{
BLOCK_LINK *const *a= _a;
BLOCK_LINK *const *b= _b;
return (((*a)->hash_link->diskpos < (*b)->hash_link->diskpos) ? -1 :
((*a)->hash_link->diskpos > (*b)->hash_link->diskpos) ? 1 : 0);
}

View file

@ -84,7 +84,7 @@ typedef struct st_stack
/****************************************************************************
** 'standard' quicksort with the following extensions:
**
** Can be compiled with the qsort2_cmp compare function
** Can be compiled with the qsort_cmp2 compare function
** Store ranges on stack to avoid recursion
** Use insert sort on small ranges
** Optimize for sorting of pointers (used often by MySQL)
@ -92,7 +92,7 @@ typedef struct st_stack
*****************************************************************************/
#ifdef QSORT_EXTRA_CMP_ARGUMENT
qsort_t my_qsort2(void *base_ptr, size_t count, size_t size, qsort2_cmp cmp,
qsort_t my_qsort2(void *base_ptr, size_t count, size_t size, qsort_cmp2 cmp,
void *cmp_argument)
#else
qsort_t my_qsort(void *base_ptr, size_t count, size_t size, qsort_cmp cmp)

View file

@ -57,7 +57,7 @@
#define NAMES_START_SIZE 32768
static int comp_names(struct fileinfo *a,struct fileinfo *b);
static int comp_names(const void *a, const void *b);
typedef struct {
MY_DIR dir;
@ -83,8 +83,10 @@ void my_dirend(MY_DIR *dir)
/* Compare in sort of filenames */
static int comp_names(struct fileinfo *a, struct fileinfo *b)
static int comp_names(const void *a_, const void *b_)
{
const struct fileinfo *a= a_;
const struct fileinfo *b= b_;
return (strcmp(a->name,b->name));
} /* comp_names */

View file

@ -55,8 +55,10 @@ void init_my_likely()
pthread_mutex_init(&likely_mutex, MY_MUTEX_INIT_FAST);
}
static int likely_cmp(LIKELY_ENTRY **a, LIKELY_ENTRY **b)
static int likely_cmp(const void *a_, const void *b_)
{
const LIKELY_ENTRY *const *a= a_;
const LIKELY_ENTRY *const *b= b_;
int cmp;
if ((cmp= strcmp((*a)->key, (*b)->key)))
return cmp;

View file

@ -44,40 +44,43 @@
#include <string.h>
static int native_compare(size_t *length, unsigned char **a, unsigned char **b)
static int native_compare(void *length_, const void *a_, const void *b_)
{
size_t *length= length_;
const unsigned char *const *a= a_;
const unsigned char *const *b= b_;
return memcmp(*a, *b, *length);
}
qsort2_cmp get_ptr_compare (size_t size __attribute__((unused)))
qsort_cmp2 get_ptr_compare (size_t size __attribute__((unused)))
{
return (qsort2_cmp) native_compare;
return native_compare;
}
#else /* USE_NATIVE_MEMCMP */
static int ptr_compare(size_t *compare_length, uchar **a, uchar **b);
static int ptr_compare_0(size_t *compare_length, uchar **a, uchar **b);
static int ptr_compare_1(size_t *compare_length, uchar **a, uchar **b);
static int ptr_compare_2(size_t *compare_length, uchar **a, uchar **b);
static int ptr_compare_3(size_t *compare_length, uchar **a, uchar **b);
static int degenerate_compare_func(size_t *compare_length, uchar **a, uchar **b)
static int ptr_compare(void *compare_length, const void *a, const void *b);
static int ptr_compare_0(void *compare_length, const void *a, const void *b);
static int ptr_compare_1(void *compare_length, const void *a, const void *b);
static int ptr_compare_2(void *compare_length, const void *a, const void *b);
static int ptr_compare_3(void *compare_length, const void *a, const void *b);
static int degenerate_compare_func(void *compare_length, const void *a, const void *b)
{
DBUG_ASSERT(*compare_length == 0);
DBUG_ASSERT(*((size_t *) compare_length) == 0);
return 0;
}
qsort2_cmp get_ptr_compare (size_t size)
qsort_cmp2 get_ptr_compare (size_t size)
{
if (size == 0)
return (qsort2_cmp) degenerate_compare_func;
return degenerate_compare_func;
if (size < 4)
return (qsort2_cmp) ptr_compare;
return ptr_compare;
switch (size & 3) {
case 0: return (qsort2_cmp) ptr_compare_0;
case 1: return (qsort2_cmp) ptr_compare_1;
case 2: return (qsort2_cmp) ptr_compare_2;
case 3: return (qsort2_cmp) ptr_compare_3;
case 0: return ptr_compare_0;
case 1: return ptr_compare_1;
case 2: return ptr_compare_2;
case 3: return ptr_compare_3;
}
return 0; /* Impossible */
}
@ -88,13 +91,13 @@ qsort2_cmp get_ptr_compare (size_t size)
#define cmp(N) if (first[N] != last[N]) return (int) first[N] - (int) last[N]
static int ptr_compare(size_t *compare_length, uchar **a, uchar **b)
static int ptr_compare(void *compare_length, const void *a, const void *b)
{
size_t length= *compare_length;
uchar *first,*last;
size_t length= *((size_t *) compare_length);
const uchar *first= *((const uchar *const *) a);
const uchar *last= *((const uchar *const *) b);
DBUG_ASSERT(length > 0);
first= *a; last= *b;
while (--length)
{
if (*first++ != *last++)
@ -104,12 +107,11 @@ static int ptr_compare(size_t *compare_length, uchar **a, uchar **b)
}
static int ptr_compare_0(size_t *compare_length,uchar **a, uchar **b)
static int ptr_compare_0(void *compare_length, const void *a, const void *b)
{
size_t length= *compare_length;
uchar *first,*last;
first= *a; last= *b;
size_t length= *((size_t *) compare_length);
const uchar *first= *((const uchar *const *) a);
const uchar *last= *((const uchar *const *) b);
loop:
cmp(0);
cmp(1);
@ -125,12 +127,13 @@ static int ptr_compare_0(size_t *compare_length,uchar **a, uchar **b)
}
static int ptr_compare_1(size_t *compare_length,uchar **a, uchar **b)
static int ptr_compare_1(void *compare_length, const void *a, const void *b)
{
size_t length= *compare_length-1;
uchar *first,*last;
first= *a+1; last= *b+1;
size_t length= *((size_t *) compare_length) - 1;
const uchar *first= *((const uchar *const *) a) + 1;
const uchar *last= *((const uchar *const *) b) + 1;
cmp(-1);
loop:
cmp(0);
@ -146,12 +149,12 @@ static int ptr_compare_1(size_t *compare_length,uchar **a, uchar **b)
return (0);
}
static int ptr_compare_2(size_t *compare_length,uchar **a, uchar **b)
static int ptr_compare_2(void *compare_length, const void *a, const void *b)
{
size_t length= *compare_length-2;
uchar *first,*last;
size_t length= *((size_t *) compare_length) - 2;
const uchar *first= *((const uchar *const *) a) + 2;
const uchar *last= *((const uchar *const *) b) + 2;
first= *a +2 ; last= *b +2;
cmp(-2);
cmp(-1);
loop:
@ -168,12 +171,12 @@ static int ptr_compare_2(size_t *compare_length,uchar **a, uchar **b)
return (0);
}
static int ptr_compare_3(size_t *compare_length,uchar **a, uchar **b)
static int ptr_compare_3(void *compare_length, const void *a, const void *b)
{
size_t length= *compare_length-3;
uchar *first,*last;
size_t length= *((size_t *) compare_length) - 3;
const uchar *first= *((const uchar *const *) a) + 3;
const uchar *last= *((const uchar *const *) b) + 3;
first= *a +3 ; last= *b +3;
cmp(-3);
cmp(-2);
cmp(-1);

View file

@ -70,7 +70,7 @@
*/
int init_queue(QUEUE *queue, uint max_elements, uint offset_to_key,
my_bool max_at_top, int (*compare) (void *, uchar *, uchar *),
my_bool max_at_top, qsort_cmp2 compare,
void *first_cmp_arg, uint offset_to_queue_pos,
uint auto_extent)
{
@ -109,7 +109,7 @@ int init_queue(QUEUE *queue, uint max_elements, uint offset_to_key,
*/
int reinit_queue(QUEUE *queue, uint max_elements, uint offset_to_key,
my_bool max_at_top, int (*compare) (void *, uchar *, uchar *),
my_bool max_at_top, qsort_cmp2 compare,
void *first_cmp_arg, uint offset_to_queue_pos,
uint auto_extent)
{

View file

@ -77,10 +77,11 @@ static void *alarm_handler(void *arg);
static sig_handler thread_alarm(int sig __attribute__((unused)));
static int compare_ulong(void *not_used __attribute__((unused)),
uchar *a_ptr,uchar* b_ptr)
const void *a_ptr, const void *b_ptr)
{
ulong a=*((ulong*) a_ptr),b= *((ulong*) b_ptr);
return (a < b) ? -1 : (a == b) ? 0 : 1;
const ulong *ap= a_ptr;
const ulong *bp= b_ptr;
return (*ap < *bp) ? -1 : (*ap == *bp) ? 0 : 1;
}
void init_thr_alarm(uint max_alarms)

View file

@ -46,10 +46,11 @@ static void *timer_handler(void *arg __attribute__((unused)));
*/
static int compare_timespec(void *not_used __attribute__((unused)),
uchar *a_ptr, uchar *b_ptr)
const void *a_ptr, const void *b_ptr)
{
return cmp_timespec((*(struct timespec*) a_ptr),
(*(struct timespec*) b_ptr));
const struct timespec *ap= a_ptr;
const struct timespec *bp= b_ptr;
return cmp_timespec((*ap), (*bp));
}

View file

@ -594,9 +594,9 @@ public:
Inet6_null tmp(arg);
return m_null_value || tmp.is_null() ? UNKNOWN : m_native.cmp(tmp) != 0;
}
int compare(cmp_item *ci) override
int compare(const cmp_item *ci) const override
{
cmp_item_inet6 *tmp= static_cast<cmp_item_inet6*>(ci);
const cmp_item_inet6 *tmp= static_cast<const cmp_item_inet6*>(ci);
DBUG_ASSERT(!m_null_value);
DBUG_ASSERT(!tmp->m_null_value);
return m_native.cmp(tmp->m_native);
@ -1293,13 +1293,15 @@ public:
class in_inet6 :public in_vector
{
Inet6 m_value;
static int cmp_inet6(void *cmp_arg, Inet6 *a, Inet6 *b)
static int cmp_inet6(void *, const void *a_, const void *b_)
{
const Inet6 *a= static_cast<const Inet6*>(a_);
const Inet6 *b= static_cast<const Inet6*>(b_);
return a->cmp(*b);
}
public:
in_inet6(THD *thd, uint elements)
:in_vector(thd, elements, sizeof(Inet6), (qsort2_cmp) cmp_inet6, 0),
:in_vector(thd, elements, sizeof(Inet6), cmp_inet6, 0),
m_value(Inet6_zero())
{ }
const Type_handler *type_handler() const override

View file

@ -62,16 +62,6 @@ public:
Element_type *from,
bool packing_keys);
/**
Function for comparing two keys.
@param n Pointer to number of bytes to compare.
@param a First key.
@param b Second key.
@retval -1, 0, or 1 depending on whether the left argument is
less than, equal to, or greater than the right argument.
*/
typedef int (*compare_function)(size_t *n, Key_type **a, Key_type **b);
/**
Initialize the queue.
@ -81,8 +71,6 @@ public:
pop() will return the smallest key in the result set.
true: We keep the n smallest elements.
pop() will return the largest key in the result set.
@param compare Compare function for elements, takes 3 arguments.
If NULL, we use get_ptr_compare(compare_length).
@param compare_length Length of the data (i.e. the keys) used for sorting.
@param keymaker Function which generates keys for elements.
@param sort_param Sort parameters.
@ -93,7 +81,7 @@ public:
We do *not* take ownership of any of the input pointer arguments.
*/
int init(ha_rows max_elements, bool max_at_top,
compare_function compare, size_t compare_length,
size_t compare_length,
keymaker_function keymaker, Sort_param *sort_param,
Key_type **sort_keys);
@ -148,7 +136,6 @@ private:
template<typename Element_type, typename Key_type>
int Bounded_queue<Element_type, Key_type>::init(ha_rows max_elements,
bool max_at_top,
compare_function compare,
size_t compare_length,
keymaker_function keymaker,
Sort_param *sort_param,
@ -163,13 +150,10 @@ int Bounded_queue<Element_type, Key_type>::init(ha_rows max_elements,
// init_queue() takes an uint, and also does (max_elements + 1)
if (max_elements >= (UINT_MAX - 1))
return 1;
if (compare == NULL)
compare=
reinterpret_cast<compare_function>(get_ptr_compare(compare_length));
// We allocate space for one extra element, for replace when queue is full.
return init_queue(&m_queue, (uint) max_elements + 1,
0, max_at_top,
reinterpret_cast<queue_compare>(compare),
get_ptr_compare(compare_length),
&m_compare_length, 0, 0);
}

View file

@ -67,10 +67,10 @@
extern "C" int event_queue_element_compare_q(void *, uchar *, uchar *);
int event_queue_element_compare_q(void *vptr, uchar* a, uchar *b)
int event_queue_element_compare_q(void *, const void *a, const void *b)
{
Event_queue_element *left = (Event_queue_element *)a;
Event_queue_element *right = (Event_queue_element *)b;
auto left= static_cast<const Event_queue_element *>(a);
auto right= static_cast<const Event_queue_element *>(b);
my_time_t lhs = left->execute_at;
my_time_t rhs = right->execute_at;

View file

@ -283,7 +283,6 @@ SORT_INFO *filesort(THD *thd, TABLE *table, Filesort *filesort,
sort->init_record_pointers();
if (pq.init(param.max_rows,
true, // max_at_top
NULL, // compare_function
compare_length,
&make_sortkey, &param, sort->get_sort_keys()))
{
@ -1820,7 +1819,7 @@ bool merge_buffers(Sort_param *param, IO_CACHE *from_file,
uchar *strpos;
Merge_chunk *buffpek;
QUEUE queue;
qsort2_cmp cmp;
qsort_cmp2 cmp;
void *first_cmp_arg;
element_count dupl_count= 0;
uchar *src;
@ -1864,9 +1863,9 @@ bool merge_buffers(Sort_param *param, IO_CACHE *from_file,
cmp= param->get_compare_function();
first_cmp_arg= param->get_compare_argument(&sort_length);
}
if (unlikely(init_queue(&queue, (uint) (Tb-Fb)+1,
offsetof(Merge_chunk,m_current_key), 0,
(queue_compare) cmp, first_cmp_arg, 0, 0)))
if (unlikely(init_queue(&queue, (uint) (Tb - Fb) + 1,
offsetof(Merge_chunk, m_current_key), 0, cmp,
first_cmp_arg, 0, 0)))
DBUG_RETURN(1); /* purecov: inspected */
const size_t chunk_sz = (sort_buffer.size()/((uint) (Tb-Fb) +1));
for (buffpek= Fb ; buffpek <= Tb ; buffpek++)
@ -2786,9 +2785,9 @@ void SORT_FIELD_ATTR::set_length_and_original_length(THD *thd, uint length_arg)
Compare function used for packing sort keys
*/
qsort2_cmp get_packed_keys_compare_ptr()
qsort_cmp2 get_packed_keys_compare_ptr()
{
return (qsort2_cmp) compare_packed_sort_keys;
return compare_packed_sort_keys;
}
@ -2802,8 +2801,8 @@ qsort2_cmp get_packed_keys_compare_ptr()
suffix_bytes are used only for binary columns.
*/
int SORT_FIELD_ATTR::compare_packed_varstrings(uchar *a, size_t *a_len,
uchar *b, size_t *b_len)
int SORT_FIELD_ATTR::compare_packed_varstrings(const uchar *a, size_t *a_len,
const uchar *b, size_t *b_len)
{
int retval;
size_t a_length, b_length;
@ -2862,8 +2861,8 @@ int SORT_FIELD_ATTR::compare_packed_varstrings(uchar *a, size_t *a_len,
packed-value format.
*/
int SORT_FIELD_ATTR::compare_packed_fixed_size_vals(uchar *a, size_t *a_len,
uchar *b, size_t *b_len)
int SORT_FIELD_ATTR::compare_packed_fixed_size_vals(const uchar *a, size_t *a_len,
const uchar *b, size_t *b_len)
{
if (maybe_null)
{
@ -2908,15 +2907,15 @@ int SORT_FIELD_ATTR::compare_packed_fixed_size_vals(uchar *a, size_t *a_len,
*/
int compare_packed_sort_keys(void *sort_param,
unsigned char **a_ptr, unsigned char **b_ptr)
int compare_packed_sort_keys(void *sort_param, const void *a_ptr,
const void *b_ptr)
{
int retval= 0;
size_t a_len, b_len;
Sort_param *param= (Sort_param*)sort_param;
Sort_param *param= static_cast<Sort_param *>(sort_param);
Sort_keys *sort_keys= param->sort_keys;
uchar *a= *a_ptr;
uchar *b= *b_ptr;
auto a= *(static_cast<const uchar *const *>(a_ptr));
auto b= *(static_cast<const uchar *const *>(b_ptr));
a+= Sort_keys::size_of_length_field;
b+= Sort_keys::size_of_length_field;

View file

@ -268,8 +268,8 @@ private:
longlong m_idx;
};
int compare_packed_sort_keys(void *sort_keys, unsigned char **a,
unsigned char **b);
qsort2_cmp get_packed_keys_compare_ptr();
int compare_packed_sort_keys(void *sort_param, const void *a_ptr,
const void *b_ptr);
qsort_cmp2 get_packed_keys_compare_ptr();
#endif // FILESORT_UTILS_INCLUDED

View file

@ -5515,7 +5515,7 @@ bool ha_partition::init_record_priority_queue()
m_start_key.key= (const uchar*)ptr;
/* Initialize priority queue, initialized to reading forward. */
int (*cmp_func)(void *, uchar *, uchar *);
int (*cmp_func)(void *, const void *, const void *);
void *cmp_arg= (void*) this;
if (!m_using_extended_keys && !(table_flags() & HA_SLOW_CMP_REF))
cmp_func= cmp_key_rowid_part_id;
@ -5763,8 +5763,10 @@ int ha_partition::index_read_map(uchar *buf, const uchar *key,
/* Compare two part_no partition numbers */
static int cmp_part_ids(uchar *ref1, uchar *ref2)
static int cmp_part_ids(const void *ref1_, const void *ref2_)
{
auto ref1= static_cast<const uchar *>(ref1_);
auto ref2= static_cast<const uchar *>(ref2_);
uint32 diff2= uint2korr(ref2);
uint32 diff1= uint2korr(ref1);
if (diff2 > diff1)
@ -5780,9 +5782,12 @@ static int cmp_part_ids(uchar *ref1, uchar *ref2)
Provide ordering by (key_value, part_no).
*/
extern "C" int cmp_key_part_id(void *ptr, uchar *ref1, uchar *ref2)
extern "C" int cmp_key_part_id(void *ptr, const void *ref1_, const void *ref2_)
{
ha_partition *file= (ha_partition*)ptr;
const ha_partition *file= static_cast<const ha_partition *>(ptr);
const uchar *ref1= static_cast<const uchar *>(ref1_);
const uchar *ref2= static_cast<const uchar *>(ref2_);
if (int res= key_rec_cmp(file->m_curr_key_info,
ref1 + PARTITION_BYTES_IN_POS,
ref2 + PARTITION_BYTES_IN_POS))
@ -5794,9 +5799,13 @@ extern "C" int cmp_key_part_id(void *ptr, uchar *ref1, uchar *ref2)
@brief
Provide ordering by (key_value, underying_table_rowid, part_no).
*/
extern "C" int cmp_key_rowid_part_id(void *ptr, uchar *ref1, uchar *ref2)
extern "C" int cmp_key_rowid_part_id(void *ptr, const void *ref1_,
const void *ref2_)
{
ha_partition *file= (ha_partition*)ptr;
const ha_partition *file= static_cast<const ha_partition *>(ptr);
const uchar *ref1= static_cast<const uchar *>(ref1_);
const uchar *ref2= static_cast<const uchar *>(ref2_);
int res;
if ((res= key_rec_cmp(file->m_curr_key_info, ref1 + PARTITION_BYTES_IN_POS,
@ -8348,10 +8357,12 @@ int ha_partition::handle_ordered_prev(uchar *buf)
Helper function for sorting according to number of rows in descending order.
*/
int ha_partition::compare_number_of_records(ha_partition *me,
const uint32 *a,
const uint32 *b)
int ha_partition::compare_number_of_records(void *me_, const void *a_,
const void *b_)
{
const ha_partition *me= static_cast<const ha_partition *>(me_);
const uint32 *a= static_cast<const uint32 *>(a_);
const uint32 *b= static_cast<const uint32 *>(b_);
handler **file= me->m_file;
/* Note: sorting in descending order! */
if (file[*a]->stats.records > file[*b]->stats.records)
@ -8651,7 +8662,7 @@ int ha_partition::info(uint flag)
my_qsort2((void*) m_part_ids_sorted_by_num_of_records,
m_tot_parts,
sizeof(uint32),
(qsort2_cmp) compare_number_of_records,
compare_number_of_records,
this);
file= m_file[handler_instance];

View file

@ -277,8 +277,8 @@ typedef struct st_partition_part_key_multi_range_hld
} PARTITION_PART_KEY_MULTI_RANGE_HLD;
extern "C" int cmp_key_part_id(void *key_p, uchar *ref1, uchar *ref2);
extern "C" int cmp_key_rowid_part_id(void *ptr, uchar *ref1, uchar *ref2);
extern "C" int cmp_key_part_id(void *key_p, const void *ref1, const void *ref2);
extern "C" int cmp_key_rowid_part_id(void *ptr, const void *ref1, const void *ref2);
class ha_partition :public handler
{
@ -446,9 +446,7 @@ private:
/** Sorted array of partition ids in descending order of number of rows. */
uint32 *m_part_ids_sorted_by_num_of_records;
/* Compare function for my_qsort2, for reversed order. */
static int compare_number_of_records(ha_partition *me,
const uint32 *a,
const uint32 *b);
static int compare_number_of_records(void *me, const void *a, const void *b);
/** keep track of partitions to call ha_reset */
MY_BITMAP m_partitions_to_reset;
/** partitions that returned HA_ERR_KEY_NOT_FOUND. */
@ -1635,8 +1633,9 @@ public:
int notify_tabledef_changed(LEX_CSTRING *db, LEX_CSTRING *table,
LEX_CUSTRING *frm, LEX_CUSTRING *version);
friend int cmp_key_rowid_part_id(void *ptr, uchar *ref1, uchar *ref2);
friend int cmp_key_part_id(void *key_p, uchar *ref1, uchar *ref2);
friend int cmp_key_rowid_part_id(void *ptr, const void *ref1,
const void *ref2);
friend int cmp_key_part_id(void *key_p, const void *ref1, const void *ref2);
bool can_convert_nocopy(const Field &field,
const Column_definition &new_field) const override;

View file

@ -6116,15 +6116,19 @@ static int cmp_file_names(const void *a, const void *b)
return cs->strnncoll(aa, strlen(aa), bb, strlen(bb));
}
static int cmp_table_names(LEX_CSTRING * const *a, LEX_CSTRING * const *b)
static int cmp_table_names(const void *a_, const void *b_)
{
auto a= static_cast<const LEX_CSTRING *const *>(a_);
auto b= static_cast<const LEX_CSTRING *const *>(b_);
return my_charset_bin.strnncoll((*a)->str, (*a)->length,
(*b)->str, (*b)->length);
}
#ifndef DBUG_OFF
static int cmp_table_names_desc(LEX_CSTRING * const *a, LEX_CSTRING * const *b)
static int cmp_table_names_desc(const void *a_, const void *b_)
{
auto a= static_cast<const LEX_CSTRING *const *>(a_);
auto b= static_cast<const LEX_CSTRING *const *>(b_);
return -cmp_table_names(a, b);
}
#endif

View file

@ -3650,10 +3650,10 @@ static inline int cmp_ulongs (ulonglong a_val, ulonglong b_val)
0 left argument is equal to the right argument.
1 left argument is greater than the right argument.
*/
int cmp_longlong(void *cmp_arg,
in_longlong::packed_longlong *a,
in_longlong::packed_longlong *b)
int cmp_longlong(void *, const void *a_, const void *b_)
{
auto a= static_cast<const in_longlong::packed_longlong *>(a_);
auto b= static_cast<const in_longlong::packed_longlong *>(b_);
if (a->unsigned_flag != b->unsigned_flag)
{
/*
@ -3675,19 +3675,26 @@ int cmp_longlong(void *cmp_arg,
return cmp_longs(a->val, b->val);
}
static int cmp_double(void *cmp_arg, double *a,double *b)
static int cmp_double(void *, const void *a_, const void *b_)
{
const double *a= static_cast<const double *>(a_);
const double *b= static_cast<const double *>(b_);
return *a < *b ? -1 : *a == *b ? 0 : 1;
}
static int cmp_row(void *cmp_arg, cmp_item_row *a, cmp_item_row *b)
static int cmp_row(void *, const void *a_, const void *b_)
{
const cmp_item_row *a= static_cast<const cmp_item_row *>(a_);
const cmp_item_row *b= static_cast<const cmp_item_row *>(b_);
return a->compare(b);
}
static int cmp_decimal(void *cmp_arg, my_decimal *a, my_decimal *b)
static int cmp_decimal(void *, const void *a_, const void *b_)
{
my_decimal *a= const_cast<my_decimal *>(static_cast<const my_decimal *>(a_));
my_decimal *b= const_cast<my_decimal *>(static_cast<const my_decimal *>(b_));
/*
We need call of fixing buffer pointer, because fast sort just copy
decimal buffers in memory and pointers left pointing on old buffer place
@ -3710,17 +3717,19 @@ bool in_vector::find(Item *item)
{
uint mid=(start+end+1)/2;
int res;
if ((res=(*compare)(collation, base+mid*size, result)) == 0)
if ((res= (*compare)(const_cast<charset_info_st *>(collation),
base + mid * size, result)) == 0)
return true;
if (res < 0)
start=mid;
else
end=mid-1;
}
return ((*compare)(collation, base+start*size, result) == 0);
return ((*compare)(const_cast<charset_info_st *>(collation),
base + start * size, result) == 0);
}
in_string::in_string(THD *thd, uint elements, qsort2_cmp cmp_func,
in_string::in_string(THD *thd, uint elements, qsort_cmp2 cmp_func,
CHARSET_INFO *cs)
:in_vector(thd, elements, sizeof(String), cmp_func, cs),
tmp(buff, sizeof(buff), &my_charset_bin)
@ -3775,7 +3784,7 @@ in_row::in_row(THD *thd, uint elements, Item * item)
{
base= (char*) new (thd->mem_root) cmp_item_row[count= elements];
size= sizeof(cmp_item_row);
compare= (qsort2_cmp) cmp_row;
compare= cmp_row;
/*
We need to reset these as otherwise we will call sort() with
uninitialized (even if not used) elements
@ -3807,8 +3816,7 @@ bool in_row::set(uint pos, Item *item)
}
in_longlong::in_longlong(THD *thd, uint elements)
:in_vector(thd, elements, sizeof(packed_longlong),
(qsort2_cmp) cmp_longlong, 0)
: in_vector(thd, elements, sizeof(packed_longlong), cmp_longlong, 0)
{}
bool in_longlong::set(uint pos, Item *item)
@ -3839,16 +3847,16 @@ Item *in_longlong::create_item(THD *thd)
}
static int cmp_timestamp(void *cmp_arg,
Timestamp_or_zero_datetime *a,
Timestamp_or_zero_datetime *b)
static int cmp_timestamp(void *, const void *a_, const void *b_)
{
auto a= static_cast<const Timestamp_or_zero_datetime *>(a_);
auto b= static_cast<const Timestamp_or_zero_datetime *>(b_);
return a->cmp(*b);
}
in_timestamp::in_timestamp(THD *thd, uint elements)
:in_vector(thd, elements, sizeof(Value), (qsort2_cmp) cmp_timestamp, 0)
:in_vector(thd, elements, sizeof(Value), cmp_timestamp, 0)
{}
@ -3932,7 +3940,7 @@ Item *in_temporal::create_item(THD *thd)
in_double::in_double(THD *thd, uint elements)
:in_vector(thd, elements, sizeof(double), (qsort2_cmp) cmp_double, 0)
:in_vector(thd, elements, sizeof(double), cmp_double, 0)
{}
bool in_double::set(uint pos, Item *item)
@ -3956,7 +3964,7 @@ Item *in_double::create_item(THD *thd)
in_decimal::in_decimal(THD *thd, uint elements)
:in_vector(thd, elements, sizeof(my_decimal), (qsort2_cmp) cmp_decimal, 0)
:in_vector(thd, elements, sizeof(my_decimal), cmp_decimal, 0)
{}
@ -4201,9 +4209,9 @@ int cmp_item_row::cmp(Item *arg)
}
int cmp_item_row::compare(cmp_item *c)
int cmp_item_row::compare(const cmp_item *c) const
{
cmp_item_row *l_cmp= (cmp_item_row *) c;
auto l_cmp= static_cast<const cmp_item_row *>(c);
for (uint i=0; i < n; i++)
{
int res;
@ -4239,9 +4247,9 @@ int cmp_item_decimal::cmp(Item *arg)
}
int cmp_item_decimal::compare(cmp_item *arg)
int cmp_item_decimal::compare(const cmp_item *arg) const
{
cmp_item_decimal *l_cmp= (cmp_item_decimal*) arg;
auto l_cmp= static_cast<const cmp_item_decimal *>(arg);
return my_decimal_cmp(&value, &l_cmp->value);
}
@ -4282,9 +4290,9 @@ int cmp_item_time::cmp(Item *arg)
}
int cmp_item_temporal::compare(cmp_item *ci)
int cmp_item_temporal::compare(const cmp_item *ci) const
{
cmp_item_temporal *l_cmp= (cmp_item_temporal *)ci;
auto l_cmp= static_cast<const cmp_item_temporal *>(ci);
return (value < l_cmp->value) ? -1 : ((value == l_cmp->value) ? 0 : 1);
}
@ -4330,9 +4338,9 @@ int cmp_item_timestamp::cmp(Item *arg)
}
int cmp_item_timestamp::compare(cmp_item *arg)
int cmp_item_timestamp::compare(const cmp_item *arg) const
{
cmp_item_timestamp *tmp= static_cast<cmp_item_timestamp*>(arg);
auto tmp= static_cast<const cmp_item_timestamp *>(arg);
return type_handler_timestamp2.cmp_native(m_native, tmp->m_native);
}

View file

@ -1365,12 +1365,12 @@ class in_vector :public Sql_alloc
public:
char *base;
uint size;
qsort2_cmp compare;
qsort_cmp2 compare;
CHARSET_INFO *collation;
uint count;
uint used_count;
in_vector() = default;
in_vector(THD *thd, uint elements, uint element_length, qsort2_cmp cmp_func,
in_vector(THD *thd, uint elements, uint element_length, qsort_cmp2 cmp_func,
CHARSET_INFO *cmp_coll)
:base((char*) thd_calloc(thd, elements * element_length)),
size(element_length), compare(cmp_func), collation(cmp_coll),
@ -1414,7 +1414,8 @@ public:
/* Compare values number pos1 and pos2 for equality */
bool compare_elems(uint pos1, uint pos2)
{
return MY_TEST(compare(collation, base + pos1 * size, base + pos2 * size));
return MY_TEST(compare(const_cast<charset_info_st *>(collation),
base + pos1 * size, base + pos2 * size));
}
virtual const Type_handler *type_handler() const= 0;
};
@ -1436,7 +1437,7 @@ class in_string :public in_vector
}
};
public:
in_string(THD *thd, uint elements, qsort2_cmp cmp_func, CHARSET_INFO *cs);
in_string(THD *thd, uint elements, qsort_cmp2 cmp_func, CHARSET_INFO *cs);
~in_string();
bool set(uint pos, Item *item) override;
uchar *get_value(Item *item) override;
@ -1476,7 +1477,7 @@ public:
}
const Type_handler *type_handler() const override { return &type_handler_slonglong; }
friend int cmp_longlong(void *cmp_arg, packed_longlong *a,packed_longlong *b);
friend int cmp_longlong(void *cmp_arg, const void *a, const void *b);
};
@ -1510,7 +1511,7 @@ public:
Item_datetime *dt= static_cast<Item_datetime*>(item);
dt->set(val->val, type_handler()->mysql_timestamp_type());
}
friend int cmp_longlong(void *cmp_arg, packed_longlong *a,packed_longlong *b);
friend int cmp_longlong(void *cmp_arg, const void *a, const void *b);
};
@ -1590,7 +1591,7 @@ public:
virtual int cmp(Item *item)= 0;
virtual int cmp_not_null(const Value *value)= 0;
// for optimized IN with row
virtual int compare(cmp_item *item)= 0;
virtual int compare(const cmp_item *item) const = 0;
virtual cmp_item *make_same()= 0;
/*
Store a scalar or a ROW value into "this".
@ -1668,7 +1669,7 @@ public:
else
return TRUE;
}
int compare(cmp_item *ci) override
int compare(const cmp_item *ci) const override
{
cmp_item_string *l_cmp= (cmp_item_string *) ci;
return sortcmp(value_res, l_cmp->value_res, cmp_charset);
@ -1702,7 +1703,7 @@ public:
const bool rc= value != arg->val_int();
return (m_null_value || arg->null_value) ? UNKNOWN : rc;
}
int compare(cmp_item *ci) override
int compare(const cmp_item *ci) const override
{
cmp_item_int *l_cmp= (cmp_item_int *)ci;
return (value < l_cmp->value) ? -1 : ((value == l_cmp->value) ? 0 : 1);
@ -1719,7 +1720,7 @@ protected:
longlong value;
public:
cmp_item_temporal() = default;
int compare(cmp_item *ci) override;
int compare(const cmp_item *ci) const override;
};
@ -1765,7 +1766,7 @@ public:
void store_value(Item *item) override;
int cmp_not_null(const Value *val) override;
int cmp(Item *arg) override;
int compare(cmp_item *ci) override;
int compare(const cmp_item *ci) const override;
cmp_item *make_same() override;
};
@ -1791,7 +1792,7 @@ public:
const bool rc= value != arg->val_real();
return (m_null_value || arg->null_value) ? UNKNOWN : rc;
}
int compare(cmp_item *ci) override
int compare(const cmp_item *ci) const override
{
cmp_item_real *l_cmp= (cmp_item_real *) ci;
return (value < l_cmp->value)? -1 : ((value == l_cmp->value) ? 0 : 1);
@ -1808,7 +1809,7 @@ public:
void store_value(Item *item) override;
int cmp(Item *arg) override;
int cmp_not_null(const Value *val) override;
int compare(cmp_item *c) override;
int compare(const cmp_item *c) const override;
cmp_item *make_same() override;
};
@ -1841,7 +1842,7 @@ public:
DBUG_ASSERT(false);
return TRUE;
}
int compare(cmp_item *ci) override
int compare(const cmp_item *ci) const override
{
cmp_item_string *l_cmp= (cmp_item_string *) ci;
return sortcmp(value_res, l_cmp->value_res, cmp_charset);
@ -2557,7 +2558,7 @@ public:
DBUG_ASSERT(false);
return TRUE;
}
int compare(cmp_item *arg) override;
int compare(const cmp_item *arg) const override;
cmp_item *make_same() override;
bool store_value_by_template(THD *thd, cmp_item *tmpl, Item *) override;
friend class Item_func_in;

View file

@ -6039,7 +6039,7 @@ bool Ordered_key::alloc_keys_buffers()
*/
int
Ordered_key::cmp_keys_by_row_data(ha_rows a, ha_rows b)
Ordered_key::cmp_keys_by_row_data(const ha_rows a, const ha_rows b) const
{
uchar *rowid_a, *rowid_b;
int error;
@ -6081,10 +6081,12 @@ Ordered_key::cmp_keys_by_row_data(ha_rows a, ha_rows b)
}
int
Ordered_key::cmp_keys_by_row_data_and_rownum(Ordered_key *key,
rownum_t* a, rownum_t* b)
int Ordered_key::cmp_keys_by_row_data_and_rownum(void *key_, const void *a_,
const void *b_)
{
Ordered_key *key= static_cast<Ordered_key *>(key_);
const rownum_t *a= static_cast<const rownum_t *>(a_);
const rownum_t *b= static_cast<const rownum_t *>(b_);
/* The result of comparing the two keys according to their row data. */
int cmp_row_res= key->cmp_keys_by_row_data(*a, *b);
if (cmp_row_res)
@ -6098,7 +6100,7 @@ bool Ordered_key::sort_keys()
if (tbl->file->ha_rnd_init_with_error(0))
return TRUE;
my_qsort2(key_buff, (size_t) key_buff_elements, sizeof(rownum_t),
(qsort2_cmp) &cmp_keys_by_row_data_and_rownum, (void*) this);
&cmp_keys_by_row_data_and_rownum, (void *) this);
/* Invalidate the current row position. */
cur_key_idx= HA_POS_ERROR;
tbl->file->ha_rnd_end();
@ -6114,7 +6116,7 @@ bool Ordered_key::sort_keys()
@retval 0 if only NULLs
*/
double Ordered_key::null_selectivity()
inline double Ordered_key::null_selectivity() const
{
/* We should not be processing empty tables. */
DBUG_ASSERT(tbl->file->stats.records);
@ -6246,7 +6248,7 @@ bool Ordered_key::next_same()
}
void Ordered_key::print(String *str)
void Ordered_key::print(String *str) const
{
uint i;
str->append("{idx=");
@ -6605,10 +6607,11 @@ void subselect_rowid_merge_engine::cleanup()
@retval -1 if k1 is more selective than k2
*/
int
subselect_rowid_merge_engine::cmp_keys_by_null_selectivity(Ordered_key **k1,
Ordered_key **k2)
int subselect_rowid_merge_engine::cmp_keys_by_null_selectivity(const void *k1_,
const void *k2_)
{
auto k1= static_cast<const Ordered_key *const *>(k1_);
auto k2= static_cast<const Ordered_key *const *>(k2_);
double k1_sel= (*k1)->null_selectivity();
double k2_sel= (*k2)->null_selectivity();
if (k1_sel < k2_sel)
@ -6622,12 +6625,14 @@ subselect_rowid_merge_engine::cmp_keys_by_null_selectivity(Ordered_key **k1,
/*
*/
int
subselect_rowid_merge_engine::cmp_keys_by_cur_rownum(void *arg,
uchar *k1, uchar *k2)
int subselect_rowid_merge_engine::cmp_keys_by_cur_rownum(void *,
const void *k1_,
const void *k2_)
{
rownum_t r1= ((Ordered_key*) k1)->current();
rownum_t r2= ((Ordered_key*) k2)->current();
auto k1= static_cast<const Ordered_key *>(k1_);
auto k2= static_cast<const Ordered_key *>(k2_);
rownum_t r1= k1->current();
rownum_t r2= k2->current();
return (r1 < r2) ? -1 : (r1 > r2) ? 1 : 0;
}

View file

@ -1296,9 +1296,9 @@ protected:
Quick sort comparison function that compares two rows of the same table
indentfied with their row numbers.
*/
int cmp_keys_by_row_data(rownum_t a, rownum_t b);
static int cmp_keys_by_row_data_and_rownum(Ordered_key *key,
rownum_t* a, rownum_t* b);
int cmp_keys_by_row_data(const rownum_t a, const rownum_t b) const;
static int cmp_keys_by_row_data_and_rownum(void *key, const void *a,
const void *b);
int cmp_key_with_search_key(rownum_t row_num);
@ -1314,23 +1314,23 @@ public:
/* Initialize a single-column index. */
bool init(int col_idx);
uint get_column_count() { return key_column_count; }
uint get_keyid() { return keyid; }
Field *get_field(uint i)
uint get_column_count() const { return key_column_count; }
uint get_keyid() const { return keyid; }
Field *get_field(uint i) const
{
DBUG_ASSERT(i < key_column_count);
return key_columns[i]->field;
}
rownum_t get_min_null_row() { return min_null_row; }
rownum_t get_max_null_row() { return max_null_row; }
rownum_t get_min_null_row() const { return min_null_row; }
rownum_t get_max_null_row() const { return max_null_row; }
MY_BITMAP * get_null_key() { return &null_key; }
ha_rows get_null_count() { return null_count; }
ha_rows get_key_buff_elements() { return key_buff_elements; }
ha_rows get_null_count() const { return null_count; }
ha_rows get_key_buff_elements() const { return key_buff_elements; }
/*
Get the search key element that corresponds to the i-th key part of this
index.
*/
Item *get_search_key(uint i)
Item *get_search_key(uint i) const
{
return search_key->element_index(key_columns[i]->field->field_index);
}
@ -1343,7 +1343,7 @@ public:
}
bool sort_keys();
double null_selectivity();
inline double null_selectivity() const;
/*
Position the current element at the first row that matches the key.
@ -1371,7 +1371,7 @@ public:
return FALSE;
};
/* Return the current index element. */
rownum_t current()
rownum_t current() const
{
DBUG_ASSERT(key_buff_elements && cur_key_idx < key_buff_elements);
return key_buff[cur_key_idx];
@ -1381,7 +1381,7 @@ public:
{
bitmap_set_bit(&null_key, (uint)row_num);
}
bool is_null(rownum_t row_num)
bool is_null(rownum_t row_num) const
{
/*
Indexes consisting of only NULLs do not have a bitmap buffer at all.
@ -1397,7 +1397,7 @@ public:
return FALSE;
return bitmap_is_set(&null_key, (uint)row_num);
}
void print(String *str);
void print(String *str) const;
};
@ -1515,12 +1515,12 @@ protected:
Comparison function to compare keys in order of decreasing bitmap
selectivity.
*/
static int cmp_keys_by_null_selectivity(Ordered_key **k1, Ordered_key **k2);
static int cmp_keys_by_null_selectivity(const void *k1, const void *k2);
/*
Comparison function used by the priority queue pq, the 'smaller' key
is the one with the smaller current row number.
*/
static int cmp_keys_by_cur_rownum(void *arg, uchar *k1, uchar *k2);
static int cmp_keys_by_cur_rownum(void *, const void *k1, const void *k2);
bool test_null_row(rownum_t row_num);
bool exists_complementing_null_row(MY_BITMAP *keys_to_complement);

View file

@ -654,10 +654,11 @@ bool Item_sum::check_vcol_func_processor(void *arg)
@retval > 0 if key1 > key2
*/
int simple_str_key_cmp(void* arg, uchar* key1, uchar* key2)
int simple_str_key_cmp(void *arg, const void *key1, const void *key2)
{
Field *f= (Field*) arg;
return f->cmp(key1, key2);
Field *f= static_cast<Field *>(arg);
return f->cmp(static_cast<const uchar *>(key1),
static_cast<const uchar *>(key2));
}
@ -687,9 +688,12 @@ C_MODE_END
@retval >0 if key1 > key2
*/
int Aggregator_distinct::composite_key_cmp(void* arg, uchar* key1, uchar* key2)
int Aggregator_distinct::composite_key_cmp(void *arg, const void *key1_,
const void *key2_)
{
Aggregator_distinct *aggr= (Aggregator_distinct *) arg;
const uchar *key1= static_cast<const uchar *>(key1_);
const uchar *key2= static_cast<const uchar *>(key2_);
Aggregator_distinct *aggr= static_cast<Aggregator_distinct *>(arg);
Field **field = aggr->table->field;
Field **field_end= field + aggr->table->s->fields;
uint32 *lengths=aggr->field_lengths;
@ -706,7 +710,6 @@ int Aggregator_distinct::composite_key_cmp(void* arg, uchar* key1, uchar* key2)
return 0;
}
/***************************************************************************/
C_MODE_START
@ -715,7 +718,7 @@ C_MODE_START
int simple_raw_key_cmp(void* arg, const void* key1, const void* key2)
{
return memcmp(key1, key2, *(uint *) arg);
return memcmp(key1, key2, *(static_cast<uint *>(arg)));
}
@ -837,7 +840,7 @@ bool Aggregator_distinct::setup(THD *thd)
if (all_binary)
{
cmp_arg= (void*) &tree_key_length;
compare_key= (qsort_cmp2) simple_raw_key_cmp;
compare_key= simple_raw_key_cmp;
}
else
{
@ -849,14 +852,14 @@ bool Aggregator_distinct::setup(THD *thd)
compare method that can take advantage of not having to worry
about other fields.
*/
compare_key= (qsort_cmp2) simple_str_key_cmp;
compare_key= simple_str_key_cmp;
cmp_arg= (void*) table->field[0];
/* tree_key_length has been set already */
}
else
{
uint32 *length;
compare_key= (qsort_cmp2) composite_key_cmp;
compare_key= composite_key_cmp;
cmp_arg= (void*) this;
field_lengths= (uint32*) thd->alloc(table->s->fields * sizeof(uint32));
for (tree_key_length= 0, length= field_lengths, field= table->field;
@ -3559,11 +3562,10 @@ String *Item_sum_udf_str::val_str(String *str)
@retval 1 : key1 > key2
*/
extern "C"
int group_concat_key_cmp_with_distinct(void* arg, const void* key1,
const void* key2)
extern "C" int group_concat_key_cmp_with_distinct(void *arg, const void *key1,
const void *key2)
{
Item_func_group_concat *item_func= (Item_func_group_concat*)arg;
auto item_func= static_cast<const Item_func_group_concat *>(arg);
for (uint i= 0; i < item_func->arg_count_field; i++)
{
@ -3602,11 +3604,11 @@ int group_concat_key_cmp_with_distinct(void* arg, const void* key1,
Used for JSON_ARRAYAGG function
*/
int group_concat_key_cmp_with_distinct_with_nulls(void* arg,
const void* key1_arg,
const void* key2_arg)
int group_concat_key_cmp_with_distinct_with_nulls(void *arg,
const void *key1_arg,
const void *key2_arg)
{
Item_func_group_concat *item_func= (Item_func_group_concat*)arg;
auto item_func= static_cast<Item_func_group_concat *>(arg);
uchar *key1= (uchar*)key1_arg + item_func->table->s->null_bytes;
uchar *key2= (uchar*)key2_arg + item_func->table->s->null_bytes;
@ -3655,11 +3657,10 @@ int group_concat_key_cmp_with_distinct_with_nulls(void* arg,
function of sort for syntax: GROUP_CONCAT(expr,... ORDER BY col,... )
*/
extern "C"
int group_concat_key_cmp_with_order(void* arg, const void* key1,
const void* key2)
extern "C" int group_concat_key_cmp_with_order(void *arg, const void *key1,
const void *key2)
{
Item_func_group_concat* grp_item= (Item_func_group_concat*) arg;
auto grp_item= static_cast<Item_func_group_concat *>(arg);
ORDER **order_item, **end;
for (order_item= grp_item->order, end=order_item+ grp_item->arg_count_order;
@ -3715,10 +3716,11 @@ int group_concat_key_cmp_with_order(void* arg, const void* key1,
Used for JSON_ARRAYAGG function
*/
int group_concat_key_cmp_with_order_with_nulls(void *arg, const void *key1_arg,
int group_concat_key_cmp_with_order_with_nulls(void *arg,
const void *key1_arg,
const void *key2_arg)
{
Item_func_group_concat* grp_item= (Item_func_group_concat*) arg;
auto grp_item= static_cast<const Item_func_group_concat *>(arg);
ORDER **order_item, **end;
uchar *key1= (uchar*)key1_arg + grp_item->table->s->null_bytes;

View file

@ -714,7 +714,7 @@ public:
bool unique_walk_function(void *element);
bool unique_walk_function_for_count(void *element);
static int composite_key_cmp(void* arg, uchar* key1, uchar* key2);
static int composite_key_cmp(void *arg, const void *key1, const void *key2);
};
@ -1872,12 +1872,12 @@ public:
#endif /* HAVE_DLOPEN */
C_MODE_START
int group_concat_key_cmp_with_distinct(void* arg, const void* key1,
const void* key2);
int group_concat_key_cmp_with_distinct_with_nulls(void* arg, const void* key1,
const void* key2);
int group_concat_key_cmp_with_order(void* arg, const void* key1,
const void* key2);
int group_concat_key_cmp_with_distinct(void *arg, const void *key1,
const void *key2);
int group_concat_key_cmp_with_distinct_with_nulls(void *arg, const void *key1,
const void *key2);
int group_concat_key_cmp_with_order(void *arg, const void *key1,
const void *key2);
int group_concat_key_cmp_with_order_with_nulls(void *arg, const void *key1,
const void *key2);
int dump_leaf_key(void* key_arg,
@ -1940,15 +1940,16 @@ protected:
*/
bool add(bool exclude_nulls);
friend int group_concat_key_cmp_with_distinct(void* arg, const void* key1,
const void* key2);
friend int group_concat_key_cmp_with_distinct_with_nulls(void* arg,
const void* key1,
const void* key2);
friend int group_concat_key_cmp_with_order(void* arg, const void* key1,
const void* key2);
friend int group_concat_key_cmp_with_distinct(void *arg, const void *key1,
const void *key2);
friend int group_concat_key_cmp_with_distinct_with_nulls(void *arg,
const void *key1,
const void *key2);
friend int group_concat_key_cmp_with_order(void *arg, const void *key1,
const void *key2);
friend int group_concat_key_cmp_with_order_with_nulls(void *arg,
const void *key1, const void *key2);
const void *key1,
const void *key2);
friend int dump_leaf_key(void* key_arg,
element_count count __attribute__((unused)),
void* item_arg);

View file

@ -551,10 +551,10 @@ int key_cmp(KEY_PART_INFO *key_part, const uchar *key, uint key_length)
@retval +1 first_rec is greater than second_rec
*/
int key_rec_cmp(void *key_p, uchar *first_rec, uchar *second_rec)
int key_rec_cmp(const KEY *const *key, const uchar *first_rec,
const uchar *second_rec)
{
KEY **key= (KEY**) key_p;
KEY *key_info= *(key++); // Start with first key
const KEY *key_info= *(key++); // Start with first key
uint key_parts, key_part_num;
KEY_PART_INFO *key_part= key_info->key_part;
uchar *rec0= key_part->field->ptr - key_part->offset;
@ -642,10 +642,10 @@ next_loop:
@retval +1 key1 > key2
*/
int key_tuple_cmp(KEY_PART_INFO *part, uchar *key1, uchar *key2,
int key_tuple_cmp(KEY_PART_INFO *part, const uchar *key1, const uchar *key2,
uint tuple_length)
{
uchar *key1_end= key1 + tuple_length;
const uchar *key1_end= key1 + tuple_length;
int UNINIT_VAR(len);
int res;
for (;key1 < key1_end; key1 += len, key2 += len, part++)
@ -672,7 +672,6 @@ int key_tuple_cmp(KEY_PART_INFO *part, uchar *key1, uchar *key2,
return 0;
}
/**
Get hash value for the key from a key buffer

View file

@ -38,7 +38,9 @@ int key_cmp(KEY_PART_INFO *key_part, const uchar *key, uint key_length);
ulong key_hashnr(KEY *key_info, uint used_key_parts, const uchar *key);
bool key_buf_cmp(KEY *key_info, uint used_key_parts,
const uchar *key1, const uchar *key2);
extern "C" int key_rec_cmp(void *key_info, uchar *a, uchar *b);
int key_tuple_cmp(KEY_PART_INFO *part, uchar *key1, uchar *key2, uint tuple_length);
extern "C" int key_rec_cmp(const KEY *const *key_info, const uchar *a,
const uchar *b);
int key_tuple_cmp(KEY_PART_INFO *part, const uchar *key1, const uchar *key2,
uint tuple_length);
#endif /* KEY_INCLUDED */

View file

@ -761,9 +761,9 @@ int Mrr_ordered_index_reader::refill_buffer(bool initial)
status_var_increment(thd->status_var.ha_mrr_key_refills_count);
}
key_buffer->sort((key_buffer->type() == Lifo_buffer::FORWARD)?
(qsort2_cmp)Mrr_ordered_index_reader::compare_keys_reverse :
(qsort2_cmp)Mrr_ordered_index_reader::compare_keys,
key_buffer->sort((key_buffer->type() == Lifo_buffer::FORWARD)
? Mrr_ordered_index_reader::compare_keys_reverse
: Mrr_ordered_index_reader::compare_keys,
this);
DBUG_RETURN(0);
}
@ -795,9 +795,11 @@ int Mrr_ordered_index_reader::init(handler *h_arg, RANGE_SEQ_IF *seq_funcs,
}
static int rowid_cmp_reverse(void *file, uchar *a, uchar *b)
static int rowid_cmp_reverse(void *file, const void *a, const void *b)
{
return - ((handler*)file)->cmp_ref(a, b);
return -(static_cast<handler *>(file))
->cmp_ref(static_cast<const uchar *>(a),
static_cast<const uchar *>(b));
}
@ -933,7 +935,7 @@ int Mrr_ordered_rndpos_reader::refill_from_index_reader()
if (!index_reader_needs_refill)
index_reader->interrupt_read();
/* Sort the buffer contents by rowid */
rowid_buffer->sort((qsort2_cmp)rowid_cmp_reverse, (void*)file);
rowid_buffer->sort(rowid_cmp_reverse, (void*)file);
rowid_buffer->setup_reading(file->ref_length,
is_mrr_assoc ? sizeof(range_id_t) : 0);
@ -1402,14 +1404,16 @@ void DsMrr_impl::dsmrr_close()
my_qsort2-compatible static member function to compare key tuples
*/
int Mrr_ordered_index_reader::compare_keys(void* arg, uchar* key1_arg,
uchar* key2_arg)
int Mrr_ordered_index_reader::compare_keys(void *arg, const void *key1_arg_,
const void *key2_arg_)
{
Mrr_ordered_index_reader *reader= (Mrr_ordered_index_reader*)arg;
auto key1_arg= static_cast<const uchar *>(key1_arg_);
auto key2_arg= static_cast<const uchar *>(key2_arg_);
auto reader= static_cast<const Mrr_ordered_index_reader *>(arg);
TABLE *table= reader->file->get_table();
KEY_PART_INFO *part= table->key_info[reader->file->active_index].key_part;
uchar *key1, *key2;
const uchar *key1, *key2;
if (reader->keypar.use_key_pointers)
{
/* the buffer stores pointers to keys, get to the keys */
@ -1426,8 +1430,8 @@ int Mrr_ordered_index_reader::compare_keys(void* arg, uchar* key1_arg,
}
int Mrr_ordered_index_reader::compare_keys_reverse(void* arg, uchar* key1,
uchar* key2)
int Mrr_ordered_index_reader::compare_keys_reverse(void *arg, const void *key1,
const void *key2)
{
return -compare_keys(arg, key1, key2);
}

View file

@ -346,9 +346,10 @@ private:
*/
bool read_was_interrupted;
static int compare_keys(void* arg, uchar* key1, uchar* key2);
static int compare_keys_reverse(void* arg, uchar* key1, uchar* key2);
static int compare_keys(void *arg, const void *key1, const void *key2);
static int compare_keys_reverse(void *arg, const void *key1,
const void *key2);
friend class Key_value_records_iterator;
friend class DsMrr_impl;
friend class Mrr_ordered_rndpos_reader;

View file

@ -7679,10 +7679,10 @@ static void print_version(void)
}
/** Compares two options' names, treats - and _ the same */
static int option_cmp(my_option *a, my_option *b)
static int option_cmp(const void *a, const void *b)
{
const char *sa= a->name;
const char *sb= b->name;
const char *sa= static_cast<const my_option *>(a)->name;
const char *sb= static_cast<const my_option *>(b)->name;
for (; *sa || *sb; sa++, sb++)
{
if (*sa < *sb)

View file

@ -1749,11 +1749,13 @@ QUICK_ROR_UNION_SELECT::QUICK_ROR_UNION_SELECT(THD *thd_param,
C_MODE_START
static int QUICK_ROR_UNION_SELECT_queue_cmp(void *arg, uchar *val1, uchar *val2)
static int QUICK_ROR_UNION_SELECT_queue_cmp(void *arg, const void *val1_,
const void *val2_)
{
QUICK_ROR_UNION_SELECT *self= (QUICK_ROR_UNION_SELECT*)arg;
return self->head->file->cmp_ref(((QUICK_SELECT_I*)val1)->last_rowid,
((QUICK_SELECT_I*)val2)->last_rowid);
auto self= static_cast<QUICK_ROR_UNION_SELECT *>(arg);
auto val1= static_cast<const QUICK_SELECT_I *>(val1_);
auto val2= static_cast<const QUICK_SELECT_I *>(val2_);
return self->head->file->cmp_ref(val1->last_rowid, val2->last_rowid);
}
C_MODE_END
@ -3346,8 +3348,11 @@ double records_in_column_ranges(PARAM *param, uint idx,
*/
static
int cmp_quick_ranges(TABLE *table, uint *a, uint *b)
int cmp_quick_ranges(void *table_, const void *a_, const void *b_)
{
TABLE *table= static_cast<TABLE *>(table_);
const uint *a= static_cast<const uint *>(a_);
const uint *b= static_cast<const uint *>(b_);
int tmp= CMP_NUM(table->opt_range[*a].rows, table->opt_range[*b].rows);
if (tmp)
return tmp;
@ -3440,9 +3445,8 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond)
if (table->opt_range_keys.is_set(keynr))
optimal_key_order[ranges++]= keynr;
my_qsort2(optimal_key_order, ranges,
sizeof(optimal_key_order[0]),
(qsort2_cmp) cmp_quick_ranges, table);
my_qsort2(optimal_key_order, ranges, sizeof(optimal_key_order[0]),
cmp_quick_ranges, table);
for (range_index= 0 ; range_index < ranges ; range_index++)
{
@ -5751,8 +5755,10 @@ bool create_fields_bitmap(PARAM *param, MY_BITMAP *fields_bitmap)
/* Compare two indexes scans for sort before search for the best intersection */
static
int cmp_intersect_index_scan(INDEX_SCAN_INFO **a, INDEX_SCAN_INFO **b)
int cmp_intersect_index_scan(const void *a_, const void *b_)
{
auto a= static_cast<const INDEX_SCAN_INFO *const *>(a_);
auto b= static_cast<const INDEX_SCAN_INFO *const *>(b_);
return (*a)->records < (*b)->records ?
-1 : (*a)->records == (*b)->records ? 0 : 1;
}
@ -6685,8 +6691,10 @@ ROR_SCAN_INFO *make_ror_scan(const PARAM *param, int idx, SEL_ARG *sel_arg)
1 a > b
*/
static int cmp_ror_scan_info(ROR_SCAN_INFO** a, ROR_SCAN_INFO** b)
static int cmp_ror_scan_info(const void *a_, const void *b_)
{
auto a= static_cast<const ROR_SCAN_INFO *const *>(a_);
auto b= static_cast<const ROR_SCAN_INFO *const *>(b_);
double val1= rows2double((*a)->records) * (*a)->key_rec_length;
double val2= rows2double((*b)->records) * (*b)->key_rec_length;
return (val1 < val2)? -1: (val1 == val2)? 0 : 1;
@ -6709,8 +6717,10 @@ static int cmp_ror_scan_info(ROR_SCAN_INFO** a, ROR_SCAN_INFO** b)
1 a > b
*/
static int cmp_ror_scan_info_covering(ROR_SCAN_INFO** a, ROR_SCAN_INFO** b)
static int cmp_ror_scan_info_covering(const void *a_, const void *b_)
{
auto a= static_cast<const ROR_SCAN_INFO *const *>(a_);
auto b= static_cast<const ROR_SCAN_INFO *const *>(b_);
if ((*a)->used_fields_covered > (*b)->used_fields_covered)
return -1;
if ((*a)->used_fields_covered < (*b)->used_fields_covered)

View file

@ -672,8 +672,10 @@ add_ext_keyuse_for_splitting(Dynamic_array<KEYUSE_EXT> *ext_keyuses,
static int
sort_ext_keyuse(KEYUSE_EXT *a, KEYUSE_EXT *b)
sort_ext_keyuse(const void *a_, const void *b_)
{
const KEYUSE_EXT *a= static_cast<const KEYUSE_EXT *>(a_);
const KEYUSE_EXT *b= static_cast<const KEYUSE_EXT *>(b_);
if (a->table->tablenr != b->table->tablenr)
return (int) (a->table->tablenr - b->table->tablenr);
if (a->key != b->key)

View file

@ -43,7 +43,7 @@ template<bool,bool> static int rr_unpack_from_buffer(READ_RECORD *info);
int rr_from_pointers(READ_RECORD *info);
static int rr_from_cache(READ_RECORD *info);
static int init_rr_cache(THD *thd, READ_RECORD *info);
static int rr_cmp(uchar *a,uchar *b);
static int rr_cmp(const void *a, const void *b);
static int rr_index_first(READ_RECORD *info);
static int rr_index_last(READ_RECORD *info);
static int rr_index(READ_RECORD *info);
@ -772,8 +772,10 @@ static int rr_from_cache(READ_RECORD *info)
} /* rr_from_cache */
static int rr_cmp(uchar *a,uchar *b)
static int rr_cmp(const void *a_, const void *b_)
{
auto a= static_cast<const uchar *>(a_);
auto b= static_cast<const uchar *>(b_);
if (a[0] != b[0])
return (int) a[0] - (int) b[0];
if (a[1] != b[1])

View file

@ -172,12 +172,12 @@ Rowid_filter_container *Range_rowid_filter_cost_info::create_container()
}
static
int compare_range_rowid_filter_cost_info_by_a(
Range_rowid_filter_cost_info **filter_ptr_1,
Range_rowid_filter_cost_info **filter_ptr_2)
static int compare_range_rowid_filter_cost_info_by_a(const void *p1_,
const void *p2_)
{
double diff= (*filter_ptr_2)->get_a() - (*filter_ptr_1)->get_a();
auto p1= static_cast<const Range_rowid_filter_cost_info *const *>(p1_);
auto p2= static_cast<const Range_rowid_filter_cost_info *const *>(p2_);
double diff= (*p2)->get_a() - (*p1)->get_a();
return (diff < 0 ? -1 : (diff > 0 ? 1 : 0));
}

View file

@ -343,11 +343,10 @@ public:
uint elements() { return (uint) (array->elements() / elem_size); }
void sort (int (*cmp) (void *ctxt, const void *el1, const void *el2),
void *cmp_arg)
void sort(qsort_cmp2 cmp, void *cmp_arg)
{
my_qsort2(array->front(), array->elements()/elem_size,
elem_size, (qsort2_cmp) cmp, cmp_arg);
my_qsort2(array->front(), array->elements() / elem_size, elem_size, cmp,
cmp_arg);
}
bool is_empty() { return elements() == 0; }
@ -464,7 +463,7 @@ public:
Rowid_filter_container *create_container();
double get_a() { return a; }
double get_a() const { return a; }
void trace_info(THD *thd);

View file

@ -2925,10 +2925,10 @@ gtid_waiting::destroy()
static int
cmp_queue_elem(void *, uchar *a, uchar *b)
cmp_queue_elem(void *, const void *a, const void *b)
{
uint64 seq_no_a= *(uint64 *)a;
uint64 seq_no_b= *(uint64 *)b;
auto seq_no_a= *(static_cast<const uint64 *>(a));
auto seq_no_b= *(static_cast<const uint64 *>(b));
if (seq_no_a < seq_no_b)
return -1;
else if (seq_no_a == seq_no_b)

View file

@ -614,8 +614,10 @@ int mysql_del_sys_var_chain(sys_var *first)
}
static int show_cmp(SHOW_VAR *a, SHOW_VAR *b)
static int show_cmp(const void *a_, const void *b_)
{
const SHOW_VAR *a= static_cast<const SHOW_VAR *>(a_);
const SHOW_VAR *b= static_cast<const SHOW_VAR *>(b_);
return strcmp(a->name, b->name);
}

View file

@ -3383,9 +3383,11 @@ static bool send_show_master_info_data(THD *thd, Master_info *mi, bool full,
/* Used to sort connections by name */
static int cmp_mi_by_name(const Master_info **arg1,
const Master_info **arg2)
static int cmp_mi_by_name(const void *arg1_,
const void *arg2_)
{
auto arg1= static_cast<const Master_info *const *>(arg1_);
auto arg2= static_cast<const Master_info *const *>(arg2_);
return my_strcasecmp(system_charset_info, (*arg1)->connection_name.str,
(*arg2)->connection_name.str);
}

View file

@ -997,9 +997,10 @@ sp_head::create_result_field(uint field_max_length, const LEX_CSTRING *field_nam
}
int cmp_rqp_locations(Rewritable_query_parameter * const *a,
Rewritable_query_parameter * const *b)
int cmp_rqp_locations(const void *a_, const void *b_)
{
auto a= static_cast<const Rewritable_query_parameter *const *>(a_);
auto b= static_cast<const Rewritable_query_parameter *const *>(b_);
return (int)((*a)->pos_in_query - (*b)->pos_in_query);
}

View file

@ -657,7 +657,6 @@ bool ROLE_GRANT_PAIR::init(MEM_ROOT *mem, const char *username,
static DYNAMIC_ARRAY acl_hosts, acl_users, acl_proxy_users;
static Dynamic_array<ACL_DB> acl_dbs(PSI_INSTRUMENT_MEM, 0U, 50U);
typedef Dynamic_array<ACL_DB>::CMP_FUNC acl_dbs_cmp;
static HASH acl_roles;
/*
An hash containing mappings user <--> role
@ -675,10 +674,10 @@ static DYNAMIC_ARRAY acl_wild_hosts;
static Hash_filo<acl_entry> *acl_cache;
static uint grant_version=0; /* Version of priv tables. incremented by acl_load */
static privilege_t get_access(TABLE *form, uint fieldnr, uint *next_field=0);
static int acl_compare(const ACL_ACCESS *a, const ACL_ACCESS *b);
static int acl_user_compare(const ACL_USER *a, const ACL_USER *b);
static int acl_compare(const void *a, const void *b);
static int acl_user_compare(const void *a, const void *b);
static void rebuild_acl_users();
static int acl_db_compare(const ACL_DB *a, const ACL_DB *b);
static int acl_db_compare(const void *a, const void *b);
static void rebuild_acl_dbs();
static void init_check_host(void);
static void rebuild_check_host(void);
@ -3004,8 +3003,10 @@ static privilege_t get_access(TABLE *form, uint fieldnr, uint *next_field)
}
static int acl_compare(const ACL_ACCESS *a, const ACL_ACCESS *b)
static int acl_compare(const void *a_, const void *b_)
{
const ACL_ACCESS *a= static_cast<const ACL_ACCESS *>(a_);
const ACL_ACCESS *b= static_cast<const ACL_ACCESS *>(b_);
if (a->sort > b->sort)
return -1;
if (a->sort < b->sort)
@ -3013,8 +3014,11 @@ static int acl_compare(const ACL_ACCESS *a, const ACL_ACCESS *b)
return 0;
}
static int acl_user_compare(const ACL_USER *a, const ACL_USER *b)
static int acl_user_compare(const void *a_, const void *b_)
{
const ACL_USER *a= static_cast<const ACL_USER *>(a_);
const ACL_USER *b= static_cast<const ACL_USER *>(b_);
int res= strcmp(a->user.str, b->user.str);
if (res)
return res;
@ -3033,8 +3037,10 @@ static int acl_user_compare(const ACL_USER *a, const ACL_USER *b)
return -strcmp(a->host.hostname, b->host.hostname);
}
static int acl_db_compare(const ACL_DB *a, const ACL_DB *b)
static int acl_db_compare(const void *a_, const void *b_)
{
const ACL_DB *a= static_cast<const ACL_DB *>(a_);
const ACL_DB *b= static_cast<const ACL_DB *>(b_);
int res= strcmp(a->user, b->user);
if (res)
return res;
@ -6522,8 +6528,10 @@ static bool merge_role_global_privileges(ACL_ROLE *grantee)
return old != grantee->access;
}
static int db_name_sort(const int *db1, const int *db2)
static int db_name_sort(const void *db1_, const void *db2_)
{
auto db1= static_cast<const int *>(db1_);
auto db2= static_cast<const int *>(db2_);
return strcmp(acl_dbs.at(*db1).db, acl_dbs.at(*db2).db);
}
@ -6676,8 +6684,10 @@ static bool merge_role_db_privileges(ACL_ROLE *grantee, const char *dbname,
return update_flags;
}
static int table_name_sort(GRANT_TABLE * const *tbl1, GRANT_TABLE * const *tbl2)
static int table_name_sort(const void *tbl1_, const void *tbl2_)
{
auto tbl1= static_cast<const GRANT_TABLE *const *>(tbl1_);
auto tbl2= static_cast<const GRANT_TABLE *const *>(tbl2_);
int res = strcmp((*tbl1)->db, (*tbl2)->db);
if (res) return res;
return strcmp((*tbl1)->tname, (*tbl2)->tname);
@ -6878,8 +6888,10 @@ static bool merge_role_table_and_column_privileges(ACL_ROLE *grantee,
return update_flags;
}
static int routine_name_sort(GRANT_NAME * const *r1, GRANT_NAME * const *r2)
static int routine_name_sort(const void *r1_, const void *r2_)
{
auto r1= static_cast<const GRANT_NAME *const *>(r1_);
auto r2= static_cast<const GRANT_NAME *const *>(r2_);
int res= strcmp((*r1)->db, (*r2)->db);
if (res) return res;
return strcmp((*r1)->tname, (*r2)->tname);

View file

@ -38,32 +38,40 @@
#define MAX_TREEMEM 8192
#define MAX_TREE_ELEMENTS 256
int sortcmp2(void* cmp_arg __attribute__((unused)),
const String *a,const String *b)
int sortcmp2(void *, const void *a_, const void *b_)
{
const String *a= static_cast<const String*>(a_);
const String *b= static_cast<const String*>(b_);
return sortcmp(a,b,a->charset());
}
int compare_double2(void* cmp_arg __attribute__((unused)),
const double *s, const double *t)
int compare_double2(void *, const void *s_, const void *t_)
{
const double *s= static_cast<const double*>(s_);
const double *t= static_cast<const double*>(t_);
return compare_double(s,t);
}
int compare_longlong2(void* cmp_arg __attribute__((unused)),
const longlong *s, const longlong *t)
int compare_longlong2(void *, const void *s_, const void *t_)
{
const longlong *s= static_cast<const longlong*>(s_);
const longlong *t= static_cast<const longlong*>(t_);
return compare_longlong(s,t);
}
int compare_ulonglong2(void* cmp_arg __attribute__((unused)),
const ulonglong *s, const ulonglong *t)
int compare_ulonglong2(void *, const void *s_, const void *t_)
{
const ulonglong *s= static_cast<const ulonglong*>(s_);
const ulonglong *t= static_cast<const ulonglong*>(t_);
return compare_ulonglong(s,t);
}
int compare_decimal2(int* len, const char *s, const char *t)
int compare_decimal2(void *_len, const void *s_, const void *t_)
{
int *len= static_cast<int *>(_len);
const char *s= static_cast<const char *>(s_);
const char *t= static_cast<const char *>(t_);
return memcmp(s, t, *len);
}

View file

@ -57,15 +57,12 @@ 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_double2(void *, const void *s, const void *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_longlong2(void *, const void *s, const void *t);
int compare_ulonglong(const ulonglong *s, const ulonglong *t);
int compare_ulonglong2(void* cmp_arg __attribute__((unused)),
const ulonglong *s, const ulonglong *t);
int compare_decimal2(int* len, const char *s, const char *t);
int compare_ulonglong2(void *, const void *s, const void *t);
int compare_decimal2(void *len, const void *s, const void *t);
Procedure *proc_analyse_init(THD *thd, ORDER *param, select_result *result,
List<Item> &field_list);
int free_string(void* str, TREE_FREE, void*);
@ -102,8 +99,7 @@ public:
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 sortcmp2(void *, const void *a, const void *b);
class field_str :public field_info
{
@ -120,8 +116,10 @@ public:
max_arg("",default_charset_info), sum(0),
must_be_blob(0), was_zero_fill(0),
was_maybe_zerofill(0), can_be_still_num(1)
{ init_tree(&tree, 0, 0, sizeof(String), (qsort_cmp2) sortcmp2,
free_string, NULL, MYF(MY_THREAD_SPECIFIC)); };
{
init_tree(&tree, 0, 0, sizeof(String), sortcmp2, free_string, NULL,
MYF(MY_THREAD_SPECIFIC));
};
void add() override;
void get_opt_type(String*, ha_rows) override;
@ -161,8 +159,8 @@ public:
field_decimal(Item* a, analyse* b) :field_info(a,b)
{
bin_size= my_decimal_get_binary_size(a->max_length, a->decimals);
init_tree(&tree, 0, 0, bin_size, (qsort_cmp2)compare_decimal2,
0, (void *)&bin_size, MYF(MY_THREAD_SPECIFIC));
init_tree(&tree, 0, 0, bin_size, compare_decimal2, 0, (void *) &bin_size,
MYF(MY_THREAD_SPECIFIC));
};
void add() override;
@ -189,9 +187,10 @@ class field_real: public field_info
public:
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, 0, sizeof(double),
(qsort_cmp2) compare_double2, NULL, NULL,
MYF(MY_THREAD_SPECIFIC)); }
{
init_tree(&tree, 0, 0, sizeof(double), compare_double2, NULL, NULL,
MYF(MY_THREAD_SPECIFIC));
}
void add() override;
void get_opt_type(String*, ha_rows) override;
@ -244,9 +243,10 @@ class field_longlong: public field_info
public:
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, 0, sizeof(longlong),
(qsort_cmp2) compare_longlong2, NULL, NULL,
MYF(MY_THREAD_SPECIFIC)); }
{
init_tree(&tree, 0, 0, sizeof(longlong), compare_longlong2, NULL, NULL,
MYF(MY_THREAD_SPECIFIC));
}
void add() override;
void get_opt_type(String*, ha_rows) override;
@ -290,9 +290,10 @@ class field_ulonglong: public field_info
public:
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, 0, sizeof(ulonglong),
(qsort_cmp2) compare_ulonglong2, NULL, NULL,
MYF(MY_THREAD_SPECIFIC)); }
{
init_tree(&tree, 0, 0, sizeof(ulonglong), compare_ulonglong2, NULL, NULL,
MYF(MY_THREAD_SPECIFIC));
}
void add() override;
void get_opt_type(String*, ha_rows) override;
String *get_min_arg(String *s) override { s->set(min_arg,my_thd_charset); return s; }

View file

@ -289,17 +289,14 @@ public:
delete_dynamic(&array);
}
typedef int (*CMP_FUNC)(const Elem *el1, const Elem *el2);
void sort(CMP_FUNC cmp_func)
void sort(int (*cmp_func)(const void *, const void *))
{
my_qsort(array.buffer, array.elements, sizeof(Elem), (qsort_cmp)cmp_func);
my_qsort(array.buffer, array.elements, sizeof(Elem), cmp_func);
}
typedef int (*CMP_FUNC2)(void *, const Elem *el1, const Elem *el2);
void sort(CMP_FUNC2 cmp_func, void *data)
void sort(qsort_cmp2 cmp_func, void *data)
{
my_qsort2(array.buffer, array.elements, sizeof(Elem), (qsort2_cmp)cmp_func, data);
my_qsort2(array.buffer, array.elements, sizeof(Elem), cmp_func, data);
}
};

View file

@ -323,10 +323,9 @@ int dynamic_column_error_message(enum_dyncol_func_result rc);
/* open_and_lock_tables with optional derived handling */
int open_and_lock_tables_derived(THD *thd, TABLE_LIST *tables, bool derived);
extern "C" int simple_raw_key_cmp(void* arg, const void* key1,
const void* key2);
extern "C" qsort_cmp2 simple_raw_key_cmp;
extern "C" int count_distinct_walk(void *elem, element_count count, void *arg);
int simple_str_key_cmp(void* arg, uchar* key1, uchar* key2);
int simple_str_key_cmp(void *arg, const void *key1, const void *key2);
extern Item **not_found_item;
extern Field *not_found_field;

View file

@ -6759,10 +6759,10 @@ struct SORT_FIELD_ATTR
CHARSET_INFO *cs;
uint pack_sort_string(uchar *to, const Binary_string *str,
CHARSET_INFO *cs) const;
int compare_packed_fixed_size_vals(uchar *a, size_t *a_len,
uchar *b, size_t *b_len);
int compare_packed_varstrings(uchar *a, size_t *a_len,
uchar *b, size_t *b_len);
int compare_packed_fixed_size_vals(const uchar *a, size_t *a_len,
const uchar *b, size_t *b_len);
int compare_packed_varstrings(const uchar *a, size_t *a_len,
const uchar *b, size_t *b_len);
bool check_if_packing_possible(THD *thd) const;
bool is_variable_sized() { return type == VARIABLE_SIZE; }
void set_length_and_original_length(THD *thd, uint length_arg);

View file

@ -1108,10 +1108,11 @@ int mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds,
***************************************************************************/
extern "C" int refpos_order_cmp(void* arg, const void *a,const void *b)
extern "C" int refpos_order_cmp(void *arg, const void *a, const void *b)
{
handler *file= (handler*)arg;
return file->cmp_ref((const uchar*)a, (const uchar*)b);
auto file= static_cast<handler *>(arg);
return file->cmp_ref(static_cast<const uchar *>(a),
static_cast<const uchar *>(b));
}
/*

View file

@ -117,7 +117,7 @@ public:
bool is_empty() { return used_size() == 0; }
virtual bool read() = 0;
void sort(qsort2_cmp cmp_func, void *cmp_func_arg)
void sort(qsort_cmp2 cmp_func, void *cmp_func_arg)
{
size_t elem_size= size1 + size2;
size_t n_elements= used_size() / elem_size;

View file

@ -100,7 +100,7 @@ static bool update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,
uint tables, COND *conds,
table_map table_map, SELECT_LEX *select_lex,
SARGABLE_PARAM **sargables);
static int sort_keyuse(KEYUSE *a,KEYUSE *b);
static int sort_keyuse(const void *a, const void *b);
static bool are_tables_local(JOIN_TAB *jtab, table_map used_tables);
static bool create_ref_for_key(JOIN *join, JOIN_TAB *j, KEYUSE *org_keyuse,
bool allow_full_scan, table_map used_tables);
@ -119,9 +119,9 @@ static bool best_extension_by_limited_search(JOIN *join,
uint use_cond_selectivity);
static uint determine_search_depth(JOIN* join);
C_MODE_START
static int join_tab_cmp(const void *dummy, const void* ptr1, const void* ptr2);
static int join_tab_cmp_straight(const void *dummy, const void* ptr1, const void* ptr2);
static int join_tab_cmp_embedded_first(const void *emb, const void* ptr1, const void *ptr2);
static int join_tab_cmp(void *dummy, const void* ptr1, const void* ptr2);
static int join_tab_cmp_straight(void *dummy, const void* ptr1, const void* ptr2);
static int join_tab_cmp_embedded_first(void *emb, const void* ptr1, const void *ptr2);
C_MODE_END
static uint cache_record_length(JOIN *join,uint index);
static store_key *get_store_key(THD *thd,
@ -6838,8 +6838,10 @@ add_ft_keys(DYNAMIC_ARRAY *keyuse_array,
static int
sort_keyuse(KEYUSE *a,KEYUSE *b)
sort_keyuse(const void *a_, const void *b_)
{
const KEYUSE *a= static_cast<const KEYUSE *>(a_);
const KEYUSE *b= static_cast<const KEYUSE *>(b_);
int res;
if (a->table->tablenr != b->table->tablenr)
return (int) (a->table->tablenr - b->table->tablenr);
@ -8650,7 +8652,7 @@ choose_plan(JOIN *join, table_map join_tables)
join->cur_embedding_map= 0;
reset_nj_counters(join, join->join_list);
qsort2_cmp jtab_sort_func;
qsort_cmp2 jtab_sort_func;
if (join->emb_sjm_nest)
{
@ -8734,7 +8736,7 @@ choose_plan(JOIN *join, table_map join_tables)
1 - jt1 > jt2
*/
static int compare_embedding_subqueries(JOIN_TAB *jt1, JOIN_TAB *jt2)
static int compare_embedding_subqueries(const JOIN_TAB *jt1, const JOIN_TAB *jt2)
{
/* Determine if the first table is originally from a subquery */
TABLE_LIST *tbl1= jt1->table->pos_in_table_list;
@ -8809,10 +8811,10 @@ static int compare_embedding_subqueries(JOIN_TAB *jt1, JOIN_TAB *jt2)
*/
static int
join_tab_cmp(const void *dummy, const void* ptr1, const void* ptr2)
join_tab_cmp(void *, const void* ptr1, const void* ptr2)
{
JOIN_TAB *jt1= *(JOIN_TAB**) ptr1;
JOIN_TAB *jt2= *(JOIN_TAB**) ptr2;
auto jt1= *(static_cast<const JOIN_TAB *const *>(ptr1));
auto jt2= *(static_cast<const JOIN_TAB *const *>(ptr2));
int cmp;
if ((cmp= compare_embedding_subqueries(jt1, jt2)) != 0)
@ -8839,10 +8841,10 @@ join_tab_cmp(const void *dummy, const void* ptr1, const void* ptr2)
*/
static int
join_tab_cmp_straight(const void *dummy, const void* ptr1, const void* ptr2)
join_tab_cmp_straight(void *, const void* ptr1, const void* ptr2)
{
JOIN_TAB *jt1= *(JOIN_TAB**) ptr1;
JOIN_TAB *jt2= *(JOIN_TAB**) ptr2;
auto jt1= *(static_cast<const JOIN_TAB *const *>(ptr1));
auto jt2= *(static_cast<const JOIN_TAB *const *>(ptr2));
/*
We don't do subquery flattening if the parent or child select has
@ -8870,11 +8872,11 @@ join_tab_cmp_straight(const void *dummy, const void* ptr1, const void* ptr2)
*/
static int
join_tab_cmp_embedded_first(const void *emb, const void* ptr1, const void* ptr2)
join_tab_cmp_embedded_first(void *emb, const void* ptr1, const void* ptr2)
{
const TABLE_LIST *emb_nest= (TABLE_LIST*) emb;
JOIN_TAB *jt1= *(JOIN_TAB**) ptr1;
JOIN_TAB *jt2= *(JOIN_TAB**) ptr2;
TABLE_LIST *emb_nest= static_cast<TABLE_LIST *>(emb);
auto jt1= *(static_cast<const JOIN_TAB *const *>(ptr1));
auto jt2= *(static_cast<const JOIN_TAB *const *>(ptr2));
if (jt1->emb_sj_nest == emb_nest && jt2->emb_sj_nest != emb_nest)
return -1;
@ -25079,8 +25081,7 @@ static int remove_dup_with_hash_index(THD *thd, TABLE *table,
(*field_length++)= (*ptr)->sort_length();
if (my_hash_init(key_memory_hash_index_key_buffer, &hash, &my_charset_bin,
(uint) file->stats.records, 0, key_length,
(my_hash_get_key) 0, 0, 0))
(uint) file->stats.records, 0, key_length, 0, 0, 0))
{
my_free(key_buffer);
DBUG_RETURN(1);

View file

@ -1945,7 +1945,7 @@ int opt_sum_query(THD* thd,
List<TABLE_LIST> &tables, List<Item> &all_fields, COND *conds);
/* from sql_delete.cc, used by opt_range.cc */
extern "C" int refpos_order_cmp(void* arg, const void *a,const void *b);
extern "C" int refpos_order_cmp(void *arg, const void *a,const void *b);
/** class to copying an field/item to a key struct */

View file

@ -18,7 +18,7 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
#include "my_base.h" /* ha_rows */
#include <my_sys.h> /* qsort2_cmp */
#include <my_cmp.h>
#include "queues.h"
#include "sql_string.h"
#include "sql_class.h"
@ -565,7 +565,7 @@ public:
bool not_killable;
String tmp_buffer;
// The fields below are used only by Unique class.
qsort2_cmp compare;
qsort_cmp2 compare;
BUFFPEK_COMPARE_CONTEXT cmp_context;
Sort_param()
@ -669,7 +669,7 @@ public:
void try_to_pack_sortkeys();
qsort2_cmp get_compare_function() const
qsort_cmp2 get_compare_function() const
{
return using_packed_sortkeys() ?
get_packed_keys_compare_ptr() :

View file

@ -1646,8 +1646,8 @@ public:
table_field= field;
tree_key_length= field->pack_length();
tree= new Unique((qsort_cmp2) simple_str_key_cmp, (void*) field,
tree_key_length, max_heap_table_size, 1);
tree= new Unique(simple_str_key_cmp, field, tree_key_length,
max_heap_table_size, 1);
}
virtual ~Count_distinct_field()
@ -1732,13 +1732,13 @@ public:
static
int simple_ulonglong_key_cmp(void* arg, uchar* key1, uchar* key2)
int simple_ulonglong_key_cmp(void*, const void* key1, const void* key2)
{
ulonglong *val1= (ulonglong *) key1;
ulonglong *val2= (ulonglong *) key2;
const ulonglong *val1= static_cast<const ulonglong *>(key1);
const ulonglong *val2= static_cast<const ulonglong *>(key2);
return *val1 > *val2 ? 1 : *val1 == *val2 ? 0 : -1;
}
/*
The class Count_distinct_field_bit is derived from the class
@ -1755,8 +1755,7 @@ public:
table_field= field;
tree_key_length= sizeof(ulonglong);
tree= new Unique((qsort_cmp2) simple_ulonglong_key_cmp,
(void*) &tree_key_length,
tree= new Unique(simple_ulonglong_key_cmp, &tree_key_length,
tree_key_length, max_heap_table_size, 1);
}

View file

@ -2957,8 +2957,10 @@ bool quick_rm_table(THD *thd, handlerton *base, const LEX_CSTRING *db,
PRIMARY keys are prioritized.
*/
static int sort_keys(KEY *a, KEY *b)
static int sort_keys(const void *a_, const void *b_)
{
const KEY *a= static_cast<const KEY *>(a_);
const KEY *b= static_cast<const KEY *>(b_);
ulong a_flags= a->flags, b_flags= b->flags;
/*
@ -7143,8 +7145,10 @@ static bool fix_constraints_names(THD *thd, List<Virtual_column_info>
}
static int compare_uint(const uint *s, const uint *t)
static int compare_uint(const void *s_, const void *t_)
{
const uint *s= static_cast<const uint *>(s_);
const uint *t= static_cast<const uint *>(t_);
return (*s < *t) ? -1 : ((*s > *t) ? 1 : 0);
}

View file

@ -5844,9 +5844,9 @@ cmp_item *Type_handler_timestamp_common::make_cmp_item(THD *thd,
/***************************************************************************/
static int srtcmp_in(const void *cs_, const void *x_, const void *y_)
static int srtcmp_in(void *cs_, const void *x_, const void *y_)
{
const CHARSET_INFO *cs= static_cast<const CHARSET_INFO *>(cs_);
CHARSET_INFO *cs= static_cast<CHARSET_INFO *>(cs_);
const String *x= static_cast<const String *>(x_);
const String *y= static_cast<const String *>(y_);
return cs->strnncollsp(x->ptr(), x->length(), y->ptr(), y->length());
@ -5856,12 +5856,10 @@ in_vector *Type_handler_string_result::make_in_vector(THD *thd,
const Item_func_in *func,
uint nargs) const
{
return new (thd->mem_root) in_string(thd, nargs, (qsort2_cmp) srtcmp_in,
func->compare_collation());
return new (thd->mem_root)
in_string(thd, nargs, srtcmp_in, func->compare_collation());
}
in_vector *Type_handler_int_result::make_in_vector(THD *thd,
const Item_func_in *func,
uint nargs) const

View file

@ -429,11 +429,13 @@ Unique::reset()
C_MODE_START
static int buffpek_compare(void *arg, uchar *key_ptr1, uchar *key_ptr2)
static int buffpek_compare(void *arg, const void *key_ptr1,
const void *key_ptr2)
{
BUFFPEK_COMPARE_CONTEXT *ctx= (BUFFPEK_COMPARE_CONTEXT *) arg;
auto ctx= static_cast<const BUFFPEK_COMPARE_CONTEXT *>(arg);
return ctx->key_compare(ctx->key_compare_arg,
*((uchar **) key_ptr1), *((uchar **)key_ptr2));
*(static_cast<const uchar *const *>(key_ptr1)),
*(static_cast<const uchar *const *>(key_ptr2)));
}
C_MODE_END
@ -734,7 +736,7 @@ bool Unique::merge(TABLE *table, uchar *buff, size_t buff_size,
sort_param.unique_buff= buff +(sort_param.max_keys_per_buffer *
sort_param.sort_length);
sort_param.compare= (qsort2_cmp) buffpek_compare;
sort_param.compare= buffpek_compare;
sort_param.cmp_context.key_compare= tree.compare;
sort_param.cmp_context.key_compare_arg= tree.custom_arg;

View file

@ -96,8 +96,10 @@ static handler *tina_create_handler(handlerton *hton,
/*
Used for sorting chains with qsort().
*/
int sort_set (tina_set *a, tina_set *b)
int sort_set (const void *a_, const void *b_)
{
const tina_set *a= static_cast<const tina_set*>(a_);
const tina_set *b= static_cast<const tina_set*>(b_);
/*
We assume that intervals do not intersect. So, it is enought to compare
any two points. Here we take start of intervals for comparison.

View file

@ -16,7 +16,7 @@
#include "heapdef.h"
static int keys_compare(heap_rb_param *param, uchar *key1, uchar *key2);
static int keys_compare(void *heap_rb, const void *key1, const void *key2);
static void init_block(HP_BLOCK *block,uint reclength,ulong min_records,
ulong max_records);
@ -190,7 +190,7 @@ int heap_create(const char *name, HP_CREATE_INFO *create_info,
keyseg++;
init_tree(&keyinfo->rb_tree, 0, 0, sizeof(uchar*),
(qsort_cmp2)keys_compare, NULL, NULL,
keys_compare, NULL, NULL,
MYF((create_info->internal_table ? MY_THREAD_SPECIFIC : 0) |
MY_TREE_WITH_DELETE));
keyinfo->delete_key= hp_rb_delete_key;
@ -255,11 +255,15 @@ err:
} /* heap_create */
static int keys_compare(heap_rb_param *param, uchar *key1, uchar *key2)
static int keys_compare(void *heap_rb_, const void *key1_,
const void *key2_)
{
heap_rb_param *heap_rb= heap_rb_;
const uchar *key1= key1_;
const uchar *key2= key2_;
uint not_used[2];
return ha_key_cmp(param->keyseg, key1, key2, param->key_length,
param->search_flag, not_used);
return ha_key_cmp(heap_rb->keyseg, key1, key2, heap_rb->key_length,
heap_rb->search_flag, not_used);
}
static void init_block(HP_BLOCK *block, uint reclength, ulong min_records,

View file

@ -135,8 +135,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(void* cmp_arg __attribute__((unused)),
const uchar *s,const uchar *t);
static int compare_tree(void *cmp_arg __attribute__((unused)),
const void *s, const void *t);
static int get_statistic(PACK_MRG_INFO *mrg,HUFF_COUNTS *huff_counts);
static void check_counts(HUFF_COUNTS *huff_counts,uint trees,
my_off_t records);
@ -146,7 +146,8 @@ static int test_space_compress(HUFF_COUNTS *huff_counts,my_off_t records,
enum en_fieldtype field_type);
static HUFF_TREE* make_huff_trees(HUFF_COUNTS *huff_counts,uint trees);
static int make_huff_tree(HUFF_TREE *tree,HUFF_COUNTS *huff_counts);
static int compare_huff_elements(void *not_used, uchar *a,uchar *b);
static int compare_huff_elements(void *not_used, const void *a,
const void *b);
static int save_counts_in_queue(uchar *key,element_count count,
HUFF_TREE *tree);
static my_off_t calc_packed_length(HUFF_COUNTS *huff_counts,uint flag);
@ -180,7 +181,7 @@ static int mrg_rrnd(PACK_MRG_INFO *info,uchar *buf);
static void mrg_reset(PACK_MRG_INFO *mrg);
#if !defined(DBUG_OFF)
static void fakebigcodes(HUFF_COUNTS *huff_counts, HUFF_COUNTS *end_count);
static int fakecmp(my_off_t **count1, my_off_t **count2);
static int fakecmp(const void *count1, const void *count2);
#endif
/*
@ -905,8 +906,8 @@ static HUFF_COUNTS *init_huff_count(MARIA_HA *info,my_off_t records)
'tree_pos'. It's keys are implemented by pointers into 'tree_buff'.
This is accomplished by '-1' as the element size.
*/
init_tree(&count[col_nr].int_tree,0,0,-1,(qsort_cmp2) compare_tree, NULL,
NULL, MYF(0));
init_tree(&count[col_nr].int_tree, 0, 0, -1, compare_tree, NULL, NULL,
MYF(0));
if (records && type != FIELD_BLOB && type != FIELD_VARCHAR)
count[col_nr].tree_pos=count[col_nr].tree_buff =
my_malloc(PSI_NOT_INSTRUMENTED,
@ -1258,12 +1259,14 @@ static int get_statistic(PACK_MRG_INFO *mrg,HUFF_COUNTS *huff_counts)
}
static int compare_huff_elements(void *not_used __attribute__((unused)),
uchar *a, uchar *b)
const void *a_, const void *b_)
{
return *((my_off_t*) a) < *((my_off_t*) b) ? -1 :
(*((my_off_t*) a) == *((my_off_t*) b) ? 0 : 1);
const my_off_t *a= a_;
const my_off_t *b= b_;
return *a < *b ? -1 : (*a == *b ? 0 : 1);
}
/* Check each tree if we should use pre-space-compress, end-space-
compress, empty-field-compress or zero-field-compress */
@ -1770,9 +1773,11 @@ static int make_huff_tree(HUFF_TREE *huff_tree, HUFF_COUNTS *huff_counts)
return 0;
}
static int compare_tree(void* cmp_arg __attribute__((unused)),
register const uchar *s, register const uchar *t)
static int compare_tree(void *cmp_arg __attribute__((unused)), const void *s_,
const void *t_)
{
const uchar *s= s_;
const uchar *t= t_;
uint length;
for (length=global_count->field_length; length-- ;)
if (*s++ != *t++)
@ -3323,8 +3328,10 @@ static void fakebigcodes(HUFF_COUNTS *huff_counts, HUFF_COUNTS *end_count)
-1 count1 > count2
*/
static int fakecmp(my_off_t **count1, my_off_t **count2)
static int fakecmp(const void *count1_, const void *count2_)
{
const my_off_t *const *count1= count1_;
const my_off_t *const *count2= count2_;
return ((**count1 < **count2) ? 1 :
(**count1 > **count2) ? -1 : 0);
}

View file

@ -67,8 +67,7 @@ static int sort_one_index(HA_CHECK *param, MARIA_HA *info,
static int sort_key_read(MARIA_SORT_PARAM *sort_param, uchar *key);
static int sort_maria_ft_key_read(MARIA_SORT_PARAM *sort_param, uchar *key);
static int sort_get_next_record(MARIA_SORT_PARAM *sort_param);
static int sort_key_cmp(MARIA_SORT_PARAM *sort_param, const void *a,
const void *b);
static int sort_key_cmp(void *sort_param, const void *a, const void *b);
static int sort_maria_ft_key_write(MARIA_SORT_PARAM *sort_param,
const uchar *a);
static int sort_key_write(MARIA_SORT_PARAM *sort_param, const uchar *a);
@ -5624,9 +5623,9 @@ int _ma_sort_write_record(MARIA_SORT_PARAM *sort_param)
/* Compare two keys from _ma_create_index_by_sort */
static int sort_key_cmp(MARIA_SORT_PARAM *sort_param, const void *a,
const void *b)
static int sort_key_cmp(void *sort_param_, const void *a, const void *b)
{
const MARIA_SORT_PARAM *sort_param= sort_param_;
uint not_used[2];
return (ha_key_cmp(sort_param->seg, *((uchar* const *) a),
*((uchar* const *) b),

View file

@ -31,7 +31,7 @@
#endif
#include <m_ctype.h>
static int compare_columns(MARIA_COLUMNDEF **a, MARIA_COLUMNDEF **b);
static int compare_columns(const void *a, const void *b);
static ulonglong update_tot_length(ulonglong tot_length, ulonglong max_rows, uint length)
@ -1335,9 +1335,11 @@ static inline int sign(long a)
}
static int compare_columns(MARIA_COLUMNDEF **a_ptr, MARIA_COLUMNDEF **b_ptr)
static int compare_columns(const void *a_ptr_, const void *b_ptr_)
{
MARIA_COLUMNDEF *a= *a_ptr, *b= *b_ptr;
const MARIA_COLUMNDEF *const *a_ptr= a_ptr_;
const MARIA_COLUMNDEF *const *b_ptr= b_ptr_;
const MARIA_COLUMNDEF *a= *a_ptr, *b= *b_ptr;
enum en_fieldtype a_type, b_type;
a_type= (a->type == FIELD_CHECK) ? FIELD_NORMAL : a->type;

View file

@ -144,9 +144,12 @@ typedef struct st_ft_info
enum { UNINITIALIZED, READY, INDEX_SEARCH, INDEX_DONE } state;
} FTB;
static int FTB_WORD_cmp(my_off_t *v, FTB_WORD *a, FTB_WORD *b)
static int FTB_WORD_cmp(void *v_, const void *a_, const void *b_)
{
int i;
const my_off_t *v= v_;
const FTB_WORD *a= a_;
const FTB_WORD *b= b_;
/* if a==curdoc, take it as a < b */
if (v && a->docid[0] == *v)
@ -159,11 +162,15 @@ static int FTB_WORD_cmp(my_off_t *v, FTB_WORD *a, FTB_WORD *b)
return i;
}
static int FTB_WORD_cmp_list(CHARSET_INFO *cs, FTB_WORD **a, FTB_WORD **b)
static int FTB_WORD_cmp_list(void *cs_, const void *a_, const void *b_)
{
CHARSET_INFO *cs= cs_;
const FTB_WORD *const *a= a_;
const FTB_WORD *const *b= b_;
/* ORDER BY word, ndepth */
int i= ha_compare_word(cs, (uchar*) (*a)->word + 1, (*a)->len - 1,
(uchar*) (*b)->word + 1, (*b)->len - 1);
int i= ha_compare_word(cs, (*a)->word + 1, (*a)->len - 1, (*b)->word + 1,
(*b)->len - 1);
if (!i)
i=CMP_NUM((*a)->ndepth, (*b)->ndepth);
return i;
@ -325,10 +332,12 @@ static int _ftb_parse_query(FTB *ftb, uchar *query, uint len,
}
static int _ftb_no_dupes_cmp(void* not_used __attribute__((unused)),
const void *a,const void *b)
static int _ftb_no_dupes_cmp(void *not_used __attribute__((unused)),
const void *a_, const void *b_)
{
return CMP_NUM((*((my_off_t*)a)), (*((my_off_t*)b)));
const my_off_t *a= a_;
const my_off_t *b= b_;
return CMP_NUM((*a), (*b));
}
@ -597,14 +606,14 @@ FT_INFO * maria_ft_init_boolean_search(MARIA_HA *info, uint keynr,
sizeof(void *))))
goto err;
reinit_queue(&ftb->queue, ftb->queue.max_elements, 0, 0,
(int (*)(void*, uchar*, uchar*))FTB_WORD_cmp, 0, 0, 0);
FTB_WORD_cmp, 0, 0, 0);
for (ftbw= ftb->last_word; ftbw; ftbw= ftbw->prev)
queue_insert(&ftb->queue, (uchar *)ftbw);
ftb->list=(FTB_WORD **)alloc_root(&ftb->mem_root,
sizeof(FTB_WORD *)*ftb->queue.elements);
memcpy(ftb->list, ftb->queue.root+1, sizeof(FTB_WORD *)*ftb->queue.elements);
my_qsort2(ftb->list, ftb->queue.elements, sizeof(FTB_WORD *),
(qsort2_cmp)FTB_WORD_cmp_list, (void*) ftb->charset);
FTB_WORD_cmp_list, (void*) ftb->charset);
if (ftb->queue.elements<2) ftb->with_scan &= ~FTB_FLAG_TRUNC;
ftb->state=READY;
return ftb;

View file

@ -52,9 +52,11 @@ typedef struct st_ft_superdoc
} FT_SUPERDOC;
static int FT_SUPERDOC_cmp(void* cmp_arg __attribute__((unused)),
FT_SUPERDOC *p1, FT_SUPERDOC *p2)
static int FT_SUPERDOC_cmp(void *cmp_arg __attribute__((unused)),
const void *p1_, const void *p2_)
{
const FT_SUPERDOC *p1= p1_;
const FT_SUPERDOC *p2= p2_;
if (p1->doc.dpos < p2->doc.dpos)
return -1;
if (p1->doc.dpos == p2->doc.dpos)
@ -209,8 +211,10 @@ static int walk_and_push(FT_SUPERDOC *from,
static int FT_DOC_cmp(void *unused __attribute__((unused)),
FT_DOC *a, FT_DOC *b)
const void *a_, const void *b_)
{
const FT_DOC *a= a_;
const FT_DOC *b= b_;
return CMP_NUM(b->weight, a->weight);
}
@ -244,8 +248,8 @@ FT_INFO *maria_ft_init_nlq_search(MARIA_HA *info, uint keynr, uchar *query,
bzero(&wtree,sizeof(wtree));
init_tree(&aio.dtree,0,0,sizeof(FT_SUPERDOC),(qsort_cmp2)&FT_SUPERDOC_cmp,
NULL, NULL, MYF(0));
init_tree(&aio.dtree, 0, 0, sizeof(FT_SUPERDOC), &FT_SUPERDOC_cmp, NULL,
NULL, MYF(0));
maria_ft_parse_init(&wtree, aio.charset);
ftparser_param->flags= 0;
@ -260,8 +264,7 @@ FT_INFO *maria_ft_init_nlq_search(MARIA_HA *info, uint keynr, uchar *query,
if (flags & FT_EXPAND && ft_query_expansion_limit)
{
QUEUE best;
init_queue(&best,ft_query_expansion_limit,0,0, (queue_compare) &FT_DOC_cmp,
0, 0, 0);
init_queue(&best, ft_query_expansion_limit, 0, 0, &FT_DOC_cmp, 0, 0, 0);
tree_walk(&aio.dtree, (tree_walk_action) &walk_and_push,
&best, left_root_right);
while (best.elements)
@ -308,8 +311,7 @@ FT_INFO *maria_ft_init_nlq_search(MARIA_HA *info, uint keynr, uchar *query,
&dptr, left_root_right);
if (flags & FT_SORTED)
my_qsort2(dlist->doc, dlist->ndocs, sizeof(FT_DOC),
(qsort2_cmp)&FT_DOC_cmp, 0);
my_qsort2(dlist->doc, dlist->ndocs, sizeof(FT_DOC), &FT_DOC_cmp, 0);
err:
delete_tree(&aio.dtree, 0);

View file

@ -32,10 +32,12 @@ typedef struct st_my_maria_ft_parser_param
} MY_FT_PARSER_PARAM;
static int FT_WORD_cmp(CHARSET_INFO* cs, FT_WORD *w1, FT_WORD *w2)
static int FT_WORD_cmp(void *cs_, const void *w1_, const void *w2_)
{
return ha_compare_word(cs, (uchar*) w1->pos, w1->len,
(uchar*) w2->pos, w2->len);
CHARSET_INFO *cs= cs_;
const FT_WORD *w1= w1_;
const FT_WORD *w2= w2_;
return ha_compare_word(cs, w1->pos, w1->len, w2->pos, w2->len);
}
static int walk_and_copy(FT_WORD *word,uint32 count,FT_DOCSTAT *docstat)
@ -255,8 +257,8 @@ void maria_ft_parse_init(TREE *wtree, CHARSET_INFO *cs)
{
DBUG_ENTER("maria_ft_parse_init");
if (!is_tree_inited(wtree))
init_tree(wtree,0,0,sizeof(FT_WORD),(qsort_cmp2)&FT_WORD_cmp, NULL,
(void*) cs, MYF(0));
init_tree(wtree, 0, 0, sizeof(FT_WORD), &FT_WORD_cmp, NULL, (void *) cs,
MYF(0));
DBUG_VOID_RETURN;
}

View file

@ -4722,8 +4722,10 @@ static my_bool free_block(PAGECACHE *pagecache, PAGECACHE_BLOCK_LINK *block,
}
static int cmp_sec_link(PAGECACHE_BLOCK_LINK **a, PAGECACHE_BLOCK_LINK **b)
static int cmp_sec_link(const void *a_, const void *b_)
{
PAGECACHE_BLOCK_LINK *const *a= a_;
PAGECACHE_BLOCK_LINK *const *b= b_;
return (((*a)->hash_link->pageno < (*b)->hash_link->pageno) ? -1 :
((*a)->hash_link->pageno > (*b)->hash_link->pageno) ? 1 : 0);
}

View file

@ -752,8 +752,8 @@ static int write_keys(MARIA_SORT_PARAM *info, register uchar **sort_keys,
if (!buffpek)
DBUG_RETURN(1); /* Out of memory */
my_qsort2((uchar*) sort_keys,(size_t) count, sizeof(uchar*),
(qsort2_cmp) info->key_cmp, info);
my_qsort2(sort_keys, count, sizeof(uchar*),
info->key_cmp, info);
if (!my_b_inited(tempfile) &&
open_cached_file(tempfile, my_tmpdir(info->tmpdir), "ST",
DISK_BUFFER_SIZE, info->sort_info->param->myf_rw))
@ -798,8 +798,8 @@ static int write_keys_varlen(MARIA_SORT_PARAM *info,
if (!buffpek)
DBUG_RETURN(1); /* Out of memory */
my_qsort2((uchar*) sort_keys, (size_t) count, sizeof(uchar*),
(qsort2_cmp) info->key_cmp, info);
my_qsort2(sort_keys, count, sizeof(uchar*),
info->key_cmp, info);
if (!my_b_inited(tempfile) &&
open_cached_file(tempfile, my_tmpdir(info->tmpdir), "ST",
DISK_BUFFER_SIZE, info->sort_info->param->myf_rw))
@ -841,8 +841,8 @@ static int write_index(MARIA_SORT_PARAM *info, register uchar **sort_keys,
{
DBUG_ENTER("write_index");
my_qsort2((uchar*) sort_keys,(size_t) count,sizeof(uchar*),
(qsort2_cmp) info->key_cmp,info);
my_qsort2(sort_keys, count,sizeof(uchar*),
info->key_cmp,info);
while (count--)
{
if ((*info->key_write)(info, *sort_keys++))
@ -1044,8 +1044,8 @@ merge_buffers(MARIA_SORT_PARAM *info, ha_keys keys, IO_CACHE *from_file,
sort_length=info->key_length;
if (init_queue(&queue,(uint) (Tb-Fb)+1,offsetof(BUFFPEK,key),0,
(int (*)(void*, uchar *,uchar*)) info->key_cmp,
(void*) info, 0, 0))
info->key_cmp,
info, 0, 0))
DBUG_RETURN(1); /* purecov: inspected */
for (buffpek= Fb ; buffpek <= Tb ; buffpek++)

View file

@ -1687,8 +1687,12 @@ static my_bool _ma_ck_write_tree(register MARIA_HA *info, MARIA_KEY *key)
/* typeof(_ma_keys_compare)=qsort_cmp2 */
static int keys_compare(bulk_insert_param *param, uchar *key1, uchar *key2)
static int keys_compare(void *param_, const void *key1_,
const void *key2_)
{
const bulk_insert_param *param= param_;
const uchar *key1= key1_;
const uchar *key2= key2_;
uint not_used[2];
return ha_key_cmp(param->info->s->keyinfo[param->keynr].seg,
key1, key2, USE_WHOLE_KEY, SEARCH_SAME,
@ -1794,7 +1798,7 @@ int maria_init_bulk_insert(MARIA_HA *info, size_t cache_size, ha_rows rows)
init_tree(&info->bulk_insert[i],
cache_size * key[i].maxlength,
cache_size * key[i].maxlength, 0,
(qsort_cmp2) keys_compare, keys_free, (void *)params++, MYF(0));
keys_compare, keys_free, params++, MYF(0));
}
else
info->bulk_insert[i].root=0;

View file

@ -398,7 +398,7 @@ typedef struct st_maria_sort_param
my_bool calc_checksum; /* calculate table checksum */
size_t rec_buff_size;
int (*key_cmp)(struct st_maria_sort_param *, const void *, const void *);
int (*key_cmp)(void *, const void *, const void *);
int (*key_read)(struct st_maria_sort_param *, uchar *);
int (*key_write)(struct st_maria_sort_param *, const uchar *);
void (*lock_in_memory)(HA_CHECK *);

View file

@ -144,9 +144,12 @@ typedef struct st_ft_info
enum { UNINITIALIZED, READY, INDEX_SEARCH, INDEX_DONE } state;
} FTB;
static int FTB_WORD_cmp(my_off_t *v, FTB_WORD *a, FTB_WORD *b)
static int FTB_WORD_cmp(void *v_, const void *a_, const void *b_)
{
int i;
const my_off_t *v= v_;
const FTB_WORD *a= a_;
const FTB_WORD *b= b_;
/* if a==curdoc, take it as a < b */
if (v && a->docid[0] == *v)
@ -159,11 +162,14 @@ static int FTB_WORD_cmp(my_off_t *v, FTB_WORD *a, FTB_WORD *b)
return i;
}
static int FTB_WORD_cmp_list(CHARSET_INFO *cs, FTB_WORD **a, FTB_WORD **b)
static int FTB_WORD_cmp_list(void *cs_, const void *a_, const void *b_)
{
CHARSET_INFO *cs= cs_;
const FTB_WORD *const *a= a_;
const FTB_WORD *const *b= b_;
/* ORDER BY word, ndepth */
int i= ha_compare_word(cs, (uchar*) (*a)->word + 1, (*a)->len - 1,
(uchar*) (*b)->word + 1, (*b)->len - 1);
int i= ha_compare_word(cs, (*a)->word + 1, (*a)->len - 1, (*b)->word + 1,
(*b)->len - 1);
if (!i)
i= CMP_NUM((*a)->ndepth, (*b)->ndepth);
return i;
@ -327,8 +333,8 @@ static int _ftb_parse_query(FTB *ftb, uchar *query, uint len,
}
static int _ftb_no_dupes_cmp(void* not_used __attribute__((unused)),
const void *a,const void *b)
static int _ftb_no_dupes_cmp(void *not_used __attribute__((unused)),
const void *a, const void *b)
{
return CMP_NUM((*((my_off_t*)a)), (*((my_off_t*)b)));
}
@ -607,14 +613,14 @@ FT_INFO * ft_init_boolean_search(MI_INFO *info, uint keynr, uchar *query,
sizeof(void *))))
goto err;
reinit_queue(&ftb->queue, ftb->queue.max_elements, 0, 0,
(int (*)(void*, uchar*, uchar*))FTB_WORD_cmp, 0, 0, 0);
FTB_WORD_cmp, 0, 0, 0);
for (ftbw= ftb->last_word; ftbw; ftbw= ftbw->prev)
queue_insert(&ftb->queue, (uchar *)ftbw);
ftb->list=(FTB_WORD **)alloc_root(&ftb->mem_root,
sizeof(FTB_WORD *)*ftb->queue.elements);
memcpy(ftb->list, &queue_top(&ftb->queue), sizeof(FTB_WORD *)*ftb->queue.elements);
my_qsort2(ftb->list, ftb->queue.elements, sizeof(FTB_WORD *),
(qsort2_cmp)FTB_WORD_cmp_list, (void*)ftb->charset);
FTB_WORD_cmp_list, (void*)ftb->charset);
if (ftb->queue.elements<2) ftb->with_scan &= ~FTB_FLAG_TRUNC;
ftb->state=READY;
return ftb;

View file

@ -51,9 +51,10 @@ typedef struct st_ft_superdoc
double tmp_weight;
} FT_SUPERDOC;
static int FT_SUPERDOC_cmp(void* cmp_arg __attribute__((unused)),
FT_SUPERDOC *p1, FT_SUPERDOC *p2)
static int FT_SUPERDOC_cmp(void *cmp_arg __attribute__((unused)),
const void *p1_, const void *p2_)
{
const FT_SUPERDOC *p1= p1_, *p2= p2_;
if (p1->doc.dpos < p2->doc.dpos)
return -1;
if (p1->doc.dpos == p2->doc.dpos)
@ -206,9 +207,10 @@ static int walk_and_push(FT_SUPERDOC *from,
}
static int FT_DOC_cmp(void *unused __attribute__((unused)),
FT_DOC *a, FT_DOC *b)
static int FT_DOC_cmp(void *unused __attribute__((unused)), const void *a_,
const void *b_)
{
const FT_DOC *a= a_, *b= b_;
return CMP_NUM(b->weight, a->weight);
}
@ -242,7 +244,7 @@ FT_INFO *ft_init_nlq_search(MI_INFO *info, uint keynr, uchar *query,
bzero(&wtree,sizeof(wtree));
init_tree(&aio.dtree,0,0,sizeof(FT_SUPERDOC),(qsort_cmp2)&FT_SUPERDOC_cmp,
init_tree(&aio.dtree,0,0,sizeof(FT_SUPERDOC),&FT_SUPERDOC_cmp,
NULL, NULL, MYF(0));
ft_parse_init(&wtree, aio.charset);
@ -258,8 +260,7 @@ FT_INFO *ft_init_nlq_search(MI_INFO *info, uint keynr, uchar *query,
if (flags & FT_EXPAND && ft_query_expansion_limit)
{
QUEUE best;
init_queue(&best,ft_query_expansion_limit,0,0, (queue_compare) &FT_DOC_cmp,
0, 0, 0);
init_queue(&best, ft_query_expansion_limit, 0, 0, &FT_DOC_cmp, 0, 0, 0);
tree_walk(&aio.dtree, (tree_walk_action) &walk_and_push,
&best, left_root_right);
while (best.elements)
@ -306,7 +307,7 @@ FT_INFO *ft_init_nlq_search(MI_INFO *info, uint keynr, uchar *query,
&dptr, left_root_right);
if (flags & FT_SORTED)
my_qsort2(dlist->doc, dlist->ndocs, sizeof(FT_DOC), (qsort2_cmp)&FT_DOC_cmp,
my_qsort2(dlist->doc, dlist->ndocs, sizeof(FT_DOC), &FT_DOC_cmp,
0);
err:

View file

@ -30,10 +30,11 @@ typedef struct st_my_ft_parser_param
MEM_ROOT *mem_root;
} MY_FT_PARSER_PARAM;
static int FT_WORD_cmp(CHARSET_INFO* cs, FT_WORD *w1, FT_WORD *w2)
static int FT_WORD_cmp(void *cs_, const void *w1_, const void *w2_)
{
return ha_compare_word(cs, (uchar*) w1->pos, w1->len,
(uchar*) w2->pos, w2->len);
CHARSET_INFO *cs= cs_;
const FT_WORD *w1= w1_, *w2= w2_;
return ha_compare_word(cs, w1->pos, w1->len, w2->pos, w2->len);
}
static int walk_and_copy(FT_WORD *word,uint32 count,FT_DOCSTAT *docstat)
@ -257,8 +258,8 @@ void ft_parse_init(TREE *wtree, CHARSET_INFO *cs)
{
DBUG_ENTER("ft_parse_init");
if (!is_tree_inited(wtree))
init_tree(wtree, 0, 0, sizeof(FT_WORD), (qsort_cmp2)&FT_WORD_cmp, 0,
(void*)cs, MYF(0));
init_tree(wtree, 0, 0, sizeof(FT_WORD), &FT_WORD_cmp, 0, (void *) cs,
MYF(0));
DBUG_VOID_RETURN;
}

View file

@ -30,9 +30,10 @@ typedef struct st_ft_stopwords
static TREE *stopwords3=NULL;
static int FT_STOPWORD_cmp(void* cmp_arg __attribute__((unused)),
FT_STOPWORD *w1, FT_STOPWORD *w2)
static int FT_STOPWORD_cmp(void *cmp_arg __attribute__((unused)),
const void *w1_, const void *w2_)
{
const FT_STOPWORD *w1= w1_, *w2= w2_;
return ha_compare_word(ft_stopword_cs,
(uchar *) w1->pos, w1->len,
(uchar *) w2->pos, w2->len);
@ -62,7 +63,7 @@ int ft_init_stopwords()
if (!(stopwords3=(TREE *)my_malloc(mi_key_memory_ft_stopwords,
sizeof(TREE), MYF(0))))
DBUG_RETURN(-1);
init_tree(stopwords3,0,0,sizeof(FT_STOPWORD),(qsort_cmp2)&FT_STOPWORD_cmp,
init_tree(stopwords3,0,0,sizeof(FT_STOPWORD),&FT_STOPWORD_cmp,
(ft_stopword_file ? (tree_element_free)&FT_STOPWORD_free : 0),
NULL, MYF(0));
/*

View file

@ -61,7 +61,7 @@ static int sort_one_index(HA_CHECK *, MI_INFO *, MI_KEYDEF *, my_off_t, File);
static int sort_key_read(MI_SORT_PARAM *sort_param,void *key);
static int sort_ft_key_read(MI_SORT_PARAM *sort_param,void *key);
static int sort_get_next_record(MI_SORT_PARAM *sort_param);
static int sort_key_cmp(MI_SORT_PARAM *sort_param, const void *a,const void *b);
static int sort_key_cmp(void *sort_param, const void *a, const void *b);
static int sort_ft_key_write(MI_SORT_PARAM *sort_param, const void *a);
static int sort_key_write(MI_SORT_PARAM *sort_param, const void *a);
static my_off_t get_record_for_key(MI_INFO *, MI_KEYDEF *, uchar *);
@ -3805,12 +3805,14 @@ int sort_write_record(MI_SORT_PARAM *sort_param)
/* Compare two keys from _create_index_by_sort */
static int sort_key_cmp(MI_SORT_PARAM *sort_param, const void *a,
const void *b)
static int sort_key_cmp(void *sort_param_, const void *a_, const void *b_)
{
const MI_SORT_PARAM *sort_param= sort_param_;
uint not_used[2];
return (ha_key_cmp(sort_param->seg, *((uchar**) a), *((uchar**) b),
USE_WHOLE_KEY, SEARCH_SAME, not_used));
const void *const *a= a_;
const void *const *b= b_;
return (ha_key_cmp(sort_param->seg, *a, *b,
USE_WHOLE_KEY, SEARCH_SAME, not_used));
} /* sort_key_cmp */

View file

@ -923,8 +923,11 @@ int _mi_ck_write_tree(register MI_INFO *info, uint keynr, uchar *key,
/* typeof(_mi_keys_compare)=qsort_cmp2 */
static int keys_compare(bulk_insert_param *param, uchar *key1, uchar *key2)
static int keys_compare(void *param_, const void *key1_, const void *key2_)
{
const bulk_insert_param *param= param_;
const uchar *key1= key1_;
const uchar *key2= key2_;
uint not_used[2];
return ha_key_cmp(param->info->s->keyinfo[param->keynr].seg,
key1, key2, USE_WHOLE_KEY, SEARCH_SAME,
@ -1020,7 +1023,7 @@ int mi_init_bulk_insert(MI_INFO *info, size_t cache_size, ha_rows rows)
init_tree(&info->bulk_insert[i],
cache_size * key[i].maxlength,
cache_size * key[i].maxlength, 0,
(qsort_cmp2)keys_compare, keys_free, (void *)params++, MYF(0));
keys_compare, keys_free, params++, MYF(0));
}
else
info->bulk_insert[i].root=0;

View file

@ -57,7 +57,7 @@ extern int main(int argc,char * *argv);
static void get_options(int *argc,char ***argv);
static int examine_log(char * file_name,char **table_names);
static int read_string(IO_CACHE *file,uchar* *to,uint length);
static int file_info_compare(void *cmp_arg, void *a,void *b);
static int file_info_compare(void *cmp_arg, const void *a, const void *b);
static int test_if_open(struct file_info *key,element_count count,
struct test_if_open_param *param);
static void fix_blob_pointers(MI_INFO *isam,uchar *record);
@ -329,7 +329,7 @@ static int examine_log(char * file_name, char **table_names)
init_io_cache(&cache,file,0,READ_CACHE,start_offset,0,MYF(0));
bzero((uchar*) com_count,sizeof(com_count));
init_tree(&tree,0,0,sizeof(file_info),(qsort_cmp2) file_info_compare,
init_tree(&tree,0,0,sizeof(file_info), file_info_compare,
file_info_free, NULL, MYF(MY_TREE_WITH_DELETE));
(void) init_key_cache(dflt_key_cache,KEY_CACHE_BLOCK_SIZE,KEY_CACHE_SIZE,
0, 0, 0, 0);
@ -696,8 +696,8 @@ static int read_string(IO_CACHE *file, register uchar* *to, register uint length
} /* read_string */
static int file_info_compare(void* cmp_arg __attribute__((unused)),
void *a, void *b)
static int file_info_compare(void *cmp_arg __attribute__((unused)),
const void *a, const void *b)
{
long lint;

View file

@ -131,8 +131,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(void* cmp_arg __attribute__((unused)),
const uchar *s,const uchar *t);
static int compare_tree(void *cmp_arg __attribute__((unused)),
const void *s, const void *t);
static int get_statistic(PACK_MRG_INFO *mrg,HUFF_COUNTS *huff_counts);
static void check_counts(HUFF_COUNTS *huff_counts,uint trees,
my_off_t records);
@ -142,7 +142,7 @@ static int test_space_compress(HUFF_COUNTS *huff_counts,my_off_t records,
enum en_fieldtype field_type);
static HUFF_TREE* make_huff_trees(HUFF_COUNTS *huff_counts,uint trees);
static int make_huff_tree(HUFF_TREE *tree,HUFF_COUNTS *huff_counts);
static int compare_huff_elements(void *not_used, uchar *a,uchar *b);
static int compare_huff_elements(void *not_used, const void *a, const void *b);
static int save_counts_in_queue(uchar *key,element_count count,
HUFF_TREE *tree);
static my_off_t calc_packed_length(HUFF_COUNTS *huff_counts,uint flag);
@ -176,7 +176,7 @@ static int mrg_rrnd(PACK_MRG_INFO *info,uchar *buf);
static void mrg_reset(PACK_MRG_INFO *mrg);
#if !defined(DBUG_OFF)
static void fakebigcodes(HUFF_COUNTS *huff_counts, HUFF_COUNTS *end_count);
static int fakecmp(my_off_t **count1, my_off_t **count2);
static int fakecmp(const void *count1, const void *count2);
#endif
@ -822,8 +822,8 @@ static HUFF_COUNTS *init_huff_count(MI_INFO *info,my_off_t records)
'tree_pos'. It's keys are implemented by pointers into 'tree_buff'.
This is accomplished by '-1' as the element size.
*/
init_tree(&count[i].int_tree,0,0,-1,(qsort_cmp2) compare_tree, NULL,
NULL, MYF(0));
init_tree(&count[i].int_tree, 0, 0, -1, compare_tree, NULL, NULL,
MYF(0));
if (records && type != FIELD_BLOB && type != FIELD_VARCHAR)
count[i].tree_pos=count[i].tree_buff =
my_malloc(PSI_NOT_INSTRUMENTED, count[i].field_length > 1 ? tree_buff_length : 2,
@ -1182,10 +1182,11 @@ static int get_statistic(PACK_MRG_INFO *mrg,HUFF_COUNTS *huff_counts)
}
static int compare_huff_elements(void *not_used __attribute__((unused)),
uchar *a, uchar *b)
const void *a_, const void *b_)
{
return *((my_off_t*) a) < *((my_off_t*) b) ? -1 :
(*((my_off_t*) a) == *((my_off_t*) b) ? 0 : 1);
const my_off_t *a= a_;
const my_off_t *b= b_;
return *a < *b ? -1 : (*a == *b ? 0 : 1);
}
/* Check each tree if we should use pre-space-compress, end-space-
@ -1694,9 +1695,11 @@ static int make_huff_tree(HUFF_TREE *huff_tree, HUFF_COUNTS *huff_counts)
return 0;
}
static int compare_tree(void* cmp_arg __attribute__((unused)),
register const uchar *s, register const uchar *t)
static int compare_tree(void *cmp_arg __attribute__((unused)), const void *s_,
const void *t_)
{
const uchar *s= s_;
const uchar *t= t_;
uint length;
for (length=global_count->field_length; length-- ;)
if (*s++ != *t++)
@ -3227,8 +3230,10 @@ static void fakebigcodes(HUFF_COUNTS *huff_counts, HUFF_COUNTS *end_count)
-1 count1 > count2
*/
static int fakecmp(my_off_t **count1, my_off_t **count2)
static int fakecmp(const void *count1_, const void *count2_)
{
const my_off_t *const *count1= count1_;
const my_off_t *const *count2= count2_;
return ((**count1 < **count2) ? 1 :
(**count1 > **count2) ? -1 : 0);
}

View file

@ -730,8 +730,8 @@ static int write_keys(MI_SORT_PARAM *info, register uchar **sort_keys,
if (!buffpek)
DBUG_RETURN(1); /* Out of memory */
my_qsort2((uchar*) sort_keys,(size_t) count, sizeof(uchar*),
(qsort2_cmp) info->key_cmp, info);
my_qsort2(sort_keys, count, sizeof(uchar *),
info->key_cmp, info);
if (!my_b_inited(tempfile) &&
open_cached_file(tempfile, my_tmpdir(info->tmpdir), "ST",
DISK_BUFFER_SIZE, info->sort_info->param->myf_rw))
@ -776,8 +776,8 @@ static int write_keys_varlen(MI_SORT_PARAM *info,
if (!buffpek)
DBUG_RETURN(1); /* Out of memory */
my_qsort2((uchar*) sort_keys, (size_t) count, sizeof(uchar*),
(qsort2_cmp) info->key_cmp, info);
my_qsort2(sort_keys, count, sizeof(uchar *),
info->key_cmp, info);
if (!my_b_inited(tempfile) &&
open_cached_file(tempfile, my_tmpdir(info->tmpdir), "ST",
DISK_BUFFER_SIZE, info->sort_info->param->myf_rw))
@ -818,8 +818,8 @@ static int write_index(MI_SORT_PARAM *info, register uchar **sort_keys,
{
DBUG_ENTER("write_index");
my_qsort2((uchar*) sort_keys,(size_t) count,sizeof(uchar*),
(qsort2_cmp) info->key_cmp,info);
my_qsort2(sort_keys, count, sizeof(uchar *),
info->key_cmp, info);
while (count--)
{
if ((*info->key_write)(info,*sort_keys++))
@ -1004,7 +1004,7 @@ merge_buffers(MI_SORT_PARAM *info, ha_keys keys, IO_CACHE *from_file,
sort_length=info->key_length;
if (init_queue(&queue,(uint) (Tb-Fb)+1,offsetof(BUFFPEK,key),0,
(int (*)(void*, uchar *,uchar*)) info->key_cmp,
info->key_cmp,
(void*) info, 0, 0))
DBUG_RETURN(1); /* purecov: inspected */

View file

@ -15,10 +15,10 @@
#include "myrg_def.h"
static int queue_key_cmp(void *keyseg, uchar *a, uchar *b)
static int queue_key_cmp(void *keyseg, const void *a, const void *b)
{
MYRG_TABLE *ma= (MYRG_TABLE *)a;
MYRG_TABLE *mb= (MYRG_TABLE *)b;
const MYRG_TABLE *ma= a;
const MYRG_TABLE *mb= b;
MI_INFO *aa= ma->table;
MI_INFO *bb= mb->table;
uint not_used[2];

View file

@ -8069,9 +8069,11 @@ bool spider_check_index_merge(
}
int spider_compare_for_sort(
SPIDER_SORT *a,
SPIDER_SORT *b
const void *a_,
const void *b_
) {
const SPIDER_SORT *a= static_cast<const SPIDER_SORT *>(a_);
const SPIDER_SORT *b= static_cast<const SPIDER_SORT *>(b_);
DBUG_ENTER("spider_compare_for_sort");
if (a->sort > b->sort)
DBUG_RETURN(-1);

View file

@ -451,8 +451,8 @@ bool spider_check_index_merge(
);
int spider_compare_for_sort(
SPIDER_SORT *a,
SPIDER_SORT *b
const void *a,
const void *b
);
ulong spider_calc_for_sort(

View file

@ -19,8 +19,10 @@
#include <my_rnd.h>
#include "tap.h"
int cmp(void *arg __attribute__((unused)), uchar *a, uchar *b)
int cmp(void *arg __attribute__((unused)), const void *a_, const void *b_)
{
const uchar *a= a_;
const uchar *b= b_;
return *a < *b ? -1 : *a > *b;
}