3
Extensibility of PostgreSQL
Features
functions and programming languages
data types, operators, access methods
foreign data wrappers (FDW)
Mechanisms
modifiable system catalog
API for external handlers
loading and execution of user code
Extensibility is the the core feature of PostgreSQL. It allows to add new
functionality on the fly without changing the server code.
Thus, we can add programming languages and develop functions using
them, define new types of data and operators to work with them, create new
access methods for data types, develop foreign data wrappers to connect to
external sources.
To make this possible, the PostgreSQL system catalog stores a large
amount of information about database objects. This information is not
hardcoded in the server source code. Users can modify the contents of the
system catalog tables, thereby adding new objects and related functionality.
In addition, PostgreSQL source code has a large number of hooks and
various APIs for connecting user functions. This enables the development of
extensions such as pg_stat_statements, auto_explain, pldebugger, and
many others.
The final key mechanism is the ability to load user code into server
processes. For example, we can develop a shared library and incorporate it
during operation.
Note that the execution of poorly written user code by server processes can
lead to catastrophic consequences. Only verified code from reliable sources
should be trusted.