Use pg_restore to restore from a newer version of PostgreSQL

前端 未结 5 2183
难免孤独
难免孤独 2020-12-16 00:32

I have a (production) DB server running PostgreSQL v9.0 and a development machine running PostgreSQL v8.4. I would like to take a dump of the production DB and use it on the

5条回答
  •  眼角桃花
    2020-12-16 01:07

    If the 9.0 database contains any bytea columns, then bigger problems await.

    These columns will be exported by pg_dump using the "hex" representation and appear in your dump file like:

    SELECT pg_catalog.lowrite(0, '\x0a2')

    Any version of the postgres backend below 9.0 can't grok the hex representation of bytea, and I can't find an option to tell pg_dump on the 9.0 side to not use it. Setting the default "bytea_output" setting to ESCAPE for either the database or the whole server is seemingly ignored by pg_dump.

    I suppose it would be possible to post-process the dump file and actually change every hex-encoded bytea value to an escaped one, but the risk of untraceably corrupting the kind of things normally stored in a bytea (images, PDFs etc) does not excite me.

提交回复
热议问题