Fix pg_upgrade to handle extensions.
Tom Lane <tgl@sss.pgh.pa.us>
Fix pg_upgrade to handle extensions. This follows my proposal of yesterday, namely that we try to recreate the previous state of the extension exactly, instead of allowing CREATE EXTENSION to run a SQL script that might create some entirely-incompatible on-disk state. In --binary-upgrade mode, pg_dump won't issue CREATE EXTENSION at all, but instead uses a kluge function provided by pg_upgrade_support to recreate the pg_extension row (and extension-level pg_depend entries) without creating any member objects. The member objects are then restored in the same way as if they weren't members, in particular using pg_upgrade's normal hacks to preserve OIDs that need to be preserved. Then, for each member object, ALTER EXTENSION ADD is issued to recreate the pg_depend entry that marks it as an extension member. In passing, fix breakage in pg_upgrade's enum-type support: somebody didn't fix it when the noise word VALUE got added to ALTER TYPE ADD. Also, rationalize parsetree representation of COMMENT ON DOMAIN and fix get_object_address() to allow OBJECT_DOMAIN.
Files
| Path | Change | +/− |
|---|---|---|
| contrib/pg_upgrade/function.c | modified | +16 −10 |
| contrib/pg_upgrade_support/pg_upgrade_support.c | modified | +71 −2 |
| src/backend/catalog/objectaddress.c | modified | +1 −0 |
| src/backend/commands/comment.c | modified | +1 −0 |
| src/backend/commands/extension.c | modified | +68 −26 |
| src/backend/parser/gram.y | modified | +1 −1 |
| src/bin/pg_dump/common.c | modified | +1 −0 |
| src/bin/pg_dump/pg_dump.c | modified | +377 −144 |
| src/bin/pg_dump/pg_dump.h | modified | +3 −0 |
| src/include/commands/extension.h | modified | +5 −0 |