From c79039f8679f7a77032f0b81a82771e616f4e704 Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Thu, 17 Jul 2008 20:46:07 +0000 Subject: Fixed two more problems exposed by mysql: * non-numeric IDs (like in the global_info table) were not handled properly * mysql needs to auto-reconnect to bypass problems related to forking while database connections are kept open git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@1934 95ad53e4-c205-0410-b2fa-d234c58c8868 --- config-db/OpenSLX/MetaDB/DBI.pm | 7 ++++--- config-db/OpenSLX/MetaDB/mysql.pm | 5 ++++- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'config-db') 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; } -- cgit v1.2.3-55-g7522