Re: libpq - Mailing list pgsql-general

From Merlin Moncure
Subject Re: libpq
Date
Msg-id b42b73150908101317p60c42c51x3a52866fa86ae2b1@mail.gmail.com
Whole thread Raw
In response to Re: libpq  (Jim Michaels <jmichae3@yahoo.com>)
List pgsql-general
On Mon, Aug 10, 2009 at 4:03 PM, Jim Michaels<jmichae3@yahoo.com> wrote:
> 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.

that is not why they look funny...they look funny because you made them so :-).

function pointers mapped at runtime via dynamic linking do  not need
to be wrapped with ().

val = (PQgetvalue)(pgr,index, 0);strcpy(row.firstname    , val);

could be re-written as:
strcpy(row.firstname, PQgetvalue(pgr,index, 0));

...which is still asking for trouble...you're not checking the length
and blindly copying your results into the receiving structure.

Also, you are mixing 'SELECT *' with assumed column positions.  This
is IMO very bad style. either use explicit column list in your select
statement or pull your data from the result using name instead of
position.

Also, use a compiler which tells you about uninitialized variables,
don't top post, and avoid html emails when posting to public lists
:-).

merlin

pgsql-general by date:

Previous
From: Jim Michaels
Date:
Subject: Re: libpq
Next
From: Bill Moran
Date:
Subject: Re: Postgres memory question