MagicStack / MagicStack/asyncpg

OverflowError: date value out of range

未关闭
#412 5 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Python
星标
8.1k
派生
468
PR 合并指标
30 天内没有已合并 PR

描述

  • asyncpg version: 0.18.3
  • PostgreSQL version: 10.7
  • Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
    the issue with a local PostgreSQL install?
    : Yes
  • Python version: 3.7
  • Platform: Mac OS
  • Do you use pgbouncer?: No
  • Did you install asyncpg with pip?: Yes
  • If you built asyncpg locally, which version of Cython did you use?:
  • Can the issue be reproduced under both asyncio and
    uvloop?
    :

asyncpg is failing to parse timestamp

code:

import asyncio
import asyncpg

async def run():
    conn = await asyncpg.connect(user='secure', password='secure',
                                 database='secure',
                                 host='secure.com', port=15432, timeout=600)

    values = await conn.fetch('''SELECT  _ts FROM Events''')
    print(values)
    await conn.close()


loop = asyncio.get_event_loop()
loop.run_until_complete(run())
Timestamp format: 2019-01-01T08:42:25.921Z
Traceback (most recent call last):
  File "/scratch_65.py", line 21, in <module>
    loop.run_until_complete(run())
  File "/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
    return future.result()
  File "/scratch_65.py", line 15, in run
    values = await conn.fetch('''SELECT  _ts FROM Events''')
  File "/lib/python3.7/site-packages/asyncpg/connection.py", line 421, in fetch
    return await self._execute(query, args, 0, timeout)
  File "/lib/python3.7/site-packages/asyncpg/connection.py", line 1414, in _execute
    query, args, limit, timeout, return_status=return_status)
  File "/lib/python3.7/site-packages/asyncpg/connection.py", line 1422, in __execute
    return await self._do_execute(query, executor, timeout)
  File "/lib/python3.7/site-packages/asyncpg/connection.py", line 1444, in _do_execute
    result = await executor(stmt, None)
  File "asyncpg/protocol/protocol.pyx", line 196, in bind_execute
  File "asyncpg/protocol/coreproto.pyx", line 65, in asyncpg.protocol.protocol.CoreProtocol._read_server_messages
  File "asyncpg/protocol/coreproto.pyx", line 202, in asyncpg.protocol.protocol.CoreProtocol._process__bind_execute
  File "asyncpg/protocol/coreproto.pyx", line 498, in asyncpg.protocol.protocol.CoreProtocol._parse_data_msgs
  File "asyncpg/protocol/protocol.pyx", line 754, in asyncpg.protocol.protocol.BaseProtocol._decode_row
  File "asyncpg/protocol/prepared_stmt.pyx", line 282, in asyncpg.protocol.protocol.PreparedStatementState._decode_row
  File "asyncpg/protocol/codecs/base.pyx", line 288, in asyncpg.protocol.protocol.Codec.decode
  File "asyncpg/protocol/codecs/base.pyx", line 195, in asyncpg.protocol.protocol.Codec.decode_scalar
  File "asyncpg/pgproto/./codecs/datetime.pyx", line 252, in asyncpg.pgproto.pgproto.timestamptz_decode
OverflowError: date value out of range

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 asyncpg/pgproto/./codecs/datetime.pyx 中的 timestamptz_decode 开始,然后使用提供的 Python 查询针对 PostgreSQL 重现该故障。跟踪所报告时间戳的解码过程,如果仓库中有相关的测试位置,则为此用例添加覆盖。完成的标志是查询在不发生 OverflowError 的情况下返回该时间戳。

由索引模型根据 Issue 内容生成。

评估

技术栈
postgresql, python
领域
databases
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。