Search code examples
postgresqlplpython

Where I can find my PLPython functions in Postgres?


I've created some functions in a specific schema, but the "Functions" section has nothing inside..

I create functions like this example:

CREATE FUNCTION pymax (a integer, b integer)
  RETURNS integer
AS $$
  if a > b:
  return a
return b
$$ LANGUAGE plpythonu;

Solution

  • If the name is not schema-qualified, a function (like other objects) is created in your current schema. Your current schema is defined by the current setting of search_path.

    To see your current search_path:

    SHOW search_path;
    

    There are a number of ways to set the search_path, more in this related answer:
    How does the search_path influence identifier resolution and the "current schema"

    To find out whether any function with a similar name exists in your database:

    SELECT n.nspname, p.proname, pg_get_function_arguments(p.oid) As args
    FROM   pg_proc p
    JOIN   pg_namespace n ON n.oid = p.pronamespace
    WHERE  p.proname ILIKE '%pymax%';
    

    If that doesn't find anything, the functions doesn't exist in this database. Maybe you created it in another db by mistake?