Skip to content

"RuntimeError: no codec for array element type 17189" with $1::citext[] #82

Closed

Description

@rijenkii
  • asyncpg version: 0.8.4
  • PostgreSQL version: 9.6.1
  • Python version: 3.6.0
  • Platform: Linux
  • 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?
    : Yes

Steps to reproduce:

  1. CREATE DATABASE test;
  2. Inside the DB: CREATE EXTENSION citext;
  3. Run this python script:
import asyncio
import asyncpg

async def main():
    conn = await asyncpg.connect(database='test')
    print(await conn.fetch('SELECT $1::citext[]', ('a', 'b')))
    await conn.close()

asyncio.get_event_loop().run_until_complete(main())
  1. Get an exception:
Traceback (most recent call last):
  File "test.py", line 9, in <module>
    asyncio.get_event_loop().run_until_complete(main())
  File "/usr/lib/python3.6/asyncio/base_events.py", line 466, in run_until_complete
    return future.result()
  File "test.py", line 6, in main
    print(await conn.fetch('SELECT $1::citext[]', ('a', 'b')))
  File "/usr/lib/python3.6/site-packages/asyncpg/connection.py", line 268, in fetch
    stmt = await self._get_statement(query, timeout)
  File "/usr/lib/python3.6/site-packages/asyncpg/connection.py", line 220, in _get_statement
    protocol.get_settings().register_data_types(types)
  File "asyncpg/protocol/settings.pyx", line 32, in asyncpg.protocol.protocol.ConnectionSettings.register_data_types (asyncpg/protocol/protocol.c:4669)
  File "asyncpg/protocol/settings.pyx", line 33, in asyncpg.protocol.protocol.ConnectionSettings.register_data_types (asyncpg/protocol/protocol.c:4592)
  File "asyncpg/protocol/codecs/base.pyx", line 373, in asyncpg.protocol.protocol.DataCodecConfig.add_types (asyncpg/protocol/protocol.c:16328)
RuntimeError: no codec for array element type 17189

Am I doing something wrong?

Activity

  1. elprans commented on Mar 1, 2017

    @elprans
    Member

    Appears to be a bug. citext is an extension type, so asyncpg doesn't know how to decode it in binary mode. Text mode fallback seems to be broken with arrays. I'll work on a fix shortly, meanwhile you can work around this by aliasing citext to the text codec:

    await conn.set_builtin_type_codec('citext', codec_name=25)
  2. self-assigned this
    on Mar 1, 2017
  3. added 4 commits that reference this issue on Mar 15, 2017
    29b097c
    0452b8f
    6780e45
    c021b3f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions