diff options
author | Michael Biebl <biebl@debian.org> | 2014-09-26 23:40:38 +0200 |
---|---|---|
committer | Michael Biebl <biebl@debian.org> | 2014-09-26 23:40:38 +0200 |
commit | 7bfd178d59a2c706d46092d745b54c61403cb44a (patch) | |
tree | fe5db3a861d09953408ad79a21318eda3afed7de /plugins/ompgsql | |
parent | 1dfcd909d90f6fad4a612b6fd998d7473a9da399 (diff) | |
download | rsyslog-upstream/8.4.1.tar.gz |
Imported Upstream version 8.4.1upstream/8.4.1upstream
Diffstat (limited to 'plugins/ompgsql')
-rw-r--r-- | plugins/ompgsql/ompgsql.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/plugins/ompgsql/ompgsql.c b/plugins/ompgsql/ompgsql.c index 4da0949..6b89717 100644 --- a/plugins/ompgsql/ompgsql.c +++ b/plugins/ompgsql/ompgsql.c @@ -235,9 +235,18 @@ writePgSQL(uchar *psz, instanceData *pData) if(bHadError || (PQstatus(pData->f_hpgsql) != CONNECTION_OK)) { /* error occured, try to re-init connection and retry */ - closePgSQL(pData); /* close the current handle */ - CHKiRet(initPgSQL(pData, 0)); /* try to re-open */ - bHadError = tryExec(psz, pData); /* retry */ + int inTransaction = 0; + if(pData->f_hpgsql != NULL) { + PGTransactionStatusType xactStatus = PQtransactionStatus(pData->f_hpgsql); + if((xactStatus == PQTRANS_INTRANS) || (xactStatus == PQTRANS_ACTIVE)) { + inTransaction = 1; + } + } + if ( inTransaction == 0 ) { + closePgSQL(pData); /* close the current handle */ + CHKiRet(initPgSQL(pData, 0)); /* try to re-open */ + bHadError = tryExec(psz, pData); /* retry */ + } if(bHadError || (PQstatus(pData->f_hpgsql) != CONNECTION_OK)) { /* we failed, giving up for now */ reportDBError(pData, 0); |