Backslashes in data in version 8.1.2

From: Mike Nolan <nolan(at)gw(dot)tssi(dot)com>
To: pgsql-general(at)postgresql(dot)org (pgsql general list)
Subject: Backslashes in data in version 8.1.2
Date: 2006-02-19 18:56:00
Message-ID: 200602191856.k1JIu2eO015468@gw.tssi.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

When I moved up to 8.1.2 one of my PHP programs appears to be broken,
I am getting backslashes in my data that I don't want.

Investigating further, I have found some inconsistencies in how verion
8.1.2 handles data with backslashes in it:

uscf=> \d backtest;
Table "mikenolan.backtest"
Column | Type | Modifiers
--------+------+-----------
field | text |

uscf=> insert into backtest values ('ABCDEFG');
insert into backtest values ('ABCDEFG');
INSERT 417194901 1

uscf=> insert into backtest values (E'ABC\\DEFG');
insert into backtest values (E'ABC\\DEFG');
INSERT 417194902 1

uscf=> select * from backtest;
select * from backtest;
field
----------
ABCDEFG
ABC\DEFG
(2 rows)

uscf=> select * from backtest where field like E'%\\%';
select * from backtest where field like E'%\\%';
field
-------
(0 rows)

select * from backtest where field like E'%\\134%'

field
-------
(0 rows)

uscf=> select * from backtest where field ~ E'\\';
select * from backtest where field ~ E'\\';
ERROR: invalid regular expression: invalid escape \ sequence

uscf=> select * from backtest where field ~ E'\\134';
select * from backtest where field ~ E'\\134';
field
----------
ABC\DEFG
(1 row)

So far the only way I have found to change data with backslashes in it
is something like the following:

update backtest
set field = replace(field,'\\','')
where
field ~ E'\\134';
UPDATE 1

uscf=> select * from backtest;
select * from backtest;
field
---------
ABCDEFG
ABCDEFG
(2 rows)
--
Mike Nolan

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Christopher J. Bottaro 2006-02-19 20:25:20 restoring under a different owner?
Previous Message Tom Lane 2006-02-19 17:07:42 Re: pgplsql and notifications