Re: Finding the bin path

From: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
To: Rob Jaeger <yogirob(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Finding the bin path
Date: 2009-12-28 00:30:44
Message-ID: 4B37FC34.5080605@postnewspapers.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 27/12/2009 2:12 PM, Rob Jaeger wrote:
> I was not clear in my initial question. I need to access the pg_dump.exe
> and pg_restore.exe files from within a c++ program. I can't execute
> pg_config.exe because it's in that bin that I'm seeking.
>
> I don't quite follow Greg Smith's reply of 'try guess based on "which
> postmaster"' (can you clarify?)
>
> But - I think I have found what I need! I can do a "SHOW
> data_directory;" and then from there I can snoop inside the
> postmaster.opts file to get the bin path. The question I have now is -
> is this method safe? Is this file present in all platform data
> directories. (I'm using Win7)

Oh, I just thought: what if your app isn't being run on the same host as
the database server? If the database server isn't even on the same kind
of platform? What if (as is quite likely) the data directory is locked
down so that user running your program does not have permission to
access it, even though it is on the same computer?

You need to provide preferences to let the user override the
auto-detected paths to pg_dump and pg_restore, so this can be handled.

I also suggest checking
%ProgramFiles%\PostgreSQL\<largest-version-number>\bin
for `pg_dump.exe' and `pg_restore.exe' if you can't access postmaster.opts.

You will need to detect and warn about the case where pg_dump is older
than the database being connected to. It's fine if it's newer, but it
should not be older.

--
Craig Ringer

In response to

Browse pgsql-general by date

  From Date Subject
Next Message donniehan 2009-12-28 02:59:27 Re: Why grantor is owner in this case?
Previous Message Craig Ringer 2009-12-28 00:25:54 Re: Finding the bin path