1

earthdistance modulePostgresql 9.6.5上的安装OSX El Capitan 10.11.6。PG 已经安装,正在运行。我创建了extension,它cube首先安装:

rich=# CREATE EXTENSION earthdistance CASCADE;
NOTICE:  installing required extension "cube"
CREATE EXTENSION

重新启动我的盒子。打开psql,选择合适的数据库,询问功能(\df):

    rich=# \df
                                                                                     List of functions
     Schema |        Name        | Result data type |           Argument data types            |  Type
    --------+--------------------+------------------+------------------------------------------+--------
     public | cube               | cube             | cube, double precision                   | normal
     public | cube               | cube             | cube, double precision, double precision | normal
     public | cube               | cube             | double precision                         | normal
     public | cube               | cube             | double precision, double precision       | normal
     public | cube               | cube             | double precision[]                       | normal
     public | cube               | cube             | double precision[], double precision[]   | normal
     public | cube_cmp           | integer          | cube, cube                               | normal
     public | cube_contained     | boolean          | cube, cube                               | normal
     public | cube_contains      | boolean          | cube, cube                               | normal
     public | cube_coord         | double precision | cube, integer                            | normal
     public | cube_coord_llur    | double precision | cube, integer                            | normal
     public | cube_dim           | integer          | cube                                     | normal
     public | cube_distance      | double precision | cube, cube                               | normal
     public | cube_enlarge       | cube             | cube, double precision, integer          | normal
     public | cube_eq            | boolean          | cube, cube                               | normal
     public | cube_ge            | boolean          | cube, cube                               | normal
     public | cube_gt            | boolean          | cube, cube                               | normal
     public | cube_in            | cube             | cstring                                  | normal
     public | cube_inter         | cube             | cube, cube                               | normal
     public | cube_is_point      | boolean          | cube                                     | normal
     public | cube_le            | boolean          | cube, cube                               | normal
     public | cube_ll_coord      | double precision | cube, integer                            | normal
     public | cube_lt            | boolean          | cube, cube                               | normal
     public | cube_ne            | boolean          | cube, cube                               | normal
     public | cube_out           | cstring          | cube                                     | normal
     public | cube_overlap       | boolean          | cube, cube                               | normal
     public | cube_size          | double precision | cube                                     | normal
     public | cube_subset        | cube             | cube, integer[]                          | normal
     public | cube_union         | cube             | cube, cube                               | normal
     public | cube_ur_coord      | double precision | cube, integer                            | normal
     public | distance_chebyshev | double precision | cube, cube                               | normal
     public | distance_taxicab   | double precision | cube, cube                               | normal
     public | earth              | double precision |                                          | normal
     public | earth_box          | cube             | earth, double precision                  | normal
     public | earth_distance     | double precision | earth, earth                             | normal
     public | g_cube_compress    | internal         | internal                                 | normal
     public | g_cube_consistent  | boolean          | internal, cube, smallint, oid, internal  | normal
     public | g_cube_decompress  | internal         | internal                                 | normal
     public | g_cube_distance    | double precision | internal, cube, smallint, oid, internal  | normal
     public | g_cube_penalty     | internal         | internal, internal, internal             | normal
     public | g_cube_picksplit   | internal         | internal, internal                       | normal
     public | g_cube_same        | internal         | cube, cube, internal                     | normal
     public | g_cube_union       | cube             | internal, internal                       | normal
     public | gc_to_sec          | double precision | double precision                         | normal
     public | geo_distance       | double precision | point, point                             | normal
     public | latitude           | double precision | earth                                    | normal
     public | ll_to_earth        | earth            | double precision, double precision       | normal
     public | longitude          | double precision | earth                                    | normal
     public | sec_to_gc          | double precision | double precision                         | normal
    (49 rows)

所以看起来extension加载得很好。作为测试,我使用以下简单命令:

SELECT point(43.664828,-79.341620) <@> point(44.418390, -80.096013)

psql我没有收到任何反馈。在Postico 1.3.2(PG客户端)中,我收到以下错误:

ERROR:  operator does not exist: point <@> point
LINE 1: SELECT point(43.664828,-79.341620) <@> point(44.418390, -80....
                                           ^
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.

根据反馈,该模块似乎未安装。我希望这可以正常工作,因为extension安装正确,并且我使用了正确的语法earth_distance function。我尝试了其他具有相同类型错误的查询,表明无法识别运算符。

我究竟做错了什么?

4

1 回答 1

1

解决了。事实证明,您必须选择database适用extension于特定的database. 只是进入psql是在应用程序级别内,所以CREATE EXTENSION earthdistance CASCADE显然仍然对任何数据库视而不见。因此psql,使用psql <dbname>语法输入,然后将CREATE EXTENSION earthdistance CASCADE其应用于您选择的数据库。

于 2018-04-07T16:05:14.817 回答