key->recheckCurItem = true;
 
        return DatumGetBool(FunctionCall8Coll(&ginstate->consistentFn[key->attnum - 1],
-                                                                                 ginstate->compareCollation[key->attnum - 1],
+                                                                                 ginstate->supportCollation[key->attnum - 1],
                                                                                  PointerGetDatum(key->entryRes),
                                                                                  UInt16GetDatum(key->strategy),
                                                                                  key->query,
                         *----------
                         */
                        cmp = DatumGetInt32(FunctionCall4Coll(&btree->ginstate->comparePartialFn[attnum - 1],
-                                                                                                 btree->ginstate->compareCollation[attnum - 1],
+                                                                                                 btree->ginstate->supportCollation[attnum - 1],
                                                                                                  scanEntry->queryKey,
                                                                                                  idatum,
                                                                                 UInt16GetDatum(scanEntry->strategy),
                 *----------
                 */
                cmp = DatumGetInt32(FunctionCall4Coll(&ginstate->comparePartialFn[entry->attnum - 1],
-                                                                                         ginstate->compareCollation[entry->attnum - 1],
+                                                                                         ginstate->supportCollation[entry->attnum - 1],
                                                                                          entry->queryKey,
                                                                                          datum[off - 1],
                                                                                  UInt16GetDatum(entry->strategy),
 
 
                /* OK to call the extractQueryFn */
                queryValues = (Datum *)
-                       DatumGetPointer(FunctionCall7(&so->ginstate.extractQueryFn[skey->sk_attno - 1],
-                                                                                 skey->sk_argument,
-                                                                                 PointerGetDatum(&nQueryValues),
-                                                                                 UInt16GetDatum(skey->sk_strategy),
-                                                                                 PointerGetDatum(&partial_matches),
-                                                                                 PointerGetDatum(&extra_data),
-                                                                                 PointerGetDatum(&nullFlags),
-                                                                                 PointerGetDatum(&searchMode)));
+                       DatumGetPointer(FunctionCall7Coll(&so->ginstate.extractQueryFn[skey->sk_attno - 1],
+                                                                                         so->ginstate.supportCollation[skey->sk_attno - 1],
+                                                                                         skey->sk_argument,
+                                                                                         PointerGetDatum(&nQueryValues),
+                                                                                         UInt16GetDatum(skey->sk_strategy),
+                                                                                         PointerGetDatum(&partial_matches),
+                                                                                         PointerGetDatum(&extra_data),
+                                                                                         PointerGetDatum(&nullFlags),
+                                                                                         PointerGetDatum(&searchMode)));
 
                /*
                 * If bogus searchMode is returned, treat as GIN_SEARCH_MODE_ALL; note
 
                 * while doing comparisons.  However, we may have a collatable storage
                 * type for a noncollatable indexed data type (for instance, hstore
                 * uses text index entries).  If there's no index collation then
-                * specify default collation in case the comparison function needs
-                * collation.  This is harmless if the comparison function doesn't
+                * specify default collation in case the support functions need
+                * collation.  This is harmless if the support functions don't
                 * care about collation, so we just do it unconditionally.  (We could
                 * alternatively call get_typcollation, but that seems like expensive
                 * overkill --- there aren't going to be any cases where a GIN storage
                 * type has a nondefault collation.)
                 */
                if (OidIsValid(index->rd_indcollation[i]))
-                       state->compareCollation[i] = index->rd_indcollation[i];
+                       state->supportCollation[i] = index->rd_indcollation[i];
                else
-                       state->compareCollation[i] = DEFAULT_COLLATION_OID;
+                       state->supportCollation[i] = DEFAULT_COLLATION_OID;
        }
 }
 
 
        /* both not null, so safe to call the compareFn */
        return DatumGetInt32(FunctionCall2Coll(&ginstate->compareFn[attnum - 1],
-                                                                                  ginstate->compareCollation[attnum - 1],
+                                                                                  ginstate->supportCollation[attnum - 1],
                                                                                   a, b));
 }
 
        /* OK, call the opclass's extractValueFn */
        nullFlags = NULL;                       /* in case extractValue doesn't set it */
        entries = (Datum *)
-               DatumGetPointer(FunctionCall3(&ginstate->extractValueFn[attnum - 1],
-                                                                         value,
-                                                                         PointerGetDatum(nentries),
-                                                                         PointerGetDatum(&nullFlags)));
+               DatumGetPointer(FunctionCall3Coll(&ginstate->extractValueFn[attnum - 1],
+                                                                                 ginstate->supportCollation[attnum - 1],
+                                                                                 value,
+                                                                                 PointerGetDatum(nentries),
+                                                                                 PointerGetDatum(&nullFlags)));
 
        /*
         * Generate a placeholder if the item contained no keys.
                }
 
                arg.cmpDatumFunc = &ginstate->compareFn[attnum - 1];
-               arg.collation = ginstate->compareCollation[attnum - 1];
+               arg.collation = ginstate->supportCollation[attnum - 1];
                arg.haveDups = false;
                qsort_arg(keydata, *nentries, sizeof(keyEntryData),
                                  cmpEntries, (void *) &arg);
 
 #include "access/genam.h"
 #include "access/gist_private.h"
 #include "catalog/index.h"
+#include "catalog/pg_collation.h"
 #include "miscadmin.h"
 #include "storage/bufmgr.h"
 #include "storage/indexfsm.h"
                                                   CurrentMemoryContext);
                else
                        giststate->distanceFn[i].fn_oid = InvalidOid;
+
+               /*
+                * If the index column has a specified collation, we should honor that
+                * while doing comparisons.  However, we may have a collatable storage
+                * type for a noncollatable indexed data type.  If there's no index
+                * collation then specify default collation in case the support
+                * functions need collation.  This is harmless if the support
+                * functions don't care about collation, so we just do it
+                * unconditionally.  (We could alternatively call get_typcollation,
+                * but that seems like expensive overkill --- there aren't going to be
+                * any cases where a GIST storage type has a nondefault collation.)
+                */
+               if (OidIsValid(index->rd_indcollation[i]))
+                       giststate->supportCollation[i] = index->rd_indcollation[i];
+               else
+                       giststate->supportCollation[i] = DEFAULT_COLLATION_OID;
        }
 }
 
 
        evec->n = v->spl_nleft;
        memcpy(evec->vector, entryvec->vector + FirstOffsetNumber,
                   sizeof(GISTENTRY) * evec->n);
-       v->spl_ldatum = FunctionCall2(&giststate->unionFn[attno],
-                                                                 PointerGetDatum(evec),
-                                                                 PointerGetDatum(&nbytes));
+       v->spl_ldatum = FunctionCall2Coll(&giststate->unionFn[attno],
+                                                                         giststate->supportCollation[attno],
+                                                                         PointerGetDatum(evec),
+                                                                         PointerGetDatum(&nbytes));
 
        evec->n = v->spl_nright;
        memcpy(evec->vector, entryvec->vector + FirstOffsetNumber + v->spl_nleft,
                   sizeof(GISTENTRY) * evec->n);
-       v->spl_rdatum = FunctionCall2(&giststate->unionFn[attno],
-                                                                 PointerGetDatum(evec),
-                                                                 PointerGetDatum(&nbytes));
+       v->spl_rdatum = FunctionCall2Coll(&giststate->unionFn[attno],
+                                                                         giststate->supportCollation[attno],
+                                                                         PointerGetDatum(evec),
+                                                                         PointerGetDatum(&nbytes));
 }
 
 /*
        sv->spl_ldatum = v->spl_lattr[attno];
        sv->spl_rdatum = v->spl_rattr[attno];
 
-       FunctionCall2(&giststate->picksplitFn[attno],
-                                 PointerGetDatum(entryvec),
-                                 PointerGetDatum(sv));
+       FunctionCall2Coll(&giststate->picksplitFn[attno],
+                                         giststate->supportCollation[attno],
+                                         PointerGetDatum(entryvec),
+                                         PointerGetDatum(sv));
 
        if (sv->spl_nleft == 0 || sv->spl_nright == 0)
        {
 
                        }
 
                        /* Make union and store in attr array */
-                       attr[i] = FunctionCall2(&giststate->unionFn[i],
-                                                                       PointerGetDatum(evec),
-                                                                       PointerGetDatum(&attrsize));
+                       attr[i] = FunctionCall2Coll(&giststate->unionFn[i],
+                                                                               giststate->supportCollation[i],
+                                                                               PointerGetDatum(evec),
+                                                                               PointerGetDatum(&attrsize));
 
                        isnull[i] = FALSE;
                }
                }
 
                *dstisnull = FALSE;
-               *dst = FunctionCall2(&giststate->unionFn[attno],
-                                                        PointerGetDatum(evec),
-                                                        PointerGetDatum(&dstsize));
+               *dst = FunctionCall2Coll(&giststate->unionFn[attno],
+                                                                giststate->supportCollation[attno],
+                                                                PointerGetDatum(evec),
+                                                                PointerGetDatum(&dstsize));
        }
 }
 
 {
        bool            result;
 
-       FunctionCall3(&giststate->equalFn[attno],
-                                 a, b,
-                                 PointerGetDatum(&result));
+       FunctionCall3Coll(&giststate->equalFn[attno],
+                                         giststate->supportCollation[attno],
+                                         a, b,
+                                         PointerGetDatum(&result));
        return result;
 }
 
 
                gistentryinit(*e, k, r, pg, o, l);
                dep = (GISTENTRY *)
-                       DatumGetPointer(FunctionCall1(&giststate->decompressFn[nkey],
-                                                                                 PointerGetDatum(e)));
+                       DatumGetPointer(FunctionCall1Coll(&giststate->decompressFn[nkey],
+                                                                                         giststate->supportCollation[nkey],
+                                                                                         PointerGetDatum(e)));
                /* decompressFn may just return the given pointer */
                if (dep != e)
                        gistentryinit(*e, dep->key, dep->rel, dep->page, dep->offset,
 
                gistentryinit(*e, k, r, pg, o, l);
                cep = (GISTENTRY *)
-                       DatumGetPointer(FunctionCall1(&giststate->compressFn[nkey],
-                                                                                 PointerGetDatum(e)));
+                       DatumGetPointer(FunctionCall1Coll(&giststate->compressFn[nkey],
+                                                                                         giststate->supportCollation[nkey],
+                                                                                         PointerGetDatum(e)));
                /* compressFn may just return the given pointer */
                if (cep != e)
                        gistentryinit(*e, cep->key, cep->rel, cep->page, cep->offset,
 {
        float           penalty = 0.0;
 
-       if (giststate->penaltyFn[attno].fn_strict == FALSE || (isNullOrig == FALSE && isNullAdd == FALSE))
-               FunctionCall3(&giststate->penaltyFn[attno],
-                                         PointerGetDatum(orig),
-                                         PointerGetDatum(add),
-                                         PointerGetDatum(&penalty));
+       if (giststate->penaltyFn[attno].fn_strict == FALSE ||
+               (isNullOrig == FALSE && isNullAdd == FALSE))
+               FunctionCall3Coll(&giststate->penaltyFn[attno],
+                                                 giststate->supportCollation[attno],
+                                                 PointerGetDatum(orig),
+                                                 PointerGetDatum(add),
+                                                 PointerGetDatum(&penalty));
        else if (isNullOrig && isNullAdd)
                penalty = 0.0;
        else
 
        FmgrInfo        comparePartialFn[INDEX_MAX_KEYS];               /* optional method */
        /* canPartialMatch[i] is true if comparePartialFn[i] is valid */
        bool            canPartialMatch[INDEX_MAX_KEYS];
-       /* Collations to supply to the compareFns and comparePartialFns */
-       Oid                     compareCollation[INDEX_MAX_KEYS];
+       /* Collations to pass to the support functions */
+       Oid                     supportCollation[INDEX_MAX_KEYS];
 } GinState;
 
 /* XLog stuff */
 
        FmgrInfo        equalFn[INDEX_MAX_KEYS];
        FmgrInfo        distanceFn[INDEX_MAX_KEYS];
 
+       /* Collations to pass to the support functions */
+       Oid                     supportCollation[INDEX_MAX_KEYS];
+
        TupleDesc       tupdesc;
 } GISTSTATE;