Support for multi-query statements
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 1.7k
- Forks
- 175
- Avg merge
- 5d 14h
- Merged PRs (30d)
- 9
Description
The postgres protocol supports sending multiple queries across different tables/views (separated by semi-colon) in one request and receiving the results. Currently Skunk explicitly does not support this:
From Query.scala
case ReadyForQuery(_) =>
new SkunkException(
message = "Multi-statement queries and commands are not supported.",
hint = Some("Break up semicolon-separated statements and execute them independently."),
sql = Some(stmt.sql),
sqlOrigin = Some(stmt.origin),
).raiseError[F, Unit].whenA(multipleStatements)
Even if you have parallelizeable queries in a transaction, currently clients are forced to submit the queries one at a time, waiting for the results of the first query before submitting the second query. If you have a lot of queries and a decent amount of latency between your app/db servers this can add up.
I'm interested in adding support for this and am digging around but wouldn't mind if anyone had any pointers or reasons why this could never work with the Skunk model.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the ReadyForQuery handling in Query.scala and trace how Skunk currently detects multipleStatements and returns the unsupported-operation error. Investigate the PostgreSQL protocol behavior for multiple semicolon-separated queries, including result delivery and transactions. Done means clients can submit such statements and receive their results without triggering the current exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgres, scala
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100