Re: Finding the bin path
| От | Craig Ringer |
|---|---|
| Тема | Re: Finding the bin path |
| Дата | |
| Msg-id | 4B37FC34.5080605@postnewspapers.com.au обсуждение исходный текст |
| Ответ на | Re: Finding the bin path (Rob Jaeger <yogirob@gmail.com>) |
| Список | 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
В списке pgsql-general по дате отправления: