diff options
author | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2006-11-15 05:06:11 +0000 |
---|---|---|
committer | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2006-11-15 05:06:11 +0000 |
commit | 7cb3213ba1a2f90b5c025c716092ede5038c6ca8 (patch) | |
tree | 7e1e546efce30395ceada63250fc278c9c16ab6f | |
parent | 6bd5fc956b7dad86070e6b8da7520c373624e4f4 (diff) |
Added psql error detection
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@615 4979c152-3d1c-0410-bac9-87ea11338e46
-rwxr-xr-x | LedgerSMB/User.pm | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/LedgerSMB/User.pm b/LedgerSMB/User.pm index 1427ad53..ee870d7c 100755 --- a/LedgerSMB/User.pm +++ b/LedgerSMB/User.pm @@ -453,20 +453,14 @@ sub process_query { return unless (-f $filename); - open(FH, "$filename") or $form->error(__FILE__.':'.__LINE__.": $filename : $!\n"); $ENV{PGPASSWORD} = $form->{dbpasswd}; $ENV{PGUSER} = $form->{dbuser}; $ENV{PGDATABASE} = $form->{db}; - open(PSQL, "| psql") or $form->error(__FILE__.':'.__LINE__.": psql : $! \n"); - print PSQL "\\o spool/log \n"; - print PSQL "BEGIN;\n"; - while (<FH>){ - print PSQL $_; + $results = `psql -f $filename 2>&1`; + if ($? or ($results =~ /error/i)){ + $form->error($results); } - print PSQL "COMMIT;\n"; - close FH; - } |