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.


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




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.


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.


Basic example.

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

See also