1

I have a postgresql function where I want to use get user defined environment variable. Is there any default function to get the environment variable directly ?

1
  • Potentially useful related question. Commented Feb 6, 2022 at 15:15

2 Answers 2

1

Since a function is running on the database server, you would get the environment of the database server process (I wonder if that is what you want). This should be restricted to superusers (or perhaps the pg_execute_server_program role).

There is no standard function for this, probably because it is mostly useless, but it should be easy to write a function in C, PL/PerlU or PL/PythonU to do that.

Sign up to request clarification or add additional context in comments.

1 Comment

This SO answer gives access to the general server environment (not the database server process environment)
0

No there is no SQL function available to do this.

But it should not be complicate to do using https://www.postgresql.org/docs/12/xfunc-c.html.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.