考虑以下查询
select ...
(
select ... from
(
select * from trips where deviceid=ANY('{22}'::int[]) order by startts
) as sortedtrips group by deviceid
) as V
right join devices D on D.deviceid=V.deviceid
left join mostrecent M on M.deviceid=D.deviceid
left join v_auto_odometer DD on DD.deviceid=M.deviceid
where D.deviceid=ANY('{22}'::int[])
它曾经在我的作品中作为登台环境运行良好。 突然,此查询不再在分段中运行,而是在生产中运行。
罪魁祸首似乎是最后一个"其中"条款
... where D.deviceid=ANY('{22}'::int[])
导致
ERROR: invalid input syntax for integer: ""
********** Error **********
ERROR: invalid input syntax for integer: ""
SQL state: 22P02
将此更改为
D.deviceid=22
解决了这个问题(但请注意,查询中仍然提供了一个非常相似的where子句,并且不会出现问题。)
我完全不知道发生了什么,以及为什么查询不再有效。它似乎与特定的postgres环境有关,后者在颠覆中有所不同
staging:PostgreSQL 9.3.5
production:PostgreSQL 9.3.4
我真的需要使用ANY语句(因为上面的查询只是一个例子。真正的查询使用了一个实际的id数组。
有人可以帮忙吗?
答案 0 :(得分:0)
感谢大家的评论。
最后,问题与登台和制作之间的数据不匹配有关。特定列中的空值导致暂存问题。
Postgres没有帮我解决具体的错误消息。