]> granicus.if.org Git - postgresql/commitdiff
Move relpath() to libpgcommon
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Fri, 22 Feb 2013 01:46:17 +0000 (22:46 -0300)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Fri, 22 Feb 2013 01:46:17 +0000 (22:46 -0300)
This enables non-backend code, such as pg_xlogdump, to use it easily.
The previous location, in src/backend/catalog/catalog.c, made that
essentially impossible because that file depends on many backend-only
facilities; so this needs to live separately.

19 files changed:
src/backend/Makefile
src/backend/access/rmgrdesc/smgrdesc.c
src/backend/access/rmgrdesc/xactdesc.c
src/backend/access/transam/xlogutils.c
src/backend/catalog/catalog.c
src/backend/commands/tablespace.c
src/backend/storage/buffer/bufmgr.c
src/backend/storage/buffer/localbuf.c
src/backend/storage/file/fd.c
src/backend/storage/file/reinit.c
src/backend/storage/smgr/md.c
src/backend/utils/adt/dbsize.c
src/backend/utils/adt/misc.c
src/backend/utils/cache/relcache.c
src/common/Makefile
src/common/relpath.c [new file with mode: 0644]
src/include/catalog/catalog.h
src/include/common/relpath.h [new file with mode: 0644]
src/tools/msvc/Mkvcbuild.pm

index 323b417ed746779a63a82d4a1f8a57a86b277457..318cdbcf76723c356d660c195e72f33c355e4e9c 100644 (file)
@@ -35,10 +35,12 @@ LOCALOBJS += utils/probes.o
 endif
 endif
 
-OBJS = $(SUBDIROBJS) $(LOCALOBJS) $(top_builddir)/src/port/libpgport_srv.a
+OBJS = $(SUBDIROBJS) $(LOCALOBJS) $(top_builddir)/src/port/libpgport_srv.a \
+       $(top_builddir)/src/common/libpgcommon_srv.a
 
-# We put libpgport into OBJS, so remove it from LIBS; also add libldap
-LIBS := $(filter-out -lpgport, $(LIBS)) $(LDAP_LIBS_BE)
+# We put libpgport and libpgcommon into OBJS, so remove it from LIBS; also add
+# libldap
+LIBS := $(filter-out -lpgport -lpgcommon, $(LIBS)) $(LDAP_LIBS_BE)
 
 # The backend doesn't need everything that's in LIBS, however
 LIBS := $(filter-out -lz -lreadline -ledit -ltermcap -lncurses -lcurses, $(LIBS))
index bcabf8993af22f68c1ee34ffe0fa8718c8163382..176d8142a60a205d15fbba666fc1d4fec32b199e 100644 (file)
@@ -16,6 +16,7 @@
 
 #include "catalog/catalog.h"
 #include "catalog/storage_xlog.h"
+#include "common/relpath.h"
 
 
 void
index 247127999e361434d4a700ebf0ad84c3c473c4a8..11c6912753a89bd9eefc78fcd93d302d83f44b8c 100644 (file)
@@ -16,6 +16,7 @@
 
 #include "access/xact.h"
 #include "catalog/catalog.h"
+#include "common/relpath.h"
 #include "storage/sinval.h"
 #include "utils/timestamp.h"
 
index f9a6e628b7fb6bc21838819753b4c1ebb19a9d02..5429d5ed5e9c715c4cb75546db4aa30e4142e4ff 100644 (file)
@@ -20,6 +20,7 @@
 #include "access/xlog.h"
 #include "access/xlogutils.h"
 #include "catalog/catalog.h"
+#include "common/relpath.h"
 #include "storage/smgr.h"
 #include "utils/guc.h"
 #include "utils/hsearch.h"
index 968648627c0a5d58e7d46ba4afa5f34787bb47a1..967182b541bc98d2a8ec81e83a89c7e6014499cd 100644 (file)
@@ -37,6 +37,7 @@
 #include "catalog/pg_shseclabel.h"
 #include "catalog/pg_tablespace.h"
 #include "catalog/toasting.h"
+#include "common/relpath.h"
 #include "miscadmin.h"
 #include "storage/fd.h"
 #include "utils/fmgroids.h"
 #include "utils/tqual.h"
 
 
-#define FORKNAMECHARS  4               /* max chars for a fork name */
-
-/*
- * Lookup table of fork name by fork number.
- *
- * If you add a new entry, remember to update the errhint below, and the
- * documentation for pg_relation_size(). Also keep FORKNAMECHARS above
- * up-to-date.
- */
-const char *forkNames[] = {
-       "main",                                         /* MAIN_FORKNUM */
-       "fsm",                                          /* FSM_FORKNUM */
-       "vm",                                           /* VISIBILITYMAP_FORKNUM */
-       "init"                                          /* INIT_FORKNUM */
-};
 
 /*
  * forkname_to_number - look up fork number by name
@@ -79,130 +65,6 @@ forkname_to_number(char *forkName)
        return InvalidForkNumber;       /* keep compiler quiet */
 }
 
-/*
- * forkname_chars
- *             We use this to figure out whether a filename could be a relation
- *             fork (as opposed to an oddly named stray file that somehow ended
- *             up in the database directory).  If the passed string begins with
- *             a fork name (other than the main fork name), we return its length,
- *             and set *fork (if not NULL) to the fork number.  If not, we return 0.
- *
- * Note that the present coding assumes that there are no fork names which
- * are prefixes of other fork names.
- */
-int
-forkname_chars(const char *str, ForkNumber *fork)
-{
-       ForkNumber      forkNum;
-
-       for (forkNum = 1; forkNum <= MAX_FORKNUM; forkNum++)
-       {
-               int                     len = strlen(forkNames[forkNum]);
-
-               if (strncmp(forkNames[forkNum], str, len) == 0)
-               {
-                       if (fork)
-                               *fork = forkNum;
-                       return len;
-               }
-       }
-       return 0;
-}
-
-/*
- * relpathbackend - construct path to a relation's file
- *
- * Result is a palloc'd string.
- */
-char *
-relpathbackend(RelFileNode rnode, BackendId backend, ForkNumber forknum)
-{
-       int                     pathlen;
-       char       *path;
-
-       if (rnode.spcNode == GLOBALTABLESPACE_OID)
-       {
-               /* Shared system relations live in {datadir}/global */
-               Assert(rnode.dbNode == 0);
-               Assert(backend == InvalidBackendId);
-               pathlen = 7 + OIDCHARS + 1 + FORKNAMECHARS + 1;
-               path = (char *) palloc(pathlen);
-               if (forknum != MAIN_FORKNUM)
-                       snprintf(path, pathlen, "global/%u_%s",
-                                        rnode.relNode, forkNames[forknum]);
-               else
-                       snprintf(path, pathlen, "global/%u", rnode.relNode);
-       }
-       else if (rnode.spcNode == DEFAULTTABLESPACE_OID)
-       {
-               /* The default tablespace is {datadir}/base */
-               if (backend == InvalidBackendId)
-               {
-                       pathlen = 5 + OIDCHARS + 1 + OIDCHARS + 1 + FORKNAMECHARS + 1;
-                       path = (char *) palloc(pathlen);
-                       if (forknum != MAIN_FORKNUM)
-                               snprintf(path, pathlen, "base/%u/%u_%s",
-                                                rnode.dbNode, rnode.relNode,
-                                                forkNames[forknum]);
-                       else
-                               snprintf(path, pathlen, "base/%u/%u",
-                                                rnode.dbNode, rnode.relNode);
-               }
-               else
-               {
-                       /* OIDCHARS will suffice for an integer, too */
-                       pathlen = 5 + OIDCHARS + 2 + OIDCHARS + 1 + OIDCHARS + 1
-                               + FORKNAMECHARS + 1;
-                       path = (char *) palloc(pathlen);
-                       if (forknum != MAIN_FORKNUM)
-                               snprintf(path, pathlen, "base/%u/t%d_%u_%s",
-                                                rnode.dbNode, backend, rnode.relNode,
-                                                forkNames[forknum]);
-                       else
-                               snprintf(path, pathlen, "base/%u/t%d_%u",
-                                                rnode.dbNode, backend, rnode.relNode);
-               }
-       }
-       else
-       {
-               /* All other tablespaces are accessed via symlinks */
-               if (backend == InvalidBackendId)
-               {
-                       pathlen = 9 + 1 + OIDCHARS + 1
-                               + strlen(TABLESPACE_VERSION_DIRECTORY) + 1 + OIDCHARS + 1
-                               + OIDCHARS + 1 + FORKNAMECHARS + 1;
-                       path = (char *) palloc(pathlen);
-                       if (forknum != MAIN_FORKNUM)
-                               snprintf(path, pathlen, "pg_tblspc/%u/%s/%u/%u_%s",
-                                                rnode.spcNode, TABLESPACE_VERSION_DIRECTORY,
-                                                rnode.dbNode, rnode.relNode,
-                                                forkNames[forknum]);
-                       else
-                               snprintf(path, pathlen, "pg_tblspc/%u/%s/%u/%u",
-                                                rnode.spcNode, TABLESPACE_VERSION_DIRECTORY,
-                                                rnode.dbNode, rnode.relNode);
-               }
-               else
-               {
-                       /* OIDCHARS will suffice for an integer, too */
-                       pathlen = 9 + 1 + OIDCHARS + 1
-                               + strlen(TABLESPACE_VERSION_DIRECTORY) + 1 + OIDCHARS + 2
-                               + OIDCHARS + 1 + OIDCHARS + 1 + FORKNAMECHARS + 1;
-                       path = (char *) palloc(pathlen);
-                       if (forknum != MAIN_FORKNUM)
-                               snprintf(path, pathlen, "pg_tblspc/%u/%s/%u/t%d_%u_%s",
-                                                rnode.spcNode, TABLESPACE_VERSION_DIRECTORY,
-                                                rnode.dbNode, backend, rnode.relNode,
-                                                forkNames[forknum]);
-                       else
-                               snprintf(path, pathlen, "pg_tblspc/%u/%s/%u/t%d_%u",
-                                                rnode.spcNode, TABLESPACE_VERSION_DIRECTORY,
-                                                rnode.dbNode, backend, rnode.relNode);
-               }
-       }
-       return path;
-}
-
 /*
  * GetDatabasePath                     - construct path to a database dir
  *
index 9bba75be1a2d561629134eefd7beae57fb0d919b..7cad0cc969d5f9e41564f9f6cbba885e7b701138 100644 (file)
@@ -64,6 +64,7 @@
 #include "commands/comment.h"
 #include "commands/seclabel.h"
 #include "commands/tablespace.h"
+#include "common/relpath.h"
 #include "miscadmin.h"
 #include "postmaster/bgwriter.h"
 #include "storage/fd.h"
index 405ff61130e81319745001e66a2f20f8c3e1bd46..ea7d469f2f412212fc531ece5ef58f3732467da0 100644 (file)
@@ -34,6 +34,7 @@
 #include <unistd.h>
 
 #include "catalog/catalog.h"
+#include "common/relpath.h"
 #include "executor/instrument.h"
 #include "miscadmin.h"
 #include "pg_trace.h"
index df15789e6a6aebb3fa1ee4ffc2d1dee58bd5f2d3..30dc8098ed2f92c7fa9c36d210df992a81aa54a9 100644 (file)
@@ -16,6 +16,7 @@
 #include "postgres.h"
 
 #include "catalog/catalog.h"
+#include "common/relpath.h"
 #include "executor/instrument.h"
 #include "storage/buf_internals.h"
 #include "storage/bufmgr.h"
index ff7e221cde9527c2caecb682f86fdb5dda2eb58c..ba1b84eadeff288b130b6de8b5572219ae9dd561 100644 (file)
@@ -71,6 +71,7 @@
 #include "access/xact.h"
 #include "catalog/catalog.h"
 #include "catalog/pg_tablespace.h"
+#include "common/relpath.h"
 #include "pgstat.h"
 #include "storage/fd.h"
 #include "storage/ipc.h"
index 2623be8aeff13a6a587158b48cb5393d82df782a..d62d5848a7a39d7dcc6b04c68f49fe4f50e9f444 100644 (file)
@@ -17,6 +17,7 @@
 #include <unistd.h>
 
 #include "catalog/catalog.h"
+#include "common/relpath.h"
 #include "storage/copydir.h"
 #include "storage/fd.h"
 #include "storage/reinit.h"
index 20eb36a85f93a88c803acefca18b8b8e6cdbc039..7d567ae1103968eaa4b530c8345259e8adbc4c60 100644 (file)
@@ -21,6 +21,7 @@
 #include "miscadmin.h"
 #include "access/xlog.h"
 #include "catalog/catalog.h"
+#include "common/relpath.h"
 #include "portability/instr_time.h"
 #include "postmaster/bgwriter.h"
 #include "storage/fd.h"
index 89ad3868bac184fed9ee81bf604ea1d11380c015..11b004072f6ca998df3a21367d0d1e085819217e 100644 (file)
@@ -21,6 +21,7 @@
 #include "catalog/pg_tablespace.h"
 #include "commands/dbcommands.h"
 #include "commands/tablespace.h"
+#include "common/relpath.h"
 #include "miscadmin.h"
 #include "storage/fd.h"
 #include "utils/acl.h"
index a36d065abf23c7c7e58a8984c90bf75fc8219352..4e38d7c06c2e7496633f546f447d2dd211976eb5 100644 (file)
@@ -24,6 +24,7 @@
 #include "catalog/pg_tablespace.h"
 #include "catalog/pg_type.h"
 #include "commands/dbcommands.h"
+#include "common/relpath.h"
 #include "funcapi.h"
 #include "miscadmin.h"
 #include "parser/keywords.h"
index b9c03c31156c944f2cf05879fdbfc81ab4f0f8e4..e85c7a987254e3d958b21ae69f7e3da31dedc0d6 100644 (file)
@@ -56,6 +56,7 @@
 #include "catalog/schemapg.h"
 #include "catalog/storage.h"
 #include "commands/trigger.h"
+#include "common/relpath.h"
 #include "miscadmin.h"
 #include "optimizer/clauses.h"
 #include "optimizer/planmain.h"
index 55d7b5b93500e7fe6ead273f911c95c6c8e3f56b..cd97980ce663147087c133d6ff16ab75b8a0443e 100644 (file)
@@ -23,13 +23,13 @@ include $(top_builddir)/src/Makefile.global
 override CPPFLAGS := -DFRONTEND $(CPPFLAGS)
 LIBS += $(PTHREAD_LIBS)
 
-OBJS_COMMON =
+OBJS_COMMON = relpath.o
 
 OBJS_FRONTEND = $(OBJS_COMMON) fe_memutils.o
 
 OBJS_SRV = $(OBJS_COMMON:%.o=%_srv.o)
 
-all: libpgcommon.a
+all: libpgcommon.a libpgcommon_srv.a
 
 # libpgcommon is needed by some contrib
 install: all installdirs
@@ -60,5 +60,12 @@ libpgcommon_srv.a: $(OBJS_SRV)
 %_srv.o: %.c %.o
        $(CC) $(CFLAGS) $(subst -DFRONTEND,, $(CPPFLAGS)) -c $< -o $@
 
+$(OBJS_SRV): | submake-errcodes
+
+.PHONY: submake-errcodes
+
+submake-errcodes:
+       $(MAKE) -C ../backend submake-errcodes
+
 clean distclean maintainer-clean:
        rm -f libpgcommon.a libpgcommon_srv.a $(OBJS_FRONTEND) $(OBJS_SRV)
diff --git a/src/common/relpath.c b/src/common/relpath.c
new file mode 100644 (file)
index 0000000..18fe4d1
--- /dev/null
@@ -0,0 +1,162 @@
+/*-------------------------------------------------------------------------
+ * relpath.c
+ *             Shared frontend/backend code to find out pathnames of relation files
+ *
+ * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ * IDENTIFICATION
+ *    src/common/relpath.c
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef FRONTEND
+#include "postgres.h"
+#else
+#include "postgres_fe.h"
+#endif
+
+#include "catalog/pg_tablespace.h"
+#include "common/relpath.h"
+#include "storage/backendid.h"
+
+#define FORKNAMECHARS  4               /* max chars for a fork name */
+
+/*
+ * Lookup table of fork name by fork number.
+ *
+ * If you add a new entry, remember to update the errhint below, and the
+ * documentation for pg_relation_size(). Also keep FORKNAMECHARS above
+ * up-to-date.
+ */
+const char *forkNames[] = {
+       "main",                                         /* MAIN_FORKNUM */
+       "fsm",                                          /* FSM_FORKNUM */
+       "vm",                                           /* VISIBILITYMAP_FORKNUM */
+       "init"                                          /* INIT_FORKNUM */
+};
+
+/*
+ * forkname_chars
+ *             We use this to figure out whether a filename could be a relation
+ *             fork (as opposed to an oddly named stray file that somehow ended
+ *             up in the database directory).  If the passed string begins with
+ *             a fork name (other than the main fork name), we return its length,
+ *             and set *fork (if not NULL) to the fork number.  If not, we return 0.
+ *
+ * Note that the present coding assumes that there are no fork names which
+ * are prefixes of other fork names.
+ */
+int
+forkname_chars(const char *str, ForkNumber *fork)
+{
+       ForkNumber      forkNum;
+
+       for (forkNum = 1; forkNum <= MAX_FORKNUM; forkNum++)
+       {
+               int                     len = strlen(forkNames[forkNum]);
+
+               if (strncmp(forkNames[forkNum], str, len) == 0)
+               {
+                       if (fork)
+                               *fork = forkNum;
+                       return len;
+               }
+       }
+       return 0;
+}
+
+/*
+ * relpathbackend - construct path to a relation's file
+ *
+ * Result is a palloc'd string.
+ */
+char *
+relpathbackend(RelFileNode rnode, BackendId backend, ForkNumber forknum)
+{
+       int                     pathlen;
+       char       *path;
+
+       if (rnode.spcNode == GLOBALTABLESPACE_OID)
+       {
+               /* Shared system relations live in {datadir}/global */
+               Assert(rnode.dbNode == 0);
+               Assert(backend == InvalidBackendId);
+               pathlen = 7 + OIDCHARS + 1 + FORKNAMECHARS + 1;
+               path = (char *) palloc(pathlen);
+               if (forknum != MAIN_FORKNUM)
+                       snprintf(path, pathlen, "global/%u_%s",
+                                        rnode.relNode, forkNames[forknum]);
+               else
+                       snprintf(path, pathlen, "global/%u", rnode.relNode);
+       }
+       else if (rnode.spcNode == DEFAULTTABLESPACE_OID)
+       {
+               /* The default tablespace is {datadir}/base */
+               if (backend == InvalidBackendId)
+               {
+                       pathlen = 5 + OIDCHARS + 1 + OIDCHARS + 1 + FORKNAMECHARS + 1;
+                       path = (char *) palloc(pathlen);
+                       if (forknum != MAIN_FORKNUM)
+                               snprintf(path, pathlen, "base/%u/%u_%s",
+                                                rnode.dbNode, rnode.relNode,
+                                                forkNames[forknum]);
+                       else
+                               snprintf(path, pathlen, "base/%u/%u",
+                                                rnode.dbNode, rnode.relNode);
+               }
+               else
+               {
+                       /* OIDCHARS will suffice for an integer, too */
+                       pathlen = 5 + OIDCHARS + 2 + OIDCHARS + 1 + OIDCHARS + 1
+                               + FORKNAMECHARS + 1;
+                       path = (char *) palloc(pathlen);
+                       if (forknum != MAIN_FORKNUM)
+                               snprintf(path, pathlen, "base/%u/t%d_%u_%s",
+                                                rnode.dbNode, backend, rnode.relNode,
+                                                forkNames[forknum]);
+                       else
+                               snprintf(path, pathlen, "base/%u/t%d_%u",
+                                                rnode.dbNode, backend, rnode.relNode);
+               }
+       }
+       else
+       {
+               /* All other tablespaces are accessed via symlinks */
+               if (backend == InvalidBackendId)
+               {
+                       pathlen = 9 + 1 + OIDCHARS + 1
+                               + strlen(TABLESPACE_VERSION_DIRECTORY) + 1 + OIDCHARS + 1
+                               + OIDCHARS + 1 + FORKNAMECHARS + 1;
+                       path = (char *) palloc(pathlen);
+                       if (forknum != MAIN_FORKNUM)
+                               snprintf(path, pathlen, "pg_tblspc/%u/%s/%u/%u_%s",
+                                                rnode.spcNode, TABLESPACE_VERSION_DIRECTORY,
+                                                rnode.dbNode, rnode.relNode,
+                                                forkNames[forknum]);
+                       else
+                               snprintf(path, pathlen, "pg_tblspc/%u/%s/%u/%u",
+                                                rnode.spcNode, TABLESPACE_VERSION_DIRECTORY,
+                                                rnode.dbNode, rnode.relNode);
+               }
+               else
+               {
+                       /* OIDCHARS will suffice for an integer, too */
+                       pathlen = 9 + 1 + OIDCHARS + 1
+                               + strlen(TABLESPACE_VERSION_DIRECTORY) + 1 + OIDCHARS + 2
+                               + OIDCHARS + 1 + OIDCHARS + 1 + FORKNAMECHARS + 1;
+                       path = (char *) palloc(pathlen);
+                       if (forknum != MAIN_FORKNUM)
+                               snprintf(path, pathlen, "pg_tblspc/%u/%s/%u/t%d_%u_%s",
+                                                rnode.spcNode, TABLESPACE_VERSION_DIRECTORY,
+                                                rnode.dbNode, backend, rnode.relNode,
+                                                forkNames[forknum]);
+                       else
+                               snprintf(path, pathlen, "pg_tblspc/%u/%s/%u/t%d_%u",
+                                                rnode.spcNode, TABLESPACE_VERSION_DIRECTORY,
+                                                rnode.dbNode, backend, rnode.relNode);
+               }
+       }
+       return path;
+}
+
index 5d506fe78b1cca3385429739e791bbee3dd9ce0b..44b6f38743681a0706047d7a4b973ce00dfb0fd8 100644 (file)
 #ifndef CATALOG_H
 #define CATALOG_H
 
-/*
- *     'pgrminclude ignore' needed here because CppAsString2() does not throw
- *     an error if the symbol is not defined.
- */
-#include "catalog/catversion.h" /* pgrminclude ignore */
 #include "catalog/pg_class.h"
 #include "storage/relfilenode.h"
 #include "utils/relcache.h"
 
-#define OIDCHARS               10              /* max chars printed by %u */
-#define TABLESPACE_VERSION_DIRECTORY   "PG_" PG_MAJORVERSION "_" \
-                                                                       CppAsString2(CATALOG_VERSION_NO)
-
-extern const char *forkNames[];
 extern ForkNumber forkname_to_number(char *forkName);
-extern int     forkname_chars(const char *str, ForkNumber *);
 
-extern char *relpathbackend(RelFileNode rnode, BackendId backend,
-                          ForkNumber forknum);
 extern char *GetDatabasePath(Oid dbNode, Oid spcNode);
 
-/* First argument is a RelFileNodeBackend */
-#define relpath(rnode, forknum) \
-               relpathbackend((rnode).node, (rnode).backend, (forknum))
-
-/* First argument is a RelFileNode */
-#define relpathperm(rnode, forknum) \
-               relpathbackend((rnode), InvalidBackendId, (forknum))
 
 extern bool IsSystemRelation(Relation relation);
 extern bool IsToastRelation(Relation relation);
diff --git a/src/include/common/relpath.h b/src/include/common/relpath.h
new file mode 100644 (file)
index 0000000..5b28bd0
--- /dev/null
@@ -0,0 +1,41 @@
+/*-------------------------------------------------------------------------
+ *
+ * relpath.h
+ *             Declarations for relpath() and friends
+ *
+ * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ * src/include/common/relpath.h
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef RELPATH_H
+#define RELPATH_H
+
+/*
+ *     'pgrminclude ignore' needed here because CppAsString2() does not throw
+ *     an error if the symbol is not defined.
+ */
+#include "catalog/catversion.h" /* pgrminclude ignore */
+#include "storage/relfilenode.h"
+
+
+#define OIDCHARS               10              /* max chars printed by %u */
+#define TABLESPACE_VERSION_DIRECTORY   "PG_" PG_MAJORVERSION "_" \
+                                                                       CppAsString2(CATALOG_VERSION_NO)
+
+extern const char *forkNames[];
+extern int     forkname_chars(const char *str, ForkNumber *fork);
+extern char *relpathbackend(RelFileNode rnode, BackendId backend,
+                          ForkNumber forknum);
+
+/* First argument is a RelFileNodeBackend */
+#define relpath(rnode, forknum) \
+               relpathbackend((rnode).node, (rnode).backend, (forknum))
+
+/* First argument is a RelFileNode */
+#define relpathperm(rnode, forknum) \
+               relpathbackend((rnode), InvalidBackendId, (forknum))
+
+#endif         /* RELPATH_H */
index ad797ffa6c8dfc8a1e0816907bae2c9d495a21fd..9bca46fa941a3f0d4f02937de2de210a29fc67cc 100644 (file)
@@ -69,10 +69,13 @@ sub mkvcbuild
          sprompt.c tar.c thread.c getopt.c getopt_long.c dirent.c rint.c win32env.c
          win32error.c win32setlocale.c);
 
-       our @pgcommonfiles = qw(
-               fe_memutils.c);
+       our @pgcommonallfiles = qw(
+               relpath.c);
 
-       our @pgcommonbkndfiles = qw();
+       our @pgcommonfrontendfiles = (@pgcommonallfiles,
+               qw(fe_memutils.c));
+
+       our @pgcommonbkndfiles = @pgcommonallfiles;
 
        $libpgport = $solution->AddProject('libpgport', 'lib', 'misc');
        $libpgport->AddDefine('FRONTEND');
@@ -80,7 +83,7 @@ sub mkvcbuild
 
        $libpgcommon = $solution->AddProject('libpgcommon', 'lib', 'misc');
        $libpgcommon->AddDefine('FRONTEND');
-       $libpgcommon->AddFiles('src\common', @pgcommonfiles);
+       $libpgcommon->AddFiles('src\common', @pgcommonfrontendfiles);
 
        $postgres = $solution->AddProject('postgres', 'exe', '', 'src\backend');
        $postgres->AddIncludeDir('src\backend');