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