Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't run CREATE TEMPORARY TABLE queries with sqlc. #1599

Open
Jille opened this issue May 9, 2022 · 3 comments
Open

Can't run CREATE TEMPORARY TABLE queries with sqlc. #1599

Jille opened this issue May 9, 2022 · 3 comments

Comments

@Jille
Copy link
Contributor

Jille commented May 9, 2022

Version

1.13.0

What happened?

All DDL statements in queries.sql are parsed as schema definition, rather than as queries that can be executed at runtime.

I want to create temporary tables at runtime, so I can then CopyFrom into them and use UPDATE .. FROM .. to efficiently write back to a non-temp table.

Relevant log output

No response

Database schema

No response

SQL queries

No response

Configuration

No response

Playground URL

https://play.sqlc.dev/p/9a91120870ebfb6e91ab726c9495822a6403c2db27fbf036c07e976af9f794d3

What operating system are you using?

Linux

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

@Jille Jille added bug Something isn't working triage New issues that hasn't been reviewed labels May 9, 2022
@kyleconroy kyleconroy added 📚 postgresql 🔧 golang enhancement New feature or request and removed bug Something isn't working triage New issues that hasn't been reviewed labels Jun 4, 2022
@kyleconroy
Copy link
Collaborator

Tracking here #1661

@sgielen
Copy link

sgielen commented Jan 15, 2024

I believe this is resolved in sqlc v1.25.0, although the release notes don't directly mention it - only that a different PostgreSQL query parser is now used, which may be relevant. If you open the Playground link on v1.24.0 you'll see the CreateTempTable query is not generated, but on v1.25.0, it is. (You may need to make a tiny change to the query.sql to get the playground to rerun codegen.)

@ZNackasha
Copy link

@sgielen can we get an example of how to do this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants