| 1636 | |
| 1637 | |
| 1638 | void CVT_move_common(const dsc* from, dsc* to, DecimalStatus decSt, Callbacks* cb) |
| 1639 | { |
| 1640 | /************************************** |
| 1641 | * |
| 1642 | * C V T _ m o v e _ c o m m o n |
| 1643 | * |
| 1644 | ************************************** |
| 1645 | * |
| 1646 | * Functional description |
| 1647 | * Move (and possible convert) something to something else. |
| 1648 | * |
| 1649 | **************************************/ |
| 1650 | ULONG length = from->dsc_length; |
| 1651 | UCHAR* p = to->dsc_address; |
| 1652 | const UCHAR* q = from->dsc_address; |
| 1653 | |
| 1654 | // If the datatypes and lengths are identical, just move the |
| 1655 | // stuff byte by byte. Although this may seem slower than |
| 1656 | // optimal, it would cost more to find the fast move than the |
| 1657 | // fast move would gain. |
| 1658 | |
| 1659 | if (DSC_EQUIV(from, to, false)) |
| 1660 | { |
| 1661 | if (length) { |
| 1662 | memcpy(p, q, length); |
| 1663 | } |
| 1664 | return; |
| 1665 | } |
| 1666 | |
| 1667 | // Special optimization case: RDB$DB_KEY is binary compatible with CHAR(8) OCTETS |
| 1668 | |
| 1669 | if ((from->dsc_dtype == dtype_text && |
| 1670 | to->dsc_dtype == dtype_dbkey && |
| 1671 | from->dsc_ttype() == ttype_binary && |
| 1672 | from->dsc_length == to->dsc_length) || |
| 1673 | (to->dsc_dtype == dtype_text && |
| 1674 | from->dsc_dtype == dtype_dbkey && |
| 1675 | to->dsc_ttype() == ttype_binary && |
| 1676 | from->dsc_length == to->dsc_length)) |
| 1677 | { |
| 1678 | memcpy(p, q, length); |
| 1679 | return; |
| 1680 | } |
| 1681 | |
| 1682 | // Do data type by data type conversions. Not all are supported, |
| 1683 | // and some will drop out for additional handling. |
| 1684 | |
| 1685 | dsc d; |
| 1686 | switch (to->dsc_dtype) |
| 1687 | { |
| 1688 | case dtype_timestamp: |
| 1689 | switch (from->dsc_dtype) |
| 1690 | { |
| 1691 | case dtype_varying: |
| 1692 | case dtype_cstring: |
| 1693 | case dtype_text: |
| 1694 | { |
| 1695 | ISC_TIMESTAMP_TZ date; |
no test coverage detected