From fab5bf352950e15fbca1befd55eacdd5924dac71 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 4 Nov 2003 11:20:00 +0200 Subject: [PATCH 1/4] avoid writting junk --- sql/unireg.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/sql/unireg.cc b/sql/unireg.cc index 8606830e450..7ad20a4b208 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -302,6 +302,7 @@ static uint pack_keys(uchar *keybuff,uint key_count,KEY *keyinfo) { keybuff[0]=(uchar) key_count; keybuff[1]=(uchar) key_parts; + keybuff[2]= keybuff[3]= 0; } length=(uint) (pos-keyname_pos); int2store(keybuff+4,length); From 92c280552fee94ed016a05f5012954f71cd3cd90 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 4 Nov 2003 12:51:01 +0200 Subject: [PATCH 2/4] fixed problem with UNION flags sql/sql_lex.h: removed unused flag sql/sql_union.cc: correct flag used --- sql/sql_lex.h | 2 +- sql/sql_union.cc | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 20b796bb1ba..be931c56247 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -296,7 +296,7 @@ protected: select_result *result; int res; - ulong describe, found_rows_for_union; + ulong found_rows_for_union; bool prepared, // prepare phase already performed for UNION (unit) optimized, // optimize phase already performed for UNION (unit) executed, // already executed diff --git a/sql/sql_union.cc b/sql/sql_union.cc index de2bb4a786c..93541d66d65 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -377,11 +377,12 @@ int st_select_lex_unit::exec() offset_limit_cnt= global_parameters->offset_limit; select_limit_cnt= global_parameters->select_limit + global_parameters->offset_limit; + if (select_limit_cnt < global_parameters->select_limit) select_limit_cnt= HA_POS_ERROR; // no limit if (select_limit_cnt == HA_POS_ERROR) options&= ~OPTION_FOUND_ROWS; - else if (found_rows_for_union && !describe) + else if (found_rows_for_union && !thd->lex.describe) options|= OPTION_FOUND_ROWS; fake_select_lex->ftfunc_list= &empty_list; fake_select_lex->table_list.link_in_list((byte *)&result_table_list, From 91b53294dfa28bf576d1662db9ba910a19570f0f Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 4 Nov 2003 13:28:36 +0200 Subject: [PATCH 3/4] avoid problem when all tables are const --- sql/sql_select.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index bdaed894a52..8df64e2040c 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -862,7 +862,8 @@ JOIN::optimize() We only need to do this when we have a simple_order or simple_group as in other cases the join is done before the sort. */ - if ((order || group_list) && join_tab[const_tables].type != JT_ALL && + if (const_tables != tables && + (order || group_list) && join_tab[const_tables].type != JT_ALL && join_tab[const_tables].type != JT_FT && (order && simple_order || group_list && simple_group)) { From e82a1ff9027b8c4557ffb6dd9500a523a6c04e1e Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 4 Nov 2003 13:47:19 +0200 Subject: [PATCH 4/4] avoid problem when all tables are const --- sql/sql_select.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index bdaed894a52..8df64e2040c 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -862,7 +862,8 @@ JOIN::optimize() We only need to do this when we have a simple_order or simple_group as in other cases the join is done before the sort. */ - if ((order || group_list) && join_tab[const_tables].type != JT_ALL && + if (const_tables != tables && + (order || group_list) && join_tab[const_tables].type != JT_ALL && join_tab[const_tables].type != JT_FT && (order && simple_order || group_list && simple_group)) {