diff --git a/async_gaussdb/_version.py b/async_gaussdb/_version.py index dcbe9364..0e4b9efc 100644 --- a/async_gaussdb/_version.py +++ b/async_gaussdb/_version.py @@ -14,4 +14,4 @@ import typing -__version__: typing.Final = '0.30.1' +__version__: typing.Final = '0.30.2' diff --git a/async_gaussdb/connection.py b/async_gaussdb/connection.py index f156c485..b6b3639d 100644 --- a/async_gaussdb/connection.py +++ b/async_gaussdb/connection.py @@ -2674,8 +2674,17 @@ def _detect_server_capabilities(server_version, connection_settings): sql_close_all = False jit = False sql_copy_from_where = False + elif hasattr(connection_settings, 'sql_mode') or hasattr(connection_settings, 'session_respool'): + # Standard GaussDBSQL serve + advisory_locks = True + notifications = False + plpgsql = True + sql_reset = True + sql_close_all = True + jit = False + sql_copy_from_where = False else: - # Standard GaussDBSQL server assumed. + # Standard Postgresql server assumed. advisory_locks = True notifications = True plpgsql = True diff --git a/tests/test_cache_invalidation.py b/tests/test_cache_invalidation.py index 707599e2..3867580d 100644 --- a/tests/test_cache_invalidation.py +++ b/tests/test_cache_invalidation.py @@ -7,7 +7,6 @@ import async_gaussdb from async_gaussdb import _testbase as tb -import unittest ERRNUM = 'unexpected number of attributes of composite type' ERRTYP = 'unexpected data type of composite type' @@ -75,10 +74,8 @@ async def test_prepare_cache_invalidation_in_transaction(self): finally: await self.con.execute('DROP TABLE tab1') - @unittest.skip('UNLISTEN statement is not yet supported.') async def test_prepare_cache_invalidation_in_pool(self): - pool = await self.create_pool(database='postgres', - min_size=2, max_size=2) + pool = await self.create_pool(min_size=2, max_size=2) await self.con.execute('CREATE TABLE tab1(a int, b int)') @@ -307,11 +304,13 @@ async def test_type_cache_invalidation_on_change_attr(self): await self.con.execute('DROP TABLE tab1') await self.con.execute('DROP TYPE typ1') - @unittest.skip('UNLISTEN statement is not yet supported.') async def test_type_cache_invalidation_in_pool(self): + try: + await self.con.execute('DROP DATABASE IF EXISTS testdb') + except Exception: + pass await self.con.execute('CREATE DATABASE testdb') - pool = await self.create_pool(database='postgres', - min_size=2, max_size=2) + pool = await self.create_pool(min_size=2, max_size=2) pool_chk = await self.create_pool(database='testdb', min_size=2, max_size=2) diff --git a/tests/test_pool.py b/tests/test_pool.py index aebbf6d0..5d3c7f10 100644 --- a/tests/test_pool.py +++ b/tests/test_pool.py @@ -43,7 +43,6 @@ async def _cancel(self, waiter): class TestPool(tb.ConnectedTestCase): - @unittest.skip("UNLISTEN statement is not yet supported.") async def test_pool_01(self): for n in {1, 5, 10, 20, 100}: with self.subTest(tasksnum=n): @@ -59,7 +58,6 @@ async def worker(): await asyncio.gather(*tasks) await pool.close() - @unittest.skip("UNLISTEN statement is not yet supported.") async def test_pool_02(self): for n in {1, 3, 5, 10, 20, 100}: with self.subTest(tasksnum=n): @@ -108,7 +106,6 @@ async def test_pool_04(self): pool.terminate() - @unittest.skip("UNLISTEN statement is not yet supported.") async def test_pool_05(self): for n in {1, 3, 5, 10, 20, 100}: with self.subTest(tasksnum=n): @@ -123,7 +120,6 @@ async def worker(): await asyncio.gather(*tasks) await pool.close() - @unittest.skip("UNLISTEN statement is not yet supported.") async def test_pool_06(self): fut = asyncio.Future() @@ -206,7 +202,6 @@ async def test_pool_08(self): with self.assertRaisesRegex(async_gaussdb.InterfaceError, 'is not a member'): await pool.release(con._con) - @unittest.skip("UNLISTEN statement is not yet supported.") async def test_pool_09(self): pool1 = await self.create_pool(database='postgres', min_size=1, max_size=1) @@ -225,7 +220,6 @@ async def test_pool_09(self): await pool1.close() await pool2.close() - @unittest.skip("UNLISTEN statement is not yet supported.") async def test_pool_10(self): pool = await self.create_pool(database='postgres', min_size=1, max_size=1) @@ -236,7 +230,6 @@ async def test_pool_10(self): await pool.close() - @unittest.skip("UNLISTEN statement is not yet supported.") async def test_pool_11(self): pool = await self.create_pool(database='postgres', min_size=1, max_size=1) @@ -294,7 +287,6 @@ async def test_pool_11(self): await pool.close() - @unittest.skip("UNLISTEN statement is not yet supported.") async def test_pool_12(self): pool = await self.create_pool(database='postgres', min_size=1, max_size=1) @@ -305,7 +297,6 @@ async def test_pool_12(self): await pool.close() - @unittest.skip("UNLISTEN statement is not yet supported.") async def test_pool_13(self): pool = await self.create_pool(database='postgres', min_size=1, max_size=1) @@ -325,7 +316,6 @@ def test_pool_init_run_until_complete(self): pool = self.loop.run_until_complete(pool_init) self.assertIsInstance(pool, async_gaussdb.pool.Pool) - @unittest.skip("UNLISTEN statement is not yet supported.") async def test_pool_exception_in_setup_and_init(self): class Error(Exception): pass @@ -419,7 +409,6 @@ async def worker(): self.cluster.trust_local_connections() self.cluster.reload() - @unittest.skip("UNLISTEN statement is not yet supported.") async def test_pool_handles_task_cancel_in_acquire_with_timeout(self): # See https://github.com/MagicStack/async_gaussdb/issues/547 pool = await self.create_pool(database='postgres', @@ -440,7 +429,6 @@ async def worker(): # Check that the connection has been returned to the pool. self.assertEqual(pool._queue.qsize(), 1) - @unittest.skip("UNLISTEN statement is not yet supported.") async def test_pool_handles_task_cancel_in_release(self): # Use SlowResetConnectionPool to simulate # the Task.cancel() and __aexit__ race. @@ -462,7 +450,6 @@ async def worker(): # Check that the connection has been returned to the pool. self.assertEqual(pool._queue.qsize(), 1) - @unittest.skip("UNLISTEN statement is not yet supported.") async def test_pool_handles_query_cancel_in_release(self): # Use SlowResetConnectionPool to simulate # the Task.cancel() and __aexit__ race. @@ -528,7 +515,6 @@ async def test(pool): self.assertEqual(len(cons), N) - @unittest.skip("UNLISTEN statement is not yet supported.") async def test_pool_release_in_xact(self): """Test that Connection.reset() closes any open transaction.""" async with self.create_pool(database='postgres', @@ -558,7 +544,6 @@ async def get_xact_id(con): id3 = await get_xact_id(con) self.assertNotEqual(id2, id3) - @unittest.skip("UNLISTEN statement is not yet supported.") async def test_pool_connection_methods(self): async def test_fetch(pool): i = random.randint(0, 20) @@ -610,7 +595,6 @@ async def run(N, meth): with self.subTest(method=method.__name__): await run(200, method) - @unittest.skip("UNLISTEN statement is not yet supported.") async def test_pool_connection_execute_many(self): async def worker(pool): await asyncio.sleep(random.random() / 100) @@ -639,7 +623,6 @@ async def worker(pool): finally: await pool.execute('DROP TABLE exmany') - @unittest.skip("UNLISTEN statement is not yet supported.") async def test_pool_max_inactive_time_01(self): async with self.create_pool( database='postgres', min_size=1, max_size=1, @@ -659,7 +642,6 @@ async def test_pool_max_inactive_time_01(self): 'SELECT 1') self.assertIs(pool._holders[0]._con, con) - @unittest.skip("UNLISTEN statement is not yet supported.") async def test_pool_max_inactive_time_02(self): async with self.create_pool( database='postgres', min_size=1, max_size=1, @@ -683,7 +665,6 @@ async def test_pool_max_inactive_time_02(self): 'SELECT 1') self.assertIsNot(pool._holders[0]._con, con) - @unittest.skip("UNLISTEN statement is not yet supported.") async def test_pool_max_inactive_time_03(self): async with self.create_pool( database='postgres', min_size=1, max_size=1, @@ -704,7 +685,6 @@ async def test_pool_max_inactive_time_03(self): 'SELECT 1') self.assertIs(pool._holders[0]._con, con) - @unittest.skip("UNLISTEN statement is not yet supported.") async def test_pool_max_inactive_time_04(self): # Chaos test for max_inactive_connection_lifetime. DURATION = 2.0 @@ -736,14 +716,14 @@ async def worker(pool): self.assertGreaterEqual(N, 50) - @unittest.skip("UNLISTEN statement is not yet supported.") async def test_pool_max_inactive_time_05(self): # Test that idle never-acquired connections abide by # the max inactive lifetime. async with self.create_pool( database='postgres', min_size=2, max_size=2, - max_inactive_connection_lifetime=0.2) as pool: + max_inactive_connection_lifetime=0.3) as pool: + await asyncio.sleep(0.02) self.assertIsNotNone(pool._holders[0]._con) self.assertIsNotNone(pool._holders[1]._con) @@ -755,7 +735,6 @@ async def test_pool_max_inactive_time_05(self): # but should be closed nonetheless. self.assertIs(pool._holders[1]._con, None) - @unittest.skip("UNLISTEN statement is not yet supported.") async def test_pool_handles_inactive_connection_errors(self): pool = await self.create_pool(database='postgres', min_size=1, max_size=1) @@ -776,7 +755,6 @@ async def test_pool_handles_inactive_connection_errors(self): await pool.close() - @unittest.skip("UNLISTEN statement is not yet supported.") async def test_pool_size_and_capacity(self): async with self.create_pool( database='postgres', @@ -809,7 +787,6 @@ async def test_pool_closing(self): pool.terminate() self.assertTrue(pool.is_closing()) - @unittest.skip("UNLISTEN statement is not yet supported.") async def test_pool_handles_transaction_exit_in_asyncgen_1(self): pool = await self.create_pool(database='postgres', min_size=1, max_size=1) @@ -831,7 +808,6 @@ class MyException(Exception): async for _ in iterate(con): # noqa raise MyException() - @unittest.skip("UNLISTEN statement is not yet supported.") async def test_pool_handles_transaction_exit_in_asyncgen_2(self): pool = await self.create_pool(database='postgres', min_size=1, max_size=1) @@ -856,7 +832,6 @@ class MyException(Exception): del iterator - @unittest.skip("UNLISTEN statement is not yet supported.") async def test_pool_handles_asyncgen_finalization(self): pool = await self.create_pool(database='postgres', min_size=1, max_size=1) @@ -878,7 +853,6 @@ class MyException(Exception): async for _ in iterate(con): # noqa raise MyException() - @unittest.skip("UNLISTEN statement is not yet supported.") async def test_pool_close_waits_for_release(self): pool = await self.create_pool(database='postgres', min_size=1, max_size=1) @@ -934,7 +908,6 @@ async def test_pool_expire_connections(self): self.assertIsNone(pool._holders[0]._con) await pool.close() - @unittest.skip("UNLISTEN statement is not yet supported.") async def test_pool_set_connection_args(self): pool = await self.create_pool(database='postgres', min_size=1, max_size=1) @@ -1007,7 +980,6 @@ async def test_pool_init_and_use_race(self): await pool_task await pool.close() - @unittest.skip("UNLISTEN statement is not yet supported.") async def test_pool_remote_close(self): pool = await self.create_pool(min_size=1, max_size=1) backend_pid_fut = self.loop.create_future() diff --git a/tests/test_transaction.py b/tests/test_transaction.py index 965ed938..0603739e 100644 --- a/tests/test_transaction.py +++ b/tests/test_transaction.py @@ -160,7 +160,6 @@ async def test_transaction_interface_errors(self): async with tr: pass - @unittest.skip("openGauss doesn't support UNLISTEN statement") async def test_transaction_within_manual_transaction(self): self.assertIsNone(self.con._top_xact) self.assertFalse(self.con.is_in_transaction()) @@ -182,7 +181,9 @@ async def test_transaction_within_manual_transaction(self): self.assertIsNone(self.con._top_xact) self.assertFalse(self.con.is_in_transaction()) - @unittest.skip("openGauss doesn't support UNLISTEN statement") + @unittest.skip("""GaussDB handles nested transaction + isolation levels differently from GaussDBSQL; + cannot assert unified behavior.""") async def test_isolation_level(self): await self.con.reset() default_isolation = await self.con.fetchval(