Arrays and backslashes

From: Colin DuPlantis <colind(at)sun(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Arrays and backslashes
Date: 2006-08-18 19:00:41
Message-ID: 44E60E59.5050607@sun.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I'm running:

colin=# select version();
version
---------------------------------------------------------------------------------------------------------------------------
PostgreSQL 8.1.1 on x86_64-unknown-linux-gnu, compiled by GCC gcc
(GCC) 3.4.4 (Gentoo 3.4.4-r1, ssp-3.4.4-1.0, pie-8.7.8)
(1 row)

My problem is as follows:

given this table:
create table test ( c1 text, c2 text[] );

I am having trouble inserting a value into the array column that
contains a single '\' (no quotes) character. The following examples are
my attempts to produce a value of 'x\y' (no quotes) in both the regular
text and the text array columns in the test table:

insert into test values ( 'x\\y', array['x\\y']);

c1 | c2
-----+----------
x\y | {"x\\y"}
(1 row)

while:

insert into test values ( 'x\\y', array['x\y']);

c1 | c2
-----+----------
x\y | {xy}
(1 row)

I also tried:

insert into test values ( 'x\\y', array[$$x\y$$]);

c1 | c2
-----+----------
x\y | {"x\\y"}
(1 row)

and:

insert into test values ( 'x\\y', '{x\y}');

c1 | c2
-----+----------
x\y | {xy}
(1 row)

and:

insert into test values ( 'x\\y', '{x\\y}');

c1 | c2
-----+------
x\y | {xy}
(1 row)

and:

insert into test values ( 'x\\y', '{x\\\\y}');

c1 | c2
-----+----------
x\y | {"x\\y"}
(1 row)

just to be complete, I also tried this:

insert into test values ( 'x\\y', '{x\\\y}');

c1 | c2
-----+------
x\y | {xy}
(1 row)

I found an article that may be releated, but didn't provide much
insight: http://archives.postgresql.org/pgsql-bugs/2001-11/msg00162.php
(at least to me).

Any help that can be offered will be greatly appreciated. Thanks.

- Colin

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Fuhr 2006-08-18 20:54:19 Re: Connection string
Previous Message Merlin Moncure 2006-08-18 18:20:15 Re: Migrating PostgreSQL database to MySQL/MS Access