| 377 | |
| 378 | |
| 379 | bool EVL_field(jrd_rel* relation, Record* record, USHORT id, dsc* desc) |
| 380 | { |
| 381 | /************************************** |
| 382 | * |
| 383 | * E V L _ f i e l d |
| 384 | * |
| 385 | ************************************** |
| 386 | * |
| 387 | * Functional description |
| 388 | * Evaluate a field by filling out a descriptor. |
| 389 | * |
| 390 | **************************************/ |
| 391 | |
| 392 | DEV_BLKCHK(record, type_rec); |
| 393 | |
| 394 | if (!record) |
| 395 | { |
| 396 | // ASF: Usage of ERR_warning with Arg::Gds (instead of Arg::Warning) is correct here. |
| 397 | // Maybe not all code paths are prepared for throwing an exception here, |
| 398 | // but it will leave the engine as an error (when testing for req_warning). |
| 399 | ERR_warning(Arg::Gds(isc_no_cur_rec)); |
| 400 | return false; |
| 401 | } |
| 402 | |
| 403 | const Format* format = record->getFormat(); |
| 404 | fb_assert(format); |
| 405 | |
| 406 | if (id < format->fmt_count) |
| 407 | *desc = format->fmt_desc[id]; |
| 408 | |
| 409 | if (id >= format->fmt_count || desc->isUnknown()) |
| 410 | { |
| 411 | // Map a non-existent field to a default value, if available. |
| 412 | // This enables automatic format upgrade for data rows. |
| 413 | // Reference: Bug 10424, 10116 |
| 414 | |
| 415 | if (relation) |
| 416 | { |
| 417 | thread_db* tdbb = JRD_get_thread_data(); |
| 418 | |
| 419 | const Format* const currentFormat = MET_current(tdbb, relation); |
| 420 | |
| 421 | while (id >= format->fmt_defaults.getCount() || |
| 422 | format->fmt_defaults[id].vlu_desc.isUnknown()) |
| 423 | { |
| 424 | if (format->fmt_version >= currentFormat->fmt_version) |
| 425 | { |
| 426 | format = NULL; |
| 427 | break; |
| 428 | } |
| 429 | |
| 430 | format = MET_format(tdbb, relation, format->fmt_version + 1); |
| 431 | fb_assert(format); |
| 432 | } |
| 433 | |
| 434 | if (format) |
| 435 | { |
| 436 | *desc = format->fmt_defaults[id].vlu_desc; |
no test coverage detected