Skip to content

Disallow multiple statements in prepare (2.0) - #1012

Merged
staticlibs merged 1 commit into
duckdb:v2.0.1from
staticlibs:prepare_multi_20
Nov 25, 2026
Merged

staticlibs merged 1 commit into
duckdb:v2.0.1from
staticlibs:prepare_multi_20

Conversation

@staticlibs

Copy link
Copy Markdown
Member

This is a backport of the PR #1008 to v2.0-cyanoptera branch.

Historically the driver accepts multiple concatenated SQL statements in a query string. Where all statements are executed one by one and the result of the last statement is returned.

This PR changes that, it continues allowing multiple concatenated statements in a plain Java Statement, but rejects them in a PreparedStatement. Thus the following code (that was working before) is now rejected:

try (Connection c = DriverManager.getConnection("jdbc:duckdb:")) {
    try (PreparedStatement p = c.prepareStatement("CREATE TABLE z(i int); SELECT 1 AS x")) {
    ...
    }
}

Fixes: #1004

This is a backport of the PR duckdb#1008 to `v2.0-cyanoptera` branch.

Historically the driver accepts multiple concatenated SQL statements
in a query string. Where all statements are executed one by one and
the result of the last statement is returned.

This PR changes that, it continues allowing multiple concatenated
statements in a plain Java `Statement`, but rejects them in a
`PreparedStatement`. Thus the following code (that was working before)
is now rejected:

```java
try (Connection c = DriverManager.getConnection("jdbc:duckdb:")) {
    try (PreparedStatement p = c.prepareStatement("CREATE TABLE z(i int); SELECT 1 AS x")) {
    ...
    }
}
```

Fixes: duckdb#1004
@staticlibs
staticlibs merged commit 80a62cb into duckdb:v2.0.1 Nov 25, 2026
17 checks passed
@staticlibs
staticlibs deleted the prepare_multi_20 branch November 25, 2026 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant