Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
d4d0cd5
release modify
zhanghaitao3 Aug 10, 2025
3212af7
release modify
zhanghaitao3 Aug 10, 2025
eea28b0
release modify
zhanghaitao3 Aug 10, 2025
b600871
release modify
zhanghaitao3 Aug 10, 2025
0fd5e6d
release modify
zhanghaitao3 Aug 10, 2025
1a043d3
release modify
zhanghaitao3 Aug 10, 2025
b8245a2
release modify
zhanghaitao3 Aug 10, 2025
64584b4
release modify
zhanghaitao3 Aug 10, 2025
0f7ef59
release modify
zhanghaitao3 Aug 10, 2025
d364aea
release modify
zhanghaitao3 Aug 10, 2025
70d908b
release modify
zhanghaitao3 Aug 10, 2025
ae9a06c
release modify
zhanghaitao3 Aug 10, 2025
3fe222c
release modify
zhanghaitao3 Aug 11, 2025
6630ca3
release modify
zhanghaitao3 Aug 11, 2025
8b8416a
release modify
zhanghaitao3 Aug 11, 2025
34f1051
release modify
zhanghaitao3 Aug 11, 2025
3a3510f
release modify
zhanghaitao3 Aug 11, 2025
13de81e
release modify
zhanghaitao3 Aug 11, 2025
0dd1928
release modify
zhanghaitao3 Aug 11, 2025
9bc371f
release modify
zhanghaitao3 Aug 11, 2025
22ae929
release modify
zhanghaitao3 Aug 11, 2025
5332623
release modify
zhanghaitao3 Aug 11, 2025
976a5f7
release modify
zhanghaitao3 Aug 11, 2025
a55d9e7
release modify
zhanghaitao3 Aug 11, 2025
306fc07
release modify
zhanghaitao3 Aug 11, 2025
eab851b
release modify
zhanghaitao3 Aug 11, 2025
c7359c4
release modify
zhanghaitao3 Aug 11, 2025
d3c7862
release modify
zhanghaitao3 Aug 11, 2025
e1df6ec
release modify
zhanghaitao3 Aug 11, 2025
9801d3b
release modify
zhanghaitao3 Aug 11, 2025
b6ebd9e
release modify
zhanghaitao3 Aug 11, 2025
0f67206
release modify
zhanghaitao3 Aug 11, 2025
254027d
release modify
zhanghaitao3 Aug 11, 2025
ee7ee00
release modify
zhanghaitao3 Aug 11, 2025
01f32c1
release modify
zhanghaitao3 Aug 11, 2025
13e6176
release modify
zhanghaitao3 Aug 11, 2025
b21b4f2
release modify
zhanghaitao3 Aug 11, 2025
f0a1d15
release modify
zhanghaitao3 Aug 11, 2025
782d727
release modify
zhanghaitao3 Aug 11, 2025
0482d20
release modify
zhanghaitao3 Aug 11, 2025
c6ea39a
release modify
zhanghaitao3 Aug 11, 2025
44cd306
release modify
zhanghaitao3 Aug 11, 2025
3f22ae3
release modify
zhanghaitao3 Aug 11, 2025
73ecbbe
release modify
zhanghaitao3 Aug 11, 2025
cfd8138
release modify
zhanghaitao3 Aug 11, 2025
3663ff0
Fix multiple test failures
zhanghaitao3 Nov 24, 2025
fc75b7c
Merge branch 'master' of https://github.com/zhanghaitao3/gaussdb-pyth…
zhanghaitao3 Nov 24, 2025
3cde240
Fix test cases for GaussDB under Oracle compatibility mode
zhanghaitao3 Nov 25, 2025
122411d
Fix github test workflows
zhanghaitao3 Nov 25, 2025
161e685
Fix Gaussdb enable_extension!=true
zhanghaitao3 Nov 25, 2025
2ad6852
Fix COPY OUT race conditions and state corruption (Python 3.9.9 speci…
zhanghaitao3 Nov 25, 2025
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
128 changes: 35 additions & 93 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ on:
tags:
- "*"

permissions:
contents: write

jobs:
build-sdist:
runs-on: ubuntu-latest
Expand All @@ -31,9 +28,10 @@ jobs:
pip install -U setuptools wheel pip
python setup.py sdist

- uses: actions/upload-artifact@v4
- name: Upload sdist artifact
uses: actions/upload-artifact@v4
with:
name: dist-sdist
name: dist-sdist
path: dist/*.tar.*

build-wheels-matrix:
Expand Down Expand Up @@ -90,121 +88,65 @@ jobs:
env:
CIBW_BUILD_VERBOSITY: 1

- uses: actions/upload-artifact@v4
- name: Upload wheel artifacts
uses: actions/upload-artifact@v4
with:
name: dist-wheels-${{ matrix.only }}
path: wheelhouse/*.whl

merge-artifacts:
runs-on: ubuntu-latest
needs: [build-sdist, build-wheels]
steps:
- name: Merge Artifacts
uses: actions/upload-artifact/merge@v4
with:
name: dist
delete-merged: true

publish-docs:
needs: [build-sdist, build-wheels]
runs-on: ubuntu-latest

env:
PIP_DISABLE_PIP_VERSION_CHECK: 1

steps:
- name: Checkout source
uses: actions/checkout@v4
with:
fetch-depth: 5
submodules: true

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"

- name: Build docs
run: |
pip install -e .[docs]
make htmldocs

- name: Checkout gh-pages
uses: actions/checkout@v4
with:
fetch-depth: 5
ref: gh-pages
path: docs/gh-pages

- name: Sync docs
run: |
rsync -a docs/_build/html/ docs/gh-pages/current/

- name: Commit and push docs
uses: magicstack/gha-commit-and-push@master
with:
target_branch: gh-pages
workdir: docs/gh-pages
commit_message: Automatic documentation update
github_token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
ssh_key: ${{ secrets.RELEASE_BOT_SSH_KEY }}
gpg_key: ${{ secrets.RELEASE_BOT_GPG_KEY }}
gpg_key_id: "5C468778062D87BF!"

publish:
needs: [build-sdist, build-wheels, publish-docs]
needs: [build-sdist, build-wheels]
runs-on: ubuntu-latest

environment:
name: pypi
url: https://pypi.org/p/async_gaussdb
permissions:
id-token: write
attestations: write
contents: write
deployments: write

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 5
submodules: false

- uses: actions/download-artifact@v4
- name: Download sdist artifact
uses: actions/download-artifact@v4
with:
name: dist-sdist
path: dist/

- name: Download all wheel artifacts
uses: actions/download-artifact@v4
with:
name: dist
pattern: dist-wheels-*
path: dist/

- name: Extract Release Version
id: relver
run: |
set -e
# 从标签中提取版本
echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT

- name: Merge and tag the PR
uses: edgedb/action-release/merge@master
with:
github_token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
ssh_key: ${{ secrets.RELEASE_BOT_SSH_KEY }}
gpg_key: ${{ secrets.RELEASE_BOT_GPG_KEY }}
gpg_key_id: "5C468778062D87BF!"
tag_name: v${{ steps.relver.outputs.version }}

- name: Publish Github Release
uses: elprans/gh-action-create-release@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare all_dist directory
run: mkdir all_dist

- name: Move artifacts to all_dist
run: |
ls dist/dist-wheels-cp310-macosx_arm64/
mv dist/**/*.whl all_dist/
mv dist/*.tar.gz all_dist/
ls -l all_dist/

- name: Upload all dist/* to GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.relver.outputs.version }}
release_name: v${{ steps.relver.outputs.version }}
target: ${{ github.ref }} # 使用提交的标签作为目标
body: "Release v${{ steps.relver.outputs.version }}"
files: all_dist/*

- run: |
ls -al dist/

- name: Upload to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
attestations: true
if: startsWith(github.ref, 'refs/tags/')
run: |
pip install --upgrade twine setuptools wheel twine packaging
twine upload all_dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
4 changes: 4 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ jobs:
[ "$RUNNER_OS" = "Linux" ] && .github/workflows/install-krb5.sh
python -m pip install -U pip setuptools wheel
python -m pip install -e .[test]
# 添加 uvloop 安装
if [ "${{ matrix.loop }}" = "uvloop" ]; then
python -m pip install uvloop
fi

- name: Wait for openGauss to be ready
env:
Expand Down
12 changes: 3 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
async_gaussdb -- A fast GaussDB/openGauss Database Client Library for Python/asyncio
=====================================================================================

.. image:: https://github.com/MagicStack/async_gaussdb/workflows/Tests/badge.svg
:target: https://github.com/MagicStack/async_gaussdb/actions?query=workflow%3ATests+branch%3Amaster
:alt: GitHub Actions status
.. image:: https://img.shields.io/pypi/v/async_gaussdb.svg
:target: https://pypi.python.org/pypi/async_gaussdb

**async_gaussdb** is a database interface library designed specifically for
GaussDB and openGauss databases with Python/asyncio. This fork of async_gaussdb is
optimized for GaussDB/openGauss compatibility, including native SHA256
Expand Down Expand Up @@ -86,7 +80,7 @@ Basic Usage


GaussDB/openGauss Specific Features
----------------------------------
-----------------------------------

This library includes enhanced support for GaussDB and openGauss databases:

Expand Down Expand Up @@ -115,5 +109,5 @@ This library includes enhanced support for GaussDB and openGauss databases:

asyncio.run(run())


asyncpg is developed and distributed under the Apache 2.0 license.
asyncpg is developed and distributed under the Apache 2.0 license
by MagicStack Inc. and the HuaweiCloudDeveloper team.
2 changes: 2 additions & 0 deletions async_gaussdb/protocol/protocol.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ cdef class BaseProtocol(CoreProtocol):

bint _is_ssl

object _pending_result

PreparedStatementState statement

cdef get_connection(self)
Expand Down
41 changes: 38 additions & 3 deletions async_gaussdb/protocol/protocol.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ cdef class BaseProtocol(CoreProtocol):

self._is_ssl = False

self._pending_result = None

try:
self.create_future = loop.create_future
except AttributeError:
Expand Down Expand Up @@ -414,7 +416,10 @@ cdef class BaseProtocol(CoreProtocol):
self._request_cancel()
# Make asyncio shut up about unretrieved
# QueryCanceledError
waiter.add_done_callback(lambda f: f.exception())
if waiter and not waiter.done():
waiter.cancel()
elif waiter and waiter.done() and not waiter.cancelled():
waiter.exception()
raise

# done will be True upon receipt of CopyDone.
Expand All @@ -424,6 +429,7 @@ cdef class BaseProtocol(CoreProtocol):
waiter = self._new_waiter(timer.get_remaining_budget())

finally:
self._pending_result = None
self.resume_reading()

return status_msg
Expand Down Expand Up @@ -776,6 +782,14 @@ cdef class BaseProtocol(CoreProtocol):
self.abort()

cdef _new_waiter(self, timeout):
if self._pending_result is not None:
res = self._pending_result
self._pending_result = None
self.resume_reading()
waiter = self.loop.create_future()
waiter.set_result(res)
return waiter

if self.waiter is not None:
raise apg_exc.InterfaceError(
'cannot perform operation: another operation is in progress')
Expand Down Expand Up @@ -848,10 +862,31 @@ cdef class BaseProtocol(CoreProtocol):
waiter = self.waiter
self.waiter = None

if PG_DEBUG:
if waiter is None:
if waiter is None:
if PG_DEBUG:
raise apg_exc.InternalClientError('_on_result: waiter is None')

if self.state == PROTOCOL_COPY_OUT_DATA or \
self.state == PROTOCOL_COPY_OUT_DONE:

copy_done = self.state == PROTOCOL_COPY_OUT_DONE
if copy_done:
status_msg = self.result_status_msg.decode(self.encoding)
else:
status_msg = None

self.pause_reading()
if self._pending_result is not None:
old_data, old_done, old_status = self._pending_result
current_data = self.result if self.result is not None else b''
merged_data = (old_data if old_data is not None else b'') + current_data
self._pending_result = (merged_data, copy_done, status_msg)
else:
self._pending_result = (self.result, copy_done, status_msg)

return
else:
return
if waiter.cancelled():
return

Expand Down
59 changes: 2 additions & 57 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
[project]
name = "async_gaussdb"
description = "An asyncio GaussDB driver"
authors = [{name = "MagicStack Inc", email = "hello@magic.io"}]
requires-python = '>=3.8.0'
readme = "README.rst"
license = {text = "Apache License, Version 2.0"}
license = {text = "Apache-2.0"}
dynamic = ["version"]
keywords = [
"database",
Expand Down Expand Up @@ -39,16 +38,6 @@ gssauth = [
'gssapi; platform_system != "Windows"',
'sspilib; platform_system == "Windows"',
]
test = [
'flake8~=6.1',
'flake8-pyi~=24.1.0',
'distro~=1.9.0',
'uvloop>=0.15.3; platform_system != "Windows" and python_version < "3.14.0"',
'gssapi; platform_system == "Linux"',
'k5test; platform_system == "Linux"',
'sspilib; platform_system == "Windows"',
'mypy~=1.8.0',
]
docs = [
'Sphinx~=8.1.3',
'sphinx_rtd_theme>=1.2.2',
Expand All @@ -71,50 +60,6 @@ include = ["async_gaussdb", "async_gaussdb.*"]
[tool.setuptools.exclude-package-data]
"*" = ["*.c", "*.h"]

[tool.cibuildwheel]
build-frontend = "build"
test-extras = "test"

[tool.cibuildwheel.macos]
before-all = ".github/workflows/install-gaussdb.sh"
test-command = "python {project}/tests/__init__.py"

[tool.cibuildwheel.windows]
test-command = "python {project}\\tests\\__init__.py"

[tool.cibuildwheel.linux]
before-all = """
.github/workflows/install-gaussdb.sh \
&& .github/workflows/install-krb5.sh \
"""
test-command = """\
PY=`which python` \
&& chmod -R go+rX "$(dirname $(dirname $(dirname $PY)))" \
&& su -l apgtest -c "$PY {project}/tests/__init__.py" \
"""

[tool.pytest.ini_options]
addopts = "--capture=no --assert=plain --strict-markers --tb=native --import-mode=importlib"
testpaths = "tests"
filterwarnings = "default"

[tool.coverage.run]
branch = true
plugins = ["Cython.Coverage"]
parallel = true
source = ["async_gaussdb/", "tests/"]
omit = ["*.pxd"]

[tool.coverage.report]
exclude_lines = [
"pragma: no cover",
"def __repr__",
"if debug",
"raise NotImplementedError",
"if __name__ == .__main__.",
]
show_missing = true

[tool.mypy]
exclude = [
"^.eggs",
Expand Down Expand Up @@ -145,4 +90,4 @@ module = [
"async_gaussdb.transaction",
"async_gaussdb.utils",
]
ignore_errors = true
ignore_errors = true
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,5 +249,5 @@ def finalize_options(self):
extra_link_args=LDFLAGS),
],
cmdclass={'build_ext': build_ext, 'build_py': build_py, 'sdist': sdist},
setup_requires=setup_requires,
setup_requires=setup_requires
)
Loading