Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Break out error codes, cleanup header files and HISTORY

  • Loading branch information...
commit 45022debc639b61afbf4e69d6ff4161ce74bcf1d 1 parent f6618a0
Greg Smith authored
Showing with 81 additions and 33 deletions.
  1. +6 −1 HISTORY
  2. +37 −0 errcode.h
  3. +8 −15 repmgr.c
  4. +1 −14 repmgr.h
  5. +14 −1 strutil.c
  6. +15 −2 strutil.h
7 HISTORY
View
@@ -15,4 +15,9 @@
Add information about progress during "standby clone" (Gabriele)
Fix double free error in repmgrd (Charles Duffy)
Make repmgr exit with an error code when encountering an error (Charles)
- Standardize on error return codes, use in repmgrd too (Greg)
+ Standardize on error return codes, use in repmgrd too (Greg)
+ Add [un]install actions/SQL like most contrib modules (Daniel Farina)
+ Wrap all string construction and produce error on overflow (Daniel)
+ Correct freeing of memory from first_wal_segment (Daniel)
+ Allow creating recovery.conf file with a password (Daniel)
+ Inform when STANDBY CLONE sees an unused config file (Daniel)
37 errcode.h
View
@@ -0,0 +1,37 @@
+/*
+ * errcode.h
+ * Copyright (C) 2ndQuadrant, 2011
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef _ERRCODE_H_
+#define _ERRCODE_H_
+
+/* Exit return code */
+
+#define SUCCESS 0
+#define ERR_BAD_CONFIG 1
+#define ERR_BAD_RSYNC 2
+#define ERR_STOP_BACKUP 3
+#define ERR_NO_RESTART 4
+#define ERR_NEEDS_XLOG 5
+#define ERR_DB_CON 6
+#define ERR_DB_QUERY 7
+#define ERR_PROMOTED 8
+#define ERR_BAD_PASSWORD 9
+#define ERR_STR_OVERFLOW 10
+
+#endif /* _ERRCODE_H_ */
23 repmgr.c
View
@@ -1025,19 +1025,15 @@ do_standby_clone(void)
}
last_wal_segment = PQgetvalue(res, 0, 0);
- if (runtime_options.verbose)
- {
- printf(
- _("%s requires primary to keep WAL files %s until at least %s\n"),
- progname, first_wal_segment, last_wal_segment);
+ log_info(_("%s requires primary to keep WAL files %s until at least %s\n"),
+ progname, first_wal_segment, last_wal_segment);
- /*
- * Only free the first_wal_segment since it was copied out of the
- * pqresult.
- */
- free(first_wal_segment);
- first_wal_segment = NULL;
- }
+ /*
+ * Only free the first_wal_segment since it was copied out of the
+ * pqresult.
+ */
+ free(first_wal_segment);
+ first_wal_segment = NULL;
PQclear(res);
PQfinish(conn);
@@ -1046,9 +1042,6 @@ do_standby_clone(void)
if (r != 0)
exit(ERR_BAD_RSYNC);
- log_info(_("%s requires primary to keep WAL files %s until at least %s\n"),
- progname, first_wal_segment, last_wal_segment);
-
/*
* We need to create the pg_xlog sub directory too, I'm reusing a variable
* here.
15 repmgr.h
View
@@ -26,13 +26,13 @@
#include "strutil.h"
#include "dbutils.h"
+#include "errcode.h"
#define PRIMARY_MODE 0
#define STANDBY_MODE 1
#include "config.h"
#define MAXFILENAME 1024
-#define MAXLINELENGTH 4096
#define ERRBUFF_SIZE 512
#define DEFAULT_CONFIG_FILE "./repmgr.conf"
@@ -42,19 +42,6 @@
#define DEFAULT_DBNAME "postgres"
#define DEFAULT_REPMGR_SCHEMA_PREFIX "repmgr_"
-/* Exit return code */
-
-#define SUCCESS 0
-#define ERR_BAD_CONFIG 1
-#define ERR_BAD_RSYNC 2
-#define ERR_STOP_BACKUP 3
-#define ERR_NO_RESTART 4
-#define ERR_NEEDS_XLOG 5
-#define ERR_DB_CON 6
-#define ERR_DB_QUERY 7
-#define ERR_PROMOTED 8
-#define ERR_BAD_PASSWORD 9
-
/* Run time options type */
typedef struct
{
15 strutil.c
View
@@ -3,6 +3,19 @@
*
* Copyright (C) 2ndQuadrant, 2011
*
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
*/
#include <stdarg.h>
@@ -24,7 +37,7 @@ xvsnprintf(char *str, size_t size, const char *format, va_list ap)
if (retval >= size)
{
fprintf(stderr, "Buffer not large enough to format entire string\n");
- exit(255);
+ exit(ERR_STR_OVERFLOW);
}
return retval;
17 strutil.h
View
@@ -1,15 +1,28 @@
/*
* strutil.h
- *
* Copyright (C) 2ndQuadrant, 2010-2011
*
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
*/
#ifndef _STRUTIL_H_
#define _STRUTIL_H_
#include <stdlib.h>
-
+#include <errcode.h>
#define QUERY_STR_LEN 8192
#define MAXLEN 1024
Please sign in to comment.
Something went wrong with that request. Please try again.