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 1nKk1U-0006Zp-Ms for pgsql-general@arkaria.postgresql.org; Thu, 17 Feb 2022 16:52:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nKk1T-00038a-Ke for pgsql-general@arkaria.postgresql.org; Thu, 17 Feb 2022 16:52: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 1nKk1T-00038R-4d for pgsql-general@lists.postgresql.org; Thu, 17 Feb 2022 16:52:51 +0000 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nKk1O-0003Hh-Ma for pgsql-general@lists.postgresql.org; Thu, 17 Feb 2022 16:52:50 +0000 Received: by mail-pg1-x52b.google.com with SMTP id h125so5535914pgc.3 for ; Thu, 17 Feb 2022 08:52:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yugabyte.com; s=google; h=from:mime-version:subject:message-id:date:to; bh=POa4TeCrCq3AKPkS0V/TBHCRP3Msd+cE9xssY9nI58Q=; b=i9V6YCFYJM3MgtttoCZNIQ9DBlsReCOzOREY6KyMzSpeVc93/iQLjfACHiilhb9lFo egp5JVDPchRcJJPrPdPOKS8TUq79hai7H6GjiQTyIXg3BHeS8RqIN+w9aUty1by83AzC TOTtt49THSr7cx7Kclu+n9dH9P8/YOk/nhLok= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:mime-version:subject:message-id:date:to; bh=POa4TeCrCq3AKPkS0V/TBHCRP3Msd+cE9xssY9nI58Q=; b=NwuqsL7iyUjHrFoJKiMQHMapvxsGvaEHsSZ15nhcItakk6LIPAgFgT6VI14ZwysZ/j Wv3pbpGsW0P945LLwlTdk7KIyhyttGgKc/j5OThEv+ciPiQldyYg/NFTfY+euaWGwAZj gN7MxnvrpE6NFzTGP7kaNvACyN3kT1Y3kI8vDYHc+ub74lXO9EEMpFkidMg6vYeefemZ YHdfLURBDg63RLF0tuwPu19aFIbLXxCXEZG87RxtXoNg3akyKLJXaBbPR4SwL8fcv9mK XTTsG7V4blvPJFUjAYAVqWLWqcjasHCwja+G26pYYc6/fzIgkVu6oTPJX0aRLQzkHm5H zp3A== X-Gm-Message-State: AOAM5304maCax1RLoXEnUNAF81EFBAdC/glnlcf/WD+L4k54kqmC9jWn E30BQ4cEOVEYGekxV+cHM+ldu1Y9b8ggPg== X-Google-Smtp-Source: ABdhPJzMsxw9sYip6zNp0ok8Xe5v/i5eJlKRNd6AcOCQ1LgNo+bqad2xu9nfgbHZI9GvnC2RGUKndA== X-Received: by 2002:a63:6cb:0:b0:36c:e2d:8857 with SMTP id 194-20020a6306cb000000b0036c0e2d8857mr3047745pgg.214.1645116763605; Thu, 17 Feb 2022 08:52:43 -0800 (PST) Received: from smtpclient.apple ([2601:646:101:7fda:cdc2:b45d:7f7:b9ed]) by smtp.gmail.com with ESMTPSA id u2sm187400pfk.15.2022.02.17.08.52.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Feb 2022 08:52:43 -0800 (PST) From: Bryn Llewellyn Content-Type: multipart/alternative; boundary="Apple-Mail=_DFAFFA91-43D7-41DB-95DC-5309E61DE2F6" Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Subject: alter function/procedure depends on extension Message-Id: <7C2D01B4-AD32-48DB-B5FA-6FFBC312ECB2@yugabyte.com> Date: Thu, 17 Feb 2022 08:52:40 -0800 To: pgsql-general list X-Mailer: Apple Mail (2.3654.120.0.1.13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_DFAFFA91-43D7-41DB-95DC-5309E61DE2F6 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 *Briefly* qu. 1. What is the use-case for "alter function/procedure depends on = extension"? After all, subprograms depend, functionally, on all sorts of things. But = (unlike in Oracle Database) there=E2=80=99s (almost) no semantic check = at =E2=80=9Ccreate=E2=80=9D time and therefore nothing like the = semantics that ORCL=E2=80=99s "DBA_Dependencies" exposes. Rather, if = some semantic dependency parent doesn=E2=80=99t exist, then you might = get a run-time error=E2=80=94depending on whether the execution path = tries to use it. Moreover, on such an error, the persisted source code = remains in place so that if you create the missing dependency parent, = then the dependant will then just work. It would seem that this same = run-time error model that was designed for schema objects would be a = good choice for extensions too. And you get this model, anyway, by = default. What is the argument for overriding the default behavior by = using "alter function/procedure"? qu. 2. Why does "drop extension restrict" quietly succeed=E2=80=94having = the effect of cascade-dropping any subprogram that you've altered to = depend on the extension in question? This is at odds with the documented = meaning of "restrict". qu. 3. I established by experiment that you can repeat "alter = function/procedure depends on extension" time and again for the same = subprogram to make it depend on lots of extensions. And I checked that = dropping any one of the extensions nominated this way is enough to = cascade-drop the dependent subprogram. Why, then, is there no list = syntax like this: alter function s.f() depends on extension tablefunc, fuzzystrmatch; Trying it causes the generic 42601 syntax error at the comma. *More detail* "Chapter 52. System Catalogs" gave me what I needed to list out what = functions depend on what extensions. But the approach that I used was = straight Codd-and-Date: an intersection table between the procedures = table and the extensions table. qu. 4. Why the asymmetry of approach with the way that, for example, the = many execute-grantees for a procedure are represented as an array, = Stonebraker-object-relational-style, in the procedures table? (It's the = same, too, for the list of session parameter settings that "alter = function/procedure... set=E2=80=A6" establishes. (Here, you _can_ set = many different parameters with a single "alter".) Just for completeness, this query (after my setup): select p.proname::text, p.pronamespace::regnamespace::text, e.extname from pg_catalog.pg_proc p inner join pg_catalog.pg_depend d on p.oid =3D d.objid inner join pg_catalog.pg_extension e on d.refobjid =3D e.oid where p.proname::text in ('a', 'b', 'c') and p.pronamespace::regnamespace::text =3D 's' order by 1, 2, 3; produced this result: proname | pronamespace | extname =20 ---------+--------------+--------------- a | s | tablefunc b | s | fuzzystrmatch c | s | fuzzystrmatch c | s | tablefunc just as I expected. --Apple-Mail=_DFAFFA91-43D7-41DB-95DC-5309E61DE2F6 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
*Briefly*

qu. 1. What is the use-case for "alter = function/procedure depends on extension"?

After all, subprograms depend, = functionally, on all sorts of things. But (unlike in Oracle Database) = there=E2=80=99s (almost) no semantic check at =E2=80=9Ccreate=E2=80=9D = time and therefore nothing like the semantics that ORCL=E2=80=99s = "DBA_Dependencies" exposes. Rather, if some semantic dependency parent = doesn=E2=80=99t exist, then you might get a run-time error=E2=80=94dependi= ng on whether the execution path tries to use it. Moreover, on such an = error, the persisted source code remains in place so that if you create = the missing dependency parent, then the dependant will then just work. = It would seem that this same run-time error model that was designed for = schema objects would be a good choice for extensions too. And you get = this model, anyway, by default. What is the argument for overriding the = default behavior by using "alter function/procedure"?

qu. = 2. Why does "drop extension restrict" quietly succeed=E2=80=94hav= ing the effect of cascade-dropping any subprogram that you've altered to = depend on the extension in question? This is at odds with the documented = meaning of "restrict".

qu. 3. I established by experiment that you = can repeat "alter function/procedure depends on extension" time and = again for the same subprogram to make it depend on lots of extensions. = And I checked that dropping any one of the extensions nominated this way = is enough to cascade-drop the dependent subprogram. Why, then, is there = no list syntax like this:

alter function s.f() depends on extension tablefunc, = fuzzystrmatch;

Trying it causes the generic 42601 = syntax error at the comma.

*More detail*

"Chapter 52. System Catalogs" gave me = what I needed to list out what functions depend on what extensions. But = the approach that I used was straight Codd-and-Date: an intersection = table between the procedures table and the extensions table.

qu. = 4. Why the asymmetry of approach with the way that, for = example, the many execute-grantees for a procedure are represented as an = array, Stonebraker-object-relational-style, in the procedures table? = (It's the same, too, for the list of session parameter settings that = "alter function/procedure... set=E2=80=A6" establishes. (Here, you _can_ = set many different parameters with a single "alter".)

Just for completeness, = this query (after my setup):

select
  p.proname::text,
  p.pronamespace::regnamespace::text,
  e.extname
from
  pg_catalog.pg_proc p
  inner join
  pg_catalog.pg_depend d
  on= p.oid =3D d.objid
  inner join
  pg_catalog.pg_extension e
  on d.refobjid =3D e.oid
where
  p.proname::text in ('a', 'b', 'c') and
  p.pronamespace::regnamespace::text =3D 's'
order by 1, 2, 3;


produced this result:

 proname | pronamespace |  =   extname    
---------+--------------+---------------
 a       | s    =         | tablefunc
 b       | s    =         | fuzzystrmatch
 c       | s    =         | fuzzystrmatch
 c       | s    =         | tablefunc

just as I = expected.


= --Apple-Mail=_DFAFFA91-43D7-41DB-95DC-5309E61DE2F6--