pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jeff Davis <pgsql@j-davis.com>
To: pgsql-interfaces@postgresql.org
Subject: ruby-postgres doesn't compile against 8.3!
Date: Fri, 07 Dec 2007 10:52:00 -0800
Message-ID: <1197053520.28804.122.camel@dogma.ljc.laika.com> (raw)

ruby-postgres is the most widely used PostgreSQL binding for ruby, but
it is unmaintained.

ruby-postgres-0.7.1.tar.gz     compiles fine
ruby-postgres-20051221.tar.gz  doesn't build
ruby-postgres-20060405.tar.gz  doesn't build
ruby-postgres-20060406.tar.gz  doesn't build

The same problems exist for the gems, versions 0.7.1.2006.04.05
0.7.1.2006.04.06.

This could mean that a lot (probably most) of ruby developers will have
a problem upgrading to PostgreSQL 8.3.

This is easy to fix (described below) but unfortunately ruby-postgres is
unmaintained.

I am working on my own fork of the project, ruby-pg, where I maintain
patches against ruby-postgres. It can be found here:

http://rubyforge.org/projects/ruby-pg

I backpatched it to stable, so you can check it out here:

svn co http://ruby-pg.rubyforge.org/svn/branches/stable

and I also released it as a file in the project.

The stable branch is very similar to snapshot 20060406 with a few
updates of my own. It *should* work fine with applications that work
with that snapshot release.

Most of my work on the project has gone into a branch called raw_libpq
(not currently stable), in which I'm rewriting a lot of the code. I'm
trying to streamline the module and make it a fairly thin wrapper around
libpq, that exposes *all* libpq functionality, with a ruby feel to it.
For instance, I raise exceptions on errors, but those exception objects
also hold the PGconn and PGresult objects so that you can access
detailed information if needed.

I would like this new branch to eventually replace the current ruby-
postgres, which does a lot of type conversion magic in C, which ends up
hiding libpq functionality and complicating the C code. Any type
conversion magic should really be done in ruby; there's no reason to do
it in C. I think that's a big part of the reason the current ruby-
postgres is so cluttered.

So, use ruby-pg instead. But please test it first, it hasn't received
much attention outside of my environment.

Regards,
	Jeff Davis

------------------------------------------------
PROBLEM DETAILS:

The snapshot releases of ruby-postgres do not compile against PostgreSQL
8.3. 

This is due to a rather strange sequence in postgres.c:

#ifndef HAVE_PG_ENCODING_TO_CHAR
#define pg_encoding_to_char(x) "SQL_ASCII"
#else
extern char* pg_encoding_to_char(int);
#endif

Apparently, PostgreSQL 8.2 and below did export a function called
pg_encoding_to_char, but did not declare it in any header. PostgreSQL
8.3 does declare it in the header, leading to a "conflicting types"
compilation error.

The quick fix I applied simply removes the declaration (the #else
clause) from postgres.c (which has been renamed to pg.c in my fork).
This leads to an "implicit declaration" compiler warning in 8.2 and
before, but no errors or warnings compiling against 8.3.





Message-ID: <1197053520.28804.122.camel@dogma.ljc.laika.com>
Permalink:  ../1197053520.28804.122.camel@dogma.ljc.laika.com/
Also on:    postgresql.org/message-id/1197053520.28804.122.camel@dogma.ljc.laika.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: pgsql@j-davis.com
  Subject: Re: ruby-postgres doesn't compile against 8.3!
  In-Reply-To: <1197053520.28804.122.camel@dogma.ljc.laika.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox