Replace calls to pg_qsort() with the qsort() macro.
Calls to this function might give the impression that pg_qsort() is somehow different than qsort(), when in fact there is a qsort() macro in port.h that expands all in-tree uses to pg_qsort(). Reviewed-by: Mats Kindahl Discussion: https://postgr.es/m/CA%2B14426g2Wa9QuUpmakwPxXFWG_1FaY0AsApkvcTBy-YfS6uaw%40mail.gmail.com
This commit is contained in:
parent
d57b7cc333
commit
5497daf3aa
@ -346,8 +346,8 @@ apw_load_buffers(void)
|
|||||||
FreeFile(file);
|
FreeFile(file);
|
||||||
|
|
||||||
/* Sort the blocks to be loaded. */
|
/* Sort the blocks to be loaded. */
|
||||||
pg_qsort(blkinfo, num_elements, sizeof(BlockInfoRecord),
|
qsort(blkinfo, num_elements, sizeof(BlockInfoRecord),
|
||||||
apw_compare_blockinfo);
|
apw_compare_blockinfo);
|
||||||
|
|
||||||
/* Populate shared memory state. */
|
/* Populate shared memory state. */
|
||||||
apw_state->block_info_handle = dsm_segment_handle(seg);
|
apw_state->block_info_handle = dsm_segment_handle(seg);
|
||||||
|
@ -1369,7 +1369,7 @@ build_distances(FmgrInfo *distanceFn, Oid colloid,
|
|||||||
* Sort the distances in descending order, so that the longest gaps are at
|
* Sort the distances in descending order, so that the longest gaps are at
|
||||||
* the front.
|
* the front.
|
||||||
*/
|
*/
|
||||||
pg_qsort(distances, ndistances, sizeof(DistanceValue), compare_distances);
|
qsort(distances, ndistances, sizeof(DistanceValue), compare_distances);
|
||||||
|
|
||||||
return distances;
|
return distances;
|
||||||
}
|
}
|
||||||
|
@ -2307,8 +2307,8 @@ remove_self_joins_recurse(PlannerInfo *root, List *joinlist, Relids toRemove)
|
|||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
|
|
||||||
pg_qsort(candidates, numRels, sizeof(SelfJoinCandidate),
|
qsort(candidates, numRels, sizeof(SelfJoinCandidate),
|
||||||
self_join_candidates_cmp);
|
self_join_candidates_cmp);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Iteratively form a group of relation indexes with the same oid and
|
* Iteratively form a group of relation indexes with the same oid and
|
||||||
|
@ -3915,7 +3915,7 @@ DropRelationsAllBuffers(SMgrRelation *smgr_reln, int nlocators)
|
|||||||
|
|
||||||
/* sort the list of rlocators if necessary */
|
/* sort the list of rlocators if necessary */
|
||||||
if (use_bsearch)
|
if (use_bsearch)
|
||||||
pg_qsort(locators, n, sizeof(RelFileLocator), rlocator_comparator);
|
qsort(locators, n, sizeof(RelFileLocator), rlocator_comparator);
|
||||||
|
|
||||||
for (i = 0; i < NBuffers; i++)
|
for (i = 0; i < NBuffers; i++)
|
||||||
{
|
{
|
||||||
@ -4269,7 +4269,7 @@ FlushRelationsAllBuffers(SMgrRelation *smgrs, int nrels)
|
|||||||
|
|
||||||
/* sort the list of SMgrRelations if necessary */
|
/* sort the list of SMgrRelations if necessary */
|
||||||
if (use_bsearch)
|
if (use_bsearch)
|
||||||
pg_qsort(srels, nrels, sizeof(SMgrSortArray), rlocator_comparator);
|
qsort(srels, nrels, sizeof(SMgrSortArray), rlocator_comparator);
|
||||||
|
|
||||||
for (i = 0; i < NBuffers; i++)
|
for (i = 0; i < NBuffers; i++)
|
||||||
{
|
{
|
||||||
|
10
src/backend/utils/cache/syscache.c
vendored
10
src/backend/utils/cache/syscache.c
vendored
@ -146,14 +146,14 @@ InitCatalogCache(void)
|
|||||||
Assert(SysCacheSupportingRelOidSize <= lengthof(SysCacheSupportingRelOid));
|
Assert(SysCacheSupportingRelOidSize <= lengthof(SysCacheSupportingRelOid));
|
||||||
|
|
||||||
/* Sort and de-dup OID arrays, so we can use binary search. */
|
/* Sort and de-dup OID arrays, so we can use binary search. */
|
||||||
pg_qsort(SysCacheRelationOid, SysCacheRelationOidSize,
|
qsort(SysCacheRelationOid, SysCacheRelationOidSize,
|
||||||
sizeof(Oid), oid_compare);
|
sizeof(Oid), oid_compare);
|
||||||
SysCacheRelationOidSize =
|
SysCacheRelationOidSize =
|
||||||
qunique(SysCacheRelationOid, SysCacheRelationOidSize, sizeof(Oid),
|
qunique(SysCacheRelationOid, SysCacheRelationOidSize, sizeof(Oid),
|
||||||
oid_compare);
|
oid_compare);
|
||||||
|
|
||||||
pg_qsort(SysCacheSupportingRelOid, SysCacheSupportingRelOidSize,
|
qsort(SysCacheSupportingRelOid, SysCacheSupportingRelOidSize,
|
||||||
sizeof(Oid), oid_compare);
|
sizeof(Oid), oid_compare);
|
||||||
SysCacheSupportingRelOidSize =
|
SysCacheSupportingRelOidSize =
|
||||||
qunique(SysCacheSupportingRelOid, SysCacheSupportingRelOidSize,
|
qunique(SysCacheSupportingRelOid, SysCacheSupportingRelOidSize,
|
||||||
sizeof(Oid), oid_compare);
|
sizeof(Oid), oid_compare);
|
||||||
@ -668,7 +668,7 @@ RelationSupportsSysCache(Oid relid)
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* OID comparator for pg_qsort
|
* OID comparator for qsort
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
oid_compare(const void *a, const void *b)
|
oid_compare(const void *a, const void *b)
|
||||||
|
@ -438,6 +438,10 @@ extern bool pg_get_user_name(uid_t user_id, char *buffer, size_t buflen);
|
|||||||
extern bool pg_get_user_home_dir(uid_t user_id, char *buffer, size_t buflen);
|
extern bool pg_get_user_home_dir(uid_t user_id, char *buffer, size_t buflen);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Callers should use the qsort() macro defined below instead of calling
|
||||||
|
* pg_qsort() directly.
|
||||||
|
*/
|
||||||
extern void pg_qsort(void *base, size_t nel, size_t elsize,
|
extern void pg_qsort(void *base, size_t nel, size_t elsize,
|
||||||
int (*cmp) (const void *, const void *));
|
int (*cmp) (const void *, const void *));
|
||||||
extern int pg_qsort_strcmp(const void *a, const void *b);
|
extern int pg_qsort_strcmp(const void *a, const void *b);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user