mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Improve updatability checking for views and foreign tables.
Extend the FDW API (which we already changed for 9.3) so that an FDW can report whether specific foreign tables are insertable/updatable/deletable. The default assumption continues to be that they're updatable if the relevant executor callback function is supplied by the FDW, but finer granularity is now possible. As a test case, add an "updatable" option to contrib/postgres_fdw. This patch also fixes the information_schema views, which previously did not think that foreign tables were ever updatable, and fixes view_is_auto_updatable() so that a view on a foreign table can be auto-updatable. initdb forced due to changes in information_schema views and the functions they rely on. This is a bit unfortunate to do post-beta1, but if we don't change this now then we'll have another API break for FDWs when we do change it. Dean Rasheed, somewhat editorialized on by Tom Lane
This commit is contained in:
@ -254,6 +254,43 @@
|
||||
</para>
|
||||
|
||||
</sect3>
|
||||
|
||||
<sect3>
|
||||
<title>Updatability Options</title>
|
||||
|
||||
<para>
|
||||
By default all foreign tables using <filename>postgres_fdw</> are assumed
|
||||
to be updatable. This may be overridden using the following option:
|
||||
</para>
|
||||
|
||||
<variablelist>
|
||||
|
||||
<varlistentry>
|
||||
<term><literal>updatable</literal></term>
|
||||
<listitem>
|
||||
<para>
|
||||
This option controls whether <filename>postgres_fdw</> allows foreign
|
||||
tables to be modified using <command>INSERT</>, <command>UPDATE</> and
|
||||
<command>DELETE</> commands. It can be specified for a foreign table
|
||||
or a foreign server. A table-level option overrides a server-level
|
||||
option.
|
||||
The default is <literal>true</>.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Of course, if the remote table is not in fact updatable, an error
|
||||
would occur anyway. Use of this option primarily allows the error to
|
||||
be thrown locally without querying the remote server. Note however
|
||||
that the <literal>information_schema</> views will report a
|
||||
<filename>postgres_fdw</> foreign table to be updatable (or not)
|
||||
according to the setting of this option, without any check of the
|
||||
remote server.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
</sect3>
|
||||
</sect2>
|
||||
|
||||
<sect2>
|
||||
|
Reference in New Issue
Block a user