aboutsummaryrefslogtreecommitdiff
path: root/contrib/btree_gist/btree_oid.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/btree_gist/btree_oid.c')
-rw-r--r--contrib/btree_gist/btree_oid.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/contrib/btree_gist/btree_oid.c b/contrib/btree_gist/btree_oid.c
index d9afffe7827..ffe0d7983e4 100644
--- a/contrib/btree_gist/btree_oid.c
+++ b/contrib/btree_gist/btree_oid.c
@@ -5,6 +5,7 @@
#include "btree_gist.h"
#include "btree_utils_num.h"
+#include "utils/sortsupport.h"
typedef struct
{
@@ -21,6 +22,7 @@ PG_FUNCTION_INFO_V1(gbt_oid_consistent);
PG_FUNCTION_INFO_V1(gbt_oid_distance);
PG_FUNCTION_INFO_V1(gbt_oid_penalty);
PG_FUNCTION_INFO_V1(gbt_oid_same);
+PG_FUNCTION_INFO_V1(gbt_oid_sortsupport);
static bool
@@ -209,3 +211,29 @@ gbt_oid_same(PG_FUNCTION_ARGS)
*result = gbt_num_same((void *) b1, (void *) b2, &tinfo, fcinfo->flinfo);
PG_RETURN_POINTER(result);
}
+
+static int
+gbt_oid_ssup_cmp(Datum x, Datum y, SortSupport ssup)
+{
+ oidKEY *arg1 = (oidKEY *) DatumGetPointer(x);
+ oidKEY *arg2 = (oidKEY *) DatumGetPointer(y);
+
+ /* for leaf items we expect lower == upper, so only compare lower */
+ if (arg1->lower > arg2->lower)
+ return 1;
+ else if (arg1->lower < arg2->lower)
+ return -1;
+ else
+ return 0;
+}
+
+Datum
+gbt_oid_sortsupport(PG_FUNCTION_ARGS)
+{
+ SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0);
+
+ ssup->comparator = gbt_oid_ssup_cmp;
+ ssup->ssup_extra = NULL;
+
+ PG_RETURN_VOID();
+}