在Windows上使用PostgreSQL 11。
cube和earthdistance都由pg_available_extensions安装和验证。
重新启动PostgreSQL。
42883错误:操作符不存在:点<@>点。
设置:
CREATE EXTENSION IF NOT EXISTS cube SCHEMA temp;
CREATE EXTENSION IF NOT EXISTS earthdistance SCHEMA temp;尝试了以下代码来自叠加流
create table temp.lat_lon (
city varchar(50) primary key,
lat float8 not null,
lon float8 not null
);
insert into temp.lat_lon values
('London, GB', 51.67234320, 0.14787970),
('New York, NY', 40.91524130, -73.7002720);
select
(
(select point(lon,lat) from temp.lat_lon where city = 'London, GB') <@>
(select point(lon,lat) from temp.lat_lon where city = 'New York, NY')
) as distance_miles;抛出:
42883错误:操作符不存在:点<@>点。
已安装扩展并重新启动Postgres。
select * from pg_available_extensions where name IN ('cube', 'earthdistance');
cube 1.4 data type for multidimensional cubes
earthdistance 1.1 calculate great-circle distances on the surface of the Earth这是因为Windows上的PostgreSQL v11吗?是的,Lat/Long的顺序是正确的(long是第一位)。
有关: schema /搜索路径的更新:
SELECT extname, extnamespace::regnamespace FROM pg_extension
WHERE extname IN ('cube', 'earthdistance');
cube temp
earthdistance tempSHOW search_path;
temp注意:我CREATE EXTENSION hstore SCHMEA temp;并可以使用hstore及其操作符。所以似乎并不是所有的扩展。
发布于 2019-03-06 01:26:02
可能的解释:您在当前search_path中缺少的模式中安装了扩展。
诊断:
SELECT extname, extnamespace::regnamespace FROM pg_extension
WHERE extname IN ('cube', 'earthdistance');
SHOW search_path;当前search_path中的扩展模式是吗?如果没有,这是你的解释。要么安装到不同的架构,要么调整search_path。
和:
SELECT oprnamespace::regnamespace, oprleft::regtype, oprname, oprright::regtype
FROM pg_operator
WHERE oprname = '<@>';相关信息:
https://dba.stackexchange.com/questions/231411
复制相似问题