Skip to content

Commit ddd2e0a

Browse files
jfrocheyvan-sraka
authored andcommitted
fix(exts): handle pg_upgrade generated update_extensions.sql script in the extension tests
pg_upgrade may generate an update_extensions.sql script to update extensions after a major version upgrade. This commit modifies the extension tests to check for the presence of this script after upgrading PostgreSQL to version 17. If the script exists, it is executed to ensure that the extensions are updated correctly.
1 parent 3df6c4a commit ddd2e0a

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

nix/ext/tests/default.nix

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,25 @@ let
188188
with subtest("Check pg_regress with postgresql 15 after installing the last version"):
189189
test.check_pg_regress(Path("${psql_15}/lib/pgxs/src/test/regress/pg_regress"), "15", pg_regress_test_name)
190190
191+
has_update_script = False
191192
with subtest("switch to postgresql 17"):
192193
server.succeed(
193194
f"{pg17_configuration}/bin/switch-to-configuration test >&2"
194195
)
196+
has_update_script = server.succeed(
197+
"test -f /var/lib/postgresql/update_extensions.sql && echo 'yes' || echo 'no'"
198+
).strip() == "yes"
199+
if has_update_script:
200+
# Run the extension update script generated during the upgrade
201+
test.run_sql_file("/var/lib/postgresql/update_extensions.sql")
195202
196203
with subtest("Check last version of the extension after postgresql upgrade"):
197-
test.assert_version_matches(last_version)
204+
if has_update_script:
205+
# If there was an update script, the last version should be installed
206+
test.assert_version_matches(versions["17"][-1])
207+
else:
208+
# Otherwise, the version should match the last version from postgresql 15
209+
test.assert_version_matches(last_version)
198210
199211
with subtest("Check upgrade path with postgresql 17"):
200212
test.check_upgrade_path("17")

0 commit comments

Comments
 (0)