pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rory Campbell-Lange <rory@campbell-lange.net>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: Guyren Howe <guyren@gmail.com>
Cc: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: PG-General Mailing List <pgsql-general@postgresql.org>
Subject: Re: Advice request : simultaneous function/data updates on many databases
Date: Wed, 4 Mar 2020 23:41:59 +0000
Message-ID: <20200304234159.GA14088@campbell-lange.net> (raw)
In-Reply-To: <CAKFQuwZh-2pfr73XNUXg9CJtSDaVbiTOJYF4Dbre_6vs-JjcMA@mail.gmail.com>
References: <20200304220426.GB7232@campbell-lange.net>
	<7ce9074f-0468-1cc8-3337-018b66e56679@aklaver.com>
	<20200304222257.GA11376@campbell-lange.net>
	<42b4d82b-d468-3f9e-c021-c20bcc141245@aklaver.com>
	<20200304223342.GA11628@campbell-lange.net>
	<E34FAEFC-8F73-4AFF-966B-4E067CC78A34@gmail.com>
	<20200304224843.GA12333@campbell-lange.net>
	<CAKFQuwZ8DCJu9BYckq3AocCP3rkX-g=VvDLON2qnisBnOgofxQ@mail.gmail.com>
	<CAKFQuwZh-2pfr73XNUXg9CJtSDaVbiTOJYF4Dbre_6vs-JjcMA@mail.gmail.com>

On 04/03/20, David G. Johnston (david.g.johnston@gmail.com) wrote:
> On Wed, Mar 4, 2020 at 3:55 PM David G. Johnston <david.g.johnston@gmail.com>
> wrote:
> 
> > On Wed, Mar 4, 2020 at 3:48 PM Rory Campbell-Lange <
> > rory@campbell-lange.net> wrote:
> >
> >> Any thoughts on how to wrap pl/pgsql function dropping and recreation code
> >> within a wrapper pl/pgsql function?
> >
> >
> > Not endorsing this but dynamic SQL works just fine (though can get hard to
> > read).  Use format() and EXECUTE ... USING liberally.
> >
> >
> Or, more readable depending upon your trust level:
> 
> INSERT INTO dynamic_codes VALUES (1, 'DROP FUNCTION ...');
> 
> CREATE FUNCTION execute_dynamic(code_id int)
> AS $$
> sql_cmd := (SELECT val FROM dynamic_codes WHERE id = code_id);
> EXECUTE sql_cmd;
> $$;
> 
> SELECT execute_dynamic(1);

Thanks very much for the useful examples.

Based on your second example, we could drop and then reload a upgrade
schema with entries in dynamic_codes then use execute_dynamic(...) as
you suggest.

Any idea on how to run execute_dynamic across many databases at roughly
the same time?

I'm just wondering if Guyren Howe's idea of having many transactions
open waiting for a clock time to commit is in fact feasible due to
(presumably) having to have all the connections open to every database
from the client until the transactions complete.






view thread (18+ messages)  latest in thread

Message-ID: <20200304234159.GA14088@campbell-lange.net>
Permalink:  ../20200304234159.GA14088@campbell-lange.net/
Also on:    postgresql.org/message-id/20200304234159.GA14088@campbell-lange.net

 · 

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: rory@campbell-lange.net, david.g.johnston@gmail.com, guyren@gmail.com, adrian.klaver@aklaver.com
  Subject: Re: Advice request : simultaneous function/data updates on many databases
  In-Reply-To: <20200304234159.GA14088@campbell-lange.net>
  References: <20200304220426.GB7232@campbell-lange.net> <7ce9074f-0468-1cc8-3337-018b66e56679@aklaver.com> <20200304222257.GA11376@campbell-lange.net> <42b4d82b-d468-3f9e-c021-c20bcc141245@aklaver.com> <20200304223342.GA11628@campbell-lange.net> <E34FAEFC-8F73-4AFF-966B-4E067CC78A34@gmail.com> <20200304224843.GA12333@campbell-lange.net> <CAKFQuwZ8DCJu9BYckq3AocCP3rkX-g=VvDLON2qnisBnOgofxQ@mail.gmail.com> <CAKFQuwZh-2pfr73XNUXg9CJtSDaVbiTOJYF4Dbre_6vs-JjcMA@mail.gmail.com> <20200304234159.GA14088@campbell-lange.net>

* 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