Home Explore Blog CI



postgresql

3rd chunk of `doc/src/sgml/file-fdw.sgml`
5eff7583ac31f52c3f5407d21e837a5b42a778d6acbea4da0000000100000874
 Boolean option.  If true, it specifies that values of the
     column which match the null string are returned as <literal>NULL</literal>
     even if the value is quoted. Without this option, only unquoted
     values matching the null string are returned as <literal>NULL</literal>.
     This has the same effect  as listing the column in
     <command>COPY</command>'s <literal>FORCE_NULL</literal> option.
    </para>
   </listitem>
  </varlistentry>

 </variablelist>

 <para>
  <command>COPY</command>'s <literal>FORCE_QUOTE</literal> option is
  currently not supported by <literal>file_fdw</literal>.
 </para>

 <para>
  These options can only be specified for a foreign table or its columns, not
  in the options of the <literal>file_fdw</literal> foreign-data wrapper, nor in the
  options of a server or user mapping using the wrapper.
 </para>

 <para>
  Changing table-level options requires being a superuser or having the privileges
  of the role <literal>pg_read_server_files</literal> (to use a filename) or
  the role <literal>pg_execute_server_program</literal> (to use a program),
  for security reasons: only certain users should be able to control which file is
  read or which program is run.  In principle regular users could be allowed to
  change the other options, but that's not supported at present.
 </para>

 <para>
  When specifying the <literal>program</literal> option, keep in mind that the option
  string is executed by the shell.  If you need to pass any arguments to the
  command that come from an untrusted source, you must be careful to strip or
  escape any characters that might have special meaning to the shell.
  For security reasons, it is best to use a fixed command string, or at least
  avoid passing any user input in it.
 </para>

 <para>
  For a foreign table using <literal>file_fdw</literal>, <command>EXPLAIN</command> shows
  the name of the file to be read or program to be run.
  For a file, unless <literal>COSTS OFF</literal> is
  specified, the file size (in bytes) is shown as well.
 </para>

 <example>
  <title>Create a Foreign Table for PostgreSQL CSV Logs</title>

  <para>
   One of the obvious

Title: file_fdw Restrictions, Security and EXPLAIN Behavior
Summary
The FORCE_QUOTE option of COPY is not supported by file_fdw. Options can only be set on foreign tables or their columns, not on the wrapper itself, servers or user mappings. Changing table-level options requires superuser or pg_read_server_files/pg_execute_server_program privileges for security reasons. The program option executes via the shell, so sanitize user-provided arguments. EXPLAIN displays the file or program used by file_fdw and, optionally, the file size.