List:General Discussion« Previous MessageNext Message »
From:Erik Rantapaa Date:June 12 2001 9:34pm
Subject:last_insert_id() issue w/ DBI
View as plain text  
This really might be a DBI problem, but I find it's pretty weird.

I am attempting to perform atomic updates by using UPDATE statements

	UPDATE counter SET v = last_insert_id(v+1) WHERE k = 'xxx';

where counter has the schema: create table counter (k varchar(16) primary key, v int);

This works flawlessly through DBI when accessing a local database.
However, when accessing a remote database it sometimes fails. I can get
it to fail more often when I have multiple processes banging away at
the database with this same statement.

The exact failure is:

	$sth = $dbh->prepare("UPDATE ... WHERE k = ?") succeeds
	$sth->execute("xxx") succeeds
	$sth->{mysql_insertid} is undefined

I've written a C program to test this query, and I can't get it to fail,
even with multiple concurrent queries running.

Has anyone seen this problem before?

Erik Rantapaa

last_insert_id() issue w/ DBIErik Rantapaa12 Jun
  • Re: last_insert_id() issue w/ DBIPaul DuBois12 Jun
    • Re: last_insert_id() issue w/ DBIErik Rantapaa13 Jun