Lists: | pgsql-interfaces |
---|
From: | "creid" <creid(at)netbcg(dot)com> |
---|---|
To: | <pgsql-interfaces(at)postgresql(dot)org> |
Subject: | LIBPQ Question |
Date: | 2003-10-26 23:08:49 |
Message-ID: | ILECJKPFOLBAGINIFFFBMECECAAA.creid@netbcg.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-interfaces |
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.
Thanks
Cliff
From: | "(dot)"(at)babolo(dot)ru |
---|---|
To: | creid <creid(at)netbcg(dot)com> |
Cc: | pgsql-interfaces(at)postgresql(dot)org |
Subject: | Re: LIBPQ Question |
Date: | 2003-10-27 00:38:09 |
Message-ID: | 1067215089.757529.1657.nullmailer@cicuta.babolo.ru |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-interfaces |
> 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.
As far as I remember count() has bigint result
From: | Tomasz Myrta <jasiek(at)klaster(dot)net> |
---|---|
To: | creid <creid(at)netbcg(dot)com> |
Cc: | pgsql-interfaces(at)postgresql(dot)org |
Subject: | Re: LIBPQ Question |
Date: | 2003-10-27 07:15:40 |
Message-ID: | 3F9CC61C.8010103@klaster.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | Postg토토 핫SQL : Postg토토 |
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(...))
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
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 |
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
From: | "creid" <creid(at)netbcg(dot)com> |
---|---|
To: | <pgsql-interfaces(at)postgresql(dot)org> |
Subject: | PGEASY QUESTION |
Date: | 2003-10-30 15:11:23 |
Message-ID: | ILECJKPFOLBAGINIFFFBMEDHCAAA.creid@netbcg.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-interfaces |
I am experimenting with LIBPGEASY
Problem: When I access a "varchar(30)" column using "DECLARE.....FOR SELECT column from schema.table WHERE pkey='KEY'"
When I fetch to a declared variable to return to a calling procedure, my program does a (segmentation error) unless I declare the char variable to some much higher value than it is seemingly necessary. Moreover, the problem does not occur when I manipulate the result in the called procedure. In fact, in my experimentation, I have noticed that I can declare a char variable array less than what the result is and it still works. The crash only occurs in the calling procedure.
What might I be doing wrong?
Thanks
Cliff
-----Original Message-----
From: pgsql-interfaces-owner(at)postgresql(dot)org
[mailto:pgsql-interfaces-owner(at)postgresql(dot)org]On Behalf Of Igor
Shevchenko
Sent: Monday, October 27, 2003 2:25 AM
To: Tomasz Myrta
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: [INTERFACES] LIBPQ Question
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
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
message can get through to the mailing list cleanly