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

Method addTimeStamp

src/dsql/ExprNodes.cpp:2936–3162  ·  view source on GitHub ↗

Perform date&time arithmetic. TIMESTAMP - TIMESTAMP Result is INT64 TIMESTAMP +/- NUMERIC Numeric is interpreted as days DECIMAL(*,*). NUMERIC +/- TIMESTAMP Numeric is interpreted as days DECIMAL(*,*). DATE + TIME TIME + DATE

Source from the content-addressed store, hash-verified

2934// DATE + TIME
2935// TIME + DATE
2936dsc* ArithmeticNode::addTimeStamp(thread_db* tdbb, const dsc* desc, impure_value* value) const
2937{
2938 fb_assert(blrOp == blr_add || blrOp == blr_subtract);
2939
2940 const dsc* op1_desc = &value->vlu_desc;
2941 const dsc* op2_desc = desc;
2942
2943 Nullable<USHORT> op1_tz, op2_tz;
2944
2945 if (op1_desc->dsc_dtype == dtype_sql_time_tz)
2946 op1_tz = ((ISC_TIME_TZ*) op1_desc->dsc_address)->time_zone;
2947 else if (op1_desc->dsc_dtype == dtype_timestamp_tz)
2948 op1_tz = ((ISC_TIMESTAMP_TZ*) op1_desc->dsc_address)->time_zone;
2949
2950 if (op2_desc->dsc_dtype == dtype_sql_time_tz)
2951 op2_tz = ((ISC_TIME_TZ*) op2_desc->dsc_address)->time_zone;
2952 else if (op2_desc->dsc_dtype == dtype_timestamp_tz)
2953 op2_tz = ((ISC_TIMESTAMP_TZ*) op2_desc->dsc_address)->time_zone;
2954
2955 dsc op1_tz_desc, op2_tz_desc;
2956 ISC_TIMESTAMP_TZ op1_timestamp_tz, op2_timestamp_tz;
2957 ISC_TIME_TZ op1_time_tz, op2_time_tz;
2958
2959 if ((op1_desc->dsc_dtype == dtype_sql_time || op1_desc->dsc_dtype == dtype_timestamp) &&
2960 op2_desc->isDateTime() && op2_tz.specified)
2961 {
2962 if (op1_desc->dsc_dtype == dtype_sql_time)
2963 op1_tz_desc.makeTimeTz(&op1_time_tz);
2964 else
2965 op1_tz_desc.makeTimestampTz(&op1_timestamp_tz);
2966
2967 MOV_move(tdbb, const_cast<dsc*>(op1_desc), &op1_tz_desc);
2968 op1_desc = &op1_tz_desc;
2969 }
2970
2971 if ((op2_desc->dsc_dtype == dtype_sql_time || op2_desc->dsc_dtype == dtype_timestamp) &&
2972 op1_desc->isDateTime() && op1_tz.specified)
2973 {
2974 if (op2_desc->dsc_dtype == dtype_sql_time)
2975 op2_tz_desc.makeTimeTz(&op2_time_tz);
2976 else
2977 op2_tz_desc.makeTimestampTz(&op2_timestamp_tz);
2978
2979 MOV_move(tdbb, const_cast<dsc*>(op2_desc), &op2_tz_desc);
2980 op2_desc = &op2_tz_desc;
2981 }
2982
2983 SINT64 d1, d2;
2984
2985 dsc* result = &value->vlu_desc;
2986
2987 // Operand 1 is Value -- Operand 2 is desc
2988
2989 if (op1_desc->dsc_dtype == dtype_sql_date)
2990 {
2991 // DATE + TIME
2992 if (op2_desc->isTime() && blrOp == blr_add)
2993 {

Callers

nothing calls this directly

Calls 11

MOV_moveFunction · 0.85
GdsClass · 0.85
DTYPE_IS_TEXTFunction · 0.85
getTimeStampToIscTicksFunction · 0.85
getDayFractionFunction · 0.85
isDateTimeMethod · 0.80
makeTimeTzMethod · 0.80
makeTimestampTzMethod · 0.80
isTimeMethod · 0.80
isTimeStampMethod · 0.80
ERR_postFunction · 0.50

Tested by

no test coverage detected