mirror of https://github.com/postgres/postgres
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);
|
||||
|
||||
/* Sort the blocks to be loaded. */
|
||||
pg_qsort(blkinfo, num_elements, sizeof(BlockInfoRecord),
|
||||
apw_compare_blockinfo);
|
||||
qsort(blkinfo, num_elements, sizeof(BlockInfoRecord),
|
||||
apw_compare_blockinfo);
|
||||
|
||||
/* Populate shared memory state. */
|
||||
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
|
||||
* the front.
|
||||
*/
|
||||
pg_qsort(distances, ndistances, sizeof(DistanceValue), compare_distances);
|
||||
qsort(distances, ndistances, sizeof(DistanceValue), compare_distances);
|
||||
|
||||
return distances;
|
||||
}
|
||||
|
|
|
@ -2307,8 +2307,8 @@ remove_self_joins_recurse(PlannerInfo *root, List *joinlist, Relids toRemove)
|
|||
j++;
|
||||
}
|
||||
|
||||
pg_qsort(candidates, numRels, sizeof(SelfJoinCandidate),
|
||||
self_join_candidates_cmp);
|
||||
qsort(candidates, numRels, sizeof(SelfJoinCandidate),
|
||||
self_join_candidates_cmp);
|
||||
|
||||
/*
|
||||
* 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 */
|
||||
if (use_bsearch)
|
||||
pg_qsort(locators, n, sizeof(RelFileLocator), rlocator_comparator);
|
||||
qsort(locators, n, sizeof(RelFileLocator), rlocator_comparator);
|
||||
|
||||
for (i = 0; i < NBuffers; i++)
|
||||
{
|
||||
|
@ -4269,7 +4269,7 @@ FlushRelationsAllBuffers(SMgrRelation *smgrs, int nrels)
|
|||
|
||||
/* sort the list of SMgrRelations if necessary */
|
||||
if (use_bsearch)
|
||||
pg_qsort(srels, nrels, sizeof(SMgrSortArray), rlocator_comparator);
|
||||
qsort(srels, nrels, sizeof(SMgrSortArray), rlocator_comparator);
|
||||
|
||||
for (i = 0; i < NBuffers; i++)
|
||||
{
|
||||
|
|
|
@ -146,14 +146,14 @@ InitCatalogCache(void)
|
|||
Assert(SysCacheSupportingRelOidSize <= lengthof(SysCacheSupportingRelOid));
|
||||
|
||||
/* Sort and de-dup OID arrays, so we can use binary search. */
|
||||
pg_qsort(SysCacheRelationOid, SysCacheRelationOidSize,
|
||||
sizeof(Oid), oid_compare);
|
||||
qsort(SysCacheRelationOid, SysCacheRelationOidSize,
|
||||
sizeof(Oid), oid_compare);
|
||||
SysCacheRelationOidSize =
|
||||
qunique(SysCacheRelationOid, SysCacheRelationOidSize, sizeof(Oid),
|
||||
oid_compare);
|
||||
|
||||
pg_qsort(SysCacheSupportingRelOid, SysCacheSupportingRelOidSize,
|
||||
sizeof(Oid), oid_compare);
|
||||
qsort(SysCacheSupportingRelOid, SysCacheSupportingRelOidSize,
|
||||
sizeof(Oid), oid_compare);
|
||||
SysCacheSupportingRelOidSize =
|
||||
qunique(SysCacheSupportingRelOid, SysCacheSupportingRelOidSize,
|
||||
sizeof(Oid), oid_compare);
|
||||
|
@ -668,7 +668,7 @@ RelationSupportsSysCache(Oid relid)
|
|||
|
||||
|
||||
/*
|
||||
* OID comparator for pg_qsort
|
||||
* OID comparator for qsort
|
||||
*/
|
||||
static int
|
||||
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);
|
||||
#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,
|
||||
int (*cmp) (const void *, const void *));
|
||||
extern int pg_qsort_strcmp(const void *a, const void *b);
|
||||
|
|
Loading…
Reference in New Issue