mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Add reusable routine for making arrays unique.
Introduce qunique() and qunique_arg(), which can be used after qsort() and qsort_arg() respectively to remove duplicate values. Use it where appropriate. Author: Thomas Munro Reviewed-by: Tom Lane (in an earlier version) Discussion: https://postgr.es/m/CAEepm%3D2vmFTNpAmwbGGD2WaryM6T3hSDVKQPfUwjdD_5XY6vAA%40mail.gmail.com
This commit is contained in:
@ -27,6 +27,7 @@
|
||||
#include "catalog/pg_type.h"
|
||||
#include "executor/execdebug.h"
|
||||
#include "executor/nodeTidscan.h"
|
||||
#include "lib/qunique.h"
|
||||
#include "miscadmin.h"
|
||||
#include "nodes/nodeFuncs.h"
|
||||
#include "storage/bufmgr.h"
|
||||
@ -260,21 +261,13 @@ TidListEval(TidScanState *tidstate)
|
||||
*/
|
||||
if (numTids > 1)
|
||||
{
|
||||
int lastTid;
|
||||
int i;
|
||||
|
||||
/* CurrentOfExpr could never appear OR'd with something else */
|
||||
Assert(!tidstate->tss_isCurrentOf);
|
||||
|
||||
qsort((void *) tidList, numTids, sizeof(ItemPointerData),
|
||||
itemptr_comparator);
|
||||
lastTid = 0;
|
||||
for (i = 1; i < numTids; i++)
|
||||
{
|
||||
if (!ItemPointerEquals(&tidList[lastTid], &tidList[i]))
|
||||
tidList[++lastTid] = tidList[i];
|
||||
}
|
||||
numTids = lastTid + 1;
|
||||
numTids = qunique(tidList, numTids, sizeof(ItemPointerData),
|
||||
itemptr_comparator);
|
||||
}
|
||||
|
||||
tidstate->tss_TidList = tidList;
|
||||
|
Reference in New Issue
Block a user