From 15c34be96178afe9189edfa7970a789704919a2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=ED=98=84=EC=88=98?= Date: Tue, 23 Jan 2024 15:56:01 +0900 Subject: [PATCH] Supports PostgreSQL 9.4 and later versions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The return value data type of function “appendStringInfoVA” has changed. Before PostgreSQL 9.4, returns true on success, or false as bool type on failure. Since PostgreSQL 9.4, returns 0 on success, and returns the required memory size as an integer on failure. --- src/pg_journal.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/pg_journal.c b/src/pg_journal.c index cb07910..de563e9 100644 --- a/src/pg_journal.c +++ b/src/pg_journal.c @@ -230,16 +230,29 @@ append_fmt(StringInfo str, struct iovec *field, const char *fmt, ...) { size_t old_len = str->len; va_list args; +#if PG_VERSION_NUM >= 90400 + int needed; +#else bool success; +#endif /* appendStringInfoVA can fail due to insufficient space */ while (1) { va_start(args, fmt); +#if PG_VERSION_NUM >= 90400 + needed = appendStringInfoVA(str, fmt, args); +#else success = appendStringInfoVA(str, fmt, args); +#endif va_end(args); +#if PG_VERSION_NUM >= 90400 + if (needed == 0) + break; +#else if (success) break; +#endif /* Double the buffer size and try again. */ enlargeStringInfo(str, str->maxlen);