Skip to content

Commit

Permalink
If db superuser is now omitted, will try to create the dataset without
Browse files Browse the repository at this point in the history
creating the database or language first.  This can be useful in shared hosting
environments. 


git-svn-id: svn://svn.code.sf.net/p/ledger-smb/code/trunk@119 4979c152-3d1c-0410-bac9-87ea11338e46
  • Loading branch information
einhverfr committed Sep 19, 2006
1 parent d4674f0 commit 4791fbe
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
1 change: 1 addition & 0 deletions Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Database
* Protection against duplicate transaction id's.
* Added foreign key constraint to acc_trans.chart_id
* Database backups now use pg_dump
* Database creation routines now attempt to add plpgsql to the db if not there.

Security
* One is required to change the admin password when it is blank (on first login etc).
Expand Down
28 changes: 16 additions & 12 deletions LedgerSMB/User.pm
Original file line number Diff line number Diff line change
Expand Up @@ -308,15 +308,17 @@ sub dbcreate {
&dbconnect_vars($form, $form->{dbdefault});
# The below line connects to Template1 or another template file in order
# to create the db. One must disconnect and reconnect later.
my $superdbh = DBI->connect(
$form->{dbconnect},
if ($form->{dbsuperuser}){
my $superdbh = DBI->connect(
$form->{dbconnect},
$form->{dbsuperuser},
$form->{dbsuperpasswd}
) or $form->dberror;
my $query = qq|$dbcreate{$form->{dbdriver}}|;
$superdbh->do($query) || $form->dberror($query);
) or $form->dberror;
my $query = qq|$dbcreate{$form->{dbdriver}}|;
$superdbh->do($query) || $form->dberror($query);

$superdbh->disconnect;
$superdbh->disconnect;
}
#Reassign for the work below

&dbconnect_vars($form, $form->{db});
Expand All @@ -326,19 +328,21 @@ sub dbcreate {
$form->{dbuser},
$form->{dbpasswd}
) or $form->dberror;
my $superdbh = DBI->connect(
if ($form->{dbsuperuser}){
my $superdbh = DBI->connect(
$form->{dbconnect},
$form->{dbsuperuser},
$form->{dbsuperpasswd}
) or $form->dberror;
) or $form->dberror;
# JD: We need to check for plpgsql, if it isn't there create it, if we can't error
# Good chance I will have to do this twice as I get used to the way the code is
# structured

my %langcreate = ( 'Pg' => qq|CREATE LANGUAGE plpgsql|);
my $query = qq|$langcreate{$form->{dbdriver}}|;
$superdbh->do($query);

my %langcreate = ( 'Pg' => qq|CREATE LANGUAGE plpgsql|);
my $query = qq|$langcreate{$form->{dbdriver}}|;
$superdbh->do($query);
$superdbh->disconnect;
}
# create the tables
my $dbdriver = ($form->{dbdriver} =~ /Pg/) ? 'Pg' : $form->{dbdriver};

Expand Down

0 comments on commit 4791fbe

Please sign in to comment.