加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

database – ERROR:function addgeometrycolumn不是唯一的

发布时间:2020-12-13 16:04:47 所属栏目:百科 来源:网络整理
导读:我正在尝试使用以下功能; 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 stat
我正在尝试使用以下功能;

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可能会使之前唯一的调用不明确.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读