From 6122a5dbcb675ba3a274c2cfa6b1ba5f523c112c Mon Sep 17 00:00:00 2001 From: Cory Rivera Date: Fri, 9 Dec 2022 10:25:28 -0800 Subject: [PATCH] Remove big data cluster references from connections. (#1775) --- .../ReliableConnectionHelper.cs | 56 ------------------- .../SqlConnectionHelperScripts.cs | 19 ------- 2 files changed, 75 deletions(-) diff --git a/src/Microsoft.SqlTools.ManagedBatchParser/ReliableConnection/ReliableConnectionHelper.cs b/src/Microsoft.SqlTools.ManagedBatchParser/ReliableConnection/ReliableConnectionHelper.cs index 752a0fba..5d049f49 100644 --- a/src/Microsoft.SqlTools.ManagedBatchParser/ReliableConnection/ReliableConnectionHelper.cs +++ b/src/Microsoft.SqlTools.ManagedBatchParser/ReliableConnection/ReliableConnectionHelper.cs @@ -652,8 +652,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection public class ServerInfo { - internal const string OptionIsBigDataCluster = "isBigDataCluster"; - internal const string OptionClusterEndpoints = "clusterEndpoints"; public int ServerMajorVersion; public int ServerMinorVersion; public int ServerReleaseVersion; @@ -676,16 +674,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection public Dictionary Options { get; set; } } - public class ClusterEndpoint - { - public string ServiceName; - public string Description; - public string Endpoint; - public string Protocol; - public string IpAddress; - public int Port; - } - public class ServerHostInfo { public string Platform; @@ -899,28 +887,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection serverInfo.Options = new Dictionary(); - // Get BDC endpoints - if (!serverInfo.IsCloud && serverInfo.ServerMajorVersion >= 15) - { - List clusterEndpoints = new List(); - serverInfo.Options.Add(ServerInfo.OptionClusterEndpoints, clusterEndpoints); - - try - { - LookupClusterEndpoints(connection, serverInfo, clusterEndpoints); - } - catch (SqlException) - { - // Failed to find cluster endpoints DMV, this must not be a cluster - // or user does not have permissions to see cluster info - serverInfo.Options.Add(ServerInfo.OptionIsBigDataCluster, false); - } - } - else - { - serverInfo.Options.Add(ServerInfo.OptionIsBigDataCluster, false); - } - return serverInfo; }; @@ -939,28 +905,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection return result; } - private static void LookupClusterEndpoints(IDbConnection connection, ServerInfo serverInfo, List clusterEndpoints) - { - ExecuteReader( - connection, - SqlConnectionHelperScripts.GetClusterEndpoints, - delegate (IDataReader reader) - { - while (reader.Read()) - { - clusterEndpoints.Add(new ClusterEndpoint - { - ServiceName = reader.GetString(0), - Description = reader.GetString(1), - Endpoint = reader.GetString(2), - Protocol = reader.GetString(3) - }); - } - serverInfo.Options.Add(ServerInfo.OptionIsBigDataCluster, clusterEndpoints.Count > 0); - } - ); - } - public static string GetServerName(IDbConnection connection) { return new DbConnectionWrapper(connection).DataSource; diff --git a/src/Microsoft.SqlTools.ManagedBatchParser/ReliableConnection/SqlConnectionHelperScripts.cs b/src/Microsoft.SqlTools.ManagedBatchParser/ReliableConnection/SqlConnectionHelperScripts.cs index 1b719e4c..99767171 100644 --- a/src/Microsoft.SqlTools.ManagedBatchParser/ReliableConnection/SqlConnectionHelperScripts.cs +++ b/src/Microsoft.SqlTools.ManagedBatchParser/ReliableConnection/SqlConnectionHelperScripts.cs @@ -44,25 +44,6 @@ IF (@filepath IS NULL) WHERE [file_id] = 2 SELECT @filepath AS FilePath -"; - /** - * Query to get the server endpoints. We first try to query the dm_cluster_endpoints DMV since that will contain all - * of the endpoints. But if that fails (such as if the user doesn't have VIEW SERVER STATE permissions) then we'll - * fall back to just querying the ControllerEndpoint server property to at least get the endpoint of the controller - * and rely on the caller to connect to the controller to query for any of the other endpoints it needs. - */ - public const string GetClusterEndpoints = @"BEGIN TRY -SELECT [name], [description], [endpoint], [protocol_desc] FROM .[sys].[dm_cluster_endpoints] -END TRY -BEGIN CATCH -DECLARE @endpoint VARCHAR(MAX) -SELECT @endpoint = CONVERT(VARCHAR(MAX),SERVERPROPERTY('ControllerEndpoint')) --- If the endpoint is empty/null then return 0 rows (we don't have any cluster endpoints) -IF @endpoint <> '' -SELECT 'controller' AS name, 'Cluster Management Service' AS description, @endpoint as endpoint, SUBSTRING(@endpoint, 0, CHARINDEX(':', @endpoint)) -ELSE -SELECT TOP 0 '' -END CATCH "; public const string GetHostInfo = @"SELECT [host_platform], [host_distribution], [host_release], [host_service_pack_level], [host_sku], [os_language_version] FROM sys.dm_os_host_info"; public const string GetHostWindowsVersion = @"SELECT windows_release FROM sys.dm_os_windows_info";