RE: Scripting a ALTER PROCEDURE or FUNCTION to Change OWNER

From: <lennam(at)incisivetechgroup(dot)com>
To: "'David G(dot) Johnston'" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: "'PABLO ANDRES IBARRA DUPRAT'" <Pablo(dot)Ibarra(at)itau(dot)cl>, <pgsql-admin(at)lists(dot)postgresql(dot)org>
Subject: RE: Scripting a ALTER PROCEDURE or FUNCTION to Change OWNER
Date: 2024-06-18 20:31:27
Message-ID: 002f01dac1be$7fab9830$7f02c890$@incisivetechgroup.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

I provided the scripts , use , how ever you like

From: David G. Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
Sent: Tuesday, June 18, 2024 4:23 PM
To: lennam(at)incisivetechgroup(dot)com
Cc: PABLO ANDRES IBARRA DUPRAT <Pablo(dot)Ibarra(at)itau(dot)cl>; pgsql-admin(at)lists(dot)postgresql(dot)org
Subject: Re: Scripting a ALTER PROCEDURE or FUNCTION to Change OWNER

On Tue, Jun 18, 2024 at 12:58 PM <lennam(at)incisivetechgroup(dot)com <mailto:lennam(at)incisivetechgroup(dot)com> > wrote:

Following scripts will take care to change schema owner

Mk_altr_proc_owner.sql ( copy past this SQL statement)

SELECT ' alter procedure '||rtrim(nspname)||'.'||ltrim( proname )||' owner to targetschema;'

Maybe using quote_ident to prevent, unlikely as it may be, SQL injection issues. The trims seem likely to be unnecessary - catalog contents should be clean.

Psql -h hostname -U ursename -d dbname -t -A -f mk_altr_proc_owner.sql -o altr_proc_owner.sql

The script output file is nice to check one's works I guess. But if you are going to use psql there is the \gexec meta-command that makes this even easier.

David J.

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message David G. Johnston 2024-06-18 20:34:37 Re: Scripting a ALTER PROCEDURE or FUNCTION to Change OWNER
Previous Message Ron Johnson 2024-06-18 20:28:48 Re: Scripting a ALTER PROCEDURE or FUNCTION to Change OWNER