| 7685 | */ |
| 7686 | |
| 7687 | void handle_expr_function_call(enum func_type func_type, |
| 7688 | Expression_value *result, const char **s) |
| 7689 | { |
| 7690 | Expression_value args[MAX_FUNC_ARGS]; |
| 7691 | int arg_count= 0; |
| 7692 | |
| 7693 | while (!match(s, ")")) |
| 7694 | { |
| 7695 | if (arg_count >= MAX_FUNC_ARGS) |
| 7696 | die("Too many function arguments (max %d)", MAX_FUNC_ARGS); |
| 7697 | |
| 7698 | expr(&args[arg_count], s); |
| 7699 | arg_count++; |
| 7700 | |
| 7701 | /* if the next character is a comma, skip it */ |
| 7702 | if (match(s, ",")) |
| 7703 | continue; |
| 7704 | |
| 7705 | if (match(s, ")")) |
| 7706 | break; |
| 7707 | |
| 7708 | die("Syntax error: Expected ',' or ')' in function call"); |
| 7709 | } |
| 7710 | |
| 7711 | /* generic NULL propagation, except for IFNULL/NULLIF/COALESCE/CONCAT_WS */ |
| 7712 | if (func_type != FUNC_IFNULL && func_type != FUNC_NULLIF && |
| 7713 | func_type != FUNC_COALESCE && func_type != FUNC_CONCAT_WS) |
| 7714 | { |
| 7715 | for (int i= 0; i < arg_count; i++) |
| 7716 | { |
| 7717 | if (args[i].type == EXPR_NULL) |
| 7718 | { |
| 7719 | result->reset(); |
| 7720 | return; |
| 7721 | } |
| 7722 | } |
| 7723 | } |
| 7724 | |
| 7725 | switch (func_type) { |
| 7726 | case FUNC_ABS: |
| 7727 | func_abs(args, arg_count, result); |
| 7728 | break; |
| 7729 | case FUNC_CONV: |
| 7730 | func_conv(args, arg_count, result); |
| 7731 | break; |
| 7732 | case FUNC_BIN: |
| 7733 | func_bin(args, arg_count, result); |
| 7734 | break; |
| 7735 | case FUNC_OCT: |
| 7736 | func_oct(args, arg_count, result); |
| 7737 | break; |
| 7738 | case FUNC_HEX: |
| 7739 | func_hex(args, arg_count, result); |
| 7740 | break; |
| 7741 | case FUNC_INSTR: |
| 7742 | func_instr(args, arg_count, result); |
| 7743 | break; |
| 7744 | case FUNC_LOCATE: |
no test coverage detected