summaryrefslogtreecommitdiffstats
path: root/config-db
diff options
context:
space:
mode:
authorOliver Tappe2008-07-17 22:46:07 +0200
committerOliver Tappe2008-07-17 22:46:07 +0200
commitc79039f8679f7a77032f0b81a82771e616f4e704 (patch)
treeaf3680fc7d96d25c43ab35153cd6f839a52ef289 /config-db
parent* fixed bad bug that would cause removal of vendor-OS if the export was (diff)
downloadcore-c79039f8679f7a77032f0b81a82771e616f4e704.tar.gz
core-c79039f8679f7a77032f0b81a82771e616f4e704.tar.xz
core-c79039f8679f7a77032f0b81a82771e616f4e704.zip
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
Diffstat (limited to 'config-db')
-rw-r--r--config-db/OpenSLX/MetaDB/DBI.pm7
-rw-r--r--config-db/OpenSLX/MetaDB/mysql.pm5
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;
}