On Wed, Jul 15, 2020 at 01:22:21PM +0200, Magnus Hagander wrote:
> According to the documentation, the filename given in file_fdw must be an
> absolute path. Hwever, it works perfectly fine with a relative path.
> 
> So either the documentation is wrong, or the code is wrong. It behaves the 
> same
> at least back to 9.5, I did not try it further back than that.

Yes, I tested back to 9.5 too:

        CREATE EXTENSION file_fdw;
        CREATE SERVER pgconf FOREIGN DATA WRAPPER file_fdw;
        CREATE FOREIGN TABLE pgconf (line TEXT) SERVER pgconf OPTIONS ( filename
                'postgresql.conf', format 'text', delimiter E'\x7f' );
        SELECT * FROM pgconf;
         # -----------------------------
         # PostgreSQL configuration file
         # -----------------------------
         #
         # This file consists of lines of the form:
        ...

> I can't find a reference to the code that limits this. AFAICT the 
> documentation
> has been there since day 1.
> 
> Question is, which one is right. Is there a reason we'd want to restrict it to
> absolute pathnames?

I think it should work just like COPY, which allows relative paths;  doc
patch attached.

-- 
  Bruce Momjian  <br...@momjian.us>        https://momjian.us
  EnterpriseDB                             https://enterprisedb.com

  The usefulness of a cup is in its emptiness, Bruce Lee

diff --git a/doc/src/sgml/file-fdw.sgml b/doc/src/sgml/file-fdw.sgml
index ed028e4ec9..d985ef0a06 100644
--- a/doc/src/sgml/file-fdw.sgml
+++ b/doc/src/sgml/file-fdw.sgml
@@ -28,7 +28,8 @@
 
    <listitem>
     <para>
-     Specifies the file to be read.  Must be an absolute path name.
+     Specifies the file to be read.  Relative paths are relative to the
+     data directory.
      Either <literal>filename</literal> or <literal>program</literal> must be
      specified, but not both.
     </para>

Reply via email to