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

Function oper

src/backend/parser/parse_oper.c:381–452  ·  view source on GitHub ↗

oper() -- search for a binary operator * Given operator name, types of arg1 and arg2, return oper struct. * * IMPORTANT: the returned operator (if any) is only promised to be * coercion-compatible with the input datatypes. Do not use this if * you need an exact- or binary-compatible match; see compatible_oper. * * If no matching operator found, return NULL if noError is true, * raise an e

Source from the content-addressed store, hash-verified

379 * must ReleaseSysCache() the entry when done with it.
380 */
381Operator
382oper(ParseState *pstate, List *opname, Oid ltypeId, Oid rtypeId,
383 bool noError, int location)
384{
385 Oid operOid;
386 OprCacheKey key;
387 bool key_ok;
388 FuncDetailCode fdresult = FUNCDETAIL_NOTFOUND;
389 HeapTuple tup = NULL;
390
391 /*
392 * Try to find the mapping in the lookaside cache.
393 */
394 key_ok = make_oper_cache_key(pstate, &key, opname, ltypeId, rtypeId, location);
395
396 if (key_ok)
397 {
398 operOid = find_oper_cache_entry(&key);
399 if (OidIsValid(operOid))
400 {
401 tup = SearchSysCache1(OPEROID, ObjectIdGetDatum(operOid));
402 if (HeapTupleIsValid(tup))
403 return (Operator) tup;
404 }
405 }
406
407 /*
408 * First try for an "exact" match.
409 */
410 operOid = binary_oper_exact(opname, ltypeId, rtypeId);
411 if (!OidIsValid(operOid))
412 {
413 /*
414 * Otherwise, search for the most suitable candidate.
415 */
416 FuncCandidateList clist;
417
418 /* Get binary operators of given name */
419 clist = OpernameGetCandidates(opname, 'b', false);
420
421 /* No operators found? Then fail... */
422 if (clist != NULL)
423 {
424 /*
425 * Unspecified type for one of the arguments? then use the other
426 * (XXX this is probably dead code?)
427 */
428 Oid inputOids[2];
429
430 if (rtypeId == InvalidOid)
431 rtypeId = ltypeId;
432 else if (ltypeId == InvalidOid)
433 ltypeId = rtypeId;
434 inputOids[0] = ltypeId;
435 inputOids[1] = rtypeId;
436 fdresult = oper_select_candidate(2, inputOids, clist, &operOid);
437 }
438 }

Callers 4

generate_operator_nameFunction · 0.85
compatible_operFunction · 0.85
make_opFunction · 0.85
make_scalar_array_opFunction · 0.85

Calls 9

make_oper_cache_keyFunction · 0.85
find_oper_cache_entryFunction · 0.85
SearchSysCache1Function · 0.85
ObjectIdGetDatumFunction · 0.85
binary_oper_exactFunction · 0.85
OpernameGetCandidatesFunction · 0.85
oper_select_candidateFunction · 0.85
make_oper_cache_entryFunction · 0.85
op_errorFunction · 0.85

Tested by

no test coverage detected