CREATE FOREIGN DATA WRAPPER
CREATE FOREIGN DATA WRAPPER — define a new foreign-data wrapper
Synopsis
Description
CREATE FOREIGN DATA WRAPPER
creates a new foreign-data wrapper. The user who defines a foreign-data wrapper becomes its owner.
The foreign-data wrapper name must be unique within the database.
Only superusers can create foreign-data wrappers.
Parameters
name
The name of the foreign-data wrapper to be created.
HANDLER
handler_function
_handler_function
_is the name of a previously registered function that will be called to retrieve the execution functions for foreign tables. The handler function must take no arguments, and its return type must befdw_handler
.
It is possible to create a foreign-data wrapper with no handler function, but foreign tables using such a wrapper can only be declared, not accessed.
VALIDATOR
validator_function
_validator_function
_is the name of a previously registered function that will be called to check the generic options given to the foreign-data wrapper, as well as options for foreign servers, user mappings and foreign tables using the foreign-data wrapper. If no validator function orNO VALIDATOR
is specified, then options will not be checked at creation time. (Foreign-data wrappers will possibly ignore or reject invalid option specifications at run time, depending on the implementation.) The validator function must take two arguments: one of typetext[]
, which will contain the array of options as stored in the system catalogs, and one of typeoid
, which will be the OID of the system catalog containing the options. The return type is ignored; the function should report invalid options using theereport(ERROR)
function.
OPTIONS (
option
'
value
' [, ... ] )
This clause specifies options for the new foreign-data wrapper. The allowed option names and values are specific to each foreign data wrapper and are validated using the foreign-data wrapper's validator function. Option names must be unique.
Notes
PostgreSQL's foreign-data functionality is still under active development. Optimization of queries is primitive (and mostly left to the wrapper, too). Thus, there is considerable room for future performance improvements.
Examples
Create a useless foreign-data wrapperdummy
:
Create a foreign-data wrapperfile
with handler functionfile_fdw_handler
:
Create a foreign-data wrappermywrapper
with some options:
Compatibility
CREATE FOREIGN DATA WRAPPER
conforms to ISO/IEC 9075-9 (SQL/MED), with the exception that theHANDLER
andVALIDATOR
clauses are extensions and the standard clausesLIBRARY
andLANGUAGE
are not implemented inPostgreSQL.
Note, however, that the SQL/MED functionality as a whole is not yet conforming.
See Also
,
,
,
,
Last updated