>>>>> "Paul" == Paul Cadach <paul@stripped> writes:
Paul> One more thing is to convert regular select to return Item_select
Paul> which with
Paul> send results:
Paul> 1) directly to network;
Paul> 2) into temporary table (located in memory for tiny tables and
Paul> for huge tables).
>> I don't think you really need to do that.
>> You can already do the same thing with the current code.
>> Check the select_result class in sql_class.h and sql_class.cc; This
>> enables the result of a select be direct to different places.
Paul> Thanks for very useful information.
>> I think we should be able to do this without any big changes in
>> the mysql_select() interface.
Paul> As I can see in sql_parse.cc, mysql_select() calls 4 times with next
Paul> 1) thd (always);
Paul> 2) tables (or tables->next in CREATE/INSERT queries);
Paul> 3) select_lex->item_list (fields list);
Paul> 4) select_lex->where (where clause);
Paul> 5) select_lex->ftfunc_list (full-text search functions);
Paul> 6) (ORDER *)select_lex->order_list.first (or UNLL in multi_delete;
Paul> expressions in order clause);
Paul> 7) (ORDER *)select_lex->group_list.first (or NULL in multi_delete;
Paul> expressions in group clause);
Paul> 8) select_lex->having (or NULL in multi_delete; having clause);
Paul> 9) (ORDER *)lex->proc_list.first (or NULL in multi_delete; procedure clause;
Paul> 2Sinisa: may be this needs to be moved from lex to select_lex?);
Paul> 10) select_lex->options | thd->options (| SELECT_NO_JOIN_CACHE in
Paul> 11) result.
Paul> As you can see 7/8 out of 11 arguments uses select_lex. May be to pass just
Paul> select_lex structure to mysql_select instead of those many arguments (this
Paul> also will help Sinisa to handle select_lex->next inside mysql_select() for
The reason for doing it this way was just to have mysql_select at
least in theory unaware of the lex structure, as this may change a
lot in the future when we add stored procedures.
I would vote for keeping the long argument list as it's now and when
we have got stored procedures in place (Arnulf should hopefully start
looking at this within weeks) then clean this up.
>> In other words:
>> - Break up the mysql_select() function in sql/sql_select.cc into
Paul> As I can see not cross-referenced sub-queries can be handled by existing
Paul> mysql_select() function. May be to try with existing then split it because
Paul> spliiting is very hard for me (at least for now, without good knowelege of
Paul> MySQL internals).
>> - Create a new mysql_select() function with almost the same parameters
>> as the old one, but using the pieces.
>> - Code item_select() to use the pieces.
>> - It should not be that hard to be able to refer to tables outside
>> the sub select from the inside of the sub select.
>> If you can break up mysql_select() into sub-pieces (init, execute...)
>> and get this to work again, I can probably help you with some of the
>> things that will come up.
Paul> I want to go some diffirent way - code sub-select related Item_, etc then
Paul> split mysql_select() because I don't have enough knowelege of MySQL
Paul> internals to do this work now.