pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: libpq environment variables in the server
Date: Mon, 21 Jan 2019 11:42:16 +0100
Message-ID: <33383613-690e-6f1b-d5ba-4957ff40f6ce@2ndquadrant.com> (raw)

When libpq is loaded in the server (libpqwalreceiver, dblink,
postgres_fdw), it may use libpq environment variables set in the
postmaster environment for connection parameter defaults.  I have
noticed that this has some confusing effects in our test suites.  I
wonder if this is a good idea in general.

For example, the TAP test infrastructure sets PGAPPNAME to allow
identifying clients in the server log.  But this environment variable is
also inherited by temporary servers started with pg_ctl and is then in
turn used by libpqwalreceiver as the application_name for connecting to
remote servers where it then shows up in pg_stat_replication and is
relevant for things like synchronous_standby_names.

Also, the pg_rewind tests appear to rely implicitly on PGHOST and PGPORT
being set in the server environment to find the other node via
primary_conninfo.  That is easy to fix, but it shows that this kind of
thing can creep in unintentionally.

I was thinking that maybe we should clear all libpq environment
variables in the server, or perhaps have a mode in libpq to ignore all
environment variables.  Then again, maybe setting something like
PGSSLMODE globally in the server could be useful, so just removing
everything might not be the right answer.

Maybe pg_ctl should have some functionality to clear the environment,
and maybe there could be a facility in postgresql.conf to set
environment variables.

Thoughts?

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services




view thread (10+ messages)  latest in thread

Message-ID: <33383613-690e-6f1b-d5ba-4957ff40f6ce@2ndquadrant.com>
Permalink:  ../33383613-690e-6f1b-d5ba-4957ff40f6ce@2ndquadrant.com/
Also on:    postgresql.org/message-id/33383613-690e-6f1b-d5ba-4957ff40f6ce@2ndquadrant.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: peter.eisentraut@2ndquadrant.com
  Subject: Re: libpq environment variables in the server
  In-Reply-To: <33383613-690e-6f1b-d5ba-4957ff40f6ce@2ndquadrant.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox