Repository navigation
Split the HTTPS transport into an optional pg_git_https extension - #71
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem
pg_git.controllistedplpython3uinrequires, soCREATE EXTENSION pg_gitfailed on every managed PostgreSQL.plpython3uis 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
Core
pg_gitnow requiresplpgsql,pgcryptoandpg_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_httpsstarts at 0.1.0.Preserving stored credentials
sql/pg_git--0.4.0--0.5.0.sqlreleasespggit.credentials,pggit.store_credentialsandpggit.http_fetchfrompg_gitwithout dropping them, so encrypted credentials survive;pg_git_httpsadopts them on install.Two details worth a reviewer's eye:
CREATE ... IF NOT EXISTSandCREATE OR REPLACEagainst an object the extension does not already own ("is not a member of extension").ALTER EXTENSION ... ADDhas to come first or the upgrade path does not work at all.ALTER EXTENSION ... DROPstatements 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
plpython3uavailable at all:CREATE EXTENSION pg_git CASCADEALTER EXTENSION pg_git UPDATE→CREATE EXTENSION pg_git_httpspg_git_https, credential still decryptableCREATE EXTENSION pg_git_httpsDROP EXTENSION pg_git_httpsAlso updated
meta.json(secondprovidesentry,plpython3umoved torecommends),README.md,sql/README.md,CONTRIBUTING.md,Dockerfilecomment, and the two tests that referenced the dependency —https_fetch_test.sqlnow installs the companion itself, so it stays the only test that needsplpython3u.🤖 Generated with Claude Code
https://claude.ai/code/session_017nq3xZcPqSTKtskyP2DzkK
Generated by Claude Code