| 237 | |
| 238 | |
| 239 | int CVT2_compare(const dsc* arg1, const dsc* arg2, Firebird::DecimalStatus decSt) |
| 240 | { |
| 241 | /************************************** |
| 242 | * |
| 243 | * C V T 2 _ c o m p a r e |
| 244 | * |
| 245 | ************************************** |
| 246 | * |
| 247 | * Functional description |
| 248 | * Compare two descriptors. Return (-1, 0, 1) if a<b, a=b, or a>b. |
| 249 | * |
| 250 | **************************************/ |
| 251 | thread_db* tdbb = NULL; |
| 252 | |
| 253 | // AB: Maybe we need a other error-message, but at least throw |
| 254 | // a message when 1 or both input paramters are empty. |
| 255 | if (!arg1 || !arg2) { |
| 256 | BUGCHECK(189); // msg 189 comparison not supported for specified data types. |
| 257 | } |
| 258 | |
| 259 | // Handle the simple (matched) ones first |
| 260 | |
| 261 | if (arg1->dsc_dtype == arg2->dsc_dtype && arg1->dsc_scale == arg2->dsc_scale) |
| 262 | { |
| 263 | const UCHAR* p1 = arg1->dsc_address; |
| 264 | const UCHAR* p2 = arg2->dsc_address; |
| 265 | |
| 266 | switch (arg1->dsc_dtype) |
| 267 | { |
| 268 | case dtype_short: |
| 269 | if (*(SSHORT *) p1 == *(SSHORT *) p2) |
| 270 | return 0; |
| 271 | if (*(SSHORT *) p1 > *(SSHORT *) p2) |
| 272 | return 1; |
| 273 | return -1; |
| 274 | |
| 275 | case dtype_ex_time_tz: |
| 276 | case dtype_sql_time_tz: |
| 277 | case dtype_sql_time: |
| 278 | if (*(ULONG *) p1 == *(ULONG *) p2) |
| 279 | return 0; |
| 280 | if (*(ULONG *) p1 > *(ULONG *) p2) |
| 281 | return 1; |
| 282 | return -1; |
| 283 | |
| 284 | case dtype_long: |
| 285 | case dtype_sql_date: |
| 286 | if (*(SLONG *) p1 == *(SLONG *) p2) |
| 287 | return 0; |
| 288 | if (*(SLONG *) p1 > *(SLONG *) p2) |
| 289 | return 1; |
| 290 | return -1; |
| 291 | |
| 292 | case dtype_quad: |
| 293 | return QUAD_COMPARE((SQUAD *) p1, (SQUAD *) p2); |
| 294 | |
| 295 | case dtype_int64: |
| 296 | if (*(SINT64 *) p1 == *(SINT64 *) p2) |
no test coverage detected