List:Internals« Previous MessageNext Message »
From:Michael Widenius Date:June 20 2001 8:28pm
Subject:Re: Testing MySQL 4.0
View as plain text  


Paul> Hi again,
Paul> As I remember I forget to attach my current patch for sub-selects (for now
Paul> it's mostly for sql_yacc.yy).


Paul> b) optimize (found non-crossreferenced subqueries and execute them
Paul> before
Paul> main query?, other optimizations);
Paul> c) initialize
Paul> d) execute
Paul> e) free resources
Paul> where initialize/execute/free can be called many times. So, I needs
Paul> a help
Paul> to make this work.

>> ok.

Paul> Michael, can you explain which function sets already used in the stages
Paul> listed above (to find where to split mysql_query())? I'm not familiar with
Paul> MySQL sources... :(((

sql/mysql_select.cc is where the big work should be done.

to handle the different stages instead of being a big massive
function. The init part and free resources part should be pretty
obvious, but the rest is a bit harder.

Paul> BTW, when I'm trying to run mysqld under GDB without setting any args it
Paul> says about "Read manual how to run mysqld under root" and halts, but I can't
Paul> re-run it under GDB until GDB restart. If I specified '--one-thread -u
Paul> mysql' all works fine (server starts and after SIGSEGVs it can be restarted
Paul> without restarting GDB).

I know; GDB doesn't work really good with threads.

try creating the following .gdbinit file in the directory you are
doing debugging:

set print sevenbit off
handle SIGUSR1 nostop noprint
handle SIGUSR2 nostop noprint
handle SIGWAITING nostop noprint
handle SIGLWP nostop noprint
handle SIGPIPE nostop
handle SIGALRM nostop
handle SIGHUP nostop
handle SIGTERM nostop noprint

In your ~/.my.ini file you should have:


Some comments for your patch:

Rename 'mysql_new_subselect()' to 'mysql_init_subselect()'
This is more in line with mysql_init_select()


+         mysql_new_subselect(lex);
+         if (lex->sql_command!=SQLCOM_UNION_SELECT)  lex->sql_command=

- Space around !=
- If and command on different rows:

+         if (lex->sql_command != SQLCOM_UNION_SELECT)
            lex->sql_command= SQLCOM_SELECT;

The expr_expr change looks VERY long.

Wouldn't some of the things, like

expr NOT LIKE '(' subselect_stmt ')'


I assume you plan to separate functions classes to handle the
different 'normal' sub selects like:

expr IN_SYM '(' subselect_stmt ')' 

What do you plan to do with:

expr GT_SYM some_all '(' subselect_stmt ')'

each operator just to be able to handle 'some_all'.

We need to do some conversation to do this efficiently.

For example:

1000 >= SOME (SELECT a FROM t1 WHERE X )

should of be converted to the expression:

If there is a row


return 1 else 0

1000 >= ALL (SELECT a FROM t1)

should be converted to

If there is a row


return 0 else 1

use Item_func_not().

Hope this helps a bit on your way.

Anyway, your patch looks ok so far!  Good work!