datamapper / do

DataObjects
147 stars 74 forks source link

Possible to compile do_postgres with only libpq? #22

Closed luislavena closed 11 years ago

luislavena commented 12 years ago

Hello,

I'm trying to build binaries for libpq, the supposed to be client library of postgres that is small enough to be used on non-postgres installations.

Problem is that do_postgres depends on postgres.h headers that are not present when only using libpq interface.

It is possible change do_postgres to only use libpq interface option?

Thank you.

dkubb commented 12 years ago

@dbussink what do you think?

dbussink commented 12 years ago

Right now it's not possible, because we need postgres.h for mapping error code to the appropriate exceptions. At the time I wrote that I search for another way to do that, but the only way was to use the postgres.h header for it.

@luislavena Do you know of other ways to get the Postgres error codes with just using the libpq interface?

deepfryed commented 12 years ago

from utils/elog.h


 56 /* macros for representing SQLSTATE strings compactly */
 57 #define PGSIXBIT(ch)    (((ch) - '0') & 0x3F)
 58 #define PGUNSIXBIT(val) (((val) & 0x3F) + '0')
 59 
 60 #define MAKE_SQLSTATE(ch1,ch2,ch3,ch4,ch5)  \
 61     (PGSIXBIT(ch1) + (PGSIXBIT(ch2) << 6) + (PGSIXBIT(ch3) << 12) + \
 62      (PGSIXBIT(ch4) << 18) + (PGSIXBIT(ch5) << 24))
dbussink commented 11 years ago

If I look at the packaging of libpq-dev for example in Debian:

http://packages.debian.org/squeeze/amd64/libpq-dev/filelist

Here the postgres.h header and some additional ones that we use are also part of this list. I guess this is what usually ends up being the list that people require for writing a client. Therefore closing this issue, since I don't see DO being able to change this anytime soon.