Re: Scripting a ALTER PROCEDURE or FUNCTION to Change OWNER - Mailing list pgsql-admin

From David G. Johnston
Subject Re: Scripting a ALTER PROCEDURE or FUNCTION to Change OWNER
Date
Msg-id CAKFQuwbtpXWGjyi_6qmi3a1-j7kLKvkPpha2_QqjTSK71K9JEQ@mail.gmail.com
Whole thread Raw
In response to RE: Scripting a ALTER PROCEDURE or FUNCTION to Change OWNER  ("Vitale, Anthony, Sony Music" <anthony.vitale@sonymusic.com>)
List pgsql-admin
On Tue, Jun 18, 2024 at 3:02 PM Vitale, Anthony, Sony Music <anthony.vitale@sonymusic.com> wrote:
I would this this is what you are looking for

For loops and SQL injection risks, not an ideal way to write SQL programs.  Though it does allow you to avoid using psql but in which case you need to do away with the \set metacommands.  If you are going to use psql I strongly suggest running the select query, inspecting the results, then changing said query to use \gexec.  A lot fewer moving parts that dealing with plpgsql.

Good call on making it dynamic on prokind though.  And the owner matching.

Tom's got the right idea of just casting the OID for the main naming scheme - it does the SQL injection mitigation.

David J.

pgsql-admin by date:

Previous
From:
Date:
Subject: RE: Materialized views & dead tuples
Next
From: Achilleas Mantzios
Date:
Subject: Re: Statement_timeout in procedure block