在哪里可以在Postgres中找到我的PLPython函数?

问题描述:

我已经在特定的模式中创建了一些函数,但是函数部分中什么都没有。.

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;


如果名称不符合模式,则该函数(就像其他对象一样)是在当前架构中创建的。您的当前架构由的当前设置定义。 search_path

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.

查看您当前的 search_path

SHOW search_path;

有很多方法可以设置 search_path ,更多与此相关的答案:

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%';

如果找不到任何内容,则此功能不存在于 this 数据库。也许您是错误地在另一个数据库中创建了它?

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