PQgetlength vs. octet_length()

From: Michael Clark <codingninja(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: PQgetlength vs. octet_length()
Date: 2009-08-17 22:28:21
Message-ID: bf5d83510908171528q2ab6ecc6md8d3d08f2c4615f3@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Hello everyone.
Having a weird issue.

I have a value inserted into a bytea column, which is about 137megs in size.

If I use octet_length() to check the size of the column for this specific
row I get this:
TestDB=# SELECT octet_length(rawdata) FROM LargeData;
octet_length
--------------
143721188

When fetching the row through the C API, and I use PQgetlength() on the
column of the row in question I get:
(gdb) p (int)PQgetlength(result, rowIndex, i)
$3 = 544453159

I am wondering if I am lacking knowledge that explains why these values are
different, or if something fishy is going on.

What led me to investigating this is that fetching this row in a C
application is causing a failure. My programs memory usage balloons to 1.3
gigs after executing this:
const char *valC = PQgetvalue(result, rowIndex, i);

Am I doing something wrong, or is there some ideas what I should investigate
next?
This seems quite puzzling to me.

Thanks in advance for any help/insight offered,
Michael.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message NTPT 2009-08-17 22:34:44 Re: Rapid Seek Devices (feature request)
Previous Message Bryan Murphy 2009-08-17 21:32:09 Re: ERROR: attempted to delete invisible tuple

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2009-08-17 22:55:52 Re: explain root element for auto-explain
Previous Message Peter Eisentraut 2009-08-17 22:15:44 Re: Alpha 1 release notes