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 1hkwtL-0007jZ-Qf for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Jul 2019 20:39:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hkwtJ-0002cj-T1 for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Jul 2019 20:39:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hkwtJ-0002Yy-I2 for pgsql-hackers@lists.postgresql.org; Tue, 09 Jul 2019 20:39:09 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hkwtH-0002tE-EM for pgsql-hackers@lists.postgresql.org; Tue, 09 Jul 2019 20:39:09 +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 x69Kd2MQ027853; Tue, 9 Jul 2019 16:39:03 -0400 From: Tom Lane To: Tomas Vondra cc: Alvaro Herrera , pgsql-hackers@lists.postgresql.org, Manuel Rigger Subject: Re: Broken defenses against dropping a partitioning column In-reply-to: <20190709191829.hqtnkt3qoa6ifgwv@development> References: <20190708143153.GA5929@alvherre.pgsql> <30041.1562597936@sss.pgh.pa.us> <20190709191829.hqtnkt3qoa6ifgwv@development> Comments: In-reply-to Tomas Vondra message dated "Tue, 09 Jul 2019 21:18:29 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <27851.1562704742.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 09 Jul 2019 16:39:02 -0400 Message-ID: <27852.1562704742@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Tomas Vondra writes: > On Mon, Jul 08, 2019 at 10:58:56AM -0400, Tom Lane wrote: >> So I think we're probably stuck with the approach of adding new interna= l >> dependencies. If we go that route, then our options for the released >> branches are (1) do nothing, or (2) back-patch the code that adds such >> dependencies, but without a catversion bump. That would mean that only >> tables created after the next minor releases would have protection agai= nst >> this problem. That's not ideal but maybe it's okay, considering that w= e >> haven't seen actual field reports of trouble of this kind. > Couldn't we also write a function that adds those dependencies for > existing objects, and request users to run it after the update? Maybe. I'm not volunteering to write such a thing. BTW, it looks like somebody actually did think about this problem with respect to external dependencies of partition expressions: regression=3D# create function myabs(int) returns int language internal as= 'int4abs' immutable strict parallel safe; CREATE FUNCTION regression=3D# create table foo (f1 int) partition by range (myabs(f1)); CREATE TABLE regression=3D# drop function myabs(int); ERROR: cannot drop function myabs(integer) because other objects depend o= n it DETAIL: table foo depends on function myabs(integer) HINT: Use DROP ... CASCADE to drop the dependent objects too. Unfortunately, there's still no dependency on the column f1 in this scenario. That means any function that wants to reconstruct the correct dependencies would need a way to scan the partition expressions for Vars. Not much fun from plpgsql, for sure. regards, tom lane