MagicStack / MagicStack/asyncpg

no decoder for composite type element in position _ of type OID _

Open
#360 8 comments 2 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
8.1k
Forks
468
PR merge metrics
No merged PRs in 30d

Description

* **asyncpg version**: 0.17.0
* **PostgreSQL version**: 10.5
* **Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
the issue with a local PostgreSQL install?**:
* **Python version**: 3.7.0
* **Platform**: Linux
* **Do you use pgbouncer?**: No
* **Did you install asyncpg with pip?**: pipenv
* **If you built asyncpg locally, which version of Cython did you use?**:
* **Can the issue be reproduced under both asyncio and
[uvloop](https://github.com/magicstack/uvloop)?**: asyncio definitely, untested with uvloop

Whenever I am trying to call a plpgsql stored procedure which returns a custom defined enum, I receive the following error:
`RuntimeError: no decoder for composite type element in position 2 of type OID 88492`

Type with OID 88492 in my database (from pg_catalog.pg_type) is listed as `ssg.logintype` which is defined as below:
```
CREATE TYPE SSG.LOGINTYPE AS ENUM (
'phone',
'email'
);
```

Partial traceback (asyncpg relevant parts):
```
File "/home/mayzie/.local/share/virtualenvs/api-xyfAGMEp/lib/python3.7/site-packages/asyncpg/prepared_stmt.py", line 179, in fetchval
data = await self.__bind_execute(args, 1, timeout)
File "/home/mayzie/.local/share/virtualenvs/api-xyfAGMEp/lib/python3.7/site-packages/asyncpg/prepared_stmt.py", line 203, in __bind_execute
self._state, args, '', limit, True, timeout)
File "asyncpg/protocol/protocol.pyx", line 212, in bind_execute
File "asyncpg/protocol/coreproto.pyx", line 71, in asyncpg.protocol.protocol.CoreProtocol._read_server_messages
File "asyncpg/protocol/coreproto.pyx", line 205, in asyncpg.protocol.protocol.CoreProtocol._process__bind_execute
File "asyncpg/protocol/coreproto.pyx", line 495, in asyncpg.protocol.protocol.CoreProtocol._parse_data_msgs
File "asyncpg/protocol/protocol.pyx", line 770, in asyncpg.protocol.protocol.BaseProtocol._decode_row
File "asyncpg/protocol/prepared_stmt.pyx", line 286, in asyncpg.protocol.protocol.PreparedStatementState._decode_row
File "asyncpg/protocol/codecs/base.pyx", line 257, in asyncpg.protocol.protocol.Codec.decode
File "asyncpg/protocol/codecs/base.pyx", line 166, in asyncpg.protocol.protocol.Codec.decode_scalar
File "asyncpg/protocol/codecs/record.pyx", line 39, in asyncpg.protocol.protocol.anonymous_record_decode
RuntimeError: no decoder for composite type element in position 2 of type OID 88492
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the decoding path shown in protocol/codecs/record.pyx and the surrounding prepared-statement and codec files named in the traceback. Reproduce the stored procedure result using PostgreSQL 10.5, a custom enum, and a composite value, then trace why the enum element lacks a decoder. Done means the result decodes without the reported RuntimeError and the behavior is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, python
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.