Re: libpq

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Jim Michaels <jmichae3(at)yahoo(dot)com>
Cc: Scott Ribe <scott_ribe(at)killerbytes(dot)com>, pgsql general <pgsql-general(at)postgresql(dot)org>
Subject: Re: libpq
Date: 2009-08-10 20:17:59
Message-ID: b42b73150908101317p60c42c51x3a52866fa86ae2b1@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Aug 10, 2009 at 4:03 PM, Jim Michaels<jmichae3(at)yahoo(dot)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

In response to

  • Re: libpq at 2009-08-10 20:03:16 from Jim Michaels

Browse pgsql-general by date

  From Date Subject
Next Message Bill Moran 2009-08-10 20:57:37 Re: Postgres memory question
Previous Message Jim Michaels 2009-08-10 20:03:16 Re: libpq