diff options
author | Michael Biebl <biebl@debian.org> | 2009-04-21 17:52:07 +0200 |
---|---|---|
committer | Michael Biebl <biebl@debian.org> | 2009-04-21 17:52:07 +0200 |
commit | ab9c4e360b143e9b9f78ae80c9da62ecc131e672 (patch) | |
tree | c7b6a54f7c605e7bdf74bdfd884b912efa17cace /plugins/ompgsql | |
parent | ae1b7835db7c4a74ff2d2e48b34f6905a54e8627 (diff) | |
download | rsyslog-ab9c4e360b143e9b9f78ae80c9da62ecc131e672.tar.gz |
Imported Upstream version 3.22.0upstream/3.22.0
Diffstat (limited to 'plugins/ompgsql')
-rw-r--r-- | plugins/ompgsql/Makefile.am | 4 | ||||
-rw-r--r-- | plugins/ompgsql/Makefile.in | 45 | ||||
-rw-r--r-- | plugins/ompgsql/ompgsql.c | 50 |
3 files changed, 66 insertions, 33 deletions
diff --git a/plugins/ompgsql/Makefile.am b/plugins/ompgsql/Makefile.am index cc1c5f4..607239c 100644 --- a/plugins/ompgsql/Makefile.am +++ b/plugins/ompgsql/Makefile.am @@ -1,8 +1,8 @@ pkglib_LTLIBRARIES = ompgsql.la ompgsql_la_SOURCES = ompgsql.c ompgsql.h -ompgsql_la_CPPFLAGS = -I$(top_srcdir) $(pgsql_cflags) $(rsrt_cflags) +ompgsql_la_CPPFLAGS = -I$(top_srcdir) $(PGSQL_CFLAGS) $(RSRT_CFLAGS) ompgsql_la_LDFLAGS = -module -avoid-version -ompgsql_la_LIBADD = $(pgsql_libs) +ompgsql_la_LIBADD = $(PGSQL_LIBS) EXTRA_DIST = createDB.sql diff --git a/plugins/ompgsql/Makefile.in b/plugins/ompgsql/Makefile.in index 65e8b1b..5f318f2 100644 --- a/plugins/ompgsql/Makefile.in +++ b/plugins/ompgsql/Makefile.in @@ -35,7 +35,8 @@ host_triplet = @host@ subdir = plugins/ompgsql DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__aclocal_m4_deps = $(top_srcdir)/m4/atomic_operations.m4 \ + $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d @@ -93,6 +94,7 @@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ +DL_LIBS = @DL_LIBS@ DSYMUTIL = @DSYMUTIL@ ECHO = @ECHO@ ECHO_C = @ECHO_C@ @@ -102,8 +104,10 @@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ F77 = @F77@ FFLAGS = @FFLAGS@ +GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ +GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ -HAVE_GNUTLS_CONFIG = @HAVE_GNUTLS_CONFIG@ +GSS_LIBS = @GSS_LIBS@ HAVE_MYSQL_CONFIG = @HAVE_MYSQL_CONFIG@ HAVE_PGSQL_CONFIG = @HAVE_PGSQL_CONFIG@ INSTALL = @INSTALL@ @@ -112,6 +116,8 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ +LIBDBI_CFLAGS = @LIBDBI_CFLAGS@ +LIBDBI_LIBS = @LIBDBI_LIBS@ LIBLOGGING_CFLAGS = @LIBLOGGING_CFLAGS@ LIBLOGGING_LIBS = @LIBLOGGING_LIBS@ LIBOBJS = @LIBOBJS@ @@ -121,6 +127,8 @@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ +MYSQL_CFLAGS = @MYSQL_CFLAGS@ +MYSQL_LIBS = @MYSQL_LIBS@ NMEDIT = @NMEDIT@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ @@ -130,15 +138,25 @@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ +PGSQL_CFLAGS = @PGSQL_CFLAGS@ +PGSQL_LIBS = @PGSQL_LIBS@ PKG_CONFIG = @PKG_CONFIG@ +PTHREADS_CFLAGS = @PTHREADS_CFLAGS@ +PTHREADS_LIBS = @PTHREADS_LIBS@ RANLIB = @RANLIB@ RELP_CFLAGS = @RELP_CFLAGS@ RELP_LIBS = @RELP_LIBS@ +RSRT_CFLAGS = @RSRT_CFLAGS@ +RSRT_LIBS = @RSRT_LIBS@ +RT_LIBS = @RT_LIBS@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ +SNMP_CFLAGS = @SNMP_CFLAGS@ +SNMP_LIBS = @SNMP_LIBS@ STRIP = @STRIP@ VERSION = @VERSION@ +ZLIB_LIBS = @ZLIB_LIBS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ @@ -160,13 +178,9 @@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ -dl_libs = @dl_libs@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ -gnutls_cflags = @gnutls_cflags@ -gnutls_libs = @gnutls_libs@ -gss_libs = @gss_libs@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ @@ -176,44 +190,31 @@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ -libdbi_cflags = @libdbi_cflags@ -libdbi_libs = @libdbi_libs@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ -mysql_cflags = @mysql_cflags@ -mysql_libs = @mysql_libs@ +moddirs = @moddirs@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ -pgsql_cflags = @pgsql_cflags@ -pgsql_libs = @pgsql_libs@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ -pthreads_cflags = @pthreads_cflags@ -pthreads_libs = @pthreads_libs@ -rsrt_cflags = @rsrt_cflags@ -rsrt_libs = @rsrt_libs@ -rt_libs = @rt_libs@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ -snmp_cflags = @snmp_cflags@ -snmp_libs = @snmp_libs@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -zlib_libs = @zlib_libs@ pkglib_LTLIBRARIES = ompgsql.la ompgsql_la_SOURCES = ompgsql.c ompgsql.h -ompgsql_la_CPPFLAGS = -I$(top_srcdir) $(pgsql_cflags) $(rsrt_cflags) +ompgsql_la_CPPFLAGS = -I$(top_srcdir) $(PGSQL_CFLAGS) $(RSRT_CFLAGS) ompgsql_la_LDFLAGS = -module -avoid-version -ompgsql_la_LIBADD = $(pgsql_libs) +ompgsql_la_LIBADD = $(PGSQL_LIBS) EXTRA_DIST = createDB.sql all: all-am diff --git a/plugins/ompgsql/ompgsql.c b/plugins/ompgsql/ompgsql.c index 7658f03..6daac1c 100644 --- a/plugins/ompgsql/ompgsql.c +++ b/plugins/ompgsql/ompgsql.c @@ -6,7 +6,11 @@ * * File begun on 2007-10-18 by sur5r (converted from ommysql.c) * - * Copyright 2007 Rainer Gerhards and Adiscon GmbH. + * Copyright 2007, 2009 Rainer Gerhards and Adiscon GmbH. + * + * The following link my be useful for the not-so-postgres literate + * when setting up a test environment (on Fedora): + * http://www.jboss.org/community/wiki/InstallPostgreSQLonFedora * * This file is part of rsyslog. * @@ -154,26 +158,55 @@ static rsRetVal initPgSQL(instanceData *pData, int bSilent) } +/* try the insert into postgres and return if that failed or not + * (1 = had error, 0=ok). We do not use the standard IRET calling convention + * rgerhards, 2009-04-17 + */ +static inline int +tryExec(uchar *pszCmd, instanceData *pData) +{ + PGresult *pgRet; + ExecStatusType execState; + int bHadError = 0; + + /* try insert */ + pgRet = PQexec(pData->f_hpgsql, (char*)pszCmd); + execState = PQresultStatus(pgRet); + if(execState != PGRES_COMMAND_OK && execState != PGRES_TUPLES_OK) { + dbgprintf("postgres query execution failed: %s\n", PQresStatus(PQresultStatus(pgRet))); + bHadError = 1; + } + PQclear(pgRet); + + return(bHadError); +} + + /* The following function writes the current log entry * to an established PgSQL session. + * Enhanced function to take care of the returned error + * value (if there is such). Note that this may happen due to + * a sql format error - connection aborts were properly handled + * before my patch. -- rgerhards, 2009-04-17 */ rsRetVal writePgSQL(uchar *psz, instanceData *pData) { + int bHadError = 0; DEFiRet; assert(psz != NULL); assert(pData != NULL); - dbgprintf("writePgSQL: %s", psz); + dbgprintf("writePgSQL: %s\n", psz); - /* try insert */ - PQclear(PQexec(pData->f_hpgsql, (char*)psz)); - if(PQstatus(pData->f_hpgsql) != CONNECTION_OK) { + bHadError = tryExec(psz, pData); /* try insert */ + + 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 */ - PQclear(PQexec(pData->f_hpgsql, (char*)psz)); - if(PQstatus(pData->f_hpgsql) != CONNECTION_OK) { /* re-try insert */ + bHadError = tryExec(psz, pData); /* retry */ + if(bHadError || (PQstatus(pData->f_hpgsql) != CONNECTION_OK)) { /* we failed, giving up for now */ reportDBError(pData, 0); closePgSQL(pData); /* free ressources */ @@ -290,6 +323,5 @@ CODESTARTmodInit CODEmodInit_QueryRegCFSLineHdlr CHKiRet(objUse(errmsg, CORE_COMPONENT)); ENDmodInit -/* - * vi:set ai: +/* vi:set ai: */ |