]> granicus.if.org Git - postgresql/blobdiff - contrib/btree_gist/btree_oid.c
Post-PG 10 beta1 pgindent run
[postgresql] / contrib / btree_gist / btree_oid.c
index c81dd31799eb9a2f61b86ab29d2f05adc8a2db31..e0d6f2adf18236ea5ae100abfd15858ec2c0217f 100644 (file)
@@ -1,6 +1,8 @@
 /*
  * contrib/btree_gist/btree_oid.c
  */
+#include "postgres.h"
+
 #include "btree_gist.h"
 #include "btree_utils_num.h"
 
@@ -14,6 +16,7 @@ typedef struct
 ** OID ops
 */
 PG_FUNCTION_INFO_V1(gbt_oid_compress);
+PG_FUNCTION_INFO_V1(gbt_oid_fetch);
 PG_FUNCTION_INFO_V1(gbt_oid_union);
 PG_FUNCTION_INFO_V1(gbt_oid_picksplit);
 PG_FUNCTION_INFO_V1(gbt_oid_consistent);
@@ -21,46 +24,38 @@ PG_FUNCTION_INFO_V1(gbt_oid_distance);
 PG_FUNCTION_INFO_V1(gbt_oid_penalty);
 PG_FUNCTION_INFO_V1(gbt_oid_same);
 
-Datum          gbt_oid_compress(PG_FUNCTION_ARGS);
-Datum          gbt_oid_union(PG_FUNCTION_ARGS);
-Datum          gbt_oid_picksplit(PG_FUNCTION_ARGS);
-Datum          gbt_oid_consistent(PG_FUNCTION_ARGS);
-Datum          gbt_oid_distance(PG_FUNCTION_ARGS);
-Datum          gbt_oid_penalty(PG_FUNCTION_ARGS);
-Datum          gbt_oid_same(PG_FUNCTION_ARGS);
-
 
 static bool
-gbt_oidgt(const void *a, const void *b)
+gbt_oidgt(const void *a, const void *b, FmgrInfo *flinfo)
 {
-       return (*((Oid *) a) > *((Oid *) b));
+       return (*((const Oid *) a) > *((const Oid *) b));
 }
 static bool
-gbt_oidge(const void *a, const void *b)
+gbt_oidge(const void *a, const void *b, FmgrInfo *flinfo)
 {
-       return (*((Oid *) a) >= *((Oid *) b));
+       return (*((const Oid *) a) >= *((const Oid *) b));
 }
 static bool
-gbt_oideq(const void *a, const void *b)
+gbt_oideq(const void *a, const void *b, FmgrInfo *flinfo)
 {
-       return (*((Oid *) a) == *((Oid *) b));
+       return (*((const Oid *) a) == *((const Oid *) b));
 }
 static bool
-gbt_oidle(const void *a, const void *b)
+gbt_oidle(const void *a, const void *b, FmgrInfo *flinfo)
 {
-       return (*((Oid *) a) <= *((Oid *) b));
+       return (*((const Oid *) a) <= *((const Oid *) b));
 }
 static bool
-gbt_oidlt(const void *a, const void *b)
+gbt_oidlt(const void *a, const void *b, FmgrInfo *flinfo)
 {
-       return (*((Oid *) a) < *((Oid *) b));
+       return (*((const Oid *) a) < *((const Oid *) b));
 }
 
 static int
-gbt_oidkey_cmp(const void *a, const void *b)
+gbt_oidkey_cmp(const void *a, const void *b, FmgrInfo *flinfo)
 {
-       oidKEY     *ia = (oidKEY *) (((Nsrt *) a)->t);
-       oidKEY     *ib = (oidKEY *) (((Nsrt *) b)->t);
+       oidKEY     *ia = (oidKEY *) (((const Nsrt *) a)->t);
+       oidKEY     *ib = (oidKEY *) (((const Nsrt *) b)->t);
 
        if (ia->lower == ib->lower)
        {
@@ -74,7 +69,7 @@ gbt_oidkey_cmp(const void *a, const void *b)
 }
 
 static float8
-gbt_oid_dist(const void *a, const void *b)
+gbt_oid_dist(const void *a, const void *b, FmgrInfo *flinfo)
 {
        Oid                     aa = *(const Oid *) a;
        Oid                     bb = *(const Oid *) b;
@@ -90,6 +85,7 @@ static const gbtree_ninfo tinfo =
 {
        gbt_t_oid,
        sizeof(Oid),
+       8,                                                      /* sizeof(gbtreekey8) */
        gbt_oidgt,
        gbt_oidge,
        gbt_oideq,
@@ -101,13 +97,12 @@ static const gbtree_ninfo tinfo =
 
 
 PG_FUNCTION_INFO_V1(oid_dist);
-Datum       oid_dist(PG_FUNCTION_ARGS);
 Datum
 oid_dist(PG_FUNCTION_ARGS)
 {
-    Oid                a = PG_GETARG_OID(0);
-       Oid             b = PG_GETARG_OID(1);
-       Oid             res;
+       Oid                     a = PG_GETARG_OID(0);
+       Oid                     b = PG_GETARG_OID(1);
+       Oid                     res;
 
        if (a < b)
                res = b - a;
@@ -126,11 +121,17 @@ Datum
 gbt_oid_compress(PG_FUNCTION_ARGS)
 {
        GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
-       GISTENTRY  *retval = NULL;
 
-       PG_RETURN_POINTER(gbt_num_compress(retval, entry, &tinfo));
+       PG_RETURN_POINTER(gbt_num_compress(entry, &tinfo));
 }
 
+Datum
+gbt_oid_fetch(PG_FUNCTION_ARGS)
+{
+       GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
+
+       PG_RETURN_POINTER(gbt_num_fetch(entry, &tinfo));
+}
 
 Datum
 gbt_oid_consistent(PG_FUNCTION_ARGS)
@@ -151,7 +152,7 @@ gbt_oid_consistent(PG_FUNCTION_ARGS)
        key.upper = (GBT_NUMKEY *) &kkk->upper;
 
        PG_RETURN_BOOL(
-                                  gbt_num_consistent(&key, (void *) &query, &strategy, GIST_LEAF(entry), &tinfo)
+                                  gbt_num_consistent(&key, (void *) &query, &strategy, GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
                );
 }
 
@@ -170,7 +171,7 @@ gbt_oid_distance(PG_FUNCTION_ARGS)
        key.upper = (GBT_NUMKEY *) &kkk->upper;
 
        PG_RETURN_FLOAT8(
-                                  gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
+                                        gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
                );
 }
 
@@ -182,7 +183,7 @@ gbt_oid_union(PG_FUNCTION_ARGS)
        void       *out = palloc(sizeof(oidKEY));
 
        *(int *) PG_GETARG_POINTER(1) = sizeof(oidKEY);
-       PG_RETURN_POINTER(gbt_num_union((void *) out, entryvec, &tinfo));
+       PG_RETURN_POINTER(gbt_num_union((void *) out, entryvec, &tinfo, fcinfo->flinfo));
 }
 
 
@@ -204,7 +205,7 @@ gbt_oid_picksplit(PG_FUNCTION_ARGS)
        PG_RETURN_POINTER(gbt_num_picksplit(
                                                                        (GistEntryVector *) PG_GETARG_POINTER(0),
                                                                          (GIST_SPLITVEC *) PG_GETARG_POINTER(1),
-                                                                               &tinfo
+                                                                               &tinfo, fcinfo->flinfo
                                                                                ));
 }
 
@@ -215,6 +216,6 @@ gbt_oid_same(PG_FUNCTION_ARGS)
        oidKEY     *b2 = (oidKEY *) PG_GETARG_POINTER(1);
        bool       *result = (bool *) PG_GETARG_POINTER(2);
 
-       *result = gbt_num_same((void *) b1, (void *) b2, &tinfo);
+       *result = gbt_num_same((void *) b1, (void *) b2, &tinfo, fcinfo->flinfo);
        PG_RETURN_POINTER(result);
 }