summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2010-01-12 13:34:01 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2010-01-12 13:34:01 +0100
commit58870fc483c441fba4a87b8411642ea5bc8a7e74 (patch)
tree10726bfa4634429d24f0d3f41a2e5441b8a13ffb /plugins
parent671470f1a1880865bc1175414b0e5000713556d1 (diff)
parentd7277484811249b7acacb45a223928980e1a36b4 (diff)
downloadrsyslog-58870fc483c441fba4a87b8411642ea5bc8a7e74.tar.gz
rsyslog-58870fc483c441fba4a87b8411642ea5bc8a7e74.tar.xz
rsyslog-58870fc483c441fba4a87b8411642ea5bc8a7e74.zip
Merge branch 'beta'
Diffstat (limited to 'plugins')
-rw-r--r--plugins/ompgsql/ompgsql.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/plugins/ompgsql/ompgsql.c b/plugins/ompgsql/ompgsql.c
index 784a722d..c13f58e9 100644
--- a/plugins/ompgsql/ompgsql.c
+++ b/plugins/ompgsql/ompgsql.c
@@ -65,6 +65,8 @@ typedef struct _instanceData {
} instanceData;
+static rsRetVal writePgSQL(uchar *psz, instanceData *pData);
+
BEGINcreateInstance
CODESTARTcreateInstance
ENDcreateInstance
@@ -170,9 +172,6 @@ tryExec(uchar *pszCmd, instanceData *pData)
int bHadError = 0;
/* try insert */
-BEGINfunc
-RUNLOG_VAR("%p", pData->f_hpgsql);
-RUNLOG_VAR("%s", pszCmd);
pgRet = PQexec(pData->f_hpgsql, (char*)pszCmd);
execState = PQresultStatus(pgRet);
if(execState != PGRES_COMMAND_OK && execState != PGRES_TUPLES_OK) {
@@ -181,7 +180,6 @@ RUNLOG_VAR("%s", pszCmd);
}
PQclear(pgRet);
-ENDfunc
return(bHadError);
}
@@ -193,7 +191,8 @@ ENDfunc
* a sql format error - connection aborts were properly handled
* before my patch. -- rgerhards, 2009-04-17
*/
-rsRetVal writePgSQL(uchar *psz, instanceData *pData)
+static rsRetVal
+writePgSQL(uchar *psz, instanceData *pData)
{
int bHadError = 0;
DEFiRet;
@@ -231,6 +230,16 @@ BEGINtryResume
CODESTARTtryResume
if(pData->f_hpgsql == NULL) {
iRet = initPgSQL(pData, 1);
+ if(iRet == RS_RET_OK) {
+ /* the code above seems not to actually connect to the database. As such, we do a
+ * dummy statement (a pointless select...) to verify the connection and return
+ * success only when that statemetn succeeds. Note that I am far from being a
+ * PostgreSQL expert, so any patch that does the desired result in a more
+ * intelligent way is highly welcome. -- rgerhards, 2009-12-16
+ */
+ iRet = writePgSQL((uchar*)"select 'a' as a", pData);
+ }
+
}
ENDtryResume