#include "access/reloptions.h"
#include "access/stratnum.h"
#include "catalog/pg_type.h"
+#include "common/int.h"
#include "hstore.h"
#include "utils/pg_crc.h"
static int
comparecost(const void *a, const void *b)
{
- return ((const SPLITCOST *) a)->cost - ((const SPLITCOST *) b)->cost;
+ return pg_cmp_s32(((const SPLITCOST *) a)->cost,
+ ((const SPLITCOST *) b)->cost);
}
#include "_int.h"
#include "catalog/pg_type.h"
+#include "common/int.h"
#include "lib/qunique.h"
/* arguments are assumed sorted & unique-ified */
int
compASC(const void *a, const void *b)
{
- if (*(const int32 *) a == *(const int32 *) b)
- return 0;
- return (*(const int32 *) a > *(const int32 *) b) ? 1 : -1;
+ return pg_cmp_s32(*(const int32 *) a, *(const int32 *) b);
}
int
compDESC(const void *a, const void *b)
{
- if (*(const int32 *) a == *(const int32 *) b)
- return 0;
- return (*(const int32 *) a < *(const int32 *) b) ? 1 : -1;
+ return pg_cmp_s32(*(const int32 *) b, *(const int32 *) a);
}
#include "access/gist.h"
#include "access/reloptions.h"
#include "access/stratnum.h"
+#include "common/int.h"
#include "port/pg_bitutils.h"
#define GETENTRY(vec,pos) ((GISTTYPE *) DatumGetPointer((vec)->vector[(pos)].key))
static int
comparecost(const void *a, const void *b)
{
- return ((const SPLITCOST *) a)->cost - ((const SPLITCOST *) b)->cost;
+ return pg_cmp_s32(((const SPLITCOST *) a)->cost,
+ ((const SPLITCOST *) b)->cost);
}
#include "access/parallel.h"
#include "catalog/pg_authid.h"
#include "common/hashfn.h"
+#include "common/int.h"
#include "executor/instrument.h"
#include "funcapi.h"
#include "jit/jit.h"
int l = ((const LocationLen *) a)->location;
int r = ((const LocationLen *) b)->location;
- if (l < r)
- return -1;
- else if (l > r)
- return +1;
- else
- return 0;
+ return pg_cmp_s32(l, r);
}
#include <ctype.h>
#include "catalog/pg_type.h"
+#include "common/int.h"
#include "lib/qunique.h"
#include "miscadmin.h"
#include "trgm.h"
if (cmp != 0)
return cmp;
- if (p1->index < p2->index)
- return -1;
- else if (p1->index == p2->index)
- return 0;
- else
- return 1;
+ return pg_cmp_s32(p1->index, p2->index);
}
/*
#include "access/nbtxlog.h"
#include "access/transam.h"
#include "access/xloginsert.h"
+#include "common/int.h"
#include "common/pg_prng.h"
#include "lib/qunique.h"
#include "miscadmin.h"
BlockNumber b1 = *((BlockNumber *) arg1);
BlockNumber b2 = *((BlockNumber *) arg2);
- if (b1 < b2)
- return -1;
- else if (b1 > b2)
- return 1;
-
- return 0;
+ return pg_cmp_u32(b1, b2);
}
#include "access/transam.h"
#include "access/xlog.h"
#include "access/xloginsert.h"
+#include "common/int.h"
#include "miscadmin.h"
#include "storage/indexfsm.h"
#include "storage/lmgr.h"
TM_IndexDelete *indexdelete1 = (TM_IndexDelete *) a;
TM_IndexDelete *indexdelete2 = (TM_IndexDelete *) b;
- if (indexdelete1->id > indexdelete2->id)
- return 1;
- if (indexdelete1->id < indexdelete2->id)
- return -1;
+ Assert(indexdelete1->id != indexdelete2->id);
- Assert(false);
-
- return 0;
+ return pg_cmp_s16(indexdelete1->id, indexdelete2->id);
}
/*
#include "postgres.h"
#include "access/nbtree.h"
+#include "common/int.h"
#include "storage/lmgr.h"
typedef enum
SplitPoint *split1 = (SplitPoint *) arg1;
SplitPoint *split2 = (SplitPoint *) arg2;
- if (split1->curdelta > split2->curdelta)
- return 1;
- if (split1->curdelta < split2->curdelta)
- return -1;
-
- return 0;
+ return pg_cmp_s16(split1->curdelta, split2->curdelta);
}
/*
#include "access/spgist_private.h"
#include "access/spgxlog.h"
#include "access/xloginsert.h"
+#include "common/int.h"
#include "common/pg_prng.h"
#include "miscadmin.h"
#include "storage/bufmgr.h"
static int
cmpOffsetNumbers(const void *a, const void *b)
{
- if (*(const OffsetNumber *) a == *(const OffsetNumber *) b)
- return 0;
- return (*(const OffsetNumber *) a > *(const OffsetNumber *) b) ? 1 : -1;
+ return pg_cmp_u16(*(const OffsetNumber *) a, *(const OffsetNumber *) b);
}
/*
#include "postgres.h"
#include "access/spgist.h"
+#include "common/int.h"
#include "catalog/pg_type.h"
#include "mb/pg_wchar.h"
#include "utils/builtins.h"
const spgNodePtr *aa = (const spgNodePtr *) a;
const spgNodePtr *bb = (const spgNodePtr *) b;
- return aa->c - bb->c;
+ return pg_cmp_s16(aa->c, bb->c);
}
Datum
#include "common/blkreftable.h"
#include "common/parse_manifest.h"
#include "common/hashfn.h"
+#include "common/int.h"
#include "postmaster/walsummarizer.h"
#define BLOCKS_PER_READ 512
BlockNumber aa = *(BlockNumber *) a;
BlockNumber bb = *(BlockNumber *) b;
- if (aa > bb)
- return 1;
- else if (aa == bb)
- return 0;
- else
- return -1;
+ return pg_cmp_u32(aa, bb);
}
#include "access/xlog_internal.h"
#include "backup/walsummary.h"
+#include "common/int.h"
#include "utils/wait_event.h"
static bool IsWalSummaryFilename(char *filename);
WalSummaryFile *ws1 = lfirst(a);
WalSummaryFile *ws2 = lfirst(b);
- if (ws1->start_lsn < ws2->start_lsn)
- return -1;
- if (ws1->start_lsn > ws2->start_lsn)
- return 1;
- return 0;
+ return pg_cmp_u64(ws1->start_lsn, ws2->start_lsn);
}
#include "catalog/storage.h"
#include "commands/tablecmds.h"
#include "commands/typecmds.h"
+#include "common/int.h"
#include "miscadmin.h"
#include "nodes/nodeFuncs.h"
#include "optimizer/optimizer.h"
AttrNumber v1 = ((CookedConstraint *) lfirst(p1))->attnum;
AttrNumber v2 = ((CookedConstraint *) lfirst(p2))->attnum;
- if (v1 < v2)
- return -1;
- if (v1 > v2)
- return 1;
- return 0;
+ return pg_cmp_s16(v1, v2);
}
/*
*/
#include "postgres.h"
+#include "common/int.h"
#include "nodes/pg_list.h"
#include "port/pg_bitutils.h"
#include "utils/memdebug.h"
int v1 = lfirst_int(p1);
int v2 = lfirst_int(p2);
- if (v1 < v2)
- return -1;
- if (v1 > v2)
- return 1;
- return 0;
+ return pg_cmp_s32(v1, v2);
}
/*
Oid v1 = lfirst_oid(p1);
Oid v2 = lfirst_oid(p2);
- if (v1 < v2)
- return -1;
- if (v1 > v2)
- return 1;
- return 0;
+ return pg_cmp_u32(v1, v2);
}
#include "access/htup_details.h"
#include "common/hashfn.h"
+#include "common/int.h"
#include "nodes/bitmapset.h"
#include "nodes/tidbitmap.h"
#include "storage/lwlock.h"
BlockNumber l = (*((PagetableEntry *const *) left))->blockno;
BlockNumber r = (*((PagetableEntry *const *) right))->blockno;
- if (l < r)
- return -1;
- else if (l > r)
- return 1;
- return 0;
+ return pg_cmp_u32(l, r);
}
/*
#include "catalog/pg_aggregate.h"
#include "catalog/pg_constraint.h"
#include "catalog/pg_type.h"
+#include "common/int.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "optimizer/optimizer.h"
int la = list_length((const List *) lfirst(a));
int lb = list_length((const List *) lfirst(b));
- return (la > lb) ? 1 : (la == lb) ? 0 : -1;
+ return pg_cmp_s32(la, lb);
}
/* list_sort comparator to sort sub-lists by length and contents */
#include "catalog/pg_database.h"
#include "commands/dbcommands.h"
#include "commands/vacuum.h"
+#include "common/int.h"
#include "lib/ilist.h"
#include "libpq/pqsignal.h"
#include "miscadmin.h"
static int
db_comparator(const void *a, const void *b)
{
- if (((const avl_dbase *) a)->adl_score == ((const avl_dbase *) b)->adl_score)
- return 0;
- else
- return (((const avl_dbase *) a)->adl_score < ((const avl_dbase *) b)->adl_score) ? 1 : -1;
+ return pg_cmp_s32(((const avl_dbase *) a)->adl_score,
+ ((const avl_dbase *) b)->adl_score);
}
/*
#include "access/xact.h"
#include "access/xlog_internal.h"
#include "catalog/catalog.h"
+#include "common/int.h"
#include "lib/binaryheap.h"
#include "miscadmin.h"
#include "pgstat.h"
RewriteMappingFile *a = (RewriteMappingFile *) lfirst(a_p);
RewriteMappingFile *b = (RewriteMappingFile *) lfirst(b_p);
- if (a->lsn < b->lsn)
- return -1;
- else if (a->lsn > b->lsn)
- return 1;
- return 0;
+ return pg_cmp_u64(a->lsn, b->lsn);
}
/*
#include <unistd.h>
#include "access/xact.h"
+#include "common/int.h"
#include "miscadmin.h"
#include "pgstat.h"
#include "replication/syncrep.h"
XLogRecPtr lsn1 = *((const XLogRecPtr *) a);
XLogRecPtr lsn2 = *((const XLogRecPtr *) b);
- if (lsn1 > lsn2)
- return -1;
- else if (lsn1 == lsn2)
- return 0;
- else
- return 1;
+ return pg_cmp_u64(lsn2, lsn1);
}
/*
#include <limits.h>
#include "catalog/pg_type.h"
+#include "common/int.h"
#include "libpq/pqformat.h"
#include "nodes/miscnodes.h"
#include "nodes/value.h"
Oid v1 = *((const Oid *) p1);
Oid v2 = *((const Oid *) p2);
- if (v1 < v2)
- return -1;
- if (v1 > v2)
- return 1;
- return 0;
+ return pg_cmp_u32(v1, v2);
}
#include "access/gist.h"
#include "access/heaptoast.h"
#include "access/reloptions.h"
+#include "common/int.h"
#include "lib/qunique.h"
#include "port/pg_bitutils.h"
#include "tsearch/ts_utils.h"
int32 a = *((const int32 *) va);
int32 b = *((const int32 *) vb);
- if (a == b)
- return 0;
- return (a > b) ? 1 : -1;
+ return pg_cmp_s32(a, b);
}
static void
const SPLITCOST *a = (const SPLITCOST *) va;
const SPLITCOST *b = (const SPLITCOST *) vb;
- if (a->cost == b->cost)
- return 0;
- else
- return (a->cost > b->cost) ? 1 : -1;
+ return pg_cmp_s32(a->cost, b->cost);
}
#include "access/gist.h"
#include "access/stratnum.h"
+#include "common/int.h"
#include "tsearch/ts_utils.h"
#include "utils/builtins.h"
static int
comparecost(const void *a, const void *b)
{
- if (((const SPLITCOST *) a)->cost == ((const SPLITCOST *) b)->cost)
- return 0;
- else
- return (((const SPLITCOST *) a)->cost > ((const SPLITCOST *) b)->cost) ? 1 : -1;
+ return pg_cmp_s32(((const SPLITCOST *) a)->cost,
+ ((const SPLITCOST *) b)->cost);
}
#define WISH_F(a,b,c) (double)( -(double)(((a)-(b))*((a)-(b))*((a)-(b)))*(c) )
#include "postgres.h"
+#include "common/int.h"
#include "libpq/pqformat.h"
#include "nodes/miscnodes.h"
#include "tsearch/ts_locale.h"
int apos = WEP_GETPOS(*(const WordEntryPos *) a);
int bpos = WEP_GETPOS(*(const WordEntryPos *) b);
- if (apos == bpos)
- return 0;
- return (apos > bpos) ? 1 : -1;
+ return pg_cmp_s32(apos, bpos);
}
/*
#include "catalog/namespace.h"
#include "catalog/pg_type.h"
#include "commands/trigger.h"
+#include "common/int.h"
#include "executor/spi.h"
#include "funcapi.h"
#include "lib/qunique.h"
int a = *((const int *) va);
int b = *((const int *) vb);
- if (a == b)
- return 0;
- return (a > b) ? 1 : -1;
+ return pg_cmp_s32(a, b);
}
static int
#include "access/multixact.h"
#include "access/transam.h"
#include "access/xact.h"
+#include "common/int.h"
#include "libpq/pqformat.h"
#include "utils/builtins.h"
#include "utils/xid8.h"
TransactionId xid1 = *(const TransactionId *) arg1;
TransactionId xid2 = *(const TransactionId *) arg2;
- if (xid1 > xid2)
- return 1;
- if (xid1 < xid2)
- return -1;
- return 0;
+ return pg_cmp_u32(xid1, xid2);
}
/*
#include "commands/policy.h"
#include "commands/publicationcmds.h"
#include "commands/trigger.h"
+#include "common/int.h"
#include "miscadmin.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
const AttrDefault *ada = (const AttrDefault *) a;
const AttrDefault *adb = (const AttrDefault *) b;
- return ada->adnum - adb->adnum;
+ return pg_cmp_s16(ada->adnum, adb->adnum);
}
/*
#include "catalog/pg_shdepend_d.h"
#include "catalog/pg_shdescription_d.h"
#include "catalog/pg_shseclabel_d.h"
+#include "common/int.h"
#include "lib/qunique.h"
#include "utils/catcache.h"
#include "utils/lsyscache.h"
Oid oa = *((const Oid *) a);
Oid ob = *((const Oid *) b);
- if (oa == ob)
- return 0;
- return (oa > ob) ? 1 : -1;
+ return pg_cmp_u32(oa, ob);
}
#include "catalog/pg_range.h"
#include "catalog/pg_type.h"
#include "commands/defrem.h"
+#include "common/int.h"
#include "executor/executor.h"
#include "lib/dshash.h"
#include "optimizer/optimizer.h"
const EnumItem *l = (const EnumItem *) left;
const EnumItem *r = (const EnumItem *) right;
- if (l->enum_oid < r->enum_oid)
- return -1;
- else if (l->enum_oid > r->enum_oid)
- return 1;
- else
- return 0;
+ return pg_cmp_u32(l->enum_oid, r->enum_oid);
}
/*
#include "postgres.h"
#include "common/hashfn.h"
+#include "common/int.h"
#include "storage/ipc.h"
#include "storage/predicate.h"
#include "storage/proc.h"
/* Note: reverse order */
if (ra->kind->release_phase == rb->kind->release_phase)
- {
- if (ra->kind->release_priority == rb->kind->release_priority)
- return 0;
- else if (ra->kind->release_priority > rb->kind->release_priority)
- return -1;
- else
- return 1;
- }
+ return pg_cmp_u32(rb->kind->release_priority, ra->kind->release_priority);
else if (ra->kind->release_phase > rb->kind->release_phase)
return -1;
else
#include "postgres_fe.h"
#include "catalog/pg_class_d.h"
+#include "common/int.h"
#include "lib/binaryheap.h"
#include "pg_backup_archiver.h"
#include "pg_backup_utils.h"
int ai = (int) (intptr_t) a;
int bi = (int) (intptr_t) b;
- if (ai < bi)
- return -1;
- if (ai > bi)
- return 1;
- return 0;
+ return pg_cmp_s32(ai, bi);
}
#include "access/transam.h"
#include "catalog/pg_language_d.h"
+#include "common/int.h"
#include "pg_upgrade.h"
/*
{
const char *str1 = ((const LibraryInfo *) p1)->name;
const char *str2 = ((const LibraryInfo *) p2)->name;
- int slen1 = strlen(str1);
- int slen2 = strlen(str2);
+ size_t slen1 = strlen(str1);
+ size_t slen2 = strlen(str2);
int cmp = strcmp(str1, str2);
if (slen1 != slen2)
- return slen1 - slen2;
+ return pg_cmp_size(slen1, slen2);
if (cmp != 0)
return cmp;
- else
- return ((const LibraryInfo *) p1)->dbnum -
- ((const LibraryInfo *) p2)->dbnum;
+ return pg_cmp_s32(((const LibraryInfo *) p1)->dbnum,
+ ((const LibraryInfo *) p2)->dbnum);
}
#include <limits.h>
#include "common/blkreftable.h"
+#include "common/int.h"
#include "common/logging.h"
#include "fe_utils/option_utils.h"
#include "lib/stringinfo.h"
BlockNumber aa = *(BlockNumber *) a;
BlockNumber bb = *(BlockNumber *) b;
- if (aa > bb)
- return 1;
- else if (aa == bb)
- return 0;
- else
- return -1;
+ return pg_cmp_u32(aa, bb);
}
/*
#include "postgres_fe.h"
#include "common.h"
+#include "common/int.h"
#include "common/logging.h"
#include "crosstabview.h"
#include "pqexpbuffer.h"
static int
rankCompare(const void *a, const void *b)
{
- return *((const int *) a) - *((const int *) b);
+ return pg_cmp_s32(*(const int *) a, *(const int *) b);
}
#include "access/gin.h"
#include "access/ginblock.h"
#include "access/itup.h"
+#include "common/int.h"
#include "catalog/pg_am_d.h"
#include "fmgr.h"
#include "lib/rbtree.h"
uint64 ia = (uint64) GinItemPointerGetBlockNumber(a) << 32 | GinItemPointerGetOffsetNumber(a);
uint64 ib = (uint64) GinItemPointerGetBlockNumber(b) << 32 | GinItemPointerGetOffsetNumber(b);
- if (ia == ib)
- return 0;
- else if (ia > ib)
- return 1;
- else
- return -1;
+ return pg_cmp_u64(ia, ib);
}
extern int ginTraverseLock(Buffer buffer, bool searchMode);