diff --git a/edb/buildmeta.py b/edb/buildmeta.py index 957581cd073..ecaf60186bb 100644 --- a/edb/buildmeta.py +++ b/edb/buildmeta.py @@ -60,7 +60,7 @@ # The merge conflict there is a nice reminder that you probably need # to write a patch in edb/pgsql/patches.py, and then you should preserve # the old value. -EDGEDB_CATALOG_VERSION = 2024_12_04_00_00 +EDGEDB_CATALOG_VERSION = 2024_12_11_00_00 EDGEDB_MAJOR_VERSION = 6 diff --git a/edb/lib/_testmode.edgeql b/edb/lib/_testmode.edgeql index d2d75d8cd22..ebef5bd617d 100644 --- a/edb/lib/_testmode.edgeql +++ b/edb/lib/_testmode.edgeql @@ -289,6 +289,17 @@ sys::_sleep(duration: std::duration) -> std::bool }; +CREATE FUNCTION +sys::_postgres_version() -> std::str +{ + CREATE ANNOTATION std::description := + 'Get the postgres version string'; + USING SQL $$ + SELECT version() + $$; +}; + + CREATE FUNCTION sys::_advisory_lock(key: std::int64) -> std::bool { diff --git a/edb/server/pgcluster.py b/edb/server/pgcluster.py index 393b126bc4a..c863772b107 100644 --- a/edb/server/pgcluster.py +++ b/edb/server/pgcluster.py @@ -333,16 +333,19 @@ async def _copy_database( if self._pg_bin_dir is None: await self.lookup_postgres() pg_dump = self._find_pg_binary('pg_dump') - pg_restore = self._find_pg_binary('pg_restore') + # We actually just use psql to restore, because it is more + # tolerant of version differences. + # TODO: Maybe use pg_restore when we know we match the backend version? + pg_restore = self._find_pg_binary('psql') src_conn_args, src_env = self._dump_restore_conn_args(src_dbname) tgt_conn_args, _tgt_env = self._dump_restore_conn_args(tgt_dbname) dump_args = [ - pg_dump, '--verbose', '--format=c', *src_conn_args, *src_args + pg_dump, '--verbose', *src_conn_args, *src_args ] restore_args = [ - pg_restore, '--verbose', *tgt_conn_args, *tgt_args + pg_restore, *tgt_conn_args, *tgt_args ] rpipe, wpipe = os.pipe() @@ -367,6 +370,8 @@ async def _copy_database( stdin=rpipe, capture_stdout=False, capture_stderr=False, + log_stdout=True, + log_stderr=True, env=src_env, ) finally: diff --git a/edb/testbase/server.py b/edb/testbase/server.py index 87bcff17c84..932140ea8d6 100644 --- a/edb/testbase/server.py +++ b/edb/testbase/server.py @@ -78,6 +78,7 @@ from edb.common import retryloop from edb.common import secretkey +from edb import buildmeta from edb import protocol from edb.protocol import protocol as test_protocol from edb.testbase import serutils @@ -1982,6 +1983,17 @@ def setUpClass(cls): # Run pg_dump to create the dump data for an existing Gel database. with tempfile.NamedTemporaryFile() as f: cls.run_pg_dump_on_connection(conargs, '-f', f.name) + + # Skip the restore part of the test if the database + # backend is older than our pg_dump, since it won't work. + pg_ver_str = cls.loop.run_until_complete( + cls.backend.fetch('select version()') + )[0][0] + pg_ver = buildmeta.parse_pg_version(pg_ver_str) + bundled_ver = buildmeta.get_pg_version() + if pg_ver.major < bundled_ver.major: + raise unittest.SkipTest('pg_dump newer than backend') + # Create a new Postgres database to be used for dump tests. db_exists = cls.loop.run_until_complete( cls.backend.fetch(f''' diff --git a/tests/test_edgeql_extensions.py b/tests/test_edgeql_extensions.py index cceb5ad0b68..841efff4912 100644 --- a/tests/test_edgeql_extensions.py +++ b/tests/test_edgeql_extensions.py @@ -21,6 +21,7 @@ import edgedb +import edb.buildmeta from edb.testbase import server as tb @@ -112,6 +113,13 @@ async def _extension_test_01(self): ''') async def test_edgeql_extensions_01(self): + pg_ver = edb.buildmeta.parse_pg_version(await self.con.query_single(''' + select sys::_postgres_version(); + ''')) + # Skip if postgres is old, since it doesn't have ltree 1.3 + if pg_ver.major < 17: + self.skipTest('Postgres version too old') + # Make an extension that wraps a tiny bit of the ltree package. await self.con.execute(''' create extension package ltree VERSION '1.0' { diff --git a/tests/test_edgeql_sys.py b/tests/test_edgeql_sys.py index 572a00361b0..5d0c590ef1b 100644 --- a/tests/test_edgeql_sys.py +++ b/tests/test_edgeql_sys.py @@ -38,6 +38,11 @@ async def _bad_query_for_stats(self): raise NotImplementedError async def _test_sys_query_stats(self): + if self.backend_dsn: + self.skipTest( + "can't run query stats test when extension isn't present" + ) + stats_query = f''' with stats := ( select