Commit 20f6d742 authored by Peter Eisentraut's avatar Peter Eisentraut

Collect duplicate copies of oid_cmp()

parent 788af6f8
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
Oid binary_upgrade_next_pg_enum_oid = InvalidOid; Oid binary_upgrade_next_pg_enum_oid = InvalidOid;
static void RenumberEnumType(Relation pg_enum, HeapTuple *existing, int nelems); static void RenumberEnumType(Relation pg_enum, HeapTuple *existing, int nelems);
static int oid_cmp(const void *p1, const void *p2);
static int sort_order_cmp(const void *p1, const void *p2); static int sort_order_cmp(const void *p1, const void *p2);
...@@ -605,20 +604,6 @@ RenumberEnumType(Relation pg_enum, HeapTuple *existing, int nelems) ...@@ -605,20 +604,6 @@ RenumberEnumType(Relation pg_enum, HeapTuple *existing, int nelems)
} }
/* qsort comparison function for oids */
static int
oid_cmp(const void *p1, const void *p2)
{
Oid v1 = *((const Oid *) p1);
Oid v2 = *((const Oid *) p2);
if (v1 < v2)
return -1;
if (v1 > v2)
return 1;
return 0;
}
/* qsort comparison function for tuples by sort order */ /* qsort comparison function for tuples by sort order */
static int static int
sort_order_cmp(const void *p1, const void *p2) sort_order_cmp(const void *p1, const void *p2)
......
...@@ -27,12 +27,11 @@ ...@@ -27,12 +27,11 @@
#include "catalog/pg_inherits_fn.h" #include "catalog/pg_inherits_fn.h"
#include "parser/parse_type.h" #include "parser/parse_type.h"
#include "storage/lmgr.h" #include "storage/lmgr.h"
#include "utils/builtins.h"
#include "utils/fmgroids.h" #include "utils/fmgroids.h"
#include "utils/syscache.h" #include "utils/syscache.h"
#include "utils/tqual.h" #include "utils/tqual.h"
static int oid_cmp(const void *p1, const void *p2);
/* /*
* find_inheritance_children * find_inheritance_children
...@@ -357,18 +356,3 @@ typeInheritsFrom(Oid subclassTypeId, Oid superclassTypeId) ...@@ -357,18 +356,3 @@ typeInheritsFrom(Oid subclassTypeId, Oid superclassTypeId)
return result; return result;
} }
/* qsort comparison function */
static int
oid_cmp(const void *p1, const void *p2)
{
Oid v1 = *((const Oid *) p1);
Oid v2 = *((const Oid *) p2);
if (v1 < v2)
return -1;
if (v1 > v2)
return 1;
return 0;
}
...@@ -88,7 +88,6 @@ static void check_circularity(const Acl *old_acl, const AclItem *mod_aip, ...@@ -88,7 +88,6 @@ static void check_circularity(const Acl *old_acl, const AclItem *mod_aip,
Oid ownerId); Oid ownerId);
static Acl *recursive_revoke(Acl *acl, Oid grantee, AclMode revoke_privs, static Acl *recursive_revoke(Acl *acl, Oid grantee, AclMode revoke_privs,
Oid ownerId, DropBehavior behavior); Oid ownerId, DropBehavior behavior);
static int oidComparator(const void *arg1, const void *arg2);
static AclMode convert_priv_string(text *priv_type_text); static AclMode convert_priv_string(text *priv_type_text);
static AclMode convert_any_priv_string(text *priv_type_text, static AclMode convert_any_priv_string(text *priv_type_text,
...@@ -1490,7 +1489,7 @@ aclmembers(const Acl *acl, Oid **roleids) ...@@ -1490,7 +1489,7 @@ aclmembers(const Acl *acl, Oid **roleids)
} }
/* Sort the array */ /* Sort the array */
qsort(list, j, sizeof(Oid), oidComparator); qsort(list, j, sizeof(Oid), oid_cmp);
/* Remove duplicates from the array */ /* Remove duplicates from the array */
k = 0; k = 0;
...@@ -1509,23 +1508,6 @@ aclmembers(const Acl *acl, Oid **roleids) ...@@ -1509,23 +1508,6 @@ aclmembers(const Acl *acl, Oid **roleids)
return k + 1; return k + 1;
} }
/*
* oidComparator
* qsort comparison function for Oids
*/
static int
oidComparator(const void *arg1, const void *arg2)
{
Oid oid1 = *(const Oid *) arg1;
Oid oid2 = *(const Oid *) arg2;
if (oid1 > oid2)
return 1;
if (oid1 < oid2)
return -1;
return 0;
}
/* /*
* aclinsert (exported function) * aclinsert (exported function)
......
...@@ -331,6 +331,20 @@ oidparse(Node *node) ...@@ -331,6 +331,20 @@ oidparse(Node *node)
return InvalidOid; /* keep compiler quiet */ return InvalidOid; /* keep compiler quiet */
} }
/* qsort comparison function for Oids */
int
oid_cmp(const void *p1, const void *p2)
{
Oid v1 = *((const Oid *) p1);
Oid v2 = *((const Oid *) p2);
if (v1 < v2)
return -1;
if (v1 > v2)
return 1;
return 0;
}
/***************************************************************************** /*****************************************************************************
* PUBLIC ROUTINES * * PUBLIC ROUTINES *
......
...@@ -67,6 +67,7 @@ extern int float8_cmp_internal(float8 a, float8 b); ...@@ -67,6 +67,7 @@ extern int float8_cmp_internal(float8 a, float8 b);
/* oid.c */ /* oid.c */
extern oidvector *buildoidvector(const Oid *oids, int n); extern oidvector *buildoidvector(const Oid *oids, int n);
extern Oid oidparse(Node *node); extern Oid oidparse(Node *node);
extern int oid_cmp(const void *p1, const void *p2);
/* regexp.c */ /* regexp.c */
extern char *regexp_fixed_prefix(text *text_re, bool case_insensitive, extern char *regexp_fixed_prefix(text *text_re, bool case_insensitive,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment