[CC'ed to Tim in order to terminate an old thread :-)]
"Gregory C. Falck" wrote:
>
> Updates that change a value to to the same thing
> come back as 0 rows updated:
>
> For example:
> object.object_title in the database is initially blank.
>
> $stmt = q{update object set object_title='test' where object_id=162};
> $sth = $dbh->prepare($stmt);
> $rv = $sth->execute;
> $rv returns 1, $sth->rows returns 1, this is correct
> execute it again
> $rv = $sth->execute;
> $rv returns 0E0, $sth->rows returns 0, this is wrong. The number
> of affected rows by the update is still 1 even though the value updated
> didn't change.
>
> I'm using mysql 1.2200.
Hmmm, I forgot about this outstanding issue. This is a known behaviour
of the MySQL engine, call it a bug or a feature, as you like. (It declares
"affected" as "changed".) The behaviour you are expecting can be enabled
by setting the C flag CLIENT_FOUND_ROWS when connecting to the database.
I have now uploaded a version 1.2205 of the Msql-Mysql-modules to CPAN
which has the following new feature: When connecting with
DBI->connect("DBI:mysql:test;mysql_client_found_rows=0", ...)
then you have the old behaviour. With
DBI->connect("DBI:mysql:test;mysql_client_found_rows=1", ...)
you have CLIENT_FOUND_ROWS set, thus your query will always return 1.
The default is 0, however you can change this by compiling the
Msql-Mysql-modules with
perl Makefile.PL --config --mysql-use-client-found-rows
in which case the default is 1.
Monty, I dislike that this must be choosen while connecting to the
client. Couldn't we make this part of the MYSQL structure?
Thanks,
Jochen
--
Jochen Wiedmann joe@stripped
Life has brown and green eyes. :-) +49 7123 14887