COPY problem on -- strings

From: "Sabin Coanda" <sabin(dot)coanda(at)deuromedia(dot)ro>
To: pgsql-general(at)postgresql(dot)org
Subject: COPY problem on -- strings
Date: 2008-11-19 10:57:37
Message-ID: gg0rg0$2dlf$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I have "PostgreSQL 8.3.5, compiled by Visual C++ build 1400" on Windows OS.

I try to use the COPY command to optimize the backup/restore performance,
but I found a problem. I reproduce it below.

I create a database with a simple table:
CREATE TABLE "A"
(
"Col1" integer NOT NULL,
"Col2" character varying NOT NULL,
CONSTRAINT "A_pkey" PRIMARY KEY ("Col1")
)
WITH (OIDS=FALSE);
ALTER TABLE "A" OWNER TO postgres;

I populate the table with the statement:
INSERT INTO "A" ( "Col1", "Col2" )
VALUES (2, '-- any text' );

I backup the database plain with the command:
pg_dump.exe -U postgres -F p -v -f "backup_plain.sql" "DemoDB"

I create a new database, and I run the script. But it rise me the error:
ERROR: syntax error at or near "1"
LINE 49: 1 -- any text

I look for the error line and I saw how pg_dump created the script
statement:
COPY "A" ("Col1", "Col2") FROM stdin;
1 -- any text
\.

Please let me know if this is a bug on pg_dump, or on the COPY syntax
design, or am I wrong ?
Do you know an workaround to make my backup/restore process available by
COPY, not by INSERT commands ?

TIA,
Sabin

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andy Greensted 2008-11-19 10:57:58 Connecting to old 7.1 Database
Previous Message Andrus 2008-11-19 10:50:23 Re: Conversion of string to int using digits at beginning