views:

51

answers:

1

Hey

I have a Postgresql dump file which i'm trying to restore. I get this error regarding an invalid data i guess.

ERROR: invalid input syntax for integer: "."

and when i checked the file, there are data like this:

469215  2009-10-10 18:16:47.041377  0   1
471217  2009-10-10 18:25:12.536352  0   1
473224  2009-10-17 09:46:43.041604  0   1
473228  2009-10-22 10:58:40.194244  0   1
.

so i was wondering what is this "." do? i check some other working dumps and they ended their data line with "." which i guess it's the correct syntax!

Please tell me what's the correct syntax and what does it do? thank you

+2  A: 

Seems that it marks the end of a COPY statement

From the documentation

End of data can be represented by a single line containing just backslash-period (\.).
 An end-of-data marker is not necessary when reading from a file, since the end of file 
serves perfectly well; it is needed only when copying data to or from client
applications using pre-3.0 client protocol.
Steven Schlansker
is there any way to get around it? kinda like set it to ignore it? cause the dump file is almost 12million lines and it's a pain to search all copy statements and replace the end of them to "\." !
omid8bimo
Don't know of one off the top of my head. However, it should be pretty easy to use some utility like "sed" to change it painlessly...
Steven Schlansker
You might want to try to figure out how it happened in the first place before you just go edit the file - pg_dump will always generate the proper terminator... (This is one more reason to always use the "custom" dump format, of course)
Magnus Hagander
well actually the data is not a actual pg_dump format, it's raw data recovered from the disk. i found a way! i used a python piece of code to convert those "." in a new line to "\." :)
omid8bimo