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

Function left_oper

src/backend/parser/parse_oper.c:529–603  ·  view source on GitHub ↗

left_oper() -- search for a unary left operator (prefix operator) * Given operator name and type of arg, return oper struct. * * IMPORTANT: the returned operator (if any) is only promised to be * coercion-compatible with the input datatype. Do not use this if * you need an exact- or binary-compatible match. * * If no matching operator found, return NULL if noError is true, * raise an erro

Source from the content-addressed store, hash-verified

527 * must ReleaseSysCache() the entry when done with it.
528 */
529Operator
530left_oper(ParseState *pstate, List *op, Oid arg, bool noError, int location)
531{
532 Oid operOid;
533 OprCacheKey key;
534 bool key_ok;
535 FuncDetailCode fdresult = FUNCDETAIL_NOTFOUND;
536 HeapTuple tup = NULL;
537
538 /*
539 * Try to find the mapping in the lookaside cache.
540 */
541 key_ok = make_oper_cache_key(pstate, &key, op, InvalidOid, arg, location);
542
543 if (key_ok)
544 {
545 operOid = find_oper_cache_entry(&key);
546 if (OidIsValid(operOid))
547 {
548 tup = SearchSysCache1(OPEROID, ObjectIdGetDatum(operOid));
549 if (HeapTupleIsValid(tup))
550 return (Operator) tup;
551 }
552 }
553
554 /*
555 * First try for an "exact" match.
556 */
557 operOid = OpernameGetOprid(op, InvalidOid, arg);
558 if (!OidIsValid(operOid))
559 {
560 /*
561 * Otherwise, search for the most suitable candidate.
562 */
563 FuncCandidateList clist;
564
565 /* Get prefix operators of given name */
566 clist = OpernameGetCandidates(op, 'l', false);
567
568 /* No operators found? Then fail... */
569 if (clist != NULL)
570 {
571 /*
572 * The returned list has args in the form (0, oprright). Move the
573 * useful data into args[0] to keep oper_select_candidate simple.
574 * XXX we are assuming here that we may scribble on the list!
575 */
576 FuncCandidateList clisti;
577
578 for (clisti = clist; clisti != NULL; clisti = clisti->next)
579 {
580 clisti->args[0] = clisti->args[1];
581 }
582
583 /*
584 * We must run oper_select_candidate even if only one candidate,
585 * otherwise we may falsely return a non-type-compatible operator.
586 */

Callers 2

generate_operator_nameFunction · 0.85
make_opFunction · 0.85

Calls 9

make_oper_cache_keyFunction · 0.85
find_oper_cache_entryFunction · 0.85
SearchSysCache1Function · 0.85
ObjectIdGetDatumFunction · 0.85
OpernameGetOpridFunction · 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