Skip to content

Commit e2f61b1

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 4615b6c commit e2f61b1

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
@@ -179,13 +179,25 @@ let
179179
with subtest("Check pg_regress with postgresql 15 after installing the last version"):
180180
test.check_pg_regress(Path("${psql_15}/lib/pgxs/src/test/regress/pg_regress"), "15", pg_regress_test_name)
181181
182+
has_update_script = False
182183
with subtest("switch to postgresql 17"):
183184
server.succeed(
184185
f"{pg17_configuration}/bin/switch-to-configuration test >&2"
185186
)
187+
has_update_script = server.succeed(
188+
"test -f /var/lib/postgresql/update_extensions.sql && echo 'yes' || echo 'no'"
189+
).strip() == "yes"
190+
if has_update_script:
191+
# Run the extension update script generated during the upgrade
192+
test.run_sql_file("/var/lib/postgresql/update_extensions.sql")
186193
187194
with subtest("Check last version of the extension after postgresql upgrade"):
188-
test.assert_version_matches(last_version)
195+
if has_update_script:
196+
# If there was an update script, the last version should be installed
197+
test.assert_version_matches(versions["17"][-1])
198+
else:
199+
# Otherwise, the version should match the last version from postgresql 15
200+
test.assert_version_matches(last_version)
189201
190202
with subtest("Check upgrade path with postgresql 17"):
191203
test.check_upgrade_path("17")

0 commit comments

Comments
 (0)