Skip to content

Temporary tables still visible after releasing connection to pool #1293

@y4n9squared

Description

@y4n9squared

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())

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions