Skip to content

INSERT .. RETURNING returns wrong binary data #728

Closed
@lukaseder

Description

@lukaseder

Here's a self contained test case that currently fails with jaybird 4.0.8:

try (Statement s = connection.createStatement()) {
    try {
        s.executeUpdate("create table t (a integer not null primary key, b blob)");

        try (ResultSet rs = s.executeQuery("insert into t (a, b) values (1, X'010203') returning a, b")) {
            while (rs.next())
                System.out.println(Arrays.toString(rs.getBytes(2)) + ": " + rs.getBytes(2).length);
        }

        try (ResultSet rs = s.executeQuery("select a, b from t")) {
            while (rs.next())
                System.out.println(Arrays.toString(rs.getBytes(2)) + ": " + rs.getBytes(2).length);
        }
    }
    finally {
        s.executeUpdate("drop table t");
    }
}

It prints:

[0, 0, 40, -60, 0, 0, 0, 0]: 8
[1, 2, 3]: 3

The first result isn't even stable, e.g. after executing it again, I'm getting:

[0, 0, 40, -58, 0, 0, 0, 0]: 8
[1, 2, 3]: 3

And then:

[0, 0, 40, -57, 0, 0, 0, 0]: 8
[1, 2, 3]: 3

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions