Re: PQgetlength vs. octet_length() - Mailing list pgsql-hackers

From Michael Clark
Subject Re: PQgetlength vs. octet_length()
Date
Msg-id bf5d83510908180804y760c2f64o4e9417929da63c85@mail.gmail.com
Whole thread Raw
In response to PQgetlength vs. octet_length()  (Michael Clark <codingninja@gmail.com>)
Responses Re: PQgetlength vs. octet_length()
Re: PQgetlength vs. octet_length()
List pgsql-hackers
Hello - am I in the wrong mailing list for this sort of problem? :-/

Thanks,
Michael.


On Mon, Aug 17, 2009 at 6:28 PM, Michael Clark <codingninja@gmail.com> wrote:
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.


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Lazy Snapshots
Next
From: "Kevin Grittner"
Date:
Subject: Re: PQgetlength vs. octet_length()