Skip to content

Commit 2633842

Browse files
committed
Merge main
2 parents 92528d3 + a93ff40 commit 2633842

File tree

83 files changed

+2082
-2668
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+2082
-2668
lines changed

doc/snippets/Microsoft.Data.SqlClient/SqlCommand.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3604,7 +3604,9 @@ Before you call <xref:Microsoft.Data.SqlClient.SqlCommand.Prepare%2A>, specify t
36043604
36053605
If you call an `Execute` method after calling <xref:Microsoft.Data.SqlClient.SqlCommand.Prepare%2A>, any parameter value that is larger than the value specified by the <xref:Microsoft.Data.SqlClient.SqlParameter.Size%2A> property is automatically truncated to the original specified size of the parameter, and no truncation errors are returned.
36063606
3607-
Output parameters (whether prepared or not) must have a user-specified data type. If you specify a variable length data type, you must also specify the maximum <xref:Microsoft.Data.SqlClient.SqlParameter.Size%2A>.
3607+
Output parameters (whether prepared or not) must have a user-specified data type. If you specify a variable length data type except vector, you must also specify the maximum <xref:Microsoft.Data.SqlClient.SqlParameter.Size%2A>.
3608+
3609+
For vector data types, the <xref:Microsoft.Data.SqlClient.SqlParameter.Size%2A> property is ignored. The size of the vector is inferred from the <xref:Microsoft.Data.SqlClient.SqlParameter.Value%2A> of type <xref:Microsoft.Data.SqlTypes.SqlVector%2A>.
36083610
36093611
Prior to Visual Studio 2010, <xref:Microsoft.Data.SqlClient.SqlCommand.Prepare%2A> threw an exception. Beginning in Visual Studio 2010, this method does not throw an exception.
36103612

doc/snippets/Microsoft.Data.SqlTypes/SqlVector.xml

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,11 @@
55
<summary>Represents a vector value in SQL Server.</summary>
66
</SqlVector>
77
<ctor1>
8-
<param name="length"></param>
9-
<summary>
10-
Constructs a null vector of the given length. SQL Server requires vector arguments to specify their length even when null.
11-
</summary>
12-
<exception cref="T:System.ArgumentOutOfRangeException">
13-
Vector length must be non-negative.
14-
</exception>
15-
</ctor1>
16-
<ctor2>
178
<param name="memory"></param>
189
<summary>
1910
Constructs a vector with the given values.
2011
</summary>
21-
</ctor2>
12+
</ctor1>
2213
<IsNull>
2314
<inheritdoc/>
2415
</IsNull>
@@ -37,13 +28,17 @@
3728
Returns the number of elements in the vector.
3829
</summary>
3930
</Length>
40-
<Size>
41-
<summary>
42-
Returns the number of bytes required to represent this vector when communicating with SQL Server.
43-
</summary>
44-
</Size>
4531
<Memory>
4632
<summary>Returns the vector values as a memory region. No copies are made.</summary>
4733
</Memory>
34+
<CreateNull>
35+
<param name="length"></param>
36+
<summary>
37+
Constructs a null vector of the given length. SQL Server requires vector arguments to specify their length even when null.
38+
</summary>
39+
<exception cref="T:System.ArgumentOutOfRangeException">
40+
Vector length must be non-negative.
41+
</exception>
42+
</CreateNull>
4843
</members>
4944
</docs>

src/Directory.Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<PackageVersion Include="System.Memory" Version="4.5.5" />
1111
<PackageVersion Include="System.Data.Common" Version="4.3.0" />
1212
<PackageVersion Include="System.Text.Encodings.Web" Version="8.0.0" />
13+
<PackageVersion Include="System.ValueTuple" Version="4.6.1" />
1314
<PackageVersion Include="System.Threading.Channels" Version="8.0.0" />
1415
</ItemGroup>
1516
<!-- NetFx and NetCore project dependencies -->

src/Microsoft.Data.SqlClient/netcore/ref/Microsoft.Data.SqlClient.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,23 +123,21 @@ public SqlJson(System.Text.Json.JsonDocument jsonDoc) { }
123123
}
124124

125125
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlVector.xml' path='docs/members[@name="SqlVector"]/SqlVector/*' />
126-
public sealed class SqlVector<T> : System.Data.SqlTypes.INullable
126+
public readonly struct SqlVector<T> : System.Data.SqlTypes.INullable
127127
where T : unmanaged
128128
{
129129
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlVector.xml' path='docs/members[@name="SqlVector"]/ctor1/*' />
130-
public SqlVector(int length) { }
131-
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlVector.xml' path='docs/members[@name="SqlVector"]/ctor2/*' />
132130
public SqlVector(System.ReadOnlyMemory<T> memory) { }
133131
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlVector.xml' path='docs/members[@name="SqlVector"]/IsNull/*' />
134132
public bool IsNull => throw null;
135133
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlVector.xml' path='docs/members[@name="SqlVector"]/Null/*' />
136134
public static SqlVector<T> Null => throw null;
137135
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlVector.xml' path='docs/members[@name="SqlVector"]/Length/*' />
138136
public int Length { get { throw null; } }
139-
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlVector.xml' path='docs/members[@name="SqlVector"]/Size/*' />
140-
public int Size { get { throw null; } }
141137
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlVector.xml' path='docs/members[@name="SqlVector"]/Memory/*' />
142138
public System.ReadOnlyMemory<T> Memory { get { throw null; } }
139+
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlTypes/SqlVector.xml' path='docs/members[@name="SqlVector"]/CreateNull/*' />
140+
public static SqlVector<T> CreateNull(int length) { throw null; }
143141
}
144142
}
145143
namespace Microsoft.Data.SqlClient

src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -435,9 +435,6 @@
435435
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\SmiMetaDataProperty.cs">
436436
<Link>Microsoft\Data\SqlClient\Server\SmiMetaDataProperty.cs</Link>
437437
</Compile>
438-
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\SmiRecordBuffer.cs">
439-
<Link>Microsoft\Data\SqlClient\Server\SmiRecordBuffer.cs</Link>
440-
</Compile>
441438
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\SmiSettersStream.cs">
442439
<Link>Microsoft\Data\SqlClient\Server\SmiSettersStream.cs</Link>
443440
</Compile>
@@ -453,9 +450,6 @@
453450
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\SqlDataRecord.cs">
454451
<Link>Microsoft\Data\SqlClient\Server\SqlDataRecord.cs</Link>
455452
</Compile>
456-
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\SqlDataRecord.netcore.cs">
457-
<Link>Microsoft\Data\SqlClient\Server\SqlDataRecord.netcore.cs</Link>
458-
</Compile>
459453
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlClient\Server\SqlMetaData.cs">
460454
<Link>Microsoft\Data\SqlClient\Server\SqlMetaData.cs</Link>
461455
</Compile>
@@ -819,6 +813,7 @@
819813
<Compile Include="Microsoft\Data\SqlClient\TdsParserStateObjectManaged.cs" />
820814
<Compile Include="Microsoft.Data.SqlClient.TypeForwards.cs" />
821815
</ItemGroup>
816+
822817
<!-- Windows only -->
823818
<ItemGroup Condition="'$(TargetsWindows)' == 'true'">
824819
<Compile Include="$(CommonSourceRoot)\Interop\Windows\Handles\SafeLibraryHandle.netcore.cs">
@@ -965,9 +960,11 @@
965960
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlTypes\SqlFileStream.Windows.cs">
966961
<Link>Microsoft\Data\SqlTypes\SqlFileStream.Windows.cs</Link>
967962
</Compile>
963+
968964
<Compile Include="Microsoft\Data\SqlClient\TdsParser.Windows.cs" />
969965
<Compile Include="Microsoft\Data\SqlClient\TdsParserStateObjectNative.cs" />
970966
</ItemGroup>
967+
971968
<!-- Unix only -->
972969
<ItemGroup Condition="'$(TargetsUnix)' == 'true'">
973970
<Compile Include="$(CommonSourceRoot)Microsoft\Data\Common\AdapterUtil.Unix.cs">
@@ -1006,8 +1003,10 @@
10061003
<Compile Include="$(CommonSourceRoot)Microsoft\Data\SqlTypes\SqlFileStream.netcore.Unix.cs">
10071004
<Link>Microsoft\Data\SqlTypes\SqlFileStream.netcore.Unix.cs</Link>
10081005
</Compile>
1006+
10091007
<Compile Include="Microsoft\Data\SqlClient\TdsParser.Unix.cs" />
10101008
</ItemGroup>
1009+
10111010
<!-- Resources -->
10121011
<ItemGroup>
10131012
<Compile Include="$(CommonSourceRoot)Resources\StringsHelper.cs">
@@ -1035,6 +1034,7 @@
10351034
<Link>Resources\Microsoft.Data.SqlClient.SqlMetaData.xml</Link>
10361035
</EmbeddedResource>
10371036
</ItemGroup>
1037+
10381038
<!-- Package References Etc -->
10391039
<ItemGroup>
10401040
<PackageReference Include="Azure.Identity" />

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlCommand.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,8 +1492,7 @@ private void ThrowIfReconnectionHasBeenCanceled()
14921492
}
14931493
}
14941494

1495-
/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlCommand.xml' path='docs/members[@name="SqlCommand"]/EndExecuteNonQueryAsync[@name="IAsyncResult"]/*'/>
1496-
public int EndExecuteNonQueryAsync(IAsyncResult asyncResult)
1495+
private int EndExecuteNonQueryAsync(IAsyncResult asyncResult)
14971496
{
14981497
SqlClientEventSource.Log.TryCorrelationTraceEvent("SqlCommand.EndExecuteNonQueryAsync | Info | Correlation | Object Id {0}, Activity Id {1}, Client Connection Id {2}, Command Text '{3}'", ObjectID, ActivityCorrelator.Current, Connection?.ClientConnectionId, CommandText);
14991498
Debug.Assert(!_internalEndExecuteInitiated || _stateObj == null);

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlConnection.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ public override int ConnectionTimeout
663663
get
664664
{
665665
SqlConnectionString constr = (SqlConnectionString)ConnectionOptions;
666-
return constr != null ? constr.ConnectTimeout : SqlConnectionString.DEFAULT.Connect_Timeout;
666+
return constr != null ? constr.ConnectTimeout : DbConnectionStringDefaults.ConnectTimeout;
667667
}
668668
}
669669

@@ -675,7 +675,7 @@ public int CommandTimeout
675675
get
676676
{
677677
SqlConnectionString constr = (SqlConnectionString)ConnectionOptions;
678-
return constr != null ? constr.CommandTimeout : SqlConnectionString.DEFAULT.Command_Timeout;
678+
return constr != null ? constr.CommandTimeout : DbConnectionStringDefaults.CommandTimeout;
679679
}
680680
}
681681

@@ -757,7 +757,7 @@ public override string Database
757757
else
758758
{
759759
SqlConnectionString constr = (SqlConnectionString)ConnectionOptions;
760-
result = constr != null ? constr.InitialCatalog : SqlConnectionString.DEFAULT.Initial_Catalog;
760+
result = constr != null ? constr.InitialCatalog : DbConnectionStringDefaults.InitialCatalog;
761761
}
762762
return result;
763763
}
@@ -830,7 +830,7 @@ public override string DataSource
830830
else
831831
{
832832
SqlConnectionString constr = (SqlConnectionString)ConnectionOptions;
833-
result = constr != null ? constr.DataSource : SqlConnectionString.DEFAULT.Data_Source;
833+
result = constr != null ? constr.DataSource : DbConnectionStringDefaults.DataSource;
834834
}
835835
return result;
836836
}
@@ -857,7 +857,7 @@ public int PacketSize
857857
else
858858
{
859859
SqlConnectionString constr = (SqlConnectionString)ConnectionOptions;
860-
result = constr != null ? constr.PacketSize : SqlConnectionString.DEFAULT.Packet_Size;
860+
result = constr != null ? constr.PacketSize : DbConnectionStringDefaults.PacketSize;
861861
}
862862
return result;
863863
}
@@ -2272,7 +2272,7 @@ public static void ChangePassword(string connectionString, string newPassword)
22722272
}
22732273
if (!string.IsNullOrEmpty(connectionOptions.AttachDBFilename))
22742274
{
2275-
throw SQL.ChangePasswordUseOfUnallowedKey(SqlConnectionString.KEY.AttachDBFilename);
2275+
throw SQL.ChangePasswordUseOfUnallowedKey(DbConnectionStringKeywords.AttachDbFilename);
22762276
}
22772277

22782278
ChangePassword(connectionString, connectionOptions, null, newPassword, null);
@@ -2329,7 +2329,7 @@ public static void ChangePassword(string connectionString, SqlCredential credent
23292329

23302330
if (!string.IsNullOrEmpty(connectionOptions.AttachDBFilename))
23312331
{
2332-
throw SQL.ChangePasswordUseOfUnallowedKey(SqlConnectionString.KEY.AttachDBFilename);
2332+
throw SQL.ChangePasswordUseOfUnallowedKey(DbConnectionStringKeywords.AttachDbFilename);
23332333
}
23342334

23352335
ChangePassword(connectionString, connectionOptions, credential, null, newSecurePassword);

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ internal bool IsDNSCachingBeforeRedirectSupported
207207
// Json Support Flag
208208
internal bool IsJsonSupportEnabled = false;
209209

210+
// User Agent Flag
211+
internal bool IsUserAgentEnabled = true;
212+
210213
// Vector Support Flag
211214
internal bool IsVectorSupportEnabled = false;
212215

@@ -1430,6 +1433,10 @@ private void Login(ServerInfo server, TimeoutTimer timeout, string newPassword,
14301433
requestedFeatures |= TdsEnums.FeatureExtension.JsonSupport;
14311434
requestedFeatures |= TdsEnums.FeatureExtension.VectorSupport;
14321435

1436+
#if DEBUG
1437+
requestedFeatures |= TdsEnums.FeatureExtension.UserAgent;
1438+
#endif
1439+
14331440
_parser.TdsLogin(login, requestedFeatures, _recoverySessionData, _fedAuthFeatureExtensionData, encrypt);
14341441
}
14351442

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.Unix.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,5 @@ private void WaitForSSLHandShakeToComplete(ref uint error, ref int protocolVersi
2222
{
2323
// No - Op
2424
}
25-
26-
private SNIErrorDetails GetSniErrorDetails()
27-
{
28-
SNIErrorDetails details;
29-
SniError sniError = SniProxy.Instance.GetLastError();
30-
details.sniErrorNumber = sniError.sniError;
31-
details.errorMessage = sniError.errorMessage;
32-
details.nativeError = sniError.nativeError;
33-
details.provider = (int)sniError.provider;
34-
details.lineNumber = sniError.lineNumber;
35-
details.function = sniError.function;
36-
details.exception = sniError.exception;
37-
38-
return details;
39-
}
40-
4125
}
4226
}

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParser.Windows.cs

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
using System;
66
using System.Diagnostics;
7-
using Interop.Windows.Sni;
8-
using Microsoft.Data.SqlClient.ManagedSni;
9-
using SniError = Microsoft.Data.SqlClient.ManagedSni.SniError;
107

118
namespace Microsoft.Data.SqlClient
129
{
@@ -62,34 +59,5 @@ private void WaitForSSLHandShakeToComplete(ref uint error, ref int protocolVersi
6259
ThrowExceptionAndWarning(_physicalStateObj);
6360
}
6461
}
65-
66-
private SNIErrorDetails GetSniErrorDetails()
67-
{
68-
SNIErrorDetails details = new SNIErrorDetails();
69-
70-
if (TdsParserStateObjectFactory.UseManagedSNI)
71-
{
72-
SniError sniError = SniProxy.Instance.GetLastError();
73-
details.sniErrorNumber = sniError.sniError;
74-
details.errorMessage = sniError.errorMessage;
75-
details.nativeError = sniError.nativeError;
76-
details.provider = (int)sniError.provider;
77-
details.lineNumber = sniError.lineNumber;
78-
details.function = sniError.function;
79-
details.exception = sniError.exception;
80-
}
81-
else
82-
{
83-
SniNativeWrapper.SniGetLastError(out Interop.Windows.Sni.SniError sniError);
84-
details.sniErrorNumber = sniError.sniError;
85-
details.errorMessage = sniError.errorMessage;
86-
details.nativeError = sniError.nativeError;
87-
details.provider = (int)sniError.provider;
88-
details.lineNumber = sniError.lineNumber;
89-
details.function = sniError.function;
90-
}
91-
return details;
92-
}
93-
9462
} // tdsparser
9563
}//namespace

0 commit comments

Comments
 (0)