微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

database – ERROR:function addgeometrycolumn不是唯一的

我正在尝试使用以下功能;

SELECT Assign_vertex_id('ways',0.00001,'the_geom','gid')

但由于某种原因,它给了我以下错误;

NOTICE:  CREATE TABLE will create implicit sequence "vertices_tmp_id_seq" for serial column "vertices_tmp.id"
CONTEXT:  sql statement "CREATE TABLE vertices_tmp (id serial)"
PL/pgsql function "assign_vertex_id" line 15 at EXECUTE statement
ERROR:  function addgeometrycolumn(unkNown,unkNown,integer,integer) is not unique
LINE 1: SELECT addGeometryColumn('vertices_tmp',4326,'...
               ^
HINT:  Could not choose a best candidate function. You might need to add explicit type casts.
QUERY:  SELECT addGeometryColumn('vertices_tmp','POINT',2)
CONTEXT:  PL/pgsql function "assign_vertex_id" line 24 at EXECUTE statement

********** Error **********

ERROR: function addgeometrycolumn(unkNown,integer) is not unique
sql state: 42725
Hint: Could not choose a best candidate function. You might need to add explicit type casts.
Context: PL/pgsql function "assign_vertex_id" line 24 at EXECUTE statement

现在从我发现它必须是旧的PostGIS签名周围.当我运行以下命令;

select proname,proargnames from pg_proc where proname = 'addgeometrycolumn';

结果是这样的;

pg_proc returns 6 rows.

Three rows with column proargnames  returning a blank or (null) value

有人能帮我吗?这与旧的postgis签名有什么关系吗?如果是的话,我该如何解决

谢谢

解决方法

Postgresql支持 function overloading.

对于重载函数(就像你显然那样),只调用文本文字(并且没有显式类型转换)的调用可能是不明确的.

通常,将明确的type casts添加到参数文字可以解决问题.任意的例子:

SELECT my_fuc('foo'::text,0.001::numeric,123::int);

在您的情况下,此调用是不明确的:

addGeometryColumn('vertices_tmp',2)

请注意以下几点:

>所有未加引号的标识符都在Postgres中转换为小写.
addGeometryColumn(…)实际上与addgeometrycolumn(…)相同.
>您可能需要对函数名称进行模式限定,以使其明确无误. (也许你最近更改了search_path导致了一个令人惊讶的结果.
>如果确实有重载函数(并非罕见),请添加类型转换以使您的调用明确无误.
>为重载函数定义parameter defaults可能会使之前唯一的调用不明确.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐