]> granicus.if.org Git - postgresql/commitdiff
Use CallerFInfoFunctionCall with btree_gist for varlena types
authorAndrew Dunstan <andrew@dunslane.net>
Tue, 21 Mar 2017 13:53:35 +0000 (09:53 -0400)
committerAndrew Dunstan <andrew@dunslane.net>
Tue, 21 Mar 2017 14:43:27 +0000 (10:43 -0400)
Follow up to commit 393bb504d7 which did this for numeric types.

contrib/btree_gist/btree_bit.c
contrib/btree_gist/btree_bytea.c
contrib/btree_gist/btree_numeric.c
contrib/btree_gist/btree_text.c
contrib/btree_gist/btree_utils_var.c
contrib/btree_gist/btree_utils_var.h

index f34fa87f9dbb2290a3e507ecfd9f1fedac96fbd6..a56a2752a7330453089725187f84ad6b6bf4e69d 100644 (file)
@@ -24,7 +24,7 @@ PG_FUNCTION_INFO_V1(gbt_bit_same);
 /* define for comparison */
 
 static bool
-gbt_bitgt(const void *a, const void *b, Oid collation)
+gbt_bitgt(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 {
        return DatumGetBool(DirectFunctionCall2(bitgt,
                                                                                        PointerGetDatum(a),
@@ -32,7 +32,7 @@ gbt_bitgt(const void *a, const void *b, Oid collation)
 }
 
 static bool
-gbt_bitge(const void *a, const void *b, Oid collation)
+gbt_bitge(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 {
        return DatumGetBool(DirectFunctionCall2(bitge,
                                                                                        PointerGetDatum(a),
@@ -40,7 +40,7 @@ gbt_bitge(const void *a, const void *b, Oid collation)
 }
 
 static bool
-gbt_biteq(const void *a, const void *b, Oid collation)
+gbt_biteq(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 {
        return DatumGetBool(DirectFunctionCall2(biteq,
                                                                                        PointerGetDatum(a),
@@ -48,7 +48,7 @@ gbt_biteq(const void *a, const void *b, Oid collation)
 }
 
 static bool
-gbt_bitle(const void *a, const void *b, Oid collation)
+gbt_bitle(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 {
        return DatumGetBool(DirectFunctionCall2(bitle,
                                                                                        PointerGetDatum(a),
@@ -56,7 +56,7 @@ gbt_bitle(const void *a, const void *b, Oid collation)
 }
 
 static bool
-gbt_bitlt(const void *a, const void *b, Oid collation)
+gbt_bitlt(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 {
        return DatumGetBool(DirectFunctionCall2(bitlt,
                                                                                        PointerGetDatum(a),
@@ -64,7 +64,7 @@ gbt_bitlt(const void *a, const void *b, Oid collation)
 }
 
 static int32
-gbt_bitcmp(const void *a, const void *b, Oid collation)
+gbt_bitcmp(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 {
        return DatumGetInt32(DirectFunctionCall2(byteacmp,
                                                                                         PointerGetDatum(a),
@@ -92,7 +92,7 @@ gbt_bit_xfrm(bytea *leaf)
 
 
 static GBT_VARKEY *
-gbt_bit_l2n(GBT_VARKEY *leaf)
+gbt_bit_l2n(GBT_VARKEY *leaf, FmgrInfo *flinfo)
 {
        GBT_VARKEY *out = leaf;
        GBT_VARKEY_R r = gbt_var_key_readable(leaf);
@@ -152,13 +152,13 @@ gbt_bit_consistent(PG_FUNCTION_ARGS)
 
        if (GIST_LEAF(entry))
                retval = gbt_var_consistent(&r, query, strategy, PG_GET_COLLATION(),
-                                                                       TRUE, &tinfo);
+                                                                       TRUE, &tinfo, fcinfo->flinfo);
        else
        {
                bytea      *q = gbt_bit_xfrm((bytea *) query);
 
                retval = gbt_var_consistent(&r, q, strategy, PG_GET_COLLATION(),
-                                                                       FALSE, &tinfo);
+                                                                       FALSE, &tinfo, fcinfo->flinfo);
        }
        PG_RETURN_BOOL(retval);
 }
@@ -172,7 +172,7 @@ gbt_bit_union(PG_FUNCTION_ARGS)
        int32      *size = (int *) PG_GETARG_POINTER(1);
 
        PG_RETURN_POINTER(gbt_var_union(entryvec, size, PG_GET_COLLATION(),
-                                                                       &tinfo));
+                                                                       &tinfo, fcinfo->flinfo));
 }
 
 
@@ -183,7 +183,7 @@ gbt_bit_picksplit(PG_FUNCTION_ARGS)
        GIST_SPLITVEC *v = (GIST_SPLITVEC *) PG_GETARG_POINTER(1);
 
        gbt_var_picksplit(entryvec, v, PG_GET_COLLATION(),
-                                         &tinfo);
+                                         &tinfo, fcinfo->flinfo);
        PG_RETURN_POINTER(v);
 }
 
@@ -194,7 +194,7 @@ gbt_bit_same(PG_FUNCTION_ARGS)
        Datum           d2 = PG_GETARG_DATUM(1);
        bool       *result = (bool *) PG_GETARG_POINTER(2);
 
-       *result = gbt_var_same(d1, d2, PG_GET_COLLATION(), &tinfo);
+       *result = gbt_var_same(d1, d2, PG_GET_COLLATION(), &tinfo, fcinfo->flinfo);
        PG_RETURN_POINTER(result);
 }
 
@@ -207,5 +207,5 @@ gbt_bit_penalty(PG_FUNCTION_ARGS)
        float      *result = (float *) PG_GETARG_POINTER(2);
 
        PG_RETURN_POINTER(gbt_var_penalty(result, o, n, PG_GET_COLLATION(),
-                                                                         &tinfo));
+                                                                         &tinfo, fcinfo->flinfo));
 }
index df6c960ce59fdedc2fd7d30a8009d88a10b7a763..00753e7f48998c3a385293cd45994f6d744b016d 100644 (file)
@@ -23,7 +23,7 @@ PG_FUNCTION_INFO_V1(gbt_bytea_same);
 /* define for comparison */
 
 static bool
-gbt_byteagt(const void *a, const void *b, Oid collation)
+gbt_byteagt(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 {
        return DatumGetBool(DirectFunctionCall2(byteagt,
                                                                                        PointerGetDatum(a),
@@ -31,7 +31,7 @@ gbt_byteagt(const void *a, const void *b, Oid collation)
 }
 
 static bool
-gbt_byteage(const void *a, const void *b, Oid collation)
+gbt_byteage(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 {
        return DatumGetBool(DirectFunctionCall2(byteage,
                                                                                        PointerGetDatum(a),
@@ -39,7 +39,7 @@ gbt_byteage(const void *a, const void *b, Oid collation)
 }
 
 static bool
-gbt_byteaeq(const void *a, const void *b, Oid collation)
+gbt_byteaeq(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 {
        return DatumGetBool(DirectFunctionCall2(byteaeq,
                                                                                        PointerGetDatum(a),
@@ -47,7 +47,7 @@ gbt_byteaeq(const void *a, const void *b, Oid collation)
 }
 
 static bool
-gbt_byteale(const void *a, const void *b, Oid collation)
+gbt_byteale(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 {
        return DatumGetBool(DirectFunctionCall2(byteale,
                                                                                        PointerGetDatum(a),
@@ -55,7 +55,7 @@ gbt_byteale(const void *a, const void *b, Oid collation)
 }
 
 static bool
-gbt_bytealt(const void *a, const void *b, Oid collation)
+gbt_bytealt(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 {
        return DatumGetBool(DirectFunctionCall2(bytealt,
                                                                                        PointerGetDatum(a),
@@ -63,7 +63,7 @@ gbt_bytealt(const void *a, const void *b, Oid collation)
 }
 
 static int32
-gbt_byteacmp(const void *a, const void *b, Oid collation)
+gbt_byteacmp(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 {
        return DatumGetInt32(DirectFunctionCall2(byteacmp,
                                                                                         PointerGetDatum(a),
@@ -118,7 +118,7 @@ gbt_bytea_consistent(PG_FUNCTION_ARGS)
        *recheck = false;
 
        retval = gbt_var_consistent(&r, query, strategy, PG_GET_COLLATION(),
-                                                               GIST_LEAF(entry), &tinfo);
+                                                               GIST_LEAF(entry), &tinfo, fcinfo->flinfo);
        PG_RETURN_BOOL(retval);
 }
 
@@ -131,7 +131,7 @@ gbt_bytea_union(PG_FUNCTION_ARGS)
        int32      *size = (int *) PG_GETARG_POINTER(1);
 
        PG_RETURN_POINTER(gbt_var_union(entryvec, size, PG_GET_COLLATION(),
-                                                                       &tinfo));
+                                                                       &tinfo, fcinfo->flinfo));
 }
 
 
@@ -142,7 +142,7 @@ gbt_bytea_picksplit(PG_FUNCTION_ARGS)
        GIST_SPLITVEC *v = (GIST_SPLITVEC *) PG_GETARG_POINTER(1);
 
        gbt_var_picksplit(entryvec, v, PG_GET_COLLATION(),
-                                         &tinfo);
+                                         &tinfo, fcinfo->flinfo);
        PG_RETURN_POINTER(v);
 }
 
@@ -153,7 +153,7 @@ gbt_bytea_same(PG_FUNCTION_ARGS)
        Datum           d2 = PG_GETARG_DATUM(1);
        bool       *result = (bool *) PG_GETARG_POINTER(2);
 
-       *result = gbt_var_same(d1, d2, PG_GET_COLLATION(), &tinfo);
+       *result = gbt_var_same(d1, d2, PG_GET_COLLATION(), &tinfo, fcinfo->flinfo);
        PG_RETURN_POINTER(result);
 }
 
@@ -166,5 +166,5 @@ gbt_bytea_penalty(PG_FUNCTION_ARGS)
        float      *result = (float *) PG_GETARG_POINTER(2);
 
        PG_RETURN_POINTER(gbt_var_penalty(result, o, n, PG_GET_COLLATION(),
-                                                                         &tinfo));
+                                                                         &tinfo, fcinfo->flinfo));
 }
index 47b00209c8dbe6ce8e53db90a8fc2729a1d8f893..43793d36a263d81404f5baa3a5d74d594d3cd5e5 100644 (file)
@@ -27,7 +27,7 @@ PG_FUNCTION_INFO_V1(gbt_numeric_same);
 /* define for comparison */
 
 static bool
-gbt_numeric_gt(const void *a, const void *b, Oid collation)
+gbt_numeric_gt(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 {
        return DatumGetBool(DirectFunctionCall2(numeric_gt,
                                                                                        PointerGetDatum(a),
@@ -35,7 +35,7 @@ gbt_numeric_gt(const void *a, const void *b, Oid collation)
 }
 
 static bool
-gbt_numeric_ge(const void *a, const void *b, Oid collation)
+gbt_numeric_ge(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 {
        return DatumGetBool(DirectFunctionCall2(numeric_ge,
                                                                                        PointerGetDatum(a),
@@ -43,7 +43,7 @@ gbt_numeric_ge(const void *a, const void *b, Oid collation)
 }
 
 static bool
-gbt_numeric_eq(const void *a, const void *b, Oid collation)
+gbt_numeric_eq(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 {
        return DatumGetBool(DirectFunctionCall2(numeric_eq,
                                                                                        PointerGetDatum(a),
@@ -51,7 +51,7 @@ gbt_numeric_eq(const void *a, const void *b, Oid collation)
 }
 
 static bool
-gbt_numeric_le(const void *a, const void *b, Oid collation)
+gbt_numeric_le(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 {
        return DatumGetBool(DirectFunctionCall2(numeric_le,
                                                                                        PointerGetDatum(a),
@@ -59,7 +59,7 @@ gbt_numeric_le(const void *a, const void *b, Oid collation)
 }
 
 static bool
-gbt_numeric_lt(const void *a, const void *b, Oid collation)
+gbt_numeric_lt(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 {
        return DatumGetBool(DirectFunctionCall2(numeric_lt,
                                                                                        PointerGetDatum(a),
@@ -67,7 +67,7 @@ gbt_numeric_lt(const void *a, const void *b, Oid collation)
 }
 
 static int32
-gbt_numeric_cmp(const void *a, const void *b, Oid collation)
+gbt_numeric_cmp(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 {
        return DatumGetInt32(DirectFunctionCall2(numeric_cmp,
                                                                                         PointerGetDatum(a),
@@ -122,7 +122,7 @@ gbt_numeric_consistent(PG_FUNCTION_ARGS)
        *recheck = false;
 
        retval = gbt_var_consistent(&r, query, strategy, PG_GET_COLLATION(),
-                                                               GIST_LEAF(entry), &tinfo);
+                                                               GIST_LEAF(entry), &tinfo, fcinfo->flinfo);
        PG_RETURN_BOOL(retval);
 }
 
@@ -135,7 +135,7 @@ gbt_numeric_union(PG_FUNCTION_ARGS)
        int32      *size = (int *) PG_GETARG_POINTER(1);
 
        PG_RETURN_POINTER(gbt_var_union(entryvec, size, PG_GET_COLLATION(),
-                                                                       &tinfo));
+                                                                       &tinfo, fcinfo->flinfo));
 }
 
 
@@ -146,7 +146,7 @@ gbt_numeric_same(PG_FUNCTION_ARGS)
        Datum           d2 = PG_GETARG_DATUM(1);
        bool       *result = (bool *) PG_GETARG_POINTER(2);
 
-       *result = gbt_var_same(d1, d2, PG_GET_COLLATION(), &tinfo);
+       *result = gbt_var_same(d1, d2, PG_GET_COLLATION(), &tinfo, fcinfo->flinfo);
        PG_RETURN_POINTER(result);
 }
 
@@ -171,7 +171,7 @@ gbt_numeric_penalty(PG_FUNCTION_ARGS)
 
        rk = gbt_var_key_readable(org);
        uni = PointerGetDatum(gbt_var_key_copy(&rk));
-       gbt_var_bin_union(&uni, newe, PG_GET_COLLATION(), &tinfo);
+       gbt_var_bin_union(&uni, newe, PG_GET_COLLATION(), &tinfo, fcinfo->flinfo);
        ok = gbt_var_key_readable(org);
        uk = gbt_var_key_readable((GBT_VARKEY *) DatumGetPointer(uni));
 
@@ -233,6 +233,6 @@ gbt_numeric_picksplit(PG_FUNCTION_ARGS)
        GIST_SPLITVEC *v = (GIST_SPLITVEC *) PG_GETARG_POINTER(1);
 
        gbt_var_picksplit(entryvec, v, PG_GET_COLLATION(),
-                                         &tinfo);
+                                         &tinfo, fcinfo->flinfo);
        PG_RETURN_POINTER(v);
 }
index 2e00cb60bad28b9090ef1f30ecc92c6988d5fa18..090c8494701ecf770b63ecf4138f1207659cfc8b 100644 (file)
@@ -23,7 +23,7 @@ PG_FUNCTION_INFO_V1(gbt_text_same);
 /* define for comparison */
 
 static bool
-gbt_textgt(const void *a, const void *b, Oid collation)
+gbt_textgt(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 {
        return DatumGetBool(DirectFunctionCall2Coll(text_gt,
                                                                                                collation,
@@ -32,7 +32,7 @@ gbt_textgt(const void *a, const void *b, Oid collation)
 }
 
 static bool
-gbt_textge(const void *a, const void *b, Oid collation)
+gbt_textge(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 {
        return DatumGetBool(DirectFunctionCall2Coll(text_ge,
                                                                                                collation,
@@ -41,7 +41,7 @@ gbt_textge(const void *a, const void *b, Oid collation)
 }
 
 static bool
-gbt_texteq(const void *a, const void *b, Oid collation)
+gbt_texteq(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 {
        return DatumGetBool(DirectFunctionCall2Coll(texteq,
                                                                                                collation,
@@ -50,7 +50,7 @@ gbt_texteq(const void *a, const void *b, Oid collation)
 }
 
 static bool
-gbt_textle(const void *a, const void *b, Oid collation)
+gbt_textle(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 {
        return DatumGetBool(DirectFunctionCall2Coll(text_le,
                                                                                                collation,
@@ -59,7 +59,7 @@ gbt_textle(const void *a, const void *b, Oid collation)
 }
 
 static bool
-gbt_textlt(const void *a, const void *b, Oid collation)
+gbt_textlt(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 {
        return DatumGetBool(DirectFunctionCall2Coll(text_lt,
                                                                                                collation,
@@ -68,7 +68,7 @@ gbt_textlt(const void *a, const void *b, Oid collation)
 }
 
 static int32
-gbt_textcmp(const void *a, const void *b, Oid collation)
+gbt_textcmp(const void *a, const void *b, Oid collation, FmgrInfo *flinfo)
 {
        return DatumGetInt32(DirectFunctionCall2Coll(bttextcmp,
                                                                                                 collation,
@@ -161,7 +161,7 @@ gbt_text_consistent(PG_FUNCTION_ARGS)
        }
 
        retval = gbt_var_consistent(&r, query, strategy, PG_GET_COLLATION(),
-                                                               GIST_LEAF(entry), &tinfo);
+                                                               GIST_LEAF(entry), &tinfo, fcinfo->flinfo);
 
        PG_RETURN_BOOL(retval);
 }
@@ -190,7 +190,7 @@ gbt_bpchar_consistent(PG_FUNCTION_ARGS)
        }
 
        retval = gbt_var_consistent(&r, trim, strategy, PG_GET_COLLATION(),
-                                                               GIST_LEAF(entry), &tinfo);
+                                                               GIST_LEAF(entry), &tinfo, fcinfo->flinfo);
        PG_RETURN_BOOL(retval);
 }
 
@@ -202,7 +202,7 @@ gbt_text_union(PG_FUNCTION_ARGS)
        int32      *size = (int *) PG_GETARG_POINTER(1);
 
        PG_RETURN_POINTER(gbt_var_union(entryvec, size, PG_GET_COLLATION(),
-                                                                       &tinfo));
+                                                                       &tinfo, fcinfo->flinfo));
 }
 
 
@@ -213,7 +213,7 @@ gbt_text_picksplit(PG_FUNCTION_ARGS)
        GIST_SPLITVEC *v = (GIST_SPLITVEC *) PG_GETARG_POINTER(1);
 
        gbt_var_picksplit(entryvec, v, PG_GET_COLLATION(),
-                                         &tinfo);
+                                         &tinfo, fcinfo->flinfo);
        PG_RETURN_POINTER(v);
 }
 
@@ -224,7 +224,7 @@ gbt_text_same(PG_FUNCTION_ARGS)
        Datum           d2 = PG_GETARG_DATUM(1);
        bool       *result = (bool *) PG_GETARG_POINTER(2);
 
-       *result = gbt_var_same(d1, d2, PG_GET_COLLATION(), &tinfo);
+       *result = gbt_var_same(d1, d2, PG_GET_COLLATION(), &tinfo, fcinfo->flinfo);
        PG_RETURN_POINTER(result);
 }
 
@@ -237,5 +237,5 @@ gbt_text_penalty(PG_FUNCTION_ARGS)
        float      *result = (float *) PG_GETARG_POINTER(2);
 
        PG_RETURN_POINTER(gbt_var_penalty(result, o, n, PG_GET_COLLATION(),
-                                                                         &tinfo));
+                                                                         &tinfo, fcinfo->flinfo));
 }
index 70b3794325b535306488643da52069221587b10f..e0b4b377796a5b3a74a2f48f57744065c7941936 100644 (file)
@@ -25,6 +25,7 @@ typedef struct
 {
        const gbtree_vinfo *tinfo;
        Oid                     collation;
+       FmgrInfo *flinfo;
 } gbt_vsrt_arg;
 
 
@@ -103,12 +104,12 @@ gbt_var_key_copy(const GBT_VARKEY_R *u)
 
 
 static GBT_VARKEY *
-gbt_var_leaf2node(GBT_VARKEY *leaf, const gbtree_vinfo *tinfo)
+gbt_var_leaf2node(GBT_VARKEY *leaf, const gbtree_vinfo *tinfo, FmgrInfo *flinfo)
 {
        GBT_VARKEY *out = leaf;
 
        if (tinfo->f_l2n)
-               out = (*tinfo->f_l2n) (leaf);
+               out = (*tinfo->f_l2n) (leaf, flinfo);
 
        return out;
 }
@@ -232,7 +233,7 @@ gbt_var_node_truncate(const GBT_VARKEY *node, int32 cpf_length, const gbtree_vin
 
 void
 gbt_var_bin_union(Datum *u, GBT_VARKEY *e, Oid collation,
-                                 const gbtree_vinfo *tinfo)
+                                 const gbtree_vinfo *tinfo, FmgrInfo *flinfo)
 {
        GBT_VARKEY_R eo = gbt_var_key_readable(e);
        GBT_VARKEY_R nr;
@@ -241,7 +242,7 @@ gbt_var_bin_union(Datum *u, GBT_VARKEY *e, Oid collation,
        {
                GBT_VARKEY *tmp;
 
-               tmp = gbt_var_leaf2node(e, tinfo);
+               tmp = gbt_var_leaf2node(e, tinfo, flinfo);
                if (tmp != e)
                        eo = gbt_var_key_readable(tmp);
        }
@@ -254,13 +255,13 @@ gbt_var_bin_union(Datum *u, GBT_VARKEY *e, Oid collation,
                nr.lower = ro.lower;
                nr.upper = ro.upper;
 
-               if ((*tinfo->f_cmp) (ro.lower, eo.lower, collation) > 0)
+               if ((*tinfo->f_cmp) (ro.lower, eo.lower, collation, flinfo) > 0)
                {
                        nr.lower = eo.lower;
                        update = true;
                }
 
-               if ((*tinfo->f_cmp) (ro.upper, eo.upper, collation) < 0)
+               if ((*tinfo->f_cmp) (ro.upper, eo.upper, collation, flinfo) < 0)
                {
                        nr.upper = eo.upper;
                        update = true;
@@ -321,7 +322,7 @@ gbt_var_fetch(PG_FUNCTION_ARGS)
 
 GBT_VARKEY *
 gbt_var_union(const GistEntryVector *entryvec, int32 *size, Oid collation,
-                         const gbtree_vinfo *tinfo)
+                         const gbtree_vinfo *tinfo, FmgrInfo *flinfo)
 {
        int                     i = 0,
                                numranges = entryvec->n;
@@ -338,7 +339,7 @@ gbt_var_union(const GistEntryVector *entryvec, int32 *size, Oid collation,
        for (i = 1; i < numranges; i++)
        {
                cur = (GBT_VARKEY *) DatumGetPointer(entryvec->vector[i].key);
-               gbt_var_bin_union(&out, cur, collation, tinfo);
+               gbt_var_bin_union(&out, cur, collation, tinfo, flinfo);
        }
 
 
@@ -360,7 +361,7 @@ gbt_var_union(const GistEntryVector *entryvec, int32 *size, Oid collation,
 
 bool
 gbt_var_same(Datum d1, Datum d2, Oid collation,
-                        const gbtree_vinfo *tinfo)
+                        const gbtree_vinfo *tinfo, FmgrInfo *flinfo)
 {
        GBT_VARKEY *t1 = (GBT_VARKEY *) DatumGetPointer(d1);
        GBT_VARKEY *t2 = (GBT_VARKEY *) DatumGetPointer(d2);
@@ -370,14 +371,14 @@ gbt_var_same(Datum d1, Datum d2, Oid collation,
        r1 = gbt_var_key_readable(t1);
        r2 = gbt_var_key_readable(t2);
 
-       return ((*tinfo->f_cmp) (r1.lower, r2.lower, collation) == 0 &&
-                       (*tinfo->f_cmp) (r1.upper, r2.upper, collation) == 0);
+       return ((*tinfo->f_cmp) (r1.lower, r2.lower, collation, flinfo) == 0 &&
+                       (*tinfo->f_cmp) (r1.upper, r2.upper, collation, flinfo) == 0);
 }
 
 
 float *
 gbt_var_penalty(float *res, const GISTENTRY *o, const GISTENTRY *n,
-                               Oid collation, const gbtree_vinfo *tinfo)
+                               Oid collation, const gbtree_vinfo *tinfo, FmgrInfo *flinfo)
 {
        GBT_VARKEY *orge = (GBT_VARKEY *) DatumGetPointer(o->key);
        GBT_VARKEY *newe = (GBT_VARKEY *) DatumGetPointer(n->key);
@@ -391,7 +392,7 @@ gbt_var_penalty(float *res, const GISTENTRY *o, const GISTENTRY *n,
        {
                GBT_VARKEY *tmp;
 
-               tmp = gbt_var_leaf2node(newe, tinfo);
+               tmp = gbt_var_leaf2node(newe, tinfo, flinfo);
                if (tmp != newe)
                        nk = gbt_var_key_readable(tmp);
        }
@@ -399,9 +400,9 @@ gbt_var_penalty(float *res, const GISTENTRY *o, const GISTENTRY *n,
 
        if ((VARSIZE(ok.lower) - VARHDRSZ) == 0 && (VARSIZE(ok.upper) - VARHDRSZ) == 0)
                *res = 0.0;
-       else if (!(((*tinfo->f_cmp) (nk.lower, ok.lower, collation) >= 0 ||
+       else if (!(((*tinfo->f_cmp) (nk.lower, ok.lower, collation, flinfo) >= 0 ||
                                gbt_bytea_pf_match(ok.lower, nk.lower, tinfo)) &&
-                          ((*tinfo->f_cmp) (nk.upper, ok.upper, collation) <= 0 ||
+                          ((*tinfo->f_cmp) (nk.upper, ok.upper, collation, flinfo) <= 0 ||
                                gbt_bytea_pf_match(ok.upper, nk.upper, tinfo))))
        {
                Datum           d = PointerGetDatum(0);
@@ -409,9 +410,9 @@ gbt_var_penalty(float *res, const GISTENTRY *o, const GISTENTRY *n,
                int32           ol,
                                        ul;
 
-               gbt_var_bin_union(&d, orge, collation, tinfo);
+               gbt_var_bin_union(&d, orge, collation, tinfo, flinfo);
                ol = gbt_var_node_cp_len((GBT_VARKEY *) DatumGetPointer(d), tinfo);
-               gbt_var_bin_union(&d, newe, collation, tinfo);
+               gbt_var_bin_union(&d, newe, collation, tinfo, flinfo);
                ul = gbt_var_node_cp_len((GBT_VARKEY *) DatumGetPointer(d), tinfo);
 
                if (ul < ol)
@@ -448,16 +449,16 @@ gbt_vsrt_cmp(const void *a, const void *b, void *arg)
        const gbt_vsrt_arg *varg = (const gbt_vsrt_arg *) arg;
        int                     res;
 
-       res = (*varg->tinfo->f_cmp) (ar.lower, br.lower, varg->collation);
+       res = (*varg->tinfo->f_cmp) (ar.lower, br.lower, varg->collation, varg->flinfo);
        if (res == 0)
-               return (*varg->tinfo->f_cmp) (ar.upper, br.upper, varg->collation);
+               return (*varg->tinfo->f_cmp) (ar.upper, br.upper, varg->collation, varg->flinfo);
 
        return res;
 }
 
 GIST_SPLITVEC *
 gbt_var_picksplit(const GistEntryVector *entryvec, GIST_SPLITVEC *v,
-                                 Oid collation, const gbtree_vinfo *tinfo)
+                                 Oid collation, const gbtree_vinfo *tinfo, FmgrInfo *flinfo)
 {
        OffsetNumber i,
                                maxoff = entryvec->n - 1;
@@ -489,7 +490,7 @@ gbt_var_picksplit(const GistEntryVector *entryvec, GIST_SPLITVEC *v,
                ro = gbt_var_key_readable((GBT_VARKEY *) cur);
                if (ro.lower == ro.upper)               /* leaf */
                {
-                       sv[svcntr] = gbt_var_leaf2node((GBT_VARKEY *) cur, tinfo);
+                       sv[svcntr] = gbt_var_leaf2node((GBT_VARKEY *) cur, tinfo, flinfo);
                        arr[i].t = sv[svcntr];
                        if (sv[svcntr] != (GBT_VARKEY *) cur)
                                svcntr++;
@@ -502,6 +503,7 @@ gbt_var_picksplit(const GistEntryVector *entryvec, GIST_SPLITVEC *v,
        /* sort */
        varg.tinfo = tinfo;
        varg.collation = collation;
+       varg.flinfo = flinfo;
        qsort_arg((void *) &arr[FirstOffsetNumber],
                          maxoff - FirstOffsetNumber + 1,
                          sizeof(Vsrt),
@@ -514,13 +516,13 @@ gbt_var_picksplit(const GistEntryVector *entryvec, GIST_SPLITVEC *v,
        {
                if (i <= (maxoff - FirstOffsetNumber + 1) / 2)
                {
-                       gbt_var_bin_union(&v->spl_ldatum, arr[i].t, collation, tinfo);
+                       gbt_var_bin_union(&v->spl_ldatum, arr[i].t, collation, tinfo, flinfo);
                        v->spl_left[v->spl_nleft] = arr[i].i;
                        v->spl_nleft++;
                }
                else
                {
-                       gbt_var_bin_union(&v->spl_rdatum, arr[i].t, collation, tinfo);
+                       gbt_var_bin_union(&v->spl_rdatum, arr[i].t, collation, tinfo, flinfo);
                        v->spl_right[v->spl_nright] = arr[i].i;
                        v->spl_nright++;
                }
@@ -556,7 +558,8 @@ gbt_var_consistent(GBT_VARKEY_R *key,
                                   StrategyNumber strategy,
                                   Oid collation,
                                   bool is_leaf,
-                                  const gbtree_vinfo *tinfo)
+                                  const gbtree_vinfo *tinfo,
+                                  FmgrInfo *flinfo)
 {
        bool            retval = FALSE;
 
@@ -564,44 +567,44 @@ gbt_var_consistent(GBT_VARKEY_R *key,
        {
                case BTLessEqualStrategyNumber:
                        if (is_leaf)
-                               retval = (*tinfo->f_ge) (query, key->lower, collation);
+                               retval = (*tinfo->f_ge) (query, key->lower, collation, flinfo);
                        else
-                               retval = (*tinfo->f_cmp) (query, key->lower, collation) >= 0
+                               retval = (*tinfo->f_cmp) (query, key->lower, collation, flinfo) >= 0
                                        || gbt_var_node_pf_match(key, query, tinfo);
                        break;
                case BTLessStrategyNumber:
                        if (is_leaf)
-                               retval = (*tinfo->f_gt) (query, key->lower, collation);
+                               retval = (*tinfo->f_gt) (query, key->lower, collation, flinfo);
                        else
-                               retval = (*tinfo->f_cmp) (query, key->lower, collation) >= 0
+                               retval = (*tinfo->f_cmp) (query, key->lower, collation, flinfo) >= 0
                                        || gbt_var_node_pf_match(key, query, tinfo);
                        break;
                case BTEqualStrategyNumber:
                        if (is_leaf)
-                               retval = (*tinfo->f_eq) (query, key->lower, collation);
+                               retval = (*tinfo->f_eq) (query, key->lower, collation, flinfo);
                        else
                                retval =
-                                       ((*tinfo->f_cmp) (key->lower, query, collation) <= 0 &&
-                                        (*tinfo->f_cmp) (query, key->upper, collation) <= 0) ||
+                                       ((*tinfo->f_cmp) (key->lower, query, collation, flinfo) <= 0 &&
+                                        (*tinfo->f_cmp) (query, key->upper, collation, flinfo) <= 0) ||
                                        gbt_var_node_pf_match(key, query, tinfo);
                        break;
                case BTGreaterStrategyNumber:
                        if (is_leaf)
-                               retval = (*tinfo->f_lt) (query, key->upper, collation);
+                               retval = (*tinfo->f_lt) (query, key->upper, collation, flinfo);
                        else
-                               retval = (*tinfo->f_cmp) (query, key->upper, collation) <= 0
+                               retval = (*tinfo->f_cmp) (query, key->upper, collation, flinfo) <= 0
                                        || gbt_var_node_pf_match(key, query, tinfo);
                        break;
                case BTGreaterEqualStrategyNumber:
                        if (is_leaf)
-                               retval = (*tinfo->f_le) (query, key->upper, collation);
+                               retval = (*tinfo->f_le) (query, key->upper, collation, flinfo);
                        else
-                               retval = (*tinfo->f_cmp) (query, key->upper, collation) <= 0
+                               retval = (*tinfo->f_cmp) (query, key->upper, collation, flinfo) <= 0
                                        || gbt_var_node_pf_match(key, query, tinfo);
                        break;
                case BtreeGistNotEqualStrategyNumber:
-                       retval = !((*tinfo->f_eq) (query, key->lower, collation) &&
-                                          (*tinfo->f_eq) (query, key->upper, collation));
+                       retval = !((*tinfo->f_eq) (query, key->lower, collation, flinfo) &&
+                                          (*tinfo->f_eq) (query, key->upper, collation, flinfo));
                        break;
                default:
                        retval = FALSE;
index 9a7c4d10554a527fa4fd038e6ea9650be22391c8..fbc76ce738564369c7217f4d3d1d9347f776ae94 100644 (file)
@@ -34,13 +34,13 @@ typedef struct
 
        /* Methods */
 
-       bool            (*f_gt) (const void *, const void *, Oid);              /* greater than */
-       bool            (*f_ge) (const void *, const void *, Oid);              /* greater equal */
-       bool            (*f_eq) (const void *, const void *, Oid);              /* equal */
-       bool            (*f_le) (const void *, const void *, Oid);              /* less equal */
-       bool            (*f_lt) (const void *, const void *, Oid);              /* less than */
-       int32           (*f_cmp) (const void *, const void *, Oid);             /* compare */
-       GBT_VARKEY *(*f_l2n) (GBT_VARKEY *);            /* convert leaf to node */
+       bool            (*f_gt) (const void *, const void *, Oid, FmgrInfo *);          /* greater than */
+       bool            (*f_ge) (const void *, const void *, Oid, FmgrInfo *);          /* greater equal */
+       bool            (*f_eq) (const void *, const void *, Oid, FmgrInfo *);          /* equal */
+       bool            (*f_le) (const void *, const void *, Oid, FmgrInfo *);          /* less equal */
+       bool            (*f_lt) (const void *, const void *, Oid, FmgrInfo *);          /* less than */
+       int32           (*f_cmp) (const void *, const void *, Oid, FmgrInfo *);         /* compare */
+       GBT_VARKEY *(*f_l2n) (GBT_VARKEY *, FmgrInfo *flinfo);          /* convert leaf to node */
 } gbtree_vinfo;
 
 
@@ -52,22 +52,22 @@ extern GBT_VARKEY *gbt_var_key_copy(const GBT_VARKEY_R *u);
 extern GISTENTRY *gbt_var_compress(GISTENTRY *entry, const gbtree_vinfo *tinfo);
 
 extern GBT_VARKEY *gbt_var_union(const GistEntryVector *entryvec, int32 *size,
-                         Oid collation, const gbtree_vinfo *tinfo);
+                         Oid collation, const gbtree_vinfo *tinfo, FmgrInfo *flinfo);
 
 extern bool gbt_var_same(Datum d1, Datum d2, Oid collation,
-                        const gbtree_vinfo *tinfo);
+                        const gbtree_vinfo *tinfo, FmgrInfo *flinfo);
 
 extern float *gbt_var_penalty(float *res, const GISTENTRY *o, const GISTENTRY *n,
-                               Oid collation, const gbtree_vinfo *tinfo);
+                               Oid collation, const gbtree_vinfo *tinfo, FmgrInfo *flinfo);
 
 extern bool gbt_var_consistent(GBT_VARKEY_R *key, const void *query,
                                   StrategyNumber strategy, Oid collation, bool is_leaf,
-                                  const gbtree_vinfo *tinfo);
+                                  const gbtree_vinfo *tinfo, FmgrInfo *flinfo);
 
 extern GIST_SPLITVEC *gbt_var_picksplit(const GistEntryVector *entryvec, GIST_SPLITVEC *v,
-                                 Oid collation, const gbtree_vinfo *tinfo);
+                                 Oid collation, const gbtree_vinfo *tinfo, FmgrInfo *flinfo);
 
 extern void gbt_var_bin_union(Datum *u, GBT_VARKEY *e, Oid collation,
-                                 const gbtree_vinfo *tinfo);
+                                 const gbtree_vinfo *tinfo, FmgrInfo *flinfo);
 
 #endif