List:Internals« Previous MessageNext Message »
From:Michael Widenius Date:February 3 2010 11:17am
Subject:Re: Finding the start of a statement
View as plain text  
Hi!

>>>>> "MARK" == MARK CALLAGHAN <mdcallag@stripped> writes:

MARK> On Fri, Jan 29, 2010 at 11:29 AM, Michael Widenius <monty@stripped>
> wrote:
>> 
>> Hi!
>> 
>>>>>>> "Paul" == Paul McCullagh <paul.mccullagh@stripped>
> writes:


Paul> It would be easy to tell the start and end of statements if these
Paul> functions were only called ONCE for each statement.
>> 
Paul> However, if multiple tables are involved in a statement (which is not
Paul> the case in the example above), then start_stmt() and reset() are
Paul> called multiple times for each statement.
>> 
Paul> So how do I know where the actual boundaries of the statements are?
>> 
>> Why not simply have a counter in your transaction object for how
>> start_stmt - reset();  When this is 0 then you know stmnt ended.
>> 
>> In Maria we count number of calls to external_lock() and when the sum
>> goes to 0 we know the transaction has ended.

MARK> Why does the solution need to be so obscure?

Historic reasons.

MySQL never kept a count of which handlers are used by a transaction,
only which tables.

So the original logic was that external_lock(lock/unlock) is called
for each usage of the table, which is normally more than enough
information for a handler to know when a statement starts/ends.

The one case this didn't work was in the case someone does lock
tables as then external_lock is not called per statement.
It was to satisfy this case that we added a call to start_stmt() for
each table.

It's of course possible to change things so that start_stmt() /
end_stmt() would be called once per used handler, but this would be
yet another overhead for the upper level to do which the current
handlers that tracks call to external_lock() doesn't need.

Regards,
Monty
Thread
Finding the start of a statementPaul McCullagh27 Jan
  • re: Finding the start of a statementMichael Widenius29 Jan
    • Re: Finding the start of a statementMARK CALLAGHAN29 Jan
      • Re: Finding the start of a statementPaul McCullagh1 Feb
        • Re: Finding the start of a statementKristian Nielsen1 Feb
          • Re: Finding the start of a statementPaul McCullagh1 Feb
          • Re: Finding the start of a statementKristian Nielsen11 Feb
        • Re: Finding the start of a statementSergei Golubchik1 Feb
          • Re: Finding the start of a statementPaul McCullagh2 Feb
      • Re: Finding the start of a statementMichael Widenius3 Feb
        • Re: Finding the start of a statementMARK CALLAGHAN18 Feb
          • Re: Finding the start of a statementMARK CALLAGHAN18 Feb
  • Re: Finding the start of a statementSergei Golubchik1 Feb
    • Re: Finding the start of a statementPaul McCullagh1 Feb