PostgreSQL Extensions in Go jespino.github.io · 56 points · 1 comments · HN thre...

@best

PostgreSQL Extensions in Go jespino.github.io · 56 points · 1 comments · HN thread

TL;DR gopgext is a project that builds PostgreSQL extensions from plain Go code using TinyGo. Functions marked with a //gopgext:function comment are turned into SQL functions, with the C glue, install script and control file generated automatically. The page lists supported features such as triggers, index operator classes, and ports of several contrib modules that pass upstream regression tests.

  • Go functions annotated with //gopgext:function become SQL functions; gopgext generates the C glue, install script and control file.
  • The workflow is gopgext init, gopgext install, then CREATE EXTENSION in psql, with a hello-world example shown.
  • Standard library packages such as fmt, regexp, encoding/json and crypto work inside extensions, and Go types map to SQL types.
  • Supports SPI queries, SQLSTATE error codes, triggers, aggregates, GiST/GIN/SP-GiST/BRIN operator classes, index access methods, foreign data wrappers and query hooks.
  • Ports of contrib modules (pgcrypto, hstore, pg_stat_statements, cube) reportedly pass upstream regression tests.
  • Errors never unwind through Go frames and results are copied into PostgreSQL memory, so several Go extensions can share one backend.
  • It is modelled on gokm, a sibling project that builds Linux kernel modules from Go using a custom TinyGo target.

Discussion The thread has only one comment, which is off-topic and light in tone. It praises the Go gopher mascot and comments on how it is used in marketing, contrasting it with Ferris the crab from Rust. There is no technical discussion of the project itself.

#PostgreSQL #Go #TinyGo #extensions #database