Skip to content

Split the HTTPS transport into an optional pg_git_https extension - #71

Merged
seanwevans merged 1 commit into
mainfrom
claude/pg-git-upgrade-deps-rk0oxk-https-split
Sep 3, 2026
Merged

seanwevans merged 1 commit into
mainfrom
claude/pg-git-upgrade-deps-rk0oxk-https-split

Conversation

@seanwevans

Copy link
Copy Markdown
Owner

Stacked on #70 — it needs that PR's canonical upgrade-script naming and DATA wiring, without which the 0.4.0 → 0.5.0 script could not be found or installed. Review/merge #70 first; the base is set accordingly.

The problem

pg_git.control listed plpython3u in requires, so CREATE EXTENSION pg_git failed on every managed PostgreSQL. plpython3u is untrusted, needs superuser, and is not offered by RDS, Cloud SQL, Supabase or Neon.

The only thing that needed it was the HTTPS transport in sql/functions/014-https.sql — three objects out of 141.

The fix

CREATE EXTENSION pg_git;        -- core VCS, trusted deps only
CREATE EXTENSION pg_git_https;  -- optional, needs plpython3u

Core pg_git now requires plpgsql, pgcrypto and pg_trgm, all of which managed providers offer.

Why the version bump

Core goes to 0.5.0 because its object set changes; leaving it at 0.4.0 would mean two databases reporting the same version with different contents. pg_git_https starts at 0.1.0.

Preserving stored credentials

sql/pg_git--0.4.0--0.5.0.sql releases pggit.credentials, pggit.store_credentials and pggit.http_fetch from pg_git without dropping them, so encrypted credentials survive; pg_git_https adopts them on install.

Two details worth a reviewer's eye:

  • The companion script adopts before it creates. While an extension script is running, PostgreSQL rejects both CREATE ... IF NOT EXISTS and CREATE OR REPLACE against an object the extension does not already own ("is not a member of extension"). ALTER EXTENSION ... ADD has to come first or the upgrade path does not work at all.
  • The ALTER EXTENSION ... DROP statements are guarded. A database that reaches 0.4.0 through this tree's upgrade chain never had the HTTPS objects; one installed from the released 0.4.0 script did. Both end at the same 0.5.0.

Verification

On PostgreSQL 16, on a cluster with no plpython3u available at all:

Scenario Result
CREATE EXTENSION pg_git CASCADE succeeds, 138 objects, no HTTPS objects present
0.4.0 install with a stored credential → bare ALTER EXTENSION pg_git UPDATE → CREATE EXTENSION pg_git_https all three objects re-owned by pg_git_https, credential still decryptable
fresh CREATE EXTENSION pg_git_https creates the same three objects
DROP EXTENSION pg_git_https core's 138 objects intact
replay 0.1.0 → 0.5.0 vs. fresh 0.5.0 identical object sets

Also updated

meta.json (second provides entry, plpython3u moved to recommends), README.md, sql/README.md, CONTRIBUTING.md, Dockerfile comment, and the two tests that referenced the dependency — https_fetch_test.sql now installs the companion itself, so it stays the only test that needs plpython3u.

🤖 Generated with Claude Code

https://claude.ai/code/session_017nq3xZcPqSTKtskyP2DzkK


Generated by Claude Code

pg_git.control listed plpython3u in requires, so CREATE EXTENSION pg_git
failed on every managed PostgreSQL: plpython3u is untrusted, needs
superuser, and is not offered by RDS, Cloud SQL, Supabase or Neon. The
only thing that needed it was the HTTPS transport in
sql/functions/014-https.sql -- three objects out of 141.

Move those three into a companion extension:

  CREATE EXTENSION pg_git;        -- core VCS, trusted deps only
  CREATE EXTENSION pg_git_https;  -- optional, needs plpython3u

Core pg_git now requires plpgsql, pgcrypto and pg_trgm, all of which
managed providers offer.

Core is bumped to 0.5.0 because its object set changes; leaving it at
0.4.0 would mean two databases reporting the same version with different
contents. sql/pg_git--0.4.0--0.5.0.sql releases pggit.credentials,
pggit.store_credentials and pggit.http_fetch from pg_git without dropping
them, so encrypted credentials survive, and pg_git_https adopts them on
install. Its ALTER EXTENSION ... DROP statements are guarded because a
database that reaches 0.4.0 through this tree's upgrade chain never had
the HTTPS objects, while one installed from the released 0.4.0 script
did; both end at the same 0.5.0.

pg_git_https--0.1.0.sql adopts before it creates. While an extension
script is running PostgreSQL rejects both CREATE ... IF NOT EXISTS and
CREATE OR REPLACE against an object the extension does not already own
("is not a member of extension"), so ALTER EXTENSION ... ADD has to come
first for the upgrade path to work at all.

Verified on PostgreSQL 16 on a cluster with no plpython3u available:
  - CREATE EXTENSION pg_git CASCADE succeeds, 138 objects, no HTTPS
    objects present;
  - a 0.4.0 install with a stored credential upgrades via a bare
    ALTER EXTENSION pg_git UPDATE, and CREATE EXTENSION pg_git_https
    then re-owns all three objects with the credential still decryptable;
  - a fresh CREATE EXTENSION pg_git_https creates the same three objects;
  - DROP EXTENSION pg_git_https leaves core's 138 objects intact;
  - replaying 0.1.0 -> 0.5.0 yields an object set identical to a fresh
    0.5.0 install.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017nq3xZcPqSTKtskyP2DzkK
Base automatically changed from claude/pg-git-upgrade-deps-rk0oxk to main September 3, 2026 23:02
@seanwevans
seanwevans merged commit dd1d8a0 into main Sep 3, 2026
@seanwevans
seanwevans deleted the claude/pg-git-upgrade-deps-rk0oxk-https-split branch September 3, 2026 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants