Re: PQgetlength vs. octet_length()

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

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 Andre Lopes 2009-08-18 16:57:24 Postgre RAISE NOTICE and PHP
Previous Message Daniel Verite 2009-08-18 15:25:25 Re: comparing NEW and OLD (any good this way?)

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2009-08-18 16:17:53 Re: "make install" now tries to build the documentation
Previous Message Andrew Dunstan 2009-08-18 16:10:01 Re: "make install" now tries to build the documentation