psql (11.5, server 11.3) on linux
Trying to insert a string containing a double-quote into a varchar arr. Here's my attempt dvdb=# create table testarr (arr varchar[]);
CREATE TABLE
dvdb=# insert into testarr (arr) values ('{"abcdefg"}');
INSERT 0 1
dvdb=# select * from testarr;
arr
-----------
{abcdefg}
(1 row)
dvdb=# insert into testarr (arr) values ('{"hijk"lmnop"}');
ERROR: malformed array literal: "{"hijk"lmnop"}"
LINE 1: insert into testarr (arr) values ('{"hijk"lmnop"}');
^
DETAIL: Unexpected array element.
dvdb=# insert into testarr (arr) values ('{"hijk""lmnop"}');
ERROR: malformed array literal: "{"hijk""lmnop"}"
LINE 1: insert into testarr (arr) values ('{"hijk""lmnop"}');
^
DETAIL: Unexpected array element.
dvdb=# insert into testarr (arr) values ('{"hijk\"lmnop"}');
INSERT 0 1
dvdb=# select * from testarr;
arr
-----------------
{abcdefg}
{"hijk\"lmnop"}
(2 rows)
CREATE TABLE
dvdb=# insert into testarr (arr) values ('{"abcdefg"}');
INSERT 0 1
dvdb=# select * from testarr;
arr
-----------
{abcdefg}
(1 row)
dvdb=# insert into testarr (arr) values ('{"hijk"lmnop"}');
ERROR: malformed array literal: "{"hijk"lmnop"}"
LINE 1: insert into testarr (arr) values ('{"hijk"lmnop"}');
^
DETAIL: Unexpected array element.
dvdb=# insert into testarr (arr) values ('{"hijk""lmnop"}');
ERROR: malformed array literal: "{"hijk""lmnop"}"
LINE 1: insert into testarr (arr) values ('{"hijk""lmnop"}');
^
DETAIL: Unexpected array element.
dvdb=# insert into testarr (arr) values ('{"hijk\"lmnop"}');
INSERT 0 1
dvdb=# select * from testarr;
arr
-----------------
{abcdefg}
{"hijk\"lmnop"}
(2 rows)
What I'm looking for is...
{abcdefg}
{hijk"lmnop}
{hijk"lmnop}
Can this be done ?