sqlc icon indicating copy to clipboard operation
sqlc copied to clipboard

Can't run CREATE TEMPORARY TABLE queries with sqlc.

Open Jille opened this issue 3 years ago • 2 comments

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 avatar May 09 '22 15:05 Jille

Tracking here https://github.com/kyleconroy/sqlc/issues/1661

kyleconroy avatar Jun 04 '22 15:06 kyleconroy

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

sgielen avatar Jan 15 '24 17:01 sgielen