| 2729 | |
| 2730 | |
| 2731 | dsc* evlDateAdd(thread_db* tdbb, const SysFunction* function, const NestValueArray& args, |
| 2732 | impure_value* impure) |
| 2733 | { |
| 2734 | fb_assert(args.getCount() == 3); |
| 2735 | |
| 2736 | Request* request = tdbb->getRequest(); |
| 2737 | |
| 2738 | const dsc* quantityDsc = EVL_expr(tdbb, request, args[0]); |
| 2739 | if (request->req_flags & req_null) // return NULL if quantityDsc is NULL |
| 2740 | return NULL; |
| 2741 | |
| 2742 | const dsc* partDsc = EVL_expr(tdbb, request, args[1]); |
| 2743 | if (request->req_flags & req_null) // return NULL if partDsc is NULL |
| 2744 | return NULL; |
| 2745 | |
| 2746 | const dsc* valueDsc = EVL_expr(tdbb, request, args[2]); |
| 2747 | if (request->req_flags & req_null) // return NULL if valueDsc is NULL |
| 2748 | return NULL; |
| 2749 | |
| 2750 | const SLONG part = MOV_get_long(tdbb, partDsc, 0); |
| 2751 | |
| 2752 | TimeStamp timestamp; |
| 2753 | |
| 2754 | switch (valueDsc->dsc_dtype) |
| 2755 | { |
| 2756 | case dtype_sql_time: |
| 2757 | case dtype_sql_time_tz: |
| 2758 | timestamp.value().timestamp_time = *(GDS_TIME*) valueDsc->dsc_address; |
| 2759 | timestamp.value().timestamp_date = |
| 2760 | (TimeStamp::MAX_DATE - TimeStamp::MIN_DATE) / 2 + TimeStamp::MIN_DATE; |
| 2761 | |
| 2762 | if (part != blr_extract_hour && |
| 2763 | part != blr_extract_minute && |
| 2764 | part != blr_extract_second && |
| 2765 | part != blr_extract_millisecond) |
| 2766 | { |
| 2767 | status_exception::raise(Arg::Gds(isc_expression_eval_err) << |
| 2768 | Arg::Gds(isc_sysf_invalid_addpart_time) << |
| 2769 | Arg::Str(function->name)); |
| 2770 | } |
| 2771 | break; |
| 2772 | |
| 2773 | case dtype_sql_date: |
| 2774 | timestamp.value().timestamp_date = *(GDS_DATE*) valueDsc->dsc_address; |
| 2775 | timestamp.value().timestamp_time = 0; |
| 2776 | /* |
| 2777 | if (part == blr_extract_hour || |
| 2778 | part == blr_extract_minute || |
| 2779 | part == blr_extract_second || |
| 2780 | part == blr_extract_millisecond) |
| 2781 | { |
| 2782 | status_exception::raise(Arg::Gds(isc_expression_eval_err)); |
| 2783 | } |
| 2784 | */ |
| 2785 | break; |
| 2786 | |
| 2787 | case dtype_timestamp: |
| 2788 | case dtype_timestamp_tz: |
nothing calls this directly
no test coverage detected