Smokes your problems, coughs fresh air.

PostgreSQL back-end for Ruby on Rails confusion

I just need to add a quick summary of what postgres back-end tool our Ruby on Rails application uses, and how we’ve configured it, because it’s quite confusing…

There are four postgresql backends:

  • ruby-postgres. This version is no longer maintained. This is the version we used when the project began.
  • postgres-pr. This is a pure ruby implementation, which is not interesting for us.
  • postgres. This is the continuation of the unmaintained ruby-postgres. This version includes such fixes as that it can be compiled against libpg-8.3.
  • ruby-pg. It is said that this one is now the official postgres back-end, but when I install it, the application still can’t find “postgres”.

Because the aforementioned article states that the pg extension is unstable, “postgres” seems to be what we should use. The article states that it is included in the ruby-pg package, but it doesn’t work when I install it, so I had to install “postgres”. I uninstalled ruby-pg, because it doesn’t seem necessary.

To continue, we once used a patched postgresql adapter, because we needed more accurate timestamps (the standard connection adapter rounded everything off to whole seconds), but if I recall correctly, this patch was only necessary on the connection adapter in Rails, not the back-end. We never commissioned the functionality that required this, so this existed only in the workdir of one of the devs.

As a final note; on our production server, we have a version of ruby-postgres installed in /usr/local. I can’t remember why…


  1. halfgaar

    Bigsmoke, if you have anything to add, please do…

  2. Rowan Rodrik

    O, the joy of documenting… I’m really glad we’re getting into the habit of logging more of what we encounter. Who cares if it’s of no use to the most of the rest of the world…

    I’d try to answer any of those questions, if only I could remember…

  3. Keith Basil

    How are you guys handling server replication and content synchronization with PostgreSQL?

  4. halfgaar

    We don’t. We only have one server…

  5. Rowan Rodrik

    Turns out we were using the manually compiled version in /usr/local. We noticed this while upgrading a very messy Debian testing to Debian Lenny. To recompile this version successfully against libpq-8.3 instead of 8.2, I had to remove the #else clause from the following bit in postgres.c

    #define pg_encoding_to_char(x) "SQL_ASCII"
    extern char* pg_encoding_to_char(int);

    I got this patch from a forum post by one of the guys who forked this code, but we got none of these other projects to work with our version of ActiveRecord (the one in Rails 1.2.6).

© 2024 BigSmoke

Theme by Anders NorenUp ↑