CREATE FOREIGN DATA WRAPPER

Synopsis

Use the CREATE FOREIGN DATA WRAPPER statement to create a foreign data wrapper. Only superusers or users with the yb_fdw role can create foreign data wrappers.

Syntax

create_foreign_data_wrapper ::= CREATE FOREIGN DATA WRAPPER fdw_name  
                                [ HANDLER handler_name | NO HANDLER ] 
                                [ VALIDATOR validator_name
                                  | NO VALIDATOR ] 
                                [ OPTIONS ( fdw_options ) ]

create_foreign_data_wrapper

CREATEFOREIGNDATAWRAPPERfdw_nameHANDLERhandler_nameNOHANDLERVALIDATORvalidator_nameNOVALIDATOROPTIONS(fdw_options)

Semantics

Create a FDW named fdw_name.

Handler function

The handler_function will be called to retrieve the execution functions for foreign tables. These functions are required by the planner and executor. The handler function takes no arguments and its return type should be fdw_handler. If no handler function is provided, foreign tables that use the wrapper can only be declared (and not accessed).

Validator function

The validator_function is used to validate the options given to the foreign-data wrapper, and the foreign servers, user mappings and foreign tables that use the foreign-data wrapper. The validator function takes two arguments: a text array (type text[]) that contains the options to be validated, and an OID of the system catalog that the object associated with the options is stored in. If no validator function is provided (or NO VALIDATOR is specified), the options will not be checked at the time of creation.

Options:

The OPTIONS clause specifies options for the foreign-data wrapper. The permitted option names and values are specific to each foreign data wrapper. The options are validated using the FDW’s validator function.

Examples

Basic example.

yugabyte=# CREATE FOREIGN DATA WRAPPER my_wrapper HANDLER myhandler OPTIONS (dummy 'true');

See also