| 1783 | |
| 1784 | |
| 1785 | static void parseSQLDA(XSQLDA* xsqlda, UCharBuffer& buff, Firebird::Array<dsc> &descs) |
| 1786 | { |
| 1787 | FB_SIZE_T offset = 0; |
| 1788 | XSQLVAR* xVar = xsqlda->sqlvar; |
| 1789 | |
| 1790 | for (int i = 0; i < xsqlda->sqld; xVar++, i++) |
| 1791 | { |
| 1792 | const UCHAR dtype = fb_utils::sqlTypeToDscType(xVar->sqltype & ~1); |
| 1793 | xVar->sqltype |= 1; |
| 1794 | |
| 1795 | if (type_alignments[dtype]) |
| 1796 | offset = FB_ALIGN(offset, type_alignments[dtype]); |
| 1797 | |
| 1798 | offset += xVar->sqllen; |
| 1799 | const int type = xVar->sqltype & (~1); |
| 1800 | if (type == SQL_VARYING) |
| 1801 | offset += sizeof(SSHORT); |
| 1802 | |
| 1803 | // null indicator |
| 1804 | offset = FB_ALIGN(offset, type_alignments[dtype_short]); |
| 1805 | offset += sizeof(SSHORT); |
| 1806 | } |
| 1807 | |
| 1808 | descs.resize(xsqlda->sqld * 2); |
| 1809 | UCHAR* p = buff.getBuffer(offset); |
| 1810 | |
| 1811 | offset = 0; |
| 1812 | xVar = xsqlda->sqlvar; |
| 1813 | |
| 1814 | for (int i = 0; i < xsqlda->sqld; xVar++, i++) |
| 1815 | { |
| 1816 | const UCHAR dtype = fb_utils::sqlTypeToDscType(xVar->sqltype & ~1); |
| 1817 | if (type_alignments[dtype]) |
| 1818 | offset = FB_ALIGN(offset, type_alignments[dtype]); |
| 1819 | |
| 1820 | xVar->sqldata = (ISC_SCHAR*) (p + offset); |
| 1821 | |
| 1822 | // build the src descriptor |
| 1823 | dsc& src = descs[i * 2]; |
| 1824 | src.dsc_dtype = dtype; |
| 1825 | src.dsc_length = xVar->sqllen; |
| 1826 | src.dsc_scale = xVar->sqlscale; |
| 1827 | src.dsc_sub_type = xVar->sqlsubtype; |
| 1828 | src.dsc_address = (UCHAR*) xVar->sqldata; |
| 1829 | |
| 1830 | offset += xVar->sqllen; |
| 1831 | const int type = xVar->sqltype & (~1); |
| 1832 | if (type == SQL_VARYING) |
| 1833 | { |
| 1834 | offset += sizeof(SSHORT); |
| 1835 | src.dsc_length += sizeof(SSHORT); |
| 1836 | } |
| 1837 | else if (type == SQL_NULL) { |
| 1838 | src.dsc_flags |= DSC_null; |
| 1839 | } |
| 1840 | |
| 1841 | // null indicator |
| 1842 | offset = FB_ALIGN(offset, type_alignments[dtype_short]); |