pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bryn Llewellyn <bryn@yugabyte.com>
To: pgsql-general list <pgsql-general@lists.postgresql.org>
Subject: alter function/procedure depends on extension
Date: Thu, 17 Feb 2022 08:52:40 -0800
Message-ID: <7C2D01B4-AD32-48DB-B5FA-6FFBC312ECB2@yugabyte.com> (raw)

*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’s (almost) no semantic check at “create” time and therefore nothing like the semantics that ORCL’s "DBA_Dependencies" exposes. Rather, if some semantic dependency parent doesn’t exist, then you might get a run-time error—depending 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—having 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…" 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 = d.objid
  inner join
  pg_catalog.pg_extension e
  on d.refobjid = e.oid
where
  p.proname::text in ('a', 'b', 'c') and
  p.pronamespace::regnamespace::text = '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.

view thread (18+ messages)  latest in thread

Message-ID: <7C2D01B4-AD32-48DB-B5FA-6FFBC312ECB2@yugabyte.com>
Permalink:  ../7C2D01B4-AD32-48DB-B5FA-6FFBC312ECB2@yugabyte.com/
Also on:    postgresql.org/message-id/7C2D01B4-AD32-48DB-B5FA-6FFBC312ECB2@yugabyte.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: bryn@yugabyte.com
  Subject: Re: alter function/procedure depends on extension
  In-Reply-To: <7C2D01B4-AD32-48DB-B5FA-6FFBC312ECB2@yugabyte.com>
  References: <7C2D01B4-AD32-48DB-B5FA-6FFBC312ECB2@yugabyte.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox