如何在pg GEM的set_single_row_mode方法中编译?

时间:2015-02-17 16:35:08

标签: ruby postgresql gem amazon-redshift

我为gem install pg安装了PostgreSQL的Ruby GEM,但安装的PG::Connection类没有set_single_row_mode方法。

我在pg_connection.c中找到了以下行,这是GEM的源文件。

#ifdef HAVE_PQSETSINGLEROWMODE
    rb_define_method(rb_cPGconn, "set_single_row_mode", pgconn_set_single_row_mode, 0);
#endif

似乎必须使用-DHAVE_PQSETSINGLEROWMODE选项编译GEM的C文件。但是,我不知道如何将-DHAVE_PQSETSINGLEROWMODE传递给gem install pg的安装过程。

有人可以帮帮我吗?

// My environment.
$ ruby --version
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
$ psql --version
psql (PostgreSQL) 8.4.20

---编辑---

嗯。似乎单行模式仅在9.2版本之后可用。我尝试了以下方法:

$ gem fetch pg
$ gem unpack pg-0.18.1.gem
$ cd pg-0.18.1
$ ruby ext/extconf.rb
$ vi extconf.h
    # Added '#define HAVE_PQSETSINGLEROWMODE 1'
$ make

但显示如下的错误消息。

ext/pg_result.c: In function ‘pgresult_stream_each’:
ext/pg_result.c:1109: error: ‘PGRES_SINGLE_TUPLE’ undeclared (first use in this function)
ext/pg_result.c:1109: error: (Each undeclared identifier is reported only once
ext/pg_result.c:1109: error: for each function it appears in.)
ext/pg_result.c: In function ‘pgresult_stream_each_row’:
ext/pg_result.c:1172: error: ‘PGRES_SINGLE_TUPLE’ undeclared (first use in this function)

可以将本地计算机上的PostgreSQL库更新到9.2或更高版本,但我担心除非服务器(Redshift)支持单行模式,否则它将毫无意义。 Redshift是否支持它?

0 个答案:

没有答案