I'm not using command line vacuumdb.
My code deletes rows older than a certain date and then to recover the space does:
my $retVal = $dbh->do('vacuum verbose analyse my_table').
The do() method behaves as documented, returning a -1. If it errored (returned undef), I'd be able to pick up the error message from $dbh->errstr but because it was successful, there is no way to get the result of the command. I'm not sure if this is a DBI or DBD-Pg or a Postgresql issue.
The "do" method documentation always says "for use with non-select statements" but I suppose it still expects sql, rather than some goofy postgresql thing.
I'm currently running with the kludgey redirect of stderr but I don't feel clean about it.!
Thanks.
Anders
On Friday, October 25, 2002, at 08:46 AM, William McKee wrote:
On 24 Oct 2002 at 13:41, Anders Bogdan wrote:Kind of a newbie-ish question I guess. I could not find a good answer inHi Anders,
the faq or the Perl DBI book.
Since noone else has taken a stab, I'll jump in and see if I can offer an
alternative. However, my first thought would have been to do what you have
done and I cannot see any problem with that. What concerns you about
redirecting STDERR for a couple of lines?
If you're using the command-line tool vacuumdb, one option would be to use
an open command that redirects the output from STDERR to STDOUT. In bash,
I think it would be something like the following:
open(FILE, "vacuumdb 2>&1|");
while (<FILE>) { $output .= $_ }
close FILE;
See Recipe 16.1 in _Perl Cookbook_ or open for more info. Also, what about
running the vacuum via an SQL statement? Would the output come back
through DBI or is this how you are doing it already?
Good luck,
William
--
Lead Developer
Knowmad Services Inc. || Internet Applications & Database Integration
http://www.knowmad.com
