pg

URL
http://rubyforge.org/projects/ruby-pg
Author(s)
Yukihiro Matsumoto, Eiji Matsumoto, Noboru Saitou, Dave Lee, and Jeff Davis
Summary
Ruby extension library providing an API to PostgreSQL

Add your comment ↓

Comments

pg is Working
for Arguppy (Mac OSX, 11 months ago)

pg (0.9.0) is Working
for senotrusov (GNU/Linux, about 1 year ago)

0.9.0 have that patch applied

pg (0.8.0 (patched)) is Working
for Pete Deffendol (Mac OSX, over 2 years ago)

Works for me with patched gem from senotrusov.

pg (0.8.0.1) is Working
for Vidmantas (GNU/Linux, over 2 years ago)

Thanks senotrusov, had the same issue with encodings but your patch fixes it! Everything now runs smoothly

pg is Working
for senotrusov (GNU/Linux, over 2 years ago)

0.8.0 returns all string in ASCII-8BIT encoding, even if you expect it to be UTF-8.

This patch solves the problem:
http://rubyforge.org/tracker/index.php?func=detail&aid=25931&group_id=3214&atid=12398

I've applied it against current trunk and packaged a gem:

wget http://dl.dropbox.com/u/2947472/pg-0.8.0.1.gem; gem install pg-0.8.0.1.gem

pg (0.8.0) is Working
for Darren Boyd (Mac OSX, over 2 years ago)

My problem shown below appears to be related to RVM, which was how I installed Ruby 1.9.

After completely removing the rvm gem, and the ruby 1.9 it had installed and reinstalling everything, the pg gem installed no problem.

pg (0.8.0) is Working
for Berin Loritsch (GNU/Linux, over 2 years ago)

Make sure you have the libpq-dev package installed in your Linux distro. For example:

sudo apt-get install libpq-dev

Once you do that, the typical install will work:

gem install pg

pg (0.8.0) is Failing
for Darren Boyd (Mac OSX, over 2 years ago)

It won't install on Snow Leopard...

$ sudo env ARCHFLAGS='i386' gem install pg -- --with-pgsql-dir=/opt/local/lib/postgresql84/
Password:
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.

/Users/dboyd/.rvm/ruby-1.9.1-p243/bin/ruby extconf.rb
checking for main() in -lpq... yes
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for PQconnectionUsedPassword()... no
checking for PQisthreadsafe()... no
checking for PQprepare()... no
checking for PQexecParams()... no
checking for PQescapeString()... no
checking for PQescapeStringConn()... no
checking for lo_create()... no
checking for pg_encoding_to_char()... no
checking for PQsetClientEncoding()... no
creating Makefile

make
gcc -I. -I/Users/dboyd/.rvm/ruby-1.9.1-p243/include/ruby-1.9.1/i386-darwin10.2.0 -I/Users/dboyd/.rvm/ruby-1.9.1-p243/include/ruby-1.9.1/ruby/backward -I/Users/dboyd/.rvm/ruby-1.9.1-p243/include/ruby-1.9.1 -I. -DHAVE_LIBPQ_FE_H -DHAVE_LIBPQ_LIBPQ_FS_H -I/opt/local/include/postgresql84 -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch i386 -O2 -g -Wall -Wno-parentheses -pipe -fno-common -o compat.o -c compat.c
In file included from compat.c:16:
compat.h:38:2: error: #error PostgreSQL client version too old, requires 7.3 or later.
In file included from compat.c:16:
compat.h:69: error: conflicting types for ‘PQconnectionNeedsPassword’
/opt/local/include/postgresql84/libpq-fe.h:293: error: previous declaration of ‘PQconnectionNeedsPassword’ was here
compat.h:70: error: conflicting types for ‘PQconnectionUsedPassword’
/opt/local/include/postgresql84/libpq-fe.h:294: error: previous declaration of ‘PQconnectionUsedPassword’ was here
compat.h:121: error: redefinition of typedef ‘PQnoticeReceiver’
/opt/local/include/postgresql84/libpq-fe.h:144: error: previous declaration of ‘PQnoticeReceiver’ was here
compat.h:125: error: redeclaration of enumerator ‘PQERRORS_TERSE’
/opt/local/include/postgresql84/libpq-fe.h:105: error: previous definition of ‘PQERRORS_TERSE’ was here
compat.h:126: error: redeclaration of enumerator ‘PQERRORS_DEFAULT’
/opt/local/include/postgresql84/libpq-fe.h:106: error: previous definition of ‘PQERRORS_DEFAULT’ was here
compat.h:128: error: redeclaration of enumerator ‘PQERRORS_VERBOSE’
/opt/local/include/postgresql84/libpq-fe.h:108: error: previous definition of ‘PQERRORS_VERBOSE’ was here
compat.h:128: error: conflicting types for ‘PGVerbosity’
/opt/local/include/postgresql84/libpq-fe.h:108: error: previous declaration of ‘PGVerbosity’ was here
compat.h:132: error: redeclaration of enumerator ‘PQTRANS_IDLE’
/opt/local/include/postgresql84/libpq-fe.h:96: error: previous definition of ‘PQTRANS_IDLE’ was here
compat.h:133: error: redeclaration of enumerator ‘PQTRANS_ACTIVE’
/opt/local/include/postgresql84/libpq-fe.h:97: error: previous definition of ‘PQTRANS_ACTIVE’ was here
compat.h:134: error: redeclaration of enumerator ‘PQTRANS_INTRANS’
/opt/local/include/postgresql84/libpq-fe.h:98: error: previous definition of ‘PQTRANS_INTRANS’ was here
compat.h:135: error: redeclaration of enumerator ‘PQTRANS_INERROR’
/opt/local/include/postgresql84/libpq-fe.h:99: error: previous definition of ‘PQTRANS_INERROR’ was here
compat.h:137: error: redeclaration of enumerator ‘PQTRANS_UNKNOWN’
/opt/local/include/postgresql84/libpq-fe.h:101: error: previous definition of ‘PQTRANS_UNKNOWN’ was here
compat.h:137: error: conflicting types for ‘PGTransactionStatusType’
/opt/local/include/postgresql84/libpq-fe.h:101: error: previous declaration of ‘PGTransactionStatusType’ was here
compat.h:142: error: conflicting types for ‘PQtransactionStatus’
/opt/local/include/postgresql84/libpq-fe.h:285: error: previous declaration of ‘PQtransactionStatus’ was here
compat.h:143: error: conflicting types for ‘PQparameterStatus’
/opt/local/include/postgresql84/libpq-fe.h:287: error: previous declaration of ‘PQparameterStatus’ was here
compat.h:157: error: conflicting types for ‘PQsetErrorVerbosity’
/opt/local/include/postgresql84/libpq-fe.h:309: error: previous declaration of ‘PQsetErrorVerbosity’ was here
compat.h:169:2: error: #error unsupported postgresql version, requires 7.3 or later.
compat.c: In function ‘PQsetClientEncoding’:
compat.c:21: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
compat.c:28: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
compat.c:35: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
compat.c:43: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
compat.c:49: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
compat.c:55: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
compat.c:61: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
compat.c:67: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
compat.c:73: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
compat.c:79: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
compat.c:85: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
compat.c:93: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
compat.c:102: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
compat.c:109: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
compat.c:115: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
compat.c:125: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
compat.c:131: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
compat.c:137: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
compat.c:143: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
compat.c:151: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
compat.c:159: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
compat.c:167: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
compat.c:173: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
compat.c:179: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
compat.c:185: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
compat.c:191: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
compat.c:197: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
compat.c:203: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
compat.c:209: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
compat.c:215: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
compat.c:221: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
compat.c:230: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
compat.c:237: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
compat.c:280: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
compat.c:339: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
compat.c:386: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
compat.c:465: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
compat.c:539: error: old-style parameter declarations in prototyped function definition
compat.c:539: error: expected ‘{’ at end of input
make: *** [compat.o] Error 1

pg (0.8.0) is Working
for George M. Harkin (GNU/Linux, over 2 years ago)

Works great so far.

pg (0.8.0) is Working
for Joshua Partogi (GNU/Linux, over 2 years ago)

Works fine.

pg (0.8.0) is Working
for Felipe Rodrigues (GNU/Linux, over 2 years ago)

(Ubuntu 9.0.4 + Ruby 1.9.1) Works

pg (0.8.0) is Working
for Sascha Konietzke (Mac OSX, over 2 years ago)

Returns all strings ascii encoded. Applying the instructions on http://pauldoerwald.ca/2009/6/15/ruby-1-9-rails-and-unicode-nightmares helped to fix this.

pg (0.8.0) is Working
for mgutz (Mac OSX, over 2 years ago)

PostgreSQL 8.3.7

ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-darwin9.7.0]

seems to be working so far

pg (0.8.0) is Working
for Clay Shentrup (GNU/Linux, over 2 years ago)

MAKE SURE YOU CHANGE YOUR ADAPTER FROM POSTGRES TO POSTGRESQL!!

pg (ruby 1.9.1p129 (2009-05-12 revision 23412) [x86_64-linux]) is Working
for Clay Shentrup (GNU/Linux, over 2 years ago)

using the ruby1.9 package on ubuntu 9.04 "jaunty".

pg (0.8) is Working
for Dylan Markow (Mac OSX, over 2 years ago)

"gem install pg" works great for me.

pg (0.8.0) is Failing
for Jakub Kuźma (GNU/Linux, over 2 years ago)

Strings are always returned with ASCII-8BIT encoding.

pg (0.8.0) is Working
for Mike Bradford (GNU/Linux, over 2 years ago)

installed using gem install pg

pg (0.8.0) is Working
for Marcus Wyatt (Mac OSX, over 2 years ago)

No problems. Installed using gem install.

pg (0.8.0) is Working
for nofxx (GNU/Linux, over 3 years ago)

Need to download the gem manually.

pg (0.8.0) is Working
for Jason LaRiviere (Mac OSX, over 3 years ago)

Finally! All joy out of the box. Macports ruby and postgres installs.

pg (0.8.0) is Working
for Pistos (GNU/Linux, over 3 years ago)

Works for me, as tested via the test suite of DBI.

pg (0.7.9.2008.10.13) is Failing
for Pistos (GNU/Linux, over 3 years ago)

Fails as-is, but this patched version compiles and works for me: http://github.com/maxime/ruby-pg-for-ruby-1.9.1rc2/tree/master

pg is Failing
for Jim Hranicky (Mac OSX, over 3 years ago)

This can be fixed with a one-liner for pg.c:

ruby -pi -e 'gsub(/RARRAY\((\S+?)\)->len/) { "RARRAY_LEN(#{$1})" }' pg.c

Still some warnings, but it compiles and works.

pg (0.7.9.2008.10.13) is Failing
for Don Park (GNU/Linux, over 3 years ago)

it fails for me too. the same error in a different gem was fixed for 1.9 in this post: http://writequit.org/blog/?p=247

perhaps it can be applied to pg.

pg (0.7.9.2008.10.13) is Failing
for Gavin Kistner (Mac OSX, over 3 years ago)

No glory with 1.9.1p0:

pg.c: In function ‘parse_connect_args’:
pg.c:233: warning: unused variable ‘error’
pg.c:231: warning: unused variable ‘conn’
pg.c: In function ‘pgconn_exec’:
pg.c:960: error: ‘struct RArray’ has no member named ‘len’
pg.c: In function ‘pgconn_prepare’:
pg.c:1065: error: ‘struct RArray’ has no member named ‘len’
pg.c: In function ‘pgconn_exec_prepared’:
pg.c:1151: error: ‘struct RArray’ has no member named ‘len’
pg.c: In function ‘pgconn_send_query’:
pg.c:1491: error: ‘struct RArray’ has no member named ‘len’
pg.c: In function ‘pgconn_send_prepare’:
pg.c:1595: error: ‘struct RArray’ has no member named ‘len’
pg.c: In function ‘pgconn_send_query_prepared’:
pg.c:1684: error: ‘struct RArray’ has no member named ‘len’
pg.c: In function ‘pgconn_trace’:
pg.c:2161: warning: implicit declaration of function ‘dup’
pg.c:2141: warning: unused variable ‘fp’
make: *** [pg.o] Error 1

Add your comment




Yes No