pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Unexpected behavior with transition tables in update statement trigger
9+ messages / 3 participants
[nested] [flat]

Commits from this thread:
  2018-02-27 e98a4de7d2 b9dac4a6eb  Use the correct tuplestore read pointer in a NamedTuplestoreScan.
* Unexpected behavior with transition tables in update statement trigger
@ 2018-02-24 03:47 Tom Kazimiers <tom@voodoo-arts.net>
  2018-02-26 10:15 ` Re: Unexpected behavior with transition tables in update statement trigger Thomas Munro <thomas.munro@enterprisedb.com>
  0 siblings, 1 reply; 9+ messages in thread

From: Tom Kazimiers @ 2018-02-24 03:47 UTC (permalink / raw)
  To: pgsql-general

Hi all,

I am on Postgres 10.2 and try to get a statement level trigger to work 
that is executed after UPDATE statements on a particular table. This 
trigger references both the old and new transition table and for some 
reason I am unable to reference each transition table multiple times in 
a CTE or subquery. E.g. forming a UNION ALL with all rows of the new 
transition table with itself, does only use the new table row once. I 
don't understand why and would appreciate some insight.

My problem is probably better described with some SQL, so here is a 
little test setup:

  CREATE TABLE test (id  serial, data int);
  INSERT INTO test VALUES (0, 1);

  CREATE OR REPLACE FUNCTION on_edit() RETURNS trigger
  LANGUAGE plpgsql AS
  $$
  DECLARE
  tmp text;
  BEGIN
      WITH test AS (
          SELECT row_to_json(a)::text FROM new_test a
          UNION ALL
          SELECT '----'
          UNION ALL
          SELECT row_to_json(b)::text FROM new_test b
      )
      SELECT array_to_string(array(SELECT row_to_json(t)::text FROM test t), ', ')::text INTO tmp;

      PERFORM pg_notify('update', tmp::text);

      WITH test AS (
          SELECT row_to_json(a)::text FROM new_test a
          UNION ALL
          SELECT '----'
          UNION ALL
          SELECT row_to_json(b)::text FROM old_test b
      )
      SELECT array_to_string(array(SELECT row_to_json(t)::text FROM test t), ', ')::text INTO tmp;

      PERFORM pg_notify('update', tmp::text);

      RETURN NEW;
  END;
  $$;

  CREATE TRIGGER on_edit AFTER UPDATE ON test
  REFERENCING NEW TABLE AS new_test OLD TABLE as old_test
  FOR EACH STATEMENT EXECUTE PROCEDURE on_edit();

  LISTEN update;

  UPDATE test SET data = 2;

This will create a new table test with one entry, adds the statement 
level trigger, registers a NOTIFY listener and updates the table. The 
trigger will first NOTIFY the result of a UNION ALL with the new 
transition table with itself. The second NOTIFY has the result of the 
UNION ALL with the new and old transition tables as payload. This is the 
output:

  Asynchronous notification "update" with payload "{"id":0,"data":2}, ----" received from server process with PID 6695.
  Asynchronous notification "update" with payload "{"id":0,"data":2}, ----, {"id":0,"data":1}" received from server process with PID 6695.

I would have expected the first line to be

  Asynchronous notification "update" with payload "{"id":0,"data":2}, ----, {"id":0,"data":2}" received from server process with PID 6695.

Why isn't it? It's the same result with a subquery. What do I overlook 
here?

Cheers,
Tom




^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Unexpected behavior with transition tables in update statement trigger
  2018-02-24 03:47 Unexpected behavior with transition tables in update statement trigger Tom Kazimiers <tom@voodoo-arts.net>
@ 2018-02-26 10:15 ` Thomas Munro <thomas.munro@enterprisedb.com>
  2018-02-26 15:18   ` Re: Unexpected behavior with transition tables in update statement trigger Tom Kazimiers <tom@voodoo-arts.net>
  0 siblings, 1 reply; 9+ messages in thread

From: Thomas Munro @ 2018-02-26 10:15 UTC (permalink / raw)
  To: Tom Kazimiers <tom@voodoo-arts.net>; +Cc: pgsql-general

On Sat, Feb 24, 2018 at 4:47 PM, Tom Kazimiers <tom@voodoo-arts.net> wrote:
> I am on Postgres 10.2 and try to get a statement level trigger to work that
> is executed after UPDATE statements on a particular table. This trigger
> references both the old and new transition table and for some reason I am
> unable to reference each transition table multiple times in a CTE or
> subquery. E.g. forming a UNION ALL with all rows of the new transition table
> with itself, does only use the new table row once. I don't understand why
> and would appreciate some insight.

Thanks for the reproducer.  Yeah, that seems to be a bug.
nodeNamedTuplestorescan.c allocates a new read pointer for each
separate scan of the named tuplestore, but it doesn't call
tuplestore_select_read_pointer() so that the two scans that appear in
your UNION ALL plan are sharing the same read pointer.  At first
glance the attached seems to fix the problem, but I'll need to look
more carefully tomorrow.

-- 
Thomas Munro
http://www.enterprisedb.com

Attachments:

named-tuplestore-scan-select.patch (application/octet-stream, 593B) download diff --git a/src/backend/executor/nodeNamedtuplestorescan.c b/src/backend/executor/nodeNamedtuplestorescan.c index 4d898b1f83e..fca48c16065 100644 --- a/src/backend/executor/nodeNamedtuplestorescan.c +++ b/src/backend/executor/nodeNamedtuplestorescan.c @@ -40,6 +40,7 @@ NamedTuplestoreScanNext(NamedTuplestoreScanState *node) * Get the next tuple from tuplestore. Return NULL if no more tuples. */ slot = node->ss.ss_ScanTupleSlot; + tuplestore_select_read_pointer(node->relation, node->readptr); (void) tuplestore_gettupleslot(node->relation, true, false, slot); return slot; }
^ permalink raw reply [nested|flat] 9+ messages in thread

* Re: Unexpected behavior with transition tables in update statement trigger
  2018-02-24 03:47 Unexpected behavior with transition tables in update statement trigger Tom Kazimiers <tom@voodoo-arts.net>
  2018-02-26 10:15 ` Re: Unexpected behavior with transition tables in update statement trigger Thomas Munro <thomas.munro@enterprisedb.com>
@ 2018-02-26 15:18   ` Tom Kazimiers <tom@voodoo-arts.net>
  2018-02-27 01:52     ` Re: Unexpected behavior with transition tables in update statement trigger Thomas Munro <thomas.munro@enterprisedb.com>
  0 siblings, 1 reply; 9+ messages in thread

From: Tom Kazimiers @ 2018-02-26 15:18 UTC (permalink / raw)
  To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: pgsql-general

Hi Thomas,

On Mon, Feb 26, 2018 at 11:15:44PM +1300, Thomas Munro wrote:
>On Sat, Feb 24, 2018 at 4:47 PM, Tom Kazimiers <tom@voodoo-arts.net> wrote:
>Thanks for the reproducer.  Yeah, that seems to be a bug.
>nodeNamedTuplestorescan.c allocates a new read pointer for each
>separate scan of the named tuplestore, but it doesn't call
>tuplestore_select_read_pointer() so that the two scans that appear in
>your UNION ALL plan are sharing the same read pointer.  At first
>glance the attached seems to fix the problem, but I'll need to look
>more carefully tomorrow.

Thanks very much for investigating this. I can confirm that applying 
your patch results in the tuples I expected in both my test trigger and 
my actual trigger function.

It would be great if this or a similar fix would make it into the next 
official release.

Cheers,
Tom




^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Unexpected behavior with transition tables in update statement trigger
  2018-02-24 03:47 Unexpected behavior with transition tables in update statement trigger Tom Kazimiers <tom@voodoo-arts.net>
  2018-02-26 10:15 ` Re: Unexpected behavior with transition tables in update statement trigger Thomas Munro <thomas.munro@enterprisedb.com>
  2018-02-26 15:18   ` Re: Unexpected behavior with transition tables in update statement trigger Tom Kazimiers <tom@voodoo-arts.net>
@ 2018-02-27 01:52     ` Thomas Munro <thomas.munro@enterprisedb.com>
  2018-02-27 20:08       ` Re: Unexpected behavior with transition tables in update statement trigger Tom Kazimiers <tom@voodoo-arts.net>
  2018-02-27 20:58       ` Re: Unexpected behavior with transition tables in update statement trigger Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 2 replies; 9+ messages in thread

From: Thomas Munro @ 2018-02-27 01:52 UTC (permalink / raw)
  To: Tom Kazimiers <tom@voodoo-arts.net>; Pg Hackers <pgsql-hackers@postgresql.org>; +Cc: pgsql-general

On Tue, Feb 27, 2018 at 4:18 AM, Tom Kazimiers <tom@voodoo-arts.net> wrote:
> On Mon, Feb 26, 2018 at 11:15:44PM +1300, Thomas Munro wrote:
>> On Sat, Feb 24, 2018 at 4:47 PM, Tom Kazimiers <tom@voodoo-arts.net>
>> wrote:
>> Thanks for the reproducer.  Yeah, that seems to be a bug.
>> nodeNamedTuplestorescan.c allocates a new read pointer for each
>> separate scan of the named tuplestore, but it doesn't call
>> tuplestore_select_read_pointer() so that the two scans that appear in
>> your UNION ALL plan are sharing the same read pointer.  At first
>> glance the attached seems to fix the problem, but I'll need to look
>> more carefully tomorrow.
>
> Thanks very much for investigating this. I can confirm that applying your
> patch results in the tuples I expected in both my test trigger and my actual
> trigger function.

Thanks for testing.

> It would be great if this or a similar fix would make it into the next
> official release.

Here's a new version with tuplestore_select_read_pointer() added in
another place where it was lacking, and commit message.  Moving to
-hackers, where patches go.

Here's a shorter repro.  On master it prints:

NOTICE:  count = 1
NOTICE:  count union = 1

With the patch the second number is 2, as it should be.

CREATE TABLE test (i int);
INSERT INTO test VALUES (1);

CREATE OR REPLACE FUNCTION my_trigger_fun() RETURNS trigger
LANGUAGE plpgsql AS
$$
  BEGIN
     RAISE NOTICE 'count = %', (SELECT COUNT(*) FROM new_test);
     RAISE NOTICE 'count union = %', (SELECT COUNT(*)
          FROM (SELECT * FROM new_test UNION ALL SELECT * FROM new_test) ss);
     RETURN NULL;
 END;
$$;

CREATE TRIGGER my_trigger AFTER UPDATE ON test
REFERENCING NEW TABLE AS new_test OLD TABLE as old_test
FOR EACH STATEMENT EXECUTE PROCEDURE my_trigger_fun();

UPDATE test SET i = i;

-- 
Thomas Munro
http://www.enterprisedb.com

Attachments:

0001-Fix-tuplestore-read-pointer-confusion-in-nodeNamedtu.patch (application/octet-stream, 1.7K) download From e16ff2f63cecbd4cb823d9d838717d8bb52b8a65 Mon Sep 17 00:00:00 2001 From: Thomas Munro <thomas.munro@enterprisedb.com> Date: Tue, 27 Feb 2018 14:25:43 +1300 Subject: [PATCH] Fix tuplestore read pointer confusion in nodeNamedtuplestorescan.c. Tom Kazimiers discovered that transition tables don't work correctly when they are scanned by more than one executor node. That's because commit 18ce3a4a allocated separate read pointers for each executor node as it should but failed to make them active at the appropriate times. Repair. Author: Thomas Munro Reported-By: Tom Kazimiers Discussion: https://postgr.es/m/20180224034748.bixarv6632vbxgeb%40dewberry.localdomain --- src/backend/executor/nodeNamedtuplestorescan.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/backend/executor/nodeNamedtuplestorescan.c b/src/backend/executor/nodeNamedtuplestorescan.c index 4d898b1f83..b260ad2594 100644 --- a/src/backend/executor/nodeNamedtuplestorescan.c +++ b/src/backend/executor/nodeNamedtuplestorescan.c @@ -40,6 +40,7 @@ NamedTuplestoreScanNext(NamedTuplestoreScanState *node) * Get the next tuple from tuplestore. Return NULL if no more tuples. */ slot = node->ss.ss_ScanTupleSlot; + tuplestore_select_read_pointer(node->relation, node->readptr); (void) tuplestore_gettupleslot(node->relation, true, false, slot); return slot; } @@ -116,6 +117,7 @@ ExecInitNamedTuplestoreScan(NamedTuplestoreScan *node, EState *estate, int eflag * The new read pointer copies its position from read pointer 0, which * could be anywhere, so explicitly rewind it. */ + tuplestore_select_read_pointer(scanstate->relation, scanstate->readptr); tuplestore_rescan(scanstate->relation); /* -- 2.15.1
^ permalink raw reply [nested|flat] 9+ messages in thread

* Re: Unexpected behavior with transition tables in update statement trigger
  2018-02-24 03:47 Unexpected behavior with transition tables in update statement trigger Tom Kazimiers <tom@voodoo-arts.net>
  2018-02-26 10:15 ` Re: Unexpected behavior with transition tables in update statement trigger Thomas Munro <thomas.munro@enterprisedb.com>
  2018-02-26 15:18   ` Re: Unexpected behavior with transition tables in update statement trigger Tom Kazimiers <tom@voodoo-arts.net>
  2018-02-27 01:52     ` Re: Unexpected behavior with transition tables in update statement trigger Thomas Munro <thomas.munro@enterprisedb.com>
@ 2018-02-27 20:08       ` Tom Kazimiers <tom@voodoo-arts.net>
  1 sibling, 0 replies; 9+ messages in thread

From: Tom Kazimiers @ 2018-02-27 20:08 UTC (permalink / raw)
  To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Pg Hackers <pgsql-hackers@postgresql.org>

On Tue, Feb 27, 2018 at 02:52:02PM +1300, Thomas Munro wrote:
>On Tue, Feb 27, 2018 at 4:18 AM, Tom Kazimiers <tom@voodoo-arts.net> wrote:
>> It would be great if this or a similar fix would make it into the 
>> next official release.
>
>Here's a new version with tuplestore_select_read_pointer() added in
>another place where it was lacking, and commit message.  Moving to
>-hackers, where patches go.

Thanks and just to confirm the obvious: the new patch still fixes this 
bug in both my test trigger function and my real trigger function.

>Here's a shorter repro.  On master it prints:
>
>NOTICE:  count = 1
>NOTICE:  count union = 1
>
>With the patch the second number is 2, as it should be.
>
>CREATE TABLE test (i int);
>INSERT INTO test VALUES (1);
>
>CREATE OR REPLACE FUNCTION my_trigger_fun() RETURNS trigger
>LANGUAGE plpgsql AS
>$$
>  BEGIN
>     RAISE NOTICE 'count = %', (SELECT COUNT(*) FROM new_test);
>     RAISE NOTICE 'count union = %', (SELECT COUNT(*)
>          FROM (SELECT * FROM new_test UNION ALL SELECT * FROM new_test) ss);
>     RETURN NULL;
> END;
>$$;
>
>CREATE TRIGGER my_trigger AFTER UPDATE ON test
>REFERENCING NEW TABLE AS new_test OLD TABLE as old_test
>FOR EACH STATEMENT EXECUTE PROCEDURE my_trigger_fun();
>
>UPDATE test SET i = i;

That's a much cleaner repro (and test case I suppose), thanks.

Tom




^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Unexpected behavior with transition tables in update statement trigger
  2018-02-24 03:47 Unexpected behavior with transition tables in update statement trigger Tom Kazimiers <tom@voodoo-arts.net>
  2018-02-26 10:15 ` Re: Unexpected behavior with transition tables in update statement trigger Thomas Munro <thomas.munro@enterprisedb.com>
  2018-02-26 15:18   ` Re: Unexpected behavior with transition tables in update statement trigger Tom Kazimiers <tom@voodoo-arts.net>
  2018-02-27 01:52     ` Re: Unexpected behavior with transition tables in update statement trigger Thomas Munro <thomas.munro@enterprisedb.com>
@ 2018-02-27 20:58       ` Tom Lane <tgl@sss.pgh.pa.us>
  2018-02-27 21:27         ` Re: Unexpected behavior with transition tables in update statement trigger Thomas Munro <thomas.munro@enterprisedb.com>
  2018-02-27 21:40         ` Re: Unexpected behavior with transition tables in update statement trigger Tom Kazimiers <tom@voodoo-arts.net>
  1 sibling, 2 replies; 9+ messages in thread

From: Tom Lane @ 2018-02-27 20:58 UTC (permalink / raw)
  To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Tom Kazimiers <tom@voodoo-arts.net>; Pg Hackers <pgsql-hackers@postgresql.org>; pgsql-general

Thomas Munro <thomas.munro@enterprisedb.com> writes:
> Here's a new version with tuplestore_select_read_pointer() added in
> another place where it was lacking, and commit message.  Moving to
> -hackers, where patches go.

Pushed, along with a regression test based on your example.
Unfortunately, this came in a bit too late for this week's releases :-(

			regards, tom lane




^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Unexpected behavior with transition tables in update statement trigger
  2018-02-24 03:47 Unexpected behavior with transition tables in update statement trigger Tom Kazimiers <tom@voodoo-arts.net>
  2018-02-26 10:15 ` Re: Unexpected behavior with transition tables in update statement trigger Thomas Munro <thomas.munro@enterprisedb.com>
  2018-02-26 15:18   ` Re: Unexpected behavior with transition tables in update statement trigger Tom Kazimiers <tom@voodoo-arts.net>
  2018-02-27 01:52     ` Re: Unexpected behavior with transition tables in update statement trigger Thomas Munro <thomas.munro@enterprisedb.com>
  2018-02-27 20:58       ` Re: Unexpected behavior with transition tables in update statement trigger Tom Lane <tgl@sss.pgh.pa.us>
@ 2018-02-27 21:27         ` Thomas Munro <thomas.munro@enterprisedb.com>
  2018-02-27 22:54           ` Re: Unexpected behavior with transition tables in update statement trigger Tom Kazimiers <tom@voodoo-arts.net>
  1 sibling, 1 reply; 9+ messages in thread

From: Thomas Munro @ 2018-02-27 21:27 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Tom Kazimiers <tom@voodoo-arts.net>; Pg Hackers <pgsql-hackers@postgresql.org>; pgsql-general

On Wed, Feb 28, 2018 at 9:58 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Thomas Munro <thomas.munro@enterprisedb.com> writes:
>> Here's a new version with tuplestore_select_read_pointer() added in
>> another place where it was lacking, and commit message.  Moving to
>> -hackers, where patches go.
>
> Pushed, along with a regression test based on your example.
> Unfortunately, this came in a bit too late for this week's releases :-(

Thanks!

Tom K, if you need a workaround before 10.4 comes out in May[1], you
could try selecting the whole transition table into a CTE up front.
Something like WITH my_copy AS (SELECT * FROM new_table) SELECT * FROM
my_copy UNION ALL SELECT * FROM my_copy should work.

[1] https://www.postgresql.org/developer/roadmap/

-- 
Thomas Munro
http://www.enterprisedb.com




^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Unexpected behavior with transition tables in update statement trigger
  2018-02-24 03:47 Unexpected behavior with transition tables in update statement trigger Tom Kazimiers <tom@voodoo-arts.net>
  2018-02-26 10:15 ` Re: Unexpected behavior with transition tables in update statement trigger Thomas Munro <thomas.munro@enterprisedb.com>
  2018-02-26 15:18   ` Re: Unexpected behavior with transition tables in update statement trigger Tom Kazimiers <tom@voodoo-arts.net>
  2018-02-27 01:52     ` Re: Unexpected behavior with transition tables in update statement trigger Thomas Munro <thomas.munro@enterprisedb.com>
  2018-02-27 20:58       ` Re: Unexpected behavior with transition tables in update statement trigger Tom Lane <tgl@sss.pgh.pa.us>
  2018-02-27 21:27         ` Re: Unexpected behavior with transition tables in update statement trigger Thomas Munro <thomas.munro@enterprisedb.com>
@ 2018-02-27 22:54           ` Tom Kazimiers <tom@voodoo-arts.net>
  0 siblings, 0 replies; 9+ messages in thread

From: Tom Kazimiers @ 2018-02-27 22:54 UTC (permalink / raw)
  To: Thomas Munro <thomas.munro@enterprisedb.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Pg Hackers <pgsql-hackers@postgresql.org>; pgsql-general

On Wed, Feb 28, 2018 at 10:27:23AM +1300, Thomas Munro wrote:
>Tom K, if you need a workaround before 10.4 comes out in May[1], you
>could try selecting the whole transition table into a CTE up front.
>Something like WITH my_copy AS (SELECT * FROM new_table) SELECT * FROM
>my_copy UNION ALL SELECT * FROM my_copy should work.
>
>[1] https://www.postgresql.org/developer/roadmap/

Thanks, that's what I am going to do.

Cheers,
Tom




^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: Unexpected behavior with transition tables in update statement trigger
  2018-02-24 03:47 Unexpected behavior with transition tables in update statement trigger Tom Kazimiers <tom@voodoo-arts.net>
  2018-02-26 10:15 ` Re: Unexpected behavior with transition tables in update statement trigger Thomas Munro <thomas.munro@enterprisedb.com>
  2018-02-26 15:18   ` Re: Unexpected behavior with transition tables in update statement trigger Tom Kazimiers <tom@voodoo-arts.net>
  2018-02-27 01:52     ` Re: Unexpected behavior with transition tables in update statement trigger Thomas Munro <thomas.munro@enterprisedb.com>
  2018-02-27 20:58       ` Re: Unexpected behavior with transition tables in update statement trigger Tom Lane <tgl@sss.pgh.pa.us>
@ 2018-02-27 21:40         ` Tom Kazimiers <tom@voodoo-arts.net>
  1 sibling, 0 replies; 9+ messages in thread

From: Tom Kazimiers @ 2018-02-27 21:40 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Thomas Munro <thomas.munro@enterprisedb.com>; Pg Hackers <pgsql-hackers@postgresql.org>; pgsql-general

On Tue, Feb 27, 2018 at 03:58:14PM -0500, Tom Lane wrote:
>Thomas Munro <thomas.munro@enterprisedb.com> writes:
>> Here's a new version with tuplestore_select_read_pointer() added in
>> another place where it was lacking, and commit message.  Moving to
>> -hackers, where patches go.
>
>Pushed, along with a regression test based on your example.
>Unfortunately, this came in a bit too late for this week's releases :-(

Ah, so close. :-) Regardless, thanks both of you for fixing this and 
committing the fix to master. I am looking forward to the release 
including this.

Cheers,
Tom




^ permalink  raw  reply  [nested|flat] 9+ messages in thread


end of thread, other threads:[~2018-02-27 22:54 UTC | newest]

Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-02-24 03:47 Unexpected behavior with transition tables in update statement trigger Tom Kazimiers <tom@voodoo-arts.net>
2018-02-26 10:15 ` Thomas Munro <thomas.munro@enterprisedb.com>
2018-02-26 15:18   ` Tom Kazimiers <tom@voodoo-arts.net>
2018-02-27 01:52     ` Thomas Munro <thomas.munro@enterprisedb.com>
2018-02-27 20:08       ` Tom Kazimiers <tom@voodoo-arts.net>
2018-02-27 20:58       ` Tom Lane <tgl@sss.pgh.pa.us>
2018-02-27 21:27         ` Thomas Munro <thomas.munro@enterprisedb.com>
2018-02-27 22:54           ` Tom Kazimiers <tom@voodoo-arts.net>
2018-02-27 21:40         ` Tom Kazimiers <tom@voodoo-arts.net>

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