Page 1 of 1

Bug / CPU issue with LAST_INSERT_ID()

Posted: Sat 25 Jun 2005 17:07
by dragonslayer
I was wondering if anyone else had had a problem with a query on LAST_INSERT_ID(). When I execute the following C++ code it will work, but when execution reaches the Query->Open() the CPU load jumps to 100% and it takes about 5 seconds to complete. It seems only to happen on this table, but is not an isolated event - I have seen it in other sections of my code where LAST_INSERT_ID() is used.

Thanks in anticipation ...

Code: Select all

    TMyQuery* Query2 = new TMyQuery(0);
    Query->Connection = MyDBSession;
    Query->SQL->Clear();
    Query->SQL->Add( "select"
                     " LAST_INSERT_ID() SeqNo"
                     " from txqueue" );
    Query->Open();
    if ( !Query->Eof )
      SeqNo = Query->FieldByName( "SeqNo" )->AsInteger;
[/code]

Correction to code sample

Posted: Sat 25 Jun 2005 17:09
by dragonslayer
Sould read ...
TMyQuery* Query = new TMyQuery(0);
and not ...
TMyQuery* Query2 = new TMyQuery(0);

Posted: Mon 27 Jun 2005 08:03
by GEswin
We had some unresolved issue with mysql 4.1.7 or 4.1.8 where selecting LAST_INSERT_ID() caused the server to shutdown (This under windows2003 server).