Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hJ3VU-00063Q-28 for pgsql-bugs@arkaria.postgresql.org; Tue, 23 Apr 2019 22:03:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hJ3VS-00077b-Hl for pgsql-bugs@arkaria.postgresql.org; Tue, 23 Apr 2019 22:03:14 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hJ3VS-00077T-6k for pgsql-bugs@lists.postgresql.org; Tue, 23 Apr 2019 22:03:14 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hJ3VP-0000zj-Nv for pgsql-bugs@lists.postgresql.org; Tue, 23 Apr 2019 22:03:12 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x3NM35Xp000696; Tue, 23 Apr 2019 18:03:06 -0400 From: Tom Lane To: Amit Langote cc: Amit Langote , Michael Paquier , jianingy.yang@gmail.com, PostgreSQL mailing lists , Pg Hackers Subject: Re: BUG #15672: PostgreSQL 11.1/11.2 crashed after dropping a partition table In-reply-to: References: <15672-b9fa7db32698269f@postgresql.org> <20190307000316.GB17293@paquier.xyz> Comments: In-reply-to Amit Langote message dated "Wed, 27 Mar 2019 11:40:12 +0900" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <557.1556056835.0@sss.pgh.pa.us> Date: Tue, 23 Apr 2019 18:03:05 -0400 Message-ID: <695.1556056985@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <557.1556056835.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable ISTM we could work around the problem with the attached, which I think is a good change independently of anything else. There is still an issue, which manifests in both 11 and HEAD, namely that the code also propagates the parent index's comment to any child indexes. You can see that with this extended test case: create table users(user_id int, name varchar(64), unique (user_id, name)) = partition by hash(user_id); = comment on index users_user_id_name_key is 'parent index'; create table users_000 partition of users for values with (modulus 2, rema= inder 0); = create table users_001 partition of users for values with (modulus 2, rema= inder 1); = select relname, relfilenode, obj_description(oid,'pg_class') from pg_class= where relname like 'users%'; alter table users alter column name type varchar(127); = = select relname, relfilenode, obj_description(oid,'pg_class') from pg_class= where relname like 'users%'; which gives me (in 11, with this patch) ... relname | relfilenode | obj_description = ----------------------------+-------------+----------------- users | 89389 | = users_000 | 89394 | = users_000_user_id_name_key | 89397 | = users_001 | 89399 | = users_001_user_id_name_key | 89402 | = users_user_id_name_key | 89392 | parent index (6 rows) ALTER TABLE relname | relfilenode | obj_description = ----------------------------+-------------+----------------- users | 89389 | = users_000 | 89394 | = users_000_user_id_name_key | 89406 | parent index users_001 | 89399 | = users_001_user_id_name_key | 89408 | parent index users_user_id_name_key | 89404 | parent index (6 rows) However, I doubt that that's bad enough to justify a major rewrite of the ALTER TABLE code in 11 ... and maybe not in HEAD either; I wouldn't be too unhappy to leave it to v13. regards, tom lane ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="dont-try-to-share-storage-thats-not-there.patch"; charset="us-ascii" Content-ID: <557.1556056835.2@sss.pgh.pa.us> Content-Description: dont-try-to-share-storage-thats-not-there.patch Content-Transfer-Encoding: quoted-printable diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/index= cmds.c index f8ee4b0..c5c543f 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -252,8 +252,17 @@ CheckIndexCompatible(Oid oldId, if (!ret) return false; = - /* For polymorphic opcintype, column type changes break compatibility. *= / + /* We now need to actually look at the index rel. */ irel =3D index_open(oldId, AccessShareLock); /* caller probably has a lo= ck */ + + /* If it's a partitioned index, there is no storage to share. */ + if (irel->rd_rel->relkind =3D=3D RELKIND_PARTITIONED_INDEX) + { + index_close(irel, NoLock); + return false; + } + + /* For polymorphic opcintype, column type changes break compatibility. *= / for (i =3D 0; i < old_natts; i++) { if (IsPolymorphicType(get_opclass_input_type(classObjectId[i])) && ------- =_aaaaaaaaaa0--