P(mutex);
m_ref_count--;
if (m_ref_count == 0) {
- sql_free_result();
+ if (m_connected) {
+ sql_free_result();
+ }
db_list->remove(this);
if (m_connected && m_db_handle) {
dbi_shutdown_r(m_instance);
P(mutex);
m_ref_count--;
if (m_ref_count == 0) {
- sql_free_result();
+ if (m_connected) {
+ sql_free_result();
+ }
db_list->remove(this);
if (m_connected && m_db_handle) {
INGdisconnectDB(m_db_handle);
m_ref_count--;
Dmsg3(100, "closedb ref=%d connected=%d db=%p\n", m_ref_count, m_connected, m_db_handle);
if (m_ref_count == 0) {
- sql_free_result();
+ if (m_connected) {
+ sql_free_result();
+ }
db_list->remove(this);
if (m_connected) {
Dmsg1(100, "close db=%p\n", m_db_handle);
P(mutex);
m_ref_count--;
if (m_ref_count == 0) {
- sql_free_result();
+ if (m_connected) {
+ sql_free_result();
+ }
db_list->remove(this);
if (m_connected && m_db_handle) {
PQfinish(m_db_handle);
P(mutex);
m_ref_count--;
if (m_ref_count == 0) {
- sql_free_result();
+ if (m_connected) {
+ sql_free_result();
+ }
db_list->remove(this);
if (m_connected && m_db_handle) {
sqlite3_close(m_db_handle);