Skip to content

Commit 91c4d27

Browse files
author
Tor Didriksen
committed
Bug#27589205 CALL TO FUNCTION COMPARE_FIELDS_BY_TABLE_ORDER
Use void* for function arguments, and cast Item_field* in function body. compare_fields_by_table_order(Item_field*, Item_field*, void*) through pointer to incorrect function type 'int (*)(void *, void *, void *)' sql/sql_optimizer.cc:3904: note: compare_fields_by_table_order(Item_field*, Item_field*, void*) defined here #0 0x34ac57d in base_list::sort(int (*)(void*, void*, void*), void*) sql/sql_list.h:278:13 #1 0x49ad303 in substitute_for_best_equal_field(Item*, COND_EQUAL*, Change-Id: I4f5417304a24201682f32fc7631034de7aa62589
1 parent 8e50623 commit 91c4d27

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

sql/item_cmpfunc.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5842,8 +5842,8 @@ bool Item_equal::merge(THD *thd, Item_equal *item) {
58425842
@param arg context extra parameter for the cmp function
58435843
*/
58445844

5845-
void Item_equal::sort(Item_field_cmpfunc compare, void *arg) {
5846-
fields.sort((Node_cmp_func)compare, arg);
5845+
void Item_equal::sort(Node_cmp_func compare, void *arg) {
5846+
fields.sort(compare, arg);
58475847
}
58485848

58495849
/**

sql/item_cmpfunc.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ struct MY_BITMAP;
6767

6868
typedef int (Arg_comparator::*arg_cmp_func)();
6969

70-
typedef int (*Item_field_cmpfunc)(Item_field *f1, Item_field *f2, void *arg);
71-
7270
class Arg_comparator {
7371
Item **a, **b;
7472
arg_cmp_func func;
@@ -2039,7 +2037,7 @@ class Item_equal final : public Item_bool_func {
20392037
longlong val_int() override;
20402038
const char *func_name() const override { return "multiple equal"; }
20412039
optimize_type select_optimize() const override { return OPTIMIZE_EQUAL; }
2042-
void sort(Item_field_cmpfunc compare, void *arg);
2040+
void sort(Node_cmp_func compare, void *arg);
20432041
friend class Item_equal_iterator;
20442042
bool resolve_type(THD *) override;
20452043
bool fix_fields(THD *thd, Item **ref) override;

sql/sql_optimizer.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3890,8 +3890,8 @@ bool build_equal_items(THD *thd, Item *cond, Item **retcond,
38903890
The function finds out what of two fields is better according
38913891
this criteria.
38923892
3893-
@param field1 first field item to compare
3894-
@param field2 second field item to compare
3893+
@param v_field1 first field item to compare
3894+
@param v_field2 second field item to compare
38953895
@param table_join_idx index to tables determining table order
38963896
38973897
@retval
@@ -3902,8 +3902,10 @@ bool build_equal_items(THD *thd, Item *cond, Item **retcond,
39023902
0 otherwise
39033903
*/
39043904

3905-
static int compare_fields_by_table_order(Item_field *field1, Item_field *field2,
3905+
static int compare_fields_by_table_order(void *v_field1, void *v_field2,
39063906
void *table_join_idx) {
3907+
Item_field *field1 = static_cast<Item_field *>(v_field1);
3908+
Item_field *field2 = static_cast<Item_field *>(v_field2);
39073909
int cmp = 0;
39083910
bool outer_ref = 0;
39093911
if (field1->used_tables() & OUTER_REF_TABLE_BIT) {

0 commit comments

Comments
 (0)