asyncpg icon indicating copy to clipboard operation
asyncpg copied to clipboard

Temporary tables still visible after releasing connection to pool

Open y4n9squared opened this issue 2 weeks ago • 0 comments

It seems like releasing a connection back to the pool doesn't entirely reset its state in a way that makes it brand new for the next user. Is it expected that temporary tables are still visible? Temporary tables in PostgreSQL are dropped after the session exits but wondering if there is a missing incantation in Connection.reset() that will allow it to be reused.

import asyncio

import asyncpg


async def main():
    pool = await asyncpg.create_pool(
        ...
        min_size=1,
        max_size=1,
    )

    async with pool.acquire() as conn:
        await conn.execute("CREATE TEMPORARY TABLE foo(id INT PRIMARY KEY)")

    async with pool.acquire() as conn:
        await conn.execute("CREATE TEMPORARY TABLE foo(id INT PRIMARY KEY)")  # DuplicateTableException


asyncio.run(main())

y4n9squared avatar Dec 08 '25 18:12 y4n9squared