Thread: 'invalid command \N' during restore from pg_dump

'invalid command \N' during restore from pg_dump

From
kevin kempter
Date:
Hi all;

I'm trying to run a restore from a pg_dump and I get loads of these:

invalid command \N


I see lots of \N char's in the data for some of the tables (NULL's ?)

Thoughts?

Thanks in advance

Re: 'invalid command \N' during restore from pg_dump

From
Jan-Peter Seifert
Date:
Hello,

kevin kempter wrote:

> I'm trying to run a restore from a pg_dump and I get loads of these:
>
> invalid command \N
>
>
> I see lots of \N char's in the data for some of the tables (NULL's ?)

Are you using pgAdmin's SQL-editor for restoring by any chance? It
throws errors - especially if the \N (NULL) is at the beginning of the
line. Use psql for restoring or try with activating the option to use
INSERT instead of COPY commands for creating dumps with pg_dump.

Peter

Re: 'invalid command \N' during restore from pg_dump

From
kevin kempter
Date:
On Oct 17, 2008, at 3:20 PM, Jan-Peter Seifert wrote:

> Hello,
>
> kevin kempter wrote:
>
>> I'm trying to run a restore from a pg_dump and I get loads of these:
>>
>> invalid command \N
>>
>>
>> I see lots of \N char's in the data for some of the tables (NULL's ?)
>
> Are you using pgAdmin's SQL-editor for restoring by any chance? It
> throws errors - especially if the \N (NULL) is at the beginning of the
> line. Use psql for restoring or try with activating the option to use
> INSERT instead of COPY commands for creating dumps with pg_dump.
>
> Peter
>

No, I'm doing it at the command line on a Redhat box (postgres version
8.2.5)



Re: 'invalid command \N' during restore from pg_dump

From
Tom Lane
Date:
kevin kempter <kevin@kevinkempterllc.com> writes:
> I'm trying to run a restore from a pg_dump and I get loads of these:
> invalid command \N

It sounds like you had an error in a COPY command, which caused psql
not to go into copy-data-eating mode but instead keep trying to read
the data as SQL commands.

Generally speaking, looking at the *first* error is the most informative
way to proceed --- all the rest may just be cascading failures.

            regards, tom lane