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
12 changes: 6 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ allprojects {

test {
useJUnitPlatform {
excludeTags (hasProperty('excludedGroups') ? excludedGroups : 'xSQLv15','xGradle','reqExternalSetup','NTLM','MSI','clientCertAuth','fedAuth','kerberos','vectorTest','JSONTest')
excludeTags (hasProperty('excludedGroups') ? excludedGroups : 'xSQLv15','xGradle','reqExternalSetup','NTLM','MSI','clientCertAuth','fedAuth','kerberos','vectorTest','JSONTest','vectorFloat16Test')
}
}

Expand All @@ -50,7 +50,7 @@ if (!hasProperty('buildProfile') || (hasProperty('buildProfile') && buildProfile
}
test {
useJUnitPlatform {
excludeTags(hasProperty('excludedGroups') ? excludedGroups : 'vectorTest','JSONTest')
excludeTags(hasProperty('excludedGroups') ? excludedGroups : 'vectorTest','JSONTest','vectorFloat16Test')
}
}
}
Expand All @@ -70,7 +70,7 @@ if (hasProperty('buildProfile') && buildProfile == "jre21") {
}
test {
useJUnitPlatform {
excludeTags(hasProperty('excludedGroups') ? excludedGroups : 'vectorTest','JSONTest')
excludeTags(hasProperty('excludedGroups') ? excludedGroups : 'vectorTest','JSONTest','vectorFloat16Test')
}
}
}
Expand All @@ -90,7 +90,7 @@ if (hasProperty('buildProfile') && buildProfile == "jre17") {
}
test {
useJUnitPlatform {
excludeTags(hasProperty('excludedGroups') ? excludedGroups : 'vectorTest','JSONTest')
excludeTags(hasProperty('excludedGroups') ? excludedGroups : 'vectorTest','JSONTest','vectorFloat16Test')
}
}
}
Expand All @@ -110,7 +110,7 @@ if (hasProperty('buildProfile') && buildProfile == "jre11") {
}
test {
useJUnitPlatform {
excludeTags(hasProperty('excludedGroups') ? excludedGroups : 'vectorTest','JSONTest')
excludeTags(hasProperty('excludedGroups') ? excludedGroups : 'vectorTest','JSONTest','vectorFloat16Test')
}
}
}
Expand All @@ -127,7 +127,7 @@ if(hasProperty('buildProfile') && buildProfile == "jre8") {

test {
useJUnitPlatform {
excludeTags (hasProperty('excludedGroups') ? excludedGroups : 'xSQLv15','xGradle','NTLM','reqExternalSetup','MSI','clientCertAuth','fedAuth','xJDBC42','vectorTest','JSONTest')
excludeTags (hasProperty('excludedGroups') ? excludedGroups : 'xSQLv15','xGradle','NTLM','reqExternalSetup','MSI','clientCertAuth','fedAuth','xJDBC42','vectorTest','JSONTest','vectorFloat16Test')
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@
kerberos - - - - - For tests using Kerberos authentication (excluded by default)
reqExternalSetup - For tests requiring external setup (excluded by default)
clientCertAuth - - For tests requiring client certificate authentication
vectorTest - - For tests using vector data types (excluded by default)
JSONTest - For tests using JSON data type
vectorTest - - - - For tests using vector data types (excluded by default)
JSONTest - - - - - For tests using JSON data type
vectorFloat16Test - For tests using vector(float16) data type
setup (excluded by default) - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Default testing enabled with SQL Server 2019 (SQLv15) -->
<excludedGroups>xSQLv12,xSQLv15,NTLM,MSI,reqExternalSetup,clientCertAuth,fedAuth,kerberos,vectorTest,JSONTest</excludedGroups>
<excludedGroups>xSQLv12,xSQLv15,NTLM,MSI,reqExternalSetup,clientCertAuth,fedAuth,kerberos,vectorTest,JSONTest,vectorFloat16Test</excludedGroups>
<!-- Use -preview for preview release, leave empty for official release. -->
<releaseExt>-preview</releaseExt>
<!-- Driver Dependencies -->
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/com/microsoft/sqlserver/jdbc/IOBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,11 @@ final class TDS {

// Vector support
static final byte TDS_FEATURE_EXT_VECTORSUPPORT = 0x0E;
static final byte VECTORSUPPORT_NOT_SUPPORTED = 0x00;
static final byte MAX_VECTORSUPPORT_VERSION = 0x01;
static final byte VECTORSUPPORT_NOT_SUPPORTED = 0x00; // vector not supported; will return json formatted string
static final byte VECTORSUPPORT_VERSION_1 = 0x01; // supports float32 vector type
static final byte VECTORSUPPORT_VERSION_2 = 0x02; // supports float32 and float16 vector types
static final byte MAX_VECTORSUPPORT_VERSION = 0x02;

// JSON support
static final byte TDS_FEATURE_EXT_JSONSUPPORT = 0x0D;
static final byte JSONSUPPORT_NOT_SUPPORTED = 0x00;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,10 @@ CallableStatement prepareCall(String sql, int nType, int nConcur, int nHold,
*
* @param vectorTypeSupport
* A string that indicates the vector type support during connection initialization.
* Valid values are "off" (vector types are returned as strings) and "v1" (vectors of type FLOAT32 are returned as vectors).
* Valid values are :
* - "off" (vector types are returned as strings)
* - "v1" (supports float32 vector type)
* - "v2" (supports float32 and float16 vector types)
* Default is "v1".
*/
void setVectorTypeSupport(String vectorTypeSupport);
Expand All @@ -667,7 +670,7 @@ CallableStatement prepareCall(String sql, int nType, int nConcur, int nHold,
* Returns the value of the vectorTypeSupport connection property.
*
* @return vectorTypeSupport
* The current vector type support setting ("off" or "v1").
* The current vector type support setting ("off"|"v1"|"v2").
*/
String getVectorTypeSupport();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,10 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource {
*
* @param vectorTypeSupport
* A string that indicates the vector type support during connection initialization.
* Valid values are "off" (vector types are returned as strings) and "v1" (vectors of type FLOAT32 are returned as vectors).
* Valid values are :
* - "off" (vector types are returned as strings)
* - "v1" (supports float32 vector type)
* - "v2" (supports float32 and float16 vector types)
* Default is "v1".
*/
void setVectorTypeSupport(String vectorTypeSupport);
Expand All @@ -1099,7 +1102,7 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource {
* Returns the value of the vectorTypeSupport connection property.
*
* @return vectorTypeSupport
* The current vector type support setting ("off" or "v1").
* The current vector type support setting ("off"|"v1"|"v2").
*/
String getVectorTypeSupport();

Expand Down
83 changes: 62 additions & 21 deletions src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -762,9 +762,6 @@ private ActiveDirectoryAuthentication() {
}
}

private static final String VECTOR_SUPPORT_OFF = "off";
private static final String VECTOR_SUPPORT_V1 = "v1";

final static int TNIR_FIRST_ATTEMPT_TIMEOUT_MS = 500; // fraction of timeout to use for fast failover connections

/**
Expand Down Expand Up @@ -1105,16 +1102,26 @@ public void setBulkCopyForBatchInsertAllowEncryptedValueModifications(

/**
* A string that indicates the vector type support during connection initialization.
* Valid values are "off" (vector types are returned as strings) and "v1" (vectors of type FLOAT32 are returned as vectors).
* Valid values are :
* - "off" (vector types are returned as strings)
* - "v1" (supports float32 vector type)
* - "v2" (supports float32 and float16 vector types)
* Default is "v1".
*/
private String vectorTypeSupport = VECTOR_SUPPORT_V1;
private String vectorTypeSupport = SQLServerDriverStringProperty.VECTOR_TYPE_SUPPORT.getDefaultValue();

private VectorTypeSupport vectorTypeSupportEnum = VectorTypeSupport.V1;

/**
* Negotiated vector version between client and server
*/
private byte negotiatedVectorVersion = TDS.VECTORSUPPORT_NOT_SUPPORTED;

/**
* Returns the value of the vectorTypeSupport connection property.
*
* @return vectorTypeSupport
* The current vector type support setting ("off" or "v1").
* The current vector type support setting ("off"|"v1"|"v2").
*/
@Override
public String getVectorTypeSupport() {
Expand All @@ -1126,7 +1133,10 @@ public String getVectorTypeSupport() {
*
* @param vectorTypeSupport
* A string that indicates the vector type support during connection initialization.
* Valid values are "off" (vector types are returned as strings) and "v1" (vectors of type FLOAT32 are returned as vectors).
* Valid values are :
* - "off" (vector types are returned as strings)
* - "v1" (supports float32 vector type)
* - "v2" (supports float32 and float16 vector types)
* Default is "v1".
*/
@Override
Expand All @@ -1136,15 +1146,14 @@ public void setVectorTypeSupport(String vectorTypeSupport) {
Object[] msgArgs = { "null" };
throw new IllegalArgumentException(form.format(msgArgs));
}
switch (vectorTypeSupport.trim().toLowerCase()) {
case VECTOR_SUPPORT_OFF:
case VECTOR_SUPPORT_V1:
this.vectorTypeSupport = vectorTypeSupport.toLowerCase();
break;
default:
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_invalidVectorTypeSupport"));
Object[] msgArgs = { vectorTypeSupport };
throw new IllegalArgumentException(form.format(msgArgs));
String normalizedValue = vectorTypeSupport.trim().toLowerCase(Locale.US);
try {
this.vectorTypeSupportEnum = VectorTypeSupport.valueOfString(normalizedValue);
this.vectorTypeSupport = normalizedValue;
} catch (SQLServerException e) {
MessageFormat form = new MessageFormat(SQLServerException.getErrString("R_invalidVectorTypeSupport"));
Object[] msgArgs = { normalizedValue };
throw new IllegalArgumentException(form.format(msgArgs));
}
}

Expand Down Expand Up @@ -5899,14 +5908,23 @@ int writeUserAgentFeatureRequest(boolean write, /* if false just calculates the
*/
int writeVectorSupportFeatureRequest(boolean write,
TDSWriter tdsWriter) throws SQLServerException {
if (VECTOR_SUPPORT_OFF.equalsIgnoreCase(vectorTypeSupport)) {

// Initialize vectorTypeSupportEnum if not already done.
if (vectorTypeSupportEnum == null) {
vectorTypeSupportEnum = VectorTypeSupport.valueOfString(vectorTypeSupport);
}

if (vectorTypeSupportEnum == VectorTypeSupport.OFF) {
return 0;
}

int len = 6; // 1byte = featureID, 4bytes = featureData length, 1 bytes = Version
if (write) {
tdsWriter.writeByte(TDS.TDS_FEATURE_EXT_VECTORSUPPORT);
tdsWriter.writeInt(1);
tdsWriter.writeByte(TDS.MAX_VECTORSUPPORT_VERSION);

// write the vector type support version
tdsWriter.writeByte(vectorTypeSupportEnum.getTdsValue());
}
return len;
}
Expand Down Expand Up @@ -7107,18 +7125,29 @@ private void onFeatureExtAck(byte featureId, byte[] data) throws SQLServerExcept

case TDS.TDS_FEATURE_EXT_VECTORSUPPORT: {
if (connectionlogger.isLoggable(Level.FINE)) {
connectionlogger.fine(toString() + " Received feature extension acknowledgement for vector support. Received byte: " + data[0]);
connectionlogger.fine(
toString() + " Received feature extension acknowledgement for Vector Support.");
}

if (1 != data.length) {
throw new SQLServerException(SQLServerException.getErrString("R_unknownVectorSupportValue"), null);
}

// The server's FEATUREEXTACK response already contains the negotiated version
// (i.e. min(clientRequested, serverMax)), so we accept data[0] directly
// as the negotiated version — no client-side re-negotiation needed.
serverSupportedVectorVersion = data[0];
if (0 == serverSupportedVectorVersion || serverSupportedVectorVersion > TDS.MAX_VECTORSUPPORT_VERSION) {
negotiatedVectorVersion = data[0];
if (0 == negotiatedVectorVersion || negotiatedVectorVersion > TDS.MAX_VECTORSUPPORT_VERSION) {
throw new SQLServerException(SQLServerException.getErrString("R_InvalidVectorVersionNumber"), null);
}
serverSupportsVector = true;

serverSupportsVector = (negotiatedVectorVersion > TDS.VECTORSUPPORT_NOT_SUPPORTED);

if (connectionlogger.isLoggable(Level.FINE)) {
connectionlogger.fine(toString() + " Vector support negotiated. Client requested: " + vectorTypeSupport +
", Negotiated version: " + negotiatedVectorVersion);
}
break;
}

Expand Down Expand Up @@ -7154,6 +7183,17 @@ private void onFeatureExtAck(byte featureId, byte[] data) throws SQLServerExcept
}
}

/**
* Returns the negotiated vector version between client and server.
* Returns 0 if vectorTypeSupport is 'off' or the server did not acknowledge vector support.
* Valid negotiated values from the server are 1 (v1) or 2 (v2).
*
* @return The negotiated vector version (0 = not negotiated, 1 = v1, 2 = v2)
*/
public byte getNegotiatedVectorVersion() {
return negotiatedVectorVersion;
}

/*
* Executes a DTC command
*/
Expand Down Expand Up @@ -7452,6 +7492,7 @@ final boolean complete(LogonCommand logonCommand, TDSReader tdsReader) throws SQ

// request vector support
len += writeVectorSupportFeatureRequest(false, tdsWriter);

// request JSON support
len += writeJSONSupportFeatureRequest(false, tdsWriter);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -893,19 +893,25 @@ public void setBulkCopyForBatchInsertAllowEncryptedValueModifications(boolean bu
}

/**
* Returns the vectorTypeSupport value.
* Returns the value of the vectorTypeSupport connection property.
*
* @return the vectorTypeSupport value.
* @return vectorTypeSupport
* The current vector type support setting ("off"|"v1"|"v2").
*/
public String getVectorTypeSupport() {
return wrappedConnection.getVectorTypeSupport();
}

/**
* Sets the vectorTypeSupport value.
* Sets the value of the vectorTypeSupport connection property.
*
* @param vectorTypeSupport
* the vectorTypeSupport value to set ("off" or "v1").
* A string that indicates the vector type support during connection initialization.
* Valid values are :
* - "off" (vector types are returned as strings)
* - "v1" (supports float32 vector type)
* - "v2" (supports float32 and float16 vector types)
* Default is "v1".
*/
public void setVectorTypeSupport(String vectorTypeSupport) {
wrappedConnection.setVectorTypeSupport(vectorTypeSupport);
Expand Down
Loading
Loading