An open source framework to easily build PostgreSQL extensions in Zig, a systems programming language for maintainable and fast code.
Because Zig interacts so effortlessly with C code, it means that you can call any Postgres function.
Make use of the Postgres memory contexts via Zig memory allocators. This means that you get memory safety and protection against leaks.
Pgzx provides a wrapper around standard Postgres error reporting functions making it easier to set up and use from Zig.
Pgzx comes with its own development environment that downloads the Postgres source code and builds the extensions against it. It also supports regression and unit testing.
SPI is a way to run SQL from inside your extension. Pgzx provides access to it also from the Zig extensions.
pgzx provides wrappers for several of the C data structures from the Postgres source code, like lists, linked lists, or hash tables.
Adds a function that counts how many times a particular character shows up in a string. Shows how to register a function and how to interpret the parameters.
# SELECT char_count_zig('Postgres, the best database in the world', 's');
char_count_zig
----------------
4
(1 row)
Inspired by the pgaudit C extension, this one registers callbacks to multiple hooks and uses more advanced error handling and memory allocation patterns.
{
"operation": "CMD_SELECT",
"relations": [
{
"relOid": 24596,
"relname": "foo",
"namespaceOid": 2200,
"relnamespaceName": "public"
},
{
"relOid": 24601,
"relname": "bar",
"namespaceOid": 2200,
"relnamespaceName": "public"
}
],
"commandText": "select * from foo,bar;"
}
By Esther Minano Sanz
• July 17, 2024
Today we’re excited to expand our open source Postgres platform with pgstream, a CDC command line tool and library for PostgreSQL with replication support for DDL changes to any provided output.
By Tudor Golubenco, Steffen Siering
• March 21, 2024
We are excited to introduce pgzx, a framework for creating Postgres extensions using the Zig programming language.
Xata provides the best free plan in the industry. It is production ready by default and doesn't pause or cool-down. Take your time to build your business and upgrade when you're ready to scale.
Copyright © 2024 Xatabase Inc.
All rights reserved.