Обсуждение: BUG #4715: libpq `PQgetlength' return invalid field length.
The following bug has been logged online:
Bug reference: 4715
Logged by: VEN
Email address: bsditer@gmail.com
PostgreSQL version: 8.3.7
Operating system: FreeBSD
Description: libpq `PQgetlength' return invalid field length.
Details:
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.
"VEN" <bsditer@gmail.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