PQgetlength vs. octet_length()

From: Michael Clark <codingninja(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org, Greg Stark <gsstark(at)mit(dot)edu>
Subject: PQgetlength vs. octet_length()
Date: 2009-08-18 17:39:30
Message-ID: bf5d83510908181039i365a0a5ag88db6eba829de5d0@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

This thread was originally posted (incorrectly by me) to the hackers
mailing list. Moving the discussion to the gerenal.

Hi Greg,
That is what Pierre pointed out, and you are both right. I am using the
text mode.

But it seems pretty crazy that a 140meg bit of data goes to 1.3 gigs. Does
that seem a bit excessive?

I avoided the binary mode because that seemed to be rather confusing when
having to deal with non-bytea data types. The docs make it sound like
binary mode should be avoided because what you get back for a datetime
varies per platform.

Thanks,
Michael.

On Tue, Aug 18, 2009 at 12:15 PM, Greg Stark <gsstark(at)mit(dot)edu> wrote:

> On Tue, Aug 18, 2009 at 4:04 PM, Michael Clark<codingninja(at)gmail(dot)com>
> wrote:
> > Hello - am I in the wrong mailing list for this sort of problem? :-
>
> Probably but it's also a pretty technical point and you're programming
> in C so it's kind of borderline.
>
> If you're using text-mode then your datum that you're getting from
> libpq is a text representation of the datum. For bytea in released
> versions that means anything which isn't a printable ascii character
> will be octal encoded like \123. You can use PQunescapeBytea to
> unescape it.
>
> If you use binary encoding then you don't have to deal with that.
> Though I seem to recall there is still a gotcha you have to worry
> about if there are nul bytes in your datum. I don't recall exactly
> what that meant you had to do though.
>
> --
> greg
> http://mit.edu/~gsstark/resume.pdf
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Greg Stark 2009-08-18 17:48:57 Re: PQgetlength vs. octet_length()
Previous Message Randal L. Schwartz 2009-08-18 17:11:10 Re: Postgre RAISE NOTICE and PHP

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2009-08-18 17:43:52 Re: "make install" now tries to build the documentation
Previous Message Tom Lane 2009-08-18 17:34:17 Re: Another try at reducing repeated detoast work for PostGIS