Commit c2b51cf1 authored by Tom Lane's avatar Tom Lane

Improve documentation about usage of FDW validator functions.

SGML documentation, as well as code comments, failed to note that an FDW's
validator will be applied to foreign-table options for foreign tables using
the FDW.

Etsuro Fujita
parent 438df52d
...@@ -91,11 +91,13 @@ ALTER FOREIGN DATA WRAPPER <replaceable class="parameter">name</replaceable> REN ...@@ -91,11 +91,13 @@ ALTER FOREIGN DATA WRAPPER <replaceable class="parameter">name</replaceable> REN
</para> </para>
<para> <para>
Note that it is possible that after changing the validator the Note that it is possible that pre-existing options of the foreign-data
options to the foreign-data wrapper, servers, and user mappings wrapper, or of dependent servers, user mappings, or foreign tables, are
have become invalid. It is up to the user to make sure that invalid according to the new validator. <productname>PostgreSQL</> does
these options are correct before using the foreign-data not check for this. It is up to the user to make sure that these
wrapper. options are correct before using the modified foreign-data wrapper.
However, any options specified in this <command>ALTER FOREIGN DATA
WRAPPER</> command will be checked using the new validator.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
......
...@@ -80,11 +80,11 @@ CREATE FOREIGN DATA WRAPPER <replaceable class="parameter">name</replaceable> ...@@ -80,11 +80,11 @@ CREATE FOREIGN DATA WRAPPER <replaceable class="parameter">name</replaceable>
<varlistentry> <varlistentry>
<term><literal>VALIDATOR <replaceable class="parameter">validator_function</replaceable></literal></term> <term><literal>VALIDATOR <replaceable class="parameter">validator_function</replaceable></literal></term>
<listitem> <listitem>
<para><replaceable class="parameter">validator_function</replaceable> is the <para><replaceable class="parameter">validator_function</replaceable>
name of a previously registered function that will be called to is the name of a previously registered function that will be called to
check the generic options given to the foreign-data wrapper, as check the generic options given to the foreign-data wrapper, as
well as options for foreign servers and user mappings using the well as options for foreign servers, user mappings and foreign tables
foreign-data wrapper. If no validator function or <literal>NO using the foreign-data wrapper. If no validator function or <literal>NO
VALIDATOR</literal> is specified, then options will not be VALIDATOR</literal> is specified, then options will not be
checked at creation time. (Foreign-data wrappers will possibly checked at creation time. (Foreign-data wrappers will possibly
ignore or reject invalid option specifications at run time, ignore or reject invalid option specifications at run time,
......
...@@ -39,7 +39,9 @@ ...@@ -39,7 +39,9 @@
/* /*
* Convert a DefElem list to the text array format that is used in * Convert a DefElem list to the text array format that is used in
* pg_foreign_data_wrapper, pg_foreign_server, and pg_user_mapping. * pg_foreign_data_wrapper, pg_foreign_server, pg_user_mapping, and
* pg_foreign_table.
*
* Returns the array in the form of a Datum, or PointerGetDatum(NULL) * Returns the array in the form of a Datum, or PointerGetDatum(NULL)
* if the list is empty. * if the list is empty.
* *
...@@ -88,7 +90,8 @@ optionListToArray(List *options) ...@@ -88,7 +90,8 @@ optionListToArray(List *options)
* Returns the array in the form of a Datum, or PointerGetDatum(NULL) * Returns the array in the form of a Datum, or PointerGetDatum(NULL)
* if the list is empty. * if the list is empty.
* *
* This is used by CREATE/ALTER of FOREIGN DATA WRAPPER/SERVER/USER MAPPING. * This is used by CREATE/ALTER of FOREIGN DATA WRAPPER/SERVER/USER MAPPING/
* FOREIGN TABLE.
*/ */
Datum Datum
transformGenericOptions(Oid catalogId, transformGenericOptions(Oid catalogId,
...@@ -681,8 +684,9 @@ AlterForeignDataWrapper(AlterFdwStmt *stmt) ...@@ -681,8 +684,9 @@ AlterForeignDataWrapper(AlterFdwStmt *stmt)
repl_repl[Anum_pg_foreign_data_wrapper_fdwvalidator - 1] = true; repl_repl[Anum_pg_foreign_data_wrapper_fdwvalidator - 1] = true;
/* /*
* It could be that the options for the FDW, SERVER and USER MAPPING * It could be that existing options for the FDW or dependent SERVER,
* are no longer valid with the new validator. Warn about this. * USER MAPPING or FOREIGN TABLE objects are no longer valid according
* to the new validator. Warn about this.
*/ */
if (OidIsValid(fdwvalidator)) if (OidIsValid(fdwvalidator))
ereport(WARNING, ereport(WARNING,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment