pg_dump again
pg_dump again
От:
Mikhail Terekhov <terekhov@emc.com>
Дата:
Hi,
It seems that pg_dump (in 6.4.2) still has a problem when quoting
\ and ' when these characters appears together.
Consider the following example:
terekhov=> create table test (i int, t text);
CREATE
terekhov=> insert into test values (1,'');
INSERT 19066 1
terekhov=> insert into test values (2,'abcd');
INSERT 19067 1
terekhov=> insert into test values (3,'\\');
INSERT 19068 1
terekhov=> insert into test values (4,'\'');
INSERT 19069 1
terekhov=> insert into test values (5,'\\\'');
INSERT 19070 1
terekhov=> select * from test;
i|t
-+----
1|
2|abcd
3|\
4|'
5|\'
(5 rows)
terekhov=> \q
terekhov(575)~>pg_dump -d -D -f ter.db terekhov
terekhov(576)~>cat ter.db
CREATE TABLE "test" ("i" int4,"t" text);
INSERT INTO "test" ("i","t") values (1,'');
INSERT INTO "test" ("i","t") values (2,'abcd');
INSERT INTO "test" ("i","t") values (3,'\');
INSERT INTO "test" ("i","t") values (4,'''');
INSERT INTO "test" ("i","t") values (5,'\'''); ^ wrong quoting here -----|
terekhov(577)~>psql
Welcome to the POSTGRESQL interactive sql monitor: Please read the file COPYRIGHT for copyright terms of POSTGRESQL
type \? for help on slash commands type \q to quit type \g or terminate with semicolon to execute queryYou are currently connected to the database: terekhov
terekhov=> alter table test rename to test0;
RENAME
terekhov=> \q
terekhov(578)~>psql -e ] -- set html3 caption (currently '')\connect -- connect to new database (currently 'terekhov')\copy table {from | to} \d [Re: [HACKERS] pg_dump again
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Mikhail Terekhov writes: > It seems that pg_dump (in 6.4.2) still has a problem when quoting > \ and ' when these characters appears together. > Consider the following example: > ... snip ... > terekhov(575)~>pg_dump -d -D -f ter.db terekhov Ah, I see the problem: pg_dump's -d/-D option doesn't do quoting of special characters properly --- in fact, the only thing it does do is double-up single quote marks. My testing was without that option --- without -d or -D, pg_dump uses COPY, which quotes everything properly. This is probably why most people weren't seeing a problem. I'll put this on my to-do list for 6.5, but in the meantime, I'd suggest not using -d or -D... a dump script with one INSERT per table row is horribly slow compared to COPY anyway... regards, tom lane
Re: [HACKERS] pg_dump again
От:
Bruce Momjian <maillist@candle.pha.pa.us>
Дата:
Tom, is this fixed? > Mikhail Terekhov writes: > > It seems that pg_dump (in 6.4.2) still has a problem when quoting > > \ and ' when these characters appears together. > > Consider the following example: > > ... snip ... > > terekhov(575)~>pg_dump -d -D -f ter.db terekhov > > Ah, I see the problem: pg_dump's -d/-D option doesn't do quoting of > special characters properly --- in fact, the only thing it does do > is double-up single quote marks. My testing was without that option --- > without -d or -D, pg_dump uses COPY, which quotes everything properly. > This is probably why most people weren't seeing a problem. > > I'll put this on my to-do list for 6.5, but in the meantime, I'd suggest > not using -d or -D... a dump script with one INSERT per table row is > horribly slow compared to COPY anyway... > > regards, tom lane > > -- Bruce Momjian | http://www.op.net/~candle maillist@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026