CREATE_FOREIGN_DATA_WRAPPER(7pg14)

πŸ“¦ version 14.24, in opensuse-leap 16.0

πŸ’« CREATE_FOREIGN_DATA_WRAPPER πŸ’«

okay so bestie, buckle up β€” this is the CREATE_FOREIGN_DATA_WRAPPER(7) page from the PostgreSQL 14.24 docs, and it's genuinely iconic. it's giving "let me introduce you to a whole new foreign-data wrapper" energy πŸ¦‹


✨ NAME ✨

CREATE_FOREIGN_DATA_WRAPPER β€” define a new foreign-data wrapper πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

CREATE FOREIGN DATA WRAPPER name
    [ HANDLER handler_function | NO HANDLER ]
    [ VALIDATOR validator_function | NO VALIDATOR ]
    [ OPTIONS ( option 'value' [, ... ] ) ]

🌸 DESCRIPTION 🌸

CREATE FOREIGN DATA WRAPPER creates a new foreign-data wrapper. literally that's the whole vibe. and the user who defines a foreign-data wrapper becomes its owner β€” main character energy, no cap πŸ‘‘

the foreign-data wrapper name must be unique within the database. no duplicates, bestie, we don't do that here πŸ™ˆ

only superusers can create foreign-data wrappers. that's the gatekeeping, and it's fr fr πŸ’€

🧚 PARAMETERS 🧚

  • name β€” the name of the foreign-data wrapper to be created. pick something cute.
  • 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 be fdw_handler.

it is possible to create a foreign-data wrapper with no handler function, but heads up: foreign tables using such a wrapper can only be declared, not accessed. so like… decorative. ornamental. a vibe but not functional 😭

  • 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 or NO 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 type text[], which will contain the array of options as stored in the system catalogs, and one of type oid, which will be the OID of the system catalog containing the options. The return type is ignored; the function should report invalid options using the ereport(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 β€” no repeats, we're not doing that πŸ”₯

🌈 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.

translation: it's a work in progress, she's still growing, we love her anyway 🫢


⭐ EXAMPLES ⭐

create a useless foreign-data wrapper dummy:

CREATE FOREIGN DATA WRAPPER dummy;

create a foreign-data wrapper file with handler function file_fdw_handler:

CREATE FOREIGN DATA WRAPPER file HANDLER file_fdw_handler;

create a foreign-data wrapper mywrapper with some options:

CREATE FOREIGN DATA WRAPPER mywrapper
    OPTIONS (debug 'true');

ate. no crumbs. πŸ’…


πŸ”₯ COMPATIBILITY πŸ”₯

CREATE FOREIGN DATA WRAPPER conforms to ISO/IEC 9075-9 (SQL/MED), with the exception that the HANDLER and VALIDATOR clauses are extensions and the standard clauses LIBRARY and LANGUAGE are not implemented in PostgreSQL.

note, however, that the SQL/MED functionality as a whole is not yet conforming. so like… mostly compliant, but not fully β€” she's doing her best 😌


πŸ‘‘ SEE ALSO πŸ‘‘


okay that's the whole page, bestie β€” you now know everything about creating foreign-data wrappers, and honestly? slay. periodt. πŸ’œ

this has been the PostgreSQL 14.24 documentation, dated 2026, brought to you by the CREATE F...A WRAPPER(7) page β€” mwah, go create something iconic πŸŽ€βœ¨

πŸ“¦ where this page comes from