Re: LIBPQ Question

From: Igor Shevchenko <igor(at)carcass(dot)ath(dot)cx>
To: Tomasz Myrta <jasiek(at)klaster(dot)net>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: LIBPQ Question
Date: 2003-10-27 07:25:25
Message-ID: 200310270925.26056.igor@carcass.ath.cx
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

On Monday 27 October 2003 09:15, Tomasz Myrta wrote:
> Dnia 2003-10-27 00:08, Użytkownik creid napisał:
> > Problem: Assigning a COUNT(*) result into an integer variable in my C
> > program consistently fails except when I assign the same result to a char
> > variable. I can only assume that the internal data type the COUNT
> > function uses is integer.
> >
> > Can anyone help put me in the proper mindset so I may deal with this,
> > seemingly simple issue, to resolution.
> >
> > I need the integer result to to help me satisfy a dynamic memory
> > requirement... COUNT(*) result will tell me how many rows of data I need
> > to malloc and I cannot perform a math operation on a char variable.
>
> All libpq results are strings.
> some_int_value=atoi(PQgetvalue(...))

Not true anymore with protocol v3, which added the binary format. Text format
is still the default.

> Anyway why do you need count(*) ? When you retrieve your rows, you can
> always check how many are them using PQntuples(...) and then malloc your
> memory tables.
>
> Regards,
> Tomasz Myrta
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: the planner will ignore your desire to choose an index scan if your
> joining column's datatypes do not match

--
Best regards,
Igor Shevchenko

In response to

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Anis W. Nugroho 2003-10-27 16:52:42 Re: LIBPQ
Previous Message Tomasz Myrta 2003-10-27 07:15:40 Re: LIBPQ Question