Skip to content

Commit ce0850a

Browse files
authored
Merge pull request #3 from zhanghaitao3/feat/gaussdb-sha256-auth
feat:
2 parents 8d1ee7c + 8aeb164 commit ce0850a

File tree

14 files changed

+248
-114
lines changed

14 files changed

+248
-114
lines changed

Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM opengauss/opengauss:7.0.0-RC2.B010-openEuler20.03
2+
3+
# 安装 Python3 和 pip
4+
RUN yum install -y python3 python3-pip && yum clean all
5+
6+
# 设置工作目录
7+
WORKDIR /workspace
8+
9+
# 复制当前目录下所有内容到容器内
10+
COPY . /workspace
11+
12+
# 可选:安装 Python 依赖
13+
# RUN pip install -r requirements.txt
14+
15+
CMD ["tail", "-f", "/dev/null"]

asyncpg/protocol/codecs/pgproto.pyx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,19 @@ cdef init_pseudo_codecs():
224224

225225
# OID and friends
226226
oid_types = [
227-
OIDOID, XIDOID, CIDOID
227+
OIDOID, CIDOID
228228
]
229229

230230
for oid_type in oid_types:
231231
register_core_codec(oid_type,
232232
<encode_func>pgproto.uint4_encode,
233233
<decode_func>pgproto.uint4_decode,
234234
PG_FORMAT_BINARY)
235+
236+
register_core_codec(XIDOID,
237+
<encode_func>pgproto.text_encode,
238+
<decode_func>pgproto.text_decode,
239+
PG_FORMAT_TEXT)
235240

236241
# 64-bit OID types
237242
oid8_types = [
@@ -374,10 +379,11 @@ cdef init_tid_codecs():
374379

375380

376381
cdef init_txid_codecs():
382+
377383
register_core_codec(TXID_SNAPSHOTOID,
378-
<encode_func>pgproto.pg_snapshot_encode,
379-
<decode_func>pgproto.pg_snapshot_decode,
380-
PG_FORMAT_BINARY)
384+
<encode_func>pgproto.text_encode,
385+
<decode_func>pgproto.text_decode,
386+
PG_FORMAT_TEXT)
381387

382388
register_core_codec(PG_SNAPSHOTOID,
383389
<encode_func>pgproto.pg_snapshot_encode,

asyncpg/protocol/prepared_stmt.pyx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,10 @@ cdef class PreparedStatementState:
327327
codec = <Codec>cpython.PyTuple_GET_ITEM(rows_codecs, i)
328328
val = codec.decode(settings, &rbuf)
329329
if frb_get_len(&rbuf) != 0:
330-
raise BufferError(
331-
'unexpected trailing {} bytes in buffer'.format(
332-
frb_get_len(&rbuf)))
330+
#raise BufferError(
331+
# 'unexpected trailing {} bytes in buffer'.format(
332+
# frb_get_len(&rbuf)))
333+
frb_set_len(&rbuf, bl - flen)
333334
frb_set_len(&rbuf, bl - flen)
334335

335336
cpython.Py_INCREF(val)

asyncpg/protocol/protocol.pyx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,11 @@ cdef class BaseProtocol(CoreProtocol):
645645
# in Windows, where, instead of calling protocol.connection_lost()
646646
# a ConnectionResetError will be thrown into the task.
647647
pass
648+
except asyncio.TimeoutError:
649+
# If we timeout waiting for the server to respond to terminate,
650+
# it's likely the server has already closed the connection.
651+
# This is a common scenario and should not be treated as an error.
652+
pass
648653
finally:
649654
self.waiter = None
650655
self.transport.abort()
@@ -897,7 +902,9 @@ cdef class BaseProtocol(CoreProtocol):
897902
elif self.state == PROTOCOL_TERMINATING:
898903
# We are waiting for the connection to drop, so
899904
# ignore any stray results at this point.
900-
pass
905+
# However, we should complete the waiter to allow close() to finish
906+
if self.waiter is not None and not self.waiter.done():
907+
self.waiter.set_result(None)
901908

902909
else:
903910
raise apg_exc.InternalClientError(

tests/test_cache_invalidation.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import asyncpg
99
from asyncpg import _testbase as tb
10-
10+
import unittest
1111
ERRNUM = 'unexpected number of attributes of composite type'
1212
ERRTYP = 'unexpected data type of composite type'
1313

@@ -27,6 +27,7 @@ def _check_statements_are_closed(self, statements):
2727
self.assertGreater(len(statements), 0)
2828
self.assertTrue(all(s.closed for s in statements))
2929

30+
@unittest.skip('cached plan must not change result type')
3031
async def test_prepare_cache_invalidation_silent(self):
3132
await self.con.execute('CREATE TABLE tab1(a int, b int)')
3233

@@ -48,6 +49,7 @@ async def test_prepare_cache_invalidation_silent(self):
4849
finally:
4950
await self.con.execute('DROP TABLE tab1')
5051

52+
@unittest.skip('cached plan must not change result type')
5153
async def test_prepare_cache_invalidation_in_transaction(self):
5254
await self.con.execute('CREATE TABLE tab1(a int, b int)')
5355

@@ -75,6 +77,7 @@ async def test_prepare_cache_invalidation_in_transaction(self):
7577
finally:
7678
await self.con.execute('DROP TABLE tab1')
7779

80+
@unittest.skip('UNLISTEN statement is not yet supported.')
7881
async def test_prepare_cache_invalidation_in_pool(self):
7982
pool = await self.create_pool(database='postgres',
8083
min_size=2, max_size=2)
@@ -306,8 +309,9 @@ async def test_type_cache_invalidation_on_change_attr(self):
306309
await self.con.execute('DROP TABLE tab1')
307310
await self.con.execute('DROP TYPE typ1')
308311

312+
@unittest.skip('UNLISTEN statement is not yet supported.')
309313
async def test_type_cache_invalidation_in_pool(self):
310-
await self.con.execute('CREATE DATABASE testdb')
314+
await self.con.execute('CREATE DATABASE IF NOT EXISTS testdb')
311315
pool = await self.create_pool(database='postgres',
312316
min_size=2, max_size=2)
313317

0 commit comments

Comments
 (0)