pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: ZongtianHou <zongtianhou@icloud.com>
Cc: pgsql-admin <pgsql-admin@postgresql.org>
Subject: Re: how to upgrade with catalog change
Date: Thu, 10 Sep 2020 10:16:17 -0400
Message-ID: <181119.1599747377@sss.pgh.pa.us> (raw)
In-Reply-To: <6D98D845-DD56-43B7-A563-DCAFE61D655E@icloud.com>
References: <6D98D845-DD56-43B7-A563-DCAFE61D655E@icloud.com>

ZongtianHou <zongtianhou@icloud.com> writes:
> I have a new version which merely add a new column (indnkeyatts int2) in pg_index and can not be upgraded
> 1. if I add this column in middle by altering pg_index add column and drop column in old version to match every column position in new version, then can not started with new version, because there is dropped column info in old heap tuple header and it is accessed by hardcoded macro like Anum_pg_index_indkeynatts which cause column mismatch. And this can not be handled by deleting and inserting data again because database will be obsolete once the original data is deleted.
> 2. if this column is added to the end of pg_index( change macro in pg_index.h and pg_attribute.h), in this way I just need to add the new column and will not break old tuple, however,it can not be inited, does this column have to be added after column indnatts because fixed and variable length thing?

> is there a simple way to just add this column and upgrade? and how does you implement it in pg_upgrade?

pg_upgrade never attempts to do direct surgery on catalogs.  The catalog
contents are transferred via pg_dump and reload, and only user tables are
moved physically.  Even if we cared to take the risk of doing something
like your suggestions above, it could only work for very trivial
cross-version catalog changes ... but such changes are frequently
far from trivial.  The SQL script generated by pg_dump is much
more portable.

			regards, tom lane





view thread (3+ messages)  latest in thread

Message-ID: <181119.1599747377@sss.pgh.pa.us>
Permalink:  ../181119.1599747377@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/181119.1599747377@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: tgl@sss.pgh.pa.us, zongtianhou@icloud.com
  Subject: Re: how to upgrade with catalog change
  In-Reply-To: <181119.1599747377@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox