Search Postgresql Archives

Re: pg_restore: custom archiver unexpected end of file , ERROR: missing data for column

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 06/19/2014 05:03 AM, Khangelani Gama wrote:
-----Original Message-----
From: Alban Hertroys [mailto:haramrae@xxxxxxxxx]
Sent: Thursday, June 19, 2014 1:54 PM
To: Khangelani Gama
Cc: pgsql-general@xxxxxxxxxxxxxx
Subject: Re: [GENERAL] pg_restore: custom archiver unexpected end of file ,
ERROR: missing data for column

On 19 June 2014 13:11, Khangelani Gama <kgama@xxxxxxxxxxxx> wrote:
Adrian you might be right I have just tried to pg_restore on the same
server(8.4.2), I get the same errors related to xml. Can someone
advise if the following XML file as an example is in the correct
state or
not:

  Hi all

I have a question, why is that pg_dump does not fail when dumping the
database but only fails when restoring the database?
Dumping the database from same server and restoring it on the same server.
Since there is data issues inside the database why is the pg_dump not
failing as well?

Because then you wouldn't be able to get your data out of your database once
some corruption occurred. You would be forced to fix the issue on your live
database.

Now you can edit the dump and attempt to restore it until it succeeds on a
different system, after which you know for certain that your data matches at
least your integrity constraints.

That makes sense to me, thanks ....Is there is an easier or better way to
edit the binary dump file? Like how I can I fix a certain row or a column of
pg_dump -Fc file? .... I am sorry I have never done this before....please
give a clue on how I can do it.


You can think of the binary dump as a 'frozen' version of your database. Generally you restore to another database, but it is also possible to restore to a text file:

http://www.postgresql.org/docs/9.3/interactive/app-pgrestore.html

So if you use:

-f filename
--file=filename

Specify output file for generated script, or for the listing when used with -l. Default is the standard output.


instead of a database name you will create a text version of the database dump. A word of caution, the text based version will be considerably bigger than the binary compressed version. As I recall you said the database in question is large so you might not want to convert the whole thing. The same switches apply to restoring to a file that work with restoring to a database. So it is possible to select one or more tables and/or data and restore that only. The text file that is generated can then be inspected. What cannot be done is after making changes is reincorporating back into the binary dump. What you do after making the changes depends on the relationships between the changed tables and the other tables in the database. That would require more information.

Another thought. Since pg_dump uses COPY(unless you specify INSERTs) you might want to look at the COPY command and see if that is a better way of seeing what is being retrieved from the table:

http://www.postgresql.org/docs/9.3/interactive/sql-copy.html

IMPORTANT:
"
COPY with a file name instructs the PostgreSQL server to directly read from or write to a file. The file must be accessible to the server and the name must be specified from the viewpoint of the server. When PROGRAM is specified, the server executes the given command, and reads from its standard input, or writes to its standard output. The command must be specified from the viewpoint of the server, and be executable by the postgres user. When STDIN or STDOUT is specified, data is transmitted via the connection between the client and the server"


With COPY you can use a query so it is possible to restrict the data you retrieve to a subset of the total.









--
Adrian Klaver
adrian.klaver@xxxxxxxxxxx



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux