Skip to content

Commit 1acc06a

Browse files
committed
When sorting functions in pg_dump, break ties (same name) by number of arguments
1 parent ec86ef7 commit 1acc06a

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/bin/pg_dump/pg_dump_sort.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump_sort.c,v 1.27 2010/01/02 16:57:59 momjian Exp $
12+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump_sort.c,v 1.28 2010/02/15 19:59:47 petere Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -163,7 +163,18 @@ DOTypeNameCompare(const void *p1, const void *p2)
163163
if (cmpval != 0)
164164
return cmpval;
165165

166-
/* Probably shouldn't get here, but if we do, sort by OID */
166+
/* To have a stable sort order, break ties for some object types */
167+
if (obj1->objType == DO_FUNC || obj1->objType == DO_AGG)
168+
{
169+
FuncInfo *fobj1 = *(FuncInfo **) p1;
170+
FuncInfo *fobj2 = *(FuncInfo **) p2;
171+
172+
cmpval = fobj1->nargs - fobj2->nargs;
173+
if (cmpval != 0)
174+
return cmpval;
175+
}
176+
177+
/* Usually shouldn't get here, but if we do, sort by OID */
167178
return oidcmp(obj1->catId.oid, obj2->catId.oid);
168179
}
169180

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy