#include "postgres.h"#include "utils/builtins.h"#include "utils/sortsupport.h"
Go to the source code of this file.
Functions | |
| Datum | btboolcmp (PG_FUNCTION_ARGS) |
| Datum | btint2cmp (PG_FUNCTION_ARGS) |
| static int | btint2fastcmp (Datum x, Datum y, SortSupport ssup) |
| Datum | btint2sortsupport (PG_FUNCTION_ARGS) |
| Datum | btint4cmp (PG_FUNCTION_ARGS) |
| static int | btint4fastcmp (Datum x, Datum y, SortSupport ssup) |
| Datum | btint4sortsupport (PG_FUNCTION_ARGS) |
| Datum | btint8cmp (PG_FUNCTION_ARGS) |
| static int | btint8fastcmp (Datum x, Datum y, SortSupport ssup) |
| Datum | btint8sortsupport (PG_FUNCTION_ARGS) |
| Datum | btint48cmp (PG_FUNCTION_ARGS) |
| Datum | btint84cmp (PG_FUNCTION_ARGS) |
| Datum | btint24cmp (PG_FUNCTION_ARGS) |
| Datum | btint42cmp (PG_FUNCTION_ARGS) |
| Datum | btint28cmp (PG_FUNCTION_ARGS) |
| Datum | btint82cmp (PG_FUNCTION_ARGS) |
| Datum | btoidcmp (PG_FUNCTION_ARGS) |
| static int | btoidfastcmp (Datum x, Datum y, SortSupport ssup) |
| Datum | btoidsortsupport (PG_FUNCTION_ARGS) |
| Datum | btoidvectorcmp (PG_FUNCTION_ARGS) |
| Datum | btcharcmp (PG_FUNCTION_ARGS) |
| Datum | btnamecmp (PG_FUNCTION_ARGS) |
| static int | btnamefastcmp (Datum x, Datum y, SortSupport ssup) |
| Datum | btnamesortsupport (PG_FUNCTION_ARGS) |
| Datum btboolcmp | ( | PG_FUNCTION_ARGS | ) |
Definition at line 56 of file nbtcompare.c.
References PG_GETARG_BOOL, and PG_RETURN_INT32.
{
bool a = PG_GETARG_BOOL(0);
bool b = PG_GETARG_BOOL(1);
PG_RETURN_INT32((int32) a - (int32) b);
}
| Datum btcharcmp | ( | PG_FUNCTION_ARGS | ) |
Definition at line 311 of file nbtcompare.c.
References PG_GETARG_CHAR, and PG_RETURN_INT32.
{
char a = PG_GETARG_CHAR(0);
char b = PG_GETARG_CHAR(1);
/* Be careful to compare chars as unsigned */
PG_RETURN_INT32((int32) ((uint8) a) - (int32) ((uint8) b));
}
| Datum btint24cmp | ( | PG_FUNCTION_ARGS | ) |
Definition at line 194 of file nbtcompare.c.
References PG_GETARG_INT16, PG_GETARG_INT32, and PG_RETURN_INT32.
{
int16 a = PG_GETARG_INT16(0);
int32 b = PG_GETARG_INT32(1);
if (a > b)
PG_RETURN_INT32(1);
else if (a == b)
PG_RETURN_INT32(0);
else
PG_RETURN_INT32(-1);
}
| Datum btint28cmp | ( | PG_FUNCTION_ARGS | ) |
Definition at line 222 of file nbtcompare.c.
References PG_GETARG_INT16, PG_GETARG_INT64, and PG_RETURN_INT32.
{
int16 a = PG_GETARG_INT16(0);
int64 b = PG_GETARG_INT64(1);
if (a > b)
PG_RETURN_INT32(1);
else if (a == b)
PG_RETURN_INT32(0);
else
PG_RETURN_INT32(-1);
}
| Datum btint2cmp | ( | PG_FUNCTION_ARGS | ) |
Definition at line 65 of file nbtcompare.c.
References PG_GETARG_INT16, and PG_RETURN_INT32.
{
int16 a = PG_GETARG_INT16(0);
int16 b = PG_GETARG_INT16(1);
PG_RETURN_INT32((int32) a - (int32) b);
}
| static int btint2fastcmp | ( | Datum | x, | |
| Datum | y, | |||
| SortSupport | ssup | |||
| ) | [static] |
Definition at line 74 of file nbtcompare.c.
References DatumGetInt16.
{
int16 a = DatumGetInt16(x);
int16 b = DatumGetInt16(y);
return (int) a - (int) b;
}
| Datum btint2sortsupport | ( | PG_FUNCTION_ARGS | ) |
Definition at line 83 of file nbtcompare.c.
References SortSupportData::comparator, PG_GETARG_POINTER, and PG_RETURN_VOID.
{
SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0);
ssup->comparator = btint2fastcmp;
PG_RETURN_VOID();
}
| Datum btint42cmp | ( | PG_FUNCTION_ARGS | ) |
Definition at line 208 of file nbtcompare.c.
References PG_GETARG_INT16, PG_GETARG_INT32, and PG_RETURN_INT32.
{
int32 a = PG_GETARG_INT32(0);
int16 b = PG_GETARG_INT16(1);
if (a > b)
PG_RETURN_INT32(1);
else if (a == b)
PG_RETURN_INT32(0);
else
PG_RETURN_INT32(-1);
}
| Datum btint48cmp | ( | PG_FUNCTION_ARGS | ) |
Definition at line 166 of file nbtcompare.c.
References PG_GETARG_INT32, PG_GETARG_INT64, and PG_RETURN_INT32.
{
int32 a = PG_GETARG_INT32(0);
int64 b = PG_GETARG_INT64(1);
if (a > b)
PG_RETURN_INT32(1);
else if (a == b)
PG_RETURN_INT32(0);
else
PG_RETURN_INT32(-1);
}
| Datum btint4cmp | ( | PG_FUNCTION_ARGS | ) |
Definition at line 92 of file nbtcompare.c.
References PG_GETARG_INT32, and PG_RETURN_INT32.
{
int32 a = PG_GETARG_INT32(0);
int32 b = PG_GETARG_INT32(1);
if (a > b)
PG_RETURN_INT32(1);
else if (a == b)
PG_RETURN_INT32(0);
else
PG_RETURN_INT32(-1);
}
| static int btint4fastcmp | ( | Datum | x, | |
| Datum | y, | |||
| SortSupport | ssup | |||
| ) | [static] |
Definition at line 106 of file nbtcompare.c.
References DatumGetInt32.
{
int32 a = DatumGetInt32(x);
int32 b = DatumGetInt32(y);
if (a > b)
return 1;
else if (a == b)
return 0;
else
return -1;
}
| Datum btint4sortsupport | ( | PG_FUNCTION_ARGS | ) |
Definition at line 120 of file nbtcompare.c.
References SortSupportData::comparator, PG_GETARG_POINTER, and PG_RETURN_VOID.
{
SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0);
ssup->comparator = btint4fastcmp;
PG_RETURN_VOID();
}
| Datum btint82cmp | ( | PG_FUNCTION_ARGS | ) |
Definition at line 236 of file nbtcompare.c.
References PG_GETARG_INT16, PG_GETARG_INT64, and PG_RETURN_INT32.
{
int64 a = PG_GETARG_INT64(0);
int16 b = PG_GETARG_INT16(1);
if (a > b)
PG_RETURN_INT32(1);
else if (a == b)
PG_RETURN_INT32(0);
else
PG_RETURN_INT32(-1);
}
| Datum btint84cmp | ( | PG_FUNCTION_ARGS | ) |
Definition at line 180 of file nbtcompare.c.
References PG_GETARG_INT32, PG_GETARG_INT64, and PG_RETURN_INT32.
{
int64 a = PG_GETARG_INT64(0);
int32 b = PG_GETARG_INT32(1);
if (a > b)
PG_RETURN_INT32(1);
else if (a == b)
PG_RETURN_INT32(0);
else
PG_RETURN_INT32(-1);
}
| Datum btint8cmp | ( | PG_FUNCTION_ARGS | ) |
Definition at line 129 of file nbtcompare.c.
References PG_GETARG_INT64, and PG_RETURN_INT32.
{
int64 a = PG_GETARG_INT64(0);
int64 b = PG_GETARG_INT64(1);
if (a > b)
PG_RETURN_INT32(1);
else if (a == b)
PG_RETURN_INT32(0);
else
PG_RETURN_INT32(-1);
}
| static int btint8fastcmp | ( | Datum | x, | |
| Datum | y, | |||
| SortSupport | ssup | |||
| ) | [static] |
Definition at line 143 of file nbtcompare.c.
References DatumGetInt64.
{
int64 a = DatumGetInt64(x);
int64 b = DatumGetInt64(y);
if (a > b)
return 1;
else if (a == b)
return 0;
else
return -1;
}
| Datum btint8sortsupport | ( | PG_FUNCTION_ARGS | ) |
Definition at line 157 of file nbtcompare.c.
References SortSupportData::comparator, PG_GETARG_POINTER, and PG_RETURN_VOID.
{
SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0);
ssup->comparator = btint8fastcmp;
PG_RETURN_VOID();
}
| Datum btnamecmp | ( | PG_FUNCTION_ARGS | ) |
Definition at line 321 of file nbtcompare.c.
References NAMEDATALEN, NameStr, PG_GETARG_NAME, and PG_RETURN_INT32.
{
Name a = PG_GETARG_NAME(0);
Name b = PG_GETARG_NAME(1);
PG_RETURN_INT32(strncmp(NameStr(*a), NameStr(*b), NAMEDATALEN));
}
| static int btnamefastcmp | ( | Datum | x, | |
| Datum | y, | |||
| SortSupport | ssup | |||
| ) | [static] |
Definition at line 330 of file nbtcompare.c.
References DatumGetName, NAMEDATALEN, and NameStr.
{
Name a = DatumGetName(x);
Name b = DatumGetName(y);
return strncmp(NameStr(*a), NameStr(*b), NAMEDATALEN);
}
| Datum btnamesortsupport | ( | PG_FUNCTION_ARGS | ) |
Definition at line 339 of file nbtcompare.c.
References SortSupportData::comparator, PG_GETARG_POINTER, and PG_RETURN_VOID.
{
SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0);
ssup->comparator = btnamefastcmp;
PG_RETURN_VOID();
}
| Datum btoidcmp | ( | PG_FUNCTION_ARGS | ) |
Definition at line 250 of file nbtcompare.c.
References PG_GETARG_OID, and PG_RETURN_INT32.
{
Oid a = PG_GETARG_OID(0);
Oid b = PG_GETARG_OID(1);
if (a > b)
PG_RETURN_INT32(1);
else if (a == b)
PG_RETURN_INT32(0);
else
PG_RETURN_INT32(-1);
}
| static int btoidfastcmp | ( | Datum | x, | |
| Datum | y, | |||
| SortSupport | ssup | |||
| ) | [static] |
Definition at line 264 of file nbtcompare.c.
References DatumGetObjectId.
{
Oid a = DatumGetObjectId(x);
Oid b = DatumGetObjectId(y);
if (a > b)
return 1;
else if (a == b)
return 0;
else
return -1;
}
| Datum btoidsortsupport | ( | PG_FUNCTION_ARGS | ) |
Definition at line 278 of file nbtcompare.c.
References SortSupportData::comparator, PG_GETARG_POINTER, and PG_RETURN_VOID.
{
SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0);
ssup->comparator = btoidfastcmp;
PG_RETURN_VOID();
}
| Datum btoidvectorcmp | ( | PG_FUNCTION_ARGS | ) |
Definition at line 287 of file nbtcompare.c.
References oidvector::dim1, i, PG_GETARG_POINTER, PG_RETURN_INT32, and oidvector::values.
Referenced by oidvectoreq(), oidvectorge(), oidvectorgt(), oidvectorle(), oidvectorlt(), and oidvectorne().
{
oidvector *a = (oidvector *) PG_GETARG_POINTER(0);
oidvector *b = (oidvector *) PG_GETARG_POINTER(1);
int i;
/* We arbitrarily choose to sort first by vector length */
if (a->dim1 != b->dim1)
PG_RETURN_INT32(a->dim1 - b->dim1);
for (i = 0; i < a->dim1; i++)
{
if (a->values[i] != b->values[i])
{
if (a->values[i] > b->values[i])
PG_RETURN_INT32(1);
else
PG_RETURN_INT32(-1);
}
}
PG_RETURN_INT32(0);
}
1.7.1