diff --git a/pg_journal-0001-rhbz1337710-out_of_memory_fix.patch b/pg_journal-0001-rhbz1337710-out_of_memory_fix.patch new file mode 100644 index 0000000..4aff7b4 --- /dev/null +++ b/pg_journal-0001-rhbz1337710-out_of_memory_fix.patch @@ -0,0 +1,77 @@ +diff -uNr pg_journal-0.2.0.old/src/pg_journal.c pg_journal-0.2.0.rm_fmt/src/pg_journal.c +--- pg_journal-0.2.0.old/src/pg_journal.c 2013-05-17 17:19:06.000000000 +0000 ++++ pg_journal-0.2.0.rm_fmt/src/pg_journal.c 2016-04-12 17:28:28.033445748 +0000 +@@ -206,6 +206,15 @@ + } + + static void ++append_int(StringInfo str, struct iovec *field, const char *key, int value) ++{ ++ char value_str[1024]; ++ ++ sprintf(value_str, "%d", value); ++ append_string(str, field, key, value_str); ++} ++ ++static void + append_string3(StringInfo str, struct iovec *field, const char *key, + const char *s1, const char *s2, const char *s3) + { +@@ -219,36 +228,7 @@ + field->iov_len = str->len - old_len; + } + +-static void +-append_fmt(StringInfo str, struct iovec *field, const char *fmt, ...) +-/* This extension allows gcc to check the format string */ +-__attribute__((format(PG_PRINTF_ATTRIBUTE, 3, 4))); +- +-/* See backend/lib/stringinfo.c function appendStringInfo */ +-static void +-append_fmt(StringInfo str, struct iovec *field, const char *fmt, ...) +-{ +- size_t old_len = str->len; +- va_list args; +- bool success; +- +- /* appendStringInfoVA can fail due to insufficient space */ +- while (1) { +- va_start(args, fmt); +- success = appendStringInfoVA(str, fmt, args); +- va_end(args); +- +- if (success) +- break; +- +- /* Double the buffer size and try again. */ +- enlargeStringInfo(str, str->maxlen); +- } +- +- field->iov_len = str->len - old_len; +-} +- +-#define MAX_FIELDS 23 /* NB! Keep this in sync when adding fields! */ ++#define MAX_FIELDS 25 /* NB! Keep this in sync when adding fields! */ + + static void + journal_emit_log(ErrorData *edata) +@@ -283,8 +263,8 @@ + ": ", + edata->message); + +- append_fmt(&buf, &fields[n++], "PRIORITY=%d", elevel_to_syslog(edata->elevel)); +- append_fmt(&buf, &fields[n++], "PGLEVEL=%d", edata->elevel); ++ append_int(&buf, &fields[n++], "PRIORITY=", elevel_to_syslog(edata->elevel)); ++ append_int(&buf, &fields[n++], "PGLEVEL=", edata->elevel); + + if (edata->sqlerrcode) + append_string(&buf, &fields[n++], "SQLSTATE=", +@@ -329,7 +309,7 @@ + if (edata->filename) + append_string(&buf, &fields[n++], "CODE_FILE=", edata->filename); + if (edata->lineno > 0) +- append_fmt(&buf, &fields[n++], "CODE_LINE=%d", edata->lineno); ++ append_int(&buf, &fields[n++], "CODE_LINE=", edata->lineno); + if (edata->funcname) + append_string(&buf, &fields[n++], "CODE_FUNCTION=", edata->funcname); + #endif /* SD_JOURNAL_SUPPRESS_LOCATION */ diff --git a/pg_journal.spec b/pg_journal.spec index 087b653..1682936 100644 --- a/pg_journal.spec +++ b/pg_journal.spec @@ -1,11 +1,13 @@ Name: pg_journal Version: 0.2.0 -Release: 11%{?dist} +Release: 12%{?dist} Summary: Module for sending log messages directly to the systemd journal License: PostgreSQL URL: https://github.com/intgr/pg_journal Source0: https://github.com/downloads/intgr/%{name}/%{name}-%{version}.tar.gz +# https://github.com/intgr/pg_journal/issues/1 +Patch0: pg_journal-0001-rhbz1337710-out_of_memory_fix.patch BuildRequires: openssl-devel BuildRequires: pkgconfig @@ -19,6 +21,7 @@ sending log messages directly to the systemd journal log. %prep %setup -q +%autopatch -p1 %build @@ -39,6 +42,9 @@ rm %{buildroot}%{_defaultdocdir}/pgsql/contrib/pg_journal.md %changelog +* Tue May 24 2016 Tomasz Torcz - 0.2.0-12 +- include patch from Ed Behn, fixing startup failure (rhbz#1337710) + * Thu Feb 04 2016 Fedora Release Engineering - 0.2.0-11 - Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild