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

Function oper_select_candidate

src/backend/parser/parse_oper.c:323–364  ·  view source on GitHub ↗

oper_select_candidate() * Given the input argtype array and one or more candidates * for the operator, attempt to resolve the conflict. * * Returns FUNCDETAIL_NOTFOUND, FUNCDETAIL_MULTIPLE, or FUNCDETAIL_NORMAL. * In the success case the Oid of the best candidate is stored in *operOid. * * Note that the caller has already determined that there is no candidate * exactly matching the input

Source from the content-addressed store, hash-verified

321 * pruned away, however.
322 */
323static FuncDetailCode
324oper_select_candidate(int nargs,
325 Oid *input_typeids,
326 FuncCandidateList candidates,
327 Oid *operOid) /* output argument */
328{
329 int ncandidates;
330
331 /*
332 * Delete any candidates that cannot actually accept the given input
333 * types, whether directly or by coercion.
334 */
335 ncandidates = func_match_argtypes(nargs, input_typeids,
336 candidates, &candidates);
337
338 /* Done if no candidate or only one candidate survives */
339 if (ncandidates == 0)
340 {
341 *operOid = InvalidOid;
342 return FUNCDETAIL_NOTFOUND;
343 }
344 if (ncandidates == 1)
345 {
346 *operOid = candidates->oid;
347 return FUNCDETAIL_NORMAL;
348 }
349
350 /*
351 * Use the same heuristics as for ambiguous functions to resolve the
352 * conflict.
353 */
354 candidates = func_select_candidate(nargs, input_typeids, candidates);
355
356 if (candidates)
357 {
358 *operOid = candidates->oid;
359 return FUNCDETAIL_NORMAL;
360 }
361
362 *operOid = InvalidOid;
363 return FUNCDETAIL_MULTIPLE; /* failed to select a best candidate */
364}
365
366
367/* oper() -- search for a binary operator

Callers 2

operFunction · 0.85
left_operFunction · 0.85

Calls 2

func_match_argtypesFunction · 0.85
func_select_candidateFunction · 0.85

Tested by

no test coverage detected