summaryrefslogtreecommitdiffstats
path: root/config-db/OpenSLX/MetaDB/mysql.pm
diff options
context:
space:
mode:
Diffstat (limited to 'config-db/OpenSLX/MetaDB/mysql.pm')
-rw-r--r--config-db/OpenSLX/MetaDB/mysql.pm100
1 files changed, 47 insertions, 53 deletions
diff --git a/config-db/OpenSLX/MetaDB/mysql.pm b/config-db/OpenSLX/MetaDB/mysql.pm
index eb6f9551..195f9870 100644
--- a/config-db/OpenSLX/MetaDB/mysql.pm
+++ b/config-db/OpenSLX/MetaDB/mysql.pm
@@ -15,7 +15,7 @@ package OpenSLX::MetaDB::mysql;
use strict;
use vars qw($VERSION);
-$VERSION = 1.01; # API-version . implementation-version
+$VERSION = 1.01; # API-version . implementation-version
use base qw(OpenSLX::MetaDB::DBI);
################################################################################
@@ -34,7 +34,7 @@ use OpenSLX::MetaDB::DBI 1;
sub new
{
my $class = shift;
- my $self = {};
+ my $self = {};
return bless $self, $class;
}
@@ -49,15 +49,14 @@ sub connect
}
my $user = (getpwuid($>))[0];
vlog(1, "trying to connect user <$user> to mysql-database <$dbSpec>");
- $self->{'dbh'} = DBI->connect("dbi:mysql:$dbSpec", $user, '',
- {PrintError => 0})
- or die _tr("Cannot connect to database <%s> (%s)",
- $dbSpec, $DBI::errstr);
+ $self->{'dbh'} =
+ DBI->connect("dbi:mysql:$dbSpec", $user, '', {PrintError => 0})
+ or die _tr("Cannot connect to database <%s> (%s)", $dbSpec, $DBI::errstr);
}
sub schemaConvertTypeDescrToNative
{
- my $self = shift;
+ my $self = shift;
my $typeDescr = lc(shift);
if ($typeDescr eq 'b') {
@@ -77,44 +76,40 @@ sub schemaConvertTypeDescrToNative
sub schemaRenameTable
{
- my $self = shift;
- my $oldTable = shift;
- my $newTable = shift;
+ my $self = shift;
+ my $oldTable = shift;
+ my $newTable = shift;
my $colDescrs = shift;
- my $isSubCmd = shift;
+ my $isSubCmd = shift;
my $dbh = $self->{'dbh'};
- vlog(1, "renaming table <$oldTable> to <$newTable>..." unless $isSubCmd);
+ vlog(1, "renaming table <$oldTable> to <$newTable>...") unless $isSubCmd;
my $sql = "ALTER TABLE $oldTable RENAME TO $newTable";
vlog(3, $sql);
$dbh->do($sql)
- or confess _tr(q[Can't rename table <%s> (%s)], $oldTable, $dbh->errstr);
+ or confess _tr(q[Can't rename table <%s> (%s)], $oldTable, $dbh->errstr);
}
sub schemaAddColumns
{
- my $self = shift;
- my $table = shift;
- my $newColDescrs = shift;
+ my $self = shift;
+ my $table = shift;
+ my $newColDescrs = shift;
my $newColDefaultVals = shift;
- my $colDescrs = shift;
- my $isSubCmd = shift;
+ my $colDescrs = shift;
+ my $isSubCmd = shift;
- my $dbh = $self->{'dbh'};
+ my $dbh = $self->{'dbh'};
my $newColNames = $self->_convertColDescrsToColNamesString($newColDescrs);
- vlog(1, "adding columns <$newColNames> to table <$table>" unless $isSubCmd);
- my $addClause
- = join ', ',
- map {
- "ADD COLUMN "
- .$self->_convertColDescrsToDBNativeString([$_]);
- }
- @$newColDescrs;
+ vlog(1, "adding columns <$newColNames> to table <$table>") unless $isSubCmd;
+ my $addClause = join ', ',
+ map { "ADD COLUMN " . $self->_convertColDescrsToDBNativeString([$_]); }
+ @$newColDescrs;
my $sql = "ALTER TABLE $table $addClause";
vlog(3, $sql);
$dbh->do($sql)
- or confess _tr(q[Can't add columns to table <%s> (%s)], $table,
- $dbh->errstr);
+ or confess _tr(q[Can't add columns to table <%s> (%s)], $table,
+ $dbh->errstr);
# if default values have been provided, we apply them now:
if (defined $newColDefaultVals) {
$self->_doUpdate($table, undef, $newColDefaultVals);
@@ -123,47 +118,46 @@ sub schemaAddColumns
sub schemaDropColumns
{
- my $self = shift;
- my $table = shift;
+ my $self = shift;
+ my $table = shift;
my $dropColNames = shift;
- my $colDescrs = shift;
- my $isSubCmd = shift;
+ my $colDescrs = shift;
+ my $isSubCmd = shift;
my $dbh = $self->{'dbh'};
my $dropColStr = join ', ', @$dropColNames;
- vlog(1, "dropping columns <$dropColStr> from table <$table>..."
- unless $isSubCmd);
+ vlog(1,
+ "dropping columns <$dropColStr> from table <$table>...")
+ unless $isSubCmd;
my $dropClause = join ', ', map { "DROP COLUMN $_" } @$dropColNames;
my $sql = "ALTER TABLE $table $dropClause";
vlog(3, $sql);
$dbh->do($sql)
- or confess _tr(q[Can't drop columns from table <%s> (%s)], $table,
- $dbh->errstr);
+ or confess _tr(q[Can't drop columns from table <%s> (%s)], $table,
+ $dbh->errstr);
}
sub schemaChangeColumns
{
- my $self = shift;
- my $table = shift;
+ my $self = shift;
+ my $table = shift;
my $colChanges = shift;
- my $colDescrs = shift;
- my $isSubCmd = shift;
+ my $colDescrs = shift;
+ my $isSubCmd = shift;
my $dbh = $self->{'dbh'};
my $changeColStr = join ', ', keys %$colChanges;
- vlog(1, "changing columns <$changeColStr> in table <$table>..."
- unless $isSubCmd);
- my $changeClause
- = join ', ',
- map {
- "CHANGE COLUMN $_ "
- .$self->_convertColDescrsToDBNativeString([$colChanges->{$_}]);
- }
- keys %$colChanges;
+ vlog(1, "changing columns <$changeColStr> in table <$table>...")
+ unless $isSubCmd;
+ my $changeClause = join ', ', map {
+ "CHANGE COLUMN $_ "
+ . $self->_convertColDescrsToDBNativeString([$colChanges->{$_}]);
+ }
+ keys %$colChanges;
my $sql = "ALTER TABLE $table $changeClause";
vlog(3, $sql);
$dbh->do($sql)
- or confess _tr(q[Can't change columns in table <%s> (%s)], $table,
- $dbh->errstr);
+ or confess _tr(q[Can't change columns in table <%s> (%s)], $table,
+ $dbh->errstr);
}
-1; \ No newline at end of file
+1;