Re: [PATCH] Sort policies and triggers by table name in pg_dump.

Benjie Gillam <benjie@jemjie.com>

From: Benjie Gillam <benjie@jemjie.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: pgsql-hackers@postgresql.org
Date: 2019-09-24T07:48:33Z
Lists: pgsql-hackers

Attachments

> Could you provide a simple example of schema (tables with some
> policies and triggers), with the difference this generates for
> pg_dump, which shows your point?

Certainly; I've attached a bash script that can reproduce the issue
and the diff that it produces, here's the important part:

    CREATE TRIGGER a BEFORE INSERT ON foo
        FOR EACH ROW EXECUTE PROCEDURE qux();
    CREATE POLICY a ON foo FOR SELECT USING (true);

    CREATE TRIGGER a BEFORE INSERT ON bar
        FOR EACH ROW EXECUTE PROCEDURE qux();
    CREATE POLICY a ON bar FOR SELECT USING (true);

Here we create two identically named triggers and two identically
named policies on tables foo and bar. If instead we ran these
statements in a different order (or if the object IDs were to wrap)
the order of the pg_dump would be different even though the
databases are identical other than object IDs. The attached
patch eliminates this difference.

> Your patch has two warnings because you are trying to map a policy
> info pointer to a trigger info pointer:

Ah, thank you for the pointer (aha); I've attached an updated patch
that addresses this copy/paste issue.

Commits

  1. Stabilize pg_dump output order for similarly-named triggers and policies.