mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-23 07:06:30 +00:00
Consolidate various backported functions
This commit is contained in:
1
HISTORY
1
HISTORY
@@ -10,6 +10,7 @@
|
||||
with cascaded downstream node records (Ian)
|
||||
repmgr: add option `--no-conninfo-password` (Abhijit, Ian)
|
||||
repmgr: add initial support for PostgreSQL 10.0 (Ian)
|
||||
repmgr: escape values in primary_conninfo if needed (Ian)
|
||||
|
||||
3.2.1 2016-10-24
|
||||
repmgr: require a valid repmgr cluster name unless -F/--force
|
||||
|
||||
2
Makefile
2
Makefile
@@ -5,7 +5,7 @@
|
||||
HEADERS = $(wildcard *.h)
|
||||
|
||||
repmgrd_OBJS = dbutils.o config.o repmgrd.o log.o strutil.o
|
||||
repmgr_OBJS = dbutils.o check_dir.o config.o repmgr.o log.o strutil.o dirmod.o escape.o
|
||||
repmgr_OBJS = dbutils.o check_dir.o config.o repmgr.o log.o strutil.o dirmod.o compat.o
|
||||
|
||||
DATA = repmgr.sql uninstall_repmgr.sql
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
/*
|
||||
*
|
||||
* escape.c
|
||||
* parameter escaping functions
|
||||
* compat.c
|
||||
* Provide backports of various functions not publicly
|
||||
* exposed before PostgreSQL 9.6
|
||||
*
|
||||
* Copyright (C) 2ndQuadrant, 2010-2016
|
||||
*
|
||||
@@ -26,7 +27,7 @@
|
||||
#if (PG_VERSION_NUM < 90600)
|
||||
|
||||
#include "repmgr.h"
|
||||
#include "escape.h"
|
||||
#include "compat.h"
|
||||
|
||||
/*
|
||||
* Append the given string to the buffer, with suitable quoting for passing
|
||||
@@ -76,4 +77,35 @@ appendConnStrVal(PQExpBuffer buf, const char *str)
|
||||
appendPQExpBufferStr(buf, str);
|
||||
}
|
||||
|
||||
/*
|
||||
* Adapted from: src/fe_utils/string_utils.c
|
||||
*
|
||||
* Function not publicly available before PostgreSQL 9.6.
|
||||
*/
|
||||
void
|
||||
appendShellString(PQExpBuffer buf, const char *str)
|
||||
{
|
||||
const char *p;
|
||||
|
||||
appendPQExpBufferChar(buf, '\'');
|
||||
for (p = str; *p; p++)
|
||||
{
|
||||
if (*p == '\n' || *p == '\r')
|
||||
{
|
||||
fprintf(stderr,
|
||||
_("shell command argument contains a newline or carriage return: \"%s\"\n"),
|
||||
str);
|
||||
exit(ERR_BAD_CONFIG);
|
||||
}
|
||||
|
||||
if (*p == '\'')
|
||||
appendPQExpBufferStr(buf, "'\"'\"'");
|
||||
else
|
||||
appendPQExpBufferChar(buf, *p);
|
||||
}
|
||||
|
||||
appendPQExpBufferChar(buf, '\'');
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* escape.h
|
||||
* compat.h
|
||||
* Copyright (c) 2ndQuadrant, 2010-2016
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -17,10 +17,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _ESCAPE_H_
|
||||
#define _ESCAPE_H_
|
||||
#ifndef _COMPAT_H_
|
||||
#define _COMPAT_H_
|
||||
|
||||
extern void
|
||||
appendConnStrVal(PQExpBuffer buf, const char *str);
|
||||
|
||||
extern void
|
||||
appendShellString(PQExpBuffer buf, const char *str);
|
||||
|
||||
#endif
|
||||
2
repmgr.c
2
repmgr.c
@@ -64,7 +64,7 @@
|
||||
#include "version.h"
|
||||
|
||||
#if (PG_VERSION_NUM < 90600)
|
||||
#include "escape.h"
|
||||
#include "compat.h"
|
||||
#else
|
||||
#include "fe_utils/string_utils.h"
|
||||
#include "postgres_fe.h"
|
||||
|
||||
31
strutil.c
31
strutil.c
@@ -89,37 +89,6 @@ maxlen_snprintf(char *str, const char *format,...)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Adapted from: src/fe_utils/string_utils.c
|
||||
*
|
||||
* Function not publicly available before PostgreSQL 9.6.
|
||||
*/
|
||||
void
|
||||
appendShellString(PQExpBuffer buf, const char *str)
|
||||
{
|
||||
const char *p;
|
||||
|
||||
appendPQExpBufferChar(buf, '\'');
|
||||
for (p = str; *p; p++)
|
||||
{
|
||||
if (*p == '\n' || *p == '\r')
|
||||
{
|
||||
fprintf(stderr,
|
||||
_("shell command argument contains a newline or carriage return: \"%s\"\n"),
|
||||
str);
|
||||
exit(ERR_BAD_CONFIG);
|
||||
}
|
||||
|
||||
if (*p == '\'')
|
||||
appendPQExpBufferStr(buf, "'\"'\"'");
|
||||
else
|
||||
appendPQExpBufferChar(buf, *p);
|
||||
}
|
||||
|
||||
appendPQExpBufferChar(buf, '\'');
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Escape a string for use as a parameter in recovery.conf
|
||||
* Caller must free returned value
|
||||
|
||||
@@ -49,9 +49,6 @@ extern int
|
||||
maxlen_snprintf(char *str, const char *format,...)
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3)));
|
||||
|
||||
extern void
|
||||
appendShellString(PQExpBuffer buf, const char *str);
|
||||
|
||||
extern char *
|
||||
escape_recovery_conf_value(const char *src);
|
||||
#endif /* _STRUTIL_H_ */
|
||||
|
||||
Reference in New Issue
Block a user