Search Postgresql Archives

Re: Finding the bin path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux