summaryrefslogtreecommitdiff
path: root/plugins/ommysql
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/ommysql')
-rw-r--r--plugins/ommysql/Makefile.in204
-rw-r--r--plugins/ommysql/ommysql.c136
2 files changed, 214 insertions, 126 deletions
diff --git a/plugins/ommysql/Makefile.in b/plugins/ommysql/Makefile.in
index b9b2d5e..794736a 100644
--- a/plugins/ommysql/Makefile.in
+++ b/plugins/ommysql/Makefile.in
@@ -1,9 +1,8 @@
-# Makefile.in generated by automake 1.11.3 from Makefile.am.
+# Makefile.in generated by automake 1.13.4 from Makefile.am.
# @configure_input@
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-# Foundation, Inc.
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@@ -16,6 +15,51 @@
@SET_MAKE@
VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
@@ -35,7 +79,8 @@ POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = plugins/ommysql
-DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+ $(top_srcdir)/depcomp
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/atomic_operations.m4 \
$(top_srcdir)/m4/atomic_operations_64bit.m4 \
@@ -84,9 +129,22 @@ ommysql_la_OBJECTS = $(am_ommysql_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
+am__v_lt_1 =
ommysql_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(ommysql_la_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
@@ -99,22 +157,40 @@ LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
AM_V_CC = $(am__v_CC_@AM_V@)
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
-am__v_CC_0 = @echo " CC " $@;
-AM_V_at = $(am__v_at_@AM_V@)
-am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
-am__v_at_0 = @
+am__v_CC_0 = @echo " CC " $@;
+am__v_CC_1 =
CCLD = $(CC)
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
-am__v_CCLD_0 = @echo " CCLD " $@;
-AM_V_GEN = $(am__v_GEN_@AM_V@)
-am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
-am__v_GEN_0 = @echo " GEN " $@;
+am__v_CCLD_0 = @echo " CCLD " $@;
+am__v_CCLD_1 =
SOURCES = $(ommysql_la_SOURCES)
DIST_SOURCES = $(ommysql_la_SOURCES)
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates. Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+ BEGIN { nonempty = 0; } \
+ { items[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique. This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+ list='$(am__tagged_files)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@@ -174,8 +250,6 @@ LEXLIB = @LEXLIB@
LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
LIBDBI_CFLAGS = @LIBDBI_CFLAGS@
LIBDBI_LIBS = @LIBDBI_LIBS@
-LIBEE_CFLAGS = @LIBEE_CFLAGS@
-LIBEE_LIBS = @LIBEE_LIBS@
LIBESTR_CFLAGS = @LIBESTR_CFLAGS@
LIBESTR_LIBS = @LIBESTR_LIBS@
LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@
@@ -349,9 +423,9 @@ $(top_srcdir)/configure: $(am__configure_deps)
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
+
install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
@$(NORMAL_INSTALL)
- test -z "$(pkglibdir)" || $(MKDIR_P) "$(DESTDIR)$(pkglibdir)"
@list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \
list2=; for p in $$list; do \
if test -f $$p; then \
@@ -359,6 +433,8 @@ install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES)
else :; fi; \
done; \
test -z "$$list2" || { \
+ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \
echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \
$(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \
}
@@ -374,12 +450,15 @@ uninstall-pkglibLTLIBRARIES:
clean-pkglibLTLIBRARIES:
-test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES)
- @list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \
- dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
- test "$$dir" != "$$p" || dir=.; \
- echo "rm -f \"$${dir}/so_locations\""; \
- rm -f "$${dir}/so_locations"; \
- done
+ @list='$(pkglib_LTLIBRARIES)'; \
+ locs=`for p in $$list; do echo $$p; done | \
+ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+ sort -u`; \
+ test -z "$$locs" || { \
+ echo rm -f $${locs}; \
+ rm -f $${locs}; \
+ }
+
ommysql.la: $(ommysql_la_OBJECTS) $(ommysql_la_DEPENDENCIES) $(EXTRA_ommysql_la_DEPENDENCIES)
$(AM_V_CCLD)$(ommysql_la_LINK) -rpath $(pkglibdir) $(ommysql_la_OBJECTS) $(ommysql_la_LIBADD) $(LIBS)
@@ -428,26 +507,15 @@ mostlyclean-libtool:
clean-libtool:
-rm -rf .libs _libs
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
- list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | \
- $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
- END { if (nonempty) { for (i in files) print i; }; }'`; \
- mkid -fID $$unique
-tags: TAGS
-
-TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
- $(TAGS_FILES) $(LISP)
+ID: $(am__tagged_files)
+ $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
- list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | \
- $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
- END { if (nonempty) { for (i in files) print i; }; }'`; \
+ $(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
@@ -459,15 +527,11 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$$unique; \
fi; \
fi
-ctags: CTAGS
-CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
- $(TAGS_FILES) $(LISP)
- list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
- unique=`for i in $$list; do \
- if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
- done | \
- $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
- END { if (nonempty) { for (i in files) print i; }; }'`; \
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ $(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
@@ -476,6 +540,21 @@ GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+ list='$(am__tagged_files)'; \
+ case "$(srcdir)" in \
+ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+ *) sdir=$(subdir)/$(srcdir) ;; \
+ esac; \
+ for i in $$list; do \
+ if test -f "$$i"; then \
+ echo "$(subdir)/$$i"; \
+ else \
+ echo "$$sdir/$$i"; \
+ fi; \
+ done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
@@ -620,19 +699,20 @@ uninstall-am: uninstall-pkglibLTLIBRARIES
.MAKE: install-am install-strip
-.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
- clean-libtool clean-pkglibLTLIBRARIES ctags distclean \
- distclean-compile distclean-generic distclean-libtool \
- distclean-tags distdir dvi dvi-am html html-am info info-am \
- install install-am install-data install-data-am install-dvi \
- install-dvi-am install-exec install-exec-am install-html \
- install-html-am install-info install-info-am install-man \
- install-pdf install-pdf-am install-pkglibLTLIBRARIES \
- install-ps install-ps-am install-strip installcheck \
- installcheck-am installdirs maintainer-clean \
- maintainer-clean-generic mostlyclean mostlyclean-compile \
- mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
- tags uninstall uninstall-am uninstall-pkglibLTLIBRARIES
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \
+ ctags-am distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-data \
+ install-data-am install-dvi install-dvi-am install-exec \
+ install-exec-am install-html install-html-am install-info \
+ install-info-am install-man install-pdf install-pdf-am \
+ install-pkglibLTLIBRARIES install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \
+ uninstall-pkglibLTLIBRARIES
# Tell versions [3.59,3.63) of GNU make to not export all variables.
diff --git a/plugins/ommysql/ommysql.c b/plugins/ommysql/ommysql.c
index 49079ab..c004d1c 100644
--- a/plugins/ommysql/ommysql.c
+++ b/plugins/ommysql/ommysql.c
@@ -6,7 +6,7 @@
*
* File begun on 2007-07-20 by RGerhards (extracted from syslogd.c)
*
- * Copyright 2007-2012 Adiscon GmbH.
+ * Copyright 2007-2013 Adiscon GmbH.
*
* This file is part of rsyslog.
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -55,18 +55,22 @@ DEF_OMOD_STATIC_DATA
DEFobjCurrIf(errmsg)
typedef struct _instanceData {
- MYSQL *f_hmysql; /* handle to MySQL */
char dbsrv[MAXHOSTNAMELEN+1]; /* IP or hostname of DB server*/
unsigned int dbsrvPort; /* port of MySQL server */
char dbname[_DB_MAXDBLEN+1]; /* DB name */
char dbuid[_DB_MAXUNAMELEN+1]; /* DB user */
char dbpwd[_DB_MAXPWDLEN+1]; /* DB user's password */
- unsigned uLastMySQLErrno; /* last errno returned by MySQL or 0 if all is well */
- uchar * f_configfile; /* MySQL Client Configuration File */
- uchar * f_configsection; /* MySQL Client Configuration Section */
- uchar *tplName; /* format template to use */
+ uchar *configfile; /* MySQL Client Configuration File */
+ uchar *configsection; /* MySQL Client Configuration Section */
+ uchar *tplName; /* format template to use */
} instanceData;
+typedef struct wrkrInstanceData {
+ instanceData *pData;
+ MYSQL *hmysql; /* handle to MySQL */
+ unsigned uLastMySQLErrno; /* last errno returned by MySQL or 0 if all is well */
+} wrkrInstanceData_t;
+
typedef struct configSettings_s {
int iSrvPort; /* database server port */
uchar *pszMySQLConfigFile; /* MySQL Client Configuration File */
@@ -104,6 +108,12 @@ CODESTARTcreateInstance
ENDcreateInstance
+BEGINcreateWrkrInstance
+CODESTARTcreateWrkrInstance
+ pWrkrData->hmysql = NULL;
+ENDcreateWrkrInstance
+
+
BEGINisCompatibleWithFeature
CODESTARTisCompatibleWithFeature
if(eFeat == sFEATURERepeatedMsgReduction)
@@ -115,25 +125,28 @@ ENDisCompatibleWithFeature
* MySQL connection.
* Initially added 2004-10-28
*/
-static void closeMySQL(instanceData *pData)
+static void closeMySQL(wrkrInstanceData_t *pWrkrData)
{
- ASSERT(pData != NULL);
-
- if(pData->f_hmysql != NULL) { /* just to be on the safe side... */
- mysql_close(pData->f_hmysql);
- pData->f_hmysql = NULL;
+ if(pWrkrData->hmysql != NULL) { /* just to be on the safe side... */
+ mysql_close(pWrkrData->hmysql);
+ pWrkrData->hmysql = NULL;
}
}
BEGINfreeInstance
CODESTARTfreeInstance
- free(pData->f_configfile);
- free(pData->f_configsection);
+ free(pData->configfile);
+ free(pData->configsection);
free(pData->tplName);
- closeMySQL(pData);
ENDfreeInstance
+BEGINfreeWrkrInstance
+CODESTARTfreeWrkrInstance
+ closeMySQL(pWrkrData);
+ENDfreeWrkrInstance
+
+
BEGINdbgPrintInstInfo
CODESTARTdbgPrintInstInfo
/* nothing special here */
@@ -144,25 +157,23 @@ ENDdbgPrintInstInfo
* We check if we have a valid MySQL handle. If not, we simply
* report an error, but can not be specific. RGerhards, 2007-01-30
*/
-static void reportDBError(instanceData *pData, int bSilent)
+static void reportDBError(wrkrInstanceData_t *pWrkrData, int bSilent)
{
char errMsg[512];
unsigned uMySQLErrno;
- ASSERT(pData != NULL);
-
/* output log message */
errno = 0;
- if(pData->f_hmysql == NULL) {
+ if(pWrkrData->hmysql == NULL) {
errmsg.LogError(0, NO_ERRCODE, "unknown DB error occured - could not obtain MySQL handle");
} else { /* we can ask mysql for the error description... */
- uMySQLErrno = mysql_errno(pData->f_hmysql);
+ uMySQLErrno = mysql_errno(pWrkrData->hmysql);
snprintf(errMsg, sizeof(errMsg)/sizeof(char), "db error (%d): %s\n", uMySQLErrno,
- mysql_error(pData->f_hmysql));
- if(bSilent || uMySQLErrno == pData->uLastMySQLErrno)
+ mysql_error(pWrkrData->hmysql));
+ if(bSilent || uMySQLErrno == pWrkrData->uLastMySQLErrno)
dbgprintf("mysql, DBError(silent): %s\n", errMsg);
else {
- pData->uLastMySQLErrno = uMySQLErrno;
+ pWrkrData->uLastMySQLErrno = uMySQLErrno;
errmsg.LogError(0, NO_ERRCODE, "%s", errMsg);
}
}
@@ -175,25 +186,26 @@ static void reportDBError(instanceData *pData, int bSilent)
* MySQL connection.
* Initially added 2004-10-28 mmeckelein
*/
-static rsRetVal initMySQL(instanceData *pData, int bSilent)
+static rsRetVal initMySQL(wrkrInstanceData_t *pWrkrData, int bSilent)
{
+ instanceData *pData;
DEFiRet;
- ASSERT(pData != NULL);
- ASSERT(pData->f_hmysql == NULL);
- pData->f_hmysql = mysql_init(NULL);
- if(pData->f_hmysql == NULL) {
+ ASSERT(pWrkrData->hmysql == NULL);
+ pData = pWrkrData->pData;
+ pWrkrData->hmysql = mysql_init(NULL);
+ if(pWrkrData->hmysql == NULL) {
errmsg.LogError(0, RS_RET_SUSPENDED, "can not initialize MySQL handle");
iRet = RS_RET_SUSPENDED;
} else { /* we could get the handle, now on with work... */
- mysql_options(pData->f_hmysql,MYSQL_READ_DEFAULT_GROUP,((pData->f_configsection!=NULL)?(char*)pData->f_configsection:"client"));
- if(pData->f_configfile!=NULL){
+ mysql_options(pWrkrData->hmysql,MYSQL_READ_DEFAULT_GROUP,((pData->configsection!=NULL)?(char*)pData->configsection:"client"));
+ if(pData->configfile!=NULL){
FILE * fp;
- fp=fopen((char*)pData->f_configfile,"r");
+ fp=fopen((char*)pData->configfile,"r");
int err=errno;
if(fp==NULL){
char msg[512];
- snprintf(msg,sizeof(msg)/sizeof(char),"Could not open '%s' for reading",pData->f_configfile);
+ snprintf(msg,sizeof(msg)/sizeof(char),"Could not open '%s' for reading",pData->configfile);
if(bSilent) {
char errStr[512];
rs_strerror_r(err, errStr, sizeof(errStr));
@@ -202,17 +214,17 @@ static rsRetVal initMySQL(instanceData *pData, int bSilent)
errmsg.LogError(err,NO_ERRCODE,"mysql configuration error: %s\n",msg);
} else {
fclose(fp);
- mysql_options(pData->f_hmysql,MYSQL_READ_DEFAULT_FILE,pData->f_configfile);
+ mysql_options(pWrkrData->hmysql,MYSQL_READ_DEFAULT_FILE,pData->configfile);
}
}
/* Connect to database */
- if(mysql_real_connect(pData->f_hmysql, pData->dbsrv, pData->dbuid,
+ if(mysql_real_connect(pWrkrData->hmysql, pData->dbsrv, pData->dbuid,
pData->dbpwd, pData->dbname, pData->dbsrvPort, NULL, 0) == NULL) {
- reportDBError(pData, bSilent);
- closeMySQL(pData); /* ignore any error we may get */
+ reportDBError(pWrkrData, bSilent);
+ closeMySQL(pWrkrData); /* ignore any error we may get */
ABORT_FINALIZE(RS_RET_SUSPENDED);
}
- mysql_autocommit(pData->f_hmysql, 0);
+ mysql_autocommit(pWrkrData->hmysql, 0);
}
finalize_it:
@@ -224,35 +236,32 @@ finalize_it:
* to an established MySQL session.
* Initially added 2004-10-28 mmeckelein
*/
-rsRetVal writeMySQL(uchar *psz, instanceData *pData)
+rsRetVal writeMySQL(wrkrInstanceData_t *pWrkrData, uchar *psz)
{
DEFiRet;
- ASSERT(psz != NULL);
- ASSERT(pData != NULL);
-
/* see if we are ready to proceed */
- if(pData->f_hmysql == NULL) {
- CHKiRet(initMySQL(pData, 0));
+ if(pWrkrData->hmysql == NULL) {
+ CHKiRet(initMySQL(pWrkrData, 0));
}
/* try insert */
- if(mysql_query(pData->f_hmysql, (char*)psz)) {
+ if(mysql_query(pWrkrData->hmysql, (char*)psz)) {
/* error occured, try to re-init connection and retry */
- closeMySQL(pData); /* close the current handle */
- CHKiRet(initMySQL(pData, 0)); /* try to re-open */
- if(mysql_query(pData->f_hmysql, (char*)psz)) { /* re-try insert */
+ closeMySQL(pWrkrData); /* close the current handle */
+ CHKiRet(initMySQL(pWrkrData, 0)); /* try to re-open */
+ if(mysql_query(pWrkrData->hmysql, (char*)psz)) { /* re-try insert */
/* we failed, giving up for now */
- reportDBError(pData, 0);
- closeMySQL(pData); /* free ressources */
+ reportDBError(pWrkrData, 0);
+ closeMySQL(pWrkrData); /* free ressources */
ABORT_FINALIZE(RS_RET_SUSPENDED);
}
}
finalize_it:
if(iRet == RS_RET_OK) {
- pData->uLastMySQLErrno = 0; /* reset error for error supression */
+ pWrkrData->uLastMySQLErrno = 0; /* reset error for error supression */
}
RETiRet;
@@ -261,28 +270,28 @@ finalize_it:
BEGINtryResume
CODESTARTtryResume
- if(pData->f_hmysql == NULL) {
- iRet = initMySQL(pData, 1);
+ if(pWrkrData->hmysql == NULL) {
+ iRet = initMySQL(pWrkrData, 1);
}
ENDtryResume
BEGINbeginTransaction
CODESTARTbeginTransaction
- CHKiRet(writeMySQL((uchar*)"START TRANSACTION", pData));
+ CHKiRet(writeMySQL(pWrkrData, (uchar*)"START TRANSACTION"));
finalize_it:
ENDbeginTransaction
BEGINdoAction
CODESTARTdoAction
dbgprintf("\n");
- CHKiRet(writeMySQL(ppString[0], pData));
+ CHKiRet(writeMySQL(pWrkrData, ppString[0]));
iRet = RS_RET_DEFER_COMMIT;
finalize_it:
ENDdoAction
BEGINendTransaction
CODESTARTendTransaction
- if (mysql_commit(pData->f_hmysql) != 0) {
+ if(mysql_commit(pWrkrData->hmysql) != 0) {
dbgprintf("mysql server error: transaction not committed\n");
iRet = RS_RET_SUSPENDED;
}
@@ -293,10 +302,9 @@ static inline void
setInstParamDefaults(instanceData *pData)
{
pData->dbsrvPort = 0;
- pData->f_configfile = NULL;
- pData->f_configsection = NULL;
+ pData->configfile = NULL;
+ pData->configsection = NULL;
pData->tplName = NULL;
- pData->f_hmysql = NULL; /* initialize, but connect only on first message (important for queued mode!) */
}
@@ -338,9 +346,9 @@ CODESTARTnewActInst
strncpy(pData->dbpwd, cstr, sizeof(pData->dbpwd));
free(cstr);
} else if(!strcmp(actpblk.descr[i].name, "mysqlconfig.file")) {
- pData->f_configfile = (uchar*)es_str2cstr(pvals[i].val.d.estr, NULL);
+ pData->configfile = (uchar*)es_str2cstr(pvals[i].val.d.estr, NULL);
} else if(!strcmp(actpblk.descr[i].name, "mysqlconfig.section")) {
- pData->f_configsection = (uchar*)es_str2cstr(pvals[i].val.d.estr, NULL);
+ pData->configsection = (uchar*)es_str2cstr(pvals[i].val.d.estr, NULL);
} else if(!strcmp(actpblk.descr[i].name, "template")) {
pData->tplName = (uchar*)es_str2cstr(pvals[i].val.d.estr, NULL);
} else {
@@ -424,9 +432,8 @@ CODE_STD_STRING_REQUESTparseSelectorAct(1)
ABORT_FINALIZE(RS_RET_INVALID_PARAMS);
} else {
pData->dbsrvPort = (unsigned) cs.iSrvPort; /* set configured port */
- pData->f_configfile = cs.pszMySQLConfigFile;
- pData->f_configsection = cs.pszMySQLConfigSection;
- pData->f_hmysql = NULL; /* initialize, but connect only on first message (important for queued mode!) */
+ pData->configfile = cs.pszMySQLConfigFile;
+ pData->configsection = cs.pszMySQLConfigSection;
}
CODE_STD_FINALIZERparseSelectorAct
@@ -446,6 +453,7 @@ ENDmodExit
BEGINqueryEtryPt
CODESTARTqueryEtryPt
CODEqueryEtryPt_STD_OMOD_QUERIES
+CODEqueryEtryPt_STD_OMOD8_QUERIES
CODEqueryEtryPt_STD_CONF2_OMOD_QUERIES
CODEqueryEtryPt_TXIF_OMOD_QUERIES /* we support the transactional interface! */
ENDqueryEtryPt
@@ -484,7 +492,7 @@ CODEmodInit_QueryRegCFSLineHdlr
mysql_server_init(0, NULL, NULL)
# endif
) {
- errmsg.LogError(0, NO_ERRCODE, "ommysql: mysql_server_init() failed, plugin "
+ errmsg.LogError(0, NO_ERRCODE, "ommysql: intializing mysql client failed, plugin "
"can not run");
ABORT_FINALIZE(RS_RET_ERR);
}