From 9613c434e0500e2815f85536a4793b7dc44d992b Mon Sep 17 00:00:00 2001 From: "msvensson@neptunus.(none)" <> Date: Fri, 1 Jul 2005 15:39:36 +0200 Subject: [PATCH 1/2] Win port fixes --- client/mysqltest.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/client/mysqltest.c b/client/mysqltest.c index fd8f19332ec..d3e0014aa80 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -60,7 +60,12 @@ #include #include #include /* Our own version of lib */ +#ifdef HAVE_SYS_WAIT_H #include +#endif +#ifndef WEXITSTATUS +# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) +#endif #define MAX_QUERY 131072 #define MAX_VAR_NAME 256 #define MAX_COLUMNS 256 From b6dc32a755a3a179c0b56356022dbcb9cb49a416 Mon Sep 17 00:00:00 2001 From: "bell@sanja.is.com.ua" <> Date: Fri, 1 Jul 2005 20:13:07 +0300 Subject: [PATCH 2/2] fixed create_distinct_group() to make references via ref_pointer_array --- sql/sql_select.cc | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 044dc60e4b6..ba14c880b65 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -134,8 +134,8 @@ static void read_cached_record(JOIN_TAB *tab); static bool cmp_buffer_with_ref(JOIN_TAB *tab); static bool setup_new_fields(THD *thd,TABLE_LIST *tables,List &fields, List &all_fields,ORDER *new_order); -static ORDER *create_distinct_group(THD *thd, ORDER *order, - List &fields, +static ORDER *create_distinct_group(THD *thd, Item **ref_pointer_array, + ORDER *order, List &fields, bool *all_order_by_fields_used); static bool test_if_subpart(ORDER *a,ORDER *b); static TABLE *get_sort_by_table(ORDER *a,ORDER *b,TABLE_LIST *tables); @@ -642,7 +642,8 @@ JOIN::optimize() bool all_order_fields_used; if (order) skip_sort_order= test_if_skip_sort_order(tab, order, select_limit, 1); - if ((group_list=create_distinct_group(thd, order, fields_list, + if ((group_list=create_distinct_group(thd, select_lex->ref_pointer_array, + order, fields_list, &all_order_fields_used))) { bool skip_group= (skip_sort_order && @@ -8440,12 +8441,14 @@ setup_new_fields(THD *thd,TABLE_LIST *tables,List &fields, */ static ORDER * -create_distinct_group(THD *thd, ORDER *order_list, List &fields, +create_distinct_group(THD *thd, Item **ref_pointer_array, + ORDER *order_list, List &fields, bool *all_order_by_fields_used) { List_iterator li(fields); Item *item; ORDER *order,*group,**prev; + uint index= 0; *all_order_by_fields_used= 1; while ((item=li++)) @@ -8477,11 +8480,17 @@ create_distinct_group(THD *thd, ORDER *order_list, List &fields, ORDER *ord=(ORDER*) thd->calloc(sizeof(ORDER)); if (!ord) return 0; - ord->item=li.ref(); + /* + We have here only field_list (not all_field_list), so we can use + simple indexing of ref_pointer_array (order in the array and in the + list are same) + */ + ord->item= ref_pointer_array + index; ord->asc=1; *prev=ord; prev= &ord->next; } + index++; } *prev=0; return group;