Skip to content

Data cannot be read after insert of clob data > MAX_LENGTH_INPLACE_LOB with data change delta table  #3376

@htran1

Description

@htran1

The issue is observed in version 2.0.206.

An inserted clob value longer than 256 characters cannot be read after the session is closed and reopened if the insert was done with a data change delta table. Shorter strings work. Normal insert without data change table works.

Exception:

java.lang.IllegalArgumentException: The value may not be null [2.0.206/0]
            at org.h2.mvstore.DataUtils.newIllegalArgumentException(DataUtils.java:978)
            at org.h2.mvstore.DataUtils.checkArgument(DataUtils.java:964)
            at org.h2.mvstore.MVMap.put(MVMap.java:155)
            at org.h2.mvstore.db.LobStorageMap.copyLob(LobStorageMap.java:257)
            at org.h2.value.ValueLob.copyToResult(ValueLob.java:291)
            at org.h2.result.LocalResult.cloneLobs(LocalResult.java:346)
            at org.h2.result.LocalResult.addRow(LocalResult.java:397)
            at org.h2.command.query.Select.queryFlat(Select.java:730)
            at org.h2.command.query.Select.queryWithoutCache(Select.java:833)
            at org.h2.command.query.Query.queryWithoutCacheLazyCheck(Query.java:197)
            at org.h2.command.query.Query.query(Query.java:494)
            at org.h2.command.query.Query.query(Query.java:457)
            at org.h2.command.CommandContainer.query(CommandContainer.java:255)
            at org.h2.command.Command.executeQuery(Command.java:190)

Code to reproduce:

        String jdbcUrl = "jdbc:h2:/tmp/testdb1";
        Connection conn = DriverManager.getConnection(jdbcUrl, "sa", "");
        Statement stmt = conn.createStatement();

        stmt.execute("drop table if exists data1");
        stmt.execute("create table data1 (a int, b clob)");

        String val = "test value test value test value test value test value test value test value test value test value test value test value test value test value test value test value test value test value test value test value test value test value test value test12345789012";
        String insertSql1 = "select DATA1.A from final table (insert into DATA1 (A, B) values (?, ?)) DATA1";
        PreparedStatement pstmt = conn.prepareStatement(insertSql1);
        pstmt.setInt(1, 1);
        pstmt.setString(2, val);
        pstmt.execute();

        // The query works when the session is active
        ResultSet res = stmt.executeQuery("select a, b from data1");

        while (res.next()) {
            System.out.println("result: " + res.getInt(1) + " : " + res.getString(2));
        }

        conn.close();

        // Open a new session after closing and reattempt the query. This time an exception is encoutered.
        conn = DriverManager.getConnection(jdbcUrl, "sa", "");
        stmt = conn.createStatement();
        pstmt = conn.prepareStatement(insertSql1);
        pstmt.setInt(1, 1);
        pstmt.setString(2, val);
        pstmt.execute();

        res = stmt.executeQuery("select a, b from data1");

        while (res.next()) {
            System.out.println("result: " + res.getInt(1) + " : " + res.getString(2));
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions