* make_scalar_array_op() * Build expression tree for "scalar op ANY/ALL (array)" construct. */
| 780 | * Build expression tree for "scalar op ANY/ALL (array)" construct. |
| 781 | */ |
| 782 | Expr * |
| 783 | make_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; |
no test coverage detected