Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

"postgres" module needs work, author gone, patch included

5 views
Skip to first unread message

Jeff Davis

unread,
Jan 19, 2007, 8:38:47 PM1/19/07
to
The "postgres" module is old and it's been a long time since there's
been a release. The module has the following problems:

* uses PQescapeString() and PQescapeBytea(), both of which are long-
since deprecated, and provides no interface to the newer functions
(which have been around for a long time).

* uses wrong quoting routine to quote connection string arguments.

* release version doesn't provide any interface to PQexecParams().

* snapshot introduces some ruby array to PG array type-awareness, but
it's broken

I tried to contact the maintainer, da...@cherryville.org, but got no
response. I tried to contact the previous maintainer,
nob...@zetabits.com, and got a bounce.

I wrote a patch that makes the following changes to the module from the
snapshot version:

* added instance methods "escape" and "escape_bytea" which use
PQescapeStringConn() and PQescapeByteaConn(). The class methods by the
same names should be deprecated, but I left them in for compatibility.

* added the instance method "unescape_bytea", which is the same as the
class method by the same name. This didn't strictly need to be done, but
I did this for consistency with "escape_bytea" which is now an instance
method.

* added an instance and class method "quote_ident" to quote identifiers.

* wrote separate quoting routine (not exported) to properly quote
connection string arguments according to the documented quoting rules
for the connection string arguments. The old code did this by using the
same routine as for quoting values passed to a SQL string, which is
wrong.

* removed code that tried to convert ruby arrays into postgresql arrays.
It was broken (in the quote method, did not actually quote the array),
and the code should be substantially refactored to better enable more
intelligent type awareness from ruby to postgresql. I could reintroduce
this if people care about more type awareness.

I'd like to do some more serious refactoring, but I just wanted to get
some feedback first. Who uses this module, and what do you think about
my changes? How old of a client library do we want to support? The
current module uses ugly #define directives to bolt on support for
ancient versions of libpq, is this necessary?

Should I fork and put a project on RAA, or should I try to take over the
current "postgres" module?

Regards,
Jeff Davis

ruby-postgres.diff

Marc Heiler

unread,
Jan 19, 2007, 8:42:13 PM1/19/07
to
> I'd like to do some more serious refactoring, but I just wanted to get
> some feedback first.

Actually I tried to use it but somehow I didnt even finished compiling.
After looking at some info in it (Readme, the website) I decided to
skip this and stick to sqlite or mysql instead, perhaps.

Nice to see I didnt happen to be the only one that tried it :)

--
Posted via http://www.ruby-forum.com/.

Daniel Berger

unread,
Jan 19, 2007, 9:28:41 PM1/19/07
to

Jeff Davis wrote:
> The "postgres" module is old and it's been a long time since there's
> been a release. The module has the following problems:

<snip>

I talked to Dave Lee a while back and he indicated to me that a new
release was imminent. Mind you, I think that was a few months ago now,
so I'm not sure what happened. I'll try to contact him again and let
you know what happens.

Worst case scenario is I give you admin rights on the DBI project, and
we bundle the postgres driver with dbd-postgres directly.

Regards,

Dan

Tom Copeland

unread,
Jan 19, 2007, 9:43:19 PM1/19/07
to
On Sat, 2007-01-20 at 10:38 +0900, Jeff Davis wrote:

> I'd like to do some more serious refactoring, but I just wanted to get
> some feedback first. Who uses this module, and what do you think about
> my changes? How old of a client library do we want to support? The
> current module uses ugly #define directives to bolt on support for
> ancient versions of libpq, is this necessary?

I use it with PostgreSQL 8.2 and I've been pretty happy with it.
Haven't looked at any of the code, though. Sounds like you're bringing
it up to speed, which is great!

Yours,

Tom

Jeff Davis

unread,
Jan 20, 2007, 1:32:22 AM1/20/07
to
Marc Heiler wrote:
>> I'd like to do some more serious refactoring, but I just wanted to get
>> some feedback first.
>
> Actually I tried to use it but somehow I didnt even finished compiling.
> After looking at some info in it (Readme, the website) I decided to
> skip this and stick to sqlite or mysql instead, perhaps.
>
> Nice to see I didnt happen to be the only one that tried it :)
>

Ouch, you avoided postgresql because the ruby driver was that bad?

Can you please send me the info in the form of a bug report? That is,
include platform, versions, exact errors, etc. If you're having a
problem, a lot of people are, and I'd like to make postgresql a
first-class supported database in Ruby.

Regards,
Jeff Davis

Jeff Davis

unread,
Jan 20, 2007, 1:39:10 AM1/20/07
to

Please let me know if you get more information from Dave Lee.

Also let me know if ruby-dbi needs anything in particular from the driver.

Regards,
Jeff Davis

Jason LaRiviere

unread,
Jan 20, 2007, 3:14:41 PM1/20/07
to
Jeff Davis wrote:
> The "postgres" module is old and it's been a long time since there's
> been a release. The module has the following problems:

I use postgres on openbsd and netbsd without incident, but recently got
a macbook, where it does nothing. I'm using postgres-pr there, but there
are differences - notably between #escape and #quote. It is less than
ideal to account for them.

I haven't looked into the problem too deeply (read: at all) yet, but I'd
be glad to help with any effort to improve the postgres lib.

--
GPG/PGP key ID: 0x3A410DBD | http://pgp.mit.edu
7B3F 4505 7D9A 7FDE 83C9 52C2 4909 59B9 3A41 0DBD

Jeff Davis

unread,
Jan 20, 2007, 5:54:25 PM1/20/07
to
Jason LaRiviere wrote:
> I haven't looked into the problem too deeply (read: at all) yet, but I'd
> be glad to help with any effort to improve the postgres lib.
>

What would help me the most is to do one or more of the following:

(1) Test my patch against the snapshot version available from the
'postgres' module website, see if it fixes the problem
(2) If the problem is not fixed, send a more detailed report. If it is
fixed, let me know.
(3) Let me know of any extra things you'd like the driver to do, or any
behaviors you'd like to change. In particular what do you expect from
"escape" and "quote".

I don't know anything about making the module portable to OS X, but it
doesn't sound hard to do after I have some more details.

I'll keep hacking away, and I'll set up a site and an SVN repo, and I'll
make an announcement. It sounds like there's demand. Thanks for your input.

Regards,
Jeff Davis

Jason LaRiviere

unread,
Jan 20, 2007, 8:03:43 PM1/20/07
to
Jeff Davis wrote:
> What would help me the most is to do one or more of the following:
>
> (1) Test my patch against the snapshot version available from the
> 'postgres' module website, see if it fixes the problem
> (2) If the problem is not fixed, send a more detailed report. If it is
> fixed, let me know.
> (3) Let me know of any extra things you'd like the driver to do, or any
> behaviors you'd like to change. In particular what do you expect from
> "escape" and "quote".
>
> I don't know anything about making the module portable to OS X, but it
> doesn't sound hard to do after I have some more details.
>
> I'll keep hacking away, and I'll set up a site and an SVN repo, and I'll
> make an announcement. It sounds like there's demand. Thanks for your input.

I'm on board; a couple notes:
http://ruby.scripting.ca/postgres/ appears to be the homepage for the
project, and offers a snapshot dated 2005.12.21.

http://rubyforge.org/frs/download.php/9553 offers a snapshot dated
2006.04.06. This package forms the basis for the openbsd port, and will
be the one I will be patching against and testing. If all is well, I
will submit an updated port for openbsd including your patch.

The project homepage also specifies that `this library works with
PostgreSQL 6.4-8.1', and the macbook is running postgresql 8.2.1. This
may, or may not have something to do with it's refusal to work. :p

I will confirm this with an update to pgsql 8.2.1 on the openbsd machines
and get back to you.

Kevin Williams

unread,
Jan 20, 2007, 9:17:53 PM1/20/07
to
I use the postgres driver everywhere - Windows, Linux, Mac, production,
dev. It seems to work from ActiveRecord, but that's about all I can tell
you. Sometimes the gem install deletes the binary after creating it, but
I just go into that directory and 'make' it again.

Long story short, yes someone uses it.

Jason LaRiviere

unread,
Jan 20, 2007, 9:19:35 PM1/20/07
to
Jason LaRiviere wrote:
> I'm on board; a couple notes:
> http://ruby.scripting.ca/postgres/ appears to be the homepage for the
> project, and offers a snapshot dated 2005.12.21.
>
> http://rubyforge.org/frs/download.php/9553 offers a snapshot dated
> 2006.04.06. This package forms the basis for the openbsd port, and will
> be the one I will be patching against and testing. If all is well, I
> will submit an updated port for openbsd including your patch.
>
> The project homepage also specifies that `this library works with
> PostgreSQL 6.4-8.1', and the macbook is running postgresql 8.2.1. This
> may, or may not have something to do with it's refusal to work. :p
>
> I will confirm this with an update to pgsql 8.2.1 on the openbsd machines
> and get back to you.

Find attatched a diff that applies cleanly to the 2006.04.06 source.
Also, all teh cool kids are using unified diffs. :p

It builds just fine. Further testing is pending...

ruby-postgres.diff

Jason LaRiviere

unread,
Jan 20, 2007, 10:27:06 PM1/20/07
to
Kevin Williams wrote:
> Sometimes the gem install deletes the binary after creating it, but
> I just go into that directory and 'make' it again.

Ha. I've never come across that before, but indeed that is what happened
with the gem install on os x. I'm now off postgres-pr and back on
ruby-postgres all around.

0 new messages