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 1mFzG3-00058R-0J for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Aug 2021 13:35:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mFzG0-0005CB-TG for pgsql-hackers@arkaria.postgresql.org; Tue, 17 Aug 2021 13:35:56 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mFzG0-0005Bg-LQ for pgsql-hackers@lists.postgresql.org; Tue, 17 Aug 2021 13:35:56 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mFzFy-0003Oo-Mn for pgsql-hackers@lists.postgresql.org; Tue, 17 Aug 2021 13:35:56 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 17HDZomZ1075631; Tue, 17 Aug 2021 09:35:50 -0400 From: Tom Lane To: Andres Freund cc: pgsql-hackers@lists.postgresql.org, a.kozhemyakin@postgrespro.ru Subject: Re: ALTER TYPE vs extension membership (was Re: BUG #17144: Upgrade from v13 to v14 with the cube extension failed) In-reply-to: <20210817112233.tiheqcydqf4bariw@alap3.anarazel.de> References: <17144-e67d7a8f049de9af@postgresql.org> <895152.1629129953@sss.pgh.pa.us> <985050.1629142619@sss.pgh.pa.us> <20210817112233.tiheqcydqf4bariw@alap3.anarazel.de> Comments: In-reply-to Andres Freund message dated "Tue, 17 Aug 2021 04:22:33 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1075629.1629207350.1@sss.pgh.pa.us> Date: Tue, 17 Aug 2021 09:35:50 -0400 Message-ID: <1075630.1629207350@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Andres Freund writes: > On 2021-08-16 15:36:59 -0400, Tom Lane wrote: >> There's a policy question here, which is when does an operation on >> a pre-existing object within an extension script cause the object >> to be absorbed into the extension? You might naively say "never", >> but that's not our historical behavior, and I think it'd clearly >> be the wrong thing in some cases. For example, consider >> >> CREATE TYPE cube; -- make a shell type >> -- do something that requires type cube to exist >> CREATE EXTENSION cube; >> >> We don't want this to fail, because it might be necessary to do >> things that way to get out of circular dependencies. > In what scenario would that be a good way to address a circular > dependency? ISTM that whatever depends on $ext should be using shell > types or such to avoid the circular dependency, then create $ext. Rather > than creating shell types for object in $ext and then create $ext. Perhaps. But that does work today (I tested), and it's been the intentional behavior ever since we invented extensions, to judge by the fact that the existing comments on GenerateTypeDependencies describe the current behavior explicitly. (Admitted, that's only talking about types not other sorts of objects, which is why I moved that comment in the proposed patch.) So I'm loath to get rid of it in a back-patched bug fix. Maybe there is a case for becoming stricter in HEAD, but I'm not really clear on what would be an improvement. I do not think that "don't adopt the object into the extension" could be sane. The only other alternative is "throw an error", which goes against the clear intention and definition of CREATE OR REPLACE. The fact that you don't need to say CREATE OR REPLACE TYPE to replace a shell type muddies the waters here a bit, but I think we should still consider that behavior to be an instance of CREATE OR REPLACE. regards, tom lane