| 1586 | |
| 1587 | |
| 1588 | void blb::BLB_put_segment(thread_db* tdbb, const void* seg, USHORT segment_length) |
| 1589 | { |
| 1590 | /************************************** |
| 1591 | * |
| 1592 | * b l b : : p u t _ s e g m e n t |
| 1593 | * |
| 1594 | ************************************** |
| 1595 | * |
| 1596 | * Functional description |
| 1597 | * Add a segment to a blob. |
| 1598 | * |
| 1599 | **************************************/ |
| 1600 | SET_TDBB(tdbb); |
| 1601 | Database* dbb = tdbb->getDatabase(); |
| 1602 | const UCHAR* segment = static_cast<const UCHAR*>(seg); |
| 1603 | |
| 1604 | // Make sure blob is a temporary blob. If not, complain bitterly. |
| 1605 | |
| 1606 | if (!(blb_flags & BLB_temporary) || (blb_flags & BLB_closed)) |
| 1607 | ERR_post(Arg::Gds(isc_cannot_update_old_blob)); |
| 1608 | |
| 1609 | if (blb_filter) |
| 1610 | { |
| 1611 | BLF_put_segment(tdbb, &blb_filter, segment_length, segment); |
| 1612 | return; |
| 1613 | } |
| 1614 | |
| 1615 | // Account for new segment |
| 1616 | |
| 1617 | blb_count++; |
| 1618 | blb_length += segment_length; |
| 1619 | |
| 1620 | if (segment_length > blb_max_segment) |
| 1621 | blb_max_segment = segment_length; |
| 1622 | |
| 1623 | // Compute the effective length of the segment (counts length unless |
| 1624 | // the blob is a stream blob). |
| 1625 | |
| 1626 | ULONG length; // length of segment + overhead |
| 1627 | bool length_flag; |
| 1628 | if (isSegmented()) |
| 1629 | { |
| 1630 | length = segment_length + 2; |
| 1631 | length_flag = true; |
| 1632 | } |
| 1633 | else |
| 1634 | { |
| 1635 | length = segment_length; |
| 1636 | length_flag = false; |
| 1637 | } |
| 1638 | |
| 1639 | // Case 0: Transition from small blob to medium size blob. This really |
| 1640 | // just does a form transformation and drops into the next case. |
| 1641 | |
| 1642 | if (blb_level == 0 && length > (ULONG) blb_space_remaining) |
| 1643 | { |
| 1644 | blb_pages = vcl::newVector(*blb_transaction->tra_pool, 0); |
| 1645 | const USHORT l = dbb->dbb_page_size - BLP_SIZE; |
no test coverage detected