List:Internals« Previous MessageNext Message »
From:Paul McCullagh Date:January 27 2010 5:42pm
Subject:Finding the start of a statement
View as plain text  
Hi All,

I am having a bit of a problem fixing the following bug:

https://bugs.launchpad.net/pbxt/+bug/513012

The problem is that it leads to "nested statements".

In the test, we have a table called tb0_eng2 which contains a few rows:

create table tb0_eng2 (
   i1 int NOT NULL auto_increment, primary key (i1),
   f1 int,
   f2 char (32)
);

insert into tb0_eng2 (f1,f2) values
   (7,  'init_val'),
   (14, 'init_val'),
   (10, 'init_val'),
   (14, 'init_val'),
   (4,  'init_val');

One of the rows is being constantly updated, as follows:

update tb0_eng2 set f2='Update #$counter' where f1=10;

A trigger on tb0_eng2, does an INSERT on tb0_logs for every UPDATE on  
tb0_eng2:

Create trigger tb0_eng2_upd after update on tb0_eng2
   for each row
     insert into tb0_logs (entry_dsc)
     values (concat('Update row ', old.i1, ' ', old.f2, ' -> ',  
new.f2));

So the INSERT statement is "nested" in the UPDATE statement.

My problem is that I need to detect the start and end of statements.

As far as I can tell (at least I have always assumed this) in this case:

ha_handler::start_stmt() is called for each table at the start of a  
statement, and

ha_handler::reset() is called for each table at the end of each  
statement.

It would be easy to tell the start and end of statements if these  
functions were only called ONCE for each statement.

However, if multiple tables are involved in a statement (which is not  
the case in the example above), then start_stmt() and reset() are  
called multiple times for each statement.

So how do I know where the actual boundaries of the statements are?

Any help would be appreciated.

--
Paul McCullagh
PrimeBase Technologies
www.primebase.org
www.blobstreaming.org
pbxt.blogspot.com



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