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.

Community
  • 1
  • 1
M_M
  • 93
  • 6

1 Answers1

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.

Craig Ringer
  • 307,061
  • 76
  • 688
  • 778
  • 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). – M_M Dec 02 '15 at 10:03