1

Scenario:

  1. I have a python function on disk somewhere.
  2. I compile a plpythonu function in pg server, which is referencing that python function from step 1 on disk.
  3. I change something in python function (from step 1).
  4. If I compile plpythonu function (from step 2), change done in step 3 does not take effect when calling from pg server.

Example of such functions can be seen in my other question: Python function hangs when called from within sql function

My assumptions (what this seems like to me):

  • PG server stores both the python function (step 1) code and plpythonu code somewhere at first compilation, where ?
  • It does not check again the linked function (step 1) when recompiling (step 4) the plpythonu function. Can this behavior be changed or affected somehow ?

If these assumptions are wrong, please also correct me and explain. Or even point me to documentation where this can be found, I have not succeeded in finding it yet.

1 Answer 1

1

PG server stores both the python function (step 1) code and plpythonu code somewhere at first compilation, where ?

The Python code for the pl/python function its self (but not any modules, libraries, etc) is stored in the pg_proc table in the database.

The compiled Python bytecode gets stored in the syscache in memory when it's first run by a given backend. It isn't updated after that if files on disk change. New connections will see the new code, old connections the existing code.

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

1 Comment

Thank you. Now that you said it, it makes sense. Being used to work with just the classic functions (plpgsql) where recompilation is visible instantly, in same connection, I intuitively did not think of any different approach in my testing (trying changes on new connection).

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.