aboutsummaryrefslogtreecommitdiff
path: root/src/bin/pg_rewind/filemap.c
diff options
context:
space:
mode:
authorFujii Masao <fujii@postgresql.org>2018-03-06 02:08:18 +0900
committerFujii Masao <fujii@postgresql.org>2018-03-06 02:08:18 +0900
commit2f3e2340cd1b67e91cefdf45e4c915297d1034e2 (patch)
tree18e80c5cb94f3a0c7004b0cf66d34150159abc5a /src/bin/pg_rewind/filemap.c
parent09230e54fb39e8cd8add3f119d03afd72adc72b9 (diff)
downloadpostgresql-2f3e2340cd1b67e91cefdf45e4c915297d1034e2.tar.gz
postgresql-2f3e2340cd1b67e91cefdf45e4c915297d1034e2.zip
Fix pg_rewind to handle relation data files in tablespaces properly.
pg_rewind checks whether each file is a relation data file, from its path. Previously this check logic had the bug which made pg_rewind fail to recognize any relation data files in tablespaces. Which also caused an assertion failure in pg_rewind. Back-patch to 9.5 where pg_rewind was added. Author: Takayuki Tsunakawa Reviewed-by: Michael Paquier Discussion: https://postgr.es/m/0A3221C70F24FB45833433255569204D1F8D6C7A@G01JPEXMBYT05
Diffstat (limited to 'src/bin/pg_rewind/filemap.c')
-rw-r--r--src/bin/pg_rewind/filemap.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/bin/pg_rewind/filemap.c b/src/bin/pg_rewind/filemap.c
index 19da1ee7e02..6122f177fe0 100644
--- a/src/bin/pg_rewind/filemap.c
+++ b/src/bin/pg_rewind/filemap.c
@@ -19,6 +19,7 @@
#include "pg_rewind.h"
#include "common/string.h"
+#include "catalog/catalog.h"
#include "catalog/pg_tablespace.h"
#include "storage/fd.h"
@@ -554,7 +555,6 @@ print_filemap(void)
static bool
isRelDataFile(const char *path)
{
- char buf[20 + 1];
RelFileNode rnode;
unsigned int segNo;
int nmatch;
@@ -569,7 +569,7 @@ isRelDataFile(const char *path)
* base/<db oid>/
* regular relations, default tablespace
*
- * pg_tblspc/<tblspc oid>/PG_9.4_201403261/
+ * pg_tblspc/<tblspc oid>/<tblspc version>/
* within a non-default tablespace (the name of the directory
* depends on version)
*
@@ -603,21 +603,19 @@ isRelDataFile(const char *path)
}
else
{
- nmatch = sscanf(path, "pg_tblspc/%u/PG_%20s/%u/%u.%u",
- &rnode.spcNode, buf, &rnode.dbNode, &rnode.relNode,
+ nmatch = sscanf(path, "pg_tblspc/%u/" TABLESPACE_VERSION_DIRECTORY "/%u/%u.%u",
+ &rnode.spcNode, &rnode.dbNode, &rnode.relNode,
&segNo);
- if (nmatch == 4 || nmatch == 5)
+ if (nmatch == 3 || nmatch == 4)
matched = true;
}
}
/*
* The sscanf tests above can match files that have extra characters at
- * the end, and the last check can also match a path belonging to a
- * different version (different TABLESPACE_VERSION_DIRECTORY). To make
- * eliminate such cases, cross-check that GetRelationPath creates the
- * exact same filename, when passed the RelFileNode information we
- * extracted from the filename.
+ * the end. To eliminate such cases, cross-check that GetRelationPath
+ * creates the exact same filename, when passed the RelFileNode information
+ * we extracted from the filename.
*/
if (matched)
{