| 1893 | } |
| 1894 | |
| 1895 | void Statement::close(thread_db* tdbb, bool invalidTran) |
| 1896 | { |
| 1897 | // we must stuff exception if and only if this is the first time it occurs |
| 1898 | // once we stuff exception we must punt |
| 1899 | |
| 1900 | const bool wasError = m_error; |
| 1901 | bool doPunt = false; |
| 1902 | |
| 1903 | if (isAllocated() && m_active) |
| 1904 | { |
| 1905 | fb_assert(isAllocated() && m_stmt_selectable); |
| 1906 | try { |
| 1907 | doClose(tdbb, false); |
| 1908 | } |
| 1909 | catch (const Exception& ex) |
| 1910 | { |
| 1911 | if (!doPunt && !wasError) |
| 1912 | { |
| 1913 | doPunt = true; |
| 1914 | ex.stuffException(tdbb->tdbb_status_vector); |
| 1915 | } |
| 1916 | } |
| 1917 | m_active = false; |
| 1918 | } |
| 1919 | |
| 1920 | if (m_boundReq) { |
| 1921 | unBindFromRequest(); |
| 1922 | } |
| 1923 | |
| 1924 | if (invalidTran) |
| 1925 | m_transaction = NULL; |
| 1926 | |
| 1927 | if (m_transaction && m_transaction->getScope() == traAutonomous) |
| 1928 | { |
| 1929 | bool commitFailed = false; |
| 1930 | if (!m_error) |
| 1931 | { |
| 1932 | try { |
| 1933 | m_transaction->commit(tdbb, false); |
| 1934 | } |
| 1935 | catch (const Exception& ex) |
| 1936 | { |
| 1937 | commitFailed = true; |
| 1938 | if (!doPunt && !wasError) |
| 1939 | { |
| 1940 | doPunt = true; |
| 1941 | ex.stuffException(tdbb->tdbb_status_vector); |
| 1942 | } |
| 1943 | } |
| 1944 | } |
| 1945 | |
| 1946 | if (m_error || commitFailed) |
| 1947 | { |
| 1948 | try { |
| 1949 | m_transaction->rollback(tdbb, false); |
| 1950 | } |
| 1951 | catch (const Exception& ex) |
| 1952 | { |
no test coverage detected