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

Benjie Gillam <benjie@jemjie.com>

From: Benjie Gillam <benjie@jemjie.com>
To: pgsql-hackers@postgresql.org
Date: 2019-09-23T21:34:07Z
Lists: pgsql-hackers

Attachments

Hello all,

Currently pg_dump sorts most dumpable objects by priority, namespace, name
and then object ID. Since triggers and RLS policies belong to tables, there
may be more than one with the same name within the same namespace, leading to
potential sorting discrepancies between databases that only differ by object
IDs.

The attached draft patch (made against `pg_dump_sort.c` on master) breaks
ties for trigger and policy objects by using the table name, increasing the
sort order stability. I have compiled it and executed it against a number of
local databases and it behaves as desired.

I am new to PostgreSQL contribution and my C-skills are rusty, so please let
me know if I can improve the patch, or if there are areas of PostgreSQL that
I have overlooked.

Kind regards,

Benjie Gillam

Commits

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