Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ make # Build extension (generates versioned SQL, docs)
make test # Full test: testdeps → install → installcheck → show diffs
make results # Run tests and update expected output files
make html # Generate HTML from Asciidoc sources
make tag # Create git branch for current META.json version
make tag # Create git tag for current META.json version
make dist # Create PGXN .zip (auto-tags, places in ../)
make pgtle # Generate pg_tle registration SQL (see pg_tle Support below)
make check-pgtle # Check pg_tle installation and report version
make install-pgtle # Install pg_tle registration SQL files into database
make run-pgtle # Register extensions with pg_tle in the database
make pgxntool-sync # Update to latest pgxntool via git subtree pull
```

Expand Down Expand Up @@ -204,7 +204,7 @@ When tests fail, examine the diff output carefully. The actual test output in `t

### Distribution Packaging
- `make dist` creates `../PGXN-VERSION.zip`
- Always creates git branch tag matching version
- Always creates git tag matching version
- Uses `git archive` to package
- Validates repo is clean before tagging

Expand All @@ -227,16 +227,16 @@ pgxntool can generate pg_tle (Trusted Language Extensions) registration SQL for

**Installation targets:**

- `make check-pgtle` - Checks if pg_tle is installed and reports the version. Reports version from `pg_extension` if extension has been created, or newest available version from `pg_available_extension_versions` if available but not created. Errors if pg_tle not available in cluster. Assumes `PG*` environment variables are configured.
- `make check-pgtle` - Checks if pg_tle is installed and reports the version. Reports the version from `pg_extension` if `CREATE EXTENSION pg_tle` has been run in the database. Errors if pg_tle is not available in the cluster. Assumes `PG*` environment variables are configured.

- `make install-pgtle` - Auto-detects pg_tle version and installs appropriate registration SQL files. Updates or creates pg_tle extension as needed. Determines which version range files to install based on detected version. Runs all generated SQL files via `psql` to register extensions with pg_tle. Assumes `PG*` environment variables are configured.
- `make run-pgtle` - Registers all extensions with pg_tle by executing the generated pg_tle registration SQL files. Requires pg_tle to already be installed in the target database (`CREATE EXTENSION pg_tle;`) -- it does not create the extension itself, and errors out telling you to run `make check-pgtle` if it's missing. Depends on `pgtle`, so it generates the SQL files first if needed. Assumes `PG*` environment variables are configured.

**Version notation:**
- `X.Y.Z+` means >= X.Y.Z
- `X.Y.Z-A.B.C` means >= X.Y.Z and < A.B.C (note boundary)

**Key implementation details:**
- Script: `pgxntool/pgtle-wrap.sh` (bash)
- Script: `pgxntool/pgtle.sh` (bash)
- Parses `.control` files for metadata (NOT META.json)
- Fixed delimiter: `$_pgtle_wrap_delimiter_$` (validated not in source)
- Each output file contains ALL versions and ALL upgrade paths
Expand Down
25 changes: 18 additions & 7 deletions README.asc
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ PGXNtool is meant to make developing new Postgres extensions for http://pgxn.org

Currently, it consists a base Makefile that you can include instead of writing your own, a template `META.in.json` (from which `META.json` is generated — you edit the former, never the latter directly), and some test framework. More features will be added over time.

If you find any bugs or have ideas for improvements, please https://github.com/decibel/pgxntool/issues[*open an issue*].
If you find any bugs or have ideas for improvements, please https://github.com/Postgres-Extensions/pgxntool/issues[*open an issue*].

== Install
This assumes that you've already initialized your extension in git.

NOTE: The `--squash` is important! Otherwise you'll clutter your repo with a bunch of commits you probably don't want.

----
git subtree add -P pgxntool --squash git@github.com:decibel/pgxntool.git release
git subtree add -P pgxntool --squash git@github.com:Postgres-Extensions/pgxntool.git release
pgxntool/setup.sh
----

Expand Down Expand Up @@ -213,7 +213,7 @@ check_control:
grep -q "requires = 'pgtap, test_factory'" test_factory_pgtap.control
----

If you want to over-ride the default dependency on `pgtap` you should be able to do that with a makefile override. If you need help with that, please https://github.com/decibel/pgxntool/issues[open an issue].
If you want to over-ride the default dependency on `pgtap` you should be able to do that with a makefile override. If you need help with that, please https://github.com/Postgres-Extensions/pgxntool/issues[open an issue].

WARNING: It will probably cause problems if you try to create a `testdeps` rule that has a recipe. Instead of doing that, put the recipe in a separate rule and make that rule a prerequisite of `testdeps` as show in the example.

Expand Down Expand Up @@ -258,7 +258,7 @@ make PGXNTOOL_ENABLE_VERIFY_RESULTS=no results

If a tag for the current version already exists and points at your current commit, `make tag` does nothing — this makes it safe for other targets (like `dist`) to depend on `tag` without worrying about re-running it. If the existing tag points at a *different* commit — meaning you likely forgot to bump the version — you'll get an error. If you're certain you want to over-write the tag, you can do `make forcetag`, which removes the existing tag (via `make rmtag`) and creates a new one.

WARNING: You will be very unhappy if you forget to update the .control file for your extension! There is an https://github.com/decibel/pgxntool/issues/1[open issue] to improve this.
WARNING: You will be very unhappy if you forget to update the .control file for your extension! There is an https://github.com/Postgres-Extensions/pgxntool/issues/1[open issue] to improve this.

=== dist
`make dist` will create a .zip file for your current version that you can upload to PGXN. It first runs `tag` (creating/pushing the version's git tag as described above if needed), then uses `git archive` at that tag to build the .zip file, so the archive always matches the exact tagged commit. The file is named after the PGXN name and version (the top-level "name" and "version" attributes in META.json, generated from `META.in.json`). The .zip file is placed in the *parent* directory so as not to clutter up your git repo.
Expand All @@ -278,6 +278,8 @@ NOTE: `git subtree pull` copies pgxntool's entire tree into your project, includ

TIP: The actual work is done by `pgxntool/pgxntool-sync.sh`, so you can run it directly (`pgxntool/pgxntool-sync.sh`) if you'd rather not go through `make`. It optionally takes `<repo>` and `<ref>` arguments to pull from somewhere other than the default.

TIP: `pgxntool-sync.sh` itself delegates the 3-way merge of `setup.sh`-copied files to `pgxntool/update-setup-files.sh <old-pgxntool-commit>`, which you can also run directly -- for example, to redo or debug just the merge step without pulling again. `<old-pgxntool-commit>` is the pgxntool subtree commit that was current *before* the sync you want to re-merge.

TIP: There is also a `pgxntool-sync-%` rule if you need to do more advanced things. `make pgxntool-sync-<name>` pulls from the `<repo> <ref>` defined by the `pgxntool-sync-<name>` make variable.

=== pgxntool-version
Expand Down Expand Up @@ -306,6 +308,12 @@ Generates pg_tle (Trusted Language Extensions) registration SQL files for deploy

`make pgtle` generates SQL files in `pg_tle/` subdirectories organized by pg_tle version ranges. For version range details, see `pgtle_versions.md`.

Set `PGTLE_VERSION` on the command line to limit generation to the single version range that value falls into, instead of every known range:

----
make pgtle PGTLE_VERSION=1.5.0
----

=== check-pgtle
Checks if pg_tle is installed and reports the version. This target:
- Reports the version from `pg_extension` if `CREATE EXTENSION pg_tle` has been run in the database
Expand Down Expand Up @@ -406,8 +414,7 @@ Because it's only ever transiently present, the correct cleanup is a single `rm

----
$(EXTENSION_ext_VERSION_FILE): sql/ext.sql extension.control
@echo '/* DO NOT EDIT - AUTO-GENERATED FILE */' > $(EXTENSION_ext_VERSION_FILE)
@cat sql/ext.sql >> $(EXTENSION_ext_VERSION_FILE)
@(echo '/* DO NOT EDIT - AUTO-GENERATED FILE */'; cat sql/ext.sql) > $(EXTENSION_ext_VERSION_FILE)
----

That rule only ever targets the file matching the extension's *current* `default_version`, so editing the base `sql/{extension}.sql` and running `make` is the correct, safe way to change that one file.
Expand Down Expand Up @@ -658,6 +665,10 @@ make dist PGXN_REMOTE=upstream

Default: auto-detected, the first of `asciidoctor` or `asciidoc` found on `PATH`. Path to the Asciidoc processor used to build `.html` files from `$(ASCIIDOC_EXTS)` source files. Override if the processor you want isn't first on `PATH`, or isn't on `PATH` at all. See <<_document_handling>>.

=== PGTLE_VERSION

Default: unset (generates every known pg_tle version range). Set on the command line to limit `make pgtle` to the single version range this value falls into. See <<_pgtle>>.

=== PG_CONFIG

Default: `pg_config`. Path to the `pg_config` binary used to detect the PostgreSQL version and locate PGXS. Override when the right `pg_config` isn't the one on `PATH`, such as when testing against a specific PostgreSQL install.
Expand Down Expand Up @@ -711,4 +722,4 @@ Default: unset (PGXS is included normally). Skips including PGXS (`$(PGXS)`) ent
== Copyright
Copyright (c) 2026 Jim Nasby <Jim.Nasby@gmail.com>

PGXNtool is released under a https://github.com/decibel/pgxntool/blob/master/LICENCE[BSD license]. Note that it includes https://github.com/dominictarr/JSON.sh[JSON.sh], which is released under a https://github.com/decibel/pgxntool/blob/master/JSON.sh.LICENCE[MIT license].
PGXNtool is released under a https://github.com/Postgres-Extensions/pgxntool/blob/master/LICENSE[BSD license]. Note that it includes https://github.com/dominictarr/JSON.sh[JSON.sh], which is released under a https://github.com/Postgres-Extensions/pgxntool/blob/master/JSON.sh.LICENSE[MIT license].
Loading
Loading