Skip to content

Commit 680b1ec

Browse files
brainrakeclaude
andcommitted
checks: drop legacyPkgName, resolve extensions from pgpkg.version directly
pgroonga/supautils lookups and the major-version comparisons used a caller-supplied 'legacyPkgName' string, re-parsed back out to derive isSlim and a fallback major version. Stamp the major label onto the package itself via passthru and use it directly. isCliVariant/isSlim become plain boolean params instead of being inferred from a name string. supautils/pgroonga are functionally interchangeable across slim/full builds (same major, no ABI-relevant difference), so both resolve from the matching-major package. getVersionArg's regex-based version detection is dropped since pgpkg.version already is the exact string it was computing. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent e030a88 commit 680b1ec

2 files changed

Lines changed: 27 additions & 63 deletions

File tree

‎nix/checks.nix‎

Lines changed: 24 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@
2727
# deadnix: skip
2828
makeCheckHarness =
2929
pgpkg:
30-
# legacyPkgName: the name used in legacyPackages (e.g., "psql_17" or "psql_17_slim")
3130
{
3231
isCliVariant ? false,
33-
legacyPkgName ? null,
32+
isSlim ? false,
3433
}:
3534
let
3635
pg_prove = pkgs.perlPackages.TAPParserSourceHandlerpgTAP;
@@ -75,43 +74,23 @@
7574
'';
7675
};
7776

78-
# Get the major version for filtering
79-
majorVersion =
80-
let
81-
version = builtins.trace "pgpkg.version is: ${pgpkg.version}" pgpkg.version;
82-
isOrioledbMatch = builtins.match "^17_[0-9]+$" version != null;
83-
isSeventeenMatch = builtins.match "^17[.][0-9]+$" version != null;
84-
result =
85-
if isOrioledbMatch then
86-
"orioledb-17"
87-
else if isSeventeenMatch then
88-
"17"
89-
else
90-
"15";
91-
in
92-
builtins.trace "Major version result: ${result}" result;
93-
94-
# Determine the legacy package name for selecting extensions
95-
effectiveLegacyPkgName = if legacyPkgName != null then legacyPkgName else "psql_${majorVersion}";
96-
97-
# Select the appropriate pgroonga package for this PostgreSQL version
98-
pgroonga = self'.legacyPackages.${effectiveLegacyPkgName}.exts.pgroonga;
77+
pgroonga = self'.legacyPackages."psql_${pgpkg.version}".exts.pgroonga;
78+
supautils = self'.legacyPackages."psql_${pgpkg.version}".exts.supautils;
9979

10080
# Use different ports to allow parallel test runs
10181
# slim packages get their own ports to avoid conflicts
102-
isSlim = lib.hasSuffix "_slim" effectiveLegacyPkgName;
10382
pgPort =
104-
if (majorVersion == "17" && isSlim) then
83+
if (pgpkg.version == "17" && isSlim) then
10584
"5538"
106-
else if (majorVersion == "15" && isSlim) then
85+
else if (pgpkg.version == "15" && isSlim) then
10786
"5539"
108-
else if (majorVersion == "orioledb-17" && isSlim) then
87+
else if (pgpkg.version == "orioledb-17" && isSlim) then
10988
"5540"
110-
else if (majorVersion == "17" && isCliVariant) then
89+
else if (pgpkg.version == "17" && isCliVariant) then
11190
"5541"
112-
else if (majorVersion == "17") then
91+
else if (pgpkg.version == "17") then
11392
"5535"
114-
else if (majorVersion == "15") then
93+
else if (pgpkg.version == "15") then
11594
"5536"
11695
else
11796
"5537";
@@ -134,7 +113,6 @@
134113
"pg_tle"
135114
"plan_filter"
136115
"supabase_vault"
137-
"supautils"
138116
)
139117
140118
# Extract available extensions from receipt
@@ -165,21 +143,6 @@
165143
};
166144
};
167145

168-
getVersionArg =
169-
pkg:
170-
let
171-
name = pkg.version;
172-
in
173-
# Check orioledb first since "17_15" would match "17.*" pattern
174-
if builtins.match "17_[0-9]+" name != null then
175-
"orioledb-17"
176-
else if builtins.match "15.*" name != null then
177-
"15"
178-
else if builtins.match "17.*" name != null then
179-
"17"
180-
else
181-
throw "Unsupported PostgreSQL version: ${name}";
182-
183146
# Tests to skip for OrioleDB (not compatible with OrioleDB storage)
184147
orioledbSkipTests = [
185148
"index_advisor" # index_advisor doesn't support OrioleDB tables
@@ -226,7 +189,7 @@
226189
pkgs.lib.filterAttrs (name: _: isValidFile name) files;
227190

228191
# Filter SQL test files
229-
filteredSqlTests = filterTestFiles majorVersion ./tests/sql;
192+
filteredSqlTests = filterTestFiles pgpkg.version ./tests/sql;
230193

231194
# Tests to skip for CLI variants (require extensions not in CLI)
232195
cliSkipTests = [
@@ -399,8 +362,12 @@
399362
substitute ${./tests/postgresql.conf.in} "$PGTAP_CLUSTER"/postgresql.conf \
400363
--subst-var-by PGSODIUM_GETKEY_SCRIPT "${getkey-script}/bin/pgsodium-getkey" \
401364
--subst-var-by PRELOAD_LIBRARIES "$PRELOAD_LIBRARIES"
402-
echo "listen_addresses = '127.0.0.1'" >> "$PGTAP_CLUSTER"/postgresql.conf
403-
echo "port = ${pgPort}" >> "$PGTAP_CLUSTER"/postgresql.conf
365+
{
366+
echo "listen_addresses = '127.0.0.1'"
367+
echo "port = ${pgPort}"
368+
echo "session_preload_libraries = 'supautils'"
369+
echo "dynamic_library_path = '${supautils}/lib:\$libdir'"
370+
} >> "$PGTAP_CLUSTER"/postgresql.conf
404371
echo "host all all 127.0.0.1/32 trust" >> "$PGTAP_CLUSTER/pg_hba.conf"
405372
log info "Checking shared_preload_libraries setting:"
406373
log info "$(grep -rn "shared_preload_libraries" "$PGTAP_CLUSTER"/postgresql.conf)"
@@ -497,7 +464,7 @@
497464
498465
log info "Starting PostgreSQL server for pg_regress tests"
499466
unset GRN_PLUGINS_DIR
500-
if ! log_cmd ${start-postgres-server-bin}/bin/start-postgres-server ${getVersionArg pgpkg} --daemonize; then
467+
if ! log_cmd ${start-postgres-server-bin}/bin/start-postgres-server ${pgpkg.version} --daemonize; then
501468
log error "Failed to start PostgreSQL server for pg_regress tests"
502469
exit 1
503470
fi
@@ -571,7 +538,7 @@
571538
# running server as pg_regress (--use-existing). These specs target
572539
# core/heap + contrib concurrency behaviour. Skipped on:
573540
# - CLI variants: portable build runs only a test subset.
574-
# - orioledb ships its own isolation suite for its storage-engine
541+
# - orioledb ships its own isolation suite for its storage-engine
575542
# concurrency semantics.
576543
#shellcheck disable=SC2193
577544
if ${lib.boolToString isCliVariant}; then
@@ -610,28 +577,22 @@
610577
in
611578
{
612579
psql_15 = pkgs.runCommand "run-check-harness-psql-15" { } (
613-
lib.getExe (makeCheckHarness self'.packages."psql_15/bin" { legacyPkgName = "psql_15"; })
580+
lib.getExe (makeCheckHarness self'.packages."psql_15/bin" { })
614581
);
615582
psql_17 = pkgs.runCommand "run-check-harness-psql-17" { } (
616-
lib.getExe (makeCheckHarness self'.packages."psql_17/bin" { legacyPkgName = "psql_17"; })
583+
lib.getExe (makeCheckHarness self'.packages."psql_17/bin" { })
617584
);
618585
psql_orioledb-17 = pkgs.runCommand "run-check-harness-psql-orioledb-17" { } (
619-
lib.getExe (
620-
makeCheckHarness self'.packages."psql_orioledb-17/bin" { legacyPkgName = "psql_orioledb-17"; }
621-
)
586+
lib.getExe (makeCheckHarness self'.packages."psql_orioledb-17/bin" { })
622587
);
623588
psql_15_slim = pkgs.runCommand "run-check-harness-psql-15-slim" { } (
624-
lib.getExe (makeCheckHarness self'.packages."psql_15_slim/bin" { legacyPkgName = "psql_15_slim"; })
589+
lib.getExe (makeCheckHarness self'.packages."psql_15_slim/bin" { isSlim = true; })
625590
);
626591
psql_17_slim = pkgs.runCommand "run-check-harness-psql-17-slim" { } (
627-
lib.getExe (makeCheckHarness self'.packages."psql_17_slim/bin" { legacyPkgName = "psql_17_slim"; })
592+
lib.getExe (makeCheckHarness self'.packages."psql_17_slim/bin" { isSlim = true; })
628593
);
629594
psql_orioledb-17_slim = pkgs.runCommand "run-check-harness-psql-orioledb-17-slim" { } (
630-
lib.getExe (
631-
makeCheckHarness self'.packages."psql_orioledb-17_slim/bin" {
632-
legacyPkgName = "psql_orioledb-17_slim";
633-
}
634-
)
595+
lib.getExe (makeCheckHarness self'.packages."psql_orioledb-17_slim/bin" { isSlim = true; })
635596
);
636597
# CLI variant checks
637598
psql_17_cli = pkgs.runCommand "run-check-harness-psql-17-cli" { } (

‎nix/packages/postgres.nix‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@
206206
(makeReceipt pgbin ourExts)
207207
]
208208
++ extraPaths;
209+
passthru = {
210+
inherit version;
211+
};
209212
};
210213

211214
# Create an attribute set, containing all the relevant packages for a

0 commit comments

Comments
 (0)