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" == Paul Cadach <paul@stripped> writes:

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/ is where the big work should be done.

The function mysql_select() should be slit to 3-7 smaller functions
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=
I would be greatfull if you can follow the same coding style as the
rest of the code ;  This makes the total much easier to read.

- 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 ')'

be handle by adding '(' subselect_stmt ')' to 'simple_expr' ?

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

expr IN_SYM '(' subselect_stmt ')' 
{ $$= new Item_sub_select_in($1, $4); }

What do you plan to do with:

expr GT_SYM some_all '(' subselect_stmt ')'

It seams kind of stupid to have to do a separate class for
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

(SELECT 1 from T1 WHERE (X) AND (1000 >= A) LIMIT 1) 

return 1 else 0

1000 >= ALL (SELECT a FROM t1)

should be converted to

If there is a row

(SELECT 1 from T1 WHERE (X) AND (1000 < A) LIMIT 1) 

return 0 else 1

Note that you should not use NOT as MySQL doesn't use keys when you
use Item_func_not().

Hope this helps a bit on your way.

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