aboutsummaryrefslogtreecommitdiff
path: root/src/bin/pg_basebackup/streamutil.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2012-05-22 10:02:47 -0400
committerRobert Haas <rhaas@postgresql.org>2012-05-22 10:02:47 -0400
commit304aa339b20df9f9ba6f4d93175e05098f6fd1c1 (patch)
tree9716f61ec4086f524b47e06aff7fb07912235871 /src/bin/pg_basebackup/streamutil.c
parent219c024c64ced7ce497fe455b1e3dd7b70012775 (diff)
downloadpostgresql-304aa339b20df9f9ba6f4d93175e05098f6fd1c1.tar.gz
postgresql-304aa339b20df9f9ba6f4d93175e05098f6fd1c1.zip
Prevent pg_basebackup when integer_datetimes flag doesn't match.
Magnus Hagander, reviewed by Fujii Masao, with slight wording changes by me.
Diffstat (limited to 'src/bin/pg_basebackup/streamutil.c')
-rw-r--r--src/bin/pg_basebackup/streamutil.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/bin/pg_basebackup/streamutil.c b/src/bin/pg_basebackup/streamutil.c
index b12932fe3f8..0de6f54e415 100644
--- a/src/bin/pg_basebackup/streamutil.c
+++ b/src/bin/pg_basebackup/streamutil.c
@@ -75,6 +75,7 @@ GetConnection(void)
const char **keywords;
const char **values;
char *password = NULL;
+ const char *tmpparam;
if (dbhost)
argcount++;
@@ -157,6 +158,29 @@ GetConnection(void)
free(values);
free(keywords);
+ /*
+ * Ensure we have the same value of integer timestamps as the
+ * server we are connecting to.
+ */
+ tmpparam = PQparameterStatus(tmpconn, "integer_datetimes");
+ if (!tmpparam)
+ {
+ fprintf(stderr, _("%s: could not determine server setting for integer_datetimes\n"),
+ progname);
+ exit(1);
+ }
+
+#ifdef HAVE_INT64_TIMESTAMP
+ if (strcmp(tmpparam, "on") != 0)
+#else
+ if (strcmp(tmpparam, "off") != 0)
+#endif
+ {
+ fprintf(stderr, _("%s: integer_datetimes compile flag does not match server\n"),
+ progname);
+ exit(1);
+ }
+
/* Store the password for next run */
if (password)
dbpassword = password;