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

INSERT .. RETURNING returns wrong binary data #728

Closed
lukaseder opened this issue Jan 9, 2023 · 4 comments
Closed

INSERT .. RETURNING returns wrong binary data #728

lukaseder opened this issue Jan 9, 2023 · 4 comments

Comments

@lukaseder
Copy link

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
@mrotteveel
Copy link
Member

Thanks for reporting. The value returned seems to be the blob-id instead of the blob value, which would suggest that this is backed by an FBCachedBlob which was populated with the blob-id and not the blob value. I'll see if I can trace where this occurs.

@mrotteveel
Copy link
Member

The code path taken intentionally does not fetch the blob value, but I'm unsure why.

@mrotteveel
Copy link
Member

Fix will be available with 4.0.9 and 5.0.1. I don't have a solid release date for either of those yet, but probably somewhere around the beginning of February, maybe earlier if it turns out I broke a lot in 5.0.0 ;).

You can test with the 5.0.1.java11-SNAPSHOT (or 5.0.1.java8-SNAPSHOT) on https://oss.sonatype.org/content/repositories/snapshots (deploying 4.0.x snapshots is a lot more manual work, so I generally won't bother, but let me know if you prefer to have a 4.0.9 snapshot).

@lukaseder
Copy link
Author

I can wait for 4.0.9, thanks!

mrotteveel added a commit that referenced this issue Jan 10, 2023
mrotteveel added a commit that referenced this issue Jan 10, 2023
mrotteveel added a commit that referenced this issue Jan 10, 2023
@mrotteveel mrotteveel added this to the v6-initial milestone Jun 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment