MCPcopy Create free account
hub / github.com/apache/cloudberry / PrepareSortSupportComparisonShim

Function PrepareSortSupportComparisonShim

src/backend/utils/sort/sortsupport.c:68–87  ·  view source on GitHub ↗

* Set up a shim function to allow use of an old-style btree comparison * function as if it were a sort support comparator. */

Source from the content-addressed store, hash-verified

66 * function as if it were a sort support comparator.
67 */
68void
69PrepareSortSupportComparisonShim(Oid cmpFunc, SortSupport ssup)
70{
71 SortShimExtra *extra;
72
73 extra = (SortShimExtra *) MemoryContextAlloc(ssup->ssup_cxt,
74 SizeForSortShimExtra(2));
75
76 /* Lookup the comparison function */
77 fmgr_info_cxt(cmpFunc, &extra->flinfo, ssup->ssup_cxt);
78
79 /* We can initialize the callinfo just once and re-use it */
80 InitFunctionCallInfoData(extra->fcinfo, &extra->flinfo, 2,
81 ssup->ssup_collation, NULL, NULL);
82 extra->fcinfo.args[0].isnull = false;
83 extra->fcinfo.args[1].isnull = false;
84
85 ssup->ssup_extra = extra;
86 ssup->comparator = comparison_shim;
87}
88
89/*
90 * Look up and call sortsupport function to setup SortSupport comparator;

Callers 2

MJExamineQualsFunction · 0.85

Calls 2

MemoryContextAllocFunction · 0.85
fmgr_info_cxtFunction · 0.85

Tested by

no test coverage detected