dtqf81594 2013-02-21 00:49
浏览 100
已采纳

2个Postgres实例的结果不同

I run a Postgres 9.2.2 server locally using the Postgres App with ssmode=disable. All the tables are created like they should be and SELECT queries work as expected.

When I create a Postgres instance on Heroku (the server is 9.1.6 according to psql, ssmode=require), everything works fine, except that a query returns no results, where the local postgres instance does.

The specific query is

SELECT * FROM "captcha" WHERE "cid" = $1 LIMIT $2

and cid/$1 is of type character varying(20).

When connecting to the remote instance via psql and executing the query manually, the rows were returned as expected. I just don't understand what could possibly cause that different behavior.

The primary suspect would be the driver that I use bmizerany/pq, but could there be other error sources for this behavior?

UPDATE:

I tried it with a plain query, same result: No rows in result set

SELECT * FROM "captcha" WHERE "cid" = 'JQRPm6qRpYukXCiPUpHZ' LIMIT 1

UPDATE 2:

It has something todo with the bytea field, the following snippet illustrates the problem when executing on those 2 PG versions https://gist.github.com/eaigner/5004468

  • 写回答

2条回答 默认 最新

  • dsfdsf8888 2013-02-21 13:00
    关注

    The problem is, that Heroku uses a non-default bytea_output. So a workaround to deal with this was

    SET bytea_output = 'hex';
    

    before running the query

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable