Skip to content

Commit 20f6d74

Browse files
committed
Collect duplicate copies of oid_cmp()
1 parent 788af6f commit 20f6d74

File tree

5 files changed

+17
-51
lines changed

5 files changed

+17
-51
lines changed

src/backend/catalog/pg_enum.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
Oid binary_upgrade_next_pg_enum_oid = InvalidOid;
3737

3838
static void RenumberEnumType(Relation pg_enum, HeapTuple *existing, int nelems);
39-
static int oid_cmp(const void *p1, const void *p2);
4039
static int sort_order_cmp(const void *p1, const void *p2);
4140

4241

@@ -605,20 +604,6 @@ RenumberEnumType(Relation pg_enum, HeapTuple *existing, int nelems)
605604
}
606605

607606

608-
/* qsort comparison function for oids */
609-
static int
610-
oid_cmp(const void *p1, const void *p2)
611-
{
612-
Oid v1 = *((const Oid *) p1);
613-
Oid v2 = *((const Oid *) p2);
614-
615-
if (v1 < v2)
616-
return -1;
617-
if (v1 > v2)
618-
return 1;
619-
return 0;
620-
}
621-
622607
/* qsort comparison function for tuples by sort order */
623608
static int
624609
sort_order_cmp(const void *p1, const void *p2)

src/backend/catalog/pg_inherits.c

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,11 @@
2727
#include "catalog/pg_inherits_fn.h"
2828
#include "parser/parse_type.h"
2929
#include "storage/lmgr.h"
30+
#include "utils/builtins.h"
3031
#include "utils/fmgroids.h"
3132
#include "utils/syscache.h"
3233
#include "utils/tqual.h"
3334

34-
static int oid_cmp(const void *p1, const void *p2);
35-
3635

3736
/*
3837
* find_inheritance_children
@@ -357,18 +356,3 @@ typeInheritsFrom(Oid subclassTypeId, Oid superclassTypeId)
357356

358357
return result;
359358
}
360-
361-
362-
/* qsort comparison function */
363-
static int
364-
oid_cmp(const void *p1, const void *p2)
365-
{
366-
Oid v1 = *((const Oid *) p1);
367-
Oid v2 = *((const Oid *) p2);
368-
369-
if (v1 < v2)
370-
return -1;
371-
if (v1 > v2)
372-
return 1;
373-
return 0;
374-
}

src/backend/utils/adt/acl.c

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ static void check_circularity(const Acl *old_acl, const AclItem *mod_aip,
8888
Oid ownerId);
8989
static Acl *recursive_revoke(Acl *acl, Oid grantee, AclMode revoke_privs,
9090
Oid ownerId, DropBehavior behavior);
91-
static int oidComparator(const void *arg1, const void *arg2);
9291

9392
static AclMode convert_priv_string(text *priv_type_text);
9493
static AclMode convert_any_priv_string(text *priv_type_text,
@@ -1490,7 +1489,7 @@ aclmembers(const Acl *acl, Oid **roleids)
14901489
}
14911490

14921491
/* Sort the array */
1493-
qsort(list, j, sizeof(Oid), oidComparator);
1492+
qsort(list, j, sizeof(Oid), oid_cmp);
14941493

14951494
/* Remove duplicates from the array */
14961495
k = 0;
@@ -1509,23 +1508,6 @@ aclmembers(const Acl *acl, Oid **roleids)
15091508
return k + 1;
15101509
}
15111510

1512-
/*
1513-
* oidComparator
1514-
* qsort comparison function for Oids
1515-
*/
1516-
static int
1517-
oidComparator(const void *arg1, const void *arg2)
1518-
{
1519-
Oid oid1 = *(const Oid *) arg1;
1520-
Oid oid2 = *(const Oid *) arg2;
1521-
1522-
if (oid1 > oid2)
1523-
return 1;
1524-
if (oid1 < oid2)
1525-
return -1;
1526-
return 0;
1527-
}
1528-
15291511

15301512
/*
15311513
* aclinsert (exported function)

src/backend/utils/adt/oid.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,20 @@ oidparse(Node *node)
331331
return InvalidOid; /* keep compiler quiet */
332332
}
333333

334+
/* qsort comparison function for Oids */
335+
int
336+
oid_cmp(const void *p1, const void *p2)
337+
{
338+
Oid v1 = *((const Oid *) p1);
339+
Oid v2 = *((const Oid *) p2);
340+
341+
if (v1 < v2)
342+
return -1;
343+
if (v1 > v2)
344+
return 1;
345+
return 0;
346+
}
347+
334348

335349
/*****************************************************************************
336350
* PUBLIC ROUTINES *

src/include/utils/builtins.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ extern int float8_cmp_internal(float8 a, float8 b);
6767
/* oid.c */
6868
extern oidvector *buildoidvector(const Oid *oids, int n);
6969
extern Oid oidparse(Node *node);
70+
extern int oid_cmp(const void *p1, const void *p2);
7071

7172
/* regexp.c */
7273
extern char *regexp_fixed_prefix(text *text_re, bool case_insensitive,

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