mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-25 09:35:37 -05:00
3326 Kusto HTTPS url fix (#1086)
* 3326 Removed sqlConnection.Open from CreateSqlConnection in ConnectionService. * 3326 Removed unused variables and functions from ConnectedBindingContext, ConnectedBindingQueue, IBindingContext, and IConnectedBindingQueue * 3326 Removed unused constant SqlAzureEdition and unused functions CreateSqlConnection and CreateServerConnection from ConnectionService. Removed ServerConnection, MetadataDisplayInfoProvider, Binder, and SmoMetaDataProvider from ConnectedBindingContext. Deleted SqlConnectionOpener and ISqlConnectionOpener.
This commit is contained in:
@@ -31,9 +31,8 @@ namespace Microsoft.Kusto.ServiceLayer.Connection
|
||||
/// </summary>
|
||||
public class ConnectionService
|
||||
{
|
||||
public const string AdminConnectionPrefix = "ADMIN:";
|
||||
internal const string PasswordPlaceholder = "******";
|
||||
private const string SqlAzureEdition = "SQL Azure";
|
||||
private const string AdminConnectionPrefix = "ADMIN:";
|
||||
private const string PasswordPlaceholder = "******";
|
||||
|
||||
/// <summary>
|
||||
/// Singleton service instance
|
||||
@@ -984,7 +983,7 @@ namespace Microsoft.Kusto.ServiceLayer.Connection
|
||||
/// Build a connection string builder a connection details instance
|
||||
/// </summary>
|
||||
/// <param name="connectionDetails"></param>
|
||||
public static SqlConnectionStringBuilder CreateConnectionStringBuilder(ConnectionDetails connectionDetails)
|
||||
private static SqlConnectionStringBuilder CreateConnectionStringBuilder(ConnectionDetails connectionDetails)
|
||||
{
|
||||
SqlConnectionStringBuilder connectionBuilder;
|
||||
|
||||
@@ -1359,63 +1358,6 @@ namespace Microsoft.Kusto.ServiceLayer.Connection
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create and open a new SqlConnection from a ConnectionInfo object
|
||||
/// Note: we need to audit all uses of this method to determine why we're
|
||||
/// bypassing normal ConnectionService connection management
|
||||
/// </summary>
|
||||
/// <param name="connInfo">The connection info to connect with</param>
|
||||
/// <param name="featureName">A plaintext string that will be included in the application name for the connection</param>
|
||||
/// <returns>A SqlConnection created with the given connection info</returns>
|
||||
internal static SqlConnection OpenSqlConnection(ConnectionInfo connInfo, string featureName = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
// capture original values
|
||||
int? originalTimeout = connInfo.ConnectionDetails.ConnectTimeout;
|
||||
bool? originalPersistSecurityInfo = connInfo.ConnectionDetails.PersistSecurityInfo;
|
||||
bool? originalPooling = connInfo.ConnectionDetails.Pooling;
|
||||
|
||||
// increase the connection timeout to at least 30 seconds and and build connection string
|
||||
connInfo.ConnectionDetails.ConnectTimeout = Math.Max(30, originalTimeout ?? 0);
|
||||
// enable PersistSecurityInfo to handle issues in SMO where the connection context is lost in reconnections
|
||||
connInfo.ConnectionDetails.PersistSecurityInfo = true;
|
||||
// turn off connection pool to avoid hold locks on server resources after calling SqlConnection Close method
|
||||
connInfo.ConnectionDetails.Pooling = false;
|
||||
connInfo.ConnectionDetails.ApplicationName = GetApplicationNameWithFeature(connInfo.ConnectionDetails.ApplicationName, featureName);
|
||||
|
||||
// generate connection string
|
||||
string connectionString = BuildConnectionString(connInfo.ConnectionDetails);
|
||||
|
||||
// restore original values
|
||||
connInfo.ConnectionDetails.ConnectTimeout = originalTimeout;
|
||||
connInfo.ConnectionDetails.PersistSecurityInfo = originalPersistSecurityInfo;
|
||||
connInfo.ConnectionDetails.Pooling = originalPooling;
|
||||
|
||||
// open a dedicated binding server connection
|
||||
using (SqlConnection sqlConn = new SqlConnection(connectionString))
|
||||
{
|
||||
// Fill in Azure authentication token if needed
|
||||
if (connInfo.ConnectionDetails.AzureAccountToken != null)
|
||||
{
|
||||
sqlConn.AccessToken = connInfo.ConnectionDetails.AzureAccountToken;
|
||||
}
|
||||
|
||||
sqlConn.Open();
|
||||
return sqlConn;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string error = string.Format(CultureInfo.InvariantCulture,
|
||||
"Failed opening a SqlConnection: error:{0} inner:{1} stacktrace:{2}",
|
||||
ex.Message, ex.InnerException != null ? ex.InnerException.Message : string.Empty, ex.StackTrace);
|
||||
Logger.Write(TraceEventType.Error, error);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create and open a new SqlConnection from a ConnectionInfo object
|
||||
/// Note: we need to audit all uses of this method to determine why we're
|
||||
@@ -1445,23 +1387,6 @@ namespace Microsoft.Kusto.ServiceLayer.Connection
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create and open a new ServerConnection from a ConnectionInfo object.
|
||||
/// This calls ConnectionService.OpenSqlConnection and then creates a
|
||||
/// ServerConnection from it.
|
||||
/// </summary>
|
||||
/// <param name="connInfo">The connection info to connect with</param>
|
||||
/// <param name="featureName">A plaintext string that will be included in the application name for the connection</param>
|
||||
/// <returns>A ServerConnection (wrapping a SqlConnection) created with the given connection info</returns>
|
||||
internal static ServerConnection OpenServerConnection(ConnectionInfo connInfo, string featureName = null)
|
||||
{
|
||||
SqlConnection sqlConnection = OpenSqlConnection(connInfo, featureName);
|
||||
|
||||
return connInfo.ConnectionDetails.AzureAccountToken != null
|
||||
? new ServerConnection(sqlConnection, new AzureAccessToken(connInfo.ConnectionDetails.AzureAccountToken))
|
||||
: new ServerConnection(sqlConnection);
|
||||
}
|
||||
|
||||
public static void EnsureConnectionIsOpen(ReliableDataSourceConnection conn, bool forceReopen = false)
|
||||
{
|
||||
// verify that the connection is open
|
||||
|
||||
Reference in New Issue
Block a user