- Start development shell
$ nix develop
- Relocate the postgres installation into our development environment and create a database.
$ pglocal && pginit
- Start the local postgres development server
$ pgstart
- Before you can build the extension you must edit the
build.zig.zon
file and update the hash value. To do so we runzig build
and copy the hash value from the error message into thebuild.zig.zon
file:
$ zig build
Fetch Packages... pgzx... build.zig.zon:13:20: error: url field is missing corresponding hash field
.url = "https://github.com/xataio/pgzx/archive/main.tar.gz",
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: expected .hash = "122097e7141a57b8170ca5288f5514b2b5b27b730a78d2aae7a5f54675ae1614c690",
- Compile and install the extension into the development server
$ zig build -freference-trace -p $PG_HOME
...
$ psql -U postgres -c 'CREATE EXTENSION my_extension'
- Verify extension is working
$ psql -U postgres -c 'SELECT hello()'
- Stop development server
$ pgstop