Header And Logo

| The world's most advanced open source database.

Data Structures | Typedefs | Functions

sortsupport.h File Reference

#include "access/attnum.h"
Include dependency graph for sortsupport.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SortSupportData


typedef struct SortSupportDataSortSupport
typedef struct SortSupportData SortSupportData


int ApplySortComparator (Datum datum1, bool isNull1, Datum datum2, bool isNull2, SortSupport ssup)
void PrepareSortSupportComparisonShim (Oid cmpFunc, SortSupport ssup)
void PrepareSortSupportFromOrderingOp (Oid orderingOp, SortSupport ssup)

Typedef Documentation

typedef struct SortSupportData* SortSupport

Definition at line 52 of file sortsupport.h.

Function Documentation

int ApplySortComparator ( Datum  datum1,
bool  isNull1,
Datum  datum2,
bool  isNull2,
SortSupport  ssup 
void PrepareSortSupportComparisonShim ( Oid  cmpFunc,
SortSupport  ssup 

Definition at line 67 of file sortsupport.c.

References FunctionCallInfoData::argnull, SortSupportData::comparator, SortShimExtra::fcinfo, SortShimExtra::flinfo, fmgr_info_cxt(), InitFunctionCallInfoData, MemoryContextAlloc(), NULL, SortSupportData::ssup_collation, SortSupportData::ssup_cxt, and SortSupportData::ssup_extra.

Referenced by MJExamineQuals(), and PrepareSortSupportFromOrderingOp().

    SortShimExtra *extra;

    extra = (SortShimExtra *) MemoryContextAlloc(ssup->ssup_cxt,

    /* Lookup the comparison function */
    fmgr_info_cxt(cmpFunc, &extra->flinfo, ssup->ssup_cxt);

    /* We can initialize the callinfo just once and re-use it */
    InitFunctionCallInfoData(extra->fcinfo, &extra->flinfo, 2,
                             ssup->ssup_collation, NULL, NULL);
    extra->fcinfo.argnull[0] = false;
    extra->fcinfo.argnull[1] = false;

    ssup->ssup_extra = extra;
    ssup->comparator = comparison_shim;

void PrepareSortSupportFromOrderingOp ( Oid  orderingOp,
SortSupport  ssup 

Definition at line 95 of file sortsupport.c.

References Assert, SortSupportData::comparator, elog, ERROR, get_sort_function_for_ordering_op(), NULL, OidFunctionCall1, PointerGetDatum, PrepareSortSupportComparisonShim(), and SortSupportData::ssup_reverse.

Referenced by compute_scalar_stats(), ExecInitMergeAppend(), tuplesort_begin_datum(), and tuplesort_begin_heap().

    Oid         sortFunction;
    bool        issupport;

    if (!get_sort_function_for_ordering_op(orderingOp,
        elog(ERROR, "operator %u is not a valid ordering operator",

    if (issupport)
        /* The sort support function should provide a comparator */
        OidFunctionCall1(sortFunction, PointerGetDatum(ssup));
        Assert(ssup->comparator != NULL);
        /* We'll use a shim to call the old-style btree comparator */
        PrepareSortSupportComparisonShim(sortFunction, ssup);