Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private boolean ifNotMissing(ByteBuf in, Row row) {

private boolean decodeMssqlNbcRow(ByteBuf in, Row row) {
int len = desc.size();
int nullBitmapByteCount = ((len - 1) >> 3) + 1;
int nullBitmapByteCount = (len - (desc.hasRowStat() ? 0 : 1) >> 3) + 1;
int nullBitMapStartIdx = in.readerIndex();
in.skipBytes(nullBitmapByteCount);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,28 @@ public void failureWhenPreparingCursor(TestContext ctx) {
}));
}));
}

@Test
public void testNbcRowWithCursor(TestContext ctx) {
Async async = ctx.async();
connect(ctx.asyncAssertSuccess(conn -> {
conn.prepare("SELECT * FROM nbcrow_with_rowstat").onComplete(ctx.asyncAssertSuccess(ps -> {
ps.createStream(50)
.exceptionHandler(ctx::fail)
.handler(row -> {
// Make sure NbcRow handling is correct when the number of columns is a multiple of 8
ctx.assertEquals(0, row.size() % 8);
for (int i = 1; i <= 8; i++) {
if (i % 2 != 0) {
ctx.assertEquals(String.valueOf(i), row.getString(i - 1));
} else {
ctx.assertNull(row.getString(i - 1));
}
}
})
.endHandler(v -> async.complete());
}));
}));
}
}

21 changes: 21 additions & 0 deletions vertx-mssql-client/src/test/resources/init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -310,3 +310,24 @@ VALUES (2, 32767, 2147483647, 9223372036854775807, 123.456, 1.234567, 'hello,wor
GO

-- TCK usage --

-- Table for testing NBCROW with a cursor
DROP TABLE IF EXISTS nbcrow_with_rowstat;
CREATE TABLE nbcrow_with_rowstat
(
test_varchar_1 VARCHAR(20),
test_varchar_2 VARCHAR(20),
test_varchar_3 VARCHAR(20),
test_varchar_4 VARCHAR(20),
test_varchar_5 VARCHAR(20),
test_varchar_6 VARCHAR(20),
test_varchar_7 VARCHAR(20),
test_varchar_8 VARCHAR(20),
);

INSERT INTO nbcrow_with_rowstat
VALUES ('1', NULL, '3', NULL, '5', NULL, '7', NULL);

GO

-- Table for testing NBCROW with a cursor