Hi,
I think the failure is not as bad as I first thought.
An INSERT statement is executed on the database handle.
Subsequently, on the same database handle, a SELECT is performed.
Now $dbh->{mysql_insertid} is 0 on the database handle; when compiled
against libmysqlclient 5.7 or up.
That actually seems more correct to me, although it is of course a
change in behavior when compared to earlier versions of libmysqlclient.
I think it would be best to always use $sth->{mysql_insertid}, and
I've updated the docs to reflect this. Also, I updated the test t/31insertid.t so it now passes on the newer client versions.
I put this out as version 4.035_01 (a DEV release) on CPAN. Please let me know your ideas.
--
Michiel
On Thu 28 Jul 2016 10:13:28, neuron wrote:
Show quoted text> Hi,
>
> I have hit the same issue (mysql 5.7.11) and I will be providing more
> data to
> mysql team. But I wonder. What is the difference between
> $sth->{'mysql_insertid'} and $dbh->{'mysql_insertid'} ?
>
> From the specs
>
>
https://dev.mysql.com/doc/refman/5.7/en/mysql-insert-id.html
>
> my_ulonglong mysql_insert_id(MYSQL *mysql)
>
> Which would I think correspond to $dbh-> one. What $sth-> one should
> do?
> (strangely dbh one fails)
>
>
> Also if I enable debug level3, I can see for the successfull call:
>
> -> FETCH for DBD::mysql::st (DBI::st=HASH(0x39ce58bc0)~INNER
> 'mysql_insertid') thr#39cae9cf0
> -> dbd_st_FETCH_attrib for 39cd74cf0, key mysql_insertid
> INSERT ID 2
> <- FETCH= ( '2' ) [1 items] at 31insertid.t line 58
> -> FETCH for DBD::mysql::st (DBI::st=HASH(0x39ce58bc0)~INNER
> 'mysql_insertid') thr#39cae9cf0
> -> dbd_st_FETCH_attrib for 39cd74cf0, key mysql_insertid
> INSERT ID 2
> <- FETCH= ( '2' ) [1 items] at Builder.pm line 1159 via at More.pm
> line 482
>
>
>
> And for the unsuccessfull call:
>
> -> FETCH for DBD::mysql::db (DBI::db=HASH(0x39d026d20)~INNER
> 'mysql_insertid') thr#39cae9cf0
> <- FETCH= ( '0' ) [1 items] at 31insertid.t line 60
> -> FETCH for DBD::mysql::db (DBI::db=HASH(0x39d026d20)~INNER
> 'mysql_insertid') thr#39cae9cf0
> <- FETCH= ( '0' ) [1 items] at Builder.pm line 1159 via at More.pm
> line 482
>
>
> This is the same for both mysql 5.6 (where the test passes) and 5.7
> (where it does not)
>
> I have no idea whether it means anything, but maybe it rings a bell?
>
> Cheers
> __
> Vlad