summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2006-10-25 05:53:58 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2006-10-25 05:53:58 +0000
commit52635d70697fbe0c165c742cd9e9f5e316ff09a5 (patch)
tree610dcaac7104efad9575059fcf243f1e8012fbb8
parent59073acdfc952eac35adb1088b2a97b60bfd991a (diff)
Database upgrades now use psql
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@302 4979c152-3d1c-0410-bac9-87ea11338e46
-rw-r--r--Changelog1
-rwxr-xr-xLedgerSMB/User.pm47
2 files changed, 4 insertions, 44 deletions
diff --git a/Changelog b/Changelog
index c57d0714..35804709 100644
--- a/Changelog
+++ b/Changelog
@@ -3,6 +3,7 @@ Changelog for LedgerSMB 1.2.0
Database:
* Added script to configure Slony replication (Chris Browne)
* Added defined primary keys to all tables (Chris T)
+* Database upgrades now use psql (Chris T)
Security:
* Added whitelist of allowed directories to file editor (Seneca)
diff --git a/LedgerSMB/User.pm b/LedgerSMB/User.pm
index 0b769a46..47cdad04 100755
--- a/LedgerSMB/User.pm
+++ b/LedgerSMB/User.pm
@@ -388,50 +388,9 @@ sub process_query {
return unless (-f $filename);
open(FH, "$filename") or $form->error("$filename : $!\n");
- my $query = "";
- my $loop = 0;
- my $sth;
-
-
- while (<FH>) {
-
- if ($loop && /^--\s*end\s*(procedure|function|trigger)/i) {
- $loop = 0;
-
- $sth = $dbh->prepare($query);
- $sth->execute || $form->dberror($query);
- $sth->finish;
-
- $query = "";
- next;
- }
-
- if ($loop || /^create *(or replace)? *(procedure|function|trigger)/i) {
- $loop = 1;
- next if /^(--.*|\s+)$/;
-
- $query .= $_;
- next;
- }
-
- # don't add comments or empty lines
- next if /^(--.*|\s+)$/;
-
- # anything else, add to query
- $query .= $_;
-
- if (/;\s*$/) {
- # strip ;... Oracle doesn't like it
- $query =~ s/;\s*$//;
- $query =~ s/\\'/''/g;
-
- $sth = $dbh->prepare($query);
- $sth->execute || $form->dberror($query);
- $sth->finish;
-
- $query = "";
- }
-
+ open(PSQL, "| psql") or $form->error("psql : $! \n");
+ while (<FH>){
+ print PSQL $_;
}
close FH;