Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kGZTd-0007Az-7L for pgsql-admin@arkaria.postgresql.org; Fri, 11 Sep 2020 03:11:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kGZTb-0002LP-5E for pgsql-admin@arkaria.postgresql.org; Fri, 11 Sep 2020 03:11:51 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kGZTa-0002LH-T8 for pgsql-admin@lists.postgresql.org; Fri, 11 Sep 2020 03:11:50 +0000 Received: from pv50p00im-hyfv10021501.me.com ([17.58.6.48]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kGZTU-0006Zk-6E for pgsql-admin@postgresql.org; Fri, 11 Sep 2020 03:11:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1599793901; bh=1FVf/Raz6AK0FtpFVEn8lw3+Sgl+zR6Y1aeNwJG3/dI=; h=Content-Type:Mime-Version:Subject:From:Date:Message-Id:To; b=kfmAO75cZS/S5/9Ejs5i0LL9C88yGrMTviqXjDOGL63P389CIoM7XPEKKp4nwzZd1 R3F8O2RFBu//0OJ2Efi0YUx+/e1AtRopgPjQYf6VIXsL0t86ucB1OjviQIl9OmoId/ 5yXmOTDMqQl8AsthevgekisFefyc3QbY8zg+aoEBvsIuB6JLRGRrO4vezJU2dxqs8t 70HKRa7EnVFd0SMXYEmUKdQDbOPB2qG5F6g/qrKaU4dLpqLWprjpARcueqjjDP8z3h hbyg/LGqZXQlscufyW55SJ4iH5PpUW8k2zhUo4+l/RwQGVjtv518ydGYbSlYmWaCTx AikW/0td7J/PA== Received: from [192.168.1.108] (unknown [116.213.168.141]) by pv50p00im-hyfv10021501.me.com (Postfix) with ESMTPSA id D05EEB402BA; Fri, 11 Sep 2020 03:11:40 +0000 (UTC) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3608.40.2.2.4\)) Subject: Re: how to upgrade with catalog change From: ZongtianHou In-Reply-To: <181119.1599747377@sss.pgh.pa.us> Date: Fri, 11 Sep 2020 11:11:30 +0800 Cc: pgsql-admin Content-Transfer-Encoding: quoted-printable Message-Id: <05EFE004-DC56-452C-B970-E2E862B6AB18@icloud.com> References: <6D98D845-DD56-43B7-A563-DCAFE61D655E@icloud.com> <181119.1599747377@sss.pgh.pa.us> To: Tom Lane X-Mailer: Apple Mail (2.3608.40.2.2.4) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-09-11_01:2020-09-10,2020-09-11 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-2006250000 definitions=main-2009110025 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Thanks very much, it seems that using pg_dump and reload is the standard = and most safe way. Happy to get it. Best Regards, Zongtian > On Sep 10, 2020, at 10:16 PM, Tom Lane wrote: >=20 > ZongtianHou 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? >=20 >> is there a simple way to just add this column and upgrade? and how = does you implement it in pg_upgrade? >=20 > 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. >=20 > regards, tom lane >=20 >=20