Subject: | Ubuntu 16.04, MySQL 5.7, "Can't get last insert id" error on inserting row. |
Date: | Mon, 24 Oct 2016 17:51:25 +0100 |
To: | bug-Class-DBI [...] rt.cpan.org |
From: | ChintzBaby <chintzbaby [...] chintzbaby.com> |
Hi,
* Class-DBI-v3.0.17
* Perl : v5.22.1
* Ubuntu 16.04 : Linux 4.4.0-45-lowlatency #66-Ubuntu SMP PREEMPT Wed
Oct 19 14:57:51 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
* MySQL : Ver 14.14 Distrib 5.7.15, for Linux (x86_64)
* DBD-mysql-4.038
* libmysqlclient.so.20.3.2
I've upgraded Ubuntu from 15.10 (MySQL5.6) and now have MySQL 5.7, and I
get "Can't get last insert id" when inserting a row into a table, where
in 5.6/15.10 it worked fine.
The row does get inserted into the table ok, but the inserted row_id is
not returned by MySQL :
Line 609 in /usr/local/share/perl/5.22.1/Class/DBI.pm :
sub _auto_increment_value {
...
my $id = $dbh->last_insert_id(undef, undef, $self->table, undef)
# std
|| $dbh->{mysql_insertid} # mysql
|| eval { $dbh->func('last_insert_rowid') }
*or $self->_croak("Can't get last insert id");*
Called from my CGI program :
use DBI;
use MyApp;
use MyApp::PictureTag;
...
MyApp::PictureTag->insert (
{
Picture_id => $PicId,
Tag_id => $TagId,
}
);
PictureTag has a primary auto-increment key.
DBI Trace :
-> ping for DBD::mysql::db
(DBIx::ContextualFetch::db=HASH(0x55b68bc45d30)~0x55b68bc45e68)
thr#55b68a5a8220
T <- ping= ( 1 ) [1 items] at /usr/local/share/perl/5.22.1/Ima/DBI.pm
line 326 via at /usr/local/share/perl/5.22.1/Class/DBI.pm line 600
Show quoted text
>> last_insert_id DISPATCH
(DBIx::ContextualFetch::db=HASH(0x55b68bc45d30) rc1/3 @5 g2 ima2801
pid#13281) at /usr/local/share/perl/5.22.1/Class/DBI.pm line 609 via at
/usr/local/share/perl/5.22.1/Class/DBI.pm line 628
-> last_insert_id for DBD::mysql::db
(DBIx::ContextualFetch::db=HASH(0x55b68bc45d30)~0x55b68bc45e68 undef
undef 'PictureTag' undef) thr#55b68a5a8220
T <- last_insert_id= ( '0' ) [1 items] at
/usr/local/share/perl/5.22.1/Class/DBI.pm line 609 via at
/usr/local/share/perl/5.22.1/Class/DBI.pm line 628
Show quoted text >> FETCH DISPATCH
(DBIx::ContextualFetch::db=HASH(0x55b68bc45e68) rc2/23 @2 g2 ima404
pid#13281) at /usr/local/share/perl/5.22.1/Class/DBI.pm line 609 via at
/usr/local/share/perl/5.22.1/Class/DBI.pm line 628
-> FETCH for DBD::mysql::db
(DBIx::ContextualFetch::db=HASH(0x55b68bc45e68)~INNER 'mysql_insertid')
thr#55b68a5a8220
T <- FETCH= ( '0' ) [1 items] at
/usr/local/share/perl/5.22.1/Class/DBI.pm line 609 via at
/usr/local/share/perl/5.22.1/Class/DBI.pm line 628
Show quoted text >> func DISPATCH
(DBIx::ContextualFetch::db=HASH(0x55b68bc45d30) rc1/3 @2 g2 ima6
pid#13281) at /usr/local/share/perl/5.22.1/Class/DBI.pm line 609 via at
/usr/local/share/perl/5.22.1/Class/DBI.pm line 609
-> last_insert_rowid for DBD::mysql::db
(DBIx::ContextualFetch::db=HASH(0x55b68bc45d30)~0x55b68bc45e68)
thr#55b68a5a8220
I've seen some reference to this here :
https://rt.cpan.org/Public/Bug/Display.html?id=108000 and in the change
notes for 4.035_01, but I do not know how to solve this issue (apart
from going back to MySQL 5.6).
I've scrubbed Google and I can't find anyone else who has had this issue!
Thanks much for any help.
Andy