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 1pajw6-00079C-7D for pgsql-hackers@arkaria.postgresql.org; Fri, 10 Mar 2023 21:05:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pajw4-0005rx-N7 for pgsql-hackers@arkaria.postgresql.org; Fri, 10 Mar 2023 21:05:56 +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 1pajw4-0005ro-EA for pgsql-hackers@lists.postgresql.org; Fri, 10 Mar 2023 21:05:56 +0000 Received: from mail-qt1-x830.google.com ([2607:f8b0:4864:20::830]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pajw1-0005l2-Hs for pgsql-hackers@lists.postgresql.org; Fri, 10 Mar 2023 21:05:55 +0000 Received: by mail-qt1-x830.google.com with SMTP id c18so7254349qte.5 for ; Fri, 10 Mar 2023 13:05:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pcorp-us.20210112.gappssmtp.com; s=20210112; t=1678482352; h=content-language:thread-index:content-transfer-encoding :mime-version:message-id:date:subject:in-reply-to:references:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=eI75Di+CGHn0i81csSarqzspCcKiBw07MDf3QFqyMNA=; b=UD8N9OvDol5zC2zvapGlbczT8ETB9XFzsFX1ndUCF7obqYklmfNiVhjylGWOlpLn3o LGZ7vX7hgWichFCarMKnJp3W/ZK1Dd4QxiIZQXVYhRFypgtv9RTjeR3g2ObWkEFZuMfR 3gaBWtleAY97vTkcNZwHRY66XxfwCelgpaP/BspSEytMpuwFXp7RAbjNKioFYhfxv6d4 a9oUNiltzkgoZTHzR4qB8+38nBKjj/cb0L4AxzF0DuymOINe2rgDuTymMTCC5I1WAKgU vxrnNyzvkxQ30WEf/24OYIMuq2c1LMBeiVi5PrlosWdO5Gr+I563LMHxt7n0Hz4kNS5m Oj2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678482352; h=content-language:thread-index:content-transfer-encoding :mime-version:message-id:date:subject:in-reply-to:references:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=eI75Di+CGHn0i81csSarqzspCcKiBw07MDf3QFqyMNA=; b=R5toYibI7PW3fvqDI4PuRVRcVbWboNacrrS4N2lzp9ov09h+W8BUXYQmfDDegEyJJJ hXkmZc0bfo8oeEnV/sN2n3vHL4VfIcx6Nrsi2DAcaVtcSkwvrHZMa1ltZldIxHSdLj8w XQMpVwBIf6gULYbCRHbcyjg9ZxQAUODTLDO22xr0U7kFRgoIRJiqFH8b9Rh0p7viohZ5 Gfq3Yw2JtAHAz8bkZiLeqpxheRNKtIs/2TGgVjuuQprTAzkhq6C8nykH5Q3a7M/68jzx aUfRjGGk2yjssIDZFBvXZx6JY28mn0cF5XTaWyAWurPUbQbebUa9MKU3/AfDwpNmeIZK e5AA== X-Gm-Message-State: AO0yUKW2bc2k1DmhUS/3HvW4snGj2FHbs76puPbA4nG1rriIHVo4m5Gc Ci8f8VkfIiKU2nCjyo6LV0tBXIiEl7P3nJ1sJ3UaPw== X-Google-Smtp-Source: AK7set9yLDblflDfx0o/10dWP5h0oZJJJJv4BRSkP26yEOaCLURT85y1SEq8qNx6s+u10yEF6aiLxg== X-Received: by 2002:ac8:5bc8:0:b0:3bf:ced2:2ad with SMTP id b8-20020ac85bc8000000b003bfced202admr10439489qtb.19.1678482352426; Fri, 10 Mar 2023 13:05:52 -0800 (PST) Received: from F (50-78-240-110-static.hfc.comcastbusiness.net. [50.78.240.110]) by smtp.gmail.com with ESMTPSA id d18-20020ac84e32000000b003ba11bfe4fcsm526637qtw.28.2023.03.10.13.05.51 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Mar 2023 13:05:52 -0800 (PST) From: "Regina Obe" To: "'Tom Lane'" Cc: "'Gregory Stark \(as CFM\)'" , "'Sandro Santilli'" , , "'Regina Obe'" References: <003001d8f4ae$402282c0$c0678840$@pcorp.us> <000401d94bc8$48dff700$da9fe500$@pcorp.us> <167762779361.628976.14009177203307564086.pgcf@coridan.postgresql.org> <005401d95083$26ca24a0$745e6de0$@pcorp.us> <995823.1678478825@sss.pgh.pa.us> In-Reply-To: <995823.1678478825@sss.pgh.pa.us> Subject: RE: Ability to reference other extensions by schema in extension scripts Date: Fri, 10 Mar 2023 16:05:46 -0500 Message-ID: <004b01d95394$16123ee0$4236bca0$@pcorp.us> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 15.0 Thread-Index: AQFgXZxpr0yOB+9uS1Xwc1lFBKthIAFb3UkpAlqGOBEBdWkvegLXfdbzAh2KTDWvlV6yIA== Content-Language: en-us List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > "Regina Obe" writes: > > [ 0005-Allow-use-of-extschema-reqextname-to-reference.patch ] > > I took a look at this. I'm on board with the feature design, but not so much > with this undocumented restriction you added to ALTER EXTENSION SET > SCHEMA: > > + /* If an extension requires this extension > + * do not allow relocation */ > + if (pg_depend->deptype == DEPENDENCY_NORMAL && > pg_depend->classid == ExtensionRelationId){ > + dep.classId = pg_depend->classid; > + dep.objectId = pg_depend->objid; > + dep.objectSubId = pg_depend->objsubid; > + ereport(ERROR, > + > (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), > + errmsg("cannot SET SCHEMA of > extension %s because other extensions require it", > + NameStr(extForm- > >extname)), > + errdetail("%s requires extension %s", > + > getObjectDescription(&dep, false), > +NameStr(extForm->extname)))); > > That seems quite disastrous for usability, and it's making an assumption > unsupported by any evidence: that it will be a majority use-case for > dependent extensions to have used @extschema:myextension@ in a way that > would be broken by ALTER EXTENSION SET SCHEMA. > > I think we should just drop this. It might be worth putting in some > documentation notes about the hazard, instead. > That was my thought originally too and also given the rarity of people changing schemas I wasn't that bothered with not forcing this. Sandro was a bit more bothered by not forcing it and given the default for extensions is not relocatable, we didn't see that much of an issue with it. > If you want to work harder, perhaps a reasonable way to deal with the issue > would be to allow dependent extensions to declare that they don't want your > extension relocated. But I do not think it's okay to make that the default > behavior, much less the only behavior. I had done that in one iteration of the patch. We discussed this here https://www.postgresql.org/message-id/000001d949ad%241159adc0%24340d0940%24% 40pcorp.us and here https://www.postgresql.org/message-id/20230223183906.6rhtybwdpe37sri7%40c19 - the main issue I ran into is I have to introduce another dependency type or go with Sandro's idea of using refsubobjid for this purpose. I think defining a new dependency type is less likely to cause unforeseen complications elsewhere, but did require me to expand the scope (to make changes to pg_depend). Which I am fine with doing, but didn't want to over extend my reach too much. One of my revisions tried to use DEPENDENCY_AUTO which did not work (as Sandro discovered) and I had some other annoyances with lack of helper functions https://www.postgresql.org/message-id/000401d93a14%248647f540%2492d7dfc0%24% 40pcorp.us key point: "Why isn't there a variant getAutoExtensionsOfObject take a DEPENDENCY type as an option so it would be more useful or is there functionality for that I missed?" > And really, since we've gotten along without it so far, I'm not sure that it's > necessary to have it. > > Another thing that's bothering me a bit is the use of get_required_extension > in execute_extension_script. That does way more than you really need, and > passing a bunch of bogus parameter values to it makes me uncomfortable. > The callers already have the required extensions' OIDs at hand; it'd be better > to add that list to execute_extension_script's API instead of redoing the > lookups. > > regards, tom lane So you are proposing I change the execute_extension_scripts input args to take more args?