Remove BDC backwards compat check (#873)

* Remove BDC backwards compat check

* Fix merge issues
This commit is contained in:
Charles Gagnon
2019-10-04 14:13:32 -07:00
committed by GitHub
parent e95b4c84c5
commit f392a4a3f3
2 changed files with 30 additions and 60 deletions

View File

@@ -824,29 +824,26 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection
serverInfo.Options = new Dictionary<string, object>();
// Get BDC endpoints
if (!serverInfo.IsCloud)
if (!serverInfo.IsCloud && serverInfo.ServerMajorVersion >= 15)
{
if (serverInfo.ServerMajorVersion >= 15)
{
List<ClusterEndpoint> clusterEndpoints = new List<ClusterEndpoint>();
serverInfo.Options.Add(ServerInfo.OptionClusterEndpoints, clusterEndpoints);
List<ClusterEndpoint> clusterEndpoints = new List<ClusterEndpoint>();
serverInfo.Options.Add(ServerInfo.OptionClusterEndpoints, clusterEndpoints);
try
{
LookupClusterEndpoints(connection, serverInfo, clusterEndpoints);
}
catch (SqlException)
{
// Failed to find cluster endpoints DMV / table, this must not be a cluster
// or user does not have permissions to see cluster info
serverInfo.Options.Add(ServerInfo.OptionIsBigDataCluster, false);
}
}
else
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;
};
@@ -868,44 +865,23 @@ namespace Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection
private static void LookupClusterEndpoints(IDbConnection connection, ServerInfo serverInfo, List<ClusterEndpoint> clusterEndpoints)
{
try
{
ExecuteReader(
connection,
SqlConnectionHelperScripts.GetClusterEndpoints,
delegate (IDataReader reader)
ExecuteReader(
connection,
SqlConnectionHelperScripts.GetClusterEndpoints,
delegate (IDataReader reader)
{
while (reader.Read())
{
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);
clusterEndpoints.Add(new ClusterEndpoint {
ServiceName = reader.GetString(0),
Description = reader.GetString(1),
Endpoint = reader.GetString(2),
Protocol = reader.GetString(3)
});
}
);
}
catch (Exception)
{
// Fallback to using previous CTP logic.
// TODO #847 remove this logic once we've stopped supporting CTPs
ExecuteReader(
connection,
SqlConnectionHelperScripts.GetClusterEndpoints_CTP,
delegate (IDataReader reader)
{
while (reader.Read())
{
clusterEndpoints.Add(new ClusterEndpoint { ServiceName = reader.GetString(0), IpAddress = reader.GetString(1), Port = reader.GetInt32(2) });
}
serverInfo.Options.Add(ServerInfo.OptionIsBigDataCluster, clusterEndpoints.Count > 0);
}
);
}
serverInfo.Options.Add(ServerInfo.OptionIsBigDataCluster, clusterEndpoints.Count > 0);
}
);
}
public static string GetServerName(IDbConnection connection)

View File

@@ -47,12 +47,6 @@ SELECT @filepath AS FilePath
";
public const string GetOsVersion = @"SELECT OSVersion = RIGHT(@@version, LEN(@@version)- 3 -charindex (' on ', LOWER(@@version)))";
// TODO: #847 remove the Throw condition from endpoints query when removing the GetClusterEndpoints_CTP code.
// This is needed for 1 monthly release, to support back compatibility with CTP 3.2
public const string GetClusterEndpoints = @"IF OBJECT_ID (N'sys.dm_cluster_endpoints') IS NOT NULL
SELECT [name], [description], [endpoint], [protocol_desc] FROM .[sys].[dm_cluster_endpoints];
ELSE THROW 50000, 'Use older DMV', 1";
public const string GetClusterEndpoints_CTP = @"IF OBJECT_ID (N'master.dbo.cluster_endpoint_info') IS NOT NULL
SELECT [service_name], [ip_address], [port] FROM [master].[dbo].[cluster_endpoint_info];";
public const string GetClusterEndpoints = @"SELECT [name], [description], [endpoint], [protocol_desc] FROM .[sys].[dm_cluster_endpoints];";
}
}