MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / addSqlTime

Method addSqlTime

src/dsql/ExprNodes.cpp:2813–2928  ·  view source on GitHub ↗

Perform time arithmetic. TIME - TIME Result is SLONG, scale -4 TIME +/- NUMERIC Numeric is interpreted as seconds DECIMAL(*,4). NUMERIC +/- TIME Numeric is interpreted as seconds DECIMAL(*,4).

Source from the content-addressed store, hash-verified

2811// TIME +/- NUMERIC Numeric is interpreted as seconds DECIMAL(*,4).
2812// NUMERIC +/- TIME Numeric is interpreted as seconds DECIMAL(*,4).
2813dsc* ArithmeticNode::addSqlTime(thread_db* tdbb, const dsc* desc, impure_value* value) const
2814{
2815 fb_assert(blrOp == blr_add || blrOp == blr_subtract);
2816
2817 dsc* result = &value->vlu_desc;
2818 Attachment* const attachment = tdbb->getAttachment();
2819
2820 fb_assert(value->vlu_desc.isTime() || desc->isTime());
2821
2822 const dsc* op1_desc = &value->vlu_desc;
2823 const dsc* op2_desc = desc;
2824
2825 bool op1_is_time = op1_desc->isTime();
2826 bool op2_is_time = op2_desc->isTime();
2827
2828 Nullable<USHORT> op1_tz, op2_tz;
2829
2830 if (op1_desc->dsc_dtype == dtype_sql_time_tz)
2831 op1_tz = ((ISC_TIME_TZ*) op1_desc->dsc_address)->time_zone;
2832
2833 if (op2_desc->dsc_dtype == dtype_sql_time_tz)
2834 op2_tz = ((ISC_TIME_TZ*) op2_desc->dsc_address)->time_zone;
2835
2836 dsc op1_tz_desc, op2_tz_desc;
2837 ISC_TIME_TZ op1_time_tz, op2_time_tz;
2838
2839 if (op1_desc->dsc_dtype == dtype_sql_time && op2_is_time && op2_tz.specified)
2840 {
2841 op1_tz_desc.makeTimeTz(&op1_time_tz);
2842 MOV_move(tdbb, const_cast<dsc*>(op1_desc), &op1_tz_desc);
2843 op1_desc = &op1_tz_desc;
2844 }
2845
2846 if (op2_desc->dsc_dtype == dtype_sql_time && op1_is_time && op1_tz.specified)
2847 {
2848 op2_tz_desc.makeTimeTz(&op2_time_tz);
2849 MOV_move(tdbb, const_cast<dsc*>(op2_desc), &op2_tz_desc);
2850 op2_desc = &op2_tz_desc;
2851 }
2852
2853 // Coerce operand1 to a count of seconds
2854 SINT64 d1;
2855
2856 if (op1_is_time)
2857 {
2858 d1 = *(GDS_TIME*) op1_desc->dsc_address;
2859 fb_assert(d1 >= 0 && d1 < TimeStamp::ISC_TICKS_PER_DAY);
2860 }
2861 else
2862 d1 = MOV_get_int64(tdbb, op1_desc, ISC_TIME_SECONDS_PRECISION_SCALE);
2863
2864 // Coerce operand2 to a count of seconds
2865 SINT64 d2;
2866
2867 if (op2_is_time)
2868 {
2869 d2 = *(GDS_TIME*) op2_desc->dsc_address;
2870 fb_assert(d2 >= 0 && d2 < TimeStamp::ISC_TICKS_PER_DAY);

Callers

nothing calls this directly

Calls 5

MOV_moveFunction · 0.85
MOV_get_int64Function · 0.85
isTimeMethod · 0.80
makeTimeTzMethod · 0.80
getAttachmentMethod · 0.45

Tested by

no test coverage detected