错误:函数addgeometrycolumn不是唯一的 [英] ERROR: function addgeometrycolumn is not unique

查看:2784
本文介绍了错误:函数addgeometrycolumn不是唯一的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用以下函数:

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

但由于某种原因,它会给我以下错误:



注意:CREATE TABLE将为串行列vertices_tmp.id创建隐式序列vertices_tmp_id_seq
CONTEXT:SQL语句CREATE TABLE vertices_tmp EXECUTE语句
的第15行
PL / pgSQL函数assign_vertex_id错误:函数addgeometrycolumn(未知,未知,整数,未知,整数)不唯一
LINE 1:SELECT add b'b
$ b ^
提示:无法选择最佳候选函数。你可能需要添加显式类型转换
QUERY: SELECT addGeometryColumn('vertices_tmp','the_geom',4326,'POINT',2)
CONTEXT:PL / pgSQL函数assign_vertex_idEXECUTE语句的第24行

***** *****错误**********

错误:函数addgeometrycolumn(未知,未知,整数,未知,整数)不唯一
SQL状态:42725
提示:无法选择最佳候选函数。您可能需要添加显式类型转换。
上下文:EXECUTE语句中的PL / pgSQL函数assign_vertex_id第24行

我发现它必须是一个旧的PostGIS签名around.Infect当我运行以下命令:

 选择前缀,proargnames从pg_proc where proname ='addgeometrycolumn'; 

结果是这样的;

  pg_proc返回6行。 

具有返回空值或(null)值的列proargnames的三行

有人能帮我吗?这是与旧postgis签约有关吗?



感谢

解决方案

PostgreSQL支持 函数重载 。 / p>

使用重载的函数(就像你显然有的),只是文本文字调用(没有显式类型转换)可能是不明确的。



通常,添加显式 类型转换 修改参数文字可以解决问题。任意示例:

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

是不明确的:

  addGeometryColumn('vertices_tmp','the_geom',4326,'POINT',2)

请注意以下几点:




  • 所有未加引号的标识符在Postgres中转换为小写
    addGeometryColumn(...)实际上与 addgeometrycolumn(...) p>


  • 您可能需要模式限定函数名称,使其无歧义。 (也许您最近更改了 search_path 导致令人惊讶的结果。


  • 重载函数(非常见),添加类型转换以使调用明确。


  • 定义 参数默认值 可以使以前唯一的调用不明确。



I am trying to use the following function;

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

but for some reason it is giving me the following error;

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, unknown, integer) is not unique
LINE 1: SELECT addGeometryColumn('vertices_tmp', 'the_geom', 4326, '...
               ^
HINT:  Could not choose a best candidate function. You might need to add explicit type casts.
QUERY:  SELECT addGeometryColumn('vertices_tmp', 'the_geom', 4326, 'POINT', 2)
CONTEXT:  PL/pgSQL function "assign_vertex_id" line 24 at EXECUTE statement

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

ERROR: function addgeometrycolumn(unknown, unknown, integer, 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

Now from what I found it has to be something with old PostGIS signatures around.Infect when I ran The following command;

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

The result was this;

pg_proc returns 6 rows.

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

Can someone help me? Is it something that has to do with old postgis signitures? if so, how can I fix it?

Thanks

解决方案

PostgreSQL supports function overloading.

With overloaded functions (like you obviously have), a call with just text literals (and no explicit type casts) can be ambiguous.

Normally, adding explicit type casts to your parameters literals fixes the problem. Arbitrary example:

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

In your case, this call is ambiguous:

addGeometryColumn('vertices_tmp', 'the_geom', 4326, 'POINT', 2)

Be aware of these points:

  • All unquoted identifiers are cast to lower case in Postgres. addGeometryColumn(...) is effectively the same as addgeometrycolumn(...).

  • You may need to schema-qualify the function name to make it unambiguous. (Maybe you recently changed the search_path leading to a surprising result.

  • If you do indeed have overloaded functions (not uncommon), add type casts to make your calls unambiguous.

  • Defining parameter defaults for overloaded functions can make a previously unique call ambiguous.

这篇关于错误:函数addgeometrycolumn不是唯一的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆