From 1acc06a1f4ae752793d2199d8d462a6708c8acc2 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Mon, 15 Feb 2010 19:59:47 +0000 Subject: [PATCH] When sorting functions in pg_dump, break ties (same name) by number of arguments --- src/bin/pg_dump/pg_dump_sort.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/bin/pg_dump/pg_dump_sort.c b/src/bin/pg_dump/pg_dump_sort.c index 33d29ae1a2..1551af3dbe 100644 --- a/src/bin/pg_dump/pg_dump_sort.c +++ b/src/bin/pg_dump/pg_dump_sort.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump_sort.c,v 1.27 2010/01/02 16:57:59 momjian Exp $ + * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump_sort.c,v 1.28 2010/02/15 19:59:47 petere Exp $ * *------------------------------------------------------------------------- */ @@ -163,7 +163,18 @@ DOTypeNameCompare(const void *p1, const void *p2) if (cmpval != 0) return cmpval; - /* Probably shouldn't get here, but if we do, sort by OID */ + /* To have a stable sort order, break ties for some object types */ + if (obj1->objType == DO_FUNC || obj1->objType == DO_AGG) + { + FuncInfo *fobj1 = *(FuncInfo **) p1; + FuncInfo *fobj2 = *(FuncInfo **) p2; + + cmpval = fobj1->nargs - fobj2->nargs; + if (cmpval != 0) + return cmpval; + } + + /* Usually shouldn't get here, but if we do, sort by OID */ return oidcmp(obj1->catId.oid, obj2->catId.oid); } -- 2.40.0