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
26 changes: 26 additions & 0 deletions doc/snippets/Microsoft.Data.SqlClient/SqlDataReader.xml
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ No conversions are performed; therefore. the data retrieved must already be a ch
<item><description>SqlMoney</description></item>
<item><description>SqlSingle</description></item>
<item><description>SqlString</description></item>
<item><description>SqlVectorFloat32</description></item>
<item><description>Stream</description></item>
<item><description>String</description></item>
<item><description>TextReader</description></item>
Expand Down Expand Up @@ -489,6 +490,7 @@ No conversions are performed; therefore. the data retrieved must already be a ch
<item><description>SqlMoney</description></item>
<item><description>SqlSingle</description></item>
<item><description>SqlString</description></item>
<item><description>SqlVectorFloat32</description></item>
<item><description>Stream</description></item>
<item><description>String</description></item>
<item><description>TextReader</description></item>
Expand Down Expand Up @@ -958,7 +960,31 @@ The <xref:Microsoft.Data.SqlClient.SqlDataReader.GetSchemaTable%2A> method retur
<param name="i"></param>
<summary>Gets the value of the specified column as a <see cref="T:Microsoft.Data.SqlTypes.SqlJson"/>.</summary>
<returns>A <see cref="T:Microsoft.Data.SqlTypes.SqlJson"/> object representing the column at the given ordinal.</returns>
<remarks>
No conversions are performed; therefore, the data retrieved must already be a JSON string, or an exception is generated.
</remarks>
</GetSqlJson>
<GetSqlVectorFloat32>
<param name="i"></param>
<summary>
Gets the value of the specified column as a <see cref="T:Microsoft.Data.SqlTypes.SqlVectorFloat32"/>.
</summary>
<returns>
A <see cref="T:Microsoft.Data.SqlTypes.SqlVectorFloat32"/> object representing the column at the given ordinal.
</returns>
<exception cref="T:System.ArgumentOutOfRangeException">
The index passed was outside the range of 0 to <see cref="P:System.Data.DataTableReader.FieldCount" /> - 1
</exception>
<exception cref="T:System.InvalidOperationException">
An attempt was made to read or access columns in a closed <see cref="T:Microsoft.Data.SqlClient.SqlDataReader" />.
</exception>
<exception cref="T:System.InvalidCastException">
The retrieved data is not compatible with the <see cref="T:Microsoft.Data.SqlTypes.SqlVectorFloat32" /> type.
</exception>
<remarks>
No conversions are performed; therefore, the data retrieved must already be a vector value, or an exception is generated.
</remarks>
</GetSqlVectorFloat32>
<GetSqlMoney>
<param name="i">
The zero-based column ordinal.
Expand Down
56 changes: 56 additions & 0 deletions doc/snippets/Microsoft.Data.SqlTypes/SqlVectorFloat32.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0"?>
<docs>
<members name="SqlVectorFloat32">
<SqlVectorFloat32>
<summary>Represents the 32-bit float vector datatype in SQL Server.</summary>
</SqlVectorFloat32>
<ctor1>
<param name="length"></param>
<summary>
Constructs a null vector of the given length. SQL Server requires vector arguments to specify their length even when null.
</summary>
<exception cref="T:System.ArgumentOutOfRangeException">
Vector column length must be non-negative.
</exception>
</ctor1>
<ctor2>
<param name="values"></param>
<summary>
Constructs a vector with the given values.
</summary>
</ctor2>
<IsNull>
<inheritdoc/>
</IsNull>
<Null>
<summary>
Represents a null instance of the <see cref="SqlVectorFloat32"/> type without any attributes.
</summary>
<remarks>
This is equivalent to the C# <c>null</c> value.
</remarks>
</Null>
<Length>
<summary>
Returns the number of elements in the vector.
</summary>
</Length>
<Size>
<summary>
Returns the number of bytes required to represent this vector when communicating with SQL Server.
</summary>
</Size>
<Values>
<summary>Returns the vector values as a memory region. No copies are made.</summary>
<returns>An array of float32 values as <see cref="T:System.ReadOnlyMemory{System.Single}"/> value.</returns>
</Values>
<ToString>
<summary>Returns a JSON string representation of the vector. A new string is generated each time you call this method.</summary>
<returns>A JSON <see cref="T:System.String"/> value.</returns>
</ToString>
<ToArray>
<summary>Returns the vector values as an array of floats.</summary>
<returns>An array of <see cref="T:System.String"/> values.</returns>
</ToArray>
</members>
</docs>
8 changes: 8 additions & 0 deletions doc/snippets/Microsoft.Data/SqlDbTypeExtensions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,13 @@ The <xref:Microsoft.Data.SqlDbTypeExtensions> class provides <xref:System.Data.S
<see cref="T:System.Data.SqlDbType" /> enum value for JSON datatype.
</returns>
</SqlJson>
<SqlVector name="default">
<summary>
Gets the <see cref="T:System.Data.SqlDbType" /> enum value for the vector datatype.
</summary>
<returns>
<see cref="T:System.Data.SqlDbType" /> enum value for vector datatype.
</returns>
</SqlVector>
</members>
</docs>
1 change: 1 addition & 0 deletions src/Microsoft.Data.SqlClient.sln
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Microsoft.Data.SqlTypes", "
ProjectSection(SolutionItems) = preProject
..\doc\snippets\Microsoft.Data.SqlTypes\SqlFileStream.xml = ..\doc\snippets\Microsoft.Data.SqlTypes\SqlFileStream.xml
..\doc\snippets\Microsoft.Data.SqlTypes\SqlJson.xml = ..\doc\snippets\Microsoft.Data.SqlTypes\SqlJson.xml
..\doc\snippets\Microsoft.Data.SqlTypes\SqlVectorFloat32.xml = ..\doc\snippets\Microsoft.Data.SqlTypes\SqlVectorFloat32.xml
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Data.SqlClient.TestUtilities", "Microsoft.Data.SqlClient\tests\tools\Microsoft.Data.SqlClient.TestUtilities\Microsoft.Data.SqlClient.TestUtilities.csproj", "{89D6D382-9B36-43C9-A912-03802FDA8E36}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public static class SqlDbTypeExtensions
{
/// <include file='../../../../doc/snippets/Microsoft.Data/SqlDbTypeExtensions.xml' path='docs/members[@name="SqlDbTypeExtensions"]/SqlJson[@name="default"]' />
public const System.Data.SqlDbType Json = (System.Data.SqlDbType)35;
/// <include file='../../../../doc/snippets/Microsoft.Data/SqlDbTypeExtensions.xml' path='docs/members[@name="SqlDbTypeExtensions"]/SqlVector[@name="default"]' />
public const System.Data.SqlDbType Vector = (System.Data.SqlDbType)36;
}
}

Expand Down Expand Up @@ -119,6 +121,29 @@ public SqlJson(System.Text.Json.JsonDocument jsonDoc) { }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlJson.xml' path='docs/members[@name="SqlJson"]/ToString/*' />
public override string ToString() { throw null; }
}

/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlVectorFloat32.xml' path='docs/members[@name="SqlVectorFloat32"]/SqlVectorFloat32/*' />
public sealed class SqlVectorFloat32 : System.Data.SqlTypes.INullable
{
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlVectorFloat32.xml' path='docs/members[@name="SqlVectorFloat32"]/ctor1/*' />
public SqlVectorFloat32(int length) { }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlVectorFloat32.xml' path='docs/members[@name="SqlVectorFloat32"]/ctor2/*' />
public SqlVectorFloat32(System.ReadOnlyMemory<float> values) { }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlVectorFloat32.xml' path='docs/members[@name="SqlVectorFloat32"]/IsNull/*' />
public bool IsNull => throw null;
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlVectorFloat32.xml' path='docs/members[@name="SqlVectorFloat32"]/Null/*' />
public static SqlVectorFloat32 Null => throw null;
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlVectorFloat32.xml' path='docs/members[@name="SqlVectorFloat32"]/Length/*' />
public int Length { get { throw null; } }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlVectorFloat32.xml' path='docs/members[@name="SqlVectorFloat32"]/Size/*' />
public int Size { get { throw null; } }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlVectorFloat32.xml' path='docs/members[@name="SqlVectorFloat32"]/Values/*' />
public System.ReadOnlyMemory<float> Values { get { throw null; } }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlVectorFloat32.xml' path='docs/members[@name="SqlVectorFloat32"]/ToString/*' />
public override string ToString() { throw null; }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlVectorFloat32.xml' path='docs/members[@name="SqlVectorFloat32"]/ToArray/*' />
public float[] ToArray() { throw null; }
}
}
namespace Microsoft.Data.SqlClient
{
Expand Down Expand Up @@ -1370,6 +1395,8 @@ public override void Close() { }
public virtual object GetSqlValue(int i) { throw null; }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlDataReader.xml' path='docs/members[@name="SqlDataReader"]/GetSqlValues/*'/>
public virtual int GetSqlValues(object[] values) { throw null; }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlDataReader.xml' path='docs/members[@name="SqlDataReader"]/GetSqlVectorFloat32/*'/>
public virtual Microsoft.Data.SqlTypes.SqlVectorFloat32 GetSqlVectorFloat32(int i) { throw null; }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlDataReader.xml' path='docs/members[@name="SqlDataReader"]/GetSqlXml/*'/>
public virtual System.Data.SqlTypes.SqlXml GetSqlXml(int i) { throw null; }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlDataReader.xml' path='docs/members[@name="SqlDataReader"]/GetSchemaTable/*'/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,9 @@
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\ValueUtilsSmi.cs">
<Link>Microsoft\Data\SqlClient\Server\ValueUtilsSmi.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\ISqlVector.cs">
<Link>Microsoft\Data\SqlClient\ISqlVector.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\SignatureVerificationCache.cs">
<Link>Microsoft\Data\SqlClient\SignatureVerificationCache.cs</Link>
</Compile>
Expand Down Expand Up @@ -792,6 +795,9 @@
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlTypes\SqlJson.cs">
<Link>Microsoft\Data\SqlTypes\SqlJson.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlTypes\SqlVectorFloat32.cs">
<Link>Microsoft\Data\SqlTypes\SqlVectorFloat32.cs</Link>
</Compile>
<Compile Include="$(CommonSourceRoot)Resources\ResCategoryAttribute.cs">
<Link>Resources\ResCategoryAttribute.cs</Link>
</Compile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6435,6 +6435,16 @@ internal string BuildParamList(TdsParser parser, SqlParameterCollection paramete
paramList.Append(scale);
paramList.Append(')');
}
else if (mt.SqlDbType == SqlDbTypeExtensions.Vector)
{
// The validate function for SqlParameters would
// have already thrown InvalidCastException if an incompatible
// value is specified for SqlDbType Vector.
var sqlVectorProps = (ISqlVector)sqlParam.Value;
paramList.Append('(');
paramList.Append(sqlVectorProps.Length);
paramList.Append(')');
}
else if (!mt.IsFixed && !mt.IsLong && mt.SqlDbType != SqlDbType.Timestamp && mt.SqlDbType != SqlDbType.Udt && SqlDbType.Structured != mt.SqlDbType)
{
int size = sqlParam.Size;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ internal bool IsDNSCachingBeforeRedirectSupported
// Json Support Flag
internal bool IsJsonSupportEnabled = false;

// Vector Support Flag
internal bool IsVectorSupportEnabled = false;

// TCE flags
internal byte _tceVersionSupported;

Expand Down Expand Up @@ -1422,9 +1425,10 @@ private void Login(ServerInfo server, TimeoutTimer timeout, string newPassword,
requestedFeatures |= TdsEnums.FeatureExtension.AzureSQLSupport;
}

// The SQLDNSCaching and JSON features are implicitly set
// The following features are implicitly set
requestedFeatures |= TdsEnums.FeatureExtension.SQLDNSCaching;
requestedFeatures |= TdsEnums.FeatureExtension.JsonSupport;
requestedFeatures |= TdsEnums.FeatureExtension.VectorSupport;

_parser.TdsLogin(login, requestedFeatures, _recoverySessionData, _fedAuthFeatureExtensionData, encrypt);
}
Expand Down Expand Up @@ -3011,6 +3015,24 @@ internal void OnFeatureExtAck(int featureId, byte[] data)
break;
}

case TdsEnums.FEATUREEXT_VECTORSUPPORT:
{
SqlClientEventSource.Log.TryAdvancedTraceEvent("<sc.SqlInternalConnectionTds.OnFeatureExtAck|ADV> {0}, Received feature extension acknowledgement for VECTORSUPPORT", ObjectID);
if (data.Length != 1)
{
SqlClientEventSource.Log.TryTraceEvent("<sc.SqlInternalConnectionTds.OnFeatureExtAck|ERR> {0}, Unknown token for VECTORSUPPORT", ObjectID);
throw SQL.ParsingError(ParsingErrorState.CorruptedTdsStream);
}
byte vectorSupportVersion = data[0];
if (vectorSupportVersion == 0 || vectorSupportVersion > TdsEnums.MAX_SUPPORTED_VECTOR_VERSION)
{
SqlClientEventSource.Log.TryTraceEvent("<sc.SqlInternalConnectionTds.OnFeatureExtAck|ERR> {0}, Invalid version number {1} for VECTORSUPPORT, Max supported version is {2}", ObjectID, vectorSupportVersion, TdsEnums.MAX_SUPPORTED_VECTOR_VERSION);
throw SQL.ParsingError();
}
IsVectorSupportEnabled = true;
break;
}

default:
{
// Unknown feature ack
Expand Down
Loading
Loading