Re: Error inserting data to bytea column in 8.4

From: Sam Mason <sam(at)samason(dot)me(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Error inserting data to bytea column in 8.4
Date: 2009-08-21 16:46:31
Message-ID: 20090821164630.GF5407@samason.me.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, Aug 21, 2009 at 06:54:51PM +0300, Andrus Moor wrote:
> create temp table test ( test bytea );
> insert into test values(E'\274')
>
> Causes error

Yup, you want another backslash in there, something like:

insert into test values(E'\\274');

The first backslash is expanded out during parsing the SQL into a
literal and the second during parsing of the literal into a bytea value.
You've got the following transformation going on:

SQL -> Literal -> Bytea value

The character values at each stage go like this:

SQL : 5c 5c 32 37 34
Literal : 5c 32 37 34 (because the '\\' has been unescaped to a '\')
Bytea : bc

> In 8.2 this script runs OK.

Maybe it's in SQL_ASCII encoding? NUL characters wouldn't work in your
8.2 database if that's the case.

--
Sam http://samason.me.uk/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2009-08-21 16:46:44 Re: Questions about encoding between two databases
Previous Message Greg Stark 2009-08-21 16:44:23 Re: Error inserting data to bytea column in 8.4