-
-
Notifications
You must be signed in to change notification settings - Fork 231
feat: support multiple versions of the supautils extension #1921
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
aa1ed62 to
848d4b2
Compare
848d4b2 to
d6ffec1
Compare
📝 WalkthroughWalkthroughReplaces a single-version stdenv build for the supautils extension with a multi-version packaging approach driven by nix/ext/versions.json. Adds per-version fetch-and-build logic that installs versioned shared libraries and per-version PostgreSQL control files, creates a latest-version symlink and default control file, and exposes version metadata via passthru. Adds a Nix integration test exercising PostgreSQL 15→17 migration with systemd orchestration and pg_regress checks, SQL regress tests for 15 and 17, and passthru plumbing for postgres packages. Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@nix/ext/supautils.nix`:
- Around line 41-55: The installPhase currently writes the control file but
fails to install upstream SQL migration scripts, so add steps in installPhase to
copy the extension SQL files (e.g., supautils--*.sql and any
supautils--*.sql.gz) from the build/source directory (likely src/) into
$out/share/postgresql/extension/ alongside the control file; ensure files
include the versioned filenames that match ${pname}--${version}.sql and any
default_version.sql if present, and keep the existing mv of the shared library
and the control file creation intact (refer to installPhase, ${pname},
${version}, and the $out/share/postgresql/extension destination).
🧹 Nitpick comments (1)
nix/ext/tests/supautils.nix (1)
48-61: Avoid double-wrappingpsql_15inpostgresqlWithExtension.
psql_15is already produced bypostgresqlWithExtension(Line 39), so wrapping again at Line 50 is redundant and differs from the PG17 branch. Consider usingpackage = psql_15;for consistency.♻️ Suggested change
- package = (postgresqlWithExtension psql_15); + package = psql_15;
| installPhase = '' | ||
| runHook preInstall | ||
|
|
||
| mkdir -p $out/{lib,share/postgresql/extension} | ||
|
|
||
| # Install shared library with version suffix | ||
| mv ${pname}${postgresql.dlSuffix} $out/lib/${pname}-${version}${postgresql.dlSuffix} | ||
|
|
||
| # Create version-specific control file | ||
| cat <<EOF > $out/share/postgresql/extension/${pname}--${version}.control | ||
| module_pathname = '$libdir/supautils' | ||
| relocatable = false | ||
| EOF | ||
|
|
||
| runHook postInstall |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
# First, explore the file structure to understand the context
find . -type f -name "*.nix" | head -20Repository: supabase/postgres
Length of output: 563
🏁 Script executed:
# Read the full supautils.nix file to understand the build context
wc -l nix/ext/supautils.nixRepository: supabase/postgres
Length of output: 85
🏁 Script executed:
# Check if there are SQL files in the repository
find . -type f -name "*.sql" | grep -i supabaseRepository: supabase/postgres
Length of output: 701
🏁 Script executed:
# Search for upstream source definition in supautils.nix
cat nix/ext/supautils.nixRepository: supabase/postgres
Length of output: 2861
🏁 Script executed:
# Search for any references to supautils SQL or control files in the codebase
rg -i "supautils\.(control|sql)" --type nixRepository: supabase/postgres
Length of output: 43
🏁 Script executed:
# Check if there's any documentation or references about supautils extension structure
rg -i "supautils" --type md | head -20Repository: supabase/postgres
Length of output: 1212
🌐 Web query:
supautils PostgreSQL extension GitHub supabase repository structure SQL files
💡 Result:
supabase/supautils repo — summary (where the PostgreSQL extension SQL lives)
- Repo root: contains README.md, Makefile, META.json, LICENSE and top-level dirs .github/, nix/, src/, test/. [1]
- PostgreSQL extension source (C/SQL and extension metadata) is in the src/ directory — that is where the extension build installs the SQL control/script files used by CREATE EXTENSION. [1]
- Docs / overview (features, install, config keys) are in README.md on the repo front page. [1]
Source:
[1] supabase/supautils (GitHub repository) — repository file listing and README.
🏁 Script executed:
# Check versions.json to understand what versions are being built
cat nix/ext/versions.json | rg -A 5 "supautils"Repository: supabase/postgres
Length of output: 150
🏁 Script executed:
# Look at how other extensions handle SQL files and control files
cat nix/ext/pg_net.nix | head -80Repository: supabase/postgres
Length of output: 2320
🏁 Script executed:
# Check if there are any SQL files mentioned in the extension builds
rg "\.sql" nix/ext/*.nix | head -20Repository: supabase/postgres
Length of output: 1963
🏁 Script executed:
# Let me check the documentation about supautils updates to understand the structure
cat nix/docs/update-extension.mdRepository: supabase/postgres
Length of output: 7041
🏁 Script executed:
# Look at what pg_graphql does since it's also from supabase
head -100 nix/ext/pg_graphql/default.nix | tail -60Repository: supabase/postgres
Length of output: 2423
🏁 Script executed:
# Check if the postBuild in supautils actually handles the versioning correctly
# by looking at the full flow - does it properly create default_version?
sed -n '64,88p' nix/ext/supautils.nixRepository: supabase/postgres
Length of output: 742
🌐 Web query:
site:github.com supabase/supautils repository structure src control.in
💡 Result:
The supabase/supautils repository has a top-level src/ directory, but there is no file named control.in in that repository tree (no matching file found). [1][2]
Sources:
- supabase/supautils repository (shows src/ at top level). [1]
- supabase/supautils — src/ tree view (no control.in file present). [2]
🏁 Script executed:
# Check if there are any comments in the supautils.nix that explain why SQL files aren't copied
grep -B5 -A5 "control file" nix/ext/supautils.nixRepository: supabase/postgres
Length of output: 985
🏁 Script executed:
# Look at how pg_graphql (also a Supabase pgrx extension) handles control files for reference
grep -A10 "postInstall" nix/ext/pg_graphql/default.nix | head -30Repository: supabase/postgres
Length of output: 593
🏁 Script executed:
# Search for any SQL-related patterns in nix files that might indicate what extensions typically need
rg "sql.*\.sql" nix/ext/ --type nix | grep -i "supautils|pg_net|vault" | head -20Repository: supabase/postgres
Length of output: 43
🌐 Web query:
supautils PostgreSQL extension Rust C source code SQL migration files
💡 Result:
You can find the supautils source and SQL files on the project’s GitHub repo:
- Repository (C source under src, Makefile, and SQL/metadata files): https://github.com/supabase/supautils. [1]
Additional package/extension metadata pages:
- Trunk package info for supautils. [2]
- Pigsty package metadata (versions for multiple PG releases). [3]
If you want I can list or show specific files (e.g., src/*.c, extension control/SQL files) from the repo — tell me which files or paths you want.
🏁 Script executed:
# Check if there's a Makefile or build-related file that shows what supautils builds
# Since we can see it's fetched from GitHub, the typical structure would have src files
# Let's check if there's any documentation about what supautils provides
grep -r "supautils" nix/docs/ -A 3 -B 3Repository: supabase/postgres
Length of output: 2153
Install upstream SQL migration files during installPhase.
The current installPhase creates a minimal control file but does not copy SQL migration scripts (e.g., supautils--*.sql files) from the upstream source. Unlike the default_version (which is correctly added in postBuild), missing SQL files will cause CREATE EXTENSION and upgrade operations to fail. Other extensions in this repo (pg_net, vault, pg_graphql, etc.) consistently copy these files. If the upstream supautils repository ships migration scripts in its src/ directory, they must be installed alongside the compiled library.
🤖 Prompt for AI Agents
In `@nix/ext/supautils.nix` around lines 41 - 55, The installPhase currently
writes the control file but fails to install upstream SQL migration scripts, so
add steps in installPhase to copy the extension SQL files (e.g.,
supautils--*.sql and any supautils--*.sql.gz) from the build/source directory
(likely src/) into $out/share/postgresql/extension/ alongside the control file;
ensure files include the versioned filenames that match ${pname}--${version}.sql
and any default_version.sql if present, and keep the existing mv of the shared
library and the control file creation intact (refer to installPhase, ${pname},
${version}, and the $out/share/postgresql/extension destination).
…ompatibility The newer NixOS PostgreSQL service module requires these attributes but our custom PostgreSQL packages weren't providing them, causing CI failures.
e9a6ccc to
ee472c2
Compare
Summary by CodeRabbit
New Features
Tests
Chores