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
3 changes: 1 addition & 2 deletions vertx-mssql-client/src/main/asciidoc/index.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
= Reactive MSSQL Client
:PREPARED_PARAMS: `@1`, `@2`, etc…​
:batching-unsupported:

The Reactive MSSQL Client is a client for Microsoft SQL Server with a straightforward API focusing on
scalability and low overhead.
Expand All @@ -17,7 +16,7 @@ scalability and low overhead.
*Not supported yet*

* Prepared queries caching
* Batch and cursor
* Cursor
* Row streaming
* Some https://github.com/eclipse-vertx/vertx-sql-client/issues/608#issuecomment-629390027[data types] are not supported

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright (c) 2011-2021 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*/

package io.vertx.mssqlclient.impl.codec;

import io.netty.buffer.ByteBuf;
import io.vertx.sqlclient.Tuple;
import io.vertx.sqlclient.impl.TupleInternal;
import io.vertx.sqlclient.impl.command.CommandResponse;
import io.vertx.sqlclient.impl.command.ExtendedQueryCommand;

import java.util.List;

class ExtendedBatchQueryCommandCodec<T> extends ExtendedQueryCommandBaseCodec<T> {

private final List<Tuple> paramsList;

private int paramsIdx;
private int messageDecoded;

ExtendedBatchQueryCommandCodec(ExtendedQueryCommand<T> cmd) {
super(cmd);
paramsList = cmd.paramsList();
}

@Override
void encode(TdsMessageEncoder encoder) {
if (paramsList.isEmpty()) {
completionHandler.handle(CommandResponse.failure("Can not execute batch query with 0 sets of batch parameters."));
return;
}
super.encode(encoder);
}

@Override
protected void handleMessageDecoded() {
if (paramsList.size() == 1 || ++messageDecoded == 2) {
complete();
} else {
sendExecRequest();
}
}

@Override
protected TupleInternal prepexecRequestParams() {
paramsIdx = 1;
return (TupleInternal) paramsList.get(0);
}

@Override
protected void writeRpcRequestBatch(ByteBuf packet) {
for (int initial = paramsIdx; paramsIdx < paramsList.size(); paramsIdx++) {
if (initial != paramsIdx) {
packet.writeByte(0xFF); // batch separator
}
super.writeRpcRequestBatch(packet);
}
}

@Override
protected TupleInternal execRequestParams() {
return (TupleInternal) paramsList.get(paramsIdx);
}
}
Loading