Skip to content

Commit 4c6227a

Browse files
authored
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 25ed577 commit 4c6227a

21 files changed

+466
-1984
lines changed

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

Lines changed: 7 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,6 @@ static final String getEncryptionLevel(int level) {
467467
final static int COLINFO_STATUS_DIFFERENT_NAME = 0x20;
468468

469469
final static int MAX_FRACTIONAL_SECONDS_SCALE = 7;
470-
final static int DEFAULT_FRACTIONAL_SECONDS_SCALE = 3;
471470

472471
final static Timestamp MAX_TIMESTAMP = Timestamp.valueOf("2079-06-06 23:59:59");
473472
final static Timestamp MIN_TIMESTAMP = Timestamp.valueOf("1900-01-01 00:00:00");
@@ -4854,7 +4853,7 @@ void writeVMaxHeader(long headerLength, boolean isNull, SQLCollation collation)
48544853
* Utility for internal writeRPCString calls
48554854
*/
48564855
void writeRPCStringUnicode(String sValue) throws SQLServerException {
4857-
writeRPCStringUnicode(null, sValue, false, null, false);
4856+
writeRPCStringUnicode(null, sValue, false, null);
48584857
}
48594858

48604859
/**
@@ -4869,8 +4868,8 @@ void writeRPCStringUnicode(String sValue) throws SQLServerException {
48694868
* @param collation
48704869
* the collation of the data value
48714870
*/
4872-
void writeRPCStringUnicode(String sName, String sValue, boolean bOut, SQLCollation collation,
4873-
boolean isNonPLP) throws SQLServerException {
4871+
void writeRPCStringUnicode(String sName, String sValue, boolean bOut,
4872+
SQLCollation collation) throws SQLServerException {
48744873
boolean bValueNull = (sValue == null);
48754874
int nValueLen = bValueNull ? 0 : (2 * sValue.length());
48764875
// Textual RPC requires a collation. If none is provided, as is the case when
@@ -4882,7 +4881,7 @@ void writeRPCStringUnicode(String sName, String sValue, boolean bOut, SQLCollati
48824881
* Use PLP encoding if either OUT params were specified or if the user query exceeds
48834882
* DataTypes.SHORT_VARTYPE_MAX_BYTES
48844883
*/
4885-
if ((nValueLen > DataTypes.SHORT_VARTYPE_MAX_BYTES || bOut) && !isNonPLP) {
4884+
if (nValueLen > DataTypes.SHORT_VARTYPE_MAX_BYTES || bOut) {
48864885
writeRPCNameValType(sName, bOut, TDSType.NVARCHAR);
48874886

48884887
writeVMaxHeader(nValueLen, // Length
@@ -5633,8 +5632,8 @@ void writeCryptoMetaData() throws SQLServerException {
56335632
writeByte(cryptoMeta.normalizationRuleVersion);
56345633
}
56355634

5636-
void writeRPCByteArray(String sName, byte[] bValue, boolean bOut, JDBCType jdbcType, SQLCollation collation,
5637-
boolean isNonPLP) throws SQLServerException {
5635+
void writeRPCByteArray(String sName, byte[] bValue, boolean bOut, JDBCType jdbcType,
5636+
SQLCollation collation) throws SQLServerException {
56385637
boolean bValueNull = (bValue == null);
56395638
int nValueLen = bValueNull ? 0 : bValue.length;
56405639
boolean isShortValue = (nValueLen <= DataTypes.SHORT_VARTYPE_MAX_BYTES);
@@ -5680,7 +5679,7 @@ void writeRPCByteArray(String sName, byte[] bValue, boolean bOut, JDBCType jdbcT
56805679

56815680
writeRPCNameValType(sName, bOut, tdsType);
56825681

5683-
if (usePLP && !isNonPLP) {
5682+
if (usePLP) {
56845683
writeVMaxHeader(nValueLen, bValueNull, collation);
56855684

56865685
// Send the data.
@@ -7059,35 +7058,6 @@ final short peekStatusFlag() {
70597058
return 0;
70607059
}
70617060

7062-
final int peekReturnValueStatus() throws SQLServerException {
7063-
// Ensure that we have a packet to read from.
7064-
if (!ensurePayload()) {
7065-
throwInvalidTDS();
7066-
}
7067-
7068-
// In order to parse the 'status' value, we need to skip over the following properties in the TDS packet
7069-
// payload: TDS token type (1 byte value), ordinal/length (2 byte value), parameter name length value (1 byte value) and
7070-
// the number of bytes that make the parameter name (need to be calculated).
7071-
//
7072-
// 'offset' starts at 4 because tdsTokenType + ordinal/length + parameter name length value is 4 bytes. So, we
7073-
// skip 4 bytes immediateley.
7074-
int offset = 4;
7075-
int paramNameLength = currentPacket.payload[payloadOffset + 3];
7076-
7077-
// Check if parameter name is set. If it's set, it should be > 0. In which case, we add the
7078-
// additional bytes to skip.
7079-
if (paramNameLength > 0) {
7080-
// Each character in unicode is 2 bytes
7081-
offset += 2 * paramNameLength;
7082-
}
7083-
7084-
if (payloadOffset + offset <= currentPacket.payloadLength) {
7085-
return currentPacket.payload[payloadOffset + offset] & 0xFF;
7086-
}
7087-
7088-
return -1;
7089-
}
7090-
70917061
final int readUnsignedByte() throws SQLServerException {
70927062
// Ensure that we have a packet to read from.
70937063
if (!ensurePayload())

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

Lines changed: 23 additions & 19 deletions
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
*
@@ -1365,4 +1346,27 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource {
13651346
* @return cacheBulkCopyMetadata boolean value
13661347
*/
13671348
boolean getcacheBulkCopyMetadata();
1349+
1350+
/**
1351+
* useFlexibleCallableStatements is temporarily removed. This is meant as a no-op.
1352+
*
1353+
* Sets whether or not sp_sproc_columns will be used for parameter name lookup.
1354+
*
1355+
* @param useFlexibleCallableStatements
1356+
* When set to false, sp_sproc_columns is not used for parameter name lookup
1357+
* in callable statements. This eliminates a round trip to the server but imposes limitations
1358+
* on how parameters are set. When set to false, applications must either reference
1359+
* parameters by name or by index, not both. Parameters must also be set in the same
1360+
* order as the stored procedure definition.
1361+
*/
1362+
void setUseFlexibleCallableStatements(boolean useFlexibleCallableStatements);
1363+
1364+
/**
1365+
* useFlexibleCallableStatements is temporarily removed. This is meant as a no-op.
1366+
*
1367+
* Returns whether or not sp_sproc_columns is being used for parameter name lookup.
1368+
*
1369+
* @return useFlexibleCallableStatements
1370+
*/
1371+
boolean getUseFlexibleCallableStatements();
13681372
}

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

Lines changed: 11 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ final class Parameter {
3838
// For unencrypted parameters cryptometa will be null. For encrypted parameters it will hold encryption metadata.
3939
CryptoMetadata cryptoMeta = null;
4040

41-
boolean isNonPLP = false;
42-
4341
TypeInfo getTypeInfo() {
4442
return typeInfo;
4543
}
@@ -51,7 +49,6 @@ final CryptoMetadata getCryptoMetadata() {
5149
private boolean shouldHonorAEForParameter = false;
5250
private boolean userProvidesPrecision = false;
5351
private boolean userProvidesScale = false;
54-
private boolean isReturnValue = false;
5552

5653
// The parameter type definition
5754
private String typeDefinition = null;
@@ -74,49 +71,11 @@ boolean isOutput() {
7471
return null != registeredOutDTV;
7572
}
7673

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

12281
/**
@@ -128,13 +87,6 @@ DTV getInputDTV() {
12887
return this.inputDTV;
12988
}
13089

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

307-
getterDTV.setValue(null, this.getJdbcType(), returnStatus, JavaType.INTEGER, null, null, null, con,
259+
getterDTV.setValue(null, JDBCType.INTEGER, returnStatus, JavaType.INTEGER, null, null, null, con,
308260
getForceEncryption());
309261
}
310262

@@ -445,14 +397,10 @@ boolean isValueGotten() {
445397

446398
Object getValue(JDBCType jdbcType, InputStreamGetterArgs getterArgs, Calendar cal, TDSReader tdsReader,
447399
SQLServerStatement statement) throws SQLServerException {
448-
if (null == getterDTV) {
400+
if (null == getterDTV)
449401
getterDTV = new DTV();
450-
}
451-
452-
if (null != tdsReader) {
453-
deriveTypeInfo(tdsReader);
454-
}
455402

403+
deriveTypeInfo(tdsReader);
456404
// If the parameter is not encrypted or column encryption is turned off (either at connection or
457405
// statement level), cryptoMeta would be null.
458406
return getterDTV.getValue(jdbcType, outScale, getterArgs, cal, typeInfo, cryptoMeta, tdsReader, statement);
@@ -1272,17 +1220,15 @@ String getTypeDefinition(SQLServerConnection con, TDSReader tdsReader) throws SQ
12721220
return typeDefinition;
12731221
}
12741222

1275-
void sendByRPC(TDSWriter tdsWriter, boolean callRPCDirectly,
1276-
SQLServerStatement statement) throws SQLServerException {
1223+
void sendByRPC(TDSWriter tdsWriter, SQLServerStatement statement) throws SQLServerException {
12771224
assert null != inputDTV : "Parameter was neither set nor registered";
12781225
SQLServerConnection conn = statement.connection;
12791226

12801227
try {
1281-
inputDTV.isNonPLP = isNonPLP;
12821228
inputDTV.sendCryptoMetaData(this.cryptoMeta, tdsWriter);
12831229
inputDTV.setJdbcTypeSetByUser(getJdbcTypeSetByUser(), getValueLength());
1284-
inputDTV.sendByRPC(callRPCDirectly ? name : null, null, conn.getDatabaseCollation(), valueLength,
1285-
isOutput() ? outScale : scale, isOutput(), tdsWriter, statement);
1230+
inputDTV.sendByRPC(name, null, conn.getDatabaseCollation(), valueLength, isOutput() ? outScale : scale,
1231+
isOutput(), tdsWriter, statement);
12861232
} finally {
12871233
// reset the cryptoMeta in IOBuffer
12881234
inputDTV.sendCryptoMetaData(null, tdsWriter);

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2129,8 +2129,7 @@ private void writeNullToTdsWriter(TDSWriter tdsWriter, int srcJdbcType,
21292129

21302130
private void writeColumnToTdsWriter(TDSWriter tdsWriter, int bulkPrecision, int bulkScale, int bulkJdbcType,
21312131
boolean bulkNullable, // should it be destNullable instead?
2132-
int srcColOrdinal, int destColOrdinal, boolean isStreaming, Object colValue,
2133-
Calendar cal) throws SQLServerException {
2132+
int srcColOrdinal, int destColOrdinal, boolean isStreaming, Object colValue, Calendar cal) throws SQLServerException {
21342133
SSType destSSType = destColumnMetadata.get(destColOrdinal).ssType;
21352134

21362135
bulkPrecision = validateSourcePrecision(bulkPrecision, bulkJdbcType,
@@ -3047,8 +3046,8 @@ private Object readColumnFromResultSet(int srcColOrdinal, int srcJdbcType, boole
30473046
/**
30483047
* Reads the given column from the result set current row and writes the data to tdsWriter.
30493048
*/
3050-
private void writeColumn(TDSWriter tdsWriter, int srcColOrdinal, int destColOrdinal, Object colValue,
3051-
Calendar cal) throws SQLServerException {
3049+
private void writeColumn(TDSWriter tdsWriter, int srcColOrdinal, int destColOrdinal,
3050+
Object colValue, Calendar cal) throws SQLServerException {
30523051
String destName = destColumnMetadata.get(destColOrdinal).columnName;
30533052
int srcPrecision, srcScale, destPrecision, srcJdbcType;
30543053
SSType destSSType = null;
@@ -3700,8 +3699,8 @@ private boolean writeBatchData(TDSWriter tdsWriter, TDSCommand command,
37003699
// Loop for each destination column. The mappings is a many to one mapping
37013700
// where multiple source columns can be mapped to one destination column.
37023701
for (ColumnMapping columnMapping : columnMappings) {
3703-
writeColumn(tdsWriter, columnMapping.sourceColumnOrdinal, columnMapping.destinationColumnOrdinal,
3704-
null, null // cell
3702+
writeColumn(tdsWriter, columnMapping.sourceColumnOrdinal, columnMapping.destinationColumnOrdinal, null,
3703+
null // cell
37053704
// value is
37063705
// retrieved
37073706
// inside

0 commit comments

Comments
 (0)