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

Function make_scalar_array_op

src/backend/parser/parse_oper.c:782–906  ·  view source on GitHub ↗

* make_scalar_array_op() * Build expression tree for "scalar op ANY/ALL (array)" construct. */

Source from the content-addressed store, hash-verified

780 * Build expression tree for "scalar op ANY/ALL (array)" construct.
781 */
782Expr *
783make_scalar_array_op(ParseState *pstate, List *opname,
784 bool useOr,
785 Node *ltree, Node *rtree,
786 int location)
787{
788 Oid ltypeId,
789 rtypeId,
790 atypeId,
791 res_atypeId;
792 Operator tup;
793 Form_pg_operator opform;
794 Oid actual_arg_types[2];
795 Oid declared_arg_types[2];
796 List *args;
797 Oid rettype;
798 ScalarArrayOpExpr *result;
799
800 ltypeId = exprType(ltree);
801 atypeId = exprType(rtree);
802
803 /*
804 * The right-hand input of the operator will be the element type of the
805 * array. However, if we currently have just an untyped literal on the
806 * right, stay with that and hope we can resolve the operator.
807 */
808 if (atypeId == UNKNOWNOID)
809 rtypeId = UNKNOWNOID;
810 else
811 {
812 rtypeId = get_base_element_type(atypeId);
813 if (!OidIsValid(rtypeId))
814 ereport(ERROR,
815 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
816 errmsg("op ANY/ALL (array) requires array on right side"),
817 parser_errposition(pstate, location)));
818 }
819
820 /* Now resolve the operator */
821 tup = oper(pstate, opname, ltypeId, rtypeId, false, location);
822 opform = (Form_pg_operator) GETSTRUCT(tup);
823
824 /* Check it's not a shell */
825 if (!RegProcedureIsValid(opform->oprcode))
826 ereport(ERROR,
827 (errcode(ERRCODE_UNDEFINED_FUNCTION),
828 errmsg("operator is only a shell: %s",
829 op_signature_string(opname,
830 opform->oprkind,
831 opform->oprleft,
832 opform->oprright)),
833 parser_errposition(pstate, location)));
834
835 args = list_make2(ltree, rtree);
836 actual_arg_types[0] = ltypeId;
837 actual_arg_types[1] = rtypeId;
838 declared_arg_types[0] = opform->oprleft;
839 declared_arg_types[1] = opform->oprright;

Callers 3

transformAExprOpAnyFunction · 0.85
transformAExprOpAllFunction · 0.85
transformAExprInFunction · 0.85

Calls 14

exprTypeFunction · 0.85
get_base_element_typeFunction · 0.85
parser_errpositionFunction · 0.85
operFunction · 0.85
op_signature_stringFunction · 0.85
get_func_retsetFunction · 0.85
get_array_typeFunction · 0.85
format_type_beFunction · 0.85
make_fn_argumentsFunction · 0.85
opridFunction · 0.85
ReleaseSysCacheFunction · 0.85

Tested by

no test coverage detected