By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
Help with an interesting Postgres question: Why isn't an Index Only Scan used on a partition accessed via the parent table?.
create table orders (
id int generated by default as identity primary key,
login text,
amount int);
insert into orders (id,login,amount) values
(22,'*@mail.co',230),
(39,'state}.com',340);
update orders set login=regexp_replace(login,'(\W)','\\\\\1','g')
returning *;
CREATE TABLE
INSERT 0 2
id | login | amount |
---|---|---|
22 | \*\@mail\.co | 230 |
39 | state\}\.com | 340 |
UPDATE 2
begin;
truncate orders;
insert into orders (id,login,amount) values
(22,'*@mail.co',230),
(39,'state}.com',340);
update orders set login=regexp_replace( login
, '([^[:word:]])'
, '\\\\'||'\1', 'g')
returning *;
rollback;
BEGIN
TRUNCATE TABLE
INSERT 0 2
id | login | amount |
---|---|---|
22 | \*\@mail\.co | 230 |
39 | state\}\.com | 340 |
UPDATE 2
ROLLBACK