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

Regression: "INTERNAL Error: Attempting to commit a transaction that is read-only but has made changes" when generating sequence values from generate_series table with bind value arguments #36

Open
lukaseder opened this issue Jun 17, 2024 · 0 comments

Comments

@lukaseder
Copy link

Create a sequence like this:

create sequence s;

Then try to generate sequence values like this:

try (PreparedStatement s = connection.prepareStatement("select nextval('s') from generate_series(?, ?)")) {
    s.setInt(1, 1);
    s.setInt(2, 5);

    try (ResultSet rs = s.executeQuery()) {
        while (rs.next()) {
            System.out.println(rs.getInt(1));
        }
    }
}

This produces the following error:

0
INTERNAL Error: Attempting to commit a transaction that is read-only but has made changes - this should not be possible
This error signals an assertion failure within DuckDB. This usually occurs due to unexpected conditions or errors in the program's logic.
For more information, see https://duckdb.org/docs/dev/internal_errors
null
java.sql.SQLException: INTERNAL Error: Attempting to commit a transaction that is read-only but has made changes - this should not be possible
This error signals an assertion failure within DuckDB. This usually occurs due to unexpected conditions or errors in the program's logic.
For more information, see https://duckdb.org/docs/dev/internal_errors
	at org.duckdb.DuckDBNative.duckdb_jdbc_execute(Native Method)
	at org.duckdb.DuckDBPreparedStatement.execute(DuckDBPreparedStatement.java:143)
	at org.duckdb.DuckDBPreparedStatement.executeQuery(DuckDBPreparedStatement.java:175)
	at org.jooq.testscripts.JDBC.main(JDBC.java:42)

This is a regression introduced in 0.10.3, still present in 1.0.0. It used to work in 0.10.2.

A workaround is to avoid bind values in generate_series(), like this:

try (PreparedStatement s = connection.prepareStatement("select nextval('s') from generate_series(1, 5)")) {
    try (ResultSet rs = s.executeQuery()) {
        while (rs.next()) {
            System.out.println(rs.getInt(1));
        }
    }
}

This now prints:

2
3
4
5
6
@lukaseder lukaseder changed the title Regression: INTERNAL Error: Attempting to commit a transaction that is read-only but has made changes when generating sequence values from generate_series table with bind value arguments Regression: "INTERNAL Error: Attempting to commit a transaction that is read-only but has made changes" when generating sequence values from generate_series table with bind value arguments Jun 17, 2024
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

No branches or pull requests

1 participant