| 1020 | } |
| 1021 | |
| 1022 | void ArithmeticNode::makeDialect3(dsc* desc, dsc& desc1, dsc& desc2) |
| 1023 | { |
| 1024 | USHORT dtype, dtype1, dtype2; |
| 1025 | |
| 1026 | switch (blrOp) |
| 1027 | { |
| 1028 | case blr_add: |
| 1029 | case blr_subtract: |
| 1030 | dtype1 = desc1.dsc_dtype; |
| 1031 | dtype2 = desc2.dsc_dtype; |
| 1032 | |
| 1033 | // Arrays and blobs can never partipate in addition/subtraction |
| 1034 | if (DTYPE_IS_BLOB(dtype1) || DTYPE_IS_BLOB(dtype2)) |
| 1035 | { |
| 1036 | ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-607) << |
| 1037 | Arg::Gds(isc_dsql_no_blob_array)); |
| 1038 | } |
| 1039 | |
| 1040 | // In Dialect 2 or 3, strings can never partipate in addition / sub |
| 1041 | // (use a specific cast instead) |
| 1042 | if (DTYPE_IS_TEXT(dtype1) || DTYPE_IS_TEXT(dtype2)) |
| 1043 | { |
| 1044 | ERRD_post(Arg::Gds(isc_expression_eval_err) << |
| 1045 | Arg::Gds(isc_dsql_nostring_addsub_dial3)); |
| 1046 | } |
| 1047 | |
| 1048 | // Determine the TYPE of arithmetic to perform, store it |
| 1049 | // in dtype. Note: this is different from the result of |
| 1050 | // the operation, as <timestamp>-<timestamp> uses |
| 1051 | // <timestamp> arithmetic, but returns a <double> |
| 1052 | if (DTYPE_IS_EXACT(dtype1) && DTYPE_IS_EXACT(dtype2)) |
| 1053 | { |
| 1054 | if (desc1.isInt128() || desc2.isInt128()) |
| 1055 | dtype = dtype_int128; |
| 1056 | else |
| 1057 | dtype = dtype_int64; |
| 1058 | } |
| 1059 | else if (DTYPE_IS_NUMERIC(dtype1) && DTYPE_IS_NUMERIC(dtype2)) |
| 1060 | { |
| 1061 | if (DTYPE_IS_DECFLOAT(dtype1) || DTYPE_IS_DECFLOAT(dtype2)) |
| 1062 | { |
| 1063 | USHORT d1 = DTYPE_IS_DECFLOAT(dtype1) ? dtype1 : 0; |
| 1064 | USHORT d2 = DTYPE_IS_DECFLOAT(dtype2) ? dtype2 : 0; |
| 1065 | dtype = MAX(d1, d2); |
| 1066 | } |
| 1067 | else |
| 1068 | { |
| 1069 | fb_assert(DTYPE_IS_APPROX(dtype1) || DTYPE_IS_APPROX(dtype2)); |
| 1070 | dtype = dtype_double; |
| 1071 | } |
| 1072 | } |
| 1073 | else |
| 1074 | { |
| 1075 | // mixed numeric and non-numeric: |
| 1076 | |
| 1077 | // The MAX(dtype) rule doesn't apply with dtype_int64 |
| 1078 | |
| 1079 | if (dtype1 == dtype_int64) |
nothing calls this directly
no test coverage detected