* LookupOperName * Given a possibly-qualified operator name and exact input datatypes, * look up the operator. * * Pass oprleft = InvalidOid for a prefix op. * * If the operator name is not schema-qualified, it is sought in the current * namespace search path. * * If the operator is not found, we return InvalidOid if noError is true, * else raise an error. pstate and location are used
| 98 | * error position; pass NULL/-1 if not available. |
| 99 | */ |
| 100 | Oid |
| 101 | LookupOperName(ParseState *pstate, List *opername, Oid oprleft, Oid oprright, |
| 102 | bool noError, int location) |
| 103 | { |
| 104 | Oid result; |
| 105 | |
| 106 | result = OpernameGetOprid(opername, oprleft, oprright); |
| 107 | if (OidIsValid(result)) |
| 108 | return result; |
| 109 | |
| 110 | /* we don't use op_error here because only an exact match is wanted */ |
| 111 | if (!noError) |
| 112 | { |
| 113 | char oprkind; |
| 114 | |
| 115 | if (!OidIsValid(oprleft)) |
| 116 | oprkind = 'l'; |
| 117 | else if (OidIsValid(oprright)) |
| 118 | oprkind = 'b'; |
| 119 | else |
| 120 | { |
| 121 | ereport(ERROR, |
| 122 | (errcode(ERRCODE_SYNTAX_ERROR), |
| 123 | errmsg("postfix operators are not supported"), |
| 124 | parser_errposition(pstate, location))); |
| 125 | oprkind = 0; /* keep compiler quiet */ |
| 126 | } |
| 127 | |
| 128 | ereport(ERROR, |
| 129 | (errcode(ERRCODE_UNDEFINED_FUNCTION), |
| 130 | errmsg("operator does not exist: %s", |
| 131 | op_signature_string(opername, oprkind, |
| 132 | oprleft, oprright)), |
| 133 | parser_errposition(pstate, location))); |
| 134 | } |
| 135 | |
| 136 | return InvalidOid; |
| 137 | } |
| 138 | |
| 139 | /* |
| 140 | * LookupOperWithArgs |
no test coverage detected