Re: Scripting a ALTER PROCEDURE or FUNCTION to Change OWNER

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: "Vitale, Anthony, Sony Music" <anthony(dot)vitale(at)sonymusic(dot)com>
Cc: PABLO ANDRES IBARRA DUPRAT <Pablo(dot)Ibarra(at)itau(dot)cl>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-admin(at)lists(dot)postgresql(dot)org" <pgsql-admin(at)lists(dot)postgresql(dot)org>
Subject: Re: Scripting a ALTER PROCEDURE or FUNCTION to Change OWNER
Date: 2024-06-18 23:45:55
Message-ID: CAKFQuwbtpXWGjyi_6qmi3a1-j7kLKvkPpha2_QqjTSK71K9JEQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Tue, Jun 18, 2024 at 3:02 PM Vitale, Anthony, Sony Music <
anthony(dot)vitale(at)sonymusic(dot)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.

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Achilleas Mantzios 2024-06-19 04:14:54 Re: Statement_timeout in procedure block
Previous Message lennam 2024-06-18 22:38:03 RE: Materialized views & dead tuples