diff options
author | unknown <bell@sanja.is.com.ua> | 2004-05-19 17:07:28 +0300 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2004-05-19 17:07:28 +0300 |
commit | e30a580d365df03d613c5affe14bd8cc5166f786 (patch) | |
tree | ee18fab3d095804e9a76acc18f491adfe2f6cc6f /sql | |
parent | 70f64db1cf082c8bafcd44975d864c97e6fa878b (diff) | |
download | mariadb-git-e30a580d365df03d613c5affe14bd8cc5166f786.tar.gz |
after review changes
mysql-test/r/derived.result:
explain of hidden subselect changed according to review
mysql-test/r/subselect.result:
explain of hidden subselect changed according to review
mysql-test/r/union.result:
explain of hidden subselect changed according to review
sql/sql_class.h:
we bo not need sign for now
sql/sql_lex.h:
we do not need sign for now
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_class.h | 2 | ||||
-rw-r--r-- | sql/sql_lex.h | 2 | ||||
-rw-r--r-- | sql/sql_select.cc | 47 |
3 files changed, 36 insertions, 15 deletions
diff --git a/sql/sql_class.h b/sql/sql_class.h index 9ed49c22119..493ac8e1256 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -773,7 +773,7 @@ public: uint current_tablenr,tmp_table; uint server_status,open_options,system_thread; uint32 db_length; - int select_number; //number of select (used for EXPLAIN) + uint select_number; //number of select (used for EXPLAIN) /* variables.transaction_isolation is reset to this after each commit */ enum_tx_isolation session_tx_isolation; enum_check_fields count_cuted_fields; diff --git a/sql/sql_lex.h b/sql/sql_lex.h index e6a2dcdb754..2df2c998ff0 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -425,7 +425,7 @@ public: ulong table_join_options; uint in_sum_expr; - int select_number; /* number of select (used for EXPLAIN) */ + uint select_number; /* number of select (used for EXPLAIN) */ uint with_wild; /* item list contain '*' */ bool braces; /* SELECT ... UNION (SELECT ... ) <- this braces */ /* TRUE when having fix field called in processing of this SELECT */ diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 891efb50d11..194f27e6fb8 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -9133,7 +9133,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, if (message) { - item_list.push_back(new Item_int((longlong) + item_list.push_back(new Item_int((int32) join->select_lex->select_number)); item_list.push_back(new Item_string(join->select_lex->type, strlen(join->select_lex->type), cs)); @@ -9146,23 +9146,44 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, else if (join->select_lex == join->unit->fake_select_lex) { /* - Here is guessing about fake_select_lex to avoid union SELECT - execution to get accurate information + here we assume that the query will return at least two rows, so we + show "filesort" in EXPLAIN. Of course, sometimes we'll be wrong + and no filesort will be actually done, but executing all selects in + the UNION to provide precise EXPLAIN information will hardly be + appreciated :) */ - char table_name_buffer[64]; + char table_name_buffer[NAME_LEN]; item_list.empty(); /* id */ - item_list.push_back(new Item_int((int32) - join->select_lex->select_number)); + item_list.push_back(new Item_null); /* select_type */ item_list.push_back(new Item_string(join->select_lex->type, strlen(join->select_lex->type), cs)); /* table */ - int len= my_snprintf(table_name_buffer, sizeof(table_name_buffer)-1, - "<union%d>", - -join->select_lex->select_number); - item_list.push_back(new Item_string(table_name_buffer, len, cs)); + { + SELECT_LEX *sl= join->unit->first_select(); + uint len= 6, lastop= 0; + memcpy(table_name_buffer, "<union", 6); + for (; sl && len + lastop + 5 < NAME_LEN; sl= sl->next_select()) + { + len+= lastop; + lastop= my_snprintf(table_name_buffer + len, NAME_LEN - len, + "%u,", sl->select_number); + } + if (sl || len + lastop >= NAME_LEN) + { + memcpy(table_name_buffer + len, "...>", 5); + len+= 4; + } + else + { + len+= lastop; + table_name_buffer[len - 1]= '>'; // change ',' to '>' + } + item_list.push_back(new Item_string(table_name_buffer, len, cs)); + } + /* type */ item_list.push_back(new Item_string(join_type_str[JT_ALL], strlen(join_type_str[JT_ALL]), cs)); @@ -9195,7 +9216,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, TABLE *table=tab->table; char buff[512],*buff_ptr=buff; char buff1[512], buff2[512]; - char table_name_buffer[64]; + char table_name_buffer[NAME_LEN]; String tmp1(buff1,sizeof(buff1),cs); String tmp2(buff2,sizeof(buff2),cs); tmp1.length(0); @@ -9203,7 +9224,7 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, item_list.empty(); /* id */ - item_list.push_back(new Item_int((int32) + item_list.push_back(new Item_uint((uint32) join->select_lex->select_number)); /* select_type */ item_list.push_back(new Item_string(join->select_lex->type, @@ -9379,7 +9400,7 @@ int mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit, select_result *result) } if (first->next_select()) { - unit->fake_select_lex->select_number= -first->select_number; + unit->fake_select_lex->select_number= UINT_MAX; // jost for initialization unit->fake_select_lex->type= "UNION RESULT"; unit->fake_select_lex->options|= SELECT_DESCRIBE; if (!(res= unit->prepare(thd, result, SELECT_NO_UNLOCK | SELECT_DESCRIBE))) |