if (pset.db && PQparameterStatus(pset.db, "in_hot_standby"))
Seems transaction_read_only might be a more useful thing to examine? That's the side-effect, if you will, that people really care about when in hot standby mode (and of course, we can get into TRO other ways).