Re: libpq

From: Jim Michaels <jmichae3(at)yahoo(dot)com>
To: Scott Ribe <scott_ribe(at)killerbytes(dot)com>, pgsql general <pgsql-general(at)postgresql(dot)org>
Subject: Re: libpq
Date: 2009-08-10 20:03:16
Message-ID: 461407.25372.qm@web34306.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

these are straight dll calls as outlined in Using Run-Time Dynamic Linking (Windows)
that's why they look funny. it is impossible to link VC++ .lib files with mingw(gcc) .a libraries.

yeah, I just found the PQntuples bug myself too, and got the program finished. thank you for the tips on using libpq, I may still need to implement those.

I didn't remember seeing anywhere in the docs that you were supposed to check for pqr==NULL, I wish they would document that in PQexec. must be a documentation bug. There is no mention of return values! http://www.postgresql.org/docs/8.4/interactive/libpq-exec.html

still doesn't solve the need for MingW *.a libraries version of libpq. I wouldn't have had to rewrite the whole thing for this to work with mingw. The DLL's are VC++/MinGW compatible, but the .lib files are not.

Jim Michaels
jmichae3(at)yahoo(dot)com
http://JesusnJim.com

________________________________
From: Scott Ribe <scott_ribe(at)killerbytes(dot)com>
To: Jim Michaels <jmichae3(at)yahoo(dot)com>; pgsql general <pgsql-general(at)postgresql(dot)org>
Sent: Sunday, August 9, 2009 9:16:34 AM
Subject: Re: [GENERAL] libpq

That's pretty confused C code. The most obvious problem is that you're not
calling the Pqntuples function; you're just examining the value of a
variable called ntuples, when you haven't set that value after calling
Pqexec (and maybe have never set it).

Take it step by step, and check error returns at each step--including
connecting to the database, and of course especially check errors after
calling PQexec--first checking that pgr is not null, then if not null using
the PQresultStatus, PQresStatus, PQresultErroMessage functions, otherwise
the PQstatus, PQerrorMessage functions.

Then if you still have problems, post more complete code that includes
important things like connecting to the database, and declarations &
assignments to key variables.

Also, what is this "(function)(args)" stuff? Normally, the PQ functions are
plain C functions, called as "function(args)". Do you really have some setup
where you have function pointer variables and your compiler requires that
outdated syntax? Or is this more basic C confusion?

--
Scott Ribe
scott_ribe(at)killerbytes(dot)com
http://www.killerbytes.com/
(303) 722-0567 voice

In response to

  • Re: libpq at 2009-08-09 16:16:34 from Scott Ribe

Responses

  • Re: libpq at 2009-08-10 20:17:59 from Merlin Moncure
  • Re: libpq at 2009-08-10 22:20:51 from Scott Ribe

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2009-08-10 20:17:59 Re: libpq
Previous Message Tim Hart 2009-08-10 18:02:06 Re: PQstatus does not seem to work