Skip to content

Conversion 'text' to 'integer' doesn't work anymore #3444

@turbanoff

Description

@turbanoff

Test case:

        Connection connection = DriverManager.getConnection("jdbc:h2:mem:test;MODE=PostgreSQL;DB_CLOSE_DELAY=-1;LOCK_TIMEOUT=10000");
        Statement statement = connection.createStatement();
        statement.execute("create table CONFIGURATIONS(chunk TEXT)");

        statement.execute("insert into CONFIGURATIONS(chunk) values (1)");
        statement.execute("insert into CONFIGURATIONS(chunk) values (2)");

        ResultSet rs = statement.executeQuery("select chunk::integer v from CONFIGURATIONS");
        while (rs.next()) {
            int v = rs.getInt("v");
            System.out.println("v = " + v);
        }

Works fine in PostgreSQL and H2 1.4.200.
Got exception in H2 2.1.210

Exception in thread "main" org.h2.jdbc.JdbcSQLDataException: Ошибка преобразования данных при конвертации "CHARACTER LARGE OBJECT to INTEGER"
Data conversion error converting "CHARACTER LARGE OBJECT to INTEGER"; SQL statement:
select chunk::integer v from CONFIGURATIONS [22018-210]
	at org.h2.message.DbException.getJdbcSQLException(DbException.java:525)
	at org.h2.message.DbException.getJdbcSQLException(DbException.java:496)
	at org.h2.message.DbException.get(DbException.java:227)
	at org.h2.message.DbException.get(DbException.java:203)
	at org.h2.value.Value.getDataConversionError(Value.java:2551)
	at org.h2.value.Value.convertToInt(Value.java:1606)
	at org.h2.value.Value.convertTo(Value.java:1135)
	at org.h2.value.Value.castTo(Value.java:1075)
	at org.h2.expression.function.CastSpecification.getValue(CastSpecification.java:38)
	at org.h2.expression.Alias.getValue(Alias.java:37)
	at org.h2.command.query.Select$LazyResultQueryFlat.fetchNextRow(Select.java:1833)
	at org.h2.result.LazyResult.hasNext(LazyResult.java:78)
	at org.h2.result.FetchedResult.next(FetchedResult.java:34)
	at org.h2.command.query.Select.queryFlat(Select.java:728)
	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:256)
	at org.h2.command.Command.executeQuery(Command.java:190)
	at org.h2.jdbc.JdbcStatement.executeQuery(JdbcStatement.java:99)

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