pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joe Conway <mail@joeconway.com>
To: Iklódi Lajos <il@mithrandir.hu>
Cc: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Re: How to insert zeros into a bytea column?
Date: Sat, 23 Feb 2002 13:04:07 -0800
Message-ID: <3C7803C7.4090207@joeconway.com> (raw)
References: <3C77F89F.68BFA64@mithrandir.hu>

Iklódi Lajos wrote:
> Hello,
> 
> I'm inserting data into a bytea colunm which can contain zero bytes. It
> seems that insertion stops at first zero:
> 
> gkk=# CREATE TABLE test (id int4, adat bytea);
> CREATE
> gkk=# insert into test (id, adat) values (1, '\100\200\000\100\200');
> INSERT 164175 1
> gkk=# select * from test;
>  id | adat
> ----+-------
>   1 | @\200
> (1 row)

You should double up on the backslashes:

test=# CREATE TABLE test (id int4, adat bytea);
CREATE
test=# insert into test (id, adat) values (1, '\\100\\200\\000\\100\\200');
INSERT 82097 1
test=# select * from test;
  id |      adat
----+----------------
   1 | @\200\000@\200
(1 row)

See for more info:
http://www.us.postgresql.org/users-lounge/docs/7.2/postgres/datatype-binary.html

HTH,
Joe




view thread (2+ messages)

Message-ID: <3C7803C7.4090207@joeconway.com>
Permalink:  ../3C7803C7.4090207@joeconway.com/
Also on:    postgresql.org/message-id/3C7803C7.4090207@joeconway.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: mail@joeconway.com, il@mithrandir.hu
  Subject: Re: How to insert zeros into a bytea column?
  In-Reply-To: <3C7803C7.4090207@joeconway.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox