Subject: values of column source in pg_settings

From: <[email-masked]>
Date: Wed, 10 Sep 2025 21:21:10 +0200

Hi all,

I could find several distinct values for column "source" in pg_settings
view. Examples of these values are: client, environment variable,
configuration file, default, database, override, session.

Are there other values?

The documentation doesn't mention any thing (Any way I didn't find).

In some of my databases, I have this:

postgres# select name, source from pg_settings where source like 'environ%';

      name       |        source       

-----------------+----------------------

max_stack_depth | environment variable

What is the meaning of 'environment_variable' here?

For the other listed values, I have "almost" got it but I don't see anything
for "environment variable".

Thanks in advance

Michel SALAIS

---

From: "David G. Johnston" <[email-masked]>
Date: Wed, 10 Sep 2025 12:39:09 -0700

On Wednesday, September 10, 2025, <[email-masked]> wrote:

> What is the meaning of ‘environment_variable’ here?
>
>
Operating system and/or shell variable.  Established in the parent
process’s environment before starting the server.

Think “home” and “path”.

David J.

---

From: "David G. Johnston" <[email-masked]>
Date: Wed, 10 Sep 2025 12:55:47 -0700

On Wednesday, September 10, 2025, <[email-masked]> wrote:
>
> I could find several distinct values for column “source” in pg_settings

https://github.com/postgres/postgres/blob/9016fa7e3bcde8ae4c3d63c707143af147486a10/src/backend/utils/misc/guc_tables.c#L667

David J.

---

From: Laurenz Albe <[email-masked]>
Date: Wed, 10 Sep 2025 23:35:45 +0200

On Wed, 2025-09-10 at 12:39 -0700, David G. Johnston wrote:
> Operating system and/or shell variable.  Established in the parent process’s environment before starting the server.

Almost.  "src/backend/utils/misc/guc.c" has this comment:

    /*
     * rlimit isn't exactly an "environment variable", but it behaves about
     * the same.  If we can identify the platform stack depth rlimit, increase
     * default stack depth setting up to whatever is safe (but at most 2MB).
     * Report the value's source as PGC_S_DYNAMIC_DEFAULT if it's 2MB, or as
     * PGC_S_ENV_VAR if it's reflecting the rlimit limit.
     */

Looking at the code, you seem to get "environment variable" if "ulimit -s"
is less than 2560 and "default" when it is bigger...

Yours,
Laurenz Albe