我正在尝试在应用程序中设置PgHero。我一直在跟踪错误
Started GET "/pghero" for 127.0.0.1 at 2014-09-09 12:35:41 +0530
Processing by PgHero::HomeController#index as HTML
Geokit is using the domain: localhost
(3.9ms) SELECT COUNT(*) AS count FROM pg_extension WHERE extname = 'pg_stat_statements'
CACHE (0.0ms) SELECT COUNT(*) AS count FROM pg_extension WHERE extname = 'pg_stat_statements'
(1.5ms) SELECT pid, state, application_name AS source, age(now(), xact_start) AS duration, waiting, query, xact_start AS started_at FROM pg_stat_activity WHERE query <> '<insufficient privilege>' AND state <> 'idle' AND pid <> pg_backend_pid() AND now() - query_start > interval '1 minutes' ORDER BY query_start DESC
PG::Error: ERROR: column "pid" does not exist
LINE 1: SELECT pid, state, application_name AS source, age(now(), xa...
^
: SELECT pid, state, application_name AS source, age(now(), xact_start) AS duration, waiting, query, xact_start AS started_at FROM pg_stat_activity WHERE query <> '<insufficient privilege>' AND state <> 'idle' AND pid <> pg_backend_pid() AND now() - query_start > interval '1 minutes' ORDER BY query_start DESC
postgresql.conf中
shared_preload_libraries = 'pg_stat_statements'
custom_variable_classes = 'pg_stat_statements'
pg_stat_statements.track = all
重启PG服务器后,我使用CREATE extension pg_stat_statements;
创建了扩展程序,然后使用SELECT pg_stat_statements_reset();
在我重新启动Rails服务器并点击/pghero
后出现同样的错误。
看起来像pgsql问题。我不擅长pg admin。有人可以告诉我解决方法吗?
答案 0 :(得分:3)
使用PostgreSQL 9.2,或查看是否有支持9.1的较旧的pghero版本。鉴于以下情况似乎没有:
支持PostgreSQL 9.2 +
就在README顶部附近。
错误说明:
pid
中的pg_stat_activity
列在PostgreSQL 9.1及更早版本上被命名为procpid
。这个工具似乎不检查PostgreSQL版本并使用适当的名称,它只是假设它正在与9.2或更新的对话。
因此,您可以向PgHero添加SELECT current_setting('server_version_num')
值的检查,以便切换到旧列名称,并根据需要提交拉取请求。
就我个人而言,我只是升级到9.3。