pgsql: Ensure pg_dump_sort.c sorts null vs non-null namespace consisten

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Ensure pg_dump_sort.c sorts null vs non-null namespace consisten
Date: 2018-08-07 17:14:10
Message-ID: E1fn5Yg-0003RA-BK@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Ensure pg_dump_sort.c sorts null vs non-null namespace consistently.

The original coding here (which is, I believe, my fault) supposed that
it didn't need to concern itself with the possibility that one object
of a given type-priority has a namespace while another doesn't. But
that's not reliably true anymore, if it ever was; and if it does happen
then it's possible that DOTypeNameCompare returns self-inconsistent
comparison results. That leads to unspecified behavior in qsort()
and a resultant weird output order from pg_dump.

This should end up being only a cosmetic problem, because any ordering
constraints that actually matter should be enforced by the later
dependency-based sort. Still, it's a bug, so back-patch.

Report and fix by Jacob Champion, though I editorialized on his
patch to the extent of making NULL sort after non-NULL, for consistency
with our usual sorting definitions.

Discussion: https://postgr.es/m/CABAq_6Hw+V-Kj7PNfD5tgOaWT_-qaYkc+SRmJkPLeUjYXLdxwQ@mail.gmail.com

Branch
------
REL9_3_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/5abdb33ad0533867dae08b61d922a5dfd499a290

Modified Files
--------------
src/bin/pg_dump/pg_dump_sort.c | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2018-08-07 19:44:09 pgsql: Fix pg_upgrade to handle event triggers in extensions correctly.
Previous Message Dean Rasheed 2018-08-07 07:03:21 Re: pgsql: Provide separate header file for built-in float types