0

(Using postgres 9.4beta2)

I have a dump that I want to import. I have done this with the 'psql' command, as elsewhere it is noted that this is required when using COPY FROM stdin:

psql publishing < publishing.dump.20150211160001 

I get this syntax error:

ERROR:  syntax error at or near "fbc61bc4"
LINE 1: fbc61bc4-2875-4a3a-8dec-91c8d8b60bcc root

The offending line in the dump file is the one after the COPY statement, here are both those lines together:

COPY content_fragment (id, content, name, content_item_id, entity_version) FROM stdin;
fbc61bc4-2875-4a3a-8dec-91c8dcontent    Content for root        content fbc61bc4-2875-4a3a-8dec-91c8d8b60bcc    0

The items in the data appear to be tab separated. I am wondering given that the error message says at or near "fbc61bc4", but the full string is "fbc61bc4-2875-4a3a-8dec-91c8dcontent", is psql not liking the '-' character?

user2800708
  • 1,890
  • 2
  • 18
  • 31

1 Answers1

1

This kind of error happens when the COPY itself fails because the table doesn't exist, or one of the mentioned columns doesn't, or the user lacks the permission to write into it, etc...

As COPY fails, the SQL interpreter continues to the next line and interpret it as if was an SQL statement, although it's actually data meant to be fed to COPY. Generally this leads to a syntax error, preceded by the error telling why the COPY failed (and often followed by tons of errors if there are many lines of data).

See another question: psql invalid command \N while restore sql, which shares the same root cause and has some useful comments.

Community
  • 1
  • 1
Daniel Vérité
  • 58,074
  • 15
  • 129
  • 156
  • Thanks. The file was created with pg_dump, and the admin tells me he successfully manged to re-import a file (not necessarily this one) today, on another box. I'll check this out carefully tomorrow when I'm back at work. – user2800708 Feb 12 '15 at 22:29