Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rijenkii opened this issue Feb 23, 2017 · 1 comment
Closed
Assignees
Labels

Comments

@rijenkii
Copy link

rijenkii commented Feb 23, 2017

  • 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?

@elprans
Copy link
Member

elprans commented Mar 1, 2017

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)

@elprans elprans added the bug label Mar 1, 2017
@elprans elprans self-assigned this Mar 1, 2017
elprans added a commit that referenced this issue Mar 15, 2017
Currently, asyncpg supports falling back to text I/O for types that do
not have a registered codec.  This commit extends this behaviour to
arrays of such types.

Additionally, add an explicit error for when the text I/O is attempted
for a range or a composite type, as these are not supported yet.

Fixes: #82.
elprans added a commit that referenced this issue Mar 15, 2017
Currently, asyncpg supports falling back to text I/O for types that do
not have a registered codec.  This commit extends this behaviour to
arrays of such types.

Additionally, add an explicit error for when the text I/O is attempted
for a range or a composite type, as these are not supported yet.

Fixes: #82.
elprans added a commit that referenced this issue Mar 15, 2017
Currently, asyncpg supports falling back to text I/O for types that do
not have a registered codec.  This commit extends this behaviour to
arrays of such types.

Additionally, add an explicit error for when the text I/O is attempted
for a range or a composite type, as these are not supported yet.

Fixes: #82.
elprans added a commit that referenced this issue Mar 15, 2017
Currently, asyncpg supports falling back to text I/O for types that do
not have a registered codec.  This commit extends this behaviour to
arrays of such types.

Additionally, add an explicit error for when the text I/O is attempted
for a range or a composite type, as these are not supported yet.

Fixes: #82.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants