Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion async_gaussdb/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

import typing

__version__: typing.Final = '0.30.1'
__version__: typing.Final = '0.30.2'
11 changes: 10 additions & 1 deletion async_gaussdb/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 6 additions & 7 deletions tests/test_cache_invalidation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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)')

Expand Down Expand Up @@ -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)
Expand Down
32 changes: 2 additions & 30 deletions tests/test_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down Expand Up @@ -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):
Expand All @@ -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()

Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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',
Expand All @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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)

Expand All @@ -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)
Expand All @@ -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',
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down
5 changes: 3 additions & 2 deletions tests/test_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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(
Expand Down