On 26 October 2016 at 06:56, Chapman Flack <chap@anastigmatix.net> wrote:
> My main question is, what state do I need to examine at startup
> in order to distinguish these cases?
For loaded in shared_preload_libraries, test
IsPostmasterEnvironment && !IsUnderPostmaster
See src/backend/utils/init/globals.c
> Do I detect I'm in a BGW by
> a non-null MyBgworkerEntry?
Use IsBackgroundWorker, same place as above.
-- Craig Ringer http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training & Services