PostgreSQL Extensions in Go
gopgext is a tool that allows developers to write custom PostgreSQL extensions using plain Go and TinyGo, automatically generating the required C glue and control files.
summary is enough The core concept of writing Postgres extensions in Go via TinyGo is clear from the summary, saving a full read unless you plan to use the tool.
summary
gopgext enables developers to build native PostgreSQL extensions using standard Go code compiled with TinyGo. By using function annotations like //gopgext:function, the tool automatically handles C glue generation, installation scripts, and control files. It supports the Go standard library, complex data types, queries via SPI, triggers, and custom access methods. Created by the author of a similar Linux kernel module project in Go, it provides an alternative to C, Rust, or PL/pgSQL for database extensions.
key points
- Uses TinyGo and function annotations to automatically generate C glue code, install scripts, and control files for PostgreSQL.
- Supports standard Go libraries, custom data types, query execution via SPI, and advanced features like triggers, indexes, and foreign data wrappers.
- Shares its underlying architectural approach with gokm, a sibling project for building Linux kernel modules in Go.
who should read it
PostgreSQL developers and Go engineers interested in database internals and non-traditional extension languages.
discussion positive
consensus
Commenters find the project technically impressive and novel, though many debate whether Go is appropriate for data-plane database tasks compared to C or Rust.
pushback
A minority argues that LLMs make writing native plpgsql easy enough that exotic extension languages are unnecessary.
More people using and extending Postgres is a huge win for the ecosystem, but I am somewhat uncertain of the appeal of Go for this task. It seems to really shine at "platform"-level tasks (e.g. K8s, network proxies, etc. etc.), while Postgres extensions are more at the data plane level.
It raises a valid architectural critique about whether Go's strengths in platform-level tasks translate well to the database data plane.
Generated by an LLM from the article and thread. Check the sources before relying on it.