Skip to content

Conversation

@jfroche
Copy link
Collaborator

@jfroche jfroche commented Jun 27, 2025

Build multiple versions of the pg_tap extension on different PostgreSQL versions.
Add test for the extensions and their upgrade on PostgreSQL 15 and 17.

Summary by CodeRabbit

  • New Features

    • Added pgtap extension with multi-version packaging (1.2.0, 1.3.1, 1.3.3); per-version artifacts and metadata exposed and the latest version selected by default.
    • Added a package-level alias to install all pgtap versions and improved discoverability of per-version info.
  • Tests

    • pgtap added to the extension test matrix to validate compatibility across supported PostgreSQL majors.

✏️ Tip: You can customize this high-level summary in your review settings.

@jfroche jfroche requested review from a team as code owners June 27, 2025 09:34
Copy link
Contributor

@hunleyd hunleyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rebase to fix conflicts?

@yvan-sraka yvan-sraka force-pushed the multi-version-ext/pg_tap branch from a6eec87 to 927dcdd Compare October 21, 2025 13:09
@yvan-sraka yvan-sraka requested a review from hunleyd October 21, 2025 13:09
@yvan-sraka yvan-sraka self-assigned this Oct 21, 2025
@yvan-sraka yvan-sraka requested a review from samrose October 21, 2025 13:09
@jfroche jfroche force-pushed the multi-version-ext/pg_tap branch from 927dcdd to 8590eec Compare October 27, 2025 09:34
@yvan-sraka yvan-sraka force-pushed the multi-version-ext/pg_tap branch from 8590eec to d4d66ed Compare November 11, 2025 13:27
@jfroche jfroche force-pushed the multi-version-ext/pg_tap branch from d4d66ed to 8590eec Compare November 11, 2025 13:59
@yvan-sraka yvan-sraka force-pushed the multi-version-ext/pg_tap branch from 8590eec to 635b87a Compare November 11, 2025 15:41
@yvan-sraka yvan-sraka force-pushed the multi-version-ext/pg_tap branch 3 times, most recently from 8811cbc to 30c969d Compare November 21, 2025 10:35
@yvan-sraka yvan-sraka force-pushed the multi-version-ext/pg_tap branch from 30c969d to ec034dc Compare December 11, 2025 17:24
Build multiple versions of the pg_tap extension on different PostgreSQL versions.
Add test for the extensions and their upgrade on PostgreSQL 15 and 17.
And run pg_regress tests for pgtap as part of the unified extension tests
@yvan-sraka yvan-sraka force-pushed the multi-version-ext/pg_tap branch from ec034dc to f746eec Compare December 11, 2025 17:25
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 19, 2026

Walkthrough

Convert nix/ext/pgtap.nix from a single-derivation export to a buildEnv-driven multi-version factory that reads nix/ext/versions.json, produces per-version derivations with version-specific fetch/patch/install logic, exposes aggregated paths/pathsToLink and passthru metadata, and add pgtap to extension tests.

Changes

Cohort / File(s) Summary
Multi-version pgtap build factory
nix/ext/pgtap.nix
Replace top-level stdenv.mkDerivation with a buildEnv that reads versions.json, constructs per-version derivations (fetch, optional patch for 1.3.3, special-case 1.3.1 C extension), installs control/SQL/(.so) artifacts per Postgres version, and exposes paths, pathsToLink, and passthru (versions, numberOfVersions, pname-all, multi-version version). Adds buildEnv and fetchpatch2 inputs.
Extension version registry
nix/ext/versions.json
Add pgtap entries: 1.2.0 (postgresql: ["15"], hash), 1.3.1 (postgresql: ["15","17"], hash), 1.3.3 (postgresql: ["15","17"], hash).
Test extension matrix
nix/ext/tests/default.nix
Add pgtap to the public extension list used by tests (appears alongside other extension names such as postgis).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • samrose
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive The description is minimal and vague, lacking the required template structure with sections for motivation, changes, and testing details. Complete the description by selecting and filling out the appropriate template (Default or Extension Upgrade) with detailed motivation, implementation changes, and testing information.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly and concisely summarizes the main change: adding support for multiple versions of the pg_tap extension.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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/pgtap.nix`:
- Around line 66-69: The sed invocation is using an undefined shell variable
`$ext`, so `module_pathname` will be wrong; fix by defining `ext` (e.g., set ext
to the correct shared-object path) before the sed call or replace `$ext` inline
with the correct path expression, and if the package may not build a C
extension, change the logic around `${pname}.control` generation (in the block
that runs sed and touches `${pname}--${version}.control`) to conditionally omit
the `module_pathname` line when `src/pgtap.so` (or the built shared object) does
not exist.
🧹 Nitpick comments (1)
nix/ext/pgtap.nix (1)

86-89: Hardcoded version check for C extension symlink.

The condition "${version}" == "1.3.1" is hardcoded. If a future pgtap version reintroduces a C extension, this logic won't automatically handle it. Consider documenting this decision or making the check more robust (e.g., based on whether the .so file exists and this is not the latest version).

♻️ Alternative approach
-        elif [[ "${version}" == "1.3.1" ]]; then
-          # 1.3.1 is the first and only version with a C extension
-          ln -sfn ${pname}-${version}${postgresql.dlSuffix} $out/lib/${pname}${postgresql.dlSuffix}
+        elif [[ -f src/pgtap.so && "${version}" != "${latestVersion}" ]]; then
+          # Create default symlink for non-latest versions with C extension
+          ln -sfn ${pname}-${version}${postgresql.dlSuffix} $out/lib/${pname}${postgresql.dlSuffix}
         fi

Define the ext variable to point to the correct shared library path
before using it in the sed command that sets module_pathname in the
PostgreSQL extension control file.
… detection

Check for src/pgtap${postgresql.dlSuffix} instead of hardcoded src/pgtap.so
to properly detect the shared library on all platforms (e.g., .dylib on macOS).
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@nix/ext/pgtap.nix`:
- Around line 9-29: Add a guard after computing supportedVersions/versions to
fail with a clear message when no matching entries exist: compute versions as
you do, then compute numberOfVersions (or use builtins.length versions) and use
lib.assert (or an explicit check) to ensure numberOfVersions > 0, failing with a
message that includes the current postgresql.version; this prevents lib.last
(latestVersion) from being called on an empty list and makes the error explicit.
- Around line 66-90: The control-file rewrite currently unconditionally replaces
module_pathname (using ext) which can point to a missing shared library for
SQL-only releases; change the logic so the sed rewrite that sets module_pathname
to $ext only runs when the shared library exists (the same test used for
src/pgtap${postgresql.dlSuffix}), and for SQL-only versions remove the
module_pathname line entirely (or leave it omitted) from the generated
${pname}--${version}.control so CREATE EXTENSION won't reference a non-existent
library.

…name

- Add assertion guard to fail clearly when no supported versions exist
  for the current PostgreSQL version, preventing lib.last on empty list
- Gate module_pathname rewrite on shared library existence: only set
  module_pathname when the shared library exists, remove the line
  entirely for SQL-only versions to prevent CREATE EXTENSION failures
@yvan-sraka yvan-sraka enabled auto-merge January 28, 2026 15:21
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.

5 participants