DBD::mysql::st execute failed: Cannot add or update a child row: a foreign key constraint fails at ./parseTreesPG.pl line 710.
This is not a problem in PG because foreign key checks are deferrable. Since foreigns keys are not deferrable in MySQL I am temporarily turning off FK checks in the PERL code:
$dbh->do("SET FOREIGN_KEY_CHECKS=0");to deal with this in MySQL.
#UPDATE tree TABLE HERE
$dbh->do("SET FOREIGN_KEY_CHECKS=1");
This solves this problem, but now I am still getting problems with commit:
commit ineffective with AutoCommit enabled at ./parseTreesPG.pl line 316.
Commmit ineffective while AutoCommit is on at ./parseTreesPG.pl line 316.
DBD::mysql::db commit failed: Commmit ineffective while AutoCommit is on at ./parseTreesPG.pl line 316.
I therefore added a check to see if AutoCommit was on before attempint $dbh->commit:
I am now trying to see if this will fix the problem without introducing new errors.
unless ($dbh->{AutoCommit}) {
$dbh->commit;
}
2 comments:
I'm not sure why the script should ever run with autocommit enabled in one driver but not on the other.
Would there be harm in just adding AutoCommit => 0 to the MySQL connection parameters?
Assuming that I set the MySQL schema up correctly this should be fine. I just added AutoCommit=>0 to the ConnectToMySQL subfunction of PhyInit.pl. I'll see if things work after I add $dbh->commit() to the code.
Post a Comment