Re: BUG #4715: libpq `PQgetlength' return invalid field length.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "VEN" <bsditer(at)gmail(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4715: libpq `PQgetlength' return invalid field length.
Date: 2009-03-18 12:41:01
Message-ID: 8381.1237380061@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"VEN" <bsditer(at)gmail(dot)com> writes:
> Database have below table:
> CREATE TABLE TEST {
> NUM BIGINT NOT NULL DEFAULT 0
> };

> EXEC "SELECT NUM FROM TEST LIMIT 1"
> PQgetlength return valid length (sizeof(int64)), it's ok.

> but
> EXEC "SELECT SUM(NUM)::BIGINT FROM TEST"
> or
> EXEC "SELECT SUM(NUM) FROM TEST"

> PQgetlength already return zero.

I see no bug here. For such a case (with no rows in the table)
SUM() is defined to return NULL, and PQgetvalue() is defined to
return an empty string for a null, and PQgetlength() is defined
to return the length of whatever PQgetvalue() returns.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Heikki Linnakangas 2009-03-18 14:55:27 Re: BUG #4714: Unicode Big5 Conversion
Previous Message Heikki Linnakangas 2009-03-18 09:44:43 Re: BUG #4714: Unicode Big5 Conversion