[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
SF.net SVN: ledger-smb:[4215] branches/1.3
- Subject: SF.net SVN: ledger-smb:[4215] branches/1.3
- From: ..hidden..
- Date: Thu, 15 Dec 2011 11:10:26 +0000
Revision: 4215
http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4215&view=rev
Author: einhverfr
Date: 2011-12-15 11:10:25 +0000 (Thu, 15 Dec 2011)
Log Message:
-----------
Check for contrib modules and error when creating or upgrading db
Modified Paths:
--------------
branches/1.3/Changelog
branches/1.3/LedgerSMB/Database.pm
branches/1.3/scripts/setup.pl
Modified: branches/1.3/Changelog
===================================================================
--- branches/1.3/Changelog 2011-12-15 08:38:23 UTC (rev 4214)
+++ branches/1.3/Changelog 2011-12-15 11:10:25 UTC (rev 4215)
@@ -7,6 +7,7 @@
* Fixes for POS cashier permissions. (Chris T)
* More Localization Fixes (Herman V)
* Customer/Vendor Search now shows records without credit accounts (Herman V)
+* Better error handling contrib modules not found (Chris T)
Changelog for 1.3.9
* More logging enhancements (Herman V)
Modified: branches/1.3/LedgerSMB/Database.pm
===================================================================
--- branches/1.3/LedgerSMB/Database.pm 2011-12-15 08:38:23 UTC (rev 4214)
+++ branches/1.3/LedgerSMB/Database.pm 2011-12-15 11:10:25 UTC (rev 4215)
@@ -351,6 +351,26 @@
return $retval;
}
+=item $db->server_version();
+
+Connects to the server and returns the version number in x.y.z format.
+
+=cut
+
+sub server_version {
+ my $self = shift @_;
+ my $creds = LedgerSMB::Auth->get_credentials();
+ my $dbh = DBI->connect(
+ "dbi:Pg:dbname=template1",
+ "$creds->{login}", "$creds->{password}", { AutoCommit => 0 }
+ );
+ my ($version) = $dbh->selectrow_array('SELECT version()');
+ $version =~ /(\d+\.\d+\.\d+)/;
+ my $retval = $1;
+ $dbh->disconnect;
+ return $retval;
+}
+
=item $db->create();
Creates a database and loads the contrib files. This is done from template0,
Modified: branches/1.3/scripts/setup.pl
===================================================================
--- branches/1.3/scripts/setup.pl 2011-12-15 08:38:23 UTC (rev 4214)
+++ branches/1.3/scripts/setup.pl 2011-12-15 11:10:25 UTC (rev 4215)
@@ -57,6 +57,25 @@
company_name => $request->{database},
password => $creds->{password}}
);
+ my $server_info = $database->server_version;
+ my @sv_info = split '.', $server_info;
+ if (($sv_info[0] > 9)or ($sv_info[0] == 9 and $sv_info[1] >= 1)){
+ if (! -f "$ENV{PG_CONTRIB_DIR}/tablefunc.control"){
+ $request->error($request->{_locale}->text(
+ 'Cannot find Contrib scripts in [_1].',
+ $ENV{PG_CONTRIB_DIR}
+ ));
+ }
+ } else {
+ if (! -f "$ENV{PG_CONTRIB_DIR}/tablefunc.sql"){
+ $request->error($request->{_locale}->text(
+ 'Cannot find Contrib scripts in [_1].',
+ $ENV{PG_CONTRIB_DIR}
+ ));
+
+ }
+ }
+
my $version_info = $database->get_info();
if(!$request->{dbh}){$request->{dbh}=$database->{dbh};}#allow upper stack to disconnect dbh when leaving
$request->{login_name} = $version_info->{username};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.