~ubuntu-branches/ubuntu/trusty/rsyslog/trusty

« back to all changes in this revision

Viewing changes to plugins/ompgsql/ompgsql.c

  • Committer: Dave Walker (Daviey)
  • Author(s): Scott Moser
  • Date: 2011-06-17 20:59:38 UTC
  • mfrom: (36.1.8 oneiric.merge)
  • Revision ID: davewalker@ubuntu.com-20110617205938-pfkizxz2wsgzi2ot
Tags: 5.8.1-1ubuntu1
* Resynchronise with Debian (LP: #794230).  Remaining changes:
  - Run as rsyslog:rsyslog, set $FileOwner to syslog
  - Replace init script with debian/rsyslog.upstart.
  - debian/rsyslog.logrotate: Use reload command to restart rsyslog
  - debian/rsyslog.conf: enable $RepeatedMsgReduction 
    to avoid bloating the syslog file (LP #453444)
  - Add debian/rsyslog.dmesg.upstart to save initial dmesg into a file.
    Install it in debian/rules.
  - debian/50-default.conf: set of default rules for syslog (forwarded to
    Debian #603160). remove file in postrm on purge. manage with ucf.
  - debian/rules: build with LDFLAGS=""
* Dropped:
  - debian/control: Bump build-dependency on debhelper
    debian now depends on dh >= 8
* New upstream release.
* Bump Standards-Version to 3.9.2. No further changes.
* Enable and install impstats module. (Closes: #620114)
* Update logcheck rule. (Closes: #616659)
* debian/rsyslog.init: Set correct compat level (5).
* The way rsyslog processes SIGHUP has changed. It no longer does a reload
  of its configuration, but simply closes all open files. To apply a changed
  configuration, rsyslogd needs to be restarted now.
  - Drop "reload" action from debian/rsyslog.init, map "force-reload" to
    "restart". (Closes: #580897)
  - Add "rotate" action to debian/rsyslog.init which sends SIGHUP to
    rsyslogd. Use that in debian/rsyslog.logrotate. (Closes: #626365)
  - Update debian/rsyslog-mysql.postinst and rsyslog-pgsql.postinst to use
    restart instead of reload.
  - Add a NEWS file explaining the changed SIGHUP handling.
* New upstream stable release.
* New upstream release.
  - Properly handle ANSI SQL strings in ompgsql. (Closes: #600479)
* New upstream release.
* debian/patches/02-pmaixforwardedfrom_type_nokeep.patch
  - Remove, merged upstream.
* debian/patches/03-epoll_create1-fallback.patch
  - Remove, merged upstream.
* debian/patches/03-epoll_create1-fallback.patch
  - If epoll_create1() is not available during runtime, fall back to
    epoll_create(). This fixes remote syslog when runnig rsyslog on a
    lenny kernel. (Closes: #617996)
* New upstream release.
* debian/rsyslog.links
  - Create symlink for rsyslog.service in multi-user.target.wants so rsyslog
    is enabled by default when using systemd.
* debian/patches/02-pmaixforwardedfrom_type_nokeep.patch
  - Fix build failure in aixforwardedfrom parser module by setting the
    module type to NOKEEP.
* debian/rsyslog.preinst
  - Remove old rsyslog.socket symlink from sockets.target.wants on upgrades
    as rsyslog uses syslog.socket now which is provided by systemd.
* debian/rsyslog.install
  - Stop installing rsyslog.socket.
* New upstream release.
* New upstream release.
  - Fix regression in imuxsock plugin which did no longer sanitize received
    messages. This makes 02-cleanup-trailing-lf.patch obsolete and also
    fixes the SQL syntax errors in the mysql output if the input contained
    NUL bytes. Closes: #614061
* Enable and install omprog output plugin. Closes: #552095
* Improve package description. Closes: #612948
  Thanks to Justin B Rye for the patch.
* debian/patches/02-cleanup-trailing-lf.patch
  - Fix regression in imuxsock plugin which did not remove a trailing LF
    anymore. Patch cherry-picked from upstream Git. Closes: #612829
* New upstream release.
* Enable and install parser modules.
* New upstream release.
* Upload to unstable.
* debian/patches/02-typo_fix_equation_sign.patch
  - Removed, merged upstream.
* debian/patches/03-atomic_operations.patch
  - Removed, merged upstream.
* debian/patches/03-atomic_operations.patch
  - Fix build failures on platforms which don't have 64 bit atomic
    operations. Patch cherry-picked from upstream Git. Closes: #600930
* New upstream development release.
* Remove patches, merged upstream
  - debian/patches/02-install_also_rsyslog_socket.patch
  - debian/patches/02-tls_loop_fix.patch
* debian/patches/02-typo_fix_equation_sign.patch
  - Fix small typo ("equation sign"). Closes: #575589
* debian/rsyslog.postinst
  - Remove pre-lenny migration code to rotate old log files from sysklogd.
* New upstream development release.
* debian/rsyslog.install
  - Install omruleset.so plugin: http://www.rsyslog.com/doc/omruleset.html
* debian/rsyslog.default
  - Start rsyslogd with native -c5 mode.
* Install systemd unit files which allow to run rsyslog in socket activation
  mode when systemd is used.
* debian/patches/02-install_also_rsyslog_socket.patch
  - When enabling rsyslog.service also enable rsyslog.socket. Patch
    cherry-picked from upstream Git.
* Bump debhelper compatibility level to 8. Update Build-Depends accordingly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
#include "errmsg.h"
50
50
 
51
51
MODULE_TYPE_OUTPUT
 
52
MODULE_TYPE_NOKEEP
52
53
 
53
54
/* internal structures
54
55
 */
65
66
} instanceData;
66
67
 
67
68
 
 
69
static rsRetVal writePgSQL(uchar *psz, instanceData *pData);
 
70
 
68
71
BEGINcreateInstance
69
72
CODESTARTcreateInstance
70
73
ENDcreateInstance
146
149
 
147
150
        dbgprintf("host=%s dbname=%s uid=%s\n",pData->f_dbsrv,pData->f_dbname,pData->f_dbuid);
148
151
 
 
152
        /* Force PostgreSQL to use ANSI-SQL conforming strings, otherwise we may
 
153
         * get all sorts of side effects (e.g.: backslash escapes) and warnings
 
154
         */
 
155
        const char *PgConnectionOptions = "-c standard_conforming_strings=on";
 
156
 
149
157
        /* Connect to database */
150
 
        if((pData->f_hpgsql=PQsetdbLogin(pData->f_dbsrv, NULL, NULL, NULL,
 
158
        if((pData->f_hpgsql=PQsetdbLogin(pData->f_dbsrv, NULL, PgConnectionOptions, NULL,
151
159
                                pData->f_dbname, pData->f_dbuid, pData->f_dbpwd)) == NULL) {
152
160
                reportDBError(pData, bSilent);
153
161
                closePgSQL(pData); /* ignore any error we may get */
189
197
 * a sql format error - connection aborts were properly handled
190
198
 * before my patch. -- rgerhards, 2009-04-17
191
199
 */
192
 
rsRetVal writePgSQL(uchar *psz, instanceData *pData)
 
200
static rsRetVal
 
201
writePgSQL(uchar *psz, instanceData *pData)
193
202
{
194
203
        int bHadError = 0;
195
204
        DEFiRet;
227
236
CODESTARTtryResume
228
237
        if(pData->f_hpgsql == NULL) {
229
238
                iRet = initPgSQL(pData, 1);
 
239
                if(iRet == RS_RET_OK) {
 
240
                        /* the code above seems not to actually connect to the database. As such, we do a
 
241
                         * dummy statement (a pointless select...) to verify the connection and return
 
242
                         * success only when that statemetn succeeds. Note that I am far from being a 
 
243
                         * PostgreSQL expert, so any patch that does the desired result in a more
 
244
                         * intelligent way is highly welcome. -- rgerhards, 2009-12-16
 
245
                         */
 
246
                        iRet = writePgSQL((uchar*)"select 'a' as a", pData);
 
247
                }
 
248
 
230
249
        }
231
250
ENDtryResume
232
251
 
 
252
 
 
253
BEGINbeginTransaction
 
254
CODESTARTbeginTransaction
 
255
dbgprintf("ompgsql: beginTransaction\n");
 
256
        iRet = writePgSQL((uchar*) "begin", pData); /* TODO: make user-configurable */
 
257
ENDbeginTransaction
 
258
 
 
259
 
233
260
BEGINdoAction
234
261
CODESTARTdoAction
235
262
        dbgprintf("\n");
236
 
        iRet = writePgSQL(ppString[0], pData);
 
263
        CHKiRet(writePgSQL(ppString[0], pData));
 
264
        if(bCoreSupportsBatching)
 
265
                iRet = RS_RET_DEFER_COMMIT;
 
266
finalize_it:
237
267
ENDdoAction
238
268
 
239
269
 
 
270
BEGINendTransaction
 
271
CODESTARTendTransaction
 
272
        iRet = writePgSQL((uchar*) "commit;", pData); /* TODO: make user-configurable */
 
273
dbgprintf("ompgsql: endTransaction\n");
 
274
ENDendTransaction
 
275
 
 
276
 
240
277
BEGINparseSelectorAct
241
278
        int iPgSQLPropErr = 0;
242
279
CODESTARTparseSelectorAct
314
351
BEGINqueryEtryPt
315
352
CODESTARTqueryEtryPt
316
353
CODEqueryEtryPt_STD_OMOD_QUERIES
 
354
CODEqueryEtryPt_TXIF_OMOD_QUERIES /* we support the transactional interface! */
317
355
ENDqueryEtryPt
318
356
 
319
357
 
322
360
        *ipIFVersProvided = CURR_MOD_IF_VERSION; /* we only support the current interface specification */
323
361
CODEmodInit_QueryRegCFSLineHdlr
324
362
        CHKiRet(objUse(errmsg, CORE_COMPONENT));
 
363
        INITChkCoreFeature(bCoreSupportsBatching, CORE_FEATURE_BATCHING);
 
364
        DBGPRINTF("ompgsql: module compiled with rsyslog version %s.\n", VERSION);
 
365
        DBGPRINTF("ompgsql: %susing transactional output interface.\n", bCoreSupportsBatching ? "" : "not ");
325
366
ENDmodInit
326
367
/* vi:set ai:
327
368
 */