- asyncpg version: 0.18.3
- PostgreSQL version: 11
- Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
the issue with a local PostgreSQL install?: local
- Python version: 3.7
- 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?: 0.28.5
- Can the issue be reproduced under both asyncio and
uvloop?: yes
There's a query SELECT generate_series FROM generate_series($1, $2, $3); There're multiple versions of the same function generate_series defined for different argument types. So when you emit PREPARE STATEMENT command you must emit types for which the function given should be selected by the query planner. The query then becomes PREPARE STATEMENT {stmt_name} (type1, type2, type3) AS SELECT generate_series FROM generate_series($1, $2, $3);
And there's no way to make asyncpg to emit such a type-hinted prepared statement. So this kind of queries always fail with
asyncpg.exceptions.AmbiguousFunctionError: function generate_series(unknown, unknown, unknown) is not unique
HINT: Could not choose a best candidate function. You might need to add explicit type casts.
There's even no arg in Connection.prepare() that could help providing such a type hint for CoreConnection._prepare()
the issue with a local PostgreSQL install?: local
uvloop?: yes
There's a query
SELECT generate_series FROM generate_series($1, $2, $3);There're multiple versions of the same functiongenerate_seriesdefined for different argument types. So when you emitPREPARE STATEMENTcommand you must emit types for which the function given should be selected by the query planner. The query then becomesPREPARE STATEMENT {stmt_name} (type1, type2, type3) AS SELECT generate_series FROM generate_series($1, $2, $3);And there's no way to make asyncpg to emit such a type-hinted prepared statement. So this kind of queries always fail with
There's even no arg in
Connection.prepare()that could help providing such a type hint forCoreConnection._prepare()