List:Internals« Previous MessageNext Message »
From:AugustQ Date:March 31 2012 2:39pm
Subject:table-scan-question
View as plain text  
Hi,

I'm playing with the source of MySQL (5.5) and ran into a problem. Can
you please give me a tip.

This is what I did:

let's take this statement as an example:
select * from ABDAcol2 where Hersteller = '1234';

this is what happens on the storage engine:
ha_myc::cond_push
ha_myc::rnd_init
ha_myc::rnd_next
......
ha_myc::rnd_end

OK, I simplified the listing.

In cond_push() I check the statement for some special condition.
In rnd_init() I do some preparatory work, if my condition is detected,
in rnd_next() I do some work on a row and in rnd_end() I do the cleanup.
This works. 

So I switched to this statement:
delete from ABDAcol2 where Hersteller = '1234';

Now it looks this way:
ha_myc::rnd_init
ha_myc::cond_push
ha_myc::rnd_next
.......
ha_myc::rnd_end
Now my code crashes. As you can see the order of rnd_init() and
cond_push() are swapped.

Let's take the third case:
update ABDAcol2 set hersteller = '12' where Hersteller = '1234';

The calls are like this:
ha_myc::rnd_init
ha_myc::cond_push
ha_myc::rnd_next
.............
ha_myc::rnd_end
Again rnd_init() comes before cond_push(). 

If the calls happen in this order my initialization is not done because
the situation is not detected yet. Later the situation is detected but
no initialization follows.

So what's wrong here?

Was I wrong with my assumption of the order in wich the functions are
called? In the csv-engine the order of the function-calls is described
as in my example above with the select-stmt.

Or: do I have to do my initializations in the cond_push()-function? Or
in the rnd_next()-function when it's called for the first time?

Any tips?
Thanks
August


Thread
table-scan-questionAugustQ31 Mar
  • Re: table-scan-questionStewart Smith2 Apr