Skip to content

Error when creating temporary tables #524

Open
@duncangroenewald

Description

@duncangroenewald

Describe the issue

I am trying to create a temporary table and populate it from multiple queries but keep getting an error indicating the temp table does not exist.

Vapor version

postgres-nio client

Operating system and version

macoOS15

Swift version

5.10.0-dev

Steps to reproduce

Here is what I am trying to do

try await client.query("CREATE TEMP TABLE ABC (....)")

try await client.query("INSERT INTO ABC (....) SELECT ... FROM XYZ")
try await client.query("INSERT INTO ABC (....) SELECT ... FROM GHI")

try await client.query("SELECT * FROM ABC")

However the temp table is either not created or disappears before the insert statement is executed.

Strangely I had some of these defined as Postgres FUNCTIONS and if I execute a prepared statement and then the code above it seemed to work. But as soon as I no longer execute a prepared statement calling a function I get the error about missing temp table.

Is there some specific way to create temp tables with Postgres-nio to get this to work.

Outcome

I am always getting an error indicating the temp table does not exist when the INSERT statement if executed.

Additional notes

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions