Skip to content

Commit

Permalink
Fixes p4
Browse files Browse the repository at this point in the history
  • Loading branch information
tkyc committed Sep 7, 2023
1 parent b0424dd commit b19dfb0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java
Original file line number Diff line number Diff line change
Expand Up @@ -1245,7 +1245,7 @@ void sendByRPC(TDSWriter tdsWriter, SQLServerStatement statement) throws SQLServ
try {
inputDTV.sendCryptoMetaData(this.cryptoMeta, tdsWriter);
inputDTV.setJdbcTypeSetByUser(getJdbcTypeSetByUser(), getValueLength());
inputDTV.sendByRPC(SQLServerPreparedStatement.callRpcDirectly ? name : null, null, conn.getDatabaseCollation(), valueLength, isOutput() ? outScale : scale,
inputDTV.sendByRPC(SQLServerPreparedStatement.callRpcDirectly && !conn.isColumnEncryptionSettingEnabled()? name : null, null, conn.getDatabaseCollation(), valueLength, isOutput() ? outScale : scale,
isOutput(), tdsWriter, statement);
} finally {
// reset the cryptoMeta in IOBuffer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ private Parameter getOutParameter(int i) throws SQLServerException {
return inOutParam[i - 1];
}

if (inOutParam[i - 1].isReturnValue() && bReturnValueSyntax && !isCursorable(executeMethod) && !isTVPType) {
if (inOutParam[i - 1].isReturnValue() && bReturnValueSyntax && !isCursorable(executeMethod) && !isTVPType && !connection.isColumnEncryptionSettingEnabled()) {
return inOutParam[i - 1];
}

Expand Down Expand Up @@ -341,7 +341,7 @@ boolean onRetValue(TDSReader tdsReader) throws SQLServerException {
OutParamHandler outParamHandler = new OutParamHandler();

if (bReturnValueSyntax && (nOutParamsAssigned == 0) && !isCursorable(executeMethod) && !isTVPType
&& SQLServerConnection.isCallRemoteProcDirectValid(userSQL, inOutParam.length, bReturnValueSyntax)) {
&& SQLServerConnection.isCallRemoteProcDirectValid(userSQL, inOutParam.length, bReturnValueSyntax) && !connection.isColumnEncryptionSettingEnabled()) {
nOutParamsAssigned++;
}

Expand Down Expand Up @@ -389,7 +389,7 @@ boolean onRetValue(TDSReader tdsReader) throws SQLServerException {
outParamIndex = outParamHandler.srv.getOrdinalOrLength();

if (bReturnValueSyntax && !isCursorable(executeMethod) && !isTVPType && SQLServerConnection
.isCallRemoteProcDirectValid(userSQL, inOutParam.length, bReturnValueSyntax)) {
.isCallRemoteProcDirectValid(userSQL, inOutParam.length, bReturnValueSyntax) && !connection.isColumnEncryptionSettingEnabled()) {
outParamIndex++;
} else {
// Statements need to have their out param indices adjusted by the number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,10 @@ void sendParamsByRPC(TDSWriter tdsWriter, Parameter[] params, boolean bReturnVal
&& SQLServerConnection.isCallRemoteProcDirectValid(userSQL, params.length, bReturnValueSyntax)) {
returnParam = params[index];
params[index].setReturnValue(true);
index++;

if (!connection.isColumnEncryptionSettingEnabled()) {
index++;
}
}
for (; index < params.length; index++) {
if (JDBCType.TVP == params[index].getJdbcType()) {
Expand Down Expand Up @@ -1164,7 +1167,7 @@ private boolean doPrepExec(TDSWriter tdsWriter, Parameter[] params, boolean hasN
buildServerCursorExecParams(tdsWriter);
} else {
// if it is a parameterized stored procedure call and is not TVP, use sp_execute directly.
if (needsPrepare && callRpcDirectly) {
if (needsPrepare && callRpcDirectly && !connection.isColumnEncryptionSettingEnabled()) {
buildRPCExecParams(tdsWriter);
}
// Move overhead of needing to do prepare & unprepare to only use cases that need more than one execution.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1616,7 +1616,7 @@ boolean onRetStatus(TDSReader tdsReader) throws SQLServerException {
// not cursorable and not TVP type. For these two, the driver is still following the old behavior of
// executing sp_executesql for stored procedures.
if (!isCursorable(executeMethod) && !SQLServerPreparedStatement.isTVPType && null != inOutParam
&& inOutParam.length > 0 && inOutParam[0].isReturnValue()) {
&& inOutParam.length > 0 && inOutParam[0].isReturnValue() && !connection.isColumnEncryptionSettingEnabled()) {
inOutParam[0].setFromReturnStatus(procedureRetStatToken.getStatus(), connection);
return false;
}
Expand Down

0 comments on commit b19dfb0

Please sign in to comment.