Skip to content

Commit f2f3f17

Browse files
committed
Revert Execute Stored Procedure directly feature (#2488)
* Revert "Execute Stored Procedures Directly (#2154)" This reverts commit 11680a6. * Revert "Execute cstmt directly - Additional testing and changes (#2284)" This reverts commit 92cfe0d. * Revert "Re-added support for stored procedure 'exec' escape syntax in CallableStatements (#2325)" This reverts commit ba88da8. * Additional revert of missed lines * Added no-op for getters/setters * RequestBoundaryMethods no-op test fix
1 parent ee044a8 commit f2f3f17

22 files changed

+514
-1968
lines changed

src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java

+7-37
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,6 @@ static final String getEncryptionLevel(int level) {
466466
final static int COLINFO_STATUS_DIFFERENT_NAME = 0x20;
467467

468468
final static int MAX_FRACTIONAL_SECONDS_SCALE = 7;
469-
final static int DEFAULT_FRACTIONAL_SECONDS_SCALE = 3;
470469

471470
final static Timestamp MAX_TIMESTAMP = Timestamp.valueOf("2079-06-06 23:59:59");
472471
final static Timestamp MIN_TIMESTAMP = Timestamp.valueOf("1900-01-01 00:00:00");
@@ -4827,7 +4826,7 @@ void writeVMaxHeader(long headerLength, boolean isNull, SQLCollation collation)
48274826
* Utility for internal writeRPCString calls
48284827
*/
48294828
void writeRPCStringUnicode(String sValue) throws SQLServerException {
4830-
writeRPCStringUnicode(null, sValue, false, null, false);
4829+
writeRPCStringUnicode(null, sValue, false, null);
48314830
}
48324831

48334832
/**
@@ -4842,8 +4841,8 @@ void writeRPCStringUnicode(String sValue) throws SQLServerException {
48424841
* @param collation
48434842
* the collation of the data value
48444843
*/
4845-
void writeRPCStringUnicode(String sName, String sValue, boolean bOut, SQLCollation collation,
4846-
boolean isNonPLP) throws SQLServerException {
4844+
void writeRPCStringUnicode(String sName, String sValue, boolean bOut,
4845+
SQLCollation collation) throws SQLServerException {
48474846
boolean bValueNull = (sValue == null);
48484847
int nValueLen = bValueNull ? 0 : (2 * sValue.length());
48494848
// Textual RPC requires a collation. If none is provided, as is the case when
@@ -4855,7 +4854,7 @@ void writeRPCStringUnicode(String sName, String sValue, boolean bOut, SQLCollati
48554854
* Use PLP encoding if either OUT params were specified or if the user query exceeds
48564855
* DataTypes.SHORT_VARTYPE_MAX_BYTES
48574856
*/
4858-
if ((nValueLen > DataTypes.SHORT_VARTYPE_MAX_BYTES || bOut) && !isNonPLP) {
4857+
if (nValueLen > DataTypes.SHORT_VARTYPE_MAX_BYTES || bOut) {
48594858
writeRPCNameValType(sName, bOut, TDSType.NVARCHAR);
48604859

48614860
writeVMaxHeader(nValueLen, // Length
@@ -5606,8 +5605,8 @@ void writeCryptoMetaData() throws SQLServerException {
56065605
writeByte(cryptoMeta.normalizationRuleVersion);
56075606
}
56085607

5609-
void writeRPCByteArray(String sName, byte[] bValue, boolean bOut, JDBCType jdbcType, SQLCollation collation,
5610-
boolean isNonPLP) throws SQLServerException {
5608+
void writeRPCByteArray(String sName, byte[] bValue, boolean bOut, JDBCType jdbcType,
5609+
SQLCollation collation) throws SQLServerException {
56115610
boolean bValueNull = (bValue == null);
56125611
int nValueLen = bValueNull ? 0 : bValue.length;
56135612
boolean isShortValue = (nValueLen <= DataTypes.SHORT_VARTYPE_MAX_BYTES);
@@ -5653,7 +5652,7 @@ void writeRPCByteArray(String sName, byte[] bValue, boolean bOut, JDBCType jdbcT
56535652

56545653
writeRPCNameValType(sName, bOut, tdsType);
56555654

5656-
if (usePLP && !isNonPLP) {
5655+
if (usePLP) {
56575656
writeVMaxHeader(nValueLen, bValueNull, collation);
56585657

56595658
// Send the data.
@@ -7032,35 +7031,6 @@ final short peekStatusFlag() {
70327031
return 0;
70337032
}
70347033

7035-
final int peekReturnValueStatus() throws SQLServerException {
7036-
// Ensure that we have a packet to read from.
7037-
if (!ensurePayload()) {
7038-
throwInvalidTDS();
7039-
}
7040-
7041-
// In order to parse the 'status' value, we need to skip over the following properties in the TDS packet
7042-
// payload: TDS token type (1 byte value), ordinal/length (2 byte value), parameter name length value (1 byte value) and
7043-
// the number of bytes that make the parameter name (need to be calculated).
7044-
//
7045-
// 'offset' starts at 4 because tdsTokenType + ordinal/length + parameter name length value is 4 bytes. So, we
7046-
// skip 4 bytes immediateley.
7047-
int offset = 4;
7048-
int paramNameLength = currentPacket.payload[payloadOffset + 3];
7049-
7050-
// Check if parameter name is set. If it's set, it should be > 0. In which case, we add the
7051-
// additional bytes to skip.
7052-
if (paramNameLength > 0) {
7053-
// Each character in unicode is 2 bytes
7054-
offset += 2 * paramNameLength;
7055-
}
7056-
7057-
if (payloadOffset + offset <= currentPacket.payloadLength) {
7058-
return currentPacket.payload[payloadOffset + offset] & 0xFF;
7059-
}
7060-
7061-
return -1;
7062-
}
7063-
70647034
final int readUnsignedByte() throws SQLServerException {
70657035
// Ensure that we have a packet to read from.
70667036
if (!ensurePayload())

src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataSource.java

+23-19
Original file line numberDiff line numberDiff line change
@@ -609,25 +609,6 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource {
609609
*/
610610
boolean getUseDefaultGSSCredential();
611611

612-
/**
613-
* Sets whether or not sp_sproc_columns will be used for parameter name lookup.
614-
*
615-
* @param useFlexibleCallableStatements
616-
* When set to false, sp_sproc_columns is not used for parameter name lookup
617-
* in callable statements. This eliminates a round trip to the server but imposes limitations
618-
* on how parameters are set. When set to false, applications must either reference
619-
* parameters by name or by index, not both. Parameters must also be set in the same
620-
* order as the stored procedure definition.
621-
*/
622-
void setUseFlexibleCallableStatements(boolean useFlexibleCallableStatements);
623-
624-
/**
625-
* Returns whether or not sp_sproc_columns is being used for parameter name lookup.
626-
*
627-
* @return useFlexibleCallableStatements
628-
*/
629-
boolean getUseFlexibleCallableStatements();
630-
631612
/**
632613
* Sets the GSSCredential.
633614
*
@@ -1350,4 +1331,27 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource {
13501331
* @return calcBigDecimalPrecision boolean value
13511332
*/
13521333
boolean getCalcBigDecimalPrecision();
1334+
1335+
/**
1336+
* useFlexibleCallableStatements is temporarily removed. This is meant as a no-op.
1337+
*
1338+
* Sets whether or not sp_sproc_columns will be used for parameter name lookup.
1339+
*
1340+
* @param useFlexibleCallableStatements
1341+
* When set to false, sp_sproc_columns is not used for parameter name lookup
1342+
* in callable statements. This eliminates a round trip to the server but imposes limitations
1343+
* on how parameters are set. When set to false, applications must either reference
1344+
* parameters by name or by index, not both. Parameters must also be set in the same
1345+
* order as the stored procedure definition.
1346+
*/
1347+
void setUseFlexibleCallableStatements(boolean useFlexibleCallableStatements);
1348+
1349+
/**
1350+
* useFlexibleCallableStatements is temporarily removed. This is meant as a no-op.
1351+
*
1352+
* Returns whether or not sp_sproc_columns is being used for parameter name lookup.
1353+
*
1354+
* @return useFlexibleCallableStatements
1355+
*/
1356+
boolean getUseFlexibleCallableStatements();
13531357
}

src/main/java/com/microsoft/sqlserver/jdbc/Parameter.java

+11-65
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ final class Parameter {
3737
// For unencrypted parameters cryptometa will be null. For encrypted parameters it will hold encryption metadata.
3838
CryptoMetadata cryptoMeta = null;
3939

40-
boolean isNonPLP = false;
41-
4240
TypeInfo getTypeInfo() {
4341
return typeInfo;
4442
}
@@ -50,7 +48,6 @@ final CryptoMetadata getCryptoMetadata() {
5048
private boolean shouldHonorAEForParameter = false;
5149
private boolean userProvidesPrecision = false;
5250
private boolean userProvidesScale = false;
53-
private boolean isReturnValue = false;
5451

5552
// The parameter type definition
5653
private String typeDefinition = null;
@@ -73,49 +70,11 @@ boolean isOutput() {
7370
return null != registeredOutDTV;
7471
}
7572

76-
/**
77-
* Returns true/false if the parameter is of return type
78-
*
79-
* @return isReturnValue
80-
*/
81-
boolean isReturnValue() {
82-
return isReturnValue;
83-
}
84-
85-
/**
86-
* Sets the parameter to be of return type
87-
*
88-
* @param isReturnValue
89-
*/
90-
void setReturnValue(boolean isReturnValue) {
91-
this.isReturnValue = isReturnValue;
92-
}
93-
94-
/**
95-
* Sets the name of the parameter
96-
*
97-
* @param name
98-
*/
99-
void setName(String name) {
100-
this.name = name;
101-
}
102-
103-
/**
104-
* Retrieve the name of the parameter
105-
*
106-
* @return
107-
*/
108-
String getName() {
109-
return this.name;
110-
}
111-
112-
/**
113-
* Returns the `registeredOutDTV` instance of the parameter
114-
*
115-
* @return registeredOutDTV
116-
*/
117-
DTV getRegisteredOutDTV() {
118-
return this.registeredOutDTV;
73+
// Since a parameter can have only one type definition for both sending its value to the server (IN)
74+
// and getting its value from the server (OUT), we use the JDBC type of the IN parameter value if there
75+
// is one; otherwise we use the registered OUT param JDBC type.
76+
JDBCType getJdbcType() {
77+
return (null != inputDTV) ? inputDTV.getJdbcType() : JDBCType.UNKNOWN;
11978
}
12079

12180
/**
@@ -127,13 +86,6 @@ DTV getInputDTV() {
12786
return this.inputDTV;
12887
}
12988

130-
// Since a parameter can have only one type definition for both sending its value to the server (IN)
131-
// and getting its value from the server (OUT), we use the JDBC type of the IN parameter value if there
132-
// is one; otherwise we use the registered OUT param JDBC type.
133-
JDBCType getJdbcType() {
134-
return (null != inputDTV) ? inputDTV.getJdbcType() : JDBCType.UNKNOWN;
135-
}
136-
13789
/**
13890
* Used when sendStringParametersAsUnicode=true to derive the appropriate National Character Set JDBC type
13991
* corresponding to the specified JDBC type.
@@ -303,7 +255,7 @@ void setFromReturnStatus(int returnStatus, SQLServerConnection con) throws SQLSe
303255
if (null == getterDTV)
304256
getterDTV = new DTV();
305257

306-
getterDTV.setValue(null, this.getJdbcType(), returnStatus, JavaType.INTEGER, null, null, null, con,
258+
getterDTV.setValue(null, JDBCType.INTEGER, returnStatus, JavaType.INTEGER, null, null, null, con,
307259
getForceEncryption());
308260
}
309261

@@ -444,14 +396,10 @@ boolean isValueGotten() {
444396

445397
Object getValue(JDBCType jdbcType, InputStreamGetterArgs getterArgs, Calendar cal, TDSReader tdsReader,
446398
SQLServerStatement statement) throws SQLServerException {
447-
if (null == getterDTV) {
399+
if (null == getterDTV)
448400
getterDTV = new DTV();
449-
}
450-
451-
if (null != tdsReader) {
452-
deriveTypeInfo(tdsReader);
453-
}
454401

402+
deriveTypeInfo(tdsReader);
455403
// If the parameter is not encrypted or column encryption is turned off (either at connection or
456404
// statement level), cryptoMeta would be null.
457405
return getterDTV.getValue(jdbcType, outScale, getterArgs, cal, typeInfo, cryptoMeta, tdsReader, statement);
@@ -1267,17 +1215,15 @@ String getTypeDefinition(SQLServerConnection con, TDSReader tdsReader) throws SQ
12671215
return typeDefinition;
12681216
}
12691217

1270-
void sendByRPC(TDSWriter tdsWriter, boolean callRPCDirectly,
1271-
SQLServerStatement statement) throws SQLServerException {
1218+
void sendByRPC(TDSWriter tdsWriter, SQLServerStatement statement) throws SQLServerException {
12721219
assert null != inputDTV : "Parameter was neither set nor registered";
12731220
SQLServerConnection conn = statement.connection;
12741221

12751222
try {
1276-
inputDTV.isNonPLP = isNonPLP;
12771223
inputDTV.sendCryptoMetaData(this.cryptoMeta, tdsWriter);
12781224
inputDTV.setJdbcTypeSetByUser(getJdbcTypeSetByUser(), getValueLength());
1279-
inputDTV.sendByRPC(callRPCDirectly ? name : null, null, conn.getDatabaseCollation(), valueLength,
1280-
isOutput() ? outScale : scale, isOutput(), tdsWriter, statement);
1225+
inputDTV.sendByRPC(name, null, conn.getDatabaseCollation(), valueLength, isOutput() ? outScale : scale,
1226+
isOutput(), tdsWriter, statement);
12811227
} finally {
12821228
// reset the cryptoMeta in IOBuffer
12831229
inputDTV.sendCryptoMetaData(null, tdsWriter);

src/main/java/com/microsoft/sqlserver/jdbc/SQLServerBulkCopy.java

+5-6
Original file line numberDiff line numberDiff line change
@@ -2064,8 +2064,7 @@ private void writeNullToTdsWriter(TDSWriter tdsWriter, int srcJdbcType,
20642064

20652065
private void writeColumnToTdsWriter(TDSWriter tdsWriter, int bulkPrecision, int bulkScale, int bulkJdbcType,
20662066
boolean bulkNullable, // should it be destNullable instead?
2067-
int srcColOrdinal, int destColOrdinal, boolean isStreaming, Object colValue,
2068-
Calendar cal) throws SQLServerException {
2067+
int srcColOrdinal, int destColOrdinal, boolean isStreaming, Object colValue, Calendar cal) throws SQLServerException {
20692068
SSType destSSType = destColumnMetadata.get(destColOrdinal).ssType;
20702069

20712070
bulkPrecision = validateSourcePrecision(bulkPrecision, bulkJdbcType,
@@ -2988,8 +2987,8 @@ private Object readColumnFromResultSet(int srcColOrdinal, int srcJdbcType, boole
29882987
/**
29892988
* Reads the given column from the result set current row and writes the data to tdsWriter.
29902989
*/
2991-
private void writeColumn(TDSWriter tdsWriter, int srcColOrdinal, int destColOrdinal, Object colValue,
2992-
Calendar cal) throws SQLServerException {
2990+
private void writeColumn(TDSWriter tdsWriter, int srcColOrdinal, int destColOrdinal,
2991+
Object colValue, Calendar cal) throws SQLServerException {
29932992
String destName = destColumnMetadata.get(destColOrdinal).columnName;
29942993
int srcPrecision, srcScale, destPrecision, srcJdbcType;
29952994
SSType destSSType = null;
@@ -3641,8 +3640,8 @@ private boolean writeBatchData(TDSWriter tdsWriter, TDSCommand command,
36413640
// Loop for each destination column. The mappings is a many to one mapping
36423641
// where multiple source columns can be mapped to one destination column.
36433642
for (ColumnMapping columnMapping : columnMappings) {
3644-
writeColumn(tdsWriter, columnMapping.sourceColumnOrdinal, columnMapping.destinationColumnOrdinal,
3645-
null, null // cell
3643+
writeColumn(tdsWriter, columnMapping.sourceColumnOrdinal, columnMapping.destinationColumnOrdinal, null,
3644+
null // cell
36463645
// value is
36473646
// retrieved
36483647
// inside

0 commit comments

Comments
 (0)