Skip to main content
The VillageSQL Extension Framework (VEF) gives an extension access to the inner workings of the database in a defined way. PostgreSQL has the most mature extension framework of any open-source database, so this page uses it as a point of reference to give you a sense of VEF’s current and planned capabilities. You should read this page as a snapshot, rather than the finished state. VEF changes with each release. Matching PostgreSQL’s hook capabilities exactly is not the goal. MySQL and PostgreSQL are different databases and the needs of their users are often different too.

Capabilities specific to VillageSQL

Some of what VEF offers has nothing to compare against in the tables below, either because MySQL is built differently or because VillageSQL extension authors needed something PostgreSQL does not give its own extensions.
  • Keyring accessvsql::preview::keyring lets an extension read secrets from the server’s keyring.
  • Extension-private file storagevsql::preview::storage gives an extension a managed place on disk. PostgreSQL extensions manage their own files, without a server-side API for it.
  • Alternative protocol handlers#299 would let an extension serve clients over something other than the MySQL wire protocol.
Two further capabilities exist because of how MySQL is built. Binary log write and flush observation (#297) and replication channel observation (#341) both read MySQL’s binary log and its multi-source replication channels. PostgreSQL covers comparable ground through logical decoding on the WAL and its subscription machinery, which is a different design serving a similar purpose.

How to read the tables

Every row that is not marked Available links the GitHub issue where that work is tracked and discussed. Anything marked Available through a preview capability needs vsql_allow_preview_extensions = ON — see Preview Capabilities.

C++ and Rust

You can write a VillageSQL extension in either C++ or Rust. VEF is the server-side capability and each SDK is a binding over it; the Rust bindings are newer, so a few capabilities are reachable from C++ only for now.

Pluggable interfaces

These interfaces, rather than the hooks further down, are what the best-known PostgreSQL extensions are built on. They are also the part of the framework VEF covers most completely, so start here. on_init() and on_deinit() run inside the extension with no access to the server, unlike _PG_init. They suit local setup such as choosing CPU-specific function pointers. Setup that has to talk to the server belongs in a capability’s populate step instead. vsql::preview::sql_query has three limits that affect any extension built around SPI. Statements take no bind parameters, so values have to be escaped by hand (#627). An extension gets a single session rather than concurrent ones (#626). And it cannot be called from inside a VDF (#597).

Hook variables

A hook is a point where the server hands control to an extension mid-statement, letting it read or change what the server is about to do. PostgreSQL declares a fixed set of them as global function pointers; the tables below cover all of them, grouped by the stage of query processing each one fires in.

Parsing and DDL

Planner

Executor

PostgreSQL extensions that need per-operator detail get it by wrapping ExecutorRun_hook at the node level. In VEF that is separate work, tracked in #340.

EXPLAIN

Authentication and security

PostgreSQL extensions use ClientAuthentication_hook for two different jobs, and VEF covers one of them. An extension can implement an authentication method of its own through the vsql::preview::auth capability, which is what vsql-oauth2 is built on. It cannot yet observe the result of authentication it did not handle, which is how PostgreSQL’s auth_delay and failed-login trackers work. That part is #464. PostgreSQL maps external identities to database accounts through pg_ident.conf rather than a hook. The VEF equivalent is #640.

Logging

Startup and shared memory

Function manager

Tell us what you need

We prioritize this work based on what extension authors ask for. If something above is blocking an extension you want to build, add a 👍 to its issue and describe your use case in a comment.