diff options
Diffstat (limited to 'config-db')
-rw-r--r-- | config-db/OpenSLX/MetaDB/DBI.pm | 7 | ||||
-rw-r--r-- | config-db/OpenSLX/MetaDB/mysql.pm | 5 |
2 files changed, 8 insertions, 4 deletions
diff --git a/config-db/OpenSLX/MetaDB/DBI.pm b/config-db/OpenSLX/MetaDB/DBI.pm index 4bb8ce88..a5a8e68e 100644 --- a/config-db/OpenSLX/MetaDB/DBI.pm +++ b/config-db/OpenSLX/MetaDB/DBI.pm @@ -559,11 +559,12 @@ sub _doInsert $valRow->{'id'} = $lastID; vlog(3, "DB-generated id for <$table> is <$valRow->{id}>"); } - elsif ($valRow->{'id'} != $lastID) { + elsif ($valRow->{'id'} ne $lastID) { # id has been pre-specified, but DB changed it, so we update # it with the pre-specified value - my $sql2 - = "UPDATE $table SET id=$valRow->{'id'} WHERE id=$lastID"; + my $sql2 = unshiftHereDoc(<<" End-of-Here"); + UPDATE $table SET id='$valRow->{'id'}' WHERE id='$lastID' + End-of-Here vlog(3, $sql2); $dbh->do($sql2) or croak _tr( q[Can't update table <%s> (%s)], $table, $dbh->errstr diff --git a/config-db/OpenSLX/MetaDB/mysql.pm b/config-db/OpenSLX/MetaDB/mysql.pm index 0b6569dd..82487191 100644 --- a/config-db/OpenSLX/MetaDB/mysql.pm +++ b/config-db/OpenSLX/MetaDB/mysql.pm @@ -56,7 +56,10 @@ sub connect ## no critic (ProhibitBuiltinHomonyms) vlog(1, "trying to connect user '$dbUser' to mysql-database '$dbSpec'"); $self->{'dbh'} = DBI->connect( - "dbi:mysql:$dbSpec", $dbUser, $dbPasswd, {PrintError => 0} + "dbi:mysql:$dbSpec", $dbUser, $dbPasswd, { + PrintError => 0, + mysql_auto_reconnect => 1, + } ) or die _tr("Cannot connect to database '%s' (%s)", $dbSpec, $DBI::errstr); return 1; } |