diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index d13c975f..e880659a 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -19,15 +19,13 @@ Use the `#solution` context keyword in Copilot Chat to supply full solution-wide ## 2. Tech Stack & Build Language: C# (.NET). Build system: MSBuild / `dotnet build` via solution `dirs.sln` (aggregator) or project-level builds. -Delay-signed assemblies are required for testing inside SSMS. Generated / intermediate content lives under `obj/` and must never be edited directly. When invoking "dotnet build" or "dotnet test" set DOTNET_ROLL_FORWARD=Major to avoid SDK version mismatches. -If localization projects fail to build, you can use `/p:EnableLocalization=false` to skip them. ### Build Shortcuts (via init.cmd) After running `init.cmd`, these doskey aliases are available: -- `bsmont` - Build SMO without tests (faster when you don't need test assemblies) -- `msb` - MSBuild with localization disabled +- `bsmo` - Build SMO +- `msb` - MSBuild - `rtests` - Run tests from bin\debug\net472 ### Key Directories @@ -73,7 +71,6 @@ Framework: NUnit (assert style) with VSTest discovery attributes (`[TestClass]`, Rules: - Every bug fix must ship with at least one test that fails prior to the fix and passes after. -- Tests using internal infrastructure or tenant resources must live in the `SmoInternal` project. - Long, descriptive test method names: Start with the SMO object type being tested, then scenario, then expected outcome. - Always include assertion messages clarifying intent & expected result. - Logs should make failures diagnosable without rerunning with a debugger. @@ -89,11 +86,8 @@ public void Table_CreateWithFileGroup_IncludesFileGroupInScript() { /* ... */ } - Use `[SupportedServerVersionRange]` to specify version ranges (MinMajor, MaxMajor, Edition, HostPlatform). ### Test Environment Notes -- Only delay-signed binaries can be loaded in SSMS for integration-style validation. -- Running tests against the SQL Managed Instance does not work over AzVpn except from an Azure VM. -- Test resources live in the TME tenant. Authenticate first: - - `az login --tenant 70a036f6-8e4d-4615-bad6-149c02e7720d` - - Or sign in via Visual Studio to that tenant. + +- Test servers are long lived. Tests that create files, such as filegroups, must clean up after themselves. ## 6. Coding Guidelines - Prefer `nameof(PropertyOrType)` over hard-coded strings. @@ -101,6 +95,7 @@ public void Table_CreateWithFileGroup_IncludesFileGroupInScript() { /* ... */ } - Keep public API surface stable; if change is unavoidable, document rationale in the PR description + changelog. - Follow existing nullability / exception patterns in similar classes before introducing new patterns. - Use expressive NUnit constraint assertions (`Assert.That(x, Is.Not.Null, "...context...")`). +- All `if` and `else` blocks must be enclosed in {} ## 7. Common Tasks for Copilot | Task | Guidance | @@ -108,7 +103,6 @@ public void Table_CreateWithFileGroup_IncludesFileGroupInScript() { /* ... */ } | Add new SMO property | Follow Section 3; add tests per Section 5. | | Add new specialized index type | Follow Section 4A step-by-step; reference Vector Index implementation as example. | | Fix bug in scripting | Reproduce with a failing test; fix; ensure deterministic script ordering. | -| Add integration test hitting internal MI | Place in `SmoInternal`; guard with environment/tenant checks. | | Refactor constant string names | Replace with `nameof`; ensure no breaking rename side-effects. | | Improve test diagnostics | Add assertion messages & context logging (but no secrets). | | Add version-specific helper | Add `ThrowIfBelowVersionXXX()` to SqlSmoObject.cs following existing pattern. | @@ -178,4 +172,3 @@ Concise Canonical Rules (TL;DR): 2. Use `nameof` not magic strings. 3. Never edit `obj/` or include internal links. 4. Properties: update `cfg.xml` + corresponding XML metadata. - diff --git a/.github/instructions/deprecate-sql-version-instructions.md b/.github/instructions/deprecate-sql-version-instructions.md new file mode 100644 index 00000000..eeadeef2 --- /dev/null +++ b/.github/instructions/deprecate-sql-version-instructions.md @@ -0,0 +1,650 @@ +# Deprecating Support for Old SQL Server Versions + +This document provides comprehensive, step-by-step instructions for removing support for older SQL Server versions from the SMO (SQL Management Objects) codebase. Use this guide when SQL Server versions reach end of extended support. + +## Overview + +The version deprecation process involves removing dead code paths, simplifying version checks, and updating XML metadata across the SMO codebase. The goal is to make **minimal, surgical changes** that remove obsolete code without breaking public APIs or introducing logic errors. + +**Critical Principle**: When removing support for version X and earlier, the new minimum supported version becomes X+1. Any code that checks `if (version <= X)` or `if (version == X)` for versions X and below becomes dead code and should be **removed entirely**, not modified to check for version X+1. + +**Example Context**: This guide uses SQL Server 2005 (major version 9) as the example for deprecation, making SQL Server 2008 (major version 10) the new minimum. Replace version numbers appropriately for your deprecation target. + +## Prerequisites + +- Understand the [SQL Server versioning scheme](https://learn.microsoft.com/en-us/troubleshoot/sql/general/determine-version-edition-update-level): + - SQL Server 2005 = Major version 9 + - SQL Server 2008 = Major version 10 + - SQL Server 2008 R2 = Major version 10.50 + - SQL Server 2012 = Major version 11 + - etc. +- Review the requirements document specifying which versions to deprecate +- Have a build environment set up (see main README.md) +- Run tests frequently to catch introduced bugs + +## Key Principles + +### 1. Preserve Public API Compatibility + +**DO**: +- Keep all public constants, enumerations, and type definitions +- Preserve version-related enum values (e.g., `SqlServerVersion.Version90`) +- Maintain compatibility level enums (e.g., `CompatibilityLevel.Version90`) +- Keep scripting target version options + +**DON'T**: +- Remove or rename public enum values +- Change method signatures +- Remove public classes or interfaces +- Modify public constants + +### 2. Understand Version Check Logic + +Before modifying any version check, understand what it does: + +**Common patterns**: +- `ServerVersion.Major == X` - Code executes ONLY for version X +- `ServerVersion.Major >= X` - Code executes for version X and later +- `ServerVersion.Major < X` - Code executes for versions before X +- `ServerVersion.Major > X` - Code executes for versions after X +- `ServerVersion.Major <= X` - Code executes for version X and earlier + +**When minimum supported version becomes 10 (SQL Server 2008)**: +- `Major == 9` → **Remove block** (dead code, never executes) +- `Major < 10` → **Remove block** (always false, never executes) +- `Major <= 9` → **Remove block** (always false, never executes) +- `Major >= 10` → **Always true** - simplify by removing check or entire if statement +- `Major > 9` → **Always true** - simplify by removing check +- `Major >= 9` → **Always true** - simplify by removing check + +### 3. Common Mistakes to Avoid + +❌ **WRONG**: Changing version numbers in comparisons +```csharp +// Before +if (ServerVersion.Major == 9) { /* SQL 2005 code */ } +else { /* SQL 2008+ code */ } + +// WRONG - Changes 9 to 10 +if (ServerVersion.Major == 10) { /* This is now dead code! */ } +else { /* SQL 2012+ code */ } +``` + +✅ **CORRECT**: Remove the dead code block entirely +```csharp +// CORRECT - Remove the entire if/else and keep SQL 2008+ code +/* SQL 2008+ code directly here */ +``` + +❌ **WRONG**: Keeping always-true conditions +```csharp +// Before +if (ServerVersion.Major >= 9) { /* Code for SQL 2005+ */ } + +// WRONG - Changes to >= 10 (always true) +if (ServerVersion.Major >= 10) { /* This condition is meaningless now */ } +``` + +✅ **CORRECT**: Remove the condition entirely +```csharp +// CORRECT - Remove the if statement, keep the code +/* Code executes unconditionally for all supported versions */ +``` + +## Step-by-Step Instructions + +### Phase 1: XML Metadata Updates + +**Files**: `src\Microsoft\SqlServer\Management\SqlEnum\xml\*.xml` + +#### 1.1 Update MinMajor Attributes + +For each XML file, update the minimum version: + +```xml + + + + + +``` + +**Process**: +1. Search for `min_major` attributes +2. Change any value less than the new minimum to the new minimum +3. Common values to update: `min_major="7"`, `min_major="8"`, `min_major="9"` + +#### 1.2 Remove Obsolete Version Snippets + +Remove entire `` blocks where `max_major` is less than the new minimum: + +```xml + + + + + +``` + +**Process**: +1. Search for `max_major` attributes +2. If `max_major` value is less than new minimum (e.g., `max_major="9"` when minimum is 10), remove entire block +3. Look for combinations like `min_major="7" max_major="9"` or just `max_major="8"` + +#### 1.3 Remove Version-Gated Properties for Old Versions + +Remove `` elements that only exist for deprecated versions: + +```xml + + + + + + + + +``` + +**Key files to check**: +- `Database.xml` +- `Table.xml` +- `StoredProcedure.xml` +- `View.xml` +- `Index.xml` +- All files in the `xml` directory + +### Phase 2: C# Code Analysis and Cleanup + +**Focus Projects** (as specified in requirements): +- `Microsoft.SqlServer.ConnectionInfo.csproj` +- `Microsoft.SqlServer.Management.Sdk.Sfc.csproj` +- `Microsoft.SqlServer.Smo.csproj` +- `Microsoft.SqlServer.SqlEnum.csproj` + +#### 2.1 Identify Version Check Patterns + +**Search for common patterns**: +```powershell +# PowerShell - Search for version checks +Get-ChildItem -Path "src\" -Include "*.cs" -Recurse | Select-String "ServerVersion\.Major" | Select-Object Path, LineNumber, Line + +# Search for specific version numbers +Get-ChildItem -Path "src\" -Include "*.cs" -Recurse | Select-String "\b(Version90|Version80|Version70)\b" | Select-Object Path, LineNumber, Line +``` + +**Patterns to find**: +- `ServerVersion.Major` +- `ConnectionContext.ServerVersion.Major` +- `server.Version.Major` +- `sp.TargetServerVersion` +- `DatabaseEngineType` (may combine with version checks) +- Build number comparisons (e.g., `9.0.4230` for SQL 2005 SP3 CU5) + +#### 2.2 Handle Switch Statements + +**Pattern**: Switch on `ServerVersion.Major` + +```csharp +// Before +switch (ServerVersion.Major) +{ + case 7: + case 8: + case 9: + // SQL 2000/2005 code + scriptSql80Syntax = true; + break; + case 10: + default: + // SQL 2008+ code + scriptSql90Syntax = true; + break; +} + +// After - Remove cases for versions < 10 +switch (ServerVersion.Major) +{ + case 10: + default: + // SQL 2008+ code + scriptSql90Syntax = true; + break; +} + +// Or if only one case remains, remove switch entirely +scriptSql90Syntax = true; +``` + +**Process**: +1. Remove `case` labels for versions below minimum +2. If only one case remains, consider removing the switch entirely +3. Ensure `default:` case handles current and future versions appropriately + +#### 2.3 Handle If/Else Chains + +**Pattern 1**: Exact version match (dead code removal) + +```csharp +// Before +if (ServerVersion.Major == 9) +{ + // SQL 2005 specific code + AppendDdl(builder, "OLD_SYNTAX"); +} +else +{ + // SQL 2008+ code + AppendDdl(builder, "NEW_SYNTAX"); +} + +// After - Remove entire if/else, keep the else block content +AppendDdl(builder, "NEW_SYNTAX"); +``` + +**Pattern 2**: Less-than check (always false removal) + +```csharp +// Before +if (ServerVersion.Major < 10) +{ + // SQL 2005 and earlier code + UseOldMethod(); +} +else +{ + // SQL 2008+ code + UseNewMethod(); +} + +// After - Remove if/else, keep else block content +UseNewMethod(); +``` + +**Pattern 3**: Greater-than-or-equal check (always true simplification) + +```csharp +// Before +if (ServerVersion.Major >= 9 && SomeOtherCondition) +{ + // Code for SQL 2005+ + DoSomething(); +} + +// After - Remove version check, keep other conditions +if (SomeOtherCondition) +{ + DoSomething(); +} +``` + +**Pattern 4**: Complex nested conditions + +```csharp +// Before +if (ServerVersion.Major >= 9) +{ + if (TargetServerVersion >= SqlServerVersion.Version90) + { + // Code that scripts for SQL 2005+ targets + ScriptNewSyntax(); + } +} +else +{ + // Old SQL 2000 scripting + ScriptOldSyntax(); +} + +// After - Remove always-true server version check, keep target check, remove dead else +if (TargetServerVersion >= SqlServerVersion.Version90) +{ + ScriptNewSyntax(); +} +``` + +**Important**: When a condition has multiple parts, analyze each part: +- If ALL parts are always true → Remove entire condition +- If SOME parts are always true → Remove only those parts, keep others +- Keep conditions that check `TargetServerVersion` (scripting target, not server version) + +#### 2.4 Handle Build Number Comparisons + +**Pattern**: Build number comparisons for specific versions + +```csharp +// Before +int sql2005Sp3Cu5 = 4230; // SQL 2005 SP3 CU5 +if (ServerVersion.Major == 9 && ServerVersion.BuildNumber >= sql2005Sp3Cu5) +{ + // Feature added in SQL 2005 SP3 CU5 + UseFeature(); +} + +// After - Remove dead code and unused variable +// If feature is standard in SQL 2008+, remove condition entirely +UseFeature(); + +// OR if feature still needs checking for SQL 2008 builds +int sql2008RequiredBuild = 1600; // Example +if (ServerVersion.Major == 10 && ServerVersion.BuildNumber >= sql2008RequiredBuild) +{ + UseFeature(); +} +``` + +**Process**: +1. Identify if the build check is for a deprecated version +2. Remove the entire condition if feature is standard in new minimum version +3. If feature still requires build checking for supported versions, update accordingly + +#### 2.5 Handle GetSystemUserName Pattern + +**Common pattern**: Conditional prefix based on version + +```csharp +// Before +string prefix; +if (ServerVersion.Major >= 9) +{ + prefix = "sys"; +} +else +{ + prefix = "dbo"; +} +return prefix + "." + userName; + +// After - Remove condition, use only the modern value +string prefix = "sys"; +return prefix + "." + userName; + +// Or even simpler +return "sys." + userName; +``` + +#### 2.6 Handle Try-Catch-Finally with Version Checks + +**Pattern**: Version checks inside exception handling + +```csharp +// Before +try +{ + if (ServerVersion.Major < 10) + { + ExecuteOldMethod(); + } + else + { + ExecuteNewMethod(); + } +} +finally +{ + Cleanup(); +} + +// After - Simplify +try +{ + ExecuteNewMethod(); +} +finally +{ + Cleanup(); +} +``` + +### Phase 3: Comments and Documentation + +#### 3.1 Update Version-Related Comments + +```csharp +// Before +// For SQL 2005 and later, use new syntax +// WRONG: Leave as-is (now misleading) + +// After +// For SQL 2008 and later, use new syntax +// OR +// For all supported versions, use new syntax +``` + +#### 3.2 Remove Obsolete Comments + +```csharp +// Before +// TODO: Remove SQL 2000 compatibility code after 2005 RTM + +// After - Remove obsolete TODO +``` + +### Phase 4: Testing and Validation + +#### 4.1 Build Validation + +```powershell +# Set environment variable to avoid SDK version issues +$env:DOTNET_ROLL_FORWARD = "Major" + +# Build +dotnet build dirs.sln +``` + +#### 4.2 Test Execution + +Run tests to ensure no regressions: +```powershell +# Run all SMO tests +dotnet test --no-build --logger "console;verbosity=normal" + +# Or use init.cmd shortcuts +rtests # .NET Framework tests +netcoretests # .NET Core tests +``` + +#### 4.3 Check for Unintended Changes + +```powershell +# Review what files changed +git status --porcelain + +# Review diff statistics +git diff --numstat + +# Ensure no excessive deletions or unexpected files +# Deleted lines should typically be < 2x inserted lines per file +``` + +### Phase 5: Update Documentation + +#### 5.1 Update CHANGELOG.md + +Add an entry describing the changes: + +```markdown +## [Unreleased] + +### Removed +- **Breaking Behavior Change**: Removed internal code paths for SQL Server 2005 and earlier versions. + - Minimum supported server version is now SQL Server 2008 (version 10.0). + - Public APIs remain unchanged; all version-related enumerations and constants are preserved for backward compatibility. + - Applications targeting SQL Server 2005 or earlier will need to use an older version of SMO. + - Internal version checks for SQL Server 2005 and earlier have been removed, simplifying code paths. +``` + +#### 5.2 Update README if Needed + +If the main README mentions supported versions, update it: + +```markdown +## Supported SQL Server Versions + +SMO supports the following SQL Server versions: +- SQL Server 2008 and later (version 10.0+) +- Azure SQL Database +- Azure SQL Managed Instance +``` + +## Verification Checklist + +Before completing the deprecation work, verify: + +- [ ] All XML files updated (min_major, removed max_major blocks) +- [ ] No `case X:` statements for versions < minimum in switch blocks +- [ ] No `if (Major == X)` for versions < minimum +- [ ] No `if (Major < minimum)` conditions remain +- [ ] All `if (Major >= minimum)` simplified or removed +- [ ] Build number comparisons for old versions removed +- [ ] No always-true conditions left in code +- [ ] No unreachable else blocks remain +- [ ] Version-related comments updated or removed +- [ ] CHANGELOG.md updated with summary +- [ ] All changes compile without errors +- [ ] Tests pass (no new failures introduced) +- [ ] Public APIs unchanged (no breaking changes) +- [ ] Git diff reviewed for unintended changes + +## Common Files to Review + +Based on previous deprecation work, these files often contain version checks: + +**SMO Core Objects**: +- `DatabaseBase.cs` - Many version checks for database-level features +- `TableBase.cs` - Table scripting and features +- `IndexBase.cs`, `IndexScripter.cs` - Index types and options +- `StoredProcedureBase.cs` - Stored procedure scripting +- `ViewBase.cs` - View options and scripting +- `UserBase.cs`, `UserDefinedFunctionBase.cs` - User and UDF features +- `ServerBase.cs` - Server-level version checks +- `DatabaseRoleBase.cs` - Role features + +**Scripting Infrastructure**: +- `ScriptingOptions.cs` - Target version handling +- `ScriptingPreferences.cs` - Default versions +- `SqlSmoObject.cs` - Base object version utilities + +**Utilities**: +- `SmoUtility.cs` - Helper methods with version logic +- `PermissionWorker.cs` - Permission scripting +- `ParamBase.cs` - Parameter handling + +**Connection and Metadata**: +- `SqlConnectionInfo.cs` - Connection version detection +- `Enumerator.cs` - Metadata enumeration +- `propertiesMetadata.cs` - Property version support + +## Troubleshooting + +### Issue: Build Errors After Removing Code + +**Symptom**: Compiler errors about missing variables or unreachable code + +**Solution**: +- Check if removed code defined variables used later +- Ensure you removed entire dead branches, not just conditions +- Look for warning about unreachable code (sign of incomplete cleanup) + +### Issue: Tests Failing After Changes + +**Symptom**: Tests that passed before now fail + +**Solution**: +- Review git diff for the specific file +- Check if you removed code that wasn't actually version-specific +- Verify conditions were truly always-true/always-false +- Look for target version checks (TargetServerVersion) that should remain + +### Issue: Too Many Lines Deleted + +**Symptom**: A file shows hundreds of deletions with few additions + +**Solution**: +- Review the diff carefully - may indicate over-deletion +- Check if you removed code that applies to all versions +- Verify you didn't remove entire methods by accident +- Rule of thumb: Deleted lines should be < 2x inserted lines per file + +### Issue: Always-True Condition Left in Code + +**Symptom**: Code reviewer flags `if (Major >= 10)` as always true + +**Solution**: +```csharp +// Before (after incorrect fix) +if (ServerVersion.Major >= 10 && TargetServerVersion >= SqlServerVersion.Version90) +{ + ScriptNewSyntax(); +} + +// After (correct fix) +if (TargetServerVersion >= SqlServerVersion.Version90) +{ + ScriptNewSyntax(); +} +``` + +### Issue: Dead Code Created by Incorrect Fix + +**Symptom**: Code reviewer flags `if (Major == 10)` combined with SQL 2005 build check + +**Solution**: +```csharp +// Before (incorrect fix) +int sql2005Build = 4230; +if (ServerVersion.Major == 10 && ServerVersion.BuildNumber >= sql2005Build) +{ + // This is nonsense - checking SQL 2008 version against SQL 2005 build + UseFeature(); +} + +// After (correct fix) +// Remove entire block if feature is standard in SQL 2008+ +UseFeature(); +``` + +## Best Practices + +1. **Make changes iteratively**: Don't try to fix everything at once +2. **Build and test frequently**: Catch errors early +3. **Review diffs before committing**: Use `git diff` to verify changes are minimal and correct +4. **Understand before modifying**: Read surrounding code to understand intent +5. **Preserve intent, not literal code**: If code handled both old and new versions, keep only new version handling +6. **Use think tool**: When uncertain about a complex version check, use the think tool to analyze it +7. **Test on real servers**: If possible, test against minimum supported version (SQL 2008) + +## Contact / Escalation + +If you encounter complex version logic that's unclear: +- Review git history for context (`git log -p -- `) +- Check for related bug work items or PRs +- Consult with team members familiar with that code area +- Add `// TODO: Verify this change` comments for review + +--- + +## Quick Reference: Version Check Decision Tree + +``` +Is this a version check for version X (deprecated version or lower)? +│ +├─ YES: Is it checking ServerVersion (actual server)? +│ │ +│ ├─ YES: Is it a comparison? +│ │ │ +│ │ ├─ == X or <= X or < (X+1) → REMOVE block (dead code) +│ │ ├─ >= (X+1) or > X → REMOVE condition (always true) +│ │ └─ >= X → REMOVE condition (always true) +│ │ +│ └─ NO: Is it checking TargetServerVersion (scripting target)? +│ │ +│ └─ KEEP IT (controls scripting output, not runtime logic) +│ +└─ NO: Not a version check for deprecated version + └─ LEAVE UNCHANGED +``` + +--- + +**Remember**: The goal is minimal, surgical changes that remove obsolete code paths while preserving all public APIs and maintaining the semantic meaning of the code. diff --git a/.github/instructions/eventsource-instructions.md b/.github/instructions/eventsource-instructions.md new file mode 100644 index 00000000..c0e1281a --- /dev/null +++ b/.github/instructions/eventsource-instructions.md @@ -0,0 +1,129 @@ +--- +applyTo: '**' +--- +# EventSource best practices + +Use this document as a guide when adding new events to an EventSource. +## Querying Microsoft Documentation + +You have access to an MCP server called `microsoft.docs.mcp` - this tool allows you to search through Microsoft's latest official documentation, and that information might be more detailed or newer than what's in your training data set. + +When handling questions around how to work with native Microsoft technologies, such as C#, F#, ASP.NET Core, Microsoft.Extensions, NuGet, Entity Framework, the `dotnet` runtime - please use this tool for research purposes when dealing with specific / narrowly defined questions that may occur. + +## EventSource Overview +The basic structure of a derived EventSource is always the same. In particular: + +The class inherits from System.Diagnostics.Tracing.EventSource +For each different type of event you wish to generate, a method needs to be defined. This method should be named using the name of the event being created. If the event has additional data these should be passed using arguments. These event arguments need to be serialized so only certain types are allowed. +Each method has a body that calls WriteEvent passing it an ID (a numeric value that represents the event) and the arguments of the event method. The ID needs to be unique within the EventSource. The ID is explicitly assigned using the System.Diagnostics.Tracing.EventAttribute +EventSources are intended to be singleton instances. Thus it's convenient to define a static variable, by convention called Log, that represents this singleton. + +## EventSource Keywords + +Some event tracing systems support keywords as an additional filtering mechanism. Unlike verbosity that categorizes events by level of detail, keywords are intended to categorize events based on other criteria such as areas of code functionality or which would be useful for diagnosing certain problems. Keywords are named bit flags and each event can have any combination of keywords applied to it. For example the EventSource below defines some events that relate to request processing and other events that relate to startup. If a developer wanted to analyze the performance of startup, they might only enable logging the events marked with the startup keyword. +```C# +[EventSource(Name = "Demo")] +class DemoEventSource : EventSource +{ + public static DemoEventSource Log { get; } = new DemoEventSource(); + + [Event(1, Keywords = Keywords.Startup)] + public void AppStarted(string message, int favoriteNumber) => WriteEvent(1, message, favoriteNumber); + [Event(2, Keywords = Keywords.Requests)] + public void RequestStart(int requestId) => WriteEvent(2, requestId); + [Event(3, Keywords = Keywords.Requests)] + public void RequestStop(int requestId) => WriteEvent(3, requestId); + + public class Keywords // This is a bitvector + { + public const EventKeywords Startup = (EventKeywords)0x0001; + public const EventKeywords Requests = (EventKeywords)0x0002; + } +} +``` +Keywords must be defined by using a nested class called Keywords and each individual keyword is defined by a member typed public const EventKeywords. + +Keywords are more important when distinguishing between high volume events. This allows an event consumer to raise the verbosity to a high level but manage the performance overhead and log size by only enabling narrow subsets of the events. Events that are triggered more than 1,000/sec are good candidates for a unique keyword. +For example, if you have a high volume of events related to database operations, you might want to create a keyword specifically for those events. This way, users can choose to enable or disable all database-related events with a single keyword. + +## EventSource Levels +Use levels less than Informational for relatively rare warnings or errors. When in doubt, stick with the default of Informational and use Verbose for events that occur more frequently than 1000 events/sec. + +## EventSource methods + +### Rules for defining event methods +Any instance, non-virtual, void returning method defined in an EventSource class is by default an event logging method. +Virtual or non-void-returning methods are included only if they're marked with the System.Diagnostics.Tracing.EventAttribute +To mark a qualifying method as non-logging you must decorate it with the System.Diagnostics.Tracing.NonEventAttribute +Event logging methods have event IDs associated with them. This can be done either explicitly by decorating the method with a System.Diagnostics.Tracing.EventAttribute or implicitly by the ordinal number of the method in the class. For example using implicit numbering the first method in the class has ID 1, the second has ID 2, and so on. +Event logging methods must call a WriteEvent, WriteEventCore, WriteEventWithRelatedActivityId or WriteEventWithRelatedActivityIdCore overload. +The event ID, whether implied or explicit, must match the first argument passed to the WriteEvent* API it calls. +The number, types and order of arguments passed to the EventSource method must align with how they're passed to the WriteEvent* APIs. For WriteEvent the arguments follow the Event ID, for WriteEventWithRelatedActivityId the arguments follow the relatedActivityId. For the WriteEvent*Core methods, the arguments must be serialized manually into the data parameter. +Event names cannot contain < or > characters. While user-defined methods also cannot contain these characters, async methods will be rewritten by the compiler to contain them. To be sure these generated methods don't become events, mark all non-event methods on an EventSource with the NonEventAttribute. + +### Best practices +Types that derive from EventSource usually don't have intermediate types in the hierarchy or implement interfaces. See Advanced customizations below for some exceptions where this may be useful. +Generally the name of the EventSource class is a bad public name for the EventSource. Public names, the names that will show up in logging configurations and log viewers, should be globally unique. Thus it's good practice to give your EventSource a public name using the System.Diagnostics.Tracing.EventSourceAttribute. The name "Demo" used above is short and unlikely to be unique so not a good choice for production use. A common convention is to use a hierarchical name with . or - as a separator, such as "MyCompany-Samples-Demo", or the name of the Assembly or namespace for which the EventSource provides events. It's not recommended to include "EventSource" as part of the public name. +Assign Event IDs explicitly, this way seemingly benign changes to the code in the source class such as rearranging it or adding a method in the middle won't change the event ID associated with each method. +When authoring events that represent the start and end of a unit of work, by convention these methods are named with suffixes 'Start' and 'Stop'. For example, 'RequestStart' and 'RequestStop'. +Do not specify an explicit value for EventSourceAttribute’s Guid property, unless you need it for backwards compatibility reasons. The default Guid value is derived from the source’s name, which allows tools to accept the more human-readable name and derive the same Guid. +Call IsEnabled() before performing any resource intensive work related to firing an event, such as computing an expensive event argument that won't be needed if the event is disabled. +Attempt to keep EventSource object back compatible and version them appropriately. The default version for an event is 0. The version can be changed by setting EventAttribute.Version. Change the version of an event whenever you change the data that is serialized with it. Always add new serialized data to the end of the event declaration, that is, at the end of the list of method parameters. If this isn't possible, create a new event with a new ID to replace the old one. +When declaring events methods, specify fixed-size payload data before variably sized data. +Do not use strings containing null characters. When generating the manifest for ETW EventSource will declare all strings as null terminated, even though it is possible to have a null character in a C# String. If a string contains a null character the entire string will be written to the event payload, but any parser will treat the first null character as the end of the string. If there are payload arguments after the string, the remainder of the string will be parsed instead of the intended value. + +### Performance Considerations + +**CRITICAL: Always check IsEnabled() before expensive operations** + +Event method call sites should always call `Log.IsEnabled(level, keyword)` before performing any potentially complex calculations, string formatting, or other expensive operations to avoid introducing performance regressions when tracing is disabled. + +When events are disabled (which is the default state), the EventSource infrastructure is highly optimized and calling event methods has minimal overhead. However, any work done to prepare event arguments (such as string formatting, collection enumeration, or complex calculations) will still be executed even when events are disabled. + +**Example of INCORRECT usage (performance regression):** +```C# +// BAD: This will always execute the expensive operation, even when events are disabled +string expensiveData = GenerateExpensiveReport(); // Always executes! +SmoEventSource.Log.DatabaseOperation("Operation completed", expensiveData); +``` + +**Example of CORRECT usage (performance optimized):** +```C# +// GOOD: Only execute expensive operations when events are actually enabled +if (SmoEventSource.Log.IsEnabled(EventLevel.Informational, Keywords.Database)) +{ + string expensiveData = GenerateExpensiveReport(); // Only executes when needed + SmoEventSource.Log.DatabaseOperation("Operation completed", expensiveData); +} +``` + +**Additional performance guidelines:** +- Use `IsEnabled(EventLevel level, EventKeywords keywords)` to check both level and keyword filters +- For high-frequency events (>1000/sec), always use IsEnabled() checks +- Keep event argument preparation lightweight when IsEnabled() checks aren't practical +- Truncate large strings before passing to event methods to avoid excessive ETW payload sizes +- Consider using separate events for different verbosity levels rather than complex conditional logic + +**Example with level and keyword checking:** +```C# +// Check both level and keywords for precise control +if (SmoEventSource.Log.IsEnabled(EventLevel.Verbose, Keywords.Performance)) +{ + var queryText = TruncateSqlForLogging(command.CommandText, 200); + var duration = stopwatch.ElapsedMilliseconds; + SmoEventSource.Log.QueryExecutionCompleted(queryText, duration, rowsAffected); +} +``` + +### Supported parameter types + +EventSource requires that all event parameters can be serialized so it only accepts a limited set of types. These are: + +- Primitives: bool, byte, sbyte, char, short, ushort, int, uint, long, ulong, float, double, IntPtr, and UIntPtr, Guid decimal, string, DateTime, DateTimeOffset, TimeSpan +- Enums +- Structures attributed with System.Diagnostics.Tracing.EventDataAttribute. Only the public instance properties with serializable types will be serialized. +- Anonymous types where all public properties are serializable types +- Arrays of serializable types +- Nullable where T is a serializable type +- KeyValuePair where T and U are both serializable types +- Types that implement IEnumerable for exactly one type T and where T is a serializable type \ No newline at end of file diff --git a/.scripts/ValidateXmlSchema.ps1 b/.scripts/ValidateXmlSchema.ps1 new file mode 100644 index 00000000..4dc76ea8 --- /dev/null +++ b/.scripts/ValidateXmlSchema.ps1 @@ -0,0 +1,129 @@ +<# +.SYNOPSIS + Validates XML files against an XSD schema file. + +.DESCRIPTION + This script validates all XML files in a specified folder (including subfolders) against an XSD schema. + The script compiles the schema and validates each XML file, reporting any validation errors or exceptions. + +.PARAMETER XmlFilesFolder + The folder path containing XML files to validate. The script will recursively search for files matching + the Include pattern in this folder and all subfolders. + +.PARAMETER SchemaFile + The path to the XSD schema file used for validation. The script will exit with an error if this file + does not exist. + +.PARAMETER Include + File pattern to match when searching for XML files. Defaults to "*.xml" to match all XML files. + Can be customized to validate specific file patterns (e.g., "EnumObject_*.xml"). + +.EXAMPLE + .\ValidateXmlSchema.ps1 -XmlFilesFolder "C:\Project\xml" -SchemaFile "C:\Project\schema.xsd" + + Validates all *.xml files in C:\Project\xml and subfolders against schema.xsd + +.EXAMPLE + .\ValidateXmlSchema.ps1 -XmlFilesFolder ".\xml" -SchemaFile ".\EnumObject.xsd" -Include "*.xml" + + Validates all XML files matching *.xml pattern against EnumObject.xsd + +.NOTES + Exit Codes: + - 0: All files validated successfully + - 1: Validation errors found or script error (schema not found, no XML files, etc.) + + MSBuild Integration: + Error messages use the format "ValidateXmlSchema.ps1: error VSX001: message" which MSBuild automatically + recognizes and includes in the build error summary. See https://learn.microsoft.com/en-us/visualstudio/msbuild/exec-task +#> +param( + [Parameter(Mandatory=$true)] + [string]$XmlFilesFolder, + + [Parameter(Mandatory=$true)] + [string]$SchemaFile, + + [Parameter(Mandatory=$false)] + [string]$Include = "*.xml" +) + +# Validate schema file exists +if (-not (Test-Path $SchemaFile)) { + Write-Host "ERROR: Schema file not found: $SchemaFile" -ForegroundColor Red + exit 1 +} + +# Load schema +$schemaSet = New-Object System.Xml.Schema.XmlSchemaSet +$schemaSet.Add($null, $SchemaFile) | Out-Null +$schemaSet.Compile() + +# Get XML files to validate +$xmlFiles = Get-ChildItem -Path $XmlFilesFolder -Include $Include -File -Recurse + +if ($xmlFiles.Count -eq 0) { + Write-Host "ERROR: No XML files found in: $XmlFilesFolder" -ForegroundColor Red + exit 1 +} + +Write-Host "Validating $($xmlFiles.Count) XML files in folder: $XmlFilesFolder against schema: $SchemaFile" -ForegroundColor Cyan +Write-Host "" + +$validationErrors = @() +$validatedCount = 0 + +foreach ($xmlFile in $xmlFiles) { + try { + $xmlDoc = New-Object System.Xml.XmlDocument + $xmlDoc.Schemas = $schemaSet + + $fileErrors = @() + $validationEventHandler = { + param($sender, $e) + $script:fileErrors += "$($e.Severity): $($e.Message) at line $($e.Exception.LineNumber), position $($e.Exception.LinePosition)" + } + + $xmlDoc.Load($xmlFile.FullName) + $xmlDoc.Validate($validationEventHandler) + + if ($fileErrors.Count -gt 0) { + $validationErrors += "File: $($xmlFile.FullName)" + $validationErrors += $fileErrors + $validationErrors += "" + } + else { + $validatedCount++ + } + } + catch { + $validationErrors += "File: $($xmlFile.FullName)" + $validationErrors += "ERROR: $($_.Exception.Message)" + $validationErrors += "" + } +} + +Write-Host "" + +if ($validationErrors.Count -gt 0) { + # In order for the messages to show up in the build summary we prefix the important messages with + # "ValidateXmlSchema.ps1: error VSX001: " so that msbuild recognizes it as + # an error. Otherwise users will have to dig up through the logs to find the actual errors. + # See IgnoreStandardErrorWarningFormat in https://learn.microsoft.com/en-us/visualstudio/msbuild/exec-task?view=visualstudio + Write-Host "========================================" -ForegroundColor Red + Write-Host "XML Schema Validation Failed" -ForegroundColor Red + Write-Host "========================================" -ForegroundColor Red + Write-Host "" + $validationErrors | ForEach-Object { Write-Host "ValidateXmlSchema.ps1: error VSX001: $_" -ForegroundColor Red } + Write-Host "" + Write-Host "ValidateXmlSchema.ps1: error VSX001: Fix the above errors and try again. If the schema is incorrect update $SchemaFile." + Write-Host "Summary: $validatedCount of $($xmlFiles.Count) files validated successfully" -ForegroundColor Red + exit 1 +} +else { + Write-Host "========================================" -ForegroundColor Green + Write-Host "All XML files validated successfully!" -ForegroundColor Green + Write-Host "========================================" -ForegroundColor Green + Write-Host "Total files validated: $validatedCount" -ForegroundColor Green + exit 0 +} diff --git a/CHANGELOG.md b/CHANGELOG.md index ba9b4de8..2995897c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,25 @@ Update this document for externally visible changes. Put most recent changes first. Once we push a new version to nuget.org add a double hash header for that version. +## 181.12.0 + +- Remove SQL Server 2005 and prior version support: + - Updated XML metadata files to require minimum SQL Server version 10 (SQL Server 2008) + - Removed version checks and conditional code for SQL Server versions 7, 8, and 9 + - Simplified version-specific logic in ConnectionInfo, Sdk.Sfc, Smo, and SqlEnum projects + - Preserved all public API constants and enumerations for backward compatibility +- Major version bump of packages to 181 +- Upgrade SqlClient to 6.1 +- Support vector and json value scripting natively +- Support external models +- Fix scripting of objects with columns for Synapse Serverless servers +- Add GroupMaximumTempdbDataMB and GroupMaximumTempdbDataPercent parameter in CREATE WORKLOAD GROUP script +- Fix the format of ALTER WORKLOAD GROUP script +- Remove unneeded CAST from vector and json INSERT script generation +- Use `DataReader.GetString` to retrieve formatted vector data for INSERT script generation +- Expose the MAX_DURATION property of event session. + + ## 180.10.0 - Change SMO collections to implement IEnumerator diff --git a/Directory.Packages.props b/Directory.Packages.props index fa6c40bc..1ee76e39 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -6,7 +6,7 @@ --> - 6.0.0 + 8.0.0 true true @@ -14,20 +14,18 @@ - - - - - - - + - - + @@ -38,21 +36,20 @@ - + + + + + + - - - - + - - - - - + + diff --git a/Nuget/CHANGELOG.md b/Nuget/CHANGELOG.md deleted file mode 100644 index 109809dc..00000000 --- a/Nuget/CHANGELOG.md +++ /dev/null @@ -1,216 +0,0 @@ -# Introduction - -This file will no longer be updated. Changes will be logged to [CHANGELOG.md](../ChangeLog.md) - -## 161.48028.0 - -- Add certificate and asymmetric key user support for Azure DB -- Change the name of the XML file used by SSMS 19 to RegSrvr16.xml - -## 161.47027.0 - -- Fix distribution columns on scripting for taking into consideration more than one distribution column -- Add new EXTGOV_OPERATION_GROUP audit action type -- Force [QUOTED_IDENTIFIER ON](https://github.com/microsoft/sqlmanagementobjects/issues/96) for all tables -- Change Databases enumeration on Azure DB to ignore `sys.databases` entries that don't have an entry in `sys.database_service_objectives`. Prevents attempted logins to user databases when enumerating databases on the logical master -- Update permissions enumeration for SQL Server 2022 - -## 161.47021.0 - -- Add `LedgerViewSchema` property to table objects -- Fix an issue that caused ledger tables with views with different schemas to be scripted improperly -- Added support for `Contained Availability Groups`: new AvailabilityGroup.IsContained and AvailabilityGroup.ReuseSystemDatabases properties and updated Create() method. -- Fixed generate scripts test for SQL 2012 -- Added automated tests for `JobServer` methods -- Marked several `JobServer` methods supporting SQL 2005 and earlier as Obsolete -- Marked unused property `JobServerFilter.OldestFirst` as Obsolete -- Add `IsDroppedLedgerTable` and `IsDroppedLedgerView` properties to table and view objects, respectively -- Add `IsDroppedLedgerColumn` properties to column, and updated scripting to not include dropped ledger columns in script creation -- Fixed heuristic in [Wmi.ManagedComputer](https://github.com/microsoft/sqlmanagementobjects/issues/83) to determine the correct WMI namespace to connect to, - to workaround a bug where SQL Setup setup does not fully uninstall the SQL WMI Provider. -- Update `ConnectionManager.InternalConnect` to retry connection in response to error 42109 (serverless instance is waking up) - -## 170.6.0-preview - -- Add SmoMetadataProvider preview package - -## 170.5.0-preview - -- Upgrade Microsoft.Data.SqlClient to version 5.0 -- Upgrade build tools to VS2022 - -## 161.47027.0 - -- Fix distribution columns on scripting for taking into consideration more than one distribution column -- Add new EXTGOV_OPERATION_GROUP audit action type -- Force [quoted identifier on](https://github.com/microsoft/sqlmanagementobjects/issues/96) for table scripts -- Fix EnumObjects sort by Schema -- Add new enumeration values for SQL Server 2022 permissions -- Script FIRST_ROW support for serverless Synapse - -## 161.47008.0 - -- Fix an issue that caused `ServerConnection.SqlExecutionModes` property to be set to `ExecuteSql` during lazy property fetches of SMO objects despite being set to `CaptureSql` by the calling application. -- Add `LoginType` property to `ILoginOptions` interface. -- `Login.PasswordPolicyEnforced` now returns `false` for Windows logins instead of throwing an exception -- Remove net461 binaries from nuget packages -- Added Scripting Support for Ledger tables for Sql 2022+ -- Change the `Size` property on `Server/Drive` objects to `System.Int64`. These objects don't have a C# wrapper class so it's not breaking any compilation. -- Add support for Sql Server version 16 -- Add new permissions for Sql 2019+ to SMO enumerations -- Added External Stream object and External Streaming Jobs object for scripting -- Add support for XML compression - -## 161.46521.71 - -- Handle Dedicated SQL Pool login error 110003 during enumerate of Databases -- Enable asymmetric and symmetric key objects for dedicated SQL Pool database -- Fix Tables enumeration on Azure SQL Database instances using a case sensitive catalog collation -- Fix scripting of [hidden columns](https://github.com/microsoft/sqlmanagementobjects/issues/65) -- Enable Generate Scripts to script temporal tables when the destination is a pre-2016 version of SQL Server. System versioning DDL will be omitted from the generated script. - - -## 161.46437.65 - -- Update Microsoft.Data.SqlClient dependency to version 3.0.0 -- Added Scripting Support for Ledger table in Azure Sql db -- Change `Server.MasterDBPath` and `Server.MasterDBLogPath` properties to use `file_id` instead of `name` from `sys.database_files` -- Enable Index creation for memory optimized tables in Azure -- Fix Server/Logins to show external Logins for Azure SQLDB as they are now supported -- Split SmoMetadataProvider into its own nuget packages -- Adding support for External Languages - -## 161.46347.54 - -- Add Microsoft.SqlServer.SqlWmiManagement and Microsoft.SqlServer.Management.Smo.Wmi to lib\netcoreapp3.1 -- Add missing resource files for netcoreapp3.1 and netstandard2.0 -- Fix an [issue](https://github.com/microsoft/sqlmanagementobjects/issues/50) with scripting Azure Synapse Analytics databases -- Add missing values to AuditActionType enum -- Fixed an issue where AffinityInfo.Alter() may throw an error like `An item with the same key has already been added` when - trying to update the AffinityMask of a specific CPU, particularly on machines with Soft-NUMA. -- Updated formatting logic of Predicate values in XEvent scripts -- Fix for scripting distributed Availability Groups -- Add support for resumable option on create constraints and low priority wait - -## 161.46041.41 - -- Add descriptions to more Facet properties -- Add net461 binaries due to customer demand. Only core scripting functionality is included in lib\net461 -- Make RegisteredServersStore.InitializeLocalRegisteredServersStore public to enable loading and saving registered servers in a custom location -- Fixed an [issue](https://github.com/microsoft/sqlmanagementobjects/issues/34) - where the creation of a DataFile may fail when targeting a SQL Azure Managed Instance -- Fix Database.Checkpoint to always checkpoint the correct database. [Issue 32](https://github.com/microsoft/sqlmanagementobjects/issues/32) - -## 161.44091.28 - -- Make ISmoScriptWriter interface public -- Enable apps to provide custom ISmoScriptWriter implementation to SqlScriptPublishModel and ScriptMaker -- Enabled Security Policy objects to be included in Transfer -- Change association of DatabaseEngineEdition.SqlOnDemand to DatabaseEngineType.SqlAzureDatabase -- Fix implementation of Microsoft.SqlServer.Management.HadrModel.FailoverTask.Perform to handle AvailabilityGroupClusterType.None correctly - -## 161.42121.15-msdata - -- Add netcoreapp3.1 build output -- Fix [logins using impersonation](https://github.com/microsoft/sqlmanagementobjects/issues/24) -- Expose OlapConnectionInfo class in non-netfx ConnectionInfo -- Expose WmiMgmtScopeConnection in non-netfx ConnectionInfo -- Enable OPTIMIZE_FOR_SEQUENTIAL_KEY index option for Azure SQL Database - -## 161.41981.14-msdata, 161.41981.14-preview - -- Expose [accelerated database recovery](https://github.com/microsoft/sqlmanagementobjects/issues/22) settings for Database class -- Enable Column.BindDefault on Azure SQL Database -- Add DestinationServerConnection property to Transfer - - [Github issue 16](https://github.com/microsoft/sqlmanagementobjects/issues/16) - - Allows for use of Azure SQL Database as a destination server - - Enables full customization of the destination connection -- [Script User objects for Azure SQL Database correctly](https://github.com/microsoft/sqlmanagementobjects/issues/18) -- [Enable CreateOrAlter behavior for Scripter](https://github.com/microsoft/sqlmanagementobjects/issues/11) -- Fixed issue where MaxSize value was reported as negative for Hyperscale Azure SQL Databases - Added new property "IsMaxSizeApplicable" and disabled negative values for Hyperscale Azure SQL Databases. - -## 161.41011.9 - -- First non-preview release of major package version 161 -- Microsoft.SqlServer.SqlManagementObjects.SSMS has binaries matching those shipping in SSMS 18.6 -- Put `begin try/begin catch` around TSQL querying `sys.database_service_objectives` in Azure SQL Database. This view may throw if Azure control plane has an outage and was blocking expansion of the Databases node in SSMS. - -## 161.40241.8-msdata and 161.40241.8-preview - -- Increase package major version to 161. Assembly major version remains 16 -- Change assembly minor version to 200 for Microsoft.SqlServer.SqlManagementObjects package -- Change NetFx binaries to use Microsoft.Data.SqlClient as their SQL client driver, replacing System.Data.SqlClient -- Created new package, Microsoft.SqlServer.SqlManagementObjects.SSMS, for use by SSMS and SSDT. - This package has NetFx binaries still dependent on System.Data.SqlClient. It uses assembly minor version 100 -- Update Microsoft.Data.SqlClient dependency to version 2.0.0 -- Handle SQL error code 4060 during fetch of Database.DatabaseEngineEdition and use default value of Unknown -- Fixed Database.Size property to report the accurate size of the database when - DatabaseEngineType is SqlAzureDatabase -- Fixed issue where Database.SpaceAvailable was reported as negative for Hyperscale Azure SQL Databases - (the value is reported as 0, meaning *Unavailable*) -- Implement IObjectPermission on DatabaseScopedCredential. -- Enabled Server.EnumServerAttributes API on Azure SQL Database -- Enabled Lock enumeration APIs on Azure SQL Database -- Deleted the Database.CheckIdentityValues API -- Added new property "RequestMaximumMemoryGrantPercentageAsDouble" in WorkloadGroup to accept decimal values in Resource Governor (SQL2019 and above). -- Fixed a scripting issue with statistics on filtered indexes where the filter from the index would be scripted with the UPDATE STATISTICS TSQL. -- Enabled Security Policy and Security Predicate objects on Azure SQL DataWarehouse - -## 160.2004021.0 - -- First non-preview 160 release, aligned with [SQL Server Management Studio](https://aka.ms/ssmsfullsetup) 18.5 -- Script extended properties for Azure SQL Database objects -- Enable Jupyter Notebook output for SqlScriptPublishModel. SSMS 18.5 can output a Notebook for Azure Data Studio in Generate Scripts now. -- Fix issue where Table.EnableAllIndexes(Recreate) did nothing -- Fix Database.EnumObjectPermissions usage in NetStandard binaries -- Remove FORCE ORDER hint from table enumeration that was causing major performance issues -- Fix Transfer with PrefetchAllObjects == false for pre-Sql 2014 versions so it doesn't throw an exception -- Extend value range for platform, name, and engineEdition JSON properties of SQL Assessment targets with arrays of strings: - - ```JSON - "target": { - "platform": ["Windows", "Linux"], - "name": ["master", "temp"] - } - ``` - -- Add 13 new [SQL Assessment rules](https://github.com/microsoft/sql-server-samples/blob/master/samples/manage/sql-assessment-api/release-notes.md) -- Fix help link in XTPHashAvgChainBuckets SQL Assessment rule -- Units for threshold parameter of FullBackup SQL Assessment rule changed from hours to days - -## 160.201141.0-preview - -- Remove unneeded "using" TSQL statements from Database.CheckTables method implementations -- Enable ColumnMasterKey properties Signature and AllowEnclaveComputations for Azure SQL DB -- Fix Database.EncryptionEnabled and Database.DatabaseEncryptionKey behavior during Database.Alter(). Now, this code will correctly create a new key using the server certificate named MyCertificate: - - ```C# - db.EncryptionEnabled = true; - db.DatabaseEncryptionKey.EncryptorName = "MyCertificate"; - db.DatabaseEncryptionKey.EncryptionAlgorithm = DatabaseEncryptionAlgorithm.Aes256; - db.DatabaseEncryptionKey.EncryptionType = DatabaseEncryptionType.ServerCertificate; - db.Alter() - ``` - -- Fixed the "like" and "contains" URN filter functions to work with parameters containing single quotes. These operators can be used to optimally initialize collections: - - ```C# - // populate the collection with databases that have Name starting with "RDA" - var server = Server(new ServerConnection(sqlConnection)); - server.Databases.ClearAndInitialize("[like(@Name, 'RDA%')]", new string[] { }); - ``` - -- Make Table.Location property optional for creating or scripting external tables. -- Enable scripting of ANSI_PADDING settings for Azure SQL Database tables. -- Remove obsolete types ServerActiveDirectory and DatabaseActiveDirectory -- Added BLOB_STORAGE scripting support for external data sources -- Fixed [error scripting external tables](https://feedback.azure.com/forums/908035-sql-server/suggestions/38267746-cannot-script-external-table-in-ssms-18-2) for Azure SQL Database -- Replace Microsoft.SqlServer.Management.SqlParser.dll with a dependency to its Nuget package - -## 160.1911221.0-preview - -- Increase major version from 15 to 16 -- Remove dependency on native batch parser from NetFx components -- Change NetStandard client driver to Microsoft.Data.SqlClient -- Add distribution property for DW materialized views -- Script FILLFACTOR for indexes on Azure SQL Database diff --git a/SmoBuild/DdlEvents/eventsdef.cpp b/SmoBuild/DdlEvents/eventsdef.cpp deleted file mode 100644 index 57b5d040..00000000 --- a/SmoBuild/DdlEvents/eventsdef.cpp +++ /dev/null @@ -1,3503 +0,0 @@ -//**************************************************************************** -// Copyright (c) Microsoft Corporation. -// -// @File: eventsdef.cpp -// @Owner: ivanpe, ketandu -// @Test: antonk, sshekar -// -// Purpose: This file contains all event type definitions. It's main purpose is -// to be included in eventsshema.cpp. Several perl scripts are parsing -// this file in order to get to the event type definitions. -// -// Note: If you are updating this file then you must also update the events.xsd -// schema, in Sql\Common\xsd\sqlserver\2006\events\events.xsd and -// published at http://schemas.microsoft.com/sqlserver/2006/11/eventdata/events.xsd -// with RTM releases of SQL Server. -// -// A stub for events.xsd can be generated using perl scripts, but must be tweaked -// to ensure ensure backwards compatibility. -// -// Building from sql\ntdbms\sqlwep\dllsrc (from an x86fre razzle) will generate -// the stub events.xsd in %OBJECT_ROOT%\sql\ntdbms\sqlwep\dllsrc\objfre\i386. -// -// Please refer to http://sqlserver/SQLBU/sqlxsd/default.aspx for instructions on -// publishing the events.xsd. -// -// @EndHeader@ -//**************************************************************************** - -#define BitCount1(x)\ - (((x&0xAAAAAAAAAAAAAAAA)>>1) + (x&0x5555555555555555)) -#define BitCount2(x)\ - (((x&0xCCCCCCCCCCCCCCCC)>>2) + (x&0x3333333333333333)) -#define BitCount4(x)\ - (((x&0xF0F0F0F0F0F0F0F0)>>4) + (x&0x0F0F0F0F0F0F0F0F)) -#define BitCount8(x)\ - (((x&0xFF00FF00FF00FF00)>>8) + (x&0x00FF00FF00FF00FF)) -#define BitCount16(x)\ - (((x&0xFFFF0000FFFF0000)>>16) + (x&0x0000FFFF0000FFFF)) -#define BitCount32(x)\ - (((x&0xFFFFFFFF00000000)>>32) + (x&0x00000000FFFFFFFF)) - -#define BitCount64(x)\ - (BitCount32(BitCount16(BitCount8(BitCount4(BitCount2(BitCount1((x)))))))) - - -// The Envelope properties are divided into 3 groups -// The 1st 3 are common for all event types. -// The next 2 are only for non-trace event types. -// The next one is only for event types that are not server level only. -// -//---------------------------------------------------------------- -// Event Envelope Instance Schema (instance parameters schema) -//---------------------------------------------------------------- - -STATIC EVENT_PARAM_INFO_DEF s_rgParamInfoEnvelope[] = -{ - { EnvelopeTag_EventType, L"EventType", 0,0,NULL,XVT_VARWSTR, PrecDefault(XVT_VARWSTR),ScaleDefault(XVT_VARWSTR),x_cbMAXSSWNAME,0}, - { EnvelopeTag_PostTime, L"PostTime", 0,0,NULL,XVT_SSDATE, PrecDefault(XVT_SSDATE), ScaleDefault(XVT_SSDATE), LenDefault(XVT_SSDATE),0}, - { EnvelopeTag_SPID, L"SPID", 0,0,NULL,XVT_I4, PrecDefault(XVT_I4), ScaleDefault(XVT_I4), LenDefault(XVT_I4), 0}, - - //---------------------------------------------------------------- - // Additional Event Envelope Instance Schema for non-trace events (instance parameters schema) - //---------------------------------------------------------------- - - // The server name is of the form "ComputerName\InstanceName" - { EnvelopeTag_ServerName, L"ServerName", 0,0,NULL,XVT_VARWSTR,PrecDefault(XVT_VARWSTR),ScaleDefault(XVT_VARWSTR),(x_cwchMAXSSWNAME*2 + 1)*sizeof(WCHAR),EVENT_PARAM_NULLABLE}, - { EnvelopeTag_LoginName, L"LoginName", 0,0,NULL,XVT_VARWSTR, PrecDefault(XVT_VARWSTR),ScaleDefault(XVT_VARWSTR),x_cbMAXSSWNAME,0}, - - //---------------------------------------------------------------- - // Additional Event Envelope Instance Schema for non-server level events (instance parameters schema) - //---------------------------------------------------------------- - - { EnvelopeTag_UserName, L"UserName", 0,0,NULL,XVT_VARWSTR,PrecDefault(XVT_VARWSTR),ScaleDefault(XVT_VARWSTR),x_cbMAXSSWNAME,0}, -}; - -STATIC ULONG s_cParamInfoEnvelope = NUMELEM(s_rgParamInfoEnvelope); - -//================================================= -// Param info for SQLTrace -#include "parinfo.inc" - -// The new param info array. We dont need a param info array per event type. We will just -// have a global one that can be shared by the various event types. -// -STATIC EVENT_PARAM_INFO_DEF s_rgParamInfoDDL[] = -{ - { EventTag_DatabaseName, L"DatabaseName", 0,0,NULL,XVT_VARWSTR,PrecDefault(XVT_VARWSTR), ScaleDefault(XVT_VARWSTR), x_cbMAXSSWNAME, EVENT_PARAM_NULLABLE}, - { EventTag_SchemaName, L"SchemaName", 0,0,NULL,XVT_VARWSTR,PrecDefault(XVT_VARWSTR), ScaleDefault(XVT_VARWSTR), x_cbMAXSSWNAME, EVENT_PARAM_NULLABLE}, - { EventTag_ObjectName, L"ObjectName", 0,0,NULL,XVT_VARWSTR,PrecDefault(XVT_VARWSTR), ScaleDefault(XVT_VARWSTR), x_cbMAXSSWNAME, EVENT_PARAM_NULLABLE}, - { EventTag_ObjectType, L"ObjectType", 0,0,NULL,XVT_VARWSTR,PrecDefault(XVT_VARWSTR), ScaleDefault(XVT_VARWSTR), x_cbMAXSSWNAME, EVENT_PARAM_NULLABLE}, - { EventTag_RoleName, L"RoleName", 0,0,NULL,XVT_VARWSTR,PrecDefault(XVT_VARWSTR), ScaleDefault(XVT_VARWSTR), x_cbMAXSSWNAME, EVENT_PARAM_NULLABLE}, - { EventTag_TSQLCommand, L"TSQLCommand", 0,0,NULL,XVT_VARWSTR,PrecDefault(XVT_VARWSTR), ScaleDefault(XVT_VARWSTR), VARTYPE_UNLIMITED_LENGTH, 0}, - { EventTag_TargetServerName, L"TargetServerName",0,0,NULL,XVT_VARWSTR,PrecDefault(XVT_VARWSTR),ScaleDefault(XVT_VARWSTR),x_cbMAXSSWNAME,EVENT_PARAM_NULLABLE}, - { EventTag_TargetDatabaseName, L"TargetDatabaseName", 0,0,NULL,XVT_VARWSTR,PrecDefault(XVT_VARWSTR), ScaleDefault(XVT_VARWSTR), x_cbMAXSSWNAME, EVENT_PARAM_NULLABLE}, - { EventTag_TargetSchemaName, L"TargetSchemaName", 0,0,NULL,XVT_VARWSTR,PrecDefault(XVT_VARWSTR), ScaleDefault(XVT_VARWSTR), x_cbMAXSSWNAME, EVENT_PARAM_NULLABLE}, - { EventTag_TargetObjectName, L"TargetObjectName", 0,0,NULL,XVT_VARWSTR,PrecDefault(XVT_VARWSTR), ScaleDefault(XVT_VARWSTR), x_cbMAXSSWNAME, EVENT_PARAM_NULLABLE}, - { EventTag_TargetObjectType, L"TargetObjectType", 0,0,NULL,XVT_VARWSTR,PrecDefault(XVT_VARWSTR), ScaleDefault(XVT_VARWSTR), x_cbMAXSSWNAME, EVENT_PARAM_NULLABLE}, - { EventTag_OwnerName, L"OwnerName", 0,0,NULL,XVT_VARWSTR,PrecDefault(XVT_VARWSTR), ScaleDefault(XVT_VARWSTR), x_cbMAXSSWNAME, 0}, - { EventTag_DefaultLanguage, L"DefaultLanguage", 0,0,NULL,XVT_VARWSTR,PrecDefault( XVT_VARWSTR ), ScaleDefault( XVT_VARWSTR ), x_cbMAXSSWNAME, EVENT_PARAM_NULLABLE}, - { EventTag_DefaultDatabase, L"DefaultDatabase", 0,0,NULL,XVT_VARWSTR,PrecDefault( XVT_VARWSTR ), ScaleDefault( XVT_VARWSTR ), x_cbMAXSSWNAME, EVENT_PARAM_NULLABLE}, - { EventTag_LoginType, L"LoginType", 0,0,NULL,XVT_VARWSTR,PrecDefault( XVT_VARWSTR ), ScaleDefault( XVT_VARWSTR ), x_cbMAXSSWNAME, 0}, - { EventTag_SID, L"SID", 0,0,NULL,CTypeInfo::tiSID.XvtType(), PrecDefault(CTypeInfo::tiSID.XvtType()),ScaleDefault(CTypeInfo::tiSID.XvtType()),x_cbMaxSID,EVENT_PARAM_NULLABLE}, - { EventTag_RoleSID, L"RoleSID", 0,0,NULL,CTypeInfo::tiSID.XvtType(), PrecDefault(CTypeInfo::tiSID.XvtType()),ScaleDefault(CTypeInfo::tiSID.XvtType()),x_cbMaxSID, EVENT_PARAM_NULLABLE}, - { EventTag_Grantor, L"Grantor", 0,0,NULL,XVT_VARWSTR,PrecDefault(XVT_VARWSTR), ScaleDefault(XVT_VARWSTR), x_cbMAXSSWNAME, 0}, - { EventTag_Permissions, L"Permissions", 0,0,NULL,XVT_VARWSTR,PrecDefault(XVT_VARWSTR), ScaleDefault(XVT_VARWSTR), VARTYPE_UNLIMITED_LENGTH, 0}, - { EventTag_Grantees, L"Grantees", 0,0,NULL,XVT_VARWSTR,PrecDefault(XVT_VARWSTR), ScaleDefault(XVT_VARWSTR), VARTYPE_UNLIMITED_LENGTH, 0}, - { EventTag_AsGrantor, L"AsGrantor", 0,0,NULL,XVT_VARWSTR,PrecDefault(XVT_VARWSTR), ScaleDefault(XVT_VARWSTR), x_cbMAXSSWNAME, EVENT_PARAM_NULLABLE}, - { EventTag_GrantOption, L"GrantOption", 0,0,NULL,XVT_BIT, PrecDefault(XVT_BIT), ScaleDefault(XVT_BIT), LenDefault(XVT_BIT),0}, - { EventTag_CascadeOption, L"CascadeOption", 0,0,NULL,XVT_BIT, PrecDefault(XVT_BIT), ScaleDefault(XVT_BIT), LenDefault(XVT_BIT),0}, - { EventTag_PrimaryXMLIndexName, L"PrimaryXMLIndexName", 0,0,NULL,XVT_VARWSTR,PrecDefault(XVT_VARWSTR), ScaleDefault(XVT_VARWSTR), x_cbMAXSSWNAME, EVENT_PARAM_NULLABLE}, - { EventTag_SecondaryXMLIndexType, L"SecondaryXMLIndexType", 0,0,NULL,XVT_SSWSTR,PrecDefault(XVT_SSWSTR), ScaleDefault(XVT_SSWSTR), 2, EVENT_PARAM_NULLABLE}, - { EventTag_CertificatePath, L"CertificatePath",0,0,NULL,CTypeInfo::tiMaxPathName.XvtType(),PrecDefault(CTypeInfo::tiMaxPathName.XvtType()), - ScaleDefault(CTypeInfo::tiMaxPathName.XvtType()),sizeof(WCHAR)*MAX_PATH, EVENT_PARAM_NULLABLE}, - { EventTag_PrivateKeyPath, L"PrivateKeyPath",0,0,NULL,CTypeInfo::tiMaxPathName.XvtType(),PrecDefault(CTypeInfo::tiMaxPathName.XvtType()), - ScaleDefault(CTypeInfo::tiMaxPathName.XvtType()),sizeof(WCHAR)*MAX_PATH,EVENT_PARAM_NULLABLE}, - { EventTag_CertificateSubject, L"CertificateSubject", 0,0,NULL,XVT_VARWSTR,PrecDefault(XVT_VARWSTR), ScaleDefault(XVT_VARWSTR), x_cbMAXSSWNAME, EVENT_PARAM_NULLABLE}, - { EventTag_Function, L"Function", 0,0,NULL,XVT_VARWSTR,PrecDefault(XVT_VARWSTR), ScaleDefault(XVT_VARWSTR), x_cbMAXSSWNAME, 0}, - { EventTag_DefaultSchema, L"DefaultSchema",0,0,NULL,XVT_VARWSTR,PrecDefault(XVT_VARWSTR),ScaleDefault(XVT_VARWSTR),x_cbMAXSSWNAME, EVENT_PARAM_NULLABLE}, - { EventTag_ClientHost, L"ClientHost", 0,0,NULL,XVT_VARWSTR,PrecDefault(XVT_VARWSTR), ScaleDefault(XVT_VARWSTR), x_cbMAXSSWNAME, 0}, - { EventTag_IsPooled, L"IsPooled", 0,0,NULL,XVT_BIT, PrecDefault(XVT_BIT), ScaleDefault(XVT_BIT), LenDefault(XVT_BIT),0}, - { EventTag_Parameters, L"Parameters", 0,0,NULL,XVT_VARWSTR,PrecDefault(XVT_VARWSTR), ScaleDefault(XVT_VARWSTR), VARTYPE_UNLIMITED_LENGTH, 0}, - { EventTag_PropertyName, L"PropertyName", 0,0,NULL,XVT_VARWSTR,PrecDefault(XVT_VARWSTR), ScaleDefault(XVT_VARWSTR), x_cbMAXSSWNAME, 0}, - { EventTag_PropertyValue, L"PropertyValue", 0,0,NULL,XVT_SSVARIANT,PrecDefault(XVT_SSVARIANT), ScaleDefault(XVT_SSVARIANT), SIZEOFSSVARIANT, EVENT_PARAM_NULLABLE}, - { EventTag_NewObjectName, L"NewObjectName", 0,0,NULL,XVT_VARWSTR,PrecDefault(XVT_VARWSTR), ScaleDefault(XVT_VARWSTR), x_cbMAXSSWNAME, 0}, - { EventTag_KeyPath, L"KeyPath",0,0,NULL,CTypeInfo::tiMaxPathName.XvtType(),PrecDefault(CTypeInfo::tiMaxPathName.XvtType()), - ScaleDefault(CTypeInfo::tiMaxPathName.XvtType()),sizeof(WCHAR)*MAX_PATH, EVENT_PARAM_NULLABLE}, - { EventTag_CounterSignature, L"CounterSignature", 0,0,NULL,XVT_BIT, PrecDefault(XVT_BIT), ScaleDefault(XVT_BIT), LenDefault(XVT_BIT),0}, - { EventTag_AlterTableActionList, L"AlterTableActionList", 0,0,NULL,XVT_VARWSTR,PrecDefault(XVT_VARWSTR), ScaleDefault(XVT_VARWSTR), VARTYPE_UNLIMITED_LENGTH, 0}, - { EventTag_AlterDatabaseActionList, L"AlterDatabaseActionList", 0,0,NULL,XVT_VARWSTR,PrecDefault(XVT_VARWSTR), ScaleDefault(XVT_VARWSTR), VARTYPE_UNLIMITED_LENGTH, 0}, -}; -STATIC ULONG s_cParamInfoDDL = NUMELEM(s_rgParamInfoDDL); - -// Extended GROUP enum for SQLTrace -#include "grpenum.inc" -//================================================= - -// This array defines groups for all supported synchronous events. The array order should follow -// the order of the EEventGroup enum defined in events.h. -// -EVENT_GROUP g_rgEventGroup[] = -{ - //------------------------------------------------------------------------------------------ - // GROUP ID GROUP PARENT ID Group name For optimization - //------------------------------------------------------------------------------------------ - { EGROUP_ALL, EGROUP_INVALID, L"ALL_EVENTS", x_eet_Group_All, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL, EGROUP_ALL, L"DDL_EVENTS", x_eet_Group_Ddl, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_SERVER_LEVEL, EGROUP_DDL, L"DDL_SERVER_LEVEL_EVENTS", x_eet_Group_Ddl_Server_Level, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_ENDPOINT, EGROUP_DDL_SERVER_LEVEL, L"DDL_ENDPOINT_EVENTS", x_eet_Group_Ddl_Endpoint, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_DATABASE, EGROUP_DDL_SERVER_LEVEL, L"DDL_DATABASE_EVENTS", x_eet_Group_Ddl_Database, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_SERVER_SECURITY, EGROUP_DDL_SERVER_LEVEL, L"DDL_SERVER_SECURITY_EVENTS", x_eet_Group_Ddl_Server_Security, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_LOGIN, EGROUP_DDL_SERVER_SECURITY, L"DDL_LOGIN_EVENTS", x_eet_Group_Ddl_Login, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_GDR_SERVER, EGROUP_DDL_SERVER_SECURITY, L"DDL_GDR_SERVER_EVENTS", x_eet_Group_Ddl_Gdr_Server, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_AUTH_SERVER, EGROUP_DDL_SERVER_SECURITY, L"DDL_AUTHORIZATION_SERVER_EVENTS", x_eet_Group_Ddl_Auth_Server, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_CREDENTIAL, EGROUP_DDL_SERVER_SECURITY, L"DDL_CREDENTIAL_EVENTS", x_eet_Group_Ddl_Credential, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_CRYPTOPROV, EGROUP_DDL_SERVER_SECURITY, L"DDL_CRYPTOGRAPHIC_PROVIDER_EVENTS", x_eet_Group_Ddl_CryptoProv, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_SRVMASTERKEY, EGROUP_DDL_SERVER_SECURITY, L"DDL_SERVICE_MASTER_KEY_EVENTS", x_eet_Group_Ddl_Service_Master_Key, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_SERVERAUDIT, EGROUP_DDL_SERVER_SECURITY, L"DDL_SERVER_AUDIT_EVENTS", x_eet_Group_Ddl_ServerAudit, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_SERVERAUDITSPEC, EGROUP_DDL_SERVER_SECURITY, L"DDL_SERVER_AUDIT_SPECIFICATION_EVENTS", x_eet_Group_Ddl_ServerAuditSpec, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_EXTENDED_PROCEDURE, EGROUP_DDL_SERVER_LEVEL, L"DDL_EXTENDED_PROCEDURE_EVENTS", x_eet_Group_Ddl_Extended_Procedure, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_LINKED_SERVER, EGROUP_DDL_SERVER_LEVEL, L"DDL_LINKED_SERVER_EVENTS", x_eet_Group_Ddl_Linked_Server, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_LINKED_SERVER_LOGIN, EGROUP_DDL_LINKED_SERVER, L"DDL_LINKED_SERVER_LOGIN_EVENTS", x_eet_Group_Ddl_Linked_Server_Login, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_MESSAGE, EGROUP_DDL_SERVER_LEVEL, L"DDL_MESSAGE_EVENTS", x_eet_Group_Ddl_Message, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_REMOTE_SERVER, EGROUP_DDL_SERVER_LEVEL, L"DDL_REMOTE_SERVER_EVENTS", x_eet_Group_Ddl_Remote_Server, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_EVENT_SESSION, EGROUP_DDL_SERVER_LEVEL, L"DDL_EVENT_SESSION_EVENTS", x_eet_Group_Ddl_Event_Session, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_RESOURCE_GOVERNOR, EGROUP_DDL_SERVER_LEVEL, L"DDL_RESOURCE_GOVERNOR_EVENTS",x_eet_Group_Ddl_Resource_Governor, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_RESOURCE_POOL, EGROUP_DDL_RESOURCE_GOVERNOR,L"DDL_RESOURCE_POOL", x_eet_Group_Ddl_Resource_Pool, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_EXTERNAL_RESOURCE_POOL, EGROUP_DDL_RESOURCE_GOVERNOR,L"DDL_EXTERNAL_RESOURCE_POOL_EVENTS", x_eet_Group_Ddl_External_Resource_Pool, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_RESOURCE_GROUP, EGROUP_DDL_RESOURCE_GOVERNOR,L"DDL_WORKLOAD_GROUP", x_eet_Group_Ddl_Resource_Group, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_DATABASE_LEVEL, EGROUP_DDL, L"DDL_DATABASE_LEVEL_EVENTS", x_eet_Group_Ddl_Database_Level, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_TABLEVIEW, EGROUP_DDL_DATABASE_LEVEL, L"DDL_TABLE_VIEW_EVENTS", x_eet_Group_Ddl_Tableview, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_TABLE, EGROUP_DDL_TABLEVIEW, L"DDL_TABLE_EVENTS", x_eet_Group_Ddl_Table, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_VIEW, EGROUP_DDL_TABLEVIEW, L"DDL_VIEW_EVENTS", x_eet_Group_Ddl_View, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_INDEX, EGROUP_DDL_TABLEVIEW, L"DDL_INDEX_EVENTS", x_eet_Group_Ddl_Index, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_STATS, EGROUP_DDL_TABLEVIEW, L"DDL_STATISTICS_EVENTS", x_eet_Group_Ddl_Stats, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_SYNONYM, EGROUP_DDL_DATABASE_LEVEL, L"DDL_SYNONYM_EVENTS", x_eet_Group_Ddl_Synonym, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_FUNCTION, EGROUP_DDL_DATABASE_LEVEL, L"DDL_FUNCTION_EVENTS", x_eet_Group_Ddl_Function, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_STOREDPROC, EGROUP_DDL_DATABASE_LEVEL, L"DDL_PROCEDURE_EVENTS", x_eet_Group_Ddl_Storedproc, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_TRIGGER, EGROUP_DDL_DATABASE_LEVEL, L"DDL_TRIGGER_EVENTS", x_eet_Group_Ddl_Trigger, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_EVTNOTIF, EGROUP_DDL_DATABASE_LEVEL, L"DDL_EVENT_NOTIFICATION_EVENTS", x_eet_Group_Ddl_Evtnotif, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_ASSEMBLY, EGROUP_DDL_DATABASE_LEVEL, L"DDL_ASSEMBLY_EVENTS", x_eet_Group_Ddl_Assembly, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_UDT, EGROUP_DDL_DATABASE_LEVEL, L"DDL_TYPE_EVENTS", x_eet_Group_Ddl_Udt, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_SEQUENCE, EGROUP_DDL_DATABASE_LEVEL, L"DDL_SEQUENCE_EVENTS", x_eet_Group_Ddl_Sequence, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_LIBRARY, EGROUP_DDL_DATABASE_LEVEL, L"DDL_LIBRARY_EVENTS", x_eet_Group_Ddl_Library, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_SENSITIVITY, EGROUP_DDL_DATABASE_LEVEL, L"DDL_SENSITIVITY_EVENTS", x_eet_Group_Ddl_Sensitivity, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_EXTERNAL_LANGUAGE, EGROUP_DDL_DATABASE_LEVEL, L"DDL_EXTERNAL_LANGUAGE_EVENTS", x_eet_Group_Ddl_External_Language, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_DB_SECURITY, EGROUP_DDL_DATABASE_LEVEL, L"DDL_DATABASE_SECURITY_EVENTS", x_eet_Group_Ddl_DB_Security, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_CERTIFICATE, EGROUP_DDL_DB_SECURITY, L"DDL_CERTIFICATE_EVENTS", x_eet_Group_Ddl_Certificate, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_USER, EGROUP_DDL_DB_SECURITY, L"DDL_USER_EVENTS", x_eet_Group_Ddl_User, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_ROLE, EGROUP_DDL_DB_SECURITY, L"DDL_ROLE_EVENTS", x_eet_Group_Ddl_Role, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_APPROLE, EGROUP_DDL_DB_SECURITY, L"DDL_APPLICATION_ROLE_EVENTS", x_eet_Group_Ddl_Approle, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_SCHEMA, EGROUP_DDL_DB_SECURITY, L"DDL_SCHEMA_EVENTS", x_eet_Group_Ddl_Schema, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_GDR_DATABASE, EGROUP_DDL_DB_SECURITY, L"DDL_GDR_DATABASE_EVENTS", x_eet_Group_Ddl_Gdr_Database, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_AUTH_DATABASE, EGROUP_DDL_DB_SECURITY, L"DDL_AUTHORIZATION_DATABASE_EVENTS", x_eet_Group_Ddl_Auth_Database, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_OBFUSKEY, EGROUP_DDL_DB_SECURITY, L"DDL_SYMMETRIC_KEY_EVENTS", x_eet_Group_Ddl_Symmetric, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_ASYMKEY, EGROUP_DDL_DB_SECURITY, L"DDL_ASYMMETRIC_KEY_EVENTS", x_eet_Group_Ddl_Asymmetric, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_CRYPTOSIGN, EGROUP_DDL_DB_SECURITY, L"DDL_CRYPTO_SIGNATURE_EVENTS", x_eet_Group_Ddl_Crypto_Signature, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_DBMASTERKEY, EGROUP_DDL_DB_SECURITY, L"DDL_MASTER_KEY_EVENTS", x_eet_Group_Ddl_Master_Key, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_DEK, EGROUP_DDL_DB_SECURITY, L"DDL_DATABASE_ENCRYPTION_KEY_EVENTS", x_eet_Group_Ddl_DEK, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_DBAUDITSPEC, EGROUP_DDL_DB_SECURITY, L"DDL_DATABASE_AUDIT_SPECIFICATION_EVENTS", x_eet_Group_Ddl_DbAuditSpec, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_DBAUDIT, EGROUP_DDL_DB_SECURITY, L"DDL_DATABASE_AUDIT_EVENTS", x_eet_Group_Ddl_DatabaseAudit_Group, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_SSB, EGROUP_DDL_DATABASE_LEVEL, L"DDL_SSB_EVENTS", x_eet_Group_Ddl_Ssb, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_MSGTYPE, EGROUP_DDL_SSB, L"DDL_MESSAGE_TYPE_EVENTS", x_eet_Group_Ddl_Msgtype, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_CONTRACT, EGROUP_DDL_SSB, L"DDL_CONTRACT_EVENTS", x_eet_Group_Ddl_Contract, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_QUEUE, EGROUP_DDL_SSB, L"DDL_QUEUE_EVENTS", x_eet_Group_Ddl_Queue, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_SERVICE, EGROUP_DDL_SSB, L"DDL_SERVICE_EVENTS", x_eet_Group_Ddl_Service, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_ROUTE, EGROUP_DDL_SSB, L"DDL_ROUTE_EVENTS", x_eet_Group_Ddl_Route, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_BINDING, EGROUP_DDL_SSB, L"DDL_REMOTE_SERVICE_BINDING_EVENTS", x_eet_Group_Ddl_Binding, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_PRIORITY, EGROUP_DDL_SSB, L"DDL_BROKER_PRIORITY_EVENTS", x_eet_Group_Ddl_Priority, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_XML_SCHEMA_COLLECTION, EGROUP_DDL_DATABASE_LEVEL, L"DDL_XML_SCHEMA_COLLECTION_EVENTS", x_eet_Group_Ddl_Xml_Schema_Collection, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_PARTITION, EGROUP_DDL_DATABASE_LEVEL, L"DDL_PARTITION_EVENTS", x_eet_Group_Ddl_Partition, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_PRTFUNCTION, EGROUP_DDL_PARTITION, L"DDL_PARTITION_FUNCTION_EVENTS", x_eet_Group_Ddl_Prtfunction, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_PRTSCHEME, EGROUP_DDL_PARTITION, L"DDL_PARTITION_SCHEME_EVENTS", x_eet_Group_Ddl_Prtscheme, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_DEFAULT, EGROUP_DDL_DATABASE_LEVEL, L"DDL_DEFAULT_EVENTS", x_eet_Group_Ddl_Default, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_EXTENDED_PROPERTY, EGROUP_DDL_DATABASE_LEVEL, L"DDL_EXTENDED_PROPERTY_EVENTS", x_eet_Group_Ddl_Extended_Property, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_FULLTEXT_CATALOG, EGROUP_DDL_DATABASE_LEVEL, L"DDL_FULLTEXT_CATALOG_EVENTS", x_eet_Group_Ddl_Fulltext_Catalog, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_PLAN_GUIDE, EGROUP_DDL_DATABASE_LEVEL, L"DDL_PLAN_GUIDE_EVENTS", x_eet_Group_Ddl_Plan_Guide, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_RULE, EGROUP_DDL_DATABASE_LEVEL, L"DDL_RULE_EVENTS", x_eet_Group_Ddl_Rule, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_FULLTEXT_STOPLIST, EGROUP_DDL_DATABASE_LEVEL, L"DDL_FULLTEXT_STOPLIST_EVENTS", x_eet_Group_Ddl_Fulltext_StopList, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_PROPERTYLIST, EGROUP_DDL_DATABASE_LEVEL, L"DDL_SEARCH_PROPERTY_LIST_EVENTS", x_eet_Group_Ddl_PropertyList, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_AVAILABILITY_GROUP, EGROUP_DDL_SERVER_LEVEL, L"DDL_AVAILABILITY_GROUP_EVENTS", x_eet_Group_Ddl_Availability_Group, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_SECURITY_POLICY, EGROUP_DDL_DATABASE_LEVEL, L"DDL_SECURITY_POLICY_EVENTS", x_eet_Group_Ddl_SecurityPolicy_Group, ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_COL_MASTER_KEY, EGROUP_DDL_DATABASE_LEVEL, L"DDL_COLUMN_MASTER_KEY_EVENTS", x_eet_Group_Ddl_Col_Master_Key_Group , ETYP_ON_INVALID, 0, 0, 0 }, - { EGROUP_DDL_COL_ENCRYPTION_KEY, EGROUP_DDL_DATABASE_LEVEL, L"DDL_COLUMN_ENCRYPTION_KEY_EVENTS", x_eet_Group_Ddl_Col_Encryption_Key_Group, ETYP_ON_INVALID, 0, 0, 0 }, - -// ========= SQLTrace additions. Do not put anything below!!!================================== - { EGROUP_TRCAT_ALL, EGROUP_ALL, L"TRC_ALL_EVENTS", x_eet_Group_Traceat_All, ETYP_ON_INVALID, 0, 0, 0 }, -#include "grpdefs.inc" -//============================================================================= -}; - -STATIC const ULONG s_cEventGroup = ARRAYSIZE(g_rgEventGroup); - -// This array defines schema for all supported synchronous events. The array order should follow -// the order of the EEventType enum defined in events.h. -// -STATIC EVENT_SCHEMA s_rgEventSchema[] = -{ - -//////////////////////////////////////////////////////////////////////////////////////// -// DDL EVENTS -//////////////////////////////////////////////////////////////////////////////////////// - - //----------------------------------------------- - // CREATE TABLE Event Schema - //----------------------------------------------- - { ETYP_ON_CREATETABLE, - x_eet_Create_Table, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_TABLE", - EventTag_SchemaDDL, - NULL, - 5, - EGROUP_DDL_TABLE, - 0 - }, - - //----------------------------------------------- - // ALTER TABLE Event Schema - //----------------------------------------------- - { ETYP_ON_ALTERTABLE, - x_eet_Alter_Table, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_TABLE", - EventTag_SchemaDDL | EventTag_Parameters | EventTag_AlterTableActionList, - NULL, - BitCount64(EventTag_SchemaDDL | EventTag_Parameters | EventTag_AlterTableActionList), - EGROUP_DDL_TABLE, - 0 - }, - - //----------------------------------------------- - // DROP TABLE Event Schema - //----------------------------------------------- - { ETYP_ON_DROPTABLE, - x_eet_Drop_Table, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_TABLE", - EventTag_SchemaDDL, - NULL, - 5, - EGROUP_DDL_TABLE, - 0 - }, - - //----------------------------------------------- - // CREATE VIEW Event Schema - //----------------------------------------------- - { ETYP_ON_CREATEVIEW, - x_eet_Create_View, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_VIEW", - EventTag_SchemaDDL, - NULL, - 5, - EGROUP_DDL_VIEW, - 0 - }, - - //----------------------------------------------- - // ALTER VIEW Event Schema - //----------------------------------------------- - { ETYP_ON_ALTERVIEW, - x_eet_Alter_View, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_VIEW", - EventTag_SchemaDDL, - NULL, - 5, - EGROUP_DDL_VIEW, - 0 - }, - - //----------------------------------------------- - // DROP VIEW Event Schema - //----------------------------------------------- - { ETYP_ON_DROPVIEW, - x_eet_Drop_View, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_VIEW", - EventTag_SchemaDDL, - NULL, - 5, - EGROUP_DDL_VIEW, - 0 - }, - - //----------------------------------------------- - // CREATE SYNONYM Event Schema - //----------------------------------------------- - { ETYP_ON_CREATESYNONYM, - x_eet_Create_Synonym, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_SYNONYM", - EventTag_SchemaDDL | EventTag_TargetNames, - NULL, - 9, - EGROUP_DDL_SYNONYM, - 0 - }, - - //----------------------------------------------- - // DROP SYNONYM Event Schema - //----------------------------------------------- - { ETYP_ON_DROPSYNONYM, - x_eet_Drop_Synonym, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_SYNONYM", - EventTag_SchemaDDL | EventTag_TargetNames, - NULL, - 9, - EGROUP_DDL_SYNONYM, - 0 - }, - - //----------------------------------------------- - // CREATE FUNCTION Event Schema - //----------------------------------------------- - { ETYP_ON_CREATEFUNCTION, - x_eet_Create_Function, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_FUNCTION", - EventTag_SchemaDDL, - NULL, - 5, - EGROUP_DDL_FUNCTION, - 0 - }, - - //----------------------------------------------- - // ALTER FUNCTION Event Schema - //----------------------------------------------- - { ETYP_ON_ALTERFUNCTION, - x_eet_Alter_Function, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_FUNCTION", - EventTag_SchemaDDL, - NULL, - 5, - EGROUP_DDL_FUNCTION, - 0 - }, - - //----------------------------------------------- - // DROP FUNCTION Event Schema - //----------------------------------------------- - { ETYP_ON_DROPFUNCTION, - x_eet_Drop_Function, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_FUNCTION", - EventTag_SchemaDDL, - NULL, - 5, - EGROUP_DDL_FUNCTION, - 0 - }, - - //----------------------------------------------- - // CREATE PROCEDURE Event Schema - //----------------------------------------------- - { ETYP_ON_CREATEPROC, - x_eet_Create_Procedure, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_PROCEDURE", - EventTag_SchemaDDL, - NULL, - 5, - EGROUP_DDL_STOREDPROC, - 0 - }, - - //----------------------------------------------- - // ALTER PROCEDURE Event Schema - //----------------------------------------------- - { ETYP_ON_ALTERPROC, - x_eet_Alter_Procedure, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_PROCEDURE", - EventTag_SchemaDDL | EventTag_Parameters, - NULL, - 6, - EGROUP_DDL_STOREDPROC, - 0 - }, - - //----------------------------------------------- - // DROP PROCEDURE Event Schema - //----------------------------------------------- - { ETYP_ON_DROPPROC, - x_eet_Drop_Procedure, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_PROCEDURE", - EventTag_SchemaDDL, - NULL, - 5, - EGROUP_DDL_STOREDPROC, - 0 - }, - - //----------------------------------------------- - // CREATE TRIGGER Event Schema - //----------------------------------------------- - { ETYP_ON_CREATETRIGGER, - x_eet_Create_Trigger, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_TRIGGER", - EventTag_SchemaTargetDDL, - NULL, - 7, - EGROUP_DDL_TRIGGER, - 0 - }, - - //----------------------------------------------- - // ALTER TRIGGER Event Schema - //----------------------------------------------- - { ETYP_ON_ALTERTRIGGER, - x_eet_Alter_Trigger, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_TRIGGER", - EventTag_SchemaTargetDDL | EventTag_Parameters, - NULL, - 8, - EGROUP_DDL_TRIGGER, - 0 - }, - - //----------------------------------------------- - // DROP TRIGGER Event Schema - //----------------------------------------------- - { ETYP_ON_DROPTRIGGER, - x_eet_Drop_Trigger, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_TRIGGER", - EventTag_SchemaTargetDDL, - NULL, - 7, - EGROUP_DDL_TRIGGER, - 0 - }, - - //----------------------------------------------- - // CREATE EVENT NOTIFICATION Event Schema - //----------------------------------------------- - { ETYP_ON_CREATEEVTNOTIF, - x_eet_Create_Event_Notification, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_EVENT_NOTIFICATION", - EventTag_SchemaLessFullTargetDDL, - NULL, - 7, - EGROUP_DDL_EVTNOTIF, - 0 - }, - - //----------------------------------------------- - // DROP EVENT NOTIFICATION Event Schema - //----------------------------------------------- - { ETYP_ON_DROPEVTNOTIF, - x_eet_Drop_Event_Notification, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_EVENT_NOTIFICATION", - EventTag_SchemaLessFullTargetDDL, - NULL, - 7, - EGROUP_DDL_EVTNOTIF, - 0 - }, - - //----------------------------------------------- - // CREATE INDEX Event Schema - //----------------------------------------------- - { ETYP_ON_CREATEINDEX, - x_eet_Create_Index, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_INDEX", - EventTag_SchemaTargetDDL, - NULL, - 7, - EGROUP_DDL_INDEX, - 0 - }, - - //----------------------------------------------- - // ALTER INDEX Event Schema - //----------------------------------------------- - { ETYP_ON_ALTERINDEX, - x_eet_Alter_Index, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_INDEX", - EventTag_SchemaTargetDDL | EventTag_Parameters, - NULL, - 8, - EGROUP_DDL_INDEX, - 0 - }, - - //----------------------------------------------- - // DROP INDEX Event Schema - //----------------------------------------------- - { ETYP_ON_DROPINDEX, - x_eet_Drop_Index, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_INDEX", - EventTag_SchemaTargetDDL, - NULL, - 7, - EGROUP_DDL_INDEX, - 0 - }, - - //----------------------------------------------- - // CREATE STATS Event Schema - //----------------------------------------------- - { ETYP_ON_CREATESTATS, - x_eet_Create_Stats, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_STATISTICS", - EventTag_SchemaTargetDDL, - NULL, - 7, - EGROUP_DDL_STATS, - 0 - }, - - //----------------------------------------------- - // UPDATE STATS Event Schema - //----------------------------------------------- - { ETYP_ON_UPDATESTATS, - x_eet_Update_Stats, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"UPDATE_STATISTICS", - EventTag_DatabaseEvent | EventTag_SchemaName | EventTag_ObjectType | EventTag_TargetObjectName | EventTag_TargetObjectType, - NULL, - 6, - EGROUP_DDL_STATS, - 0 - }, - - //----------------------------------------------- - // DROP STATS Event Schema - //----------------------------------------------- - { ETYP_ON_DROPSTATS, - x_eet_Drop_Stats, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_STATISTICS", - EventTag_SchemaTargetDDL, - NULL, - 7, - EGROUP_DDL_STATS, - 0 - }, - - //----------------------------------------------- - // CREATE DATABASE Event Schema - //----------------------------------------------- - { ETYP_ON_CREATEDATABASE, - x_eet_Create_Database, - EOBJTYP_SERVER, - EFLAG_NEW_TRANS, - L"CREATE_DATABASE", - EventTag_DatabaseEvent, - NULL, - 2, - EGROUP_DDL_DATABASE, - 0 - }, - - //----------------------------------------------- - // ALTER DATABASE Event Schema - //----------------------------------------------- - { ETYP_ON_ALTERDATABASE, - x_eet_Alter_Database, - EOBJTYP_SERVER, - EFLAG_NEW_TRANS, - L"ALTER_DATABASE", - EventTag_DatabaseEvent | EventTag_Parameters | EventTag_AlterDatabaseActionList, - NULL, - BitCount64(EventTag_DatabaseEvent | EventTag_Parameters | EventTag_AlterDatabaseActionList), // 4, - EGROUP_DDL_DATABASE, - 0 - }, - - //----------------------------------------------- - // DROP DATABASE Event Schema - //----------------------------------------------- - { ETYP_ON_DROPDATABASE, - x_eet_Drop_Database, - EOBJTYP_SERVER, - EFLAG_NEW_TRANS, - L"DROP_DATABASE", - EventTag_DatabaseEvent, - NULL, - 2, - EGROUP_DDL_DATABASE, - 0 - }, - - //----------------------------------------------- - // CREATE ASSEMBLY Event Schema - //----------------------------------------------- - { ETYP_ON_CREATEASSEMBLY, - x_eet_Create_Assembly, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_ASSEMBLY", - EventTag_SchemaLessDDL, - NULL, - 4, - EGROUP_DDL_ASSEMBLY, - 0 - }, - - //----------------------------------------------- - // ALTER ASSEMBLY Event Schema - //----------------------------------------------- - { ETYP_ON_ALTERASSEMBLY, - x_eet_Alter_Assembly, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_ASSEMBLY", - EventTag_SchemaLessDDL, - NULL, - 4, - EGROUP_DDL_ASSEMBLY, - 0 - }, - - //----------------------------------------------- - // DROP ASSEMBLY Event Schema - //----------------------------------------------- - { ETYP_ON_DROPASSEMBLY, - x_eet_Drop_Assembly, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_ASSEMBLY", - EventTag_SchemaLessDDL, - NULL, - 4, - EGROUP_DDL_ASSEMBLY, - 0 - }, - - //----------------------------------------------- - // CREATE TYPE Event Schema - //----------------------------------------------- - { ETYP_ON_CREATETYPE, - x_eet_Create_Type, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_TYPE", - EventTag_SchemaDDL, - NULL, - 5, - EGROUP_DDL_UDT, - 0 - }, - - //----------------------------------------------- - // DROP TYPE Event Schema - //----------------------------------------------- - { ETYP_ON_DROPTYPE, - x_eet_Drop_Type, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_TYPE", - EventTag_SchemaDDL, - NULL, - 5, - EGROUP_DDL_UDT, - 0 - }, - - //----------------------------------------------- - // CREATE USER Event Schema - //----------------------------------------------- - { ETYP_ON_CREATEUSER, - x_eet_Create_User, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_USER", - EventTag_SchemaLessDDL | EventTag_DefaultSchema | EventTag_SID | EventTag_DefaultLanguage, - NULL, - 7, - EGROUP_DDL_USER, - 0 - }, - - //----------------------------------------------- - // ALTER USER Event Schema - //----------------------------------------------- - { ETYP_ON_ALTERUSER, - x_eet_Alter_User, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_USER", - EventTag_SchemaLessDDL | EventTag_DefaultSchema | EventTag_SID | EventTag_Parameters | EventTag_DefaultLanguage, - NULL, - 8, - EGROUP_DDL_USER, - 0 - }, - - //----------------------------------------------- - // DROP USER Event Schema - //----------------------------------------------- - { ETYP_ON_DROPUSER, - x_eet_Drop_User, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_USER", - EventTag_SchemaLessDDL | EventTag_DefaultSchema | EventTag_SID | EventTag_DefaultLanguage, - NULL, - 7, - EGROUP_DDL_USER, - 0 - }, - - - //----------------------------------------------- - // ADD ROLE MEMBER (sp_AddRoleMember) Event Schema - //----------------------------------------------- - { ETYP_ON_ADDROLEMEMBER, - x_eet_Add_Role_Member, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ADD_ROLE_MEMBER", - EventTag_DatabaseName | EventTag_ObjectEvent | EventTag_DefaultSchema | EventTag_SID | EventTag_RoleName | EventTag_TSQLCommand, - NULL, - BitCount64(EventTag_DatabaseName | EventTag_ObjectEvent | EventTag_DefaultSchema | EventTag_SID | EventTag_RoleName | EventTag_TSQLCommand), - EGROUP_DDL_ROLE, - 0 - }, - - //----------------------------------------------- - // DROP ROLE MEMBER (sp_DropRoleMember) Event Schema - //----------------------------------------------- - { ETYP_ON_DROPROLEMEMBER, - x_eet_Drop_Role_Member, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_ROLE_MEMBER", - EventTag_DatabaseName | EventTag_ObjectEvent | EventTag_DefaultSchema | EventTag_SID | EventTag_RoleName | EventTag_TSQLCommand, - NULL, - BitCount64(EventTag_DatabaseName | EventTag_ObjectEvent | EventTag_DefaultSchema | EventTag_SID | EventTag_RoleName | EventTag_TSQLCommand), - EGROUP_DDL_ROLE, - 0 - }, - - - //----------------------------------------------- - // CREATE ROLE Event Schema - //----------------------------------------------- - { ETYP_ON_CREATEROLE, - x_eet_Create_Role, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_ROLE", - EventTag_SchemaLessDDL | EventTag_SID, - NULL, - 5, - EGROUP_DDL_ROLE, - 0 - }, - - //----------------------------------------------- - // ALTER ROLE Event Schema - //----------------------------------------------- - { ETYP_ON_ALTERROLE, - x_eet_Alter_Role, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_ROLE", - EventTag_SchemaLessDDL | EventTag_SID, - NULL, - 5, - EGROUP_DDL_ROLE, - 0 - }, - - //----------------------------------------------- - // DROP ROLE Event Schema - //----------------------------------------------- - { ETYP_ON_DROPROLE, - x_eet_Drop_Role, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_ROLE", - EventTag_SchemaLessDDL | EventTag_SID, - NULL, - 5, - EGROUP_DDL_ROLE, - 0 - }, - - - //----------------------------------------------- - // CREATE APPROLE Event Schema - //----------------------------------------------- - { ETYP_ON_CREATEAPPROLE, - x_eet_Create_AppRole, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_APPLICATION_ROLE", - EventTag_SchemaLessDDL | EventTag_DefaultSchema | EventTag_SID, - NULL, - 6, - EGROUP_DDL_APPROLE, - 0 - }, - - //----------------------------------------------- - // ALTER APPROLE Event Schema - //----------------------------------------------- - { ETYP_ON_ALTERAPPROLE, - x_eet_Alter_AppRole, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_APPLICATION_ROLE", - EventTag_SchemaLessDDL | EventTag_DefaultSchema | EventTag_SID, - NULL, - 6, - EGROUP_DDL_APPROLE, - 0 - }, - - //----------------------------------------------- - // DROP APPROLE Event Schema - //----------------------------------------------- - { ETYP_ON_DROPAPPROLE, - x_eet_Drop_AppRole, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_APPLICATION_ROLE", - EventTag_SchemaLessDDL | EventTag_DefaultSchema | EventTag_SID, - NULL, - 6, - EGROUP_DDL_APPROLE, - 0 - }, - - - //----------------------------------------------- - // CREATE SCHEMA Event Schema - //----------------------------------------------- - { ETYP_ON_CREATESCHEMA, - x_eet_Create_Schema, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_SCHEMA", - EventTag_DatabaseEvent | EventTag_SchemaName | EventTag_OwnerName | EventTag_ObjectEvent, - NULL, - 6, - EGROUP_DDL_SCHEMA, - 0 - }, - - //----------------------------------------------- - // ALTER SCHEMA Event Schema - //----------------------------------------------- - { ETYP_ON_ALTERSCHEMA, - x_eet_Alter_Schema, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_SCHEMA", - EventTag_SchemaDDL, - NULL, - BitCount64(EventTag_SchemaDDL), - EGROUP_DDL_SCHEMA, - 0 - }, - - //----------------------------------------------- - // DROP SCHEMA Event Schema - //----------------------------------------------- - { ETYP_ON_DROPSCHEMA, - x_eet_Drop_Schema, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_SCHEMA", - EventTag_DatabaseEvent | EventTag_SchemaName | EventTag_OwnerName | EventTag_ObjectEvent, - NULL, - 6, - EGROUP_DDL_SCHEMA, - 0 - }, - - - //----------------------------------------------- - // CREATE LOGIN Event Schema - //----------------------------------------------- - { ETYP_ON_CREATELOGIN, - x_eet_Create_Login, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_LOGIN", - EventTag_LoginEvent, - NULL, - 7, - EGROUP_DDL_LOGIN, - 0 - }, - - //----------------------------------------------- - // ALTER LOGIN Event Schema - //----------------------------------------------- - { ETYP_ON_ALTERLOGIN, - x_eet_Alter_Login, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_LOGIN", - EventTag_LoginEvent, - NULL, - 7, - EGROUP_DDL_LOGIN, - 0 - }, - - //----------------------------------------------- - // DROP LOGIN Event Schema - //----------------------------------------------- - { ETYP_ON_DROPLOGIN, - x_eet_Drop_Login, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_LOGIN", - EventTag_LoginEvent, - NULL, - 7, - EGROUP_DDL_LOGIN, - 0 - }, - - //----------------------------------------------- - // LOGON Event Schema - //----------------------------------------------- - { ETYP_ON_LOGON, - x_eet_Logon, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS | EFLAG_SYNC_ONLY, - L"LOGON", - EventTag_LoginType | EventTag_SID | EventTag_ClientHost | EventTag_IsPooled, - NULL, - 4, - EGROUP_ALL, - 0 - }, - - //----------------------------------------------- - // ADD SERVER ROLE MEMBER (sp_AddSrvRoleMember) Event Schema - //----------------------------------------------- - { ETYP_ON_ADDSRVROLEMEMBER, - x_eet_Add_Server_Role_Member, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ADD_SERVER_ROLE_MEMBER", - EventTag_LoginEvent | EventTag_RoleEvent | EventTag_TSQLCommand, - NULL, - BitCount64(EventTag_LoginEvent | EventTag_RoleEvent | EventTag_TSQLCommand), - EGROUP_DDL_SERVER_SECURITY, - 0 - }, - - //----------------------------------------------- - // DROP SERVER ROLE MEMBER (sp_DropSrvRoleMember) Event Schema - //----------------------------------------------- - { ETYP_ON_DROPSRVROLEMEMBER, - x_eet_Drop_Server_Role_Member, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_SERVER_ROLE_MEMBER", - EventTag_LoginEvent | EventTag_RoleEvent | EventTag_TSQLCommand, - NULL, - BitCount64(EventTag_LoginEvent | EventTag_RoleEvent | EventTag_TSQLCommand), - EGROUP_DDL_SERVER_SECURITY, - 0 - }, - - //----------------------------------------------- - // CREATE SERVERROLE Event Schema - //----------------------------------------------- - { ETYP_ON_CREATESERVERROLE, - x_eet_Create_ServerRole, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_SERVER_ROLE", - EventTag_ServerEvent | EventTag_SID, - NULL, - BitCount64(EventTag_ServerEvent | EventTag_SID), - EGROUP_DDL_SERVER_SECURITY, - 0 - }, - - //----------------------------------------------- - // ALTER SERVERROLE Event Schema - //----------------------------------------------- - { ETYP_ON_ALTERSERVERROLE, - x_eet_Alter_ServerRole, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_SERVER_ROLE", - EventTag_ServerEvent | EventTag_SID, - NULL, - BitCount64(EventTag_ServerEvent | EventTag_SID), - EGROUP_DDL_SERVER_SECURITY, - 0 - }, - - //----------------------------------------------- - // DROP SERVERROLE Event Schema - //----------------------------------------------- - { ETYP_ON_DROPSERVERROLE, - x_eet_Drop_ServerRole, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_SERVER_ROLE", - EventTag_ServerEvent | EventTag_SID, - NULL, - BitCount64(EventTag_ServerEvent | EventTag_SID), - EGROUP_DDL_SERVER_SECURITY, - 0 - }, - - //----------------------------------------------- - // CREATE ENDPOINT Event Schema - //----------------------------------------------- - { ETYP_ON_CREATE_ENDPOINT, - x_eet_Create_Endpoint, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_ENDPOINT", - EventTag_ServerEvent, - NULL, - 3, - EGROUP_DDL_ENDPOINT, - 0 - }, - - //----------------------------------------------- - // ALTER ENDPOINT Event Schema - //----------------------------------------------- - { ETYP_ON_ALTER_ENDPOINT, - x_eet_Alter_Endpoint, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_ENDPOINT", - EventTag_ServerEvent, - NULL, - 3, - EGROUP_DDL_ENDPOINT, - 0 - }, - - //----------------------------------------------- - // DROP ENDPOINT Event Schema - //----------------------------------------------- - { ETYP_ON_DROP_ENDPOINT, - x_eet_Drop_Endpoint, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_ENDPOINT", - EventTag_ServerEvent, - NULL, - 3, - EGROUP_DDL_ENDPOINT, - 0 - }, - - //*********************************************************************** - // START: Service Broker Events - // - //*********************************************************************** - - //----------------------------------------------- - // CREATE MSGTYPE Event Schema - //----------------------------------------------- - { ETYP_ON_CREATEMSGTYPE, - x_eet_Create_MsgType, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_MESSAGE_TYPE", - EventTag_SchemaLessDDL, - NULL, - 4, - EGROUP_DDL_MSGTYPE, - 0 - }, - - //----------------------------------------------- - // ALTER MSGTYPE Event Schema - //----------------------------------------------- - { ETYP_ON_ALTERMSGTYPE, - x_eet_Alter_MsgType, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_MESSAGE_TYPE", - EventTag_SchemaLessDDL, - NULL, - 4, - EGROUP_DDL_MSGTYPE, - 0 - }, - - //----------------------------------------------- - // DROP MSGTYPE Event Schema - //----------------------------------------------- - { ETYP_ON_DROPMSGTYPE, - x_eet_Drop_MsgType, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_MESSAGE_TYPE", - EventTag_SchemaLessDDL, - NULL, - 4, - EGROUP_DDL_MSGTYPE, - 0 - }, - - - //----------------------------------------------- - // CREATE CONTRACT Event Schema - //----------------------------------------------- - { ETYP_ON_CREATECONTRACT, - x_eet_Create_Contract, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_CONTRACT", - EventTag_SchemaLessDDL, - NULL, - 4, - EGROUP_DDL_CONTRACT, - 0 - }, - - //----------------------------------------------- - // DROP CONTRACT Event Schema - //----------------------------------------------- - { ETYP_ON_DROPCONTRACT, - x_eet_Drop_Contract, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_CONTRACT", - EventTag_SchemaLessDDL, - NULL, - 4, - EGROUP_DDL_CONTRACT, - 0 - }, - - - //----------------------------------------------- - // CREATE QUEUE Event Schema - //----------------------------------------------- - { ETYP_ON_CREATEQUEUE, - x_eet_Create_Queue, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_QUEUE", - EventTag_SchemaDDL, - NULL, - 5, - EGROUP_DDL_QUEUE, - 0 - }, - - //----------------------------------------------- - // ALTER QUEUE Event Schema - //----------------------------------------------- - { ETYP_ON_ALTERQUEUE, - x_eet_Alter_Queue, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_QUEUE", - EventTag_SchemaDDL, - NULL, - 5, - EGROUP_DDL_QUEUE, - 0 - }, - - //----------------------------------------------- - // DROP QUEUE Event Schema - //----------------------------------------------- - { ETYP_ON_DROPQUEUE, - x_eet_Drop_Queue, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_QUEUE", - EventTag_SchemaDDL, - NULL, - 5, - EGROUP_DDL_QUEUE, - 0 - }, - - - //----------------------------------------------- - // CREATE SERVICE Event Schema - //----------------------------------------------- - { ETYP_ON_CREATESERVICE, - x_eet_Create_Service, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_SERVICE", - EventTag_SchemaLessFullTargetDDL, - NULL, - 7, - EGROUP_DDL_SERVICE, - 0 - }, - - //----------------------------------------------- - // ALTER SERVICE Event Schema - //----------------------------------------------- - { ETYP_ON_ALTERSERVICE, - x_eet_Alter_Service, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_SERVICE", - EventTag_SchemaLessFullTargetDDL, - NULL, - 7, - EGROUP_DDL_SERVICE, - 0 - }, - - //----------------------------------------------- - // DROP SERVICE Event Schema - //----------------------------------------------- - { ETYP_ON_DROPSERVICE, - x_eet_Drop_Service, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_SERVICE", - EventTag_SchemaLessFullTargetDDL, - NULL, - 7, - EGROUP_DDL_SERVICE, - 0 - }, - - //----------------------------------------------- - // CREATE ROUTE Event Schema - //----------------------------------------------- - { ETYP_ON_CREATEROUTE, - x_eet_Create_Route, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_ROUTE", - EventTag_SchemaLessDDL, - NULL, - 4, - EGROUP_DDL_ROUTE, - 0 - }, - - //----------------------------------------------- - // ALTER ROUTE Event Schema - //----------------------------------------------- - { ETYP_ON_ALTERROUTE, - x_eet_Alter_Route, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_ROUTE", - EventTag_SchemaLessDDL, - NULL, - 4, - EGROUP_DDL_ROUTE, - 0 - }, - - //----------------------------------------------- - // DROP ROUTE Event Schema - //----------------------------------------------- - { ETYP_ON_DROPROUTE, - x_eet_Drop_Route, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_ROUTE", - EventTag_SchemaLessDDL, - NULL, - 4, - EGROUP_DDL_ROUTE, - 0 - }, - - //----------------------------------------------- - // CREATE BINDING Event Schema - //----------------------------------------------- - { ETYP_ON_CREATEBINDING, - x_eet_Create_Binding, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_REMOTE_SERVICE_BINDING", - EventTag_SchemaLessDDL, - NULL, - 4, - EGROUP_DDL_BINDING, - 0 - }, - - //----------------------------------------------- - // ALTER BINDING Event Schema - //----------------------------------------------- - { ETYP_ON_ALTERBINDING, - x_eet_Alter_Binding, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_REMOTE_SERVICE_BINDING", - EventTag_SchemaLessDDL, - NULL, - 4, - EGROUP_DDL_BINDING, - 0 - }, - - //----------------------------------------------- - // DROP BINDING Event Schema - //----------------------------------------------- - { ETYP_ON_DROPBINDING, - x_eet_Drop_Binding, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_REMOTE_SERVICE_BINDING", - EventTag_SchemaLessDDL, - NULL, - 4, - EGROUP_DDL_BINDING, - 0 - }, - - //----------------------------------------------- - // CREATE BROKER PRIORITY Event Schema - //----------------------------------------------- - { ETYP_ON_CREATEPRIORITY, - x_eet_Create_Priority, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_BROKER_PRIORITY", - EventTag_SchemaLessDDL, - NULL, - 4, - EGROUP_DDL_PRIORITY, - 0 - }, - - //----------------------------------------------- - // ALTER BROKER PRIORITY Event Schema - //----------------------------------------------- - { ETYP_ON_ALTERPRIORITY, - x_eet_Alter_Priority, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_BROKER_PRIORITY", - EventTag_SchemaLessDDL, - NULL, - 4, - EGROUP_DDL_PRIORITY, - 0 - }, - - //----------------------------------------------- - // DROP BROKER PRIORITY Event Schema - //----------------------------------------------- - { ETYP_ON_DROPPRIORITY, - x_eet_Drop_Priority, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_BROKER_PRIORITY", - EventTag_SchemaLessDDL, - NULL, - 4, - EGROUP_DDL_PRIORITY, - 0 - }, - - //*********************************************************************** - // END: Service Broker Events - // - //*********************************************************************** - - //*********************************************************************** - // START: Grant Deny Revoke Events - // - //*********************************************************************** - - //----------------------------------------------- - // GRANT_SERVER Event Schema - //----------------------------------------------- - { ETYP_ON_GRANT_SERVER, - x_eet_Grant_Server, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"GRANT_SERVER", - EventTag_GDR, - NULL, - 7, - EGROUP_DDL_GDR_SERVER, - 0 - }, - - //----------------------------------------------- - // DENY_SERVER Event Schema - //----------------------------------------------- - { ETYP_ON_DENY_SERVER, - x_eet_Deny_Server, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DENY_SERVER", - EventTag_GDR, - NULL, - 7, - EGROUP_DDL_GDR_SERVER, - 0 - }, - - //----------------------------------------------- - // REVOKE_SERVER Event Schema - //----------------------------------------------- - { ETYP_ON_REVOKE_SERVER, - x_eet_Revoke_Server, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"REVOKE_SERVER", - EventTag_GDR, - NULL, - 7, - EGROUP_DDL_GDR_SERVER, - 0 - }, - - - //----------------------------------------------- - // GRANT_DATABASE Event Schema - //----------------------------------------------- - { ETYP_ON_GRANT_DATABASE, - x_eet_Grant_Database, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"GRANT_DATABASE", - EventTag_GDRDatabase, - NULL, - 11, - EGROUP_DDL_GDR_DATABASE, - 0 - }, - - //----------------------------------------------- - // DENY_DATABASE Event Schema - //----------------------------------------------- - { ETYP_ON_DENY_DATABASE, - x_eet_Deny_Database, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DENY_DATABASE", - EventTag_GDRDatabase, - NULL, - 11, - EGROUP_DDL_GDR_DATABASE, - 0 - }, - - //----------------------------------------------- - // REVOKE_DATABASE Event Schema - //----------------------------------------------- - { ETYP_ON_REVOKE_DATABASE, - x_eet_Revoke_Database, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"REVOKE_DATABASE", - EventTag_GDRDatabase, - NULL, - 11, - EGROUP_DDL_GDR_DATABASE, - 0 - }, - - - //*********************************************************************** - // END: Grant Deny Revoke Events - // - //*********************************************************************** - - //----------------------------------------------- - // CREATE XML SCHEMA COLLECTION Event Schema - //----------------------------------------------- - { ETYP_ON_CREATE_XML_SCHEMA_COLLECTION, - x_eet_Create_XmlSchemaCollection, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_XML_SCHEMA_COLLECTION", - EventTag_SchemaDDL, - NULL, - 5, - EGROUP_DDL_XML_SCHEMA_COLLECTION, - 0 - }, - - //----------------------------------------------- - // ALTER XMLSCHEMA Event Schema - //----------------------------------------------- - { ETYP_ON_ALTER_XML_SCHEMA_COLLECTION, - x_eet_Alter_XmlSchemaCollection, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_XML_SCHEMA_COLLECTION", - EventTag_SchemaDDL, - NULL, - 5, - EGROUP_DDL_XML_SCHEMA_COLLECTION, - 0 - }, - - //----------------------------------------------- - // DROP XMLSCHEMA Event Schema - //----------------------------------------------- - { ETYP_ON_DROP_XML_SCHEMA_COLLECTION, - x_eet_Drop_XmlSchemaCollection, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_XML_SCHEMA_COLLECTION", - EventTag_SchemaDDL, - NULL, - 5, - EGROUP_DDL_XML_SCHEMA_COLLECTION, - 0 - }, - - - //----------------------------------------------- - // CREATE CERTIFICATE Event Schema - //----------------------------------------------- - { ETYP_ON_CREATECERT, - x_eet_Create_Cert, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_CERTIFICATE", - EventTag_ObjectOwnerKeyEvent | EventTag_CertificatePath | EventTag_PrivateKeyPath | EventTag_CertificateSubject | EventTag_DatabaseEvent, - NULL, - BitCount64(EventTag_ObjectOwnerKeyEvent | EventTag_CertificatePath | EventTag_PrivateKeyPath | EventTag_CertificateSubject | EventTag_DatabaseEvent), - EGROUP_DDL_CERTIFICATE, - 0 - }, - - //----------------------------------------------- - // ALTER CERTIFICATE Event Schema - //----------------------------------------------- - { ETYP_ON_ALTERCERT, - x_eet_Alter_Cert, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_CERTIFICATE", - EventTag_ObjectOwnerKeyEvent | EventTag_DatabaseEvent, - NULL, - BitCount64(EventTag_ObjectOwnerKeyEvent | EventTag_DatabaseEvent), - EGROUP_DDL_CERTIFICATE, - 0 - }, - - //----------------------------------------------- - // DROP CERTIFICATE Event Schema - //----------------------------------------------- - { ETYP_ON_DROPCERT, - x_eet_Drop_Cert, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_CERTIFICATE", - EventTag_ObjectOwnerEvent | EventTag_DatabaseEvent, - NULL, - BitCount64(EventTag_ObjectOwnerEvent | EventTag_DatabaseEvent), - EGROUP_DDL_CERTIFICATE, - 0 - }, - - //----------------------------------------------- - // CREATE SYMMETRIC KEY Event Schema - //----------------------------------------------- - { ETYP_ON_CREATEOBFUSKEY, - x_eet_Create_ObfusKey, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_SYMMETRIC_KEY", - EventTag_ObjectOwnerEvent | EventTag_DatabaseEvent, - NULL, - BitCount64(EventTag_ObjectOwnerEvent | EventTag_DatabaseEvent), - EGROUP_DDL_OBFUSKEY, - 0 - }, - - //----------------------------------------------- - // ALTER SYMMETRIC KEY Event Schema - //----------------------------------------------- - { ETYP_ON_ALTEROBFUSKEY, - x_eet_Alter_ObfusKey, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_SYMMETRIC_KEY", - EventTag_ObjectOwnerEvent | EventTag_DatabaseEvent, - NULL, - BitCount64(EventTag_ObjectOwnerEvent | EventTag_DatabaseEvent), - EGROUP_DDL_OBFUSKEY, - 0 - }, - - //----------------------------------------------- - // DROP SYMMETRIC KEY Event Schema - //----------------------------------------------- - { ETYP_ON_DROPOBFUSKEY, - x_eet_Drop_ObfusKey, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_SYMMETRIC_KEY", - EventTag_ObjectOwnerEvent | EventTag_DatabaseEvent, - NULL, - BitCount64(EventTag_ObjectOwnerEvent | EventTag_DatabaseEvent), - EGROUP_DDL_OBFUSKEY, - 0 - }, - - //----------------------------------------------- - // CREATE ASYMMETRIC KEY Event Schema - //----------------------------------------------- - { ETYP_ON_CREATEASYMKEY, - x_eet_Create_AsymKey, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_ASYMMETRIC_KEY", - EventTag_ObjectOwnerEvent | EventTag_DatabaseEvent | EventTag_KeyPath, - NULL, - BitCount64(EventTag_ObjectOwnerEvent | EventTag_DatabaseEvent | EventTag_KeyPath), - EGROUP_DDL_ASYMKEY, - 0 - }, - - //----------------------------------------------- - // ALTER ASYMMETRIC KEY Event Schema - //----------------------------------------------- - { ETYP_ON_ALTERASYMKEY, - x_eet_Alter_AsymKey, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_ASYMMETRIC_KEY", - EventTag_ObjectOwnerEvent | EventTag_DatabaseEvent, - NULL, - BitCount64(EventTag_ObjectOwnerEvent | EventTag_DatabaseEvent), - EGROUP_DDL_ASYMKEY, - 0 - }, - - //----------------------------------------------- - // DROP ASYMMETRIC KEY Event Schema - //----------------------------------------------- - { ETYP_ON_DROPASYMKEY, - x_eet_Drop_AsymKey, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_ASYMMETRIC_KEY", - EventTag_ObjectOwnerEvent | EventTag_DatabaseEvent, - NULL, - BitCount64(EventTag_ObjectOwnerEvent | EventTag_DatabaseEvent), - EGROUP_DDL_ASYMKEY, - 0 - }, - - //----------------------------------------------- - // ALTER SERVICE MASTER KEY Event Schema - //----------------------------------------------- - { ETYP_ON_ALTERSRVMASTERKEY, - x_eet_Alter_SrvMasterKey, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_SERVICE_MASTER_KEY", - EventTag_ObjectType | EventTag_TSQLCommand, - NULL, - BitCount64(EventTag_ObjectType | EventTag_TSQLCommand), - EGROUP_DDL_SRVMASTERKEY, - 0 - }, - - //----------------------------------------------- - // CREATE MASTER KEY Event Schema - //----------------------------------------------- - { ETYP_ON_CREATEDBMASTERKEY, - x_eet_Create_DbMasterKey, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_MASTER_KEY", - EventTag_DatabaseEvent | EventTag_ObjectType, - NULL, - BitCount64(EventTag_DatabaseEvent | EventTag_ObjectType), - EGROUP_DDL_DBMASTERKEY, - 0 - }, - - //----------------------------------------------- - // ALTER MASTER KEY Event Schema - //----------------------------------------------- - { ETYP_ON_ALTERDBMASTERKEY, - x_eet_Alter_DbMasterKey, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_MASTER_KEY", - EventTag_DatabaseEvent | EventTag_ObjectType, - NULL, - BitCount64(EventTag_DatabaseEvent | EventTag_ObjectType), - EGROUP_DDL_DBMASTERKEY, - 0 - }, - - //----------------------------------------------- - // DROP MASTER KEY Event Schema - //----------------------------------------------- - { ETYP_ON_DROPDBMASTERKEY, - x_eet_Drop_DbMasterKey, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_MASTER_KEY", - EventTag_DatabaseEvent | EventTag_ObjectType, - NULL, - BitCount64(EventTag_DatabaseEvent | EventTag_ObjectType), - EGROUP_DDL_DBMASTERKEY, - 0 - }, - - //----------------------------------------------- - // CREATE DEK Event Schema - //----------------------------------------------- - { ETYP_ON_CREATEDEK, - x_eet_Create_DEK, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_NEW_TRANS, - L"CREATE_DATABASE_ENCRYPTION_KEY", - EventTag_DatabaseEvent | EventTag_ObjectType, - NULL, - BitCount64(EventTag_DatabaseEvent | EventTag_ObjectType), - EGROUP_DDL_DEK, - 0 - }, - - //----------------------------------------------- - // ALTER DEK Event Schema - //----------------------------------------------- - { ETYP_ON_ALTERDEK, - x_eet_Alter_DEK, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_NEW_TRANS, - L"ALTER_DATABASE_ENCRYPTION_KEY", - EventTag_DatabaseEvent | EventTag_ObjectType, - NULL, - BitCount64(EventTag_DatabaseEvent | EventTag_ObjectType), - EGROUP_DDL_DEK, - 0 - }, - - //----------------------------------------------- - // DROP DEK Event Schema - //----------------------------------------------- - { ETYP_ON_DROPDEK, - x_eet_Drop_DEK, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_NEW_TRANS, - L"DROP_DATABASE_ENCRYPTION_KEY", - EventTag_DatabaseEvent | EventTag_ObjectType, - NULL, - BitCount64(EventTag_DatabaseEvent | EventTag_ObjectType), - EGROUP_DDL_DEK, - 0 - }, - - //----------------------------------------------- - // ADD SIGNATURE on Schema Object Event Schema - //----------------------------------------------- - { ETYP_ON_ADDSIGN_SCH_OBJ, - x_eet_Add_Signature_SchObj, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ADD_SIGNATURE_SCHEMA_OBJECT", - EventTag_DatabaseEvent | EventTag_ObjectEvent |EventTag_SchemaName | EventTag_CounterSignature, - NULL, - BitCount64(EventTag_DatabaseEvent | EventTag_ObjectEvent |EventTag_SchemaName | EventTag_CounterSignature), - EGROUP_DDL_CRYPTOSIGN, - 0 - }, - - //----------------------------------------------- - // DROP SIGNATURE on Schema Object Event Schema - //----------------------------------------------- - { ETYP_ON_DROPSIGN_SCH_OBJ, - x_eet_Drop_Signature_SchObj, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_SIGNATURE_SCHEMA_OBJECT", - EventTag_DatabaseEvent | EventTag_ObjectEvent |EventTag_SchemaName | EventTag_CounterSignature, - NULL, - BitCount64(EventTag_DatabaseEvent | EventTag_ObjectEvent |EventTag_SchemaName | EventTag_CounterSignature), - EGROUP_DDL_CRYPTOSIGN, - 0 - }, - - //----------------------------------------------- - // ADD SIGNATURE Event Schema - //----------------------------------------------- - { ETYP_ON_ADDSIGN, - x_eet_Add_Signature, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ADD_SIGNATURE", - EventTag_DatabaseEvent | EventTag_ObjectEvent | EventTag_CounterSignature, - NULL, - BitCount64(EventTag_DatabaseEvent | EventTag_ObjectEvent | EventTag_CounterSignature), - EGROUP_DDL_CRYPTOSIGN, - 0 - }, - - //----------------------------------------------- - // DROP SIGNATURE Event Schema - //----------------------------------------------- - { ETYP_ON_DROPSIGN, - x_eet_Drop_Signature, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_SIGNATURE", - EventTag_DatabaseEvent | EventTag_ObjectEvent | EventTag_CounterSignature, - NULL, - BitCount64(EventTag_DatabaseEvent | EventTag_ObjectEvent | EventTag_CounterSignature), - EGROUP_DDL_CRYPTOSIGN, - 0 - }, - - //----------------------------------------------- - // CREATE CREDENTIAL Event Schema - //----------------------------------------------- - { ETYP_ON_CREATECREDENTIAL, - x_eet_Create_Credential, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_CREDENTIAL", - EventTag_ServerEvent, - NULL, - BitCount64(EventTag_ServerEvent), - EGROUP_DDL_CREDENTIAL, - 0 - }, - - //----------------------------------------------- - // ALTER CREDENTIAL Event Schema - //----------------------------------------------- - { ETYP_ON_ALTERCREDENTIAL, - x_eet_Alter_Credential, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_CREDENTIAL", - EventTag_ServerEvent, - NULL, - BitCount64(EventTag_ServerEvent), - EGROUP_DDL_CREDENTIAL, - 0 - }, - - //----------------------------------------------- - // DROP CREDENTIAL Event Schema - //----------------------------------------------- - { ETYP_ON_DROPCREDENTIAL, - x_eet_Drop_Credential, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_CREDENTIAL", - EventTag_ServerEvent, - NULL, - BitCount64(EventTag_ServerEvent), - EGROUP_DDL_CREDENTIAL, - 0 - }, - - //----------------------------------------------- - // CREATE CRYPTO PROVIDER Event Schema - //----------------------------------------------- - { ETYP_ON_CREATECRYPTOPROV, - x_eet_Create_CryptoProv, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_CRYPTOGRAPHIC_PROVIDER", - EventTag_ServerEvent, - NULL, - BitCount64(EventTag_ServerEvent), - EGROUP_DDL_CRYPTOPROV, - 0 - }, - - //----------------------------------------------- - // ALTER CRYPTO PROVIDER Event Schema - //----------------------------------------------- - { ETYP_ON_ALTERCRYPTOPROV, - x_eet_Alter_CryptoProv, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_CRYPTOGRAPHIC_PROVIDER", - EventTag_ServerEvent, - NULL, - BitCount64(EventTag_ServerEvent), - EGROUP_DDL_CRYPTOPROV, - 0 - }, - - //----------------------------------------------- - // DROP CRYPTO PROVIDER Event Schema - //----------------------------------------------- - { ETYP_ON_DROPCRYPTOPROV, - x_eet_Drop_CryptoProv, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_CRYPTOGRAPHIC_PROVIDER", - EventTag_ServerEvent, - NULL, - BitCount64(EventTag_ServerEvent), - EGROUP_DDL_CRYPTOPROV, - 0 - }, - - //----------------------------------------------- - // ALTER AUTHORIZATION Server Event Schema - //----------------------------------------------- - { ETYP_ON_ALTERAUTH_SERVER, - x_eet_Alter_Auth_Server, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_AUTHORIZATION_SERVER", - EventTag_ObjectOwnerEvent | EventTag_TSQLCommand, - NULL, - 4, - EGROUP_DDL_AUTH_SERVER, - 0 - }, - - //----------------------------------------------- - // ALTER AUTHORIZATION Database Event Schema - //----------------------------------------------- - { ETYP_ON_ALTERAUTH_DATABASE, - x_eet_Alter_Auth_Database, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_AUTHORIZATION_DATABASE", - EventTag_SchemaDDL | EventTag_OwnerName, - NULL, - 6, - EGROUP_DDL_AUTH_DATABASE, - 0 - }, - - //*********************************************************************** - // START START - PARTITION RELATED - START START - // - //*********************************************************************** - - //----------------------------------------------- - // CREATE PARTITION FUNCTION Event Schema - //----------------------------------------------- - { ETYP_ON_CREATEPRTFUNCTION, - x_eet_Create_Partition_Function, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_PARTITION_FUNCTION", - EventTag_SchemaLessDDL, - NULL, - 4, - EGROUP_DDL_PRTFUNCTION, - 0 - }, - - //----------------------------------------------- - // ALTER PARTITION FUNCTION Event Schema - //----------------------------------------------- - { ETYP_ON_ALTERPRTFUNCTION, - x_eet_Alter_Partition_Function, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_PARTITION_FUNCTION", - EventTag_SchemaLessDDL, - NULL, - 4, - EGROUP_DDL_PRTFUNCTION, - 0 - }, - - //----------------------------------------------- - // DROP PARTITION FUNCTION Event Schema - //----------------------------------------------- - { ETYP_ON_DROPPRTFUNCTION, - x_eet_Drop_Partition_Function, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_PARTITION_FUNCTION", - EventTag_SchemaLessDDL, - NULL, - 4, - EGROUP_DDL_PRTFUNCTION, - 0 - }, - - //----------------------------------------------- - // CREATE PARTITION SCHEME Event Schema - //----------------------------------------------- - { ETYP_ON_CREATEPRTSCHEME, - x_eet_Create_Partition_Scheme, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_PARTITION_SCHEME", - EventTag_SchemaLessDDL | EventTag_Function, - NULL, - 5, - EGROUP_DDL_PRTSCHEME, - 0 - }, - - //----------------------------------------------- - // ALTER PARTITION SCHEME Event Schema - //----------------------------------------------- - { ETYP_ON_ALTERPRTSCHEME, - x_eet_Alter_Partition_Scheme, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_PARTITION_SCHEME", - EventTag_SchemaLessDDL | EventTag_Function, - NULL, - 5, - EGROUP_DDL_PRTSCHEME, - 0 - }, - - //----------------------------------------------- - // DROP PARTITION SCHEME Event Schema - //----------------------------------------------- - { ETYP_ON_DROPPRTSCHEME, - x_eet_Drop_Partition_Scheme, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_PARTITION_SCHEME", - EventTag_SchemaLessDDL | EventTag_Function, - NULL, - 5, - EGROUP_DDL_PRTSCHEME, - 0 - }, - - //----------------------------------------------- - // CREATE [PRIMARY] XML INDEX Event Schema - //----------------------------------------------- - { ETYP_ON_CREATE_XML_INDEX, - x_eet_Create_XML_Index, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_XML_INDEX", - EventTag_SchemaTargetDDL | EventTag_PrimaryXMLIndexName | EventTag_SecondaryXMLIndexType, - NULL, - 9, - EGROUP_DDL_INDEX, - 0 - }, - - //----------------------------------------------- - // SP_UPDATEEXTENDEDPROPERTY Event Schema - //----------------------------------------------- - { ETYP_ON_ALTER_EXTENDED_PROPERTY, - x_eet_Alter_Extended_Property, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_EXTENDED_PROPERTY", - EventTag_SPSchemaTargetDDL | EventTag_ExtendedPropertyEvent, - NULL, - 10, - EGROUP_DDL_EXTENDED_PROPERTY, - 0 - }, - //----------------------------------------------- - // ALTER FULLTEXT CATALOG Event Schema - //----------------------------------------------- - { ETYP_ON_ALTER_FULLTEXT_CATALOG, - x_eet_Alter_Fulltext_Catalog, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_FULLTEXT_CATALOG", - EventTag_SchemaLessDDL, - NULL, - 4, - EGROUP_DDL_FULLTEXT_CATALOG, - 0 - }, - //----------------------------------------------- - // ALTER FULLTEXT INDEX Event Schema - //----------------------------------------------- - { ETYP_ON_ALTER_FULLTEXT_INDEX, - x_eet_Alter_Fulltext_Index, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_FULLTEXT_INDEX", - EventTag_SchemaDDL, - NULL, - 5, - EGROUP_DDL_INDEX, - 0 - }, - //----------------------------------------------- - // SP_CONFIGURE Event Schema - //----------------------------------------------- - { ETYP_ON_ALTER_INSTANCE, - x_eet_Alter_Instance, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_INSTANCE", - EventTag_ExtendedPropertyEvent | EventTag_TSQLCommand | EventTag_Parameters, - NULL, - 4, - EGROUP_DDL_SERVER_LEVEL, - 0 - }, - //----------------------------------------------- - // SP_SERVEROPTION Event Schema - //----------------------------------------------- - { ETYP_ON_ALTER_LINKED_SERVER, - x_eet_Alter_Linked_Server, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_LINKED_SERVER", - EventTag_SPObjectEvent, - NULL, - 4, - EGROUP_DDL_LINKED_SERVER, - 0 - }, - //----------------------------------------------- - // SP_ALTERMESSAGE Event Schema - //----------------------------------------------- - { ETYP_ON_ALTER_MESSAGE, - x_eet_Alter_Message, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_MESSAGE", - EventTag_SPObjectEvent, - NULL, - 4, - EGROUP_DDL_MESSAGE, - 0 - }, - //----------------------------------------------- - // SP_CONTROL_PLAN_GUIDE Event Schema - //----------------------------------------------- - { ETYP_ON_ALTER_PLAN_GUIDE, - x_eet_Alter_Plan_Guide, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_PLAN_GUIDE", - EventTag_SPDatabaseEvent | EventTag_ObjectEvent, - NULL, - 5, - EGROUP_DDL_PLAN_GUIDE, - 0 - }, - //----------------------------------------------- - // SP_SERVEROPTION Event Schema - //----------------------------------------------- - { ETYP_ON_ALTER_REMOTE_SERVER, - x_eet_Alter_Remote_Server, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_REMOTE_SERVER", - EventTag_SPObjectEvent, - NULL, - 4, - EGROUP_DDL_REMOTE_SERVER, - 0 - }, - //----------------------------------------------- - // SP_BINDEFAULT Event Schema - //----------------------------------------------- - { ETYP_ON_BIND_DEFAULT, - x_eet_Bind_Default, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"BIND_DEFAULT", - EventTag_SPSchemaDDL, - NULL, - 6, - EGROUP_DDL_DEFAULT, - 0 - }, - //----------------------------------------------- - // SP_BINDRULE Event Schema - //----------------------------------------------- - { ETYP_ON_BIND_RULE, - x_eet_Bind_Rule, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"BIND_RULE", - EventTag_SPSchemaDDL, - NULL, - 6, - EGROUP_DDL_RULE, - 0 - }, - //----------------------------------------------- - // CREATE DEFAULT Event Schema - //----------------------------------------------- - { ETYP_ON_CREATE_DEFAULT, - x_eet_Create_Default, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_DEFAULT", - EventTag_SchemaDDL, - NULL, - 5, - EGROUP_DDL_DEFAULT, - 0 - }, - //----------------------------------------------- - // SP_ADDEXTENDEDPROC Event Schema - //----------------------------------------------- - { ETYP_ON_CREATE_EXTENDED_PROCEDURE, - x_eet_Create_Extended_Procedure, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_EXTENDED_PROCEDURE", - EventTag_SPObjectEvent, - NULL, - 4, - EGROUP_DDL_EXTENDED_PROCEDURE, - 0 - }, - //----------------------------------------------- - // SP_ADDEXTENDEDPROPERTY Event Schema - //----------------------------------------------- - { ETYP_ON_CREATE_EXTENDED_PROPERTY, - x_eet_Create_Extended_Property, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_EXTENDED_PROPERTY", - EventTag_SPSchemaTargetDDL | EventTag_ExtendedPropertyEvent, - NULL, - 10, - EGROUP_DDL_EXTENDED_PROPERTY, - 0 - }, - //----------------------------------------------- - // CREATE FULLTEXT CATALOG Event Schema - //----------------------------------------------- - { ETYP_ON_CREATE_FULLTEXT_CATALOG, - x_eet_Create_Fulltext_Catalog, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_FULLTEXT_CATALOG", - EventTag_SchemaLessDDL, - NULL, - 4, - EGROUP_DDL_FULLTEXT_CATALOG, - 0 - }, - //----------------------------------------------- - // CREATE FULLTEXT INDEX Event Schema - //----------------------------------------------- - { ETYP_ON_CREATE_FULLTEXT_INDEX, - x_eet_Create_Fulltext_Index, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_FULLTEXT_INDEX", - EventTag_SchemaDDL, - NULL, - 5, - EGROUP_DDL_INDEX, - 0 - }, - //----------------------------------------------- - // SP_ADDLINKEDSERVER Event Schema - //----------------------------------------------- - { ETYP_ON_CREATE_LINKED_SERVER, - x_eet_Create_Linked_Server, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_LINKED_SERVER", - EventTag_SPObjectEvent, - NULL, - 4, - EGROUP_DDL_LINKED_SERVER, - 0 - }, - //----------------------------------------------- - // SP_ADDLINKEDSRVLOGIN Event Schema - //----------------------------------------------- - { ETYP_ON_CREATE_LINKED_SERVER_LOGIN, - x_eet_Create_Linked_Server_Login, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_LINKED_SERVER_LOGIN", - EventTag_SPObjectTargetEvent, - NULL, - 6, - EGROUP_DDL_LINKED_SERVER_LOGIN, - 0 - }, - //----------------------------------------------- - // SP_ADDMESSAGE Event Schema - //----------------------------------------------- - { ETYP_ON_CREATE_MESSAGE, - x_eet_Create_Message, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_MESSAGE", - EventTag_SPObjectEvent, - NULL, - 4, - EGROUP_DDL_MESSAGE, - 0 - }, - //----------------------------------------------- - // SP_CREATE_PLAN_GUIDE Event Schema - //----------------------------------------------- - { ETYP_ON_CREATE_PLAN_GUIDE, - x_eet_Create_Plan_Guide, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_PLAN_GUIDE", - EventTag_SPDatabaseEvent | EventTag_ObjectEvent, - NULL, - 5, - EGROUP_DDL_PLAN_GUIDE, - 0 - }, - //----------------------------------------------- - // SP_ADDSERVER Event Schema - //----------------------------------------------- - { ETYP_ON_CREATE_REMOTE_SERVER, - x_eet_Create_Remote_Server, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_REMOTE_SERVER", - EventTag_SPObjectEvent, - NULL, - 4, - EGROUP_DDL_REMOTE_SERVER, - 0 - }, - //----------------------------------------------- - // CREATE RULE Event Schema - //----------------------------------------------- - { ETYP_ON_CREATE_RULE, - x_eet_Create_Rule, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_RULE", - EventTag_SchemaDDL, - NULL, - 5, - EGROUP_DDL_RULE, - 0 - }, - //----------------------------------------------- - // DROP DEFAULT Event Schema - //----------------------------------------------- - { ETYP_ON_DROP_DEFAULT, - x_eet_Drop_Default, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_DEFAULT", - EventTag_SchemaDDL, - NULL, - 5, - EGROUP_DDL_DEFAULT, - 0 - }, - //----------------------------------------------- - // SP_DROPEXTENDEDPROC Event Schema - //----------------------------------------------- - { ETYP_ON_DROP_EXTENDED_PROCEDURE, - x_eet_Drop_Extended_Procedure, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_EXTENDED_PROCEDURE", - EventTag_SPObjectEvent, - NULL, - 4, - EGROUP_DDL_EXTENDED_PROCEDURE, - 0 - }, - //----------------------------------------------- - // SP_DROPEXTENDEDPROPERTY Event Schema - //----------------------------------------------- - { ETYP_ON_DROP_EXTENDED_PROPERTY, - x_eet_Drop_Extended_Property, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_EXTENDED_PROPERTY", - EventTag_SPSchemaTargetDDL | EventTag_PropertyName, - NULL, - 9, - EGROUP_DDL_EXTENDED_PROPERTY, - 0 - }, - //----------------------------------------------- - // DROP FULLTEXT CATALOG Event Schema - //----------------------------------------------- - { ETYP_ON_DROP_FULLTEXT_CATALOG, - x_eet_Drop_Fulltext_Catalog, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_FULLTEXT_CATALOG", - EventTag_SchemaLessDDL, - NULL, - 4, - EGROUP_DDL_FULLTEXT_CATALOG, - 0 - }, - //----------------------------------------------- - // DROP FULLTEXT INDEX Event Schema - //----------------------------------------------- - { ETYP_ON_DROP_FULLTEXT_INDEX, - x_eet_Drop_Fulltext_Index, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_FULLTEXT_INDEX", - EventTag_SchemaDDL, - NULL, - 5, - EGROUP_DDL_INDEX, - 0 - }, - //----------------------------------------------- - // SP_DROPSERVER Event Schema - //----------------------------------------------- - { ETYP_ON_DROP_LINKED_SERVER, - x_eet_Drop_Linked_Server, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_LINKED_SERVER", - EventTag_SPObjectEvent, - NULL, - 4, - EGROUP_DDL_LINKED_SERVER, - 0 - }, - //----------------------------------------------- - // SP_DROPLINKEDSRVLOGIN Event Schema - //----------------------------------------------- - { ETYP_ON_DROP_LINKED_SERVER_LOGIN, - x_eet_Drop_Linked_Server_Login, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_LINKED_SERVER_LOGIN", - EventTag_SPObjectTargetEvent, - NULL, - 6, - EGROUP_DDL_LINKED_SERVER_LOGIN, - 0 - }, - //----------------------------------------------- - // SP_DROPMESSAGE Event Schema - //----------------------------------------------- - { ETYP_ON_DROP_MESSAGE, - x_eet_Drop_Message, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_MESSAGE", - EventTag_SPObjectEvent, - NULL, - 4, - EGROUP_DDL_MESSAGE, - 0 - }, - //----------------------------------------------- - // SP_CONTROL_PLAN_GUIDE Event Schema - //----------------------------------------------- - { ETYP_ON_DROP_PLAN_GUIDE, - x_eet_Drop_Plan_Guide, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_PLAN_GUIDE", - EventTag_SPDatabaseEvent | EventTag_ObjectEvent, - NULL, - 5, - EGROUP_DDL_PLAN_GUIDE, - 0 - }, - //----------------------------------------------- - // SP_DROPSERVER Event Schema - //----------------------------------------------- - { ETYP_ON_DROP_REMOTE_SERVER, - x_eet_Drop_Remote_Server, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_REMOTE_SERVER", - EventTag_SPObjectEvent, - NULL, - 4, - EGROUP_DDL_REMOTE_SERVER, - 0 - }, - //----------------------------------------------- - // DROP RULE Event Schema - //----------------------------------------------- - { ETYP_ON_DROP_RULE, - x_eet_Drop_Rule, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_RULE", - EventTag_SchemaDDL, - NULL, - 5, - EGROUP_DDL_RULE, - 0 - }, - - //----------------------------------------------- - // SP_RENAME Event Schema - //----------------------------------------------- - { ETYP_ON_RENAME, - x_eet_Rename, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"RENAME", - EventTag_SPSchemaTargetDDL | EventTag_NewObjectName, - NULL, - 9, - EGROUP_DDL_DATABASE_LEVEL, - 0 - }, - //----------------------------------------------- - // SP_UNBINDEFAULT Event Schema - //----------------------------------------------- - { ETYP_ON_UNBIND_DEFAULT, - x_eet_Unbind_Default, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"UNBIND_DEFAULT", - EventTag_SPSchemaDDL, - NULL, - 6, - EGROUP_DDL_DEFAULT, - 0 - }, - //----------------------------------------------- - // SP_UNBINDRULE Event Schema - //----------------------------------------------- - { ETYP_ON_UNBIND_RULE, - x_eet_Unbind_Rule, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"UNBIND_RULE", - EventTag_SPSchemaDDL, - NULL, - 6, - EGROUP_DDL_RULE, - 0 - }, - //*********************************************************************** - // END END - PARTITION RELATED - END END - // - //*********************************************************************** - - //----------------------------------------------- - // CREATE FULLTEXT STOPLIST Event Schema - //----------------------------------------------- - { ETYP_ON_CREATE_FULLTEXT_STOPLIST, - x_eet_Create_Fulltext_StopList, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_FULLTEXT_STOPLIST", - EventTag_SchemaLessDDL, - NULL, - 4, - EGROUP_DDL_FULLTEXT_STOPLIST, - 0 - }, - //----------------------------------------------- - // ALTER FULLTEXT STOPLIST Event Schema - //----------------------------------------------- - { ETYP_ON_ALTER_FULLTEXT_STOPLIST, - x_eet_Alter_Fulltext_StopList, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_FULLTEXT_STOPLIST", - EventTag_SchemaLessDDL, - NULL, - 4, - EGROUP_DDL_FULLTEXT_STOPLIST, - 0 - }, - //----------------------------------------------- - // DROP FULLTEXT STOPLIST Event Schema - //----------------------------------------------- - { ETYP_ON_DROP_FULLTEXT_STOPLIST, - x_eet_Drop_Fulltext_StopList, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_FULLTEXT_STOPLIST", - EventTag_SchemaLessDDL, - NULL, - 4, - EGROUP_DDL_FULLTEXT_STOPLIST, - 0 - }, - - //----------------------------------------------- - // CREATE PROPERTY LIST Event Schema - //----------------------------------------------- - { ETYP_ON_CREATE_PROPERTYLIST, - x_eet_Create_PropertyList, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_SEARCH_PROPERTY_LIST", - EventTag_SchemaLessDDL, - NULL, - 4, - EGROUP_DDL_PROPERTYLIST, - 0 - }, - //----------------------------------------------- - // ALTER FULLTEXT PROPERTY LIST Event Schema - //----------------------------------------------- - { ETYP_ON_ALTER_PROPERTYLIST, - x_eet_Alter_PropertyList, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_SEARCH_PROPERTY_LIST", - EventTag_SchemaLessDDL, - NULL, - 4, - EGROUP_DDL_PROPERTYLIST, - 0 - }, - //----------------------------------------------- - // DROP FULLTEXT PROPERTY LIST Event Schema - //----------------------------------------------- - { ETYP_ON_DROP_PROPERTYLIST, - x_eet_Drop_PropertyList, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_SEARCH_PROPERTY_LIST", - EventTag_SchemaLessDDL, - NULL, - 4, - EGROUP_DDL_PROPERTYLIST, - 0 - }, - - //----------------------------------------------- - // CREATE_EVENT_SESSION Event Schema - //----------------------------------------------- - { ETYP_ON_CREATE_EVENT_SESSION, - x_eet_Create_Event_Session, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_EVENT_SESSION", - EventTag_ServerEvent, - NULL, - BitCount64(EventTag_ServerEvent), - EGROUP_DDL_EVENT_SESSION, - 0 - }, - - //----------------------------------------------- - // ALTER_EVENT_SESSION Event Schema - //----------------------------------------------- - { ETYP_ON_ALTER_EVENT_SESSION, - x_eet_Alter_Event_Session, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_EVENT_SESSION", - EventTag_ServerEvent, - NULL, - BitCount64(EventTag_ServerEvent), - EGROUP_DDL_EVENT_SESSION, - 0 - }, - - //----------------------------------------------- - // DROP_EVENT_SESSION Event Schema - //----------------------------------------------- - { ETYP_ON_DROP_EVENT_SESSION, - x_eet_Drop_Event_Session, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_EVENT_SESSION", - EventTag_ServerEvent, - NULL, - BitCount64(EventTag_ServerEvent), - EGROUP_DDL_EVENT_SESSION, - 0 - }, - - //----------------------------------------------- - // CREATE RESOURCE POOL Event Schema - //----------------------------------------------- - { ETYP_ON_CREATE_RES_POOL, - x_eet_Create_Resource_Pool, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_RESOURCE_POOL", - EventTag_ServerEvent, - NULL, - BitCount64(EventTag_ServerEvent), - EGROUP_DDL_RESOURCE_POOL, - 0 - }, - - //----------------------------------------------- - // ALTER RESOURCE POOL Event Schema - //----------------------------------------------- - { ETYP_ON_ALTER_RES_POOL, - x_eet_Alter_Resource_Pool, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_RESOURCE_POOL", - EventTag_ServerEvent, - NULL, - BitCount64(EventTag_ServerEvent), - EGROUP_DDL_RESOURCE_POOL, - 0 - }, - - //----------------------------------------------- - // DROP RESOURCE POOL Event Schema - //----------------------------------------------- - { ETYP_ON_DROP_RES_POOL, - x_eet_Drop_Resource_Pool, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_RESOURCE_POOL", - EventTag_ServerEvent, - NULL, - BitCount64(EventTag_ServerEvent), - EGROUP_DDL_RESOURCE_POOL, - 0 - }, - - //----------------------------------------------- - // CREATE WORKLOAD GROUP Event Schema - //----------------------------------------------- - { ETYP_ON_CREATE_RES_GROUP, - x_eet_Create_Resource_Group, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_WORKLOAD_GROUP", - EventTag_ServerEvent, - NULL, - BitCount64(EventTag_ServerEvent), - EGROUP_DDL_RESOURCE_GROUP, - 0 - }, - - //----------------------------------------------- - // ALTER WORKLOAD GROUP Event Schema - //----------------------------------------------- - { ETYP_ON_ALTER_RES_GROUP, - x_eet_Alter_Resource_Group, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_WORKLOAD_GROUP", - EventTag_ServerEvent, - NULL, - BitCount64(EventTag_ServerEvent), - EGROUP_DDL_RESOURCE_GROUP, - 0 - }, - - //----------------------------------------------- - // DROP WORKLOAD GROUP Event Schema - //----------------------------------------------- - { ETYP_ON_DROP_RES_GROUP, - x_eet_Drop_Resource_Group, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_WORKLOAD_GROUP", - EventTag_ServerEvent, - NULL, - BitCount64(EventTag_ServerEvent), - EGROUP_DDL_RESOURCE_GROUP, - 0 - }, - - //----------------------------------------------- - // ALTER RESOURCE GOVERNOR CONFIGURATION Event Schema - //----------------------------------------------- - { ETYP_ON_ALTER_RES_GOVERNOR_CONFIG, - x_eet_Alter_Resource_Governor_Config, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_RESOURCE_GOVERNOR_CONFIG", - EventTag_ServerEvent, - NULL, - BitCount64(EventTag_ServerEvent), - EGROUP_DDL_RESOURCE_GOVERNOR, - 0 - }, - - - //----------------------------------------------- - // CREATE SPATIAL INDEX Event Schema - //----------------------------------------------- - { ETYP_ON_CREATE_SPATIAL_INDEX, - x_eet_Create_Spatial_Index, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_SPATIAL_INDEX", - EventTag_SchemaTargetDDL, - NULL, - BitCount64( EventTag_SchemaTargetDDL), - EGROUP_DDL_INDEX, - 0 - }, - - // Audit Related Events - // - //----------------------------------------------- - // CREATE SERVER AUDIT Event Schema - //----------------------------------------------- - { ETYP_ON_CREATE_SERVER_AUDIT, - x_eet_Create_ServerAudit, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_SERVER_AUDIT", - EventTag_ServerEvent, - NULL, - BitCount64(EventTag_ServerEvent), - EGROUP_DDL_SERVERAUDIT, - 0 - }, - - //----------------------------------------------- - // ALTER SERVER AUDIT Event Schema - //----------------------------------------------- - { ETYP_ON_ALTER_SERVER_AUDIT, - x_eet_Alter_ServerAudit, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_SERVER_AUDIT", - EventTag_ServerEvent, - NULL, - BitCount64(EventTag_ServerEvent), - EGROUP_DDL_SERVERAUDIT, - 0 - }, - - //----------------------------------------------- - // DROP SERVER AUDIT Event Schema - //----------------------------------------------- - { ETYP_ON_DROP_SERVER_AUDIT, - x_eet_Drop_ServerAudit, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_SERVER_AUDIT", - EventTag_ServerEvent, - NULL, - BitCount64(EventTag_ServerEvent), - EGROUP_DDL_SERVERAUDIT, - 0 - }, - - //----------------------------------------------- - // CREATE SERVER AUDIT SPEC Event Schema - //----------------------------------------------- - { ETYP_ON_CREATE_SERVER_AUDIT_SPEC, - x_eet_Create_ServerAuditSpec, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_SERVER_AUDIT_SPECIFICATION", - EventTag_ServerEvent, - NULL, - BitCount64(EventTag_ServerEvent), - EGROUP_DDL_SERVERAUDITSPEC, - 0 - }, - - //----------------------------------------------- - // ALTER SERVER AUDIT SPEC Event Schema - //----------------------------------------------- - { ETYP_ON_ALTER_SERVER_AUDIT_SPEC, - x_eet_Alter_ServerAuditSpec, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_SERVER_AUDIT_SPECIFICATION", - EventTag_ServerEvent, - NULL, - BitCount64(EventTag_ServerEvent), - EGROUP_DDL_SERVERAUDITSPEC, - 0 - }, - - //----------------------------------------------- - // DROP SERVER AUDIT SPEC Event Schema - //----------------------------------------------- - { ETYP_ON_DROP_SERVER_AUDIT_SPEC, - x_eet_Drop_ServerAuditSpec, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_SERVER_AUDIT_SPECIFICATION", - EventTag_ServerEvent, - NULL, - BitCount64(EventTag_ServerEvent), - EGROUP_DDL_SERVERAUDITSPEC, - 0 - }, - - //----------------------------------------------- - // CREATE DB AUDIT SPEC Event Schema - //----------------------------------------------- - { ETYP_ON_CREATE_DB_AUDIT_SPEC, - x_eet_Create_DbAuditSpec, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_DATABASE_AUDIT_SPECIFICATION", - EventTag_DatabaseEvent | EventTag_ObjectEvent, - NULL, - BitCount64(EventTag_DatabaseEvent | EventTag_ObjectEvent), - EGROUP_DDL_DBAUDITSPEC, - 0 - }, - - //----------------------------------------------- - // ALTER DB AUDIT SPEC Event Schema - //----------------------------------------------- - { ETYP_ON_ALTER_DB_AUDIT_SPEC, - x_eet_Alter_DbAuditSpec, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_DATABASE_AUDIT_SPECIFICATION", - EventTag_DatabaseEvent | EventTag_ObjectEvent, - NULL, - BitCount64(EventTag_DatabaseEvent | EventTag_ObjectEvent), - EGROUP_DDL_DBAUDITSPEC, - 0 - }, - - //----------------------------------------------- - // DROP DB AUDIT SPEC Event Schema - //----------------------------------------------- - { ETYP_ON_DROP_DB_AUDIT_SPEC, - x_eet_Drop_DbAuditSpec, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_DATABASE_AUDIT_SPECIFICATION", - EventTag_DatabaseEvent | EventTag_ObjectEvent, - NULL, - BitCount64(EventTag_DatabaseEvent | EventTag_ObjectEvent), - EGROUP_DDL_DBAUDITSPEC, - 0 - }, - - //----------------------------------------------- - // CREATE SEQUENCE Event Schema - //----------------------------------------------- - { ETYP_ON_CREATE_SEQUENCE, - x_eet_Create_Sequence, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_SEQUENCE", - EventTag_SchemaDDL, - NULL, - BitCount64(EventTag_SchemaDDL), - EGROUP_DDL_SEQUENCE, - 0 - }, - - //----------------------------------------------- - // ALTER SEQUENCE Event Schema - //----------------------------------------------- - { ETYP_ON_ALTER_SEQUENCE, - x_eet_Alter_Sequence, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_SEQUENCE", - EventTag_SchemaDDL, - NULL, - BitCount64(EventTag_SchemaDDL), - EGROUP_DDL_SEQUENCE, - 0 - }, - - //----------------------------------------------- - // DROP SEQUENCE Event Schema - //----------------------------------------------- - { ETYP_ON_DROP_SEQUENCE, - x_eet_Drop_Sequence, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_SEQUENCE", - EventTag_SchemaDDL, - NULL, - BitCount64(EventTag_SchemaDDL), - EGROUP_DDL_SEQUENCE, - 0 - }, - - //----------------------------------------------- - // CREATE AVAILABILITY GROUP Event Schema - //----------------------------------------------- - { ETYP_ON_CREATE_AVAILABILITY_GROUP, - x_eet_Create_Availability_Group, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_AVAILABILITY_GROUP", - EventTag_ServerEvent, - NULL, - BitCount64(EventTag_ServerEvent), - EGROUP_DDL_AVAILABILITY_GROUP, - 0 - }, - - //----------------------------------------------- - // ALTER AVAILABILITY GROUP Event Schema - //----------------------------------------------- - { ETYP_ON_ALTER_AVAILABILITY_GROUP, - x_eet_Alter_Availability_Group, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_AVAILABILITY_GROUP", - EventTag_ServerEvent, - NULL, - BitCount64(EventTag_ServerEvent), - EGROUP_DDL_AVAILABILITY_GROUP, - 0 - }, - - //----------------------------------------------- - // DROP AVAILABILITY GROUP Event Schema - //----------------------------------------------- - { ETYP_ON_DROP_AVAILABILITY_GROUP, - x_eet_Drop_Availability_Group, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_AVAILABILITY_GROUP", - EventTag_ServerEvent, - NULL, - BitCount64(EventTag_ServerEvent), - EGROUP_DDL_AVAILABILITY_GROUP, - 0 - }, - - //----------------------------------------------- - // CREATE DATABASE AUDIT Event Schema - //----------------------------------------------- - { ETYP_ON_CREATE_DATABASE_AUDIT, - x_eet_Create_Database_Audit, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_AUDIT", - EventTag_DatabaseEvent | EventTag_ObjectEvent, - NULL, - BitCount64(EventTag_DatabaseEvent | EventTag_ObjectEvent), - EGROUP_DDL_DBAUDIT, - 0 - }, - - //----------------------------------------------- - // DROP DATABASE AUDIT Event Schema - //----------------------------------------------- - { ETYP_ON_DROP_DATABASE_AUDIT, - x_eet_Drop_Database_Audit, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_AUDIT", - EventTag_DatabaseEvent | EventTag_ObjectEvent, - NULL, - BitCount64(EventTag_DatabaseEvent | EventTag_ObjectEvent), - EGROUP_DDL_DBAUDIT, - 0 - }, - - //----------------------------------------------- - // ALTER DATABASE AUDIT Event Schema - //----------------------------------------------- - { ETYP_ON_ALTER_DATABASE_AUDIT, - x_eet_Alter_Database_Audit, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_AUDIT", - EventTag_DatabaseEvent | EventTag_ObjectEvent, - NULL, - BitCount64(EventTag_DatabaseEvent | EventTag_ObjectEvent), - EGROUP_DDL_DBAUDIT, - 0 - }, - - //----------------------------------------------- - // CREATE SECURITY POLICY Event Schema - //----------------------------------------------- - { ETYP_ON_CREATE_SECURITY_POLICY, - x_eet_Create_Security_Policy, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_SECURITY_POLICY", - EventTag_SchemaDDL, - NULL, - BitCount64(EventTag_SchemaDDL), - EGROUP_DDL_SECURITY_POLICY, - 0 - }, - - //----------------------------------------------- - // ALTER SECURITY POLICY Event Schema - //----------------------------------------------- - { ETYP_ON_ALTER_SECURITY_POLICY, - x_eet_Alter_Security_Policy, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_SECURITY_POLICY", - EventTag_SchemaDDL, - NULL, - BitCount64(EventTag_SchemaDDL), - EGROUP_DDL_SECURITY_POLICY, - 0 - }, - - //----------------------------------------------- - // DROP SECURITY POLICY Event Schema - //----------------------------------------------- - { ETYP_ON_DROP_SECURITY_POLICY, - x_eet_Drop_Security_Policy, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_SECURITY_POLICY", - EventTag_SchemaDDL, - NULL, - BitCount64(EventTag_SchemaDDL), - EGROUP_DDL_SECURITY_POLICY, - 0 - }, - - //----------------------------------------------- - // CREATE COLUMN MASTER KEY Event Schema - //----------------------------------------------- - { ETYP_ON_CREATE_COL_MASTER_KEY, - x_eet_Create_Col_Master_Key, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_COLUMN_MASTER_KEY", - EventTag_DatabaseEvent | EventTag_ObjectEvent, - NULL, - BitCount64(EventTag_DatabaseEvent | EventTag_ObjectEvent), - EGROUP_DDL_COL_MASTER_KEY, - 0 - }, - - //----------------------------------------------- - // DROP COLUMN MASTER KEY Event Schema - //----------------------------------------------- - { ETYP_ON_DROP_COL_MASTER_KEY, - x_eet_Drop_Col_Master_Key, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_COLUMN_MASTER_KEY", - EventTag_DatabaseEvent | EventTag_ObjectEvent, - NULL, - BitCount64(EventTag_DatabaseEvent | EventTag_ObjectEvent), - EGROUP_DDL_COL_MASTER_KEY, - 0 - }, - - //----------------------------------------------- - // CREATE COLUMN ENCRYPTION KEY Event Schema - //----------------------------------------------- - { ETYP_ON_CREATE_COL_ENCRYPTION_KEY, - x_eet_Create_Col_Encryption_Key, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_COLUMN_ENCRYPTION_KEY", - EventTag_DatabaseEvent | EventTag_ObjectEvent, - NULL, - BitCount64(EventTag_DatabaseEvent | EventTag_ObjectEvent), - EGROUP_DDL_COL_ENCRYPTION_KEY, - 0 - }, - - //----------------------------------------------- - // ALTER COLUMN ENCRYPTION KEY Event Schema - //----------------------------------------------- - { ETYP_ON_ALTER_COL_ENCRYPTION_KEY, - x_eet_Alter_Col_Encryption_Key, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_COLUMN_ENCRYPTION_KEY", - EventTag_DatabaseEvent | EventTag_ObjectEvent, - NULL, - BitCount64(EventTag_DatabaseEvent | EventTag_ObjectEvent), - EGROUP_DDL_COL_ENCRYPTION_KEY, - 0 - }, - - //----------------------------------------------- - // DROP COLUMN ENCRYPTION KEY Event Schema - //----------------------------------------------- - { ETYP_ON_DROP_COL_ENCRYPTION_KEY, - x_eet_Drop_Col_Encryption_Key, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_COLUMN_ENCRYPTION_KEY", - EventTag_DatabaseEvent | EventTag_ObjectEvent, - NULL, - BitCount64(EventTag_DatabaseEvent | EventTag_ObjectEvent), - EGROUP_DDL_COL_ENCRYPTION_KEY, - 0 - }, - - //----------------------------------------------- - // ALTER DATABASE SCOPED CONFIG Event Schema - //----------------------------------------------- - { ETYP_ON_ALTER_DB_SCOPED_CONFIG, - x_eet_Alter_DB_Scoped_Config, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_DATABASE_SCOPED_CONFIGURATION", - EventTag_DatabaseEvent, - NULL, - BitCount64(EventTag_DatabaseEvent), - EGROUP_DDL_DATABASE_LEVEL, - 0 - }, - - //----------------------------------------------- - // CREATE EXTERNAL RESOURCE POOL Event Schema - //----------------------------------------------- - { ETYP_ON_CREATE_EXTERNAL_RESOURCE_POOL, - x_eet_Create_External_Resource_Pool, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_EXTERNAL_RESOURCE_POOL", - EventTag_ServerEvent, - NULL, - BitCount64(EventTag_ServerEvent), - EGROUP_DDL_EXTERNAL_RESOURCE_POOL, - 0 - }, - - //----------------------------------------------- - // ALTER EXTERNAL RESOURCE POOL Event Schema - //----------------------------------------------- - { ETYP_ON_ALTER_EXTERNAL_RESOURCE_POOL, - x_eet_Alter_External_Resource_Pool, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_EXTERNAL_RESOURCE_POOL", - EventTag_ServerEvent, - NULL, - BitCount64(EventTag_ServerEvent), - EGROUP_DDL_EXTERNAL_RESOURCE_POOL, - 0 - }, - - //----------------------------------------------- - // DROP EXTERNAL RESOURCE POOL Event Schema - //----------------------------------------------- - { ETYP_ON_DROP_EXTERNAL_RESOURCE_POOL, - x_eet_Drop_External_Resource_Pool, - EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_EXTERNAL_RESOURCE_POOL", - EventTag_ServerEvent, - NULL, - BitCount64(EventTag_ServerEvent), - EGROUP_DDL_EXTERNAL_RESOURCE_POOL, - 0 - }, - - //----------------------------------------------- - // CREATE EXTERNAL LIBRARY Event Schema - //----------------------------------------------- - { ETYP_ON_CREATE_EXTERNAL_LIBRARY, - x_eet_Create_External_Library, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_EXTERNAL_LIBRARY", - EventTag_SchemaLessDDL, - NULL, - 4, - EGROUP_DDL_LIBRARY, - 0 - }, - - //----------------------------------------------- - // ALTER EXTERNAL LIBRARY Event Schema - //----------------------------------------------- - { ETYP_ON_ALTER_EXTERNAL_LIBRARY, - x_eet_Alter_External_Library, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_EXTERNAL_LIBRARY", - EventTag_SchemaLessDDL, - NULL, - 4, - EGROUP_DDL_LIBRARY, - 0 - }, - - //----------------------------------------------- - // DROP EXTERNAL LIBRARY Event Schema - //----------------------------------------------- - { ETYP_ON_DROP_EXTERNAL_LIBRARY, - x_eet_Drop_External_Library, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_EXTERNAL_LIBRARY", - EventTag_SchemaLessDDL, - NULL, - 4, - EGROUP_DDL_LIBRARY, - 0 - }, - - //----------------------------------------------- - // ADD SENSITIVITY CLASSIFICATION Event Schema - //----------------------------------------------- - { ETYP_ON_ADD_SENSITIVITY_CLASSIFICATION, - x_eet_Add_Sensitivity_Classification, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ADD_SENSITIVITY_CLASSIFICATION", - EventTag_SchemaDDL, - NULL, - BitCount64(EventTag_SchemaDDL), - EGROUP_DDL_SENSITIVITY, - 0 - }, - - //----------------------------------------------- - // DROP SENSITIVITY CLASSIFICATION Event Schema - //----------------------------------------------- - { ETYP_ON_DROP_SENSITIVITY_CLASSIFICATION, - x_eet_Drop_Sensitivity_Classification, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_SENSITIVITY_CLASSIFICATION", - EventTag_SchemaDDL, - NULL, - BitCount64(EventTag_SchemaDDL), - EGROUP_DDL_SENSITIVITY, - 0 - }, - - //----------------------------------------------- - // CREATE EXTERNAL LANGUAGE Event Schema - //----------------------------------------------- - { ETYP_ON_CREATE_EXTERNAL_LANGUAGE, - x_eet_Create_External_Language, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"CREATE_EXTERNAL_LANGUAGE", - EventTag_SchemaLessDDL, - NULL, - BitCount64(EventTag_SchemaLessDDL), - EGROUP_DDL_EXTERNAL_LANGUAGE, - 0 - }, - - //----------------------------------------------- - // ALTER EXTERNAL LANGUAGE Event Schema - //----------------------------------------------- - { ETYP_ON_ALTER_EXTERNAL_LANGUAGE, - x_eet_Alter_External_Language, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"ALTER_EXTERNAL_LANGUAGE", - EventTag_SchemaLessDDL, - NULL, - BitCount64(EventTag_SchemaLessDDL), - EGROUP_DDL_EXTERNAL_LANGUAGE, - 0 - }, - - //----------------------------------------------- - // DROP EXTERNAL LANGUAGE Event Schema - //----------------------------------------------- - { ETYP_ON_DROP_EXTERNAL_LANGUAGE, - x_eet_Drop_External_Language, - EOBJTYP_DATABASE | EOBJTYP_SERVER, - EFLAG_SAME_TRANS, - L"DROP_EXTERNAL_LANGUAGE", - EventTag_SchemaLessDDL, - NULL, - BitCount64(EventTag_SchemaLessDDL), - EGROUP_DDL_EXTERNAL_LANGUAGE, - 0 - }, - - //*********************************************************************** - // START - NON DDL EVENT TYPES - START - //*********************************************************************** - - //----------------------------------------------- - // SERVICE QUEUE ACTIVATION Event Schema - //----------------------------------------------- - { ETYP_ON_ACTIVATION, - x_eet_Activation, - EOBJTYP_SVCQ, - EFLAG_ASYNC_ONLY, - L"QUEUE_ACTIVATION", - EventTag_ObjectEvent | EventTag_DatabaseName | EventTag_SchemaName, - NULL, - 4, - EGROUP_ALL, - 0 - }, - - //----------------------------------------------- - // SERVICE QUEUE DISABLED Event Schema - //----------------------------------------------- - { ETYP_ON_QUEUE_DISABLED, - x_eet_Queue_Disabled, - EOBJTYP_SVCQ, - EFLAG_ASYNC_ONLY | EFLAG_DDLADMN_CAD_PERM, - L"BROKER_QUEUE_DISABLED", - EventTag_ObjectEvent | EventTag_DatabaseName | EventTag_SchemaName, - NULL, - 4, - EGROUP_ALL, - 0 - }, - - //----------------------------------------------- - // ALTER SERVER CONFIGURATION Event Schema - // ALTER SERVER does not support transactional semantics and does not expose a DDL trigger - //----------------------------------------------- - { ETYP_ON_ALTER_SERVER_CONFIG, - x_eet_Alter_Server_Config, - EOBJTYP_SERVER, - EFLAG_ASYNC_ONLY, - L"ALTER_SERVER_CONFIGURATION", - EventTag_ObjectType | EventTag_TSQLCommand, - NULL, - BitCount64(EventTag_ObjectType | EventTag_TSQLCommand), - EGROUP_ALL, - 0 - }, - - //*********************************************************************** - // END - NON DDL EVENT TYPES - END - //*********************************************************************** - - //------------------------------------------------- - // SQL Trace events. Do not add regular events below this!!! - //------------------------------------------------- -#include "schema.inc" -}; - diff --git a/SmoBuild/DdlEvents/trccomn.h b/SmoBuild/DdlEvents/trccomn.h deleted file mode 100644 index 8655fbf0..00000000 --- a/SmoBuild/DdlEvents/trccomn.h +++ /dev/null @@ -1,1387 +0,0 @@ -// *************************************************************************** -// Copyright (C) Microsoft Corporation. -// @File: trccomn.h -// @Owner: ivanpe, fvoznika, jhalmans -// @Test: pedrou -// -// PURPOSE: Contains event and column definitions -// AUTHOR: NC Oct. 1999 -// -// @EndHeader@ -// *************************************************************************** - - -#ifndef TRCCOMN_H_ -#define TRCCOMN_H_ - -#define HRESULT_WARNING_FROM_SQL(exnumber) (MAKE_HRESULT(SEVERITY_SUCCESS, FACILITY_SQL, (exnumber))) - -// SQLTrace eTraceError conversions -#define EX_MINOR_FROM_TRC_ERROR(err) ((err) + 50) -#define EX_NUMBER_FROM_TRC_ERROR(err) (EX_NUMBER(SQLTRACE_ERR,EX_MINOR_FROM_TRC_ERROR(err))) -#define HRESULT_FROM_TRC_ERROR(err) (HRESULT_FROM_SQL(EX_NUMBER_FROM_TRC_ERROR(err))) -#define HRESULT_WARNING_FROM_TRC_ERROR(err) (HRESULT_WARNING_FROM_SQL(EX_NUMBER_FROM_TRC_ERROR(err))) -#define TRC_ERROR_FROM_HRESULT(hr) ((EX_NUMBER_FROM_HRESULT(hr)>0 && EX_MAJOR(EX_NUMBER_FROM_HRESULT(hr)) == SQLTRACE_ERR)? \ - EX_MINOR(EX_NUMBER_FROM_HRESULT(hr)) - 50 : 0) - - -// useful defines -#define BITS_PER_DWORD (sizeof(DWORD)*8) -#define RELEVANT_DWORD(ec) ((ec)/BITS_PER_DWORD) -#define BIT_IN_DWORD(ec) (0x1 << ((ec)%BITS_PER_DWORD)) - -// Maximum file path length for server file writing -#define MAX_TRACE_FILE_PATH 245 - -// a few useful enums -enum ETraceStatus - { - eTraceStopped, - eTraceStarted, - eTraceClose, - eTracePause, - }; - -// Enum for CTraceFilter booleans -enum EFilterBool - { - // Logical operator will be first - eFilterBoolAnd = 0, // AND - eFilterBoolOr, // OR - }; - -// Enum for CTraceFilter operations. -enum EFilterOp - { - // Filter operations - eFilterOpEq = 0, // equal - eFilterOpNe, // not equal - eFilterOpGt, // greater than - eFilterOpLt, // less than - eFilterOpGe, // greater than or equal - eFilterOpLe, // less than or equal - eFilterOpLike, // like - eFilterOpNotLike // not like - }; - -// Enum for Options that can be set on a server. -enum ETraceOptions -{ - eTraceDestRowset = 0x1, // data written to a rowset - eTraceRollover = 0x2, // rollover files at some max file size - eTraceShutdown = 0x4, // shutdown server on write error - eTraceFlightRec = 0x8, // Trace is being used as the flight recorder. - - // Extended option occupies high word, and is sequential number. - // Combined option would look like 0x10002 - eTraceNoExtended = 0, // No extended option this time -}; - -#define TRACEOPTIONS_NORMAL (eTraceDestRowset|eTraceRollover|eTraceShutdown|eTraceFlightRec) -#define TRACEOPTIONS_EXTENDED_MAX (eTraceNoExtended) - -inline ULONG UlTraceOptionNormalPart(__in ULONG ulOptions) -{ - return (ulOptions & 0xFFFF); -} - -inline ULONG UlTraceOptionExtendedPart(__in ULONG ulOptions) -{ - return (ulOptions >> 16); -} - -inline BOOL FIsTraceOptionWithinValidRange(__in ULONG ulOptions) -{ - return ((UlTraceOptionNormalPart(ulOptions) & (~TRACEOPTIONS_NORMAL)) == 0) - && (UlTraceOptionExtendedPart(ulOptions) <= TRACEOPTIONS_EXTENDED_MAX); -} - -// Enum for get options as returned by ::fn_trace_getTraceInfo -enum ETraceProperties - { - etpRowsetOpened = 0, - etpOptions, - etpFileName, - etpMaxsize, - etpStopTime, - etpStatus, - }; - - -// NOTE: These values are identical to the corresponding XVT_* values. -typedef enum ETraceDataTypes -{ - TRACE_I4 = 1, // XVT_I4 - TRACE_DATETIME, // XVT_SSDATE - TRACE_I8, // XVT_I8 - TRACE_BYTES, // XVT_SSBYTES - TRACE_WSTR, // XVT_VARWSTR - TRACE_NTEXT, // XVT_NTEXT - TRACE_GUID, // XVT_SSGUID -} ENUM_TRACE_DATA_TYPES; - -// =================================================================================== -// Events -// =================================================================================== - -// User Events 0x1 - 0xf3fe -// Replay events 0xf3ff - 0xf7fe -// Profiler events 0xf7ff - 0xfbfe -// Trace special events 0xfbff - 0xfffe - -#define IS_SPECIAL_EVENT(ec) (((ULONG)ec) > 0xF3FF) -#define TRACE_INVALID_EVENT 0xffff - -typedef enum -{ - TRACE_START_EVENT = 0XFFFE, - TRACE_STOP_EVENT = 0XFFFD, - TRACE_ERROR_EVENT = 0XFFFC, - TRACE_SKIPPED_EVENT = 0XFFFB, - TRACE_NOP = 0XFFFA, - TRACE_PAUSE_EVENT = 0xFFF9, - TRACE_HEADER_EVENT = 0xFFF8, - TRACE_ROLLOVER_EVENT = 0xFFF7, -} CONTROL_EVENTS; - - -// Event classes -// See DEVNOTE at the end of this enumeration!!! -typedef enum -{ - EVENT_CLASS_UNUSED = 0, // 0 to 9 Unused by server and blocked for compatiblity - EVENT_CLASS_START = 10, - //$$EVENT_CLASS_START do not remove this comment - POST_RPC_EVENT_CLASS = 10, // pingwang, jayc - PRE_RPC_EVENT_CLASS = 11, // pingwang, jayc - POST_LANG_EVENT_CLASS = 12, // pingwang, jayc - PRE_LANG_EVENT_CLASS = 13 , // pingwang, jayc - AUDIT_LOGIN_EVENT_CLASS = 14, // sashwin, pingwang - AUDIT_LOGOUT_EVENT_CLASS = 15, // sashwin, pingwang - ATTENTION_EVENT_CLASS = 16, // sashwin, pingwang - ACTIVE_EVENT_CLASS = 17, // jayc - AUDIT_SERVER_START_STOP_EVENT_CLASS = 18, // peterbyr - DTC_EVENT_CLASS = 19, // mikepurt - AUDIT_LOGIN_FAILED_EVENT_CLASS = 20, // sashwin - EVENTLOG_EVENT_CLASS = 21, // jayc - ERRORLOG_EVENT_CLASS = 22, // jayc - LCK_RELEASE_EVENT_CLASS = 23, // santeriv - LCK_ACQUIRE_EVENT_CLASS = 24, // santeriv - LCK_DEADLOCK_EVENT_CLASS = 25, // santeriv - LCK_CANCEL_EVENT_CLASS = 26, // santeriv - LCK_TIMEOUT_EVENT_CLASS = 27, // santeriv - DOP_EVENT_CLASS = 28, // ddavison - DOP_UPDATE_EVENT_CLASS = 29, // ddavison - DOP_DELETE_EVENT_CLASS = 30, // ddavison - DOP_SELECT_EVENT_CLASS = 31, // ddavison - RESERVED_32, // Can be reused - EXCEPTION_EVENT_CLASS = 33, // jayc - CP_MISS_EVENT_CLASS = 34, // ganakris - CP_INSERT_EVENT_CLASS = 35, // ganakris - CP_REMOVE_EVENT_CLASS = 36, // ganakris - CP_RECOMPILE_EVENT_CLASS = 37, // ganakris, eriki - CP_HIT_EVENT_CLASS = 38, // ganakris - RESERVED_39 = 39, // Can not be reused. This used to be EC_EVENT_CLASS (in Shiloh) - STMT_START_EVENT_CLASS = 40, // eriki, jayc - STMT_END_EVENT_CLASS = 41, // eriki, jayc - SP_START_EVENT_CLASS = 42, // eriki, jayc - SP_END_EVENT_CLASS = 43, // eriki, jayc - SP_STMT_START_EVENT_CLASS = 44, // eriki, jayc - SP_STMT_END_EVENT_CLASS = 45, // eriki, jayc - OBJECT_CREATE_EVENT_CLASS = 46, // sameerv, deepakp - OBJECT_DELETE_EVENT_CLASS = 47, // sameerv, deepakp - OBJECT_OPEN_EVENT_CLASS = 48, // sameerv, deepakp - OBJECT_CLOSE_EVENT_CLASS = 49, // UNUSED? - TRANS_EVENT_CLASS = 50, // mikepurt - SCAN_START_EVENT_CLASS = 51, // srikumar - SCAN_STOP_EVENT_CLASS = 52, // srikumar - CURSOR_CREATED_EVENT_CLASS = 53, // ganakris - LOG_EVENT_CLASS = 54, // peterbyr - HASH_WARNINGS_EVENT_CLASS = 55, // asurna - RESERVED_56, // THIS SHOULD BE USABLE IN THE FUTURE!!! - RESERVED_57, // used to be RECOMPILE_NOHINTS_EVENT_CLASS - AUTO_STATS_EVENT_CLASS = 58, // jjchen - LCK_DEADLOCKCHAIN_EVENT_CLASS = 59, // alexverb - LCK_ESCALATION_EVENT_CLASS = 60, // santeriv - OLEDB_ERRORS_EVENT_CLASS = 61, // shailv - // 62 - 66 Used by profiler replay. - QRY_EXEC_WARNINGS_EVENT_CLASS = 67, // weyg - SHOWPLAN_EVENT_CLASS = 68, // pingwang, alexisb - SORT_WARNING_EVENT_CLASS = 69, // weyg - CURSOR_PREPARE_EVENT_CLASS = 70, // sashwin, eriki, ganakris - PREPARE_EVENT_CLASS = 71, // sashwin, eriki, ganakris - EXECUTE_EVENT_CLASS = 72, // sashwin, eriki, ganakris - UNPREPARE_EVENT_CLASS = 73, // sashwin, eriki, ganakris - CURSOR_EXECUTE_EVENT_CLASS = 74, // gnakris - CURSOR_RECOMPILE_EVENT_CLASS = 75, // gnakris - CURSOR_IMPLCTCNV_EVENT_CLASS = 76, // gnakris - CURSOR_UNPREPARE_EVENT_CLASS = 77, // gnakris - CURSOR_CLOSE_EVENT_CLASS = 78, // gnakris - NO_STATISTICS_EVENT_CLASS = 79, // jjchen - NO_JOIN_PREDICATE_EVENT_CLASS = 80, // cesarg - MEMORY_CHANGE_EVENT_CLASS = 81, // slavao - // User defined event classes start here - USER_CONFIGURABLE_0_EVENT_CLASS = 82, // ganakris - USER_CONFIGURABLE_1_EVENT_CLASS = 83, // ganakris - USER_CONFIGURABLE_2_EVENT_CLASS = 84, // ganakris - USER_CONFIGURABLE_3_EVENT_CLASS = 85, // ganakris - USER_CONFIGURABLE_4_EVENT_CLASS = 86, // ganakris - USER_CONFIGURABLE_5_EVENT_CLASS = 87, // ganakris - USER_CONFIGURABLE_6_EVENT_CLASS = 88, // ganakris - USER_CONFIGURABLE_7_EVENT_CLASS = 89, // ganakris - USER_CONFIGURABLE_8_EVENT_CLASS = 90, // ganakris - USER_CONFIGURABLE_9_EVENT_CLASS = 91, // ganakris - - // NOTE: START OF 8.0 EVENTS. CHANGE FIRST_8X_EVENT_CLASS ACCORDINGLY! - DATAFILE_AUTOGROW_EVENT_CLASS = 92, // peterbyr - LOGFILE_AUTOGROW_EVENT_CLASS = 93, // peterbyr - DATAFILE_AUTOSHRINK_EVENT_CLASS = 94, // peterbyr - LOGFILE_AUTOSHRINK_EVENT_CLASS = 95, // peterbyr - SHOWPLAN_TEXT_EVENT_CLASS = 96, // pingwang, alexisb - SHOWPLAN_ALL_EVENT_CLASS = 97, // pingwang, alexisb - SHOWPLAN_STATISTICS_EVENT_CLASS = 98, // pingwang, alexisb - OLAP_NOTIFICATION_EVENT_CLASS = 99, // jayc - RPC_OUTPARAM_EVENT_CLASS = 100, // pingwang, jayc - // NOTE: START OF AUDIT EVENTS. THESE MUST REMAIN CONSTANT! - RESERVED_101, - SECURITY_GDR_DB_SCOPE_EVENT_CLASS = 102, // ruslano - SECURITY_GDR_SCH_OBJECT_EVENT_CLASS = 103, // ruslano - AUDIT_ADDLOGIN_EVENT_CLASS = 104, // ruslano, deprecated - AUDIT_LOGIN_GDR_EVENT_CLASS = 105, // ruslano, deprecated - SECURITY_SRV_LOGIN_PROP_EVENT_CLASS = 106, // ruslano - SECURITY_SRV_LOGIN_PWD_EVENT_CLASS = 107, // ruslano - SECURITY_SRV_ROLE_ADDPRIN_EVENT_CLASS = 108, // ruslano - AUDIT_ADD_DBUSER_EVENT_CLASS = 109, // ruslano, deprecated - SECURITY_DB_ROLE_ADDPRIN_EVENT_CLASS = 110, // ruslano - AUDIT_ADDROLE_EVENT_CLASS = 111, // ruslano, deprecated - SECURITY_DB_APPROLE_PWD_EVENT_CLASS = 112, // ruslano - AUDIT_STMT_PERM_EVENT_CLASS = 113, // ruslano, deprecated - SECURITY_SCH_OBJECT_ACCESS_EVENT_CLASS = 114, // ruslano - AUDIT_DMPLD_EVENT_CLASS = 115, // ruslano - AUDIT_DBCC_EVENT_CLASS = 116, // ryanston - AUDIT_CHANGE_AUDIT_EVENT_CLASS = 117, // jayc - AUDIT_OBJECT_DERIVED_PERM_EVENT_CLASS = 118, // ruslano, deprecated - - // YUKON events starts here - OLEDB_CALL_EVENT_CLASS = 119, // shailv - OLEDB_QUERYINTERFACE_EVENT_CLASS = 120, // shailv - OLEDB_DATAREAD_EVENT_CLASS = 121, // shailv - SHOWPLAN_XML_EVENT_CLASS = 122, // pingwang, alexisb - FULLTEXTQUERY_EVENT_CLASS = 123, // winfredw - - BROKER_DIALOG_ENDPOINT_EVENT_CLASS = 124, // ivantrin, augusthi - - // Deprecation events - DEPRECATION_ANNOUNCEMENT_EVENT_CLASS = 125, // ivanpe, jayc - DEPRECATION_FINAL_SUPPORT_EVENT_CLASS = 126, // ivanpe, jayc - - EXCHANGE_SPILL_EVENT_CLASS = 127, // martineu - - // Security audit events (con't) - // database and database objects - SECURITY_DB_MANAGE_EVENT_CLASS = 128, // ruslano - SECURITY_DB_OBJECT_MANAGE_EVENT_CLASS = 129, // ruslano - SECURITY_DB_PRINCIPAL_MANAGE_EVENT_CLASS = 130, // ruslano - - // schema objects - SECURITY_SCH_OBJECT_MANAGE_EVENT_CLASS = 131, // ruslano - - // impersonation - SECURITY_SRV_PRINCIPAL_IMPERSONATE_EVENT_CLASS = 132, // ruslano - SECURITY_DB_PRINCIPAL_IMPERSONATE_EVENT_CLASS = 133, // ruslano - - // take ownership - SECURITY_SRV_OBJECT_TAKEOWNERSHIP_EVENT_CLASS = 134, // ruslano - SECURITY_DB_OBJECT_TAKEOWNERSHIP_EVENT_CLASS = 135, // ruslano - - BROKER_CONVERSATION_GROUP_EVENT_CLASS = 136, // ivantrin, augusthi - BLOCKED_PROCESS_REPORT_EVENT_CLASS = 137, // alexverb - BROKER_CONNECTION_EVENT_CLASS = 138, // micn, augusthi - BROKER_FORWARDED_MESSAGE_SENT_EVENT_CLASS = 139, // micn - BROKER_FORWARDED_MESSAGE_DROPPED_EVENT_CLASS = 140, // micn - BROKER_MESSAGE_CLASSIFY_EVENT_CLASS = 141, // ivantrin, augusthi - BROKER_TRANSMISSION_EVENT_CLASS = 142, // micn - BROKER_QUEUE_DISABLED_EVENT_CLASS = 143, // augusthi - BROKER_MIRROR_ROUTE_EVENT_CLASS = 144, // rushid - RESERVED_FOR_BROKER_EVENT_CLASS_145 = 145, // augusthi - - SHOWPLAN_XML_STATISTICS_EVENT_CLASS = 146, // pingwang, alexisb - RESERVED_FOR_BROKER_EVENT_CLASS_147 = 147, // augusthi - SQLOS_XML_DEADLOCK_EVENT_CLASS = 148, // alexverb - BROKER_MESSAGE_ACK_EVENT_CLASS = 149, // micn, augusthi - TRACE_FILE_CLOSE_EVENT_CLASS = 150, // jayc - - // Database mirroring events - DBMIRRORING_CONNECTION_EVENT_CLASS = 151, // remusr, steveli - - // yukon security audit events (con't) - SECURITY_DB_TAKEOWNERSHIP_EVENT_CLASS = 152, // tamoyd, ruslano - SECURITY_SCH_OBJECT_TAKEOWNERSHIP_EVENT_CLASS = 153, // tamoyd, ruslano - AUDIT_DBMIRRORING_LOGIN_EVENT_CLASS = 154, // remusr, steveli - - // full-text events - FULLTEXT_CRAWL_START_EVENT_CLASS = 155, // nimishk - FULLTEXT_CRAWL_END_EVENT_CLASS = 156, // nimishk - FULLTEXT_CRAWL_ERROR_EVENT_CLASS = 157, // nimishk - - // service broker security audit events - AUDIT_BROKER_CONVERSATION_EVENT_CLASS = 158, // micn, augusthi - AUDIT_BROKER_LOGIN_EVENT_CLASS = 159, // micn, augusthi - - BROKER_MESSAGE_DROP_EVENT_CLASS = 160, // scottkon, augusthi - BROKER_CORRUPTED_MSG_EVENT_CLASS = 161, // scottkon, augusthi - - USER_ERROR_MSG_EVENT_CLASS = 162, // jayc - - BROKER_ACTIVATION_EVENT_CLASS = 163, // geraldh, augusthi - - OBJECT_ALTER_EVENT_CLASS = 164, // jayc - - // Performance event classes - STMT_PERFSTAT_EVENT_CLASS = 165, // ganakris, jayc - - STMT_RECOMPILE_EVENT_CLASS = 166, // eriki, ganakris - - // Database mirroring events (continued) - DBMIRRORING_STATE_CHANGE_EVENT_CLASS = 167, // steveli - - // Events on (re)compile - SHOWPLAN_XML_COMPILE_EVENT_CLASS = 168, // alexisb, pingwang - SHOWPLAN_ALL_COMPILE_EVENT_CLASS = 169, // alexisb, pingwang - - // Yukon security events (cont'd) - // GDR events - SECURITY_GDR_SRV_SCOPE_EVENT_CLASS = 170, // ruslano - SECURITY_GDR_SRV_OBJECT_EVENT_CLASS = 171, // ruslano - SECURITY_GDR_DB_OBJECT_EVENT_CLASS = 172, // ruslano - - // server and server objects - SECURITY_SRV_OPERATION_EVENT_CLASS = 173, // ruslano - FREE_TO_USE_174 = 174, // ruslano - SECURITY_SRV_ALTERTRACE_EVENT_CLASS = 175, // ruslano - SECURITY_SRV_OBJECT_MANAGE_EVENT_CLASS = 176, // ruslano - SECURITY_SRV_PRINCIPAL_MANAGE_EVENT_CLASS = 177, // ruslano - - // database and database objects - SECURITY_DB_OPERATION_EVENT_CLASS = 178, // ruslano - FREE_TO_USE_179 = 179, - SECURITY_DB_OBJECT_ACCESS_EVENT_CLASS = 180, // ruslano - - PRE_XACTEVENT_BEGIN_TRAN_EVENT_CLASS = 181, // pingwang, ganakris - POST_XACTEVENT_BEGIN_TRAN_EVENT_CLASS = 182, // pingwang, ganakris - PRE_XACTEVENT_PROMOTE_TRAN_EVENT_CLASS = 183, // pingwang, ganakris - POST_XACTEVENT_PROMOTE_TRAN_EVENT_CLASS = 184, // pingwang, ganakris - PRE_XACTEVENT_COMMIT_TRAN_EVENT_CLASS = 185, // pingwang, ganakris - POST_XACTEVENT_COMMIT_TRAN_EVENT_CLASS = 186, // pingwang, ganakris - PRE_XACTEVENT_ROLLBACK_TRAN_EVENT_CLASS = 187, // pingwang, ganakris - POST_XACTEVENT_ROLLBACK_TRAN_EVENT_CLASS = 188, // pingwang, ganakris - - // More lock events - LCK_TIMEOUT_NP_EVENT_CLASS = 189, // santeriv - - // Online index operation events - ONLINE_INDEX_PROGRESS_EVENT_CLASS = 190, // weyg - - - PRE_XACTEVENT_SAVE_TRAN_EVENT_CLASS = 191, // pingwang, ganakris - POST_XACTEVENT_SAVE_TRAN_EVENT_CLASS = 192, // pingwang, ganakris - QP_JOB_ERROR_EVENT_CLASS = 193, // marcfr - - // More oledb events - OLEDB_PROVIDERINFORMATION_EVENT_CLASS = 194, // shailv - - BACKUP_TAPE_MOUNT_EVENT_CLASS = 195, // sschmidt - - // CLR events - SQLCLR_ASSEMBLY_LOAD_CLASS = 196, // raviraj - FREE_TO_USE_197 = 197, // raviraj - - XQUERY_STATIC_TYPE_EVENT_CLASS = 198, // brunode - - // Query notifications - QN_SUBSCRIPTION_EVENT_CLASS = 199, // torsteng, florianw - QN_TABLE_EVENT_CLASS = 200, // torsteng, florianw - QN_QUERYTEMPLATE_EVENT_CLASS = 201, // torsteng, florianw - QN_DYNAMICS_EVENT_CLASS = 202, // torsteng, florianw - - - // Internal server diagnostics - PSS_QUERY_MEMGRANT_EVENT_CLASS = 203, // jayc - PSS_PAGE_PREFETCH_EVENT_CLASS = 204, // craigfr - PSS_BATCH_SORT_EVENT_CLASS = 205, // craigfr - PSS_EXCHNG_DOP_EVENT_CLASS = 206, // martineu - PSS_QE_VERBOSE_EVENT_CLASS = 207, // asurna - - PSS_CXROWSET_EVENT_CLASS = 208, // craigfr - - MATRIXDB_QUERY_ACTIVATION_SESSION_CLASS = 209, //naveenp - MATRIXDB_QUERY_ACTIVATION_BATCH_AND_LEVEL_CLASS = 210, //naveenp - MATRIXDB_QUERY_ACTIVATION_STMT_AND_QUERY_CLASS = 211, //naveenp - - BITMAP_WARNINGS_EVENT_CLASS = 212, // asurna - - DATABASE_SUSPECT_DATA_PAGE_EVENT_CLASS = 213, // kaloianm - - SQLOS_CPU_LIMIT_VIOLATION_EVENT_CLASS = 214, // alexverb - PRECONNECT_PRE_EVENT_CLASS = 215, // IvanPe - PRECONNECT_POST_EVENT_CLASS = 216, // IvanPe - - PLAN_GUIDE_SUCCESSFUL_EVENT_CLASS = 217, // vadimt - PLAN_GUIDE_UNSUCCESSFUL_EVENT_CLASS = 218, // vadimt - - MATRIXDB_TRANSACTION_START_END_CLASS = 219, // pingwang, tommill - MATRIXDB_TRANSACTION_STATE_TRANSITION_CLASS = 220, // pingwang, tommill - MATRIXDB_TRANSACTION_SHIPPING_CLASS = 221, // pingwang, tommill - MATRIXDB_TCM_EVENT_CLASS = 222, // tommill, pingwang - - MATRIXDB_CM_ENLISTMENT_CLASS = 223, // stefanr - MATRIXDB_CMA_ENLISTMENT_CLASS = 224, // stefanr - - MATRIXDB_ERROR_EVENT_CLASS = 225, //sanson - - MATRIXDB_QUERY_REMOTE_EXCHANGE_EVENT_CLASS = 226, //martineu - MATRIXDB_QUERY_RPC_EVENT_CLASS = 227, //martineu - - MATRIXDB_CLONE_REFRESH_EVENT_CLASS = 228, //vishalk - - - MATRIXDB_CM_EVENT_CLASS = 229, // stefanr - MATRIXDB_CMA_EVENT_CLASS = 230, // stefanr - - XEVENT_EVENT_CLASS = 231, // alexverb - - MATRIXDB_CLONE_TRANSITION_CLASS = 232, //andrewz - - MATRIXDB_CM_HEARTBEAT_EVENT_CLASS = 233, // sanson - MATRIXDB_CM_FAILURE_MONITOR_EVENT_CLASS = 234, // sanson - - AUDIT_FULLTEXT_EVENT_CLASS = 235, // sunnar - - //$$EVENT_CLASS_END do not remove this comment. - - // DEVNOTE!!!!!! - // ALL NEW RETAIL EVENTS MUST BE ADDED ABOVE THIS COMMENT!!!!! - // You need to follow the following format because this file is processed by perl script!!!! - // - // XXX_EVENT_CLASS = ddd, // list of owner alias - // - - TOTAL_RETAIL_EVENTS, - LAST_RETAIL_EVENT = TOTAL_RETAIL_EVENTS - 1, // dummy enum. do not remove. - - // CloudDB async transport trace events - // - ASYNC_TRANSPORT_CONNECTION_ERROR_EVENT_CLASS, // tomtal - ASYNC_TRANSPORT_CONNECT_EVENT_CLASS, // tomtal - ASYNC_TRANSPORT_SEND_EVENT_CLASS, // tomtal - ASYNC_TRANSPORT_RECEIVED_EVENT_CLASS, // tomtal - ASYNC_TRANSPORT_LOST_EVENT_CLASS, // tomtal - ASYNC_TRANSPORT_CORRUPTED_EVENT_CLASS, // tomtal - ASYNC_TRANSPORT_DISCONNECT_EVENT_CLASS, //tomtal - ASYNC_TRANSPORT_DEQUEUE_EVENT_CLASS, // tomtal - ASYNC_TRANSPORT_STATUS_EVENT_CLASS, // tomtal - - // CloudDB SE replication trace events - // - SEREPL_CAPTURE_ENLISTED_EVENT_CLASS, // tomtal - SEREPL_CAPTURE_COMMIT_WAIT_EVENT_CLASS, // tomtal - SEREPL_CAPTURE_COMMIT_FLUSHED_EVENT_CLASS, // tomtal - SEREPL_CAPTURE_COMMIT_ACKED_EVENT_CLASS, // tomtal - - SEREPL_APPLY_COMMIT_WAIT_EVENT_CLASS, // tomtal - SEREPL_APPLY_COMMIT_FLUSHED_EVENT_CLASS, // tomtal - SEREPL_APPLY_ENLISTED_EVENT_CLASS, // tomtal - - ASYNC_TRANSPORT_MESSAGE_CONTENT_CLASS, //santeriv, tomtal - - // Partition manager events - // - CLOUD_PM_REMOVE_PARTITION_EVENT_CLASS, // tomtal - CLOUD_PM_DELETE_PARTITION_EVENT_CLASS, // tomtal - CLOUD_PM_BECOME_NOTHING_EVENT_CLASS, // tomtal - CLOUD_PM_ADD_SECONDARY_EVENT_CLASS, // tomtal - CLOUD_PM_CHANGE_SECONDARY_EVENT_CLASS, // tomtal - CLOUD_PM_BECOME_PRIMARY_EVENT_CLASS, // tomtal - CLOUD_PM_ADD_PARTITION_EVENT_CLASS, // tomtal - CLOUD_PM_REMOVE_SECONDARY_EVENT_CLASS, // tomtal - - CLOUD_PM_START_NEW_EPOCH_EVENT_CLASS, // tomtal - - CLOUD_FABRIC_DB_PAIRING, // ajayk - CLOUD_FABRIC_DB_UN_PAIRING, // ajayk - WORKER_WAIT_STATS_EVENT_CLASS, // gangche - - CLOUD_PM_PARTITION_QUORUM_LOSS_EVENT_CLASS, // tomtal - CLOUD_PM_KILL_SECONDARY_EVENT_CLASS, // tomtal - CLOUD_PM_KILL_USER_TRANSACTIONS_EVENT_CLASS, // tomtal - CLOUD_PM_DELETE_PARTITION_CONTENT_EVENT_CLASS, // tomtal - CLOUD_PM_KILL_PRIMARY_EVENT_CLASS, // tomtal - CLOUD_PM_BECOME_SECONDARY_EVENT_CLASS, // tomtal - CLOUD_PM_SECONDARY_CATCHUP_REQUEST_EVENT_CLASS, // tomtal - CLOUD_PM_SECONDARY_CATCHUP_COMPLETE_EVENT_CLASS, // tomtal - CLOUD_PM_START_SECONDARY_COPY_EVENT_CLASS, // tomtal - CLOUD_PM_END_SECONDARY_COPY_EVENT_CLASS, // tomtal - CLOUD_PM_START_COPY_FROM_PRIMARY_EVENT_CLASS, // tomtal - CLOUD_PM_START_CATCHUP_FROM_PRIMARY_EVENT_CLASS, // tomtal - CLOUD_PM_CATCHUP_FROM_PRIMARY_COMPLETE_EVENT_CLASS, // tomtal - CLOUD_PM_SECONDARY_FAILURE_REPORT_EVENT_CLASS, // tomtal - CLOUD_PM_PRIMARY_FAILURE_REPORT_EVENT_CLASS, // tomtal - CLOUD_PM_RETURN_CSN, // tomtal - CLOUD_PM_START_SECONDARY_PERSISTENT_CATCHUP_EVENT_CLASS, // tomtal - CLOUD_PM_END_SECONDARY_PERSISTENT_CATCHUP_EVENT_CLASS, // tomtal - CLOUD_PM_ESTABLISH_SECONDARY_PERSISTENT_CATCHUP_EVENT_CLASS, // tomtal - SEREPL_EXCEPTION_EVENT_CLASS, - - ASYNC_TRANSPORT_CONNECTION_EVENT_CLASS, // tomtal - ASYNC_TRANSPORT_LOGIN_EVENT_CLASS, // tomtal - - CLOUD_PM_BECOME_FORWARDER_PENDING_EVENT_CLASS, // micn - CLOUD_PM_BECOME_FORWARDER_EVENT_CLASS, // micn - SFW_STMT_BLOCK_EVENT_CLASS, // balnee - CLOUD_PM_SET_PARTITION_COMMIT_MODE_EVENT_CLASS, // tomtal - SEREPL_SECONDARY_WORKER_LONG_SUSPEND_EVENT_CLASS, // tomtal - - CLOUD_PM_DUMMY_TRANSACTION_EVENT_CLASS, // tomtal - CLOUD_PM_SET_PARTITION_LOCK_MODE_EVENT_CLASS, - CLOUD_PM_SET_PARTITION_PREPARE_FULL_COMMIT_MODE_EVENT_CLASS, - CLOUD_PM_SET_PARTITION_THROTTLING_MODE_EVENT_CLASS, - - CLUSTER_PROXY_CONNECTION_EVENT_CLASS, // pporwal - CLUSTER_PROXY_LOGIN_EVENT_CLASS, // pporwal - - CLOUD_PM_PREFER_COPY_OVER_CATCHUP_EVENT_CLASS, // krishnib - - CLOUD_PM_DBSEEDING_BACKUP_PROGRESS_EVENT_CLASS, // nithinm - CLOUD_PM_DBSEEDING_RESTORE_PROGRESS_EVENT_CLASS, // nithinm - CLOUD_PM_DBSEEDING_VDICLIENT_EVENT_CLASS, // nithinm - - CLOUD_PM_DBSEEDING_INITIATE_BACKUP_EVENT_CLASS, // nithinm - CLOUD_PM_DBSEEDING_INITIATE_RESTORE_EVENT_CLASS, // nithinm - - GLOBAL_TRANSACTIONS_CONNECTION_EVENT_CLASS, // rosant - AUDIT_GLOBAL_TRANSACTIONS_LOGIN_EVENT_CLASS, // rosant - - STORAGE_CONNECTION_EVENT_CLASS, // tomtal - AUDIT_STORAGE_LOGIN_EVENT_CLASS, // tomtal - - // DEVNOTE!!!!!! - // ALL NEW TEMP (non GOLDEN_BITS) EVENTS MUST BE ADDED BELLOW THIS COMMENT!!!!! - // You should not assign values explicitly. The event IDs will change - // after more events are added, so all debug only events should be - // enabled (in test scripts) by name not by ID. These are also parsed - // by the Perl script so, please use the following format: - // - // TEMP_XXX_EVENT_CLASS, // list of owner alias - // - -#ifndef GOLDEN_BITS - TEMP_SCALABILITY_TEST_EVENT_CLASS, // ivanpe -#endif - - // DEVNOTE!!!!!! - // ALL NEW DEBUG EVENTS MUST BE ADDED BELLOW THIS COMMENT!!!!! - // You should not assign values explicitly. The event IDs will change - // after more events are added, so all debug only events should be - // enabled (in test scripts) by name not by ID. These are also parsed - // by the Perl script so, please use the following format: - // - // DBG_ONLY_XXX_EVENT_CLASS, // list of owner alias - // - // If you want to see your new events in Profier you will have to delete the - // trace definition xml file for your build number. It is located under: - // %ProgramFiles%\Microsoft SQL Server\90\Tools\Profiler\TraceDefinitions - // - -#ifdef DEBUG - DBG_ONLY_TEST_EVENT_CLASS, // ivanpe -#endif DEBUG - - TOTAL_EVENTS, -} TRACE_EVENTS; -#define TOTAL_EVENTS_FOR_SAL TOTAL_EVENTS -// 7.x events -#define FIRST_8X_EVENT_CLASS USER_CONFIGURABLE_5_EVENT_CLASS - -/////// SUB CLASSES start here ///////////////// -#define AUDIT_NO_SUBCLASS 0 - -///////////////////////////////////////////////////////////////////////// -// Security subclasses -// -// Event sub class definitions for Auditing Permission GDR Events -#define SECURITY_PERM_GRANT_SUBCLASS 1 -#define SECURITY_PERM_REVOKE_SUBCLASS 2 -#define SECURITY_PERM_DENY_SUBCLASS 3 - -// Event sub class definitions for principal management events -#define SECURITY_PRIN_ADD_SUBCLASS 1 -#define SECURITY_PRIN_DROP_SUBCLASS 2 -#define SECURITY_PRIN_CHANGE_GROUP_SUBCLASS 3 - -// event sub class specially for sp_grantdbaccess/sp_revokedbaccess -#define SECURITY_PRIN_GRANTDBACCESS_SUBCLASS 3 -#define SECURITY_PRIN_REVOKEDBACCESS_SUBCLASS 4 - -// Event sub class definitions for Auditing Backup/Restore Events -#define AUDIT_BACKUP_SUBCLASS 1 -#define AUDIT_RESTORE_SUBCLASS 2 -#define AUDIT_BACKUPLOG_SUBCLASS 3 - -// Event sub classes for Auditing changes of login properties -#define SECURITY_DEFDB_PROP_CHANGE_SUBCLASS 1 -#define SECURITY_DEFLANG_PROP_CHANGE_SUBCLASS 2 -#define SECURITY_NAME_PROP_CHANGE_SUBCLASS 3 -#define SECURITY_CREDENTIAL_PROP_CHANGE_SUBCLASS 4 -#define SECURITY_PWD_POLICY_PROP_CHANGE_SUBCLASS 5 -#define SECURITY_PWD_EXPIRATION_PROP_CHANGE_SUBCLASS 6 - -// Event sub classes for Auditing changes of login password -#define SECURITY_PWD_SELF_CHANGE_SUBCLASS 1 -#define SECURITY_PWD_CHANGE_SUBCLASS 2 -#define SECURITY_PWD_SELF_RESET_SUBCLASS 3 -#define SECURITY_PWD_RESET_SUBCLASS 4 -#define SECURITY_PWD_UNLOCK_SUBCLASS 5 -#define SECURITY_PWD_MUSTCHANGE_SUBCLASS 6 - -// Event sub classes for Auditing changes in audit. -#define AUDIT_START_AUDIT_SUBCLASS 1 -#define AUDIT_STOP_AUDIT_SUBCLASS 2 -#define AUDIT_C2MODE_CHANGED_ON 3 -#define AUDIT_C2MODE_CHANGED_OFF 4 - -// Event sub classes for security audit of securable management -#define SECURITY_CREATE_SECURABLE_SUBCLASS 1 -#define SECURITY_ALTER_SECURABLE_SUBCLASS 2 -#define SECURITY_DROP_SECURABLE_SUBCLASS 3 -#define SECURITY_BACKUP_SECURABLE_SUBCLASS 4 // used for certificate only -#define SECURITY_DISABLE_SECURABLE_SUBCLASS 5 // used for logins only -#define SECURITY_ENABLE_SECURABLE_SUBCLASS 6 // used for logins only -#define SECURITY_CREDENTIAL_MAP_TO_CREATELOGIN_SUBCLASS 7 -#define SECURITY_TRANSFER_SECURABLE_SUBCLASS 8 -#define SECURITY_NOCREDENTIAL_MAP_TO_LOGIN_SUBCLASS 9 -#define SECURITY_OPEN_SECURABLE_SUBCLASS 10 -#define SECURITY_RESTORE_SECURABLE_SUBCLASS 11 -#define SECURITY_ACCESS_SECURABLE_SUBCLASS 12 -#define SECURITY_CHANGEUSERSLOGIN_UPDATEONE_SUBCLASS 13 -#define SECURITY_CHANGEUSERSLOGIN_AUTOFIX_SUBCLASS 14 -#define SECURITY_AUDIT_SHUTDOWN_ON_FAILURE_SUBCLASS 15 - -// Event sub classese for db operation events -#define SECURITY_DB_CHECKPOINT_SUBCLASS 1 -#define SECURITY_DB_SUBSCRIBEQNOTIF_SUBCLASS 2 -#define SECURITY_DB_AUTHENTICATE_SUBCLASS 3 -#define SECURITY_DB_SHOWPLAN_SUBCLASS 4 -#define SECURITY_DB_CONNECT_SUBCLASS 5 -#define SECURITY_DB_VIEWDBSTATE_SUBCLASS 6 -#define SECURITY_DB_ADMINBULKOPS_SUBCLASS 7 - -// Event sub classese for srv operation events -#define SECURITY_SRV_ADMINBULKOPS_SUBCLASS 1 -#define SECURITY_SRV_ALTERSETTINGS_SUBCLASS 2 -#define SECURITY_SRV_ALTERRESOURCES_SUBCLASS 3 -#define SECURITY_SRV_AUTHENTICATE_SUBCLASS 4 -#define SECURITY_SRV_EXTERNALACCESS_SUBCLASS 5 -#define SECURITY_SRV_ALTERSRVSTATE_SUBCLASS 6 -#define SECURITY_SRV_UNSAFE_SUBCLASS 7 -#define SECURITY_SRV_ALTERCONN_SUBCLASS 8 -#define SECURITY_SRV_ALTERRESGOVERNOR_SUBCLASS 9 -#define SECURITY_SRV_USEANYWORKLOADGRP_SUBCLASS 10 -#define SECURITY_SRV_VIEWSERVERSTATE_SUBCLASS 11 - -// -// End of Security subclasses -// -///////////////////////////////////////////////////////////////////////// - -// Event sub classes for auditing service broker dialog security -#define AUDIT_NO_DIALOG_HDR_SUBCLASS 1 -#define AUDIT_CERT_NOT_FOUND_SUBCLASS 2 -#define AUDIT_INVALID_SIGNATURE_SUBCLASS 3 -#define AUDIT_RUN_AS_TARGET_FAIL_SUBCLASS 4 -#define AUDIT_BAD_DATA_SUBCLASS 5 - -// Event sub classes for auditing service broker login -#define AUDIT_LOGIN_SUCCESS_SUBCLASS 1 -#define AUDIT_PROTOCOL_ERROR_SUBCLASS 2 -#define AUDIT_BAD_MSG_FORMAT_SUBCLASS 3 -#define AUDIT_NEGOTIATE_FAIL_SUBCLASS 4 -#define AUDIT_AUTHENTICATION_FAIL_SUBCLASS 5 -#define AUDIT_AUTHORIZATION_FAIL_SUBCLASS 6 - -// Event sub class definitions for lock acquired class -#define LOCK_NL_SUB_CLASS 0 -#define LOCK_SCH_S_SUB_CLASS 1 -#define LOCK_SCH_M_SUB_CLASS 2 -#define LOCK_IS_SUB_CLASS 3 -#define LOCK_NL_S_SUB_CLASS 4 -#define LOCK_IS_S_SUB_CLASS 5 -#define LOCK_IX_SUB_CLASS 6 -#define LOCK_SIX_SUB_CLASS 7 -#define LOCK_S_SUB_CLASS 8 -#define LOCK_U_SUB_CLASS 9 -#define LOCK_II_NL_SUB_CLASS 10 -#define LOCK_II_X_SUB_CLASS 11 -#define LOCK_IU_X_SUB_CLASS 12 -#define LOCK_ID_NL_SUB_CLASS 13 -#define LOCK_X_SUB_CLASS 14 -#define LOCK_LAST_MODE_SUB_CLASS LOCK_X_SUB_CLASS - -#define XACT_COMMIT_XACT_SUB_CLASS 1 -#define XACT_COMMIT_AND_BEGIN_XACT_SUB_CLASS 2 - -#define XACT_ROLLBACK_XACT_SUB_CLASS 1 -#define XACT_ROLLBACK_AND_BEGIN_XACT_SUB_CLASS 2 - - -// Event sub class definitions for Matrix transaction shipping -#define MATRIX_XACT_SHIPPING_SUBCLASS_SERIALIZE 1 -#define MATRIX_XACT_SHIPPING_SUBCLASS_DESERIALIZE 2 -#define MATRIX_XACT_SHIPPING_SUBCLASS_REPORT 3 -#define MATRIX_XACT_SHIPPING_SUBCLASS_DEREPORT 4 - -// Event sub class definitions for TCM age broadcast -enum -{ - MATRIX_TCM_AGE_CLOSE_BROADCAST = 1, - MATRIX_TCM_AGE_CLOSE_RECEIVE = 2, - - MATRIX_TCM_BRICK_STATUS_SEND = 3, - MATRIX_TCM_BRICK_STATUS_RECEIVE = 4, -}; - - -// Event sub class definitions for Matrix transaction begin/commit/rollback -#define MATRIX_XACT_SUBCLASS_BEGIN 1 -#define MATRIX_XACT_SUBCLASS_COMMIT 2 -#define MATRIX_XACT_SUBCLASS_ABORT 3 - -// Event sub class definitions for Matrix error reporting, eventually have categories -#define MATRIX_BRICK_COMPONENT_ERROR_SUBCLASS 1 - -// Event sub class definitions for Matrix failure monitor heartbeat event class -// -#define MATRIX_CM_HEARTBEAT_BROADCAST_SEND_SUBCLASS 1 -#define MATRIX_CM_HEARTBEAT_BROADCAST_COMPLETE_SUBCLASS 2 -#define MATRIX_CM_HEARTBEAT_BROADCAST_REPLY_SUBCLASS 3 - -// Event subclass definitions for Matrix failure monitor brick failure event -// -#define MATRIX_CM_FAILURE_MONITOR_ADD_FAILURE_SUBCLASS 1 -#define MATRIX_CM_FAILURE_MONITOR_MARK_OFFLINE_SUBCLASS 2 - -// Event sub class definitions for bitmap warnings -#define BITMAP_WARNINGS_DISABLED_SUBCLASS 0 - -// Event sub class definitions for execution warnings (QRY_EXEC_WARNINGS_EVENT_CLASS) -enum QRY_EXEC_WARNING_TYPE -{ - QRY_EXEC_WARNINGS_QRYWAIT_SUBCLASS = 1, - QRY_EXEC_WARNINGS_QRYTIMEOUT_SUBCLASS = 2, -}; - -// Event sub class definitions for LCK_DEADLOCKCHAIN_EVENT_CLASS events -#define LCK_DEADLOCKCHAIN_RESOURCE_TYPE_LOCK 101 -#define LCK_DEADLOCKCHAIN_RESOURCE_TYPE_EXCHANGE 102 -#define LCK_DEADLOCKCHAIN_RESOURCE_TYPE_THREAD 103 -#define LCK_DEADLOCKCHAIN_RESOURCE_TYPE_PAGESUPP 104 - -// Event subclass definitions for BROKER_CONNECTION_EVENT_CLASS -#define BROKER_CONNECTION_CONNECTING_SUBCLASS 1 -#define BROKER_CONNECTION_CONNECTED_SUBCLASS 2 -#define BROKER_CONNECTION_CONNECT_FAILED_SUBCLASS 3 -#define BROKER_CONNECTION_CLOSING_SUBCLASS 4 -#define BROKER_CONNECTION_CLOSED_SUBCLASS 5 -#define BROKER_CONNECTION_ACCEPT_SUBCLASS 6 -#define BROKER_CONNECTION_SEND_ERROR_SUBCLASS 7 -#define BROKER_CONNECTION_RECEIVE_ERROR_SUBCLASS 8 - -// Event subclass definitions for BROKER_TRANSMISSION_EVENT_CLASS -#define BROKER_TRANSMISSION_EXCEPTION_SUBCLASS 1 - -// Is system process? -#define SYSTEM_PROCESS 1 - -// Event subclass definitions for EXCHANGE_SPILL_EVENT_CLASS -#define EXCHANGE_SPILL_BEGIN_SUBCLASS 1 -#define EXCHANGE_SPILL_END_SUBCLASS 2 - -// Event subclass definitions for BACKUP_TAPE_MOUNT_EVENT_CLASS -#define BACKUP_TAPE_MOUNT_REQUEST_SUBCLASS 1 // mount for tape drive is pending operator intervention -#define BACKUP_TAPE_MOUNT_COMPLETE_SUBCLASS 2 // mount for tape drive was completed successfully -#define BACKUP_TAPE_MOUNT_CANCEL_SUBCLASS 3 // mount for tape drive was cancelled - - -// Event sub classes for auditing fulltext -#define AUDIT_FDHOST_CONNECT_SUCCESS_SUBCLASS 1 -#define AUDIT_FDHOST_CONNECT_ERROR_SUBCLASS 2 -#define AUDIT_FDLAUNCHER_CONNECT_SUCCESS_SUBCLASS 3 -#define AUDIT_FDLAUNCHER_CONNECT_ERROR_SUBCLASS 4 -#define AUDIT_ISM_CORRUPT_SUBCLASS 5 -#define AUDIT_PIPE_MESSAGE_CORRUPT_SUBCLASS 6 - -// Subclass for perf stat event class -enum STMT_PERFSTAT_SUBCLASSES -{ - STMT_PERFSTAT_SQL_SUBCLASS = 0, - STMT_PERFSTAT_SPPLAN_SUBCLASS = 1, - STMT_PERFSTAT_BATCHPLAN_SUBCLASS = 2, - STMT_PERFSTAT_STAT_SUBCLASS = 3, - STMT_PERFSTAT_PROC_STAT_SUBCLASS = 4, - STMT_PERFSTAT_TRIG_STAT_SUBCLASS = 5 -}; - -// Event subclass definition for Audit Login / Audit Logout -#define NONPOOLED_CONNECTION_SUBCLASS 1 -#define POOLED_CONNECTION_SUBCLASS 2 - -// Connection type for Audit Login / Audit Logout -#define CONNECTION_NON_DAC 1 -#define CONNECTION_DAC 2 - -// Event subclass for MatrixDB Clone Refresh -#define CLONE_REFRESH_START_SUBCLASS 1 -#define CLONE_REFRESH_TRANSITION_START_SUBCLASS 2 -#define CLONE_REFRESH_TRANSITION_END_SUBCLASS 3 -#define CLONE_REFRESH_SCAN_START_SUBCLASS 4 -#define CLONE_REFRESH_SCAN_END_SUBCLASS 5 -#define CLONE_REFRESH_BATCH_START_SUBCLASS 6 -#define CLONE_REFRESH_DELETED_STALE_ROWS_SUBCLASS 7 -#define CLONE_REFRESH_BATCH_END_SUBCLASS 8 -#define CLONE_REFRESH_END_SUBCLASS 9 -#define CLONE_REFRESH_ERROR_SUBCLASS 10 - -// Event sub class for clone transition -enum CloneTransitionEventSubClass -{ - CLONE_TRANSITION_INSTALL = 1, - CLONE_TRANSITION_UNINSTALL = 2, - CLONE_TRANSITION_LOCK = 3, - CLONE_TRANSITION_COMMIT = 4, - CLONE_TRANSITION_ACTIVATE = 5, - CLONE_TRANSITION_DEACTIVATE = 6, -}; - -// =============== Object Types Start Here ======================= -// These object types should not be used for audit -// instead use enum EObjType defined in objinfo.h -typedef enum -{ - INDEX_OBJECT_TYPE = 1, - DB_OBJECT_TYPE = 2, - AP_OBJECT_TYPE = 3, - CHECK_CNST_OBJECT_TYPE = 4, - DEFAULT_CNST_OBJECT_TYPE = 5, - FORKEY_CNST_OBJECT_TYPE = 6, - PRIKEY_CNST_OBJECT_TYPE = 7, - SP_OBJECT_TYPE = 8, - FN_OBJECT_TYPE = 9, - RULE_OBJECT_TYPE = 10, - REPLPROC_OBJECT_TYPE = 11, - SYS_TAB_OBJECT_TYPE = 12, - TRIG_OBJECT_TYPE = 13, - INLINE_FN_OBJECT_TYPE = 14, - TAB_FN_OBJECT_TYPE = 15, - UNIQUE_CNST_OBJECT_TYPE = 16, - USER_TAB_OBJECT_TYPE = 17, - VIEW_OBJECT_TYPE = 18, - XPROC_OBJECT_TYPE = 19, - ADHOC_OBJECT_TYPE = 20, - PREPARED_OBJECT_TYPE = 21, - STATISTICS_OBJECT_TYPE = 22, - // End of Shiloh compatible types. - - // Add new type enumerations only if there is no definitions in the server - ASSEMBLY_OBJECT_TYPE = 23, - UDT_OBJECT_TYPE = 24, - SCHEMA_OBJECT_TYPE = 25, - XML_SCHEMA_OBJECT_TYPE = 26, - PARTITION_FUNCTION_OBJECT_TYPE = 27, - PARTITION_SCHEME_OBJECT_TYPE = 28, - SERVICE_OBJECT_TYPE = 29, - MSGTYPE_OBJECT_TYPE = 30, - CONTRACT_OBJECT_TYPE = 31, - ROUTE_OBJECT_TYPE = 32, - BINDING_OBJECT_TYPE = 33, -} TRACE_OBJTYPE; - -// =================================================================================== -// Columns -// =================================================================================== -typedef enum -{ - //$$TRCEVT_COLUMN_ENUM_START Do not remove this comment. - TRACE_COLUMN_TEXT = 1, - TRACE_COLUMN_BINARYDATA = 2, - TRACE_COLUMN_DBID = 3, - TRACE_COLUMN_XACTID = 4, - TRACE_COLUMN_LINENO = 5, - TRACE_COLUMN_NTUSERNAME = 6, - TRACE_COLUMN_NTDOMAIN = 7, - TRACE_COLUMN_HOST = 8, - TRACE_COLUMN_CPID = 9, - TRACE_COLUMN_APPNAME = 10, - TRACE_COLUMN_LOGINNAME = 11, - TRACE_COLUMN_SPID = 12, - TRACE_COLUMN_DURATION = 13, - TRACE_COLUMN_STARTTIME = 14, - TRACE_COLUMN_ENDTIME = 15, - TRACE_COLUMN_READS = 16, - TRACE_COLUMN_WRITES = 17, - TRACE_COLUMN_CPU = 18, - TRACE_COLUMN_PERMISSIONS = 19, - TRACE_COLUMN_SEVERITY = 20, - TRACE_COLUMN_SUBCLASS = 21, - TRACE_COLUMN_OBJID = 22, - TRACE_COLUMN_SUCCESS = 23, - TRACE_COLUMN_INDID = 24, - TRACE_COLUMN_INTDATA = 25, - TRACE_COLUMN_SERVER = 26, - TRACE_COLUMN_CLASS = 27, - TRACE_COLUMN_OBJTYPE = 28, - TRACE_COLUMN_NESTLEVEL = 29, - TRACE_COLUMN_STATE = 30, - TRACE_COLUMN_ERROR = 31, - TRACE_COLUMN_MODE = 32, - TRACE_COLUMN_HANDLE = 33, - TRACE_COLUMN_OBJNAME = 34, - TRACE_COLUMN_DBNAME = 35, - TRACE_COLUMN_FILENAME = 36, - TRACE_COLUMN_OWNERNAME = 37, - TRACE_COLUMN_ROLENAME = 38, - TRACE_COLUMN_TARGET_USERNAME = 39, - TRACE_COLUMN_DBUSER = 40, - TRACE_COLUMN_LOGINSID = 41, - TRACE_COLUMN_TARGET_LOGINNAME = 42, - TRACE_COLUMN_TARGET_LOGINSID = 43, - TRACE_COLUMN_COLPERMS = 44, - - TOTAL_COLUMNS_V8, // Shiloh total columns - // Start of New Yukon trace columns - // OLEDB - TRACE_COLUMN_LINKEDSERVERNAME = 45, - TRACE_COLUMN_PROVIDERNAME = 46, - TRACE_COLUMN_METHODNAME = 47, - - TRACE_COLUMN_ROWCOUNTS = 48, - TRACE_COLUMN_BATCHID = 49, - TRACE_COLUMN_XACTSEQNO = 50, - - TRACE_COLUMN_EVENTSEQ = 51, - - TRACE_COLUMN_BIGINT1 = 52, - TRACE_COLUMN_BIGINT2 = 53, - TRACE_COLUMN_GUID = 54, - - TRACE_COLUMN_INTDATA2 = 55, - TRACE_COLUMN_OBJID2 = 56, - TRACE_COLUMN_TYPE = 57, - TRACE_COLUMN_OWNERID = 58, - TRACE_COLUMN_PARENTNAME = 59, - TRACE_COLUMN_ISSYSTEM = 60, - - TRACE_COLUMN_OFFSET = 61, - TRACE_COLUMN_SOURCE_DBID = 62, - - TRACE_COLUMN_SQLHANDLE = 63, - TRACE_COLUMN_SESSLOGINNAME = 64, - TRACE_COLUMN_PLANHANDLE = 65, - - TRACE_COLUMN_GROUPID = 66, - - //$$TRCEVT_COLUMN_ENUM_END Do not remove this comment. - // DEVNOTE!!!!!! - // ALL NEW RETAIL COLUMNS MUST BE ADDED ABOVE THIS COMMENT!!!!! - // You need to follow the following format because this file is processed by perl script!!!! - // - // TRACE_COLUMN_XXX = dd, - // - TRACE_TOTAL_RETAIL_COLUMNS, - TRACE_LAST_RETAIL_COLUMN = TRACE_TOTAL_RETAIL_COLUMNS - 1, // dummy enum. do not remove. - - TRACE_COLUMN_CONTEXT_INFO = 67, - TRACE_COLUMN_GUID2 = 68, - TRACE_COLUMN_PARTITION_LOW_KEY = 69, - TRACE_COLUMN_PARTITION_TABLE_GROUP = 70, - TRACE_COLUMN_PHYSICAL_DBNAME = 71, - TRACE_COLUMN_PARTITION_APP_NAME = 72, - - // ALL COLUMNS MUST BE ADDED BEFORE TOTAL_COLUMNS!! - TOTAL_COLUMNS -} TRACE_DATA_COLUMNS; - -// Need to expand column map if we reach the following limit. -C_ASSERT(TOTAL_COLUMNS < 256); - -// Boolean representation of column bitmap. -// Make sure member defintions matches TRACE_DATA_COLUMNS enumeration!!! -class ColBitmap; - -#pragma pack(4) // Need to match DWORD array in ColBitmap -class ColBoolmap -{ -public: - FORCEINLINE ColBitmap* PBitmap() const { return reinterpret_cast(const_cast(this)); } - - BOOL bTRACE_INVALID:1; - BOOL bTRACE_COLUMN_TEXT:1; - BOOL bTRACE_COLUMN_BINARYDATA:1; - BOOL bTRACE_COLUMN_DBID:1; - BOOL bTRACE_COLUMN_XACTID:1; - BOOL bTRACE_COLUMN_LINENO:1; - BOOL bTRACE_COLUMN_NTUSERNAME:1; - BOOL bTRACE_COLUMN_NTDOMAIN:1; - BOOL bTRACE_COLUMN_HOST:1; - BOOL bTRACE_COLUMN_CPID:1; - BOOL bTRACE_COLUMN_APPNAME:1; - BOOL bTRACE_COLUMN_LOGINNAME:1; - BOOL bTRACE_COLUMN_SPID:1; - BOOL bTRACE_COLUMN_DURATION:1; - BOOL bTRACE_COLUMN_STARTTIME:1; - BOOL bTRACE_COLUMN_ENDTIME:1; - BOOL bTRACE_COLUMN_READS:1; - BOOL bTRACE_COLUMN_WRITES:1; - BOOL bTRACE_COLUMN_CPU:1; - BOOL bTRACE_COLUMN_PERMISSIONS:1; - BOOL bTRACE_COLUMN_SEVERITY:1; - BOOL bTRACE_COLUMN_SUBCLASS:1; - BOOL bTRACE_COLUMN_OBJID:1; - BOOL bTRACE_COLUMN_SUCCESS:1; - BOOL bTRACE_COLUMN_INDID:1; - BOOL bTRACE_COLUMN_INTDATA:1; - BOOL bTRACE_COLUMN_SERVER:1; - BOOL bTRACE_COLUMN_CLASS:1; - BOOL bTRACE_COLUMN_OBJTYPE:1; - BOOL bTRACE_COLUMN_NESTLEVEL:1; - BOOL bTRACE_COLUMN_STATE:1; - BOOL bTRACE_COLUMN_ERROR:1; - BOOL bTRACE_COLUMN_MODE:1; - BOOL bTRACE_COLUMN_HANDLE:1; - BOOL bTRACE_COLUMN_OBJNAME:1; - BOOL bTRACE_COLUMN_DBNAME:1; - BOOL bTRACE_COLUMN_FILENAME:1; - BOOL bTRACE_COLUMN_OWNERNAME:1; - BOOL bTRACE_COLUMN_ROLENAME:1; - BOOL bTRACE_COLUMN_TARGET_USERNAME:1; - BOOL bTRACE_COLUMN_DBUSER:1; - BOOL bTRACE_COLUMN_LOGINSID:1; - BOOL bTRACE_COLUMN_TARGET_LOGINNAME:1; - BOOL bTRACE_COLUMN_TARGET_LOGINSID:1; - BOOL bTRACE_COLUMN_COLPERMS:1; - BOOL bTRACE_COLUMN_LINKEDSERVERNAME:1; - BOOL bTRACE_COLUMN_PROVIDERNAME:1; - BOOL bTRACE_COLUMN_METHODNAME:1; - BOOL bTRACE_COLUMN_ROWCOUNTS:1; - BOOL bTRACE_COLUMN_BATCHID:1; - BOOL bTRACE_COLUMN_XACTSEQNO:1; - BOOL bTRACE_COLUMN_EVENTSEQ:1; - BOOL bTRACE_COLUMN_BIGINT1:1; - BOOL bTRACE_COLUMN_BIGINT2:1; - BOOL bTRACE_COLUMN_GUID:1; - BOOL bTRACE_COLUMN_INTDATA2:1; - BOOL bTRACE_COLUMN_OBJID2:1; - BOOL bTRACE_COLUMN_TYPE:1; - BOOL bTRACE_COLUMN_OWNERID:1; - BOOL bTRACE_COLUMN_PARENTNAME:1; - BOOL bTRACE_COLUMN_ISSYSTEM:1; - BOOL bTRACE_COLUMN_OFFSET:1; - BOOL bTRACE_COLUMN_SOURCE_DBID:1; - BOOL bTRACE_COLUMN_SQLHANDLE:1; - BOOL bTRACE_COLUMN_SESSLOGINNAME:1; - BOOL bTRACE_COLUMN_PLANHANDLE:1; - BOOL bTRACE_COLUMN_GROUPID:1; - BOOL bTRACE_COLUMN_CONTEXT_INFO:1; - BOOL bTRACE_COLUMN_GUID2:1; - BOOL bTRACE_COLUMN_PARTITION_LOW_KEY:1; - BOOL bTRACE_COLUMN_PARTITION_TABLE_GROUP:1; - BOOL bTRACE_COLUMN_PHYSICAL_DBNAME:1; - BOOL bTRACE_COLUMN_PARTITION_APP_NAME:1; -}; -#pragma pack() - -// Special columns will begin at 0xfffe which is the highest valid USHORT (colid) and -// work down. All new special columns should be added to the bottem of this list. -// DEVNOTE: These special columns are placed at the top of the USHORT range so that we can add -// add new columns to our heart's delight, and we will not need to worry about -// problems until we approach 64k columns. -typedef enum -{ - TRACE_VERSION = 0xfffe, - TRACED_OPTIONS = 0xfffd, - TRACED_EVENTS = 0xfffc, - TRACED_FILTERS = 0xfffb, - TRACE_START = 0xfffa, - TRACE_STOP = 0xfff9, - TRACE_ERROR = 0xfff8, - TRACE_SKIPPED_RECORDS = 0xfff7, - TRACE_BEGIN_RECORD = 0xfff6, - TRACE_TEXT_FILTERED = 0xfff5, - TRACE_REPEATED_BASE = 0xfff4, - TRACE_REPEATED_DATA = 0xfff3, - TRACE_FLUSH = 0xfff2, -} TRACE_SPECIAL_COLUMNS; - -#define IS_SPECIAL_COLUMN(icol) (((icol) & 0xFFF0) == 0xFFF0) - -typedef struct tagTraceCategory -{ - WCHAR* pwszCategory_Name; - SHORT sCategory_Id; - BYTE bCategory_Type; - bool fDisabled; -} TRACE_CATEGORY; - -// -// Event Categories -// -typedef enum -{ - //$$EVENT_CATEGORY_START Do not remove this comment. - TRCAT_INVALID = 0, - TRCAT_CURSORS = 1, - TRCAT_DATABASE = 2, - TRCAT_ERRORSANDWARNINGS = 3, - TRCAT_LOCKS = 4, - TRCAT_OBJECTS = 5, - TRCAT_PERFORMANCE = 6, - TRCAT_SCANS = 7, - TRCAT_SECURITYAUDIT = 8, - TRCAT_SERVER = 9, - TRCAT_SESSIONS = 10, - TRCAT_STOREDPROCEDURES = 11, - TRCAT_TRANSACTIONS = 12, - TRCAT_TSQL = 13, - TRCAT_USERCONFIGURABLE = 14, - TRCAT_OLEDB = 15, - TRCAT_BROKER = 16, - TRCAT_FULLTEXT = 17, - TRCAT_DEPRECATION = 18, - TRCAT_PROGRESS = 19, - TRCAT_CLR = 20, - TRCAT_QNOTIF = 21, - TRCAT_PSS_DIAG = 22, - //$$EVENT_CATEGORY_END Do not remove this comment. - // DEVNOTE!!!!!! - // ALL NEW RETAIL CATEGORIES MUST BE ADDED ABOVE THIS COMMENT!!!!! - // You need to follow the following format because this file is processed by perl script!!!! - // - // TRCAT_XXX = dd, - // - - TRC_NEXT_RETAIL, // Dummy enum. Do not remove. - TRC_TOTAL_RETAIL = TRC_NEXT_RETAIL -1, // Total number of VALID categories (beginning at 1) - - // DEVNOTE!!!!!! - // ALL NEW TEMP (NON GOLDEN_BITS) CATEGORIES MUST BE ADDED BELLOW THIS COMMENT!!!!! - // You should not assign values explicitly. The category IDs will change - // after more categories are added. Please use the following format: - // - // TRCAT_XXX, - // - TRCAT_SEREPL, - TRCAT_ASYNCTRANSPORT, - TRCAT_CLOUDMGMT, - TRCAT_CLOUD_PM, - -#ifndef GOLDEN_BITS - TRCAT_MATRIXDB, - TRCAT_TEMP, -#endif - - // DEVNOTE!!!!!! - // ALL NEW DEBUG CATEGORIES MUST BE ADDED BELLOW THIS COMMENT!!!!! - // You should not assign values explicitly. The category IDs will change - // after more categories are added. Please use the following format: - // - // TRCAT_XXX, - // - -#ifdef DEBUG - TRCAT_DBG_ONLY, -#endif DEBUG - - TRC_NEXT, // Dummy enum. Do not remove. - TRC_TOTAL = TRC_NEXT-1, // Total number of VALID categories (beginning at 1) - - // Special trace category, used for events disabled in certian build flavors. - // - TRCAT_DISABLED = TRC_NEXT, -} TRACE_CATEGORY_ID; - -// Non-GOLDEN_BITS trace categories having events with IDs lower than -// TOTAL_RETAIL_EVENTS must be listed here as equivalent to TRCAT_DISABLED. -// Otherwise GOLDEN_BITS build will break. -// -#ifdef GOLDEN_BITS -#define TRCAT_MATRIXDB TRCAT_DISABLED -#define TRCAT_TEMP TRCAT_DISABLED -#endif - -// Debug trace categories having events with IDs lower than -// TOTAL_RETAIL_EVENTS must be listed here as equivalent to TRC_DISABLED. -// Otherwise RETAIL build will break. -// -#ifndef DEBUG -#define TRCAT_DBG_ONLY TRCAT_DISABLED -#endif - - -// TRACE_BEGIN_RECORD -// Shiloh -// USHORT event id -// USHORT logical columns - -// Yukon -// USHORT event id -// ULONG record length - - -//NOTE: if DataType is TRACE_BYTES, bFilterable has to be false -typedef struct trace_column_info -{ - USHORT id; - ETraceDataTypes eDataType; - BYTE bFilterable; - BYTE bRepeatable; - BYTE bRepeatedBase; - WCHAR* pwszColumnName; - bool fPreFilterable:1; - bool fMandatory:1; - bool fDisabled:1; -} TRACE_COLUMN_INFO; - -// -#define TRACE_REPEATABLE_COLUMNS 9 // Increase this if you add repeatable data! - -enum eTraceHeaderOptions - { - eTraceFileRolledOver = 0x1, - eTraceFirstFile = 0x2, - }; - -#pragma pack(1) -// Header of a file. -// Shiloh Header -typedef struct V8TrcFileHeader -{ - long lVersion; - ULONG lHdrSize; - ULONG lOptions; - USHORT ColumnOrder[TOTAL_COLUMNS_V8]; - USHORT ColumnAggregation[TOTAL_COLUMNS_V8]; -} V8TrcFileHeader; - -// Yukon header -typedef struct TrcFileHeader -{ - USHORT usUnicodeTag; // 0xFEFF (2) - USHORT usHeaderSize; // sizeof(struct TrcFIleHeader) (4) - USHORT usTraceVersion; // Trace file format version (6) - WCHAR wszProviderName[128]; // L"Microsoft SQL Server" (262) - WCHAR wszDefinitionType[64]; // Unused (390) - BYTE bMajorVersion; // (391) - BYTE bMinorVersion; // (392) - USHORT usBuildNumber; // (394) - ULONG u_ulHeaderOptions; // UNALLIGNED (398) - WCHAR wszServer[128]; // server name (654) - USHORT usRepeatBase; // spid (656) - - // We use MEMCOPY to prevent Win64 data misalignment fault. - inline void SetHeaderOptions(__in ULONG ulHeaderOption) - { - MEMCOPY(&ulHeaderOption, &u_ulHeaderOptions, sizeof(ULONG)); - } - - inline ULONG UlHeaderOptions() const - { - ULONG ulRet; - MEMCOPY(&u_ulHeaderOptions, &ulRet, sizeof(ULONG)); - return ulRet; - } -} TrcFileHeader; - -// Begin Record Data -typedef struct TrcBeginRecordData -{ - USHORT usEventId; - LONG u_lRecordLength; // unaligned!! - - // We use MEMCOPY to prevent Win64 data misalignment fault. - inline LONG LRecordLength() const - { - LONG lRet; - MEMCOPY(&u_lRecordLength, &lRet, sizeof(LONG)); - return lRet; - } - - inline void SetRecordLength(__in LONG lRecordLength) - { - MEMCOPY(&lRecordLength, &u_lRecordLength, sizeof(LONG)); - } - -} TrcBeginRecordData; - -typedef struct TracedOptionsData -{ - BYTE betpOptions; - ULONG u_ulOptions; // unaligned - BYTE betpMaxSize; - INT64 u_i64MaxSize; // unaligned - BYTE betpStopTime; - SYSTEMTIME stStopTime; - - // We use MEMCOPY to prevent Win64 data misalignment fault. - inline void SetOptions(__in ULONG ulOptions) - { - MEMCOPY(&ulOptions, &u_ulOptions, sizeof(ULONG)); - } - - inline void SetMaxSize(__in INT64 i64MaxSize) - { - MEMCOPY(&i64MaxSize, &u_i64MaxSize, sizeof(INT64)); - } - - inline void SetStopTime(__in SYSTEMTIME* pst) - { - MEMCOPY(pst, &stStopTime, sizeof(SYSTEMTIME)); - } - -} TracedOptionsData; -#pragma pack() - -#define UNICODETAG 0xFEFF -#define TRACE_FORMAT_VERSION 1 - -// Enumeration of trace event flags which describe notification attributes. Values have to be or'able. - -enum TRCEventFlags -{ - TRCEF_OFF_EVT = 0x0000, // Not supported for Event Notifications - TRCEF_ON_EVT = 0x0001, // Supported for Event Notifications - TRCEF_SEC_EVT = 0x0002, // Event requiring "Monitor Security Events" permission - TRCEF_MGT_EVT = 0x0004, // Event requiring "Monitor Management Events" permission - TRCEF_USR_EVT = 0x0008, // Event requiring "Monitor User Events" permission - TRCEF_TXT_XML = 0x0010, // TextData is already in XML format. -}; - -// Map event classes with names -typedef struct tagTrace_event_info -{ - ColBoolmap colmap; - USHORT id; - SHORT sCategory_Id; - WCHAR* pwszEventName; - USHORT wEvNotifFlags; // notification and XML flags - bool fDisabled; -} TRACE_EVENT_INFO; - -// Max trace column size is 1GB -const ULONG g_cbMaxTraceColumnSize = 0x40000000; -// Max size of a TVPs trace binary format -const ULONG x_cbMaxTVPSize = g_cbMaxTraceColumnSize/4; - -extern TRACE_EVENT_INFO g_rgTraceEventInfo[]; - -#endif // TRCCOMN_H_ - - - diff --git a/SmoBuild/DdlEvents/trcdef.cpp b/SmoBuild/DdlEvents/trcdef.cpp deleted file mode 100644 index 1e6e2304..00000000 --- a/SmoBuild/DdlEvents/trcdef.cpp +++ /dev/null @@ -1,1562 +0,0 @@ -//**************************************************************************** -// Copyright (c) Microsoft Corporation. -// -// @File: trcdef.cpp -// @Owner: ivanpe, fvoznika, jhalmans -// @Test: pedrou -// -// Purpose: This file contains all trace event definitions. It's main purpose is -// to be included in trcmeta.cpp. Several perl scripts are parsing -// this file in order to get to the trace event type definitions. -// -// @EndHeader@ -//**************************************************************************** - -//$$$ START OF TRACE SCHEMA TABLES ******************************************************* - -// Event category map -TRACE_CATEGORY g_TraceCategoryMap[] = -{ - //$$CATEGORY_MAP_START Do not remove this comment. - {L"Cursors", TRCAT_CURSORS, TRCAT_TYPE_NORMAL}, - {L"Database", TRCAT_DATABASE, TRCAT_TYPE_NORMAL}, - {L"Errors and Warnings", TRCAT_ERRORSANDWARNINGS, TRCAT_TYPE_ERROR}, - {L"Locks", TRCAT_LOCKS, TRCAT_TYPE_NORMAL}, - {L"Objects", TRCAT_OBJECTS, TRCAT_TYPE_NORMAL}, - {L"Performance", TRCAT_PERFORMANCE, TRCAT_TYPE_NORMAL}, - {L"Scans", TRCAT_SCANS, TRCAT_TYPE_NORMAL}, - {L"Security Audit", TRCAT_SECURITYAUDIT, TRCAT_TYPE_NORMAL}, - {L"Server", TRCAT_SERVER, TRCAT_TYPE_NORMAL}, - {L"Sessions", TRCAT_SESSIONS, TRCAT_TYPE_CONNECTION}, - {L"Stored Procedures", TRCAT_STOREDPROCEDURES, TRCAT_TYPE_NORMAL}, - {L"Transactions", TRCAT_TRANSACTIONS, TRCAT_TYPE_NORMAL}, - {L"TSQL", TRCAT_TSQL, TRCAT_TYPE_NORMAL}, - {L"User configurable", TRCAT_USERCONFIGURABLE, TRCAT_TYPE_NORMAL}, - {L"OLEDB", TRCAT_OLEDB, TRCAT_TYPE_NORMAL}, - {L"Broker", TRCAT_BROKER, TRCAT_TYPE_NORMAL}, - {L"Full text", TRCAT_FULLTEXT, TRCAT_TYPE_NORMAL}, - {L"Deprecation", TRCAT_DEPRECATION, TRCAT_TYPE_NORMAL}, - {L"Progress Report", TRCAT_PROGRESS, TRCAT_TYPE_NORMAL}, - {L"CLR", TRCAT_CLR, TRCAT_TYPE_NORMAL}, - {L"Query Notifications", TRCAT_QNOTIF, TRCAT_TYPE_NORMAL}, - {L"Server internal diagnostics", TRCAT_PSS_DIAG, TRCAT_TYPE_NORMAL}, - //$$CATEGORY_MAP_END Do not remove this comment. - {L"CloudDB Replication", TRCAT_SEREPL, TRCAT_TYPE_NORMAL}, - {L"CloudDB Async Transport", TRCAT_ASYNCTRANSPORT, TRCAT_TYPE_NORMAL}, - {L"CloudDB Management", TRCAT_CLOUDMGMT, TRCAT_TYPE_NORMAL}, - {L"CloudDB Local Partitions", TRCAT_CLOUD_PM, TRCAT_TYPE_NORMAL}, - -#ifndef GOLDEN_BITS - // TEMP (non GOLDEN_BITS) categories. All retail categories should go above this line - {L"Scale Out Cluster", TRCAT_MATRIXDB, TRCAT_TYPE_NORMAL}, - {L"Temporary", TRCAT_TEMP, TRCAT_TYPE_NORMAL}, -#endif - -#ifdef DEBUG - // Debug only categories. - {L"Debug Only", TRCAT_DBG_ONLY, TRCAT_TYPE_NORMAL}, -#endif DEBUG -}; - - -// Mode column subclass names are applied to these events. -const USHORT x_rgusTraceLockEventsForModeInt2TypeAndOwnerColumns[] = -{ - LCK_DEADLOCKCHAIN_EVENT_CLASS, - LCK_RELEASE_EVENT_CLASS, - LCK_ACQUIRE_EVENT_CLASS, - LCK_DEADLOCK_EVENT_CLASS, - LCK_CANCEL_EVENT_CLASS, - LCK_TIMEOUT_EVENT_CLASS, - LCK_ESCALATION_EVENT_CLASS, - LCK_TIMEOUT_NP_EVENT_CLASS, - BLOCKED_PROCESS_REPORT_EVENT_CLASS, - 0, // keep this as the last entry. -}; - -// ObjType column subclass names are applicable to these events. -// If you call CTraceData::SetObjType() with standard object types such as OTYP_APP, -// you need to put your event id here. -extern const USHORT x_rgusEventsWithObjType[] = -{ - CP_RECOMPILE_EVENT_CLASS, - SP_START_EVENT_CLASS, - SP_END_EVENT_CLASS, - SP_STMT_START_EVENT_CLASS, - SP_STMT_END_EVENT_CLASS, - OBJECT_CREATE_EVENT_CLASS, - OBJECT_DELETE_EVENT_CLASS, - OBJECT_ALTER_EVENT_CLASS, - SHOWPLAN_EVENT_CLASS, - SHOWPLAN_TEXT_EVENT_CLASS, - SHOWPLAN_ALL_EVENT_CLASS, - SHOWPLAN_STATISTICS_EVENT_CLASS, - SHOWPLAN_XML_EVENT_CLASS, - SHOWPLAN_XML_STATISTICS_EVENT_CLASS, - STMT_PERFSTAT_EVENT_CLASS, - SHOWPLAN_XML_COMPILE_EVENT_CLASS, - SHOWPLAN_ALL_COMPILE_EVENT_CLASS, - SECURITY_GDR_DB_SCOPE_EVENT_CLASS, - SECURITY_GDR_SCH_OBJECT_EVENT_CLASS, - AUDIT_ADDLOGIN_EVENT_CLASS, - AUDIT_LOGIN_GDR_EVENT_CLASS, - SECURITY_SRV_LOGIN_PROP_EVENT_CLASS, - SECURITY_SRV_LOGIN_PWD_EVENT_CLASS, - SECURITY_SRV_ROLE_ADDPRIN_EVENT_CLASS, - AUDIT_ADD_DBUSER_EVENT_CLASS, - SECURITY_DB_ROLE_ADDPRIN_EVENT_CLASS, - AUDIT_ADDROLE_EVENT_CLASS, - SECURITY_DB_APPROLE_PWD_EVENT_CLASS, - AUDIT_STMT_PERM_EVENT_CLASS, - SECURITY_SCH_OBJECT_ACCESS_EVENT_CLASS, - AUDIT_DMPLD_EVENT_CLASS, - AUDIT_OBJECT_DERIVED_PERM_EVENT_CLASS, - SECURITY_DB_MANAGE_EVENT_CLASS, - SECURITY_DB_OBJECT_MANAGE_EVENT_CLASS, - SECURITY_DB_PRINCIPAL_MANAGE_EVENT_CLASS, - SECURITY_SCH_OBJECT_MANAGE_EVENT_CLASS, - SECURITY_SRV_PRINCIPAL_IMPERSONATE_EVENT_CLASS, - SECURITY_DB_PRINCIPAL_IMPERSONATE_EVENT_CLASS, - SECURITY_SRV_OBJECT_TAKEOWNERSHIP_EVENT_CLASS, - SECURITY_DB_OBJECT_TAKEOWNERSHIP_EVENT_CLASS, - SECURITY_DB_TAKEOWNERSHIP_EVENT_CLASS, - SECURITY_SCH_OBJECT_TAKEOWNERSHIP_EVENT_CLASS, - STMT_RECOMPILE_EVENT_CLASS, - SECURITY_GDR_SRV_SCOPE_EVENT_CLASS, - SECURITY_GDR_SRV_OBJECT_EVENT_CLASS, - SECURITY_GDR_DB_OBJECT_EVENT_CLASS, - SECURITY_SRV_OPERATION_EVENT_CLASS, - SECURITY_SRV_ALTERTRACE_EVENT_CLASS, - SECURITY_SRV_OBJECT_MANAGE_EVENT_CLASS, - SECURITY_SRV_PRINCIPAL_MANAGE_EVENT_CLASS, - SECURITY_DB_OPERATION_EVENT_CLASS, - SECURITY_DB_OBJECT_ACCESS_EVENT_CLASS, - CP_MISS_EVENT_CLASS, - CP_INSERT_EVENT_CLASS, - CP_REMOVE_EVENT_CLASS, - CP_HIT_EVENT_CLASS, - PRECONNECT_PRE_EVENT_CLASS, - PRECONNECT_POST_EVENT_CLASS, - - 0, // keep this as the last entry. -}; - -// The following events are using "Commit and Begin" sub events -const USHORT x_rgusEventsCommitAndBeginTranType[] = -{ - PRE_XACTEVENT_COMMIT_TRAN_EVENT_CLASS, // 185 - POST_XACTEVENT_COMMIT_TRAN_EVENT_CLASS,// 186 - 0, // keep this as the last entry. -}; - -// The following events are using "Rollback and Begin" sub events -const USHORT x_rgusEventsRollbackAndBeginTranType[] = -{ - PRE_XACTEVENT_ROLLBACK_TRAN_EVENT_CLASS, // 185 - POST_XACTEVENT_ROLLBACK_TRAN_EVENT_CLASS,// 186 - 0, // keep this as the last entry. -}; - -// Error column for PostLang and PostRPC event -const USHORT x_rgusPostExecError[] = -{ - POST_LANG_EVENT_CLASS, - POST_RPC_EVENT_CLASS, - 0, -}; - -// Management of securable entities -// corresponds to eMultiEventSecObjManagement -// -const USHORT x_rgusSecObjManagement[] = -{ - AUDIT_OBJECT_DERIVED_PERM_EVENT_CLASS, - SECURITY_SRV_OBJECT_MANAGE_EVENT_CLASS, - SECURITY_DB_MANAGE_EVENT_CLASS, - SECURITY_DB_OBJECT_MANAGE_EVENT_CLASS, - SECURITY_SCH_OBJECT_MANAGE_EVENT_CLASS, - SECURITY_SRV_PRINCIPAL_MANAGE_EVENT_CLASS, - SECURITY_DB_PRINCIPAL_MANAGE_EVENT_CLASS, - 0, -}; - -// Management of principals -// corresponds to eMultiEventSecPrinManagement -// -const USHORT x_rgusSecPrinManagement[] = -{ - AUDIT_ADDROLE_EVENT_CLASS, - AUDIT_ADD_DBUSER_EVENT_CLASS, - AUDIT_ADDLOGIN_EVENT_CLASS, - SECURITY_SRV_ROLE_ADDPRIN_EVENT_CLASS, - SECURITY_DB_ROLE_ADDPRIN_EVENT_CLASS, - 0, -}; - -// GDR events -// corresponds to eMultiEventGDR -// -const USHORT x_rgusGDR[] = -{ - SECURITY_GDR_SCH_OBJECT_EVENT_CLASS, - SECURITY_GDR_DB_SCOPE_EVENT_CLASS, - AUDIT_LOGIN_GDR_EVENT_CLASS, - SECURITY_GDR_SRV_SCOPE_EVENT_CLASS, - SECURITY_GDR_SRV_OBJECT_EVENT_CLASS, - SECURITY_GDR_DB_OBJECT_EVENT_CLASS, - 0, -}; - -// DDL events -const USHORT x_rgusDDL[] = -{ - OBJECT_CREATE_EVENT_CLASS, - OBJECT_ALTER_EVENT_CLASS, - OBJECT_DELETE_EVENT_CLASS, - 0 -}; - -enum -{ - eMultiEventLockColumns = MULTIEVENT_SUBCLASSVALUES, - eMultiEventObjType, - eMultiEventPostExecError, - eMultiEventSecObjManagement, - eMultiEventSecPrinManagement, - eMultiEventGDR, - eMultiEventCommitAndBeginTran, - eMultiEventRollbackAndBeginTran, - eMultiEventDDL, -}; - -// Contains the pointer to all multi-event subclass definitions. -const USHORT* x_rgpusMultiEventSubclassValues[] = -{ - x_rgusTraceLockEventsForModeInt2TypeAndOwnerColumns, // eMultiEventLockColumns - x_rgusEventsWithObjType, // eMultiEventObjType - x_rgusPostExecError, // eMultiEventPostExecError - x_rgusSecObjManagement, // eMultiEventSecObjManagement - x_rgusSecPrinManagement, // eMultiEventSecPrinManagement - x_rgusGDR, // eMultiEventGDR - x_rgusEventsCommitAndBeginTranType, //eMultiEventCommitAndBeginTran - x_rgusEventsRollbackAndBeginTranType, //eMultiEventRollbackAndBeginTran - x_rgusDDL, // eMultiEventDDL -}; - - -const SUBCLASSMAP x_rgTraceEventSubclassMap[] = -{ - // DDL events - {L"Begin", eMultiEventDDL, TRACE_COLUMN_SUBCLASS, XeSqlPkg::DDL_BEGIN}, - {L"Commit", eMultiEventDDL, TRACE_COLUMN_SUBCLASS, XeSqlPkg::DDL_COMMIT}, - {L"Rollback", eMultiEventDDL, TRACE_COLUMN_SUBCLASS, XeSqlPkg::DDL_ROLLBACK}, - - {L"Resource type Lock", LCK_DEADLOCKCHAIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, LCK_DEADLOCKCHAIN_RESOURCE_TYPE_LOCK}, - {L"Resource type Exchange", LCK_DEADLOCKCHAIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, LCK_DEADLOCKCHAIN_RESOURCE_TYPE_EXCHANGE}, - - // Lock mode column - {L"NULL", eMultiEventLockColumns, TRACE_COLUMN_MODE, LCK_M_NL}, - {L"Sch-S", eMultiEventLockColumns, TRACE_COLUMN_MODE, LCK_M_SCH_S}, - {L"Sch-M", eMultiEventLockColumns, TRACE_COLUMN_MODE, LCK_M_SCH_M}, - {L"S", eMultiEventLockColumns, TRACE_COLUMN_MODE, LCK_M_S}, - {L"U", eMultiEventLockColumns, TRACE_COLUMN_MODE, LCK_M_U}, - {L"X", eMultiEventLockColumns, TRACE_COLUMN_MODE, LCK_M_X}, - {L"IS", eMultiEventLockColumns, TRACE_COLUMN_MODE, LCK_M_IS}, - {L"IU", eMultiEventLockColumns, TRACE_COLUMN_MODE, LCK_M_IU}, - {L"IX", eMultiEventLockColumns, TRACE_COLUMN_MODE, LCK_M_IX}, - {L"SIU", eMultiEventLockColumns, TRACE_COLUMN_MODE, LCK_M_SIU}, - {L"SIX", eMultiEventLockColumns, TRACE_COLUMN_MODE, LCK_M_SIX}, - {L"UIX", eMultiEventLockColumns, TRACE_COLUMN_MODE, LCK_M_UIX}, - {L"BU", eMultiEventLockColumns, TRACE_COLUMN_MODE, LCK_M_BU}, - {L"RangeS-S", eMultiEventLockColumns, TRACE_COLUMN_MODE, LCK_M_RS_S}, - {L"RangeS-U", eMultiEventLockColumns, TRACE_COLUMN_MODE, LCK_M_RS_U}, - {L"RangeI-N", eMultiEventLockColumns, TRACE_COLUMN_MODE, LCK_M_RI_NL}, - {L"RangeI-S", eMultiEventLockColumns, TRACE_COLUMN_MODE, LCK_M_RI_S}, - {L"RangeI-U", eMultiEventLockColumns, TRACE_COLUMN_MODE, LCK_M_RI_U}, - {L"RangeI-X", eMultiEventLockColumns, TRACE_COLUMN_MODE, LCK_M_RI_X}, - {L"RangeX-S", eMultiEventLockColumns, TRACE_COLUMN_MODE, LCK_M_RX_S}, - {L"RangeX-U", eMultiEventLockColumns, TRACE_COLUMN_MODE, LCK_M_RX_U}, - {L"RangeX-X", eMultiEventLockColumns, TRACE_COLUMN_MODE, LCK_M_RX_X}, - - // ObjType column - // - // Schema scope - // - {L"AF", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_AGG }, - {L"AP", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_APP }, - {L"AQ", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_ADHOC }, - {L"C", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_CHECK }, - {L"D", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_DEFAULT }, - {L"EN", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_EVTNOTIF }, - {L"F", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_FKEY }, - {L"FN", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_FUNCTION }, - {L"FS", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_FNSCLASM }, - {L"FT", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_FNTABASM }, - {L"IF", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_INLFUNC }, - {L"IS", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_INLSCLFN }, - {L"IT", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_INTLTAB }, - {L"IX", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_INDEX }, - {L"OB", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_OBJ }, - {L"ON", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_OBEVTNOT }, - {L"P", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_PROC }, - {L"PC", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_PROCASM }, - {L"PK", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_PRKEY }, - {L"PQ", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_PREPARED }, - {L"R", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_RULE }, - {L"RF", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_REPLPROC }, - {L"SO", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_SEQUENCE }, - {L"S", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_SYSTAB }, - {L"SN", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_SYNONYM }, - {L"SP", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_SECPOLICY }, - {L"SQ", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_SVCQ }, - {L"ST", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_STATISTICS }, - {L"SX", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_XMLSCHEMA }, - {L"TA", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_TRIGASM }, - {L"TF", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_TABFUNC }, - {L"TR", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_TRIGGER }, - {L"U", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_USRTAB }, - {L"UQ", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_UQKEY }, - {L"V", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_VIEW }, - {L"X", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_XPROC }, - {L"TY", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_TYPE }, - - // Database scope - // - {L"AK", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_ASYMKEY }, - {L"AR", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_APPROLE }, - {L"AS", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_ASM }, - {L"BN", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_BINDING }, - {L"CT", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_CONTRACT }, - {L"DA", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_DBAUDITSPEC}, - {L"DS", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_DBCONFIG }, - {L"DU", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_DBAUDIT }, - {L"DB", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_DATABASE }, - {L"DN", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_DBEVTNOT }, - {L"DT", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_DBTRIG }, - {L"FC", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_FTCAT }, - {L"FL", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_FTSTPLIST }, - {L"MK", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_MASTERKEY }, - {L"DK", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_DEK }, - {L"MT", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_MSGTYPE }, - {L"PF", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_PFUN }, - {L"PS", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_PSCHEME }, - {L"RL", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_ROLE }, - {L"RT", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_ROUTE }, - {L"SC", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_SCHEMA }, - {L"SK", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_OBFKEY }, - {L"SV", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_SERVICE }, - {L"DC", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_DBCREDENTIAL }, - {L"DE", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_DBXESES}, - {L"DR", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_DBRG }, - {L"EL", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_EXTLIB }, - {L"LA", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_EXTLANG }, - - // Users - {L"AU", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_AKEYUSER }, - {L"CU", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_CERTUSER }, - {L"SU", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_SQLUSER }, - {L"US", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_USER }, - {L"WU", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_WINUSER }, - {L"GU", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_GROUPUSER }, - {L"XU", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_EXTUSER }, - {L"PU", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_EXTGRPUSER }, - - // Server scope - // - {L"A", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_AUDIT }, - {L"AL", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_AKEYLOGIN }, - {L"CL", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_CERTLOGIN }, - {L"CD", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_CREDENTIAL }, - {L"CP", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_CRYPTOPROVIDER}, - {L"CR", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_CERT }, - {L"EP", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_ENDPOINT }, - {L"ER", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_EXRP}, - {L"L", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_LOGIN }, - {L"SA", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_SRVAUDITSPEC}, - {L"SG", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_SRVROLE }, - {L"SL", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_SQLLOGIN }, - {L"SD", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_SRVEVTNOT }, - {L"SR", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_SERVER }, - {L"RG", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_RG }, - {L"T", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_SRVTRIG }, - {L"WG", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_WINGROUP }, - {L"WL", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_WINLOGIN }, - {L"PL", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_EXTGRPLOGIN}, - {L"XL", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_EXTLOGIN }, - {L"SE", eMultiEventObjType, TRACE_COLUMN_OBJTYPE, OTYP_SRVXESES }, - - {L"Recursion", HASH_WARNINGS_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::HWT_RECURSION}, - {L"Bailout", HASH_WARNINGS_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::HWT_BAILOUT}, - - {L"Disabled", BITMAP_WARNINGS_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BITMAP_WARNINGS_DISABLED_SUBCLASS}, - - {L"Increase", MEMORY_CHANGE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::MEMORY_CHANGE_INCREASE}, - {L"Decrease", MEMORY_CHANGE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::MEMORY_CHANGE_DECREASE}, - - {L"Starting", OLEDB_CALL_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::EVENT_OPCODE_BEGIN}, - {L"Completed", OLEDB_CALL_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::EVENT_OPCODE_END}, - {L"Starting", OLEDB_QUERYINTERFACE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::EVENT_OPCODE_BEGIN}, - {L"Completed", OLEDB_QUERYINTERFACE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::EVENT_OPCODE_END}, - {L"Starting", OLEDB_DATAREAD_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::EVENT_OPCODE_BEGIN}, - {L"Completed", OLEDB_DATAREAD_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::EVENT_OPCODE_END}, - - {L"Query wait", QRY_EXEC_WARNINGS_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, QRY_EXEC_WARNINGS_QRYWAIT_SUBCLASS}, - {L"Query timeout", QRY_EXEC_WARNINGS_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, QRY_EXEC_WARNINGS_QRYTIMEOUT_SUBCLASS}, - - {L"Select", DOP_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::DOPST_SELECT}, - {L"Insert", DOP_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::DOPST_INSERT}, - {L"Update", DOP_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::DOPST_UPDATE}, - {L"Delete", DOP_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::DOPST_DELETE}, - {L"Merge", DOP_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::DOPST_MERGE}, - - {L"Single pass", SORT_WARNING_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::SWT_SINGLEPASS}, - {L"Multiple pass", SORT_WARNING_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::SWT_MULTIPASS}, - - {L"Backup", AUDIT_DMPLD_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_BACKUP_SUBCLASS}, - {L"Restore", AUDIT_DMPLD_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_RESTORE_SUBCLASS}, - {L"BackupLog", AUDIT_DMPLD_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_BACKUPLOG_SUBCLASS}, - - {L"Create", eMultiEventSecObjManagement, TRACE_COLUMN_SUBCLASS, SECURITY_CREATE_SECURABLE_SUBCLASS}, - {L"Alter", eMultiEventSecObjManagement, TRACE_COLUMN_SUBCLASS, SECURITY_ALTER_SECURABLE_SUBCLASS}, - {L"Drop", eMultiEventSecObjManagement, TRACE_COLUMN_SUBCLASS, SECURITY_DROP_SECURABLE_SUBCLASS}, - - {L"Backup", eMultiEventSecObjManagement, TRACE_COLUMN_SUBCLASS, SECURITY_BACKUP_SECURABLE_SUBCLASS}, - {L"Disable", SECURITY_SRV_PRINCIPAL_MANAGE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_DISABLE_SECURABLE_SUBCLASS}, - {L"Enable", SECURITY_SRV_PRINCIPAL_MANAGE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_ENABLE_SECURABLE_SUBCLASS}, - {L"Credential mapped to login", SECURITY_SRV_OBJECT_MANAGE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_CREDENTIAL_MAP_TO_CREATELOGIN_SUBCLASS}, - {L"Transfer", SECURITY_SCH_OBJECT_MANAGE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_TRANSFER_SECURABLE_SUBCLASS}, - {L"Credential Map Dropped", SECURITY_SRV_OBJECT_MANAGE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_NOCREDENTIAL_MAP_TO_LOGIN_SUBCLASS}, - {L"Open", SECURITY_DB_OBJECT_MANAGE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_OPEN_SECURABLE_SUBCLASS}, - {L"Restore", eMultiEventSecObjManagement, TRACE_COLUMN_SUBCLASS, SECURITY_RESTORE_SECURABLE_SUBCLASS}, - {L"Access", SECURITY_DB_OBJECT_MANAGE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_ACCESS_SECURABLE_SUBCLASS}, - - {L"Change User Login - Update One", SECURITY_DB_PRINCIPAL_MANAGE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_CHANGEUSERSLOGIN_UPDATEONE_SUBCLASS}, - {L"Change User Login - Auto Fix", SECURITY_DB_PRINCIPAL_MANAGE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_CHANGEUSERSLOGIN_AUTOFIX_SUBCLASS}, - - {L"Shutdown on Audit Failure", SECURITY_SRV_OBJECT_MANAGE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_AUDIT_SHUTDOWN_ON_FAILURE_SUBCLASS}, - - {L"Add", eMultiEventSecPrinManagement, TRACE_COLUMN_SUBCLASS, SECURITY_PRIN_ADD_SUBCLASS}, - {L"Drop", eMultiEventSecPrinManagement, TRACE_COLUMN_SUBCLASS, SECURITY_PRIN_DROP_SUBCLASS}, - - {L"Change group", SECURITY_DB_ROLE_ADDPRIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_PRIN_CHANGE_GROUP_SUBCLASS}, - - {L"Grant database access", AUDIT_ADD_DBUSER_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_PRIN_GRANTDBACCESS_SUBCLASS}, - {L"Revoke database access", AUDIT_ADD_DBUSER_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_PRIN_REVOKEDBACCESS_SUBCLASS}, - - {L"Shutdown", AUDIT_SERVER_START_STOP_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::SSSO_SHUTDOWN}, - {L"Started", AUDIT_SERVER_START_STOP_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::SSSO_STARTED}, - {L"Paused", AUDIT_SERVER_START_STOP_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::SSSO_PAUSED}, - {L"Continue", AUDIT_SERVER_START_STOP_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::SSSO_CONTINUE}, - - {L"Grant", eMultiEventGDR, TRACE_COLUMN_SUBCLASS, SECURITY_PERM_GRANT_SUBCLASS}, - {L"Revoke", eMultiEventGDR, TRACE_COLUMN_SUBCLASS, SECURITY_PERM_REVOKE_SUBCLASS}, - {L"Deny", eMultiEventGDR, TRACE_COLUMN_SUBCLASS, SECURITY_PERM_DENY_SUBCLASS}, - - {L"No Security Header", AUDIT_BROKER_CONVERSATION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_NO_DIALOG_HDR_SUBCLASS}, - {L"No Certificate", AUDIT_BROKER_CONVERSATION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_CERT_NOT_FOUND_SUBCLASS}, - {L"Invalid Signature", AUDIT_BROKER_CONVERSATION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_INVALID_SIGNATURE_SUBCLASS}, - {L"Run As Target Failure", AUDIT_BROKER_CONVERSATION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_RUN_AS_TARGET_FAIL_SUBCLASS}, - {L"Bad Data", AUDIT_BROKER_CONVERSATION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_BAD_DATA_SUBCLASS}, - - // N.B.: AT, DBM and SSB share this subclasses, change them in sync - {L"Login Success", AUDIT_BROKER_LOGIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_LOGIN_SUCCESS_SUBCLASS}, - {L"Login Protocol Error", AUDIT_BROKER_LOGIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_PROTOCOL_ERROR_SUBCLASS}, - {L"Message Format Error", AUDIT_BROKER_LOGIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_BAD_MSG_FORMAT_SUBCLASS}, - {L"Negotiate Failure", AUDIT_BROKER_LOGIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_NEGOTIATE_FAIL_SUBCLASS}, - {L"Authentication Failure", AUDIT_BROKER_LOGIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_AUTHENTICATION_FAIL_SUBCLASS}, - {L"Authorization Failure", AUDIT_BROKER_LOGIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_AUTHORIZATION_FAIL_SUBCLASS}, - - // N.B.: AT, DBM and SSB share this subclasses, change them in sync - {L"Login Success", AUDIT_DBMIRRORING_LOGIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_LOGIN_SUCCESS_SUBCLASS}, - {L"Login Protocol Error", AUDIT_DBMIRRORING_LOGIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_PROTOCOL_ERROR_SUBCLASS}, - {L"Message Format Error", AUDIT_DBMIRRORING_LOGIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_BAD_MSG_FORMAT_SUBCLASS}, - {L"Negotiate Failure", AUDIT_DBMIRRORING_LOGIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_NEGOTIATE_FAIL_SUBCLASS}, - {L"Authentication Failure", AUDIT_DBMIRRORING_LOGIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_AUTHENTICATION_FAIL_SUBCLASS}, - {L"Authorization Failure", AUDIT_DBMIRRORING_LOGIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_AUTHORIZATION_FAIL_SUBCLASS}, - - {L"Transmission Exception", BROKER_TRANSMISSION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_TRANSMISSION_EXCEPTION_SUBCLASS}, - - {L"Audit started", AUDIT_CHANGE_AUDIT_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_START_AUDIT_SUBCLASS}, - {L"Audit stopped", AUDIT_CHANGE_AUDIT_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_STOP_AUDIT_SUBCLASS}, - {L"C2 mode ON", AUDIT_CHANGE_AUDIT_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_C2MODE_CHANGED_ON}, - {L"C2 mode OFF", AUDIT_CHANGE_AUDIT_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_C2MODE_CHANGED_OFF}, - - {L"Close connection", DTC_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::CLOSE_CONN_SUB_CLASS}, - {L"Unknown", DTC_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::UNKNOWN_SUB_CLASS}, - {L"Get address", DTC_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::GET_DTC_ADDRESS_SUB_CLASS}, - {L"Propagate Transaction", DTC_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::PROPAGATE_XACT_SUB_CLASS}, - {L"Preparing Transaction", DTC_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::DTC_PREPARING_SUB_CLASS}, - {L"Transaction is prepared", DTC_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::DTC_PREPARED_SUB_CLASS}, - {L"Transaction is aborting", DTC_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::DTC_ABORTING_SUB_CLASS}, - {L"Transaction is committing", DTC_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::DTC_COMMITTING_SUB_CLASS}, - {L"TM failed while in prepared state", DTC_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::DTC_TM_RECOVERY_SUB_CLASS}, - {L"Internal commit", DTC_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::DTC_INT_COMMIT_SUB_CLASS}, - {L"Internal abort", DTC_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::DTC_INT_ABORT_SUB_CLASS}, - {L"Creating a new DTC transaction", DTC_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::DTC_BEG_DIST_SUB_CLASS}, - {L"Enlisting in a DTC transaction", DTC_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::DTC_ENLISTING_SUB_CLASS}, - - {L"Begin", TRANS_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::TRANS_BEGIN_EVENT_SUB_CLASS}, - {L"Commit", TRANS_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::TRANS_COMMIT_EVENT_SUB_CLASS}, - {L"Rollback", TRANS_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::TRANS_ROLLBACK_EVENT_SUB_CLASS}, - {L"Savepoint", TRANS_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::TRANS_SAVEPOINT_EVENT_SUB_CLASS}, - - {L"Schema changed", CP_RECOMPILE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::etrcSchemaChanged}, - {L"Statistics changed", CP_RECOMPILE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::etrcStatsChanged}, - {L"Deferred compile", CP_RECOMPILE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::etrcRecompileDNR}, - {L"Set option change", CP_RECOMPILE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::etrcSetOptChanged}, - {L"Temp table changed", CP_RECOMPILE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::etrcTempTableChanged}, - {L"Remote rowset changed", CP_RECOMPILE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::etrcRmtRowsetChanged}, - {L"For browse permissions changed", CP_RECOMPILE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::etrcForBrowsePermsChanged}, - {L"Query notification environment changed", CP_RECOMPILE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::etrcQNSubscrChanged}, - {L"PartitionView changed", CP_RECOMPILE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::etrcMPIViewChanged}, - {L"Cursor options changed", CP_RECOMPILE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::etrcCursorOptionsChanged}, - {L"Option (recompile) requested", CP_RECOMPILE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::etrcWithRecompileOption}, - {L"Parameterized plan flushed", CP_RECOMPILE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::etrcParamPlanFlushed}, - {L"Test plan linearization", CP_RECOMPILE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::etrcTestPlanLinearization}, - {L"Plan affecting database version changed",CP_RECOMPILE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::etrcPlanAffDBVersionChange}, - - {L"Schema changed", STMT_RECOMPILE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::etrcSchemaChanged}, - {L"Statistics changed", STMT_RECOMPILE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::etrcStatsChanged}, - {L"Deferred compile", STMT_RECOMPILE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::etrcRecompileDNR}, - {L"Set option change", STMT_RECOMPILE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::etrcSetOptChanged}, - {L"Temp table changed", STMT_RECOMPILE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::etrcTempTableChanged}, - {L"Remote rowset changed", STMT_RECOMPILE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::etrcRmtRowsetChanged}, - {L"For browse permissions changed", STMT_RECOMPILE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::etrcForBrowsePermsChanged}, - {L"Query notification environment changed", STMT_RECOMPILE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::etrcQNSubscrChanged}, - {L"PartitionView changed", STMT_RECOMPILE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::etrcMPIViewChanged}, - {L"Cursor options changed", STMT_RECOMPILE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::etrcCursorOptionsChanged}, - {L"Option (recompile) requested", STMT_RECOMPILE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::etrcWithRecompileOption}, - {L"Parameterized plan flushed", STMT_RECOMPILE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::etrcParamPlanFlushed}, - {L"Test plan linearization", STMT_RECOMPILE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::etrcTestPlanLinearization}, - {L"Plan affecting database version changed",STMT_RECOMPILE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::etrcPlanAffDBVersionChange}, - - {L"Default database changed", SECURITY_SRV_LOGIN_PROP_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_DEFDB_PROP_CHANGE_SUBCLASS}, - {L"Default language changed", SECURITY_SRV_LOGIN_PROP_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_DEFLANG_PROP_CHANGE_SUBCLASS}, - {L"Name changed", SECURITY_SRV_LOGIN_PROP_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_NAME_PROP_CHANGE_SUBCLASS}, - {L"Policy changed", SECURITY_SRV_LOGIN_PROP_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_PWD_POLICY_PROP_CHANGE_SUBCLASS}, - {L"Expiration changed", SECURITY_SRV_LOGIN_PROP_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_PWD_EXPIRATION_PROP_CHANGE_SUBCLASS}, - {L"Credential changed", SECURITY_SRV_LOGIN_PROP_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_CREDENTIAL_PROP_CHANGE_SUBCLASS}, - - {L"Password self changed", SECURITY_SRV_LOGIN_PWD_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_PWD_SELF_CHANGE_SUBCLASS}, - {L"Password changed", SECURITY_SRV_LOGIN_PWD_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_PWD_CHANGE_SUBCLASS}, - {L"Password self reset", SECURITY_SRV_LOGIN_PWD_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_PWD_SELF_RESET_SUBCLASS}, - {L"Password reset", SECURITY_SRV_LOGIN_PWD_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_PWD_RESET_SUBCLASS}, - {L"Password unlocked", SECURITY_SRV_LOGIN_PWD_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_PWD_UNLOCK_SUBCLASS}, - {L"Password must change", SECURITY_SRV_LOGIN_PWD_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_PWD_MUSTCHANGE_SUBCLASS}, - - {L"SEND Message", BROKER_DIALOG_ENDPOINT_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::BCA_SEND_MESSAGE}, - {L"END CONVERSATION", BROKER_DIALOG_ENDPOINT_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::BCA_END_CONVERSATION}, - {L"END CONVERSATION WITH ERROR", BROKER_DIALOG_ENDPOINT_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::BCA_END_CONVERSATION_ERROR}, - {L"Broker Initiated Error", BROKER_DIALOG_ENDPOINT_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::BCA_BROKER_INIT_ERROR}, - {L"Terminate Dialog", BROKER_DIALOG_ENDPOINT_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::BCA_TERMINATE_DIALOG}, - {L"Received Sequenced Message", BROKER_DIALOG_ENDPOINT_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::BCA_RCV_SEQ_MESSAGE}, - {L"Received END CONVERSATION", BROKER_DIALOG_ENDPOINT_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::BCA_RCV_END_CONVERSATION}, - {L"Received END CONVERSATION WITH ERROR", BROKER_DIALOG_ENDPOINT_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::BCA_RCV_END_CONVERSATION_ERROR}, - {L"Received Broker Error Message", BROKER_DIALOG_ENDPOINT_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::BCA_RCV_BROKER_ERROR}, - {L"Received END CONVERSATION Ack", BROKER_DIALOG_ENDPOINT_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::BCA_RCV_END_CONV_ACK}, - {L"BEGIN DIALOG", BROKER_DIALOG_ENDPOINT_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::BCA_BEGIN_DIALOG}, - {L"Dialog Created", BROKER_DIALOG_ENDPOINT_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::BCA_DIALOG_CREATED}, - {L"END CONVERSATION WITH CLEANUP", BROKER_DIALOG_ENDPOINT_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::BCA_END_CONV_CLEANUP}, - - {L"Create", BROKER_CONVERSATION_GROUP_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::BGA_CREATE}, - {L"Drop", BROKER_CONVERSATION_GROUP_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::BGA_DROP}, - - {L"Message with Acknowledgement Sent", BROKER_MESSAGE_ACK_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::BAT_MESSAGE_ACK_SENT}, - {L"Acknowledgement Sent", BROKER_MESSAGE_ACK_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::BAT_ACK_SENT}, - {L"Message with Acknowledgement Received", BROKER_MESSAGE_ACK_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::BAT_MESSAGE_ACK_RECEIVED}, - {L"Acknowledgement Received", BROKER_MESSAGE_ACK_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::BAT_ACK_RECEIVED}, - - {L"Sequenced Message", BROKER_MESSAGE_DROP_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::BMT_SEQUENCED}, - {L"Unsequenced Message", BROKER_MESSAGE_DROP_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::BMT_UNSEQUENCED}, - - {L"Started", BROKER_ACTIVATION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::BAS_STARTED}, - {L"Ended", BROKER_ACTIVATION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::BAS_ENDED}, - {L"Aborted", BROKER_ACTIVATION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::BAS_ABORTED}, - {L"Notified", BROKER_ACTIVATION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::BAS_NOTIFIED}, - {L"Task Output", BROKER_ACTIVATION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::BAS_TASK_OUTPUT}, - {L"Failed to start", BROKER_ACTIVATION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::BAS_START_FAILED}, - - // N.B.: AT, DBM and SSB share this subclasses, change them in sync - {L"Connecting", BROKER_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_CONNECTING_SUBCLASS}, - {L"Connected", BROKER_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_CONNECTED_SUBCLASS}, - {L"Connect Failed", BROKER_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_CONNECT_FAILED_SUBCLASS}, - {L"Closing", BROKER_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_CLOSING_SUBCLASS}, - {L"Closed", BROKER_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_CLOSED_SUBCLASS}, - {L"Accept", BROKER_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_ACCEPT_SUBCLASS}, - {L"Send IO Error", BROKER_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_SEND_ERROR_SUBCLASS}, - {L"Receive IO Error", BROKER_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_RECEIVE_ERROR_SUBCLASS}, - - {L"Operational", BROKER_MIRROR_ROUTE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::BMR_OPERATIONAL}, - {L"Operational with principal only", BROKER_MIRROR_ROUTE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::BMR_OPERATIONAL_PRINC_ONLY}, - {L"Not operational", BROKER_MIRROR_ROUTE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::BMR_NOT_OPERATIONAL}, - - // N.B.: AT, DBM and SSB share this subclasses, change them in sync - {L"Connecting", DBMIRRORING_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_CONNECTING_SUBCLASS}, - {L"Connected", DBMIRRORING_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_CONNECTED_SUBCLASS}, - {L"Connect Failed", DBMIRRORING_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_CONNECT_FAILED_SUBCLASS}, - {L"Closing", DBMIRRORING_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_CLOSING_SUBCLASS}, - {L"Closed", DBMIRRORING_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_CLOSED_SUBCLASS}, - {L"Accept", DBMIRRORING_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_ACCEPT_SUBCLASS}, - {L"Send IO Error", DBMIRRORING_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_SEND_ERROR_SUBCLASS}, - {L"Receive IO Error", DBMIRRORING_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_RECEIVE_ERROR_SUBCLASS}, - - {L"OK", eMultiEventPostExecError, TRACE_COLUMN_ERROR, XeSqlPkg::RRR_OK}, - {L"Error", eMultiEventPostExecError, TRACE_COLUMN_ERROR, XeSqlPkg::RRR_ERROR}, - {L"Abort", eMultiEventPostExecError, TRACE_COLUMN_ERROR, XeSqlPkg::RRR_ABORT}, - - {L"Skipped", POST_RPC_EVENT_CLASS, TRACE_COLUMN_ERROR, XeSqlPkg::RRR_SKIPPED}, - - {L"Spill begin", EXCHANGE_SPILL_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, EXCHANGE_SPILL_BEGIN_SUBCLASS}, - {L"Spill end", EXCHANGE_SPILL_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, EXCHANGE_SPILL_END_SUBCLASS}, - - {L"Commit", eMultiEventCommitAndBeginTran, TRACE_COLUMN_SUBCLASS, XACT_COMMIT_XACT_SUB_CLASS}, - {L"Commit and Begin", eMultiEventCommitAndBeginTran, TRACE_COLUMN_SUBCLASS, XACT_COMMIT_AND_BEGIN_XACT_SUB_CLASS}, - - {L"Rollback", eMultiEventRollbackAndBeginTran, TRACE_COLUMN_SUBCLASS, XACT_ROLLBACK_XACT_SUB_CLASS}, - {L"Rollback and Begin", eMultiEventRollbackAndBeginTran, TRACE_COLUMN_SUBCLASS, XACT_ROLLBACK_AND_BEGIN_XACT_SUB_CLASS}, - - {L"Serialize For Shipping", MATRIXDB_TRANSACTION_SHIPPING_CLASS, TRACE_COLUMN_SUBCLASS, MATRIX_XACT_SHIPPING_SUBCLASS_SERIALIZE}, - {L"De-Serialize From Shipping", MATRIXDB_TRANSACTION_SHIPPING_CLASS, TRACE_COLUMN_SUBCLASS, MATRIX_XACT_SHIPPING_SUBCLASS_DESERIALIZE}, - {L"Serialize For Reporting", MATRIXDB_TRANSACTION_SHIPPING_CLASS, TRACE_COLUMN_SUBCLASS, MATRIX_XACT_SHIPPING_SUBCLASS_REPORT}, - {L"De-Serialize From Reporting", MATRIXDB_TRANSACTION_SHIPPING_CLASS, TRACE_COLUMN_SUBCLASS, MATRIX_XACT_SHIPPING_SUBCLASS_DEREPORT}, - - {L"TCM:CloseAge Broadcast", MATRIXDB_TCM_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, MATRIX_TCM_AGE_CLOSE_BROADCAST}, - {L"TCM:CloseAge Receive", MATRIXDB_TCM_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, MATRIX_TCM_AGE_CLOSE_RECEIVE}, - {L"TCM:BrickStatus Send", MATRIXDB_TCM_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, MATRIX_TCM_BRICK_STATUS_SEND}, - {L"TCM:CloseAge Receive", MATRIXDB_TCM_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, MATRIX_TCM_BRICK_STATUS_RECEIVE}, - - {L"Begin", MATRIXDB_TRANSACTION_START_END_CLASS, TRACE_COLUMN_SUBCLASS, MATRIX_XACT_SUBCLASS_BEGIN}, - {L"Commit", MATRIXDB_TRANSACTION_START_END_CLASS, TRACE_COLUMN_SUBCLASS, MATRIX_XACT_SUBCLASS_COMMIT}, - {L"Abort", MATRIXDB_TRANSACTION_START_END_CLASS, TRACE_COLUMN_SUBCLASS, MATRIX_XACT_SUBCLASS_ABORT}, - - {L"Matrix Error", MATRIXDB_ERROR_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, MATRIX_BRICK_COMPONENT_ERROR_SUBCLASS}, - - {L"Health check broadcast send", MATRIXDB_CM_HEARTBEAT_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, MATRIX_CM_HEARTBEAT_BROADCAST_SEND_SUBCLASS}, - {L"Health check broadcast complete", MATRIXDB_CM_HEARTBEAT_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, MATRIX_CM_HEARTBEAT_BROADCAST_COMPLETE_SUBCLASS}, - {L"Health check broadcast reply", MATRIXDB_CM_HEARTBEAT_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, MATRIX_CM_HEARTBEAT_BROADCAST_REPLY_SUBCLASS }, - - {L"Brick health check failure", MATRIXDB_CM_FAILURE_MONITOR_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, MATRIX_CM_FAILURE_MONITOR_ADD_FAILURE_SUBCLASS}, - {L"Brick health report as failed", MATRIXDB_CM_FAILURE_MONITOR_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, MATRIX_CM_FAILURE_MONITOR_MARK_OFFLINE_SUBCLASS}, - - {L"Start", ONLINE_INDEX_PROGRESS_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::OIBS_ONLINE_INDEX_START}, - {L"Stage 1 execution begin", ONLINE_INDEX_PROGRESS_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::OIBS_ONLINE_INDEX_EXECUTION_STAGE_1_BEGIN}, - {L"Stage 1 execution end", ONLINE_INDEX_PROGRESS_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::OIBS_ONLINE_INDEX_EXECUTION_STAGE_1_END}, - {L"Stage 2 execution begin", ONLINE_INDEX_PROGRESS_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::OIBS_ONLINE_INDEX_EXECUTION_STAGE_2_BEGIN}, - {L"Stage 2 execution end", ONLINE_INDEX_PROGRESS_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::OIBS_ONLINE_INDEX_EXECUTION_STAGE_2_END}, - {L"Inserted row count", ONLINE_INDEX_PROGRESS_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::OIBS_ONLINE_INDEX_EXECUTION_ROWCOUNT}, - {L"Done", ONLINE_INDEX_PROGRESS_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::OIBS_ONLINE_INDEX_STOP}, - {L"Query failed", ONLINE_INDEX_PROGRESS_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::OIBS_ONLINE_INDEX_FAILURE}, - {L"Deleted row", ONLINE_INDEX_PROGRESS_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::OIBS_ONLINE_INDEX_EXECUTION_DELETED_ROW}, - {L"Error", ONLINE_INDEX_PROGRESS_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::OIBS_ONLINE_INDEX_EXECUTION_ERROR}, - - {L"Local", BROKER_MESSAGE_CLASSIFY_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::BRT_LOCAL}, - {L"Remote", BROKER_MESSAGE_CLASSIFY_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::BRT_REMOTE}, - {L"Delayed", BROKER_MESSAGE_CLASSIFY_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::BRT_DELAYED}, - - // QP JOB Error: error type - {L"Give up", QP_JOB_ERROR_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::QPJE_GIVE_UP}, - {L"Queue full", QP_JOB_ERROR_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::QPJE_QUEUE_FULL}, - {L"Exception", QP_JOB_ERROR_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::QPJE_EXCEPTION}, - - // Auto Stats: statistics update status - {L"Other", AUTO_STATS_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::SAS_OTHER}, - {L"Queued", AUTO_STATS_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::SAS_QUEUED}, - {L"Starting", AUTO_STATS_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::SAS_START}, - {L"Completed", AUTO_STATS_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::SAS_ENDED}, - - // Pre stmt event state - {L"Recompiled", STMT_START_EVENT_CLASS, TRACE_COLUMN_STATE, XeSqlPkg::SSS_RECOMPILED}, - {L"Execution Plan Flush", STMT_START_EVENT_CLASS, TRACE_COLUMN_STATE, XeSqlPkg::SSS_XSTMTFLUSH}, - {L"Recompiled", SP_STMT_START_EVENT_CLASS, TRACE_COLUMN_STATE, XeSqlPkg::SSS_RECOMPILED}, - {L"Execution Plan Flush", SP_STMT_START_EVENT_CLASS, TRACE_COLUMN_STATE, XeSqlPkg::SSS_XSTMTFLUSH}, - - // Tape mount events - {L"Tape mount request", BACKUP_TAPE_MOUNT_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BACKUP_TAPE_MOUNT_REQUEST_SUBCLASS}, - {L"Tape mount complete", BACKUP_TAPE_MOUNT_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BACKUP_TAPE_MOUNT_COMPLETE_SUBCLASS}, - {L"Tape mount cancelled", BACKUP_TAPE_MOUNT_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BACKUP_TAPE_MOUNT_CANCEL_SUBCLASS}, - - {L"Compplan Remove", CP_REMOVE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::SCRM_COMPPLAN_REMOVE}, - {L"Proc Cache Flush", CP_REMOVE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::SCRM_PROC_CACHE_FLUSH}, - - // Perf stat event - {L"SQL", STMT_PERFSTAT_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, STMT_PERFSTAT_SQL_SUBCLASS}, - {L"SP:Plan", STMT_PERFSTAT_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, STMT_PERFSTAT_SPPLAN_SUBCLASS}, - {L"Batch:Plan", STMT_PERFSTAT_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, STMT_PERFSTAT_BATCHPLAN_SUBCLASS}, - {L"QueryStats", STMT_PERFSTAT_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, STMT_PERFSTAT_STAT_SUBCLASS}, - {L"ProcedureStats", STMT_PERFSTAT_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, STMT_PERFSTAT_PROC_STAT_SUBCLASS}, - {L"TriggerStats", STMT_PERFSTAT_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, STMT_PERFSTAT_TRIG_STAT_SUBCLASS}, - - {L"Alter Server State", SECURITY_SRV_OPERATION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_SRV_ALTERTRACE_EVENT_CLASS}, - {L"Checkpoint", SECURITY_DB_OPERATION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_DB_CHECKPOINT_SUBCLASS}, - {L"Subscribe to Query Notification", SECURITY_DB_OPERATION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_DB_SUBSCRIBEQNOTIF_SUBCLASS}, - {L"Authenticate", SECURITY_DB_OPERATION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_DB_AUTHENTICATE_SUBCLASS}, - {L"Showplan", SECURITY_DB_OPERATION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_DB_SHOWPLAN_SUBCLASS}, - {L"Connect", SECURITY_DB_OPERATION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_DB_CONNECT_SUBCLASS}, - {L"View Database State", SECURITY_DB_OPERATION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_DB_VIEWDBSTATE_SUBCLASS}, - - {L"Administer Bulk Operations", SECURITY_SRV_OPERATION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_SRV_ADMINBULKOPS_SUBCLASS}, - {L"Alter Settings", SECURITY_SRV_OPERATION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_SRV_ALTERSETTINGS_SUBCLASS}, - {L"Alter Resources", SECURITY_SRV_OPERATION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_SRV_ALTERRESOURCES_SUBCLASS}, - {L"Authenticate", SECURITY_SRV_OPERATION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_SRV_AUTHENTICATE_SUBCLASS}, - {L"External Access Assembly", SECURITY_SRV_OPERATION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_SRV_EXTERNALACCESS_SUBCLASS}, - {L"Unsafe Assembly", SECURITY_SRV_OPERATION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_SRV_UNSAFE_SUBCLASS}, - {L"Alter Connection", SECURITY_SRV_OPERATION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_SRV_ALTERCONN_SUBCLASS}, - {L"Alter Resource Governor", SECURITY_SRV_OPERATION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_SRV_ALTERRESGOVERNOR_SUBCLASS}, - {L"Use Any Workload Group", SECURITY_SRV_OPERATION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_SRV_USEANYWORKLOADGRP_SUBCLASS}, - {L"View Server State", SECURITY_SRV_OPERATION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, SECURITY_SRV_VIEWSERVERSTATE_SUBCLASS}, - - // Query notification subscription event subclasses - {L"Subscription registered", QN_SUBSCRIPTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::QNSA_REGISTERED}, - {L"Subscription rewound", QN_SUBSCRIPTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::QNSA_REWOUND}, - {L"Subscription fired", QN_SUBSCRIPTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::QNSA_SENT}, - {L"Firing failed with broker error",QN_SUBSCRIPTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::QNSA_FAILED_BROKER_ERR}, - {L"Firing failed without broker error", QN_SUBSCRIPTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::QNSA_FAILED_NON_BROKER_ERR}, - {L"Broker error intercepted", QN_SUBSCRIPTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::QNSA_ERR_INTERCEPTED}, - {L"Subscription deletion attempt", QN_SUBSCRIPTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::QNSA_DEL_ATTEMPT}, - {L"Subscription deletion failed", QN_SUBSCRIPTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::QNSA_DEL_FAILED}, - {L"Subscription destroyed", QN_SUBSCRIPTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::QNSA_DELETED}, - - // Query notification parameter table event subclasses - {L"Table created", QN_TABLE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::QNPT_TABLE_CREATED}, - {L"Table drop attempt", QN_TABLE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::QNPT_TABLE_DROP_ATTEMPT}, - {L"Table drop attempt failed", QN_TABLE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::QNPT_TABLE_DROP_FAILED}, - {L"Table dropped", QN_TABLE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::QNPT_TABLE_DROPPED}, - {L"Table pinned", QN_TABLE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::QNPT_TABLE_PINNED}, - {L"Table unpinned", QN_TABLE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::QNPT_TABLE_UNPINNED}, - {L"Number of users incremented", QN_TABLE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::QNPT_SUBS_COUNT_INC}, - {L"Number of users decremented", QN_TABLE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::QNPT_SUBS_COUNT_DEC}, - {L"LRU counter reset", QN_TABLE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::QNPT_SUBS_COUNT_RESET}, - {L"Cleanup task started", QN_TABLE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::QNPT_SUBS_CLEANUP_STARTED}, - {L"Cleanup task finished", QN_TABLE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::QNPT_SUBS_CLEANUP_FINISHED}, - - // Query notification template event subclasses - {L"Template created", QN_QUERYTEMPLATE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::QNTA_CREATED}, - {L"Template matched", QN_QUERYTEMPLATE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::QNTA_MATCHED}, - {L"Template dropped", QN_QUERYTEMPLATE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::QNTA_DROPPED}, - - // Query notification dynamics event subclasses - {L"Clock run started", QN_DYNAMICS_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::QNBA_STARTED}, - {L"Clock run finished", QN_DYNAMICS_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::QNBA_FINISHED}, - {L"Master cleanup task started", QN_DYNAMICS_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::QNBA_GC_STARTED}, - {L"Master cleanup task finished", QN_DYNAMICS_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::QNBA_GC_FINISHED}, - {L"Master cleanup task skipped", QN_DYNAMICS_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::QNBA_GC_SKIPPED}, - - // PreConnect event subclass - {L"RG Classifier UDF", PRECONNECT_PRE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::PRECONNECT_RG_CLASSIFIER}, - {L"RG Classifier UDF", PRECONNECT_POST_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::PRECONNECT_RG_CLASSIFIER}, - {L"Logon Trigger", PRECONNECT_PRE_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::PRECONNECT_LOGON_TRIGGER}, - {L"Logon Trigger", PRECONNECT_POST_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::PRECONNECT_LOGON_TRIGGER}, - - - // MatrixDB Clone Refresh event subclasses - {L"Clone Refresh task started", MATRIXDB_CLONE_REFRESH_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, CLONE_REFRESH_START_SUBCLASS}, - {L"Clone transition to InRefresh started", MATRIXDB_CLONE_REFRESH_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, CLONE_REFRESH_TRANSITION_START_SUBCLASS}, - {L"Clone transition to InRefresh completed",MATRIXDB_CLONE_REFRESH_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, CLONE_REFRESH_TRANSITION_END_SUBCLASS}, - {L"Clone scanning started", MATRIXDB_CLONE_REFRESH_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, CLONE_REFRESH_SCAN_START_SUBCLASS}, - {L"Clone scanning finished", MATRIXDB_CLONE_REFRESH_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, CLONE_REFRESH_SCAN_END_SUBCLASS}, - {L"Refresh batch started", MATRIXDB_CLONE_REFRESH_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, CLONE_REFRESH_BATCH_START_SUBCLASS}, - {L"Stale rows deleted from InRefresh clone", MATRIXDB_CLONE_REFRESH_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, CLONE_REFRESH_DELETED_STALE_ROWS_SUBCLASS}, - {L"Refresh batch finished", MATRIXDB_CLONE_REFRESH_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, CLONE_REFRESH_BATCH_END_SUBCLASS}, - {L"Clone refresh finished", MATRIXDB_CLONE_REFRESH_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, CLONE_REFRESH_END_SUBCLASS}, - {L"Clone refresh encountered an error", MATRIXDB_CLONE_REFRESH_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, CLONE_REFRESH_ERROR_SUBCLASS}, - - // DEVNOTE: Keep the following groups at the end of the array so that we - // need fewer funclets to initialize the array at startup time. All array - // entries after the first funclet requiring entry will require funclets. - // - - // Lock resource type column - {L"NULL_RESOURCE", eMultiEventLockColumns, TRACE_COLUMN_TYPE, LockRes::NULL_RESOURCE}, - {L"DATABASE", eMultiEventLockColumns, TRACE_COLUMN_TYPE, LockRes::DATABASE}, - {L"FILE", eMultiEventLockColumns, TRACE_COLUMN_TYPE, LockRes::FILE}, - {L"OBJECT", eMultiEventLockColumns, TRACE_COLUMN_TYPE, LockRes::OBJECT}, - {L"PAGE", eMultiEventLockColumns, TRACE_COLUMN_TYPE, LockRes::PAGE}, - {L"KEY", eMultiEventLockColumns, TRACE_COLUMN_TYPE, LockRes::KEY}, - {L"EXTENT", eMultiEventLockColumns, TRACE_COLUMN_TYPE, LockRes::EXTENT}, - {L"RID", eMultiEventLockColumns, TRACE_COLUMN_TYPE, LockRes::RID}, - {L"APPLICATION", eMultiEventLockColumns, TRACE_COLUMN_TYPE, LockRes::APPLICATION}, - {L"METADATA", eMultiEventLockColumns, TRACE_COLUMN_TYPE, LockRes::METADATA}, - {L"HOBT", eMultiEventLockColumns, TRACE_COLUMN_TYPE, LockRes::HOBT}, - {L"ALLOCATION_UNIT", eMultiEventLockColumns, TRACE_COLUMN_TYPE, LockRes::ALLOCATION_UNIT}, - {L"OIB", eMultiEventLockColumns, TRACE_COLUMN_TYPE, LockRes::OIB}, - {L"ROWGROUP", eMultiEventLockColumns, TRACE_COLUMN_TYPE, LockRes::ROWGROUP}, - {L"XACT", eMultiEventLockColumns, TRACE_COLUMN_TYPE, LockRes::XACT}, - - // Lock owner column - {L"TRANSACTION", eMultiEventLockColumns, TRACE_COLUMN_OWNERID, XactLockInfo::Transaction}, - {L"CURSOR", eMultiEventLockColumns, TRACE_COLUMN_OWNERID, XactLockInfo::Cursor}, - {L"SESSION", eMultiEventLockColumns, TRACE_COLUMN_OWNERID, XactLockInfo::Session}, - {L"SHARED_TRANSACTION_WORKSPACE", eMultiEventLockColumns, TRACE_COLUMN_OWNERID, XactLockInfo::SharedXactWorkspace}, - {L"EXCLUSIVE_TRANSACTION_WORKSPACE",eMultiEventLockColumns, TRACE_COLUMN_OWNERID, XactLockInfo::ExclusiveXactWorkspace}, - {L"NOTIFICATION_OBJECT", eMultiEventLockColumns, TRACE_COLUMN_OWNERID, XactLockInfo::LockConflictNotificationObject}, - {L"LOCK_TABLE_ITERATOR", eMultiEventLockColumns, TRACE_COLUMN_OWNERID, XactLockInfo::LockTableIterator}, - - // LockOwner type column - {L"LOCK", eMultiEventLockColumns, TRACE_COLUMN_INTDATA2, RegularLockOwner}, - - // Audit Login/Logout - {L"Nonpooled", AUDIT_LOGIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, NONPOOLED_CONNECTION_SUBCLASS}, - {L"Pooled", AUDIT_LOGIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, POOLED_CONNECTION_SUBCLASS}, - {L"Non-DAC", AUDIT_LOGIN_EVENT_CLASS, TRACE_COLUMN_TYPE, CONNECTION_NON_DAC}, - {L"DAC", AUDIT_LOGIN_EVENT_CLASS, TRACE_COLUMN_TYPE, CONNECTION_DAC}, - {L"Nonpooled", AUDIT_LOGOUT_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, NONPOOLED_CONNECTION_SUBCLASS}, - {L"Pooled", AUDIT_LOGOUT_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, POOLED_CONNECTION_SUBCLASS}, - {L"Non-DAC", AUDIT_LOGOUT_EVENT_CLASS, TRACE_COLUMN_TYPE, CONNECTION_NON_DAC}, - {L"DAC", AUDIT_LOGOUT_EVENT_CLASS, TRACE_COLUMN_TYPE, CONNECTION_DAC}, - {L"Nonpooled", AUDIT_LOGIN_FAILED_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, NONPOOLED_CONNECTION_SUBCLASS}, - {L"Pooled", AUDIT_LOGIN_FAILED_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, POOLED_CONNECTION_SUBCLASS}, - {L"Non-DAC", AUDIT_LOGIN_FAILED_EVENT_CLASS, TRACE_COLUMN_TYPE, CONNECTION_NON_DAC}, - {L"DAC", AUDIT_LOGIN_FAILED_EVENT_CLASS, TRACE_COLUMN_TYPE, CONNECTION_DAC}, - - // Existing Connection - {L"Non-DAC", ACTIVE_EVENT_CLASS, TRACE_COLUMN_TYPE, CONNECTION_NON_DAC}, - {L"DAC", ACTIVE_EVENT_CLASS, TRACE_COLUMN_TYPE, CONNECTION_DAC}, - - // Lock Escalation - {L"LOCK_THRESHOLD", LCK_ESCALATION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::LE_LOCK_THRESHOLD}, - {L"MEMORY_THRESHOLD", LCK_ESCALATION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, XeSqlPkg::LE_MEMORY_THRESHOLD}, - - // Fulltext Auditing - {L"Fulltext Filter Daemon Connect Success", AUDIT_FULLTEXT_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_FDHOST_CONNECT_SUCCESS_SUBCLASS}, - {L"Fulltext Filter Daemon Connect Error", AUDIT_FULLTEXT_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_FDHOST_CONNECT_ERROR_SUBCLASS}, - {L"Fulltext Launcher Connect Success", AUDIT_FULLTEXT_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_FDLAUNCHER_CONNECT_SUCCESS_SUBCLASS}, - {L"Fulltext Launcher Connect Error", AUDIT_FULLTEXT_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_FDLAUNCHER_CONNECT_ERROR_SUBCLASS}, - {L"Fulltext Inbound Shared Memory Corrupt", AUDIT_FULLTEXT_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_ISM_CORRUPT_SUBCLASS}, - {L"Fulltext Inbound Pipe Message Corrupt", AUDIT_FULLTEXT_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_PIPE_MESSAGE_CORRUPT_SUBCLASS}, - - // AT connection event - {L"Connecting", ASYNC_TRANSPORT_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_CONNECTING_SUBCLASS}, - {L"Connected", ASYNC_TRANSPORT_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_CONNECTED_SUBCLASS}, - {L"Connect Failed", ASYNC_TRANSPORT_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_CONNECT_FAILED_SUBCLASS}, - {L"Closing", ASYNC_TRANSPORT_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_CLOSING_SUBCLASS}, - {L"Closed", ASYNC_TRANSPORT_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_CLOSED_SUBCLASS}, - {L"Accept", ASYNC_TRANSPORT_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_ACCEPT_SUBCLASS}, - {L"Send IO Error", ASYNC_TRANSPORT_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_SEND_ERROR_SUBCLASS}, - {L"Receive IO Error", ASYNC_TRANSPORT_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_RECEIVE_ERROR_SUBCLASS}, - - // AT login - {L"Login Success", ASYNC_TRANSPORT_LOGIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_LOGIN_SUCCESS_SUBCLASS}, - {L"Login Protocol Error", ASYNC_TRANSPORT_LOGIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_PROTOCOL_ERROR_SUBCLASS}, - {L"Message Format Error", ASYNC_TRANSPORT_LOGIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_BAD_MSG_FORMAT_SUBCLASS}, - {L"Negotiate Failure", ASYNC_TRANSPORT_LOGIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_NEGOTIATE_FAIL_SUBCLASS}, - {L"Authentication Failure", ASYNC_TRANSPORT_LOGIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_AUTHENTICATION_FAIL_SUBCLASS}, - {L"Authorization Failure", ASYNC_TRANSPORT_LOGIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_AUTHORIZATION_FAIL_SUBCLASS}, - - // cluster proxy connection event - {L"Connecting", CLUSTER_PROXY_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_CONNECTING_SUBCLASS}, - {L"Connected", CLUSTER_PROXY_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_CONNECTED_SUBCLASS}, - {L"Connect Failed", CLUSTER_PROXY_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_CONNECT_FAILED_SUBCLASS}, - {L"Closing", CLUSTER_PROXY_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_CLOSING_SUBCLASS}, - {L"Closed", CLUSTER_PROXY_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_CLOSED_SUBCLASS}, - {L"Accept", CLUSTER_PROXY_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_ACCEPT_SUBCLASS}, - {L"Send IO Error", CLUSTER_PROXY_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_SEND_ERROR_SUBCLASS}, - {L"Receive IO Error", CLUSTER_PROXY_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_RECEIVE_ERROR_SUBCLASS}, - - // cluster proxy login event - {L"Login Success", CLUSTER_PROXY_LOGIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_LOGIN_SUCCESS_SUBCLASS}, - {L"Login Protocol Error", CLUSTER_PROXY_LOGIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_PROTOCOL_ERROR_SUBCLASS}, - {L"Message Format Error", CLUSTER_PROXY_LOGIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_BAD_MSG_FORMAT_SUBCLASS}, - {L"Negotiate Failure", CLUSTER_PROXY_LOGIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_NEGOTIATE_FAIL_SUBCLASS}, - {L"Authentication Failure", CLUSTER_PROXY_LOGIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_AUTHENTICATION_FAIL_SUBCLASS}, - {L"Authorization Failure", CLUSTER_PROXY_LOGIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_AUTHORIZATION_FAIL_SUBCLASS}, - - // global transactions connection event - {L"Connecting", GLOBAL_TRANSACTIONS_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_CONNECTING_SUBCLASS}, - {L"Connected", GLOBAL_TRANSACTIONS_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_CONNECTED_SUBCLASS}, - {L"Connect Failed", GLOBAL_TRANSACTIONS_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_CONNECT_FAILED_SUBCLASS}, - {L"Closing", GLOBAL_TRANSACTIONS_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_CLOSING_SUBCLASS}, - {L"Closed", GLOBAL_TRANSACTIONS_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_CLOSED_SUBCLASS}, - {L"Accept", GLOBAL_TRANSACTIONS_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_ACCEPT_SUBCLASS}, - {L"Send IO Error", GLOBAL_TRANSACTIONS_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_SEND_ERROR_SUBCLASS}, - {L"Receive IO Error", GLOBAL_TRANSACTIONS_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_RECEIVE_ERROR_SUBCLASS}, - - // global transactions login event - {L"Login Success", AUDIT_GLOBAL_TRANSACTIONS_LOGIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_LOGIN_SUCCESS_SUBCLASS}, - {L"Login Protocol Error", AUDIT_GLOBAL_TRANSACTIONS_LOGIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_PROTOCOL_ERROR_SUBCLASS}, - {L"Message Format Error", AUDIT_GLOBAL_TRANSACTIONS_LOGIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_BAD_MSG_FORMAT_SUBCLASS}, - {L"Negotiate Failure", AUDIT_GLOBAL_TRANSACTIONS_LOGIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_NEGOTIATE_FAIL_SUBCLASS}, - {L"Authentication Failure", AUDIT_GLOBAL_TRANSACTIONS_LOGIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_AUTHENTICATION_FAIL_SUBCLASS}, - {L"Authorization Failure", AUDIT_GLOBAL_TRANSACTIONS_LOGIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_AUTHORIZATION_FAIL_SUBCLASS}, - - // storage connection event - {L"Connecting", STORAGE_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_CONNECTING_SUBCLASS}, - {L"Connected", STORAGE_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_CONNECTED_SUBCLASS}, - {L"Connect Failed", STORAGE_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_CONNECT_FAILED_SUBCLASS}, - {L"Closing", STORAGE_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_CLOSING_SUBCLASS}, - {L"Closed", STORAGE_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_CLOSED_SUBCLASS}, - {L"Accept", STORAGE_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_ACCEPT_SUBCLASS}, - {L"Send IO Error", STORAGE_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_SEND_ERROR_SUBCLASS}, - {L"Receive IO Error", STORAGE_CONNECTION_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, BROKER_CONNECTION_RECEIVE_ERROR_SUBCLASS}, - - // storage login event - {L"Login Success", AUDIT_STORAGE_LOGIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_LOGIN_SUCCESS_SUBCLASS}, - {L"Login Protocol Error", AUDIT_STORAGE_LOGIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_PROTOCOL_ERROR_SUBCLASS}, - {L"Message Format Error", AUDIT_STORAGE_LOGIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_BAD_MSG_FORMAT_SUBCLASS}, - {L"Negotiate Failure", AUDIT_STORAGE_LOGIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_NEGOTIATE_FAIL_SUBCLASS}, - {L"Authentication Failure", AUDIT_STORAGE_LOGIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_AUTHENTICATION_FAIL_SUBCLASS}, - {L"Authorization Failure", AUDIT_STORAGE_LOGIN_EVENT_CLASS, TRACE_COLUMN_SUBCLASS, AUDIT_AUTHORIZATION_FAIL_SUBCLASS}, - - {NULL, TRACE_INVALID_EVENT, 0}, // Make sure this is the last entry. -}; - -// UNDO: -// Enable TRACE_COLUMN_GROUPID for all events. -// - -// Event definitions -// Make sure each array index matches event id. For example, index 10 = POST_RPC_EVENT_CLASS -TRACE_EVENT_INFO g_rgTraceEventInfo[] = -{ - //$$TRCEVENTINFO_START Do not remove this comment. - // Default. All other events should include at least the following columns - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6 - //0,0,0,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1 - - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6 - {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, TRACE_INVALID_EVENT, TRCAT_INVALID, NULL}, // 0 - {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, TRACE_INVALID_EVENT, TRCAT_INVALID, NULL}, - {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, TRACE_INVALID_EVENT, TRCAT_INVALID, NULL}, - {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, TRACE_INVALID_EVENT, TRCAT_INVALID, NULL}, - {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, TRACE_INVALID_EVENT, TRCAT_INVALID, NULL}, - {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, TRACE_INVALID_EVENT, TRCAT_INVALID, NULL}, - {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, TRACE_INVALID_EVENT, TRCAT_INVALID, NULL}, - {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, TRACE_INVALID_EVENT, TRCAT_INVALID, NULL}, - {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, TRACE_INVALID_EVENT, TRCAT_INVALID, NULL}, - {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, TRACE_INVALID_EVENT, TRCAT_INVALID, NULL}, - - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,7,7 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1 - {{0,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,1,1,0,0,0,1,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, POST_RPC_EVENT_CLASS, TRCAT_STOREDPROCEDURES, L"RPC:Completed"}, // 10 - {{0,1,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, PRE_RPC_EVENT_CLASS, TRCAT_STOREDPROCEDURES, L"RPC:Starting"}, - {{0,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, POST_LANG_EVENT_CLASS, TRCAT_TSQL, L"SQL:BatchCompleted"}, - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, PRE_LANG_EVENT_CLASS, TRCAT_TSQL, L"SQL:BatchStarting"}, - {{0,1,1,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,1,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,1,0,0,0,1,0,1}, AUDIT_LOGIN_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit Login", 3}, - {{0,0,0,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,1,0,0,0,1,0,1}, AUDIT_LOGOUT_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit Logout", 3}, - {{0,0,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, ATTENTION_EVENT_CLASS, TRCAT_ERRORSANDWARNINGS, L"Attention"}, - {{0,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,1,0,0,1,0,0,0,1,0,1}, ACTIVE_EVENT_CLASS, TRCAT_SESSIONS, L"ExistingConnection"}, - {{0,0,0,0,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,1,1,1}, AUDIT_SERVER_START_STOP_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit Server Starts And Stops"}, - {{0,1,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,0,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, DTC_EVENT_CLASS, TRCAT_TRANSACTIONS, L"DTCTransaction"}, - {{0,1,0,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,1,0,0,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,0,0,1,1,1}, AUDIT_LOGIN_FAILED_EVENT_CLASS, TRCAT_SECURITYAUDIT , L"Audit Login Failed", 3}, // 20 - - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,7,7 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1 - {{0,1,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,1,0,0,0,0,0,1,1,0,0,1,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, EVENTLOG_EVENT_CLASS, TRCAT_ERRORSANDWARNINGS, L"EventLog", 7}, - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,1,0,0,0,0,0,1,1,0,0,1,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,1,1,1}, ERRORLOG_EVENT_CLASS, TRCAT_ERRORSANDWARNINGS, L"ErrorLog", 7}, - {{0,1,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,0,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,1,1,1,0,1,0,0,0,1,0,1}, LCK_RELEASE_EVENT_CLASS, TRCAT_LOCKS, L"Lock:Released"}, - {{0,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,0,0,0,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,1,1,1,0,1,0,0,0,1,0,1}, LCK_ACQUIRE_EVENT_CLASS, TRCAT_LOCKS, L"Lock:Acquired"}, - {{0,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,0,0,1,1,1,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,1,1,1,0,1,0,0,0,1,0,1}, LCK_DEADLOCK_EVENT_CLASS, TRCAT_LOCKS, L"Lock:Deadlock", 5}, - {{0,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,0,0,0,1,1,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,1,1,1,0,1,0,0,0,1,0,1}, LCK_CANCEL_EVENT_CLASS, TRCAT_LOCKS, L"Lock:Cancel"}, - {{0,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,0,0,0,1,1,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,1,1,1,0,1,0,0,0,1,0,1}, LCK_TIMEOUT_EVENT_CLASS, TRCAT_LOCKS, L"Lock:Timeout"}, - {{0,0,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,0,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, DOP_EVENT_CLASS, TRCAT_PERFORMANCE, L"Degree of Parallelism"}, - - - {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, TRACE_INVALID_EVENT, TRCAT_PERFORMANCE, L"Degree of Parallelism (7.0 Update)"}, //invalid? - {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, TRACE_INVALID_EVENT, TRCAT_PERFORMANCE, L"Degree of Parallelism (7.0 Delete)"}, // 30 //invalid? - {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, TRACE_INVALID_EVENT, TRCAT_PERFORMANCE, L"Degree of Parallelism (7.0 Select)"}, // invalid? - {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, TRACE_INVALID_EVENT, TRCAT_INVALID, L"ConnectionBeingKilled"}, // invalid? - - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,7,7 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1 - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,1,0,0,0,0,0,1,1,0,0,1,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1,0,0,1,1,1}, EXCEPTION_EVENT_CLASS, TRCAT_ERRORSANDWARNINGS, L"Exception", 5}, - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,0,1,1,1,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, CP_MISS_EVENT_CLASS, TRCAT_STOREDPROCEDURES, L"SP:CacheMiss", 5}, - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,0,1,1,1,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, CP_INSERT_EVENT_CLASS, TRCAT_STOREDPROCEDURES, L"SP:CacheInsert", 5}, - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,1,0,0,0,1,1,1,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, CP_REMOVE_EVENT_CLASS, TRCAT_STOREDPROCEDURES, L"SP:CacheRemove", 5}, - {{0,1,0,1,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,1,0,0,0,1,1,1,1,0,0,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,1,0,0,0,0,1,1,0,1,1,0,1}, CP_RECOMPILE_EVENT_CLASS, TRCAT_STOREDPROCEDURES, L"SP:Recompile", 5}, - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,0,1,1,1,0,0,0,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, CP_HIT_EVENT_CLASS, TRCAT_STOREDPROCEDURES, L"SP:CacheHit"}, - {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, RESERVED_39, TRCAT_INVALID, L"SP:ExecContextHit"}, - {{0,1,0,1,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,1,0,0,0,0,1,1,0,0,1,0,1}, STMT_START_EVENT_CLASS, TRCAT_TSQL, L"SQL:StmtStarting"}, // 40 - {{0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,1,1,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,1,1,1,1,0,0,0,1,0,0,0,0,1,1,0,0,1,0,1}, STMT_END_EVENT_CLASS, TRCAT_TSQL, L"SQL:StmtCompleted"}, - - - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,7,7 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1 - {{0,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,0,1,1,1,1,0,0,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,1,0,1,0,1}, SP_START_EVENT_CLASS, TRCAT_STOREDPROCEDURES, L"SP:Starting"}, // 42 - {{0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,0,0,0,1,1,1,1,0,0,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,1,0,1,0,1,0,1}, SP_END_EVENT_CLASS, TRCAT_STOREDPROCEDURES, L"SP:Completed"}, // 43 - {{0,1,0,1,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,0,1,1,1,1,1,0,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,1,0,0,0,0,1,1,1,0,1,0,1}, SP_STMT_START_EVENT_CLASS, TRCAT_STOREDPROCEDURES, L"SP:StmtStarting"}, - {{0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,0,0,1,1,1,1,1,0,0,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,1,1,1,1,0,0,0,1,0,0,0,0,1,1,1,0,1,0,1}, SP_STMT_END_EVENT_CLASS, TRCAT_STOREDPROCEDURES, L"SP:StmtCompleted"}, - {{0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,1,0,1,1,1,1,1,0,0,0,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,1,0,0,0,1,0,0,0,1,0,0,0,1,0,1,0,0,1,1,1}, OBJECT_CREATE_EVENT_CLASS, TRCAT_OBJECTS, L"Object:Created", 7}, - {{0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,1,0,1,1,1,1,1,0,0,0,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,1,0,0,0,1,0,0,0,1,0,0,0,1,0,1,0,0,1,1,1}, OBJECT_DELETE_EVENT_CLASS, TRCAT_OBJECTS, L"Object:Deleted", 7}, - - {{0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, TRACE_INVALID_EVENT, TRCAT_OBJECTS, L"Object:Opened"}, // invalid? - {{0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, TRACE_INVALID_EVENT, TRCAT_OBJECTS, L"Object:Closed"}, // invalid? - - - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6 - {{0,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,1,0,0,0,1,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, TRANS_EVENT_CLASS, TRCAT_TRANSACTIONS, L"SQLTransaction"}, // 50 - {{0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,1,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, SCAN_START_EVENT_CLASS, TRCAT_SCANS, L"Scan:Started"}, - {{0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,0,1,0,0,0,0,0,1,0,1,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, SCAN_STOP_EVENT_CLASS, TRCAT_SCANS, L"Scan:Stopped"}, - {{0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, CURSOR_CREATED_EVENT_CLASS, TRCAT_CURSORS, L"CursorOpen"}, - {{0,0,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,1,0,1,1,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, LOG_EVENT_CLASS, TRCAT_TRANSACTIONS, L"TransactionLog"}, - {{0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,1,0,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, HASH_WARNINGS_EVENT_CLASS, TRCAT_ERRORSANDWARNINGS, L"Hash Warning", 5}, - - {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, TRACE_INVALID_EVENT, TRCAT_INVALID, NULL}, // INVALID? - {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, TRACE_INVALID_EVENT, TRCAT_INVALID, NULL}, // INVALID? - - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6 - {{0,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,1,0,0,1,0,0,0,1,0,1}, AUTO_STATS_EVENT_CLASS, TRCAT_PERFORMANCE, L"Auto Stats"}, - {{0,1,1,1,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,1,1,0,0,1,1,1,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,1,1,1,0,1,0,0,0,1,0,0}, LCK_DEADLOCKCHAIN_EVENT_CLASS, TRCAT_LOCKS, L"Lock:Deadlock Chain", 5}, - {{0,1,0,1,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,1,0,0,1,1,1,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,1,1,1,1,0,1,1,0,0,1,0,1}, LCK_ESCALATION_EVENT_CLASS, TRCAT_LOCKS, L"Lock:Escalation", 5}, // 60 - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,1,1,1,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, OLEDB_ERRORS_EVENT_CLASS, TRCAT_OLEDB, L"OLEDB Errors", 7}, - -// - SPECIAL CASE EVENTS USED ONLY BY THE CLIENT whilst replaying - {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, TRACE_INVALID_EVENT, TRCAT_INVALID, L"Replay Error"}, - {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, TRACE_INVALID_EVENT, TRCAT_INVALID, L"Replay Internal Error"}, - {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, TRACE_INVALID_EVENT, TRCAT_INVALID, L"Replay Result Set"}, - {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, TRACE_INVALID_EVENT, TRCAT_INVALID, L"Replay Result Row"}, - {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, TRACE_INVALID_EVENT, TRCAT_INVALID, L"Replay Result Statistics"}, - - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6 - {{0,1,0,1,1,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,0,0,0,0,1,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, QRY_EXEC_WARNINGS_EVENT_CLASS, TRCAT_ERRORSANDWARNINGS, L"Execution Warnings", 5}, - {{0,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,1,1,1,1,1,0,0,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, SHOWPLAN_EVENT_CLASS, TRCAT_PERFORMANCE, L"Showplan Text (Unencoded)"}, - {{0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,0,0,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, SORT_WARNING_EVENT_CLASS, TRCAT_ERRORSANDWARNINGS, L"Sort Warnings", 5}, - {{0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, CURSOR_PREPARE_EVENT_CLASS, TRCAT_CURSORS, L"CursorPrepare"}, // 70 - {{0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, PREPARE_EVENT_CLASS, TRCAT_TSQL, L"Prepare SQL"}, - {{0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, EXECUTE_EVENT_CLASS, TRCAT_TSQL, L"Exec Prepared SQL"}, - {{0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, UNPREPARE_EVENT_CLASS, TRCAT_TSQL, L"Unprepare SQL"}, - {{0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, CURSOR_EXECUTE_EVENT_CLASS, TRCAT_CURSORS, L"CursorExecute"}, - {{0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, CURSOR_RECOMPILE_EVENT_CLASS, TRCAT_CURSORS, L"CursorRecompile"}, - {{0,0,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, CURSOR_IMPLCTCNV_EVENT_CLASS, TRCAT_CURSORS, L"CursorImplicitConversion"}, - {{0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, CURSOR_UNPREPARE_EVENT_CLASS, TRCAT_CURSORS, L"CursorUnprepare"}, - {{0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, CURSOR_CLOSE_EVENT_CLASS, TRCAT_CURSORS, L"CursorClose"}, - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, NO_STATISTICS_EVENT_CLASS, TRCAT_ERRORSANDWARNINGS, L"Missing Column Statistics", 5}, - {{0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, NO_JOIN_PREDICATE_EVENT_CLASS, TRCAT_ERRORSANDWARNINGS, L"Missing Join Predicate", 5}, // 80 - {{0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, MEMORY_CHANGE_EVENT_CLASS, TRCAT_SERVER, L"Server Memory Change", 5}, - -// User defined event classes start here - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6 - {{0,1,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, USER_CONFIGURABLE_0_EVENT_CLASS, TRCAT_USERCONFIGURABLE, L"UserConfigurable:0", 11}, - {{0,1,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, USER_CONFIGURABLE_1_EVENT_CLASS, TRCAT_USERCONFIGURABLE, L"UserConfigurable:1", 11}, - {{0,1,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, USER_CONFIGURABLE_2_EVENT_CLASS, TRCAT_USERCONFIGURABLE, L"UserConfigurable:2", 11}, - {{0,1,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, USER_CONFIGURABLE_3_EVENT_CLASS, TRCAT_USERCONFIGURABLE, L"UserConfigurable:3", 11}, - {{0,1,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, USER_CONFIGURABLE_4_EVENT_CLASS, TRCAT_USERCONFIGURABLE, L"UserConfigurable:4", 11}, - {{0,1,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, USER_CONFIGURABLE_5_EVENT_CLASS, TRCAT_USERCONFIGURABLE, L"UserConfigurable:5", 11}, - {{0,1,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, USER_CONFIGURABLE_6_EVENT_CLASS, TRCAT_USERCONFIGURABLE, L"UserConfigurable:6", 11}, - {{0,1,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, USER_CONFIGURABLE_7_EVENT_CLASS, TRCAT_USERCONFIGURABLE, L"UserConfigurable:7", 11}, - {{0,1,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, USER_CONFIGURABLE_8_EVENT_CLASS, TRCAT_USERCONFIGURABLE, L"UserConfigurable:8", 11}, // 90 - {{0,1,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, USER_CONFIGURABLE_9_EVENT_CLASS, TRCAT_USERCONFIGURABLE, L"UserConfigurable:9", 11}, - - -// NOTE: START OF 7.5 EVENTS. CHANGE FIRST_7X_EVENT_CLASS ACCORDINGLY! - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6 - {{0,0,0,1,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, DATAFILE_AUTOGROW_EVENT_CLASS, TRCAT_DATABASE, L"Data File Auto Grow", 5}, - {{0,0,0,1,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, LOGFILE_AUTOGROW_EVENT_CLASS, TRCAT_DATABASE, L"Log File Auto Grow", 5}, - {{0,0,0,1,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, DATAFILE_AUTOSHRINK_EVENT_CLASS, TRCAT_DATABASE, L"Data File Auto Shrink", 5}, - {{0,0,0,1,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, LOGFILE_AUTOSHRINK_EVENT_CLASS, TRCAT_DATABASE, L"Log File Auto Shrink", 5}, - {{0,0,1,1,1,1,0,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,1,1,1,1,1,0,0,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, SHOWPLAN_TEXT_EVENT_CLASS, TRCAT_PERFORMANCE, L"Showplan Text"}, - {{0,0,1,1,1,1,0,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,1,1,1,1,1,0,0,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, SHOWPLAN_ALL_EVENT_CLASS, TRCAT_PERFORMANCE, L"Showplan All"}, - {{0,0,1,1,1,1,0,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,1,1,1,1,1,0,0,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, SHOWPLAN_STATISTICS_EVENT_CLASS, TRCAT_PERFORMANCE, L"Showplan Statistics Profile"}, - {{0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, OLAP_NOTIFICATION_EVENT_CLASS, TRCAT_INVALID, NULL}, // Special OLAP notification - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, RPC_OUTPARAM_EVENT_CLASS, TRCAT_STOREDPROCEDURES, L"RPC Output Parameter"}, // 100 - {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, TRACE_INVALID_EVENT, TRCAT_INVALID, NULL}, //INVALID - - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,7,7 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1 - {{0,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,1,0,1,0,1,0,0,1,1,1,1,0,0,0,0,1,1,0,1,0,1,1,1,1,1,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,1,1,1}, SECURITY_GDR_DB_SCOPE_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit Database Scope GDR Event", 3}, - {{0,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,1,0,1,0,1,0,0,1,1,1,1,0,0,0,0,1,1,0,1,0,1,1,1,1,1,1,0,0,0,0,1,1,1,0,0,0,0,0,0,0,1,1,0,0,0,1,0,0,0,0,1,1,1}, SECURITY_GDR_SCH_OBJECT_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit Schema Object GDR Event", 3}, - {{0,0,0,1,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,1,1,0,0,0,0,0,0,1,0,0,0,0,1,1,1,1,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,1,1,1}, AUDIT_ADDLOGIN_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit Addlogin Event", 3}, - {{0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,1,1,0,0,0,0,0,0,1,0,0,0,0,1,1,1,1,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,1,1,1}, AUDIT_LOGIN_GDR_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit Login GDR Event", 3}, // 105 - {{0,1,0,1,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,1,1,1,0,0,0,0,1,1,0,1,0,0,1,1,1,1,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0}, SECURITY_SRV_LOGIN_PROP_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit Login Change Property Event", 3}, - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,1,1,1,0,0,0,0,1,1,0,1,0,0,1,1,1,1,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0}, SECURITY_SRV_LOGIN_PWD_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit Login Change Password Event", 3}, - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,1,1,1,0,0,0,0,1,1,0,1,1,0,1,1,1,1,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,1,1,1}, SECURITY_SRV_ROLE_ADDPRIN_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit Add Login to Server Role Event", 3}, - {{0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,1,1,1,0,0,0,0,0,1,0,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,1,1,1}, AUDIT_ADD_DBUSER_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit Add DB User Event", 3}, - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,1,1,1,0,0,0,0,1,1,0,1,1,1,1,1,1,1,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,1,1,1}, SECURITY_DB_ROLE_ADDPRIN_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit Add Member to DB Role Event", 3}, // 110 - {{0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,1,1,1,0,0,0,0,0,1,0,0,1,0,1,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,1,1,1}, AUDIT_ADDROLE_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit Add Role Event", 3}, - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,1,0,0,1,1,1,1,0,0,0,0,1,1,0,1,1,0,1,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0}, SECURITY_DB_APPROLE_PWD_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit App Role Change Password Event", 3}, // 112 - - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6 - {{0,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,1,0,1,0,1,0,0,1,1,1,1,0,0,0,0,0,1,0,0,0,0,1,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, AUDIT_STMT_PERM_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit Statement Permission Event"}, - {{0,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,1,0,1,0,1,0,0,1,1,1,1,0,0,0,0,1,1,0,1,0,0,1,1,0,0,1,0,0,0,0,1,1,1,0,0,0,0,0,0,0,1,1,0,0,0,1,0,0}, SECURITY_SCH_OBJECT_ACCESS_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit Schema Object Access Event", 7}, // 114 - {{0,1,0,1,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,1,1,1,0,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, AUDIT_DMPLD_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit Backup/Restore Event", 7}, - {{0,1,0,1,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,1,0,0,1,1,0,1,0,0,0,0,0,1,0,1,0,0,1,1,0,0,1,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, AUDIT_DBCC_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit DBCC Event", 7}, - {{0,1,0,1,0,1,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,1,0,1,0,0,0,0,0,1,0,1,0,0,1,1,0,0,1,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, AUDIT_CHANGE_AUDIT_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit Change Audit Event", 7}, // 117 - {{0,1,0,1,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,1,1,1,0,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, AUDIT_OBJECT_DERIVED_PERM_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit Object Derived Permission Event"}, - - -// YUKON Additions - - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6 - {{0,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,1,1,1,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, OLEDB_CALL_EVENT_CLASS, TRCAT_OLEDB, L"OLEDB Call Event", 17}, // 119 - {{0,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,1,1,1,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, OLEDB_QUERYINTERFACE_EVENT_CLASS, TRCAT_OLEDB, L"OLEDB QueryInterface Event", 17}, // 120 - {{0,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,1,1,1,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, OLEDB_DATAREAD_EVENT_CLASS, TRCAT_OLEDB, L"OLEDB DataRead Event", 17}, // 121 - {{0,1,1,1,1,1,0,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,1,1,1,1,1,0,0,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, SHOWPLAN_XML_EVENT_CLASS, TRCAT_PERFORMANCE, L"Showplan XML", 17}, // 122 - {{0,1,0,1,1,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,0,0,1,1,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, FULLTEXTQUERY_EVENT_CLASS, TRCAT_PERFORMANCE, L"SQL:FullTextQuery"}, - {{0,1,0,1,1,1,1,1,1,1,1,0,1,0,1,0,0,0,0,0,0,1,0,0,0,0,1,1,0,0,0,0,0,0,1,0,1,1,1,1,1,1,1,0,0,0,1,1,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0}, BROKER_DIALOG_ENDPOINT_EVENT_CLASS, TRCAT_BROKER, L"Broker:Conversation"}, - -// Deprecation events - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6 - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,1,0,0,0,0,1,1,0,1,1,0,0}, DEPRECATION_ANNOUNCEMENT_EVENT_CLASS, TRCAT_DEPRECATION, L"Deprecation Announcement", 1}, // 125 - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,1,0,0,0,0,1,1,0,1,1,0,0}, DEPRECATION_FINAL_SUPPORT_EVENT_CLASS, TRCAT_DEPRECATION, L"Deprecation Final Support", 1}, // 126 - - {{0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,1,0,0,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, EXCHANGE_SPILL_EVENT_CLASS, TRCAT_ERRORSANDWARNINGS, L"Exchange Spill Event", 3}, // 127 - {{0,1,0,1,1,0,1,1,1,0,1,1,1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,1,1,1,0,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, SECURITY_DB_MANAGE_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit Database Management Event", 5}, // 128 - {{0,1,0,1,1,1,1,1,1,0,1,1,1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,1,1,1,0,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, SECURITY_DB_OBJECT_MANAGE_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit Database Object Management Event", 5}, // 129 - {{0,1,0,1,1,0,1,1,1,0,1,1,1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,1,1,1,0,0,0,0,1,1,0,1,0,1,1,1,1,1,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, SECURITY_DB_PRINCIPAL_MANAGE_EVENT_CLASS,TRCAT_SECURITYAUDIT, L"Audit Database Principal Management Event", 5}, // 130 - - {{0,1,0,1,1,0,1,1,1,0,1,1,1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,1,1,1,0,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,1,1,0,0,0,1,0,0}, SECURITY_SCH_OBJECT_MANAGE_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit Schema Object Management Event", 5}, // 131 - - {{0,1,1,1,1,0,1,1,1,0,1,1,1,0,1,0,0,0,0,1,0,1,0,1,0,0,1,1,1,1,0,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, SECURITY_SRV_PRINCIPAL_IMPERSONATE_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit Server Principal Impersonation Event", 3}, // 132 - {{0,1,1,1,1,0,1,1,1,0,1,1,1,0,1,0,0,0,0,1,0,1,0,1,0,0,1,1,1,1,0,0,0,0,1,1,0,1,1,0,1,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, SECURITY_DB_PRINCIPAL_IMPERSONATE_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit Database Principal Impersonation Event", 3}, // 133 - {{0,1,0,1,1,0,1,1,1,0,1,1,1,0,1,0,0,0,0,0,0,0,0,1,0,0,1,1,1,1,0,0,0,0,1,1,0,1,0,1,1,1,1,1,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, SECURITY_SRV_OBJECT_TAKEOWNERSHIP_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit Server Object Take Ownership Event", 3}, // 134 - {{0,1,0,1,1,0,1,1,1,0,1,1,1,0,1,0,0,0,0,0,0,0,0,1,0,0,1,1,1,1,0,0,0,0,1,1,0,1,0,1,1,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, SECURITY_DB_OBJECT_TAKEOWNERSHIP_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit Database Object Take Ownership Event", 3}, // 135 - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6 - {{0,0,0,1,1,0,1,1,1,1,1,0,1,0,1,0,0,0,0,0,0,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0}, BROKER_CONVERSATION_GROUP_EVENT_CLASS, TRCAT_BROKER, L"Broker:Conversation Group"}, // 136 - {{0,1,0,1,1,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,1,0,1,0,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, BLOCKED_PROCESS_REPORT_EVENT_CLASS, TRCAT_ERRORSANDWARNINGS, L"Blocked process report", 21}, //1// 137 - {{0,1,0,1,1,0,1,1,1,1,1,0,1,0,1,0,0,0,0,0,0,1,0,0,0,0,1,1,0,0,0,1,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0}, BROKER_CONNECTION_EVENT_CLASS, TRCAT_BROKER, L"Broker:Connection"}, // 138 - {{0,0,0,1,1,0,1,1,1,1,1,0,1,0,1,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,1,1,0,0,0,1,1,0,1,0,0,0,0,0,0,0,0,0,1,0,0}, BROKER_FORWARDED_MESSAGE_SENT_EVENT_CLASS, TRCAT_BROKER, L"Broker:Forwarded Message Sent"}, // 139 - {{0,1,0,1,1,0,1,1,1,1,1,0,1,0,1,0,0,0,0,0,1,0,1,1,1,1,1,1,0,0,1,1,0,0,0,0,1,1,1,1,1,1,1,0,0,0,1,1,0,0,0,1,1,0,1,0,0,0,0,0,0,0,0,0,1,0,0}, BROKER_FORWARDED_MESSAGE_DROPPED_EVENT_CLASS, TRCAT_BROKER, L"Broker:Forwarded Message Dropped"}, // 140 - {{0,1,0,1,1,0,1,1,1,1,1,0,1,0,1,0,0,0,0,0,0,1,0,0,0,0,1,1,0,0,0,1,0,0,0,0,1,1,1,0,0,1,0,0,0,1,0,1,0,0,0,1,0,0,1,0,0,0,0,1,1,0,0,0,1,0,0}, BROKER_MESSAGE_CLASSIFY_EVENT_CLASS, TRCAT_BROKER, L"Broker:Message Classify"}, // 141 - {{0,0,0,1,1,0,1,1,1,1,1,0,1,0,1,0,0,0,0,0,1,1,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0}, BROKER_TRANSMISSION_EVENT_CLASS, TRCAT_BROKER, L"Broker:Transmission"}, // 142 - {{0,0,0,1,1,0,1,1,1,1,1,0,1,0,1,0,0,0,0,0,0,0,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, BROKER_QUEUE_DISABLED_EVENT_CLASS, TRCAT_BROKER, L"Broker:Queue Disabled"}, // 143 - {{0,1,0,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,1,0,1,0,0,1,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, BROKER_MIRROR_ROUTE_EVENT_CLASS, TRCAT_BROKER, L"Broker:Mirrored Route State Changed"}, //144 - {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, TRACE_INVALID_EVENT, TRCAT_INVALID, NULL}, // reserved for broker 145 - - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,7,7 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1 - {{0,1,1,1,1,1,0,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,1,1,1,1,1,0,0,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, SHOWPLAN_XML_STATISTICS_EVENT_CLASS, TRCAT_PERFORMANCE, L"Showplan XML Statistics Profile", 17}, // 146 - {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, TRACE_INVALID_EVENT, TRCAT_INVALID, NULL}, // reserved for broker 147 - {{0,1,0,0,1,0,0,0,0,0,0,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, SQLOS_XML_DEADLOCK_EVENT_CLASS, TRCAT_LOCKS, L"Deadlock graph", 21}, - {{0,0,0,1,1,1,1,1,1,1,1,0,1,0,1,0,0,0,0,0,0,1,0,0,0,1,1,1,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,1,0,0,0,1,0,0}, BROKER_MESSAGE_ACK_EVENT_CLASS, TRCAT_BROKER, L"Broker:Remote Message Acknowledgement"}, - {{0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,0,0,0,0,0,1,0,0,0,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, TRACE_FILE_CLOSE_EVENT_CLASS, TRCAT_SERVER, L"Trace File Close", 5}, // 150 - - {{0,1,0,1,1,0,1,1,1,1,1,0,1,0,1,0,0,0,0,0,0,1,0,0,0,0,1,1,0,0,0,1,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0}, DBMIRRORING_CONNECTION_EVENT_CLASS, TRCAT_DATABASE, L"Database Mirroring Connection"}, // 151 - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,1,0,0,1,1,1,1,0,0,0,0,1,1,0,1,0,1,1,1,1,1,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,1,1}, SECURITY_DB_TAKEOWNERSHIP_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit Change Database Owner", 3}, // 152 - {{0,1,0,1,1,0,1,1,1,0,1,1,1,0,1,0,0,0,0,0,0,0,0,1,0,0,1,1,1,1,0,0,0,0,1,1,0,1,0,1,1,1,1,1,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,1,1,0,0,0,1,0,0,0,0,1,1}, SECURITY_SCH_OBJECT_TAKEOWNERSHIP_EVENT_CLASS,TRCAT_SECURITYAUDIT, L"Audit Schema Object Take Ownership Event", 3},// 153 - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,0,0,0,1,1,0,0,1,0,0,0,1,0,1,1,1,1,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, AUDIT_DBMIRRORING_LOGIN_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit Database Mirroring Login"}, // 154 - - {{0,1,0,1,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, FULLTEXT_CRAWL_START_EVENT_CLASS, TRCAT_FULLTEXT, L"FT:Crawl Started", 5}, // 155 - {{0,0,0,1,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, FULLTEXT_CRAWL_END_EVENT_CLASS, TRCAT_FULLTEXT, L"FT:Crawl Stopped", 5}, // 156 - {{0,0,0,1,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, FULLTEXT_CRAWL_ERROR_EVENT_CLASS, TRCAT_FULLTEXT, L"FT:Crawl Aborted", 5}, // 157 - {{0,1,0,1,1,0,1,1,1,1,1,0,1,0,1,0,0,0,0,0,1,1,1,0,0,1,1,1,0,0,1,1,0,0,0,0,0,0,1,0,1,1,1,0,0,0,0,0,0,0,0,1,1,0,1,0,0,0,0,0,1,0,0,0,1,0,0}, AUDIT_BROKER_CONVERSATION_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit Broker Conversation"}, // 158 - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,0,0,0,1,1,0,0,1,0,0,0,1,0,1,1,1,1,0,1,0,0,0,0,1,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0}, AUDIT_BROKER_LOGIN_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit Broker Login"}, // 159 - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,1,1,0,0,0,1,1,1,0,0,1,1,0,0,0,0,1,1,1,1,1,1,1,0,0,0,1,0,0,0,0,1,1,1,1,1,0,0,0,0,1,0,0,0,1,0,0}, BROKER_MESSAGE_DROP_EVENT_CLASS, TRCAT_BROKER, L"Broker:Message Undeliverable"}, // 160 - {{0,1,0,1,1,0,1,1,1,1,1,0,1,0,1,0,0,0,0,0,1,0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, BROKER_CORRUPTED_MSG_EVENT_CLASS, TRCAT_BROKER, L"Broker:Corrupted Message"}, // 161 - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,1,0,0,0,0,0,1,1,0,0,1,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1,0,0,1,1,1}, USER_ERROR_MSG_EVENT_CLASS, TRCAT_ERRORSANDWARNINGS, L"User Error Message", 5}, // 162 - {{0,1,0,1,1,0,1,1,1,1,1,0,1,1,1,1,1,1,1,0,0,1,1,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, BROKER_ACTIVATION_EVENT_CLASS, TRCAT_BROKER, L"Broker:Activation"}, // 163 - - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,7,7 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,0 - {{0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,1,0,1,1,1,1,1,0,0,0,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,1,0,0,0,1,0,0,0,1,0,0,0,1,0,1,0,0,1,1,1}, OBJECT_ALTER_EVENT_CLASS, TRCAT_OBJECTS, L"Object:Altered", 7}, // 164 - - // Perf trace - {{0,1,1,1,0,0,0,0,0,0,0,0,1,1,1,0,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,0,0,0,0,1,0,1,1,1,1}, STMT_PERFSTAT_EVENT_CLASS, TRCAT_PERFORMANCE, L"Performance statistics"}, // 165 - - {{0,1,0,1,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,1,0,0,0,1,1,1,1,0,0,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,1,0,0,0,0,1,1,0,1,1,0,1}, STMT_RECOMPILE_EVENT_CLASS, TRCAT_TSQL, L"SQL:StmtRecompile", 5}, // 166 - - {{0,1,0,1,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, DBMIRRORING_STATE_CHANGE_EVENT_CLASS, TRCAT_DATABASE, L"Database Mirroring State Change", 5}, //167 - - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6 - {{0,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,1,1,1,1,1,0,0,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, SHOWPLAN_XML_COMPILE_EVENT_CLASS, TRCAT_PERFORMANCE, L"Showplan XML For Query Compile", 21}, // 168 - {{0,0,1,1,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,1,1,1,1,1,0,0,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, SHOWPLAN_ALL_COMPILE_EVENT_CLASS, TRCAT_PERFORMANCE, L"Showplan All For Query Compile", 5}, // 169 - - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6 - {{0,1,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,1,0,1,0,1,0,0,1,1,1,1,0,0,0,0,1,1,0,1,0,0,1,1,1,1,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, SECURITY_GDR_SRV_SCOPE_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit Server Scope GDR Event", 3}, // 170 - {{0,1,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,1,0,1,0,1,0,0,1,1,1,1,0,0,0,0,1,1,0,1,0,0,1,1,1,1,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, SECURITY_GDR_SRV_OBJECT_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit Server Object GDR Event", 3}, // 171 - {{0,1,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,1,0,1,0,1,0,0,1,1,1,1,0,0,0,0,1,1,0,1,0,1,1,1,1,1,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, SECURITY_GDR_DB_OBJECT_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit Database Object GDR Event", 3}, // 172 - {{0,1,0,1,1,0,1,1,1,0,1,1,1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,1,1,1,0,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, SECURITY_SRV_OPERATION_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit Server Operation Event", 3}, // 173 - {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, TRACE_INVALID_EVENT, TRCAT_INVALID, NULL}, // free to use 174 - {{0,1,0,1,1,0,1,1,1,0,1,1,1,0,1,0,0,0,0,0,0,0,0,1,0,0,1,1,1,1,0,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, SECURITY_SRV_ALTERTRACE_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit Server Alter Trace Event", 3}, // 175 - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,1,1,1,0,0,0,0,1,1,0,1,0,0,1,1,0,0,0,1,1,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, SECURITY_SRV_OBJECT_MANAGE_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit Server Object Management Event", 5}, // 176 - {{0,1,0,1,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,1,1,1,0,0,0,0,1,1,0,1,0,1,1,1,1,1,0,1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, SECURITY_SRV_PRINCIPAL_MANAGE_EVENT_CLASS,TRCAT_SECURITYAUDIT, L"Audit Server Principal Management Event", 7}, // 177 - {{0,1,0,1,1,0,1,1,1,0,1,1,1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,1,1,1,0,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, SECURITY_DB_OPERATION_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit Database Operation Event", 3}, // 178 - {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, TRACE_INVALID_EVENT, TRCAT_INVALID, NULL}, // free to use 179 - {{0,1,1,1,1,0,1,1,1,0,1,1,1,0,1,0,0,0,0,1,0,0,0,1,0,0,1,1,1,1,0,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, SECURITY_DB_OBJECT_ACCESS_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit Database Object Access Event", 3}, // 180 - - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6 - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, PRE_XACTEVENT_BEGIN_TRAN_EVENT_CLASS, TRCAT_TRANSACTIONS, L"TM: Begin Tran starting"}, //181 - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,1,0,0,1,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, POST_XACTEVENT_BEGIN_TRAN_EVENT_CLASS, TRCAT_TRANSACTIONS, L"TM: Begin Tran completed"}, //182 - {{0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, PRE_XACTEVENT_PROMOTE_TRAN_EVENT_CLASS, TRCAT_TRANSACTIONS, L"TM: Promote Tran starting"}, //183 - {{0,0,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,1,0,0,1,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, POST_XACTEVENT_PROMOTE_TRAN_EVENT_CLASS,TRCAT_TRANSACTIONS, L"TM: Promote Tran completed"}, //184 - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,0,0,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, PRE_XACTEVENT_COMMIT_TRAN_EVENT_CLASS, TRCAT_TRANSACTIONS, L"TM: Commit Tran starting"}, //185 - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, POST_XACTEVENT_COMMIT_TRAN_EVENT_CLASS, TRCAT_TRANSACTIONS, L"TM: Commit Tran completed"}, //186 - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,0,0,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, PRE_XACTEVENT_ROLLBACK_TRAN_EVENT_CLASS,TRCAT_TRANSACTIONS, L"TM: Rollback Tran starting"}, //187 - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,1,0,0,1,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, POST_XACTEVENT_ROLLBACK_TRAN_EVENT_CLASS,TRCAT_TRANSACTIONS,L"TM: Rollback Tran completed"},//188 - - // More lock events - {{0,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,0,0,0,1,1,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,1,1,1,0,1,0,0,0,1,0,1}, LCK_TIMEOUT_NP_EVENT_CLASS, TRCAT_LOCKS, L"Lock:Timeout (timeout > 0)"}, // 189 - - // Online index operation events - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6 - {{0,0,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,1,1,0,1,0,1,1,0,0,0,1,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,1,0,0,0,1,0,1}, ONLINE_INDEX_PROGRESS_EVENT_CLASS, TRCAT_PROGRESS, L"Progress Report: Online Index Operation"}, // 190 - - - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6 - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, PRE_XACTEVENT_SAVE_TRAN_EVENT_CLASS, TRCAT_TRANSACTIONS, L"TM: Save Tran starting"}, //191 - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,1,0,0,1,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,1,0,0,0,0,0,1,0,0,0,1,0,1}, POST_XACTEVENT_SAVE_TRAN_EVENT_CLASS, TRCAT_TRANSACTIONS, L"TM: Save Tran completed"}, //192 - {{0,0,0,1,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,1,1,1,0,1,1,0,1,0,0,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,0,0,0,1,0,0}, QP_JOB_ERROR_EVENT_CLASS, TRCAT_ERRORSANDWARNINGS,L"Background Job Error"}, // 193 - - // More oledb events - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6 - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,1,0,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, OLEDB_PROVIDERINFORMATION_EVENT_CLASS, TRCAT_OLEDB, L"OLEDB Provider Information", 17}, // 194 - - {{0,1,0,1,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,1,0,0,0,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, BACKUP_TAPE_MOUNT_EVENT_CLASS, TRCAT_SERVER, L"Mount Tape", 5}, // 195 - - // SQLCLR events - {{0,1,0,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1}, SQLCLR_ASSEMBLY_LOAD_CLASS, TRCAT_CLR, L"Assembly Load", 5}, // 196 - {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, TRACE_INVALID_EVENT, TRCAT_INVALID, NULL}, // free to use 197 - - // XQuery events - {{0,1,0,1,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, XQUERY_STATIC_TYPE_EVENT_CLASS, TRCAT_TSQL, L"XQuery Static Type", 9}, // 198 - - // Query notification events - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6 - {{0,1,0,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,0,0,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, QN_SUBSCRIPTION_EVENT_CLASS, TRCAT_QNOTIF, L"QN: Subscription", 17}, // 199 - {{0,1,0,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,0,0,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, QN_TABLE_EVENT_CLASS, TRCAT_QNOTIF, L"QN: Parameter table", 17}, // 200 - {{0,1,0,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,0,0,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, QN_QUERYTEMPLATE_EVENT_CLASS, TRCAT_QNOTIF, L"QN: Template", 17}, // 201 - {{0,1,0,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,0,0,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, QN_DYNAMICS_EVENT_CLASS, TRCAT_QNOTIF, L"QN: Dynamics", 17}, // 202 - - // PSS diagnostics - {{0,1,0,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, PSS_QUERY_MEMGRANT_EVENT_CLASS, TRCAT_PSS_DIAG, L"Query memory grant", 0}, // 203 - {{0,1,0,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, PSS_PAGE_PREFETCH_EVENT_CLASS, TRCAT_PSS_DIAG, L"Page prefetch", 0}, // 204 - {{0,1,0,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, PSS_BATCH_SORT_EVENT_CLASS, TRCAT_PSS_DIAG, L"Batch sort", 0}, // 205 - {{0,1,0,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, PSS_EXCHNG_DOP_EVENT_CLASS, TRCAT_PSS_DIAG, L"Exchange DOP", 0}, // 206 - {{0,1,0,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, PSS_QE_VERBOSE_EVENT_CLASS, TRCAT_PSS_DIAG, L"QE verbose", 0}, // 207 - {{0,1,0,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, PSS_CXROWSET_EVENT_CLASS, TRCAT_PSS_DIAG, L"CXRowset", 0}, // 208 - - // matrix - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6 - {{0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,1,0,0,0,0,1,0,0,0,1,0,1}, MATRIXDB_QUERY_ACTIVATION_SESSION_CLASS, TRCAT_MATRIXDB, L"Remote Activation - Session Information", 0}, // 209 - {{0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,1,0,0,0,0,1,0,0,0,1,0,1}, MATRIXDB_QUERY_ACTIVATION_BATCH_AND_LEVEL_CLASS, TRCAT_MATRIXDB, L"Remote Activation - Batch And Level Information", 0}, // 210 - {{0,0,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1,0,0,0,1,0,0,0,1,0,1}, MATRIXDB_QUERY_ACTIVATION_STMT_AND_QUERY_CLASS, TRCAT_MATRIXDB, L"Remote Activation - Statement And Query Information", 0}, // 211 - - // QE bitmap - {{0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,1,0,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, BITMAP_WARNINGS_EVENT_CLASS, TRCAT_ERRORSANDWARNINGS, L"Bitmap Warning", 5}, // 212 - - // Suspect data page bitmap - {{0,0,0,1,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0}, DATABASE_SUSPECT_DATA_PAGE_EVENT_CLASS, TRCAT_ERRORSANDWARNINGS, L"Database Suspect Data Page", 1}, // 213 - - // RG: limit violation - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6 - {{0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,1,0,0,0,1,0,1}, SQLOS_CPU_LIMIT_VIOLATION_EVENT_CLASS, TRCAT_ERRORSANDWARNINGS, L"CPU threshold exceeded", 1}, // 214 - - // PreConnect event - {{0,0,0,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,1,0,0,0,1,1,1,0,0,0,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0}, PRECONNECT_PRE_EVENT_CLASS, TRCAT_SESSIONS, L"PreConnect:Starting"}, // 215 - {{0,0,0,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1,0,0,0,1,1,1,0,1,1,0,0,1,1,0,0,0,1,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1}, PRECONNECT_POST_EVENT_CLASS, TRCAT_SESSIONS, L"PreConnect:Completed"}, // 216 - - - // Plan guide successful bitmap - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0}, PLAN_GUIDE_SUCCESSFUL_EVENT_CLASS, TRCAT_PERFORMANCE, L"Plan Guide Successful", 0}, // 217 - - // Plan guide unsuccessful bitmap - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0}, PLAN_GUIDE_UNSUCCESSFUL_EVENT_CLASS, TRCAT_PERFORMANCE, L"Plan Guide Unsuccessful", 0}, // 218 - - // matrix transaction events - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5 - {{0,0,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,0,0,0,1,1,0,0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0}, MATRIXDB_TRANSACTION_START_END_CLASS, TRCAT_MATRIXDB, L"Matrix Transaction start and stop", 0}, - {{0,0,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0}, MATRIXDB_TRANSACTION_STATE_TRANSITION_CLASS, TRCAT_MATRIXDB, L"Matrix Transaction state transition", 0}, - {{0,1,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,0,0,0,1,1,0,0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0}, MATRIXDB_TRANSACTION_SHIPPING_CLASS, TRCAT_MATRIXDB, L"Matrix Transaction Context shipping", 0}, - - // TCM manager/agent communication - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5 - {{0,1,0,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,0,0,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,1,1,0,0,0,0,0,0,1,0,0,0,1,0}, MATRIXDB_TCM_EVENT_CLASS, TRCAT_MATRIXDB, L"TCM Age Message", 0}, - - // matrix enlistment - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5 - {{0,1,0,1,0,0,1,1,1,1,1,0,1,0,1,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,1,0,0,0,0,1,0,0,0,1,0}, MATRIXDB_CM_ENLISTMENT_CLASS, TRCAT_MATRIXDB, L"CM enlistment", 0}, - {{0,1,0,1,0,0,1,1,1,1,1,0,1,0,1,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,1,0,0,0,0,1,0,0,0,1,0}, MATRIXDB_CMA_ENLISTMENT_CLASS, TRCAT_MATRIXDB, L"CMA enlistment", 0}, - - // matrix error reporting events - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5 - {{0,1,0,0,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,1,1,0,0,0,1,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,1,0}, MATRIXDB_ERROR_EVENT_CLASS, TRCAT_MATRIXDB, L"Matrix Error", 0}, - - // matrix remote exchange and RPC - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5 - {{0,1,0,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0}, MATRIXDB_QUERY_REMOTE_EXCHANGE_EVENT_CLASS, TRCAT_MATRIXDB, L"Remote Exchange", 0}, - {{0,1,0,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0}, MATRIXDB_QUERY_RPC_EVENT_CLASS, TRCAT_MATRIXDB, L"RPC", 0}, - - // matrix clone refresh events - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5 - {{1,0,0,1,1,0,0,0,1,0,0,0,1,1,1,1,0,0,0,0,0,1,1,0,1,1,1,1,0,0,0,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,1,0,1,0,0,0,0,0,0,0,0,1,1}, MATRIXDB_CLONE_REFRESH_EVENT_CLASS, TRCAT_MATRIXDB, L"Clone Refresh - Execution Information", 0}, - // Matrix configuration manager and configuration agent - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5 - {{0,1,0,1,0,0,1,1,1,1,1,0,1,0,1,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,1,0,0,0,0,1,0,0,0,1,0}, MATRIXDB_CM_EVENT_CLASS, TRCAT_MATRIXDB, L"CM", 0}, - {{0,1,0,1,0,0,1,1,1,1,1,0,1,0,1,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,1,0,0,0,0,1,0,0,0,1,0}, MATRIXDB_CMA_EVENT_CLASS, TRCAT_MATRIXDB, L"CMA", 0}, - - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,1,0,0,0,0,0,1,1,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0}, XEVENT_EVENT_CLASS, TRCAT_MATRIXDB, L"XEvent", 0}, - - // Matrix clone transition events - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5 - {{0,0,0,1,1,0,0,0,1,0,0,0,1,0,1,1,0,0,0,0,0,1,1,0,0,1,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,0,0,0,0,0,0,0,1,0}, MATRIXDB_CLONE_TRANSITION_CLASS, TRCAT_MATRIXDB, L"Clone Transition", 0}, - - // matrix failure monitor and heartbeat (should this be a debug-only event?) - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5 - {{0,1,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,0,0,0,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,0,0,0,0,0,0,0,0,1,0}, MATRIXDB_CM_HEARTBEAT_EVENT_CLASS, TRCAT_MATRIXDB, L"Periodic health check status", 0}, - {{0,1,0,0,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,0,0,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,0,0,0,0,0,0,0,0,1,0}, MATRIXDB_CM_FAILURE_MONITOR_EVENT_CLASS, TRCAT_MATRIXDB, L"Brick failure status", 0}, - - // Fulltext Audit trace - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5 - {{0,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,1,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0}, AUDIT_FULLTEXT_EVENT_CLASS, TRCAT_SECURITYAUDIT, L"Audit Fulltext", 3}, - - //$$TRCEVENTINFO_END Do not remove this comment. - - // CloudDB Async Transport - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8 - {{0,1,0,0,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,1,1,1}, ASYNC_TRANSPORT_CONNECTION_ERROR_EVENT_CLASS, TRCAT_ASYNCTRANSPORT, L"Connection error", 0}, - {{0,1,0,0,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,1,1,1}, ASYNC_TRANSPORT_CONNECT_EVENT_CLASS, TRCAT_ASYNCTRANSPORT, L"Start connect destination", 0}, - {{0,0,0,0,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,1,1,1}, ASYNC_TRANSPORT_SEND_EVENT_CLASS, TRCAT_ASYNCTRANSPORT, L"Send next message", 0}, - {{0,0,0,0,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,1,1,1}, ASYNC_TRANSPORT_RECEIVED_EVENT_CLASS, TRCAT_ASYNCTRANSPORT, L"Received message", 0}, - {{0,0,0,0,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,1,1,1}, ASYNC_TRANSPORT_LOST_EVENT_CLASS, TRCAT_ASYNCTRANSPORT, L"Received lost message", 0}, - {{0,0,0,0,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,1,1,1}, ASYNC_TRANSPORT_CORRUPTED_EVENT_CLASS, TRCAT_ASYNCTRANSPORT, L"Received corrupted message", 0}, - {{0,0,0,0,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,1,1,1}, ASYNC_TRANSPORT_DISCONNECT_EVENT_CLASS, TRCAT_ASYNCTRANSPORT, L"Disconnected", 0}, - {{0,0,1,0,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,1,1,1}, ASYNC_TRANSPORT_DEQUEUE_EVENT_CLASS, TRCAT_ASYNCTRANSPORT, L"Dequeue message for dispatch", 0}, - {{0,1,0,0,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,1,1,1}, ASYNC_TRANSPORT_STATUS_EVENT_CLASS, TRCAT_ASYNCTRANSPORT, L"Transport stream status change", 0}, - - // CloudDB SE replication - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8 - {{0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0}, SEREPL_CAPTURE_ENLISTED_EVENT_CLASS, TRCAT_SEREPL, L"Primary: Started replicated transaction", 0}, - {{0,0,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0}, SEREPL_CAPTURE_COMMIT_WAIT_EVENT_CLASS, TRCAT_SEREPL, L"Primary: Start commit", 0}, - {{0,0,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0}, SEREPL_CAPTURE_COMMIT_FLUSHED_EVENT_CLASS, TRCAT_SEREPL, L"Primary: Local log flushed", 0}, - {{0,0,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0}, SEREPL_CAPTURE_COMMIT_ACKED_EVENT_CLASS, TRCAT_SEREPL, L"Primary: Quorum worth of acks received", 0}, - {{0,0,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0}, SEREPL_APPLY_COMMIT_WAIT_EVENT_CLASS, TRCAT_SEREPL, L"Secondary: Start commit", 0}, - {{0,0,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0}, SEREPL_APPLY_COMMIT_FLUSHED_EVENT_CLASS, TRCAT_SEREPL, L"Secondary: Local log flushed", 0}, - {{0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0}, SEREPL_APPLY_ENLISTED_EVENT_CLASS, TRCAT_SEREPL, L"Secondary: Started replicated transaction", 0}, - - // Async transport - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8 - {{0,1,1,0,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,1,0,1,1,1}, ASYNC_TRANSPORT_MESSAGE_CONTENT_CLASS, TRCAT_ASYNCTRANSPORT, L"Message Content", 0}, - - // LPM - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,7,7,7 - //0,1, 2, 3, 4, 5,6, 7, 8, 9,0, 1, 2,3, 4, 5, 6, 7, 8,9, 0,1, 2, 3,4, 5, 6, 7, 8, 9,0, 1,2, 3,4, 5, 6, 7, 8, 9,0, 1, 2, 3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2 - {{0,0,1,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,1,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,1,0,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0}, CLOUD_PM_REMOVE_PARTITION_EVENT_CLASS, TRCAT_CLOUD_PM, L"Remove partition", 0}, - {{0,0,1,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,1,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,1,0,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0}, CLOUD_PM_DELETE_PARTITION_EVENT_CLASS, TRCAT_CLOUD_PM, L"Mark partition for delete", 0}, - {{0,0,1,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,1,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,1,0,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0}, CLOUD_PM_BECOME_NOTHING_EVENT_CLASS, TRCAT_CLOUD_PM, L"Make partition nothing", 0}, - {{0,0,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,1,0,1,0,0,1,0,0,0,1,1,0,0,0,0,0,0,1,1,0,1,0,1,0,0,0,1,1,1,0,0,1,0,0,0,0,1,0,0,1,0,1,1,0,1,1,0,1}, CLOUD_PM_ADD_SECONDARY_EVENT_CLASS, TRCAT_CLOUD_PM, L"Add secondary", 0}, - {{0,0,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,1,0,1,0,0,1,0,0,0,1,1,0,0,0,0,0,0,1,1,0,1,0,1,0,0,0,1,1,1,0,0,1,0,0,0,0,1,0,0,1,0,1,1,0,1,1,0,1}, CLOUD_PM_CHANGE_SECONDARY_EVENT_CLASS, TRCAT_CLOUD_PM, L"Change secondary", 0}, - {{0,0,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,1,0,1,0,0,1,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0}, CLOUD_PM_BECOME_PRIMARY_EVENT_CLASS, TRCAT_CLOUD_PM, L"Become the primary", 0}, - {{0,0,1,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,1,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,1,0,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0,1,1,0,1}, CLOUD_PM_ADD_PARTITION_EVENT_CLASS, TRCAT_CLOUD_PM, L"Add partition", 0}, - {{0,0,1,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,1,0,0,0,1,1,0,0,0,0,0,0,1,1,0,1,0,1,0,0,0,1,1,1,0,0,1,0,0,0,0,1,0,0,1,0,1,1,0,1,1,0,1}, CLOUD_PM_REMOVE_SECONDARY_EVENT_CLASS, TRCAT_CLOUD_PM, L"Remove secondary", 0}, - - // LPM continued - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6 - //0, 1,2, 3,4, 5, 6, 7,8, 9, 0, 1, 2,3, 4,5, 6, 7, 8, 9,0, 1, 2, 3, 4, 5, 6,7, 8, 9,0, 1, 2, 3,4, 5, 6, 7, 8, 9,0,1, 2, 3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8 - {{0,0,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,1,0,1,0,0,1,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,1,0,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0}, CLOUD_PM_START_NEW_EPOCH_EVENT_CLASS, TRCAT_CLOUD_PM, L"Start new epoch", 0}, - - // Fabric-Db pairing - // - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8 - {{0,1,0,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0}, CLOUD_FABRIC_DB_PAIRING, TRCAT_CLOUDMGMT, L"Fabric node paired with db", 0}, - {{0,1,0,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0}, CLOUD_FABRIC_DB_UN_PAIRING, TRCAT_CLOUDMGMT, L"Fabric node paired with db died.", 0}, - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1,0,0}, WORKER_WAIT_STATS_EVENT_CLASS, TRCAT_ERRORSANDWARNINGS, L"Attention wait stats", 0}, - - - // LPM continued - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,7,7,7 - //0,1, 2, 3, 4,5, 6, 7, 8, 9,0, 1, 2,3,4, 5, 6, 7, 8, 9, 0, 1,2, 3,4, 5, 6,7, 8, 9, 0, 1, 2,3, 4, 5, 6,7, 8, 9,0, 1, 2, 3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2 - {{0,0,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,1,0,1,0,0,1,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0}, CLOUD_PM_PARTITION_QUORUM_LOSS_EVENT_CLASS, TRCAT_CLOUD_PM, L"Partition quorum loss", 0}, - {{0,0,1,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,1,0,0,0,1,1,0,0,1,0,0,0,1,1,0,1,1,1,0,0,0,1,1,1,0,0,1,0,0,0,0,1,0,0,1,0,1,1,0,1,1,0,1}, CLOUD_PM_KILL_SECONDARY_EVENT_CLASS, TRCAT_CLOUD_PM, L"Kill secondary", 0}, - {{0,0,1,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,1,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,1,0,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0}, CLOUD_PM_KILL_USER_TRANSACTIONS_EVENT_CLASS, TRCAT_CLOUD_PM, L"Kill user transactions", 0}, - {{0,0,1,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,1,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,1,0,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0}, CLOUD_PM_DELETE_PARTITION_CONTENT_EVENT_CLASS, TRCAT_CLOUD_PM, L"Delete partition rows", 0}, - {{0,0,1,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,1,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,1,0,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0}, CLOUD_PM_KILL_PRIMARY_EVENT_CLASS, TRCAT_CLOUD_PM, L"Kill primary", 0}, - {{0,0,1,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,1,0,0,0,1,1,0,0,0,0,0,0,1,1,0,1,0,1,0,0,0,1,1,1,0,0,1,0,0,0,0,1,0,0,1,0,1,1,0}, CLOUD_PM_BECOME_SECONDARY_EVENT_CLASS, TRCAT_CLOUD_PM, L"Become secondary", 0}, - {{0,0,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,1,0,1,0,0,1,0,0,0,1,1,0,0,1,0,0,0,1,1,0,1,1,1,0,0,0,1,1,1,0,0,1,0,0,0,0,1,0,0,1,0,1,1,0,1,1,0,1}, CLOUD_PM_SECONDARY_CATCHUP_REQUEST_EVENT_CLASS, TRCAT_CLOUD_PM, L"Secondary catchup request", 0}, - {{0,0,1,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,0,0,1,0,1,0,0,1,0,0,0,1,1,0,0,1,0,0,0,1,1,0,1,1,1,0,0,0,1,1,1,0,0,1,0,0,0,0,1,0,0,1,0,1,1,0,1,1,0,1}, CLOUD_PM_SECONDARY_CATCHUP_COMPLETE_EVENT_CLASS, TRCAT_CLOUD_PM, L"Secondary catchup complete", 0}, - {{0,0,1,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,1,0,0,0,1,1,0,0,1,0,0,0,1,1,0,1,1,1,0,0,0,1,1,1,0,0,1,0,0,0,0,1,0,0,1,0,1,1,0,1,1,0,1}, CLOUD_PM_START_SECONDARY_COPY_EVENT_CLASS, TRCAT_CLOUD_PM, L"Start copy scan to secondary", 0}, - {{0,0,1,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,1,0,1,0,0,1,0,0,0,1,1,0,0,1,0,0,0,1,1,0,1,1,1,0,0,0,1,1,1,0,0,1,0,0,0,0,1,0,0,1,0,1,1,0,1,1,0,1}, CLOUD_PM_END_SECONDARY_COPY_EVENT_CLASS, TRCAT_CLOUD_PM, L"End copy scan to secondary", 0}, - {{0,0,1,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,1,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,1,0,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0}, CLOUD_PM_START_COPY_FROM_PRIMARY_EVENT_CLASS, TRCAT_CLOUD_PM, L"Start copy from primary", 0}, - {{0,0,1,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,1,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,1,0,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0}, CLOUD_PM_START_CATCHUP_FROM_PRIMARY_EVENT_CLASS, TRCAT_CLOUD_PM, L"Start catchup from primary", 0}, - {{0,0,1,1,1,0,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0,0,1,0,0,1,0,1,0,0,1,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0}, CLOUD_PM_CATCHUP_FROM_PRIMARY_COMPLETE_EVENT_CLASS, TRCAT_CLOUD_PM, L"Catchup from primary complete", 0}, - {{0,0,1,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,1,0,0,0,1,1,0,0,1,0,0,0,1,1,0,1,1,1,0,0,0,1,1,1,0,0,1,0,0,0,0,1,0,0,1,0,1,1,0,1,1,0,1}, CLOUD_PM_SECONDARY_FAILURE_REPORT_EVENT_CLASS, TRCAT_CLOUD_PM, L"Secondary failure report", 0}, - {{0,0,1,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,1,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,1,0,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0}, CLOUD_PM_PRIMARY_FAILURE_REPORT_EVENT_CLASS, TRCAT_CLOUD_PM, L"Primary failure report", 0}, - {{0,0,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,1,0,0,0,0,1,0,0,1,0,1,0,0,1,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0,1,1,0,1}, CLOUD_PM_RETURN_CSN, TRCAT_CLOUD_PM, L"Return CSN", 0}, - {{0,0,1,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,1,0,0,0,1,1,0,0,1,0,0,0,1,1,0,1,1,1,0,0,0,1,1,1,0,0,1,0,0,0,0,1,0,0,1,0,1,1,0,1,1,0,1}, CLOUD_PM_START_SECONDARY_PERSISTENT_CATCHUP_EVENT_CLASS, TRCAT_CLOUD_PM, L"Start log scan to secondary", 0}, - {{0,0,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,1,0,0,0,0,1,0,0,1,0,1,0,0,1,0,0,0,1,1,0,0,1,0,0,0,1,1,0,1,1,1,0,0,0,1,1,1,0,0,1,0,0,0,0,1,0,0,1,0,1,1,0,1,1,0,1}, CLOUD_PM_END_SECONDARY_PERSISTENT_CATCHUP_EVENT_CLASS, TRCAT_CLOUD_PM, L"End log scan to secondary", 0}, - {{0,0,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,1,0,0,0,0,1,0,0,1,0,1,0,0,1,0,0,0,1,1,0,0,1,0,0,0,1,1,0,1,1,1,0,0,0,1,1,1,0,1,1,0,0,0,0,1,0,0,1,0,1,1,0,1,1,0,1}, CLOUD_PM_ESTABLISH_SECONDARY_PERSISTENT_CATCHUP_EVENT_CLASS, TRCAT_CLOUD_PM, L"Establish log scan start", 0}, - - // SERepl - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7 - {{0,1,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,1,0,1,0,0,0,1,1,0,0,1,1,0,0,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,0,1,0,0,0,1,0,0,0,1,0,1,1,0}, SEREPL_EXCEPTION_EVENT_CLASS, TRCAT_SEREPL, L"Background exception", 0}, - - - // AT - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,7,7,7 - //0,1, 2, 3,4, 5, 6, 7, 8, 9,0, 1, 2, 3,4, 5, 6, 7, 8,9, 0, 1,2, 3, 4,5, 6, 7,8, 9, 0,1, 2, 3, 4, 5, 6,7, 8, 9, 0,1, 2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2 - {{0,1,0,1,1,0,1,1,1,1,1,0,1,0,1,0,0,0,0,0,0,1,0,0,0,1,1,1,0,0,0,1,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0}, ASYNC_TRANSPORT_CONNECTION_EVENT_CLASS, TRCAT_ASYNCTRANSPORT, L"Async Transport connection state change"}, - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,0,0,0,1,1,0,0,1,0,0,0,1,0,1,1,1,1,0,1,0,0,0,0,1,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0}, ASYNC_TRANSPORT_LOGIN_EVENT_CLASS, TRCAT_ASYNCTRANSPORT, L"Audit Async Transport Login"}, - {{0,0,1,1,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,1,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,1,0,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0}, CLOUD_PM_BECOME_FORWARDER_PENDING_EVENT_CLASS, TRCAT_CLOUD_PM, L"Become forwarder pending", 0}, - {{0,0,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,1,0,0,0,0,1,0,0,1,0,1,0,0,1,0,0,0,1,1,0,0,0,0,0,0,1,1,0,1,0,1,0,0,0,1,1,1,0,1,1,0,0,0,0,1,0,0,1,0,1,1,0,1,1,0,1}, CLOUD_PM_BECOME_FORWARDER_EVENT_CLASS, TRCAT_CLOUD_PM, L"Become forwarder", 0}, - {{0,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,0,0,0,0,0,0,1,0,0,0,1,1,0,0,1,0,0,0,1,1,1,1,0,0,0,0,1,1,0,1,0,1,0,0,0,1,1,1,0,0,1,0,0,0,0,1,0,0,1,0,1,1,0,1,1,1,1}, SFW_STMT_BLOCK_EVENT_CLASS, TRCAT_TSQL, L"Statement blocked", 0}, - {{0,0,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,1,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,1,0,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0}, CLOUD_PM_SET_PARTITION_COMMIT_MODE_EVENT_CLASS, TRCAT_CLOUD_PM, L"Set partition commit mode", 0}, - - {{0,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,1,0,0,1,0,1,0,0,1,0,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,1,0,0,0,0,0,0,0,1,0,1,1,0}, SEREPL_SECONDARY_WORKER_LONG_SUSPEND_EVENT_CLASS,TRCAT_SEREPL, L"Secondary worker long suspending", 0}, - - // LPM continued - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,7,7,7 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2 - {{0,0,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,1,0,1,0,0,1,0,0,0,1,1,0,0,0,0,0,0,1,1,0,1,0,1,0,0,0,1,1,1,0,0,1,0,0,0,0,1,0,0,1,0,1,1,0,1,1,0,1}, CLOUD_PM_DUMMY_TRANSACTION_EVENT_CLASS, TRCAT_CLOUD_PM, L"Dummy transaction", 0}, - {{0,0,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,1,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,1,0,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0}, CLOUD_PM_SET_PARTITION_LOCK_MODE_EVENT_CLASS, TRCAT_CLOUD_PM, L"Set partition lock mode", 0}, - {{0,0,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,1,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,1,0,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0}, CLOUD_PM_SET_PARTITION_PREPARE_FULL_COMMIT_MODE_EVENT_CLASS, TRCAT_CLOUD_PM, L"Set partition prepare full commit mode", 0}, - {{0,0,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,1,0,0,1,0,1,0,0,1,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,1,0,0,0,1,0,0,0,0,0,0,0,1,0,1,1,0}, CLOUD_PM_SET_PARTITION_THROTTLING_MODE_EVENT_CLASS, TRCAT_CLOUD_PM, L"Set partition throttling mode", 0}, - - // ClusterProxy - {{0,1,0,1,1,0,1,1,1,1,1,0,1,0,1,0,0,0,0,0,0,1,0,0,0,1,1,1,0,0,0,1,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0}, CLUSTER_PROXY_CONNECTION_EVENT_CLASS, TRCAT_ASYNCTRANSPORT, L"Cluster Proxy connection state change"}, - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,0,0,0,1,1,0,0,1,0,0,0,1,0,1,1,1,1,0,1,0,0,0,0,1,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0}, CLUSTER_PROXY_LOGIN_EVENT_CLASS, TRCAT_ASYNCTRANSPORT, L"Cluster Proxy login"}, - - // LPM continued - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,7,7,7 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2 - {{0,0,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,1,0,0,0,0,1,0,0,1,0,1,0,0,1,0,0,0,1,1,0,0,1,0,0,0,1,1,0,1,1,1,0,0,0,1,1,1,0,1,1,0,0,0,0,1,0,0,1,0,1,1,0,1,1,0,1}, CLOUD_PM_PREFER_COPY_OVER_CATCHUP_EVENT_CLASS, TRCAT_CLOUD_PM, L"Prefer copy over persisted catchup", 0}, - - // DB Seeding - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,7,7,7 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2 - {{0,1,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,1,0,1,0,1,1,0,1,1,1,1,0,0,1,0,0,0,1,1,0,0,1,0,1,1,1,1,0,1,1,1,0,1,0,1,1,1,1,1,1,0,0,0,1,1,0,1,1,0,1,1,1,1,1,0,1}, CLOUD_PM_DBSEEDING_BACKUP_PROGRESS_EVENT_CLASS, TRCAT_CLOUD_PM, L"DBSeeding Backup Progress", 0}, - {{0,1,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,1,0,1,0,1,1,0,1,1,1,1,0,0,1,0,0,0,1,1,0,0,1,0,1,1,1,1,0,1,1,1,0,1,0,1,1,1,1,1,1,0,0,0,1,1,0,1,1,0,1,1,1,1,1,0,1}, CLOUD_PM_DBSEEDING_RESTORE_PROGRESS_EVENT_CLASS, TRCAT_CLOUD_PM, L"DBSeeding Restore Progress", 0}, - {{0,1,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,1,0,1,0,1,1,0,1,1,1,1,0,0,1,0,0,0,1,1,0,0,1,0,1,1,1,1,0,1,1,1,0,1,0,1,1,1,1,1,1,0,0,0,1,1,0,1,1,0,1,1,1,1,1,0,1}, CLOUD_PM_DBSEEDING_VDICLIENT_EVENT_CLASS, TRCAT_CLOUD_PM, L"DBSeeding VDI Client Progress", 0}, - {{0,1,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,1,0,1,0,1,1,0,1,1,1,1,0,0,1,0,0,0,1,1,0,0,1,0,1,1,1,1,0,1,1,1,0,1,0,1,1,1,1,1,1,0,0,0,1,1,0,1,1,0,1,1,1,1,1,0,1}, CLOUD_PM_DBSEEDING_INITIATE_BACKUP_EVENT_CLASS, TRCAT_CLOUD_PM, L"DBSeeding Initiate Backup", 0}, - {{0,1,1,1,1,0,1,1,1,1,1,1,1,0,1,0,0,1,0,1,0,1,1,0,1,1,1,1,0,0,1,0,0,0,1,1,0,0,1,0,1,1,1,1,0,1,1,1,0,1,0,1,1,1,1,1,1,0,0,0,1,1,0,1,1,0,1,1,1,1,1,0,1}, CLOUD_PM_DBSEEDING_INITIATE_RESTORE_EVENT_CLASS, TRCAT_CLOUD_PM, L"DBSeeding Initiate Restore", 0}, - - // Global Transactions - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6 - {{0,1,0,1,1,0,1,1,1,1,1,0,1,0,1,0,0,0,0,0,0,1,0,0,0,1,1,1,0,0,0,1,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0}, GLOBAL_TRANSACTIONS_CONNECTION_EVENT_CLASS, TRCAT_ASYNCTRANSPORT, L"Global Transactions connection state change"}, - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,0,0,0,1,1,0,0,1,0,0,0,1,0,1,1,1,1,0,1,0,0,0,0,1,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0}, - AUDIT_GLOBAL_TRANSACTIONS_LOGIN_EVENT_CLASS,TRCAT_ASYNCTRANSPORT, L"Global Transactions login"}, - - // Storage - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6 - {{0,1,0,1,1,0,1,1,1,1,1,0,1,0,1,0,0,0,0,0,0,1,0,0,0,1,1,1,0,0,0,1,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0}, STORAGE_CONNECTION_EVENT_CLASS, TRCAT_ASYNCTRANSPORT, L"Storage connection state change"}, - {{0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,0,0,0,1,1,0,0,1,0,0,0,1,0,1,1,1,1,0,1,0,0,0,0,1,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,1,0,0}, - AUDIT_STORAGE_LOGIN_EVENT_CLASS,TRCAT_ASYNCTRANSPORT, L"Storage login"}, - - // DEVNOTE!!!!!! - // ALL NEW RETAIL EVENTS MUST BE ADDED ABOVE THIS COMMENT!!!!! - // ALL NEW TEMP EVENTS MUST BE ADDED BELLOW THIS COMMENT!!!!! - -#ifndef GOLDEN_BITS - // Temp (non GOLDEN_BITS) trace events - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6 - {{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, TEMP_SCALABILITY_TEST_EVENT_CLASS, TRCAT_TEMP, L"Scalabity Test Event", 0}, -#endif - - // DEVNOTE!!!!!! - // ALL NEW DEBUG EVENTS MUST BE ADDED BELLOW THIS COMMENT!!!!! - -#ifdef DEBUG - // Debug only trace events - //0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6 - //0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6 - {{0,1,0,0,0,0,1,1,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1,0,0,0,1,0,0,0,1,0,0}, DBG_ONLY_TEST_EVENT_CLASS, TRCAT_DBG_ONLY, L"Debug Only Test Event", 0}, -#endif DEBUG -}; - - - - -// Make sure array index matches column id -TRACE_COLUMN_INFO g_rgTraceColumnInfo[] = -{ - //$$TRCCOLUMNINFO_START Do not remove this comment. - - {0 , TRACE_I4, 0, 0, 0, NULL, false, false}, - {TRACE_COLUMN_TEXT, TRACE_NTEXT, 1, 0, 0, L"TextData", false, false}, - {TRACE_COLUMN_BINARYDATA, TRACE_BYTES, 1, 0, 0, L"BinaryData", false, false}, - {TRACE_COLUMN_DBID, TRACE_I4, 1, 0, 0, L"DatabaseID", false, false}, - {TRACE_COLUMN_XACTID, TRACE_I8, 1, 0, 0, L"TransactionID", false, false}, - {TRACE_COLUMN_LINENO, TRACE_I4, 1, 0, 0, L"LineNumber", false, false}, - {TRACE_COLUMN_NTUSERNAME, TRACE_WSTR, 1, 1, 0, L"NTUserName", true, false}, - {TRACE_COLUMN_NTDOMAIN, TRACE_WSTR, 1, 1, 0, L"NTDomainName", true, false}, - {TRACE_COLUMN_HOST, TRACE_WSTR, 1, 1, 0, L"HostName", true, false}, - {TRACE_COLUMN_CPID, TRACE_I4, 1, 1, 0, L"ClientProcessID", true, false}, - {TRACE_COLUMN_APPNAME, TRACE_WSTR, 1, 1, 0, L"ApplicationName", true, false}, - {TRACE_COLUMN_LOGINNAME, TRACE_WSTR, 1, 1, 0, L"LoginName", true, false}, - {TRACE_COLUMN_SPID, TRACE_I4, 1, 0, 1, L"SPID", true, true}, - {TRACE_COLUMN_DURATION, TRACE_I8, 1, 0, 0, L"Duration", false, false}, - {TRACE_COLUMN_STARTTIME, TRACE_DATETIME, 1, 0, 0, L"StartTime", false, true}, - {TRACE_COLUMN_ENDTIME, TRACE_DATETIME, 1, 0, 0, L"EndTime", false, false}, - {TRACE_COLUMN_READS, TRACE_I8, 1, 0, 0, L"Reads", false, false}, - {TRACE_COLUMN_WRITES, TRACE_I8, 1, 0, 0, L"Writes", false, false}, - {TRACE_COLUMN_CPU, TRACE_I4, 1, 0, 0, L"CPU", false, false}, - {TRACE_COLUMN_PERMISSIONS, TRACE_I8, 1, 0, 0, L"Permissions", false, false}, - {TRACE_COLUMN_SEVERITY, TRACE_I4, 1, 0, 0, L"Severity", false, false}, - {TRACE_COLUMN_SUBCLASS, TRACE_I4, 1, 0, 0, L"EventSubClass", false, false}, - {TRACE_COLUMN_OBJID, TRACE_I4, 1, 0, 0, L"ObjectID", false, false}, - {TRACE_COLUMN_SUCCESS, TRACE_I4, 1, 0, 0, L"Success", false, false}, - {TRACE_COLUMN_INDID, TRACE_I4, 1, 0, 0, L"IndexID", false, false}, - {TRACE_COLUMN_INTDATA, TRACE_I4, 1, 0, 0, L"IntegerData", false, false}, - {TRACE_COLUMN_SERVER, TRACE_WSTR, 0, 1, 0, L"ServerName", false, false}, - {TRACE_COLUMN_CLASS, TRACE_I4, 0, 0, 0, L"EventClass", false, true}, - {TRACE_COLUMN_OBJTYPE, TRACE_I4, 1, 0, 0, L"ObjectType", false, false}, - {TRACE_COLUMN_NESTLEVEL, TRACE_I4, 1, 0, 0, L"NestLevel", false, false}, - {TRACE_COLUMN_STATE, TRACE_I4, 1, 0, 0, L"State", false, false}, - {TRACE_COLUMN_ERROR, TRACE_I4, 1, 0, 0, L"Error", false, false}, - {TRACE_COLUMN_MODE, TRACE_I4, 1, 0, 0, L"Mode", false, false}, - {TRACE_COLUMN_HANDLE, TRACE_I4, 1, 0, 0, L"Handle", false, false}, - {TRACE_COLUMN_OBJNAME, TRACE_WSTR, 1, 0, 0, L"ObjectName", false, false}, - {TRACE_COLUMN_DBNAME, TRACE_WSTR, 1, 0, 0, L"DatabaseName", false, false}, - {TRACE_COLUMN_FILENAME, TRACE_WSTR, 1, 0, 0, L"FileName", false, false}, - {TRACE_COLUMN_OWNERNAME, TRACE_WSTR, 1, 0, 0, L"OwnerName", false, false}, - {TRACE_COLUMN_ROLENAME, TRACE_WSTR, 1, 0, 0, L"RoleName", false, false}, - {TRACE_COLUMN_TARGET_USERNAME, TRACE_WSTR, 1, 0, 0, L"TargetUserName", false, false}, - {TRACE_COLUMN_DBUSER, TRACE_WSTR, 1, 0, 0, L"DBUserName", false, false}, - {TRACE_COLUMN_LOGINSID, TRACE_BYTES, 1, 1, 0, L"LoginSid", true, false}, - {TRACE_COLUMN_TARGET_LOGINNAME, TRACE_WSTR, 1, 0, 0, L"TargetLoginName", false, false}, - {TRACE_COLUMN_TARGET_LOGINSID, TRACE_BYTES, 1, 0, 0, L"TargetLoginSid", false, false}, - {TRACE_COLUMN_COLPERMS, TRACE_I4, 1, 0, 0, L"ColumnPermissions", false, false}, - {TRACE_COLUMN_LINKEDSERVERNAME, TRACE_WSTR, 1, 0, 0, L"LinkedServerName", false, false}, - {TRACE_COLUMN_PROVIDERNAME, TRACE_WSTR, 1, 0, 0, L"ProviderName", false, false}, //$$ Can this be repeated? - {TRACE_COLUMN_METHODNAME, TRACE_WSTR, 1, 0, 0, L"MethodName", false, false}, - {TRACE_COLUMN_ROWCOUNTS, TRACE_I8, 1, 0, 0, L"RowCounts", false, false}, - {TRACE_COLUMN_BATCHID, TRACE_I4, 1, 0, 0, L"RequestID", false, false}, - {TRACE_COLUMN_XACTSEQNO, TRACE_I8, 1, 0, 0, L"XactSequence", false, false}, - {TRACE_COLUMN_EVENTSEQ, TRACE_I8, 0, 0, 0, L"EventSequence", false, true}, - {TRACE_COLUMN_BIGINT1, TRACE_I8, 1, 0, 0, L"BigintData1", false, false}, - {TRACE_COLUMN_BIGINT2, TRACE_I8, 1, 0, 0, L"BigintData2", false, false}, - {TRACE_COLUMN_GUID, TRACE_GUID, 1, 0, 0, L"GUID", false, false}, - {TRACE_COLUMN_INTDATA2, TRACE_I4, 1, 0, 0, L"IntegerData2", false, false}, - {TRACE_COLUMN_OBJID2, TRACE_I8, 1, 0, 0, L"ObjectID2", false, false}, - {TRACE_COLUMN_TYPE, TRACE_I4, 1, 0, 0, L"Type", false, false}, - {TRACE_COLUMN_OWNERID, TRACE_I4, 1, 0, 0, L"OwnerID", false, false}, - {TRACE_COLUMN_PARENTNAME, TRACE_WSTR, 1, 0, 0, L"ParentName", false, false}, - {TRACE_COLUMN_ISSYSTEM, TRACE_I4, 1, 1, 0, L"IsSystem", false, false}, - {TRACE_COLUMN_OFFSET, TRACE_I4, 1, 0, 0, L"Offset", false, false}, - {TRACE_COLUMN_SOURCE_DBID, TRACE_I4, 1, 0, 0, L"SourceDatabaseID", false, false}, - {TRACE_COLUMN_SQLHANDLE, TRACE_BYTES, 1, 0, 0, L"SqlHandle", false, false}, - {TRACE_COLUMN_SESSLOGINNAME, TRACE_WSTR, 1, 0, 0, L"SessionLoginName", false, true}, - {TRACE_COLUMN_PLANHANDLE, TRACE_BYTES, 1, 0, 0, L"PlanHandle", false, false}, - {TRACE_COLUMN_GROUPID, TRACE_I4, 1, 0, 0, L"GroupID", true, false}, - //$$TRCCOLUMNINFO_END Do not remove this comment. - {TRACE_COLUMN_CONTEXT_INFO, TRACE_BYTES, 1, 0, 0, L"ContextInfo", false, false}, - {TRACE_COLUMN_GUID2, TRACE_GUID, 1, 0, 0, L"GUID2", false, false}, - {TRACE_COLUMN_PARTITION_LOW_KEY, TRACE_BYTES, 1, 0, 0, L"PartitionId", false, false}, - {TRACE_COLUMN_PARTITION_TABLE_GROUP, TRACE_WSTR,1, 0, 0, L"PartitionTableGroup", false, false}, - {TRACE_COLUMN_PHYSICAL_DBNAME, TRACE_WSTR, 1, 0, 0, L"PhysicalDBName", false, false}, - {TRACE_COLUMN_PARTITION_APP_NAME, TRACE_WSTR, 1, 0, 0, L"PartitionAppName", false, false}, -}; - diff --git a/SmoBuild/DisableStrongName.ps1 b/SmoBuild/DisableStrongName.ps1 deleted file mode 100644 index 1fbce54c..00000000 --- a/SmoBuild/DisableStrongName.ps1 +++ /dev/null @@ -1,18 +0,0 @@ -#This script is FOR TEST ONLY. It bypasses StrongName verification -#for SQL assemblies, since they are delay signed the installer -#will fail on non-signed builds unless we add the exceptions. - - -#List of SQL public keys -$publicKeys = @( - "*,31bf3856ad364e35", - "*,36e4ce08b8ecfb17", - "*,89845dcd8080cc91", - "*,b03f5f7f11d50a3a", - "*,ae41e2615877eb90", - "*,b77a5c561934e089") - -$publicKeys | % { - New-Item -Path "HKLM:\SOFTWARE\Microsoft\StrongName\Verification\$_" -Force | Out-Null - New-Item -Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\StrongName\Verification\$_" -Force | Out-Null -} \ No newline at end of file diff --git a/SmoBuild/SqlClientReference.props b/SmoBuild/SqlClientReference.props index 26407631..319983db 100644 --- a/SmoBuild/SqlClientReference.props +++ b/SmoBuild/SqlClientReference.props @@ -1,22 +1,7 @@ - - - - - - - - - - - - - - true diff --git a/SmoBuild/Version.props b/SmoBuild/Version.props index 7181f87d..31ec6e17 100644 --- a/SmoBuild/Version.props +++ b/SmoBuild/Version.props @@ -1,20 +1,41 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + + 1 18 + 0 100 - $(LocalBuildVersion) - $(LocalBuildRevision) - 0 - 0 - $(AssemblyMajorVersion).$(AssemblyMinorVersion).$(AssemblyBuildVersion).$(AssemblyBuildRevision) + + $(PackageMajorVersionIncrement) + + 0 + $(AssemblyMajorVersion).$(AssemblyMinorVersion).$(AssemblyBuildVersion).$(AssemblyRevisionVersion) $(AssemblyFileVersion) $(AssemblyFileVersion) $(AssemblyFileVersion) - 0 - $(AssemblyMajorVersion)$(PackageMajorVersionIncrement).$(AssemblyBuildVersion).$(AssemblyBuildRevision) + $(AssemblyMajorVersion)$(PackageMajorVersionIncrement).$(AssemblyRevisionVersion).0 $(AssemblyMajorVersion).$(AssemblyMinorVersion).0.0 \ No newline at end of file diff --git a/packages/.gitkeep b/docs/YOURGITHUB similarity index 100% rename from packages/.gitkeep rename to docs/YOURGITHUB diff --git a/examples/YOURGITHUB b/examples/YOURGITHUB new file mode 100644 index 00000000..e69de29b diff --git a/global.json b/global.json index a7cb916c..d14fbe27 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "8.0.415", + "version": "8.0.417", "rollForward": "latestMinor" }, "msbuild-sdks": { diff --git a/init.cmd b/init.cmd index e7db7abe..bb1d5bb2 100644 --- a/init.cmd +++ b/init.cmd @@ -23,41 +23,48 @@ doskey root=pushd %BASEDIR%$* doskey src=pushd %BASEDIR%src\$* doskey out=pushd %BASEDIR%bin\$* doskey bin=pushd %BASEDIR%bin\$* +doskey ci=pushd %BASEDIR%src\Microsoft\SqlServer\Management\ConnectionInfo doskey prod=pushd %BASEDIR%src\Microsoft\SqlServer\Management\$* doskey sfc=pushd %BASEDIR%src\Microsoft\SqlServer\Management\Sdk\sfc doskey smo=pushd %BASEDIR%src\Microsoft\SqlServer\Management\Smo doskey smoenum=pushd %BASEDIR%src\Microsoft\SqlServer\Management\SqlEnum\$* +doskey clean=powershell.exe -ExecutionPolicy Unrestricted -File "%BASEDIR%init.ps1" -Clean doskey tst=pushd %BASEDIR%src\FunctionalTest\Smo\$* doskey slngen19=slngen -vs "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\devenv.exe" $* +REM == Common build commands: +doskey msb=msbuild $* +doskey msbnolock=msbuild /p:RestoreLockedMode=false $* +doskey bsmo=msbuild %BASEDIR%dirs.proj +doskey bnr=msbuild /p:BuildProjectReferences=false $* + REM == Common test command: doskey rtests=pushd %BASEDIR%bin\debug\net472$Tvstest.console.exe microsoft.sqlserver.test.smo.dll /logger:trx /TestCaseFilter:"(TestCategory != Staging)" /Settings:%BASEDIR%src\FunctionalTest\Framework\functionaltest.runsettings $* doskey netcoretests=pushd %BASEDIR%bin\debug\net8.0$Tvstest.console.exe microsoft.sqlserver.test.smo.dll /logger:trx /TestCaseFilter:"(TestCategory != Staging)" /Settings:%BASEDIR%src\FunctionalTest\Framework\functionaltest.runsettings $* title git %BASEDIR% -dotnet tool install --global Microsoft.VisualStudio.SlnGen.Tool -dotnet tool install --global Microsoft.SqlPackage - -REM Download nuget.exe if it doesn't exist -IF NOT EXIST %BASEDIR%Build\Local\Nuget\nuget.exe ( - IF NOT EXIST %BASEDIR%Build\Local\Nuget ( - mkdir %BASEDIR%Build\Local\Nuget - ) - echo Downloading nuget.exe... - powershell -Command "Invoke-WebRequest -Uri 'https://dist.nuget.org/win-x86-commandline/latest/nuget.exe' -OutFile '%BASEDIR%Build\Local\Nuget\nuget.exe'" +REM Migration to PowerShell environment +powershell.exe -ExecutionPolicy Unrestricted -File "%BASEDIR%init.ps1" -Initialize +if "%errorlevel%" neq "0" ( + echo Failed to setup local dev build environment correctly ) +dotnet tool install --global Microsoft.VisualStudio.SlnGen.Tool +dotnet tool install --global Microsoft.SqlPackage IF NOT EXIST %BASEDIR%packages\StrawberryPerl.5.28.0.1\bin\perl.exe ( - %BASEDIR%Build\Local\Nuget\nuget.exe install StrawberryPerl -Version 5.28.0.1 -OutputDirectory %BASEDIR%packages + %BASEDIR%Build\Local\Nuget\nuget.exe install StrawberryPerl -Version 5.28.0.1 ) +echo. +echo. +echo To build for SMO development and to run tests (alias: bsmo): +echo msbuild %BASEDIR%dirs.proj echo. echo To open solution with SMO (code+test): echo slngen src\FunctionalTest\Smo\Microsoft.SqlServer.Test.Smo.csproj echo REM == Then use "Test | Configure Run Settings | Select Solution Wide Runsettings File" echo REM == and point it to one of the .runsettings under %BASEDIR%src\FunctionalTest\Framework -echo REM == You'll need to edit connection strings in src/functionaltest/framework/toolsconnectioninfo.xml. echo REM == Select "Test | Test Explorer" and you are ready to run tests! echo. echo To run tests (alias: rtests): @@ -66,8 +73,6 @@ echo REM == If you want to trim down the list of servers, use something like echo REM == SET SqlTestTargetServersFilter=Sql2017;Sqlv150 echo REM == See %BASEDIR%bin\Debug\net472\ToolsConnectionInfo.xml echo REM == for all the friendly names available. -echo REM == You'll need to edit connection strings in src/functionaltest/framework/toolsconnectioninfo.xml. -echo vstest.console.exe microsoft.sqlserver.test.smo.dll /TestCaseFilter:"(TestCategory != Staging)" /logger:trx /Settings:%BASEDIR%src\FunctionalTest\Framework\functionaltest.runsettings echo REM == Or pick one of the runsettings files under %BASEDIR%src\FunctionalTest\Framework echo vstest.console.exe /TestCaseFilter:"(TestCategory != Staging)" /logger:trx /Settings:%BASEDIR%src\FunctionalTest\Framework\functionaltest.runsettings echo. @@ -77,7 +82,19 @@ echo REM == If you want to trim down the list of servers, use something like echo REM == SET SqlTestTargetServersFilter=Sql2017;Sqlv150 echo REM == See %BASEDIR%bin\Debug\net472\ToolsConnectionInfo.xml echo REM == for all the friendly names available. -echo REM == You'll need to edit connection strings in src/functionaltest/framework/toolsconnectioninfo.xml. -echo vstest.console.exe microsoft.sqlserver.test.smo.dll /TestCaseFilter:"(TestCategory != Staging)" /logger:trx /Settings:%BASEDIR%src\FunctionalTest\Framework\functionaltest.runsettings +echo vstest.console.exe /TestCaseFilter:"(TestCategory != Staging)" /logger:trx /Settings:%BASEDIR%src\FunctionalTest\Framework\functionaltest.runsettings +echo. +echo To run functional tests: +echo REM == Build SMO +echo bsmo +echo. +echo REM == See content of runtests.cmd on how to filter the list of backends and tests +echo REM == otherwise it's going to take a while to run everything... +echo SET SqlTestTargetServersFilter=Sqlv160 +echo "%BASEDIR%src\FunctionalTest\runtests.cmd" echo. +echo REM ** To run fabric tests, you need to have fab cli installed and authenticated +echo REM ** See %BASEDIR%.scripts\Install-Fabric-Cli.ps1 for details +echo REM ** fab auth login +exit /b %errorlevel% diff --git a/src/Codegen/README.md b/src/Codegen/README.md index 6c2168bd..7747930d 100644 --- a/src/Codegen/README.md +++ b/src/Codegen/README.md @@ -54,274 +54,10 @@ Similar arrays exist for cloud versions ## CFG.XML -### Property Node - -Defines a property within a class definition - -Below are the attributes allowed in a property element - -#### Generate - -The generate attribute on properties controls whether the property is automatically generated by CodeGen.exe when it's ran. If this attribute is set to false you'll need to define the property in a partial class (usually located in SMO\Main\src) that will be compiled with the generated class during the build. - -#### Is_intrinsic - -This controls whether the property belongs to the XSchemaProps class or the XRuntimeProps class generated inside each SMO object class. This attribute only matters if the class element has the gen_metadata attribute set to true (as this is the only time we generate the metadata classes) - -#### Dmf_ignore - -#### Default - -The default value returned when GetPropertyDefaultValue is called (the major cases for this are when the object is in the Creating state or in Design mode). - -Will also add the default value to the SfcProperty attribute, but that isn't used by SMO - -#### Suppress_sfc_attribute - -Will suppress writing the Sfc attributes for the properties - -#### reference_type/reference_template/reference_template_parameters - -These properties are used to define SfcReference attributes for this property. This is used when the property references another object but isn't actual an instance of that object (for example the property might be just a name). During serialization, SFC uses reference_template and reference_template_parameters to construct a link between the object and the referenced object. The strings in reference_template_parameters are evaluated using reflection, as properties of the current object. - -Example for Table: - -```xml - -``` - -Generates this property: - -```C# - [SfcReference(typeof(ExternalFileFormat),"Server[@Name = '{0}']/Database[@Name = '{1}']/ExternalFileFormat[@Name='{2}']","Parent.Parent.ConnectionContext.TrueName","Parent.Name","FileFormatName")] - [CLSCompliant(false)] - public System.String FileFormatName -``` - -When the Table node is serialized, the value of the FileFormatName is stored using the evaluated template: - -````xml - - - /Server/SQLTools2019-3/Database/SfcSerialize'']]]'{5d00119a-0dba-4bb2-8150-9621c933a182}/ExternalFileFormat/SmoBaselineVerification__ExternalFileFormat - - -```` - -### Object Node +See [cfg.xsd](./cfg.xsd) for the schema of the cfg.xml file. Editors such as Visual Studio/VS Code will automatically read the schema and provide hover/auto-completion support as well. Below are the attributes allowed in an object element -#### Class_name - -The name of the class being generated - -#### collection_name - -The parent class's name for the object collection containing instances of this object (typically the pluralization of the class name) - -#### Parent_type - -The type of the Parent property. If not defined will not generate the Parent property - -#### Urn - -The SFC URN skeleton for the object - -#### Ctor_Parent - -If it exists and the value isn't AbstractCollectionBase the "new" keyword is put in the Parent property signature (public new T Parent) as long as the value - -#### New_on_get_parent - -Same thing as ctor_parent, except it reads in the boolean value to decide whether to append the "new" keyword - -#### Base_class - -The base class for the object - -#### Has_schema - -If true will set the key (used for collection lookups) to a SchemaObjectKey(name, null) and will generate a constructor that takes in a schema. If false (default) the key will be SimpleObjectKey. Should be true if the object is a schema-owned object. - -#### Has_constructors - -Whether the basic constructors are public (default true) - -#### Implements - -The list of interfaces that this class implements (comma delimited) - -Some common interfaces to implement: -• IObjectPermission - if the object is a [securable]() - -#### Sealed - -Whether the class has the "sealed" keyword on it (default true) - -#### Gen_body - -NOTE : See src/CodeGen/gen.xml for more detailed explanation of the below - -NOTE2 : If this object implements IObjectPermission this must contain "obj1,1;obj2,1;enobj,2" these are flags that tell codegen to generate the permission accessors for this object type (deny/grant/revoke methods and properties) - -Uses src/CodeGen/gen.xml to insert commonly-used code snippets with minor differences - -The value of this attribute is a string containing a list of sets, sets are delimited by semi-colons (;). Each set contains two values, delimited by commas (,). - -e.g. - -Attrib1,Body1;Attrib2,Body2… - -Attributes (Attrib1/Attrib2 above) - The first value in each set is the attribute it will map to. Think of attributes as sets of declarations of variables, which are later used to fill in the Body templates. They are identified by the "id" attribute of the "attribute" element in gen.xml. These are hierarchical - an attribute can have a load_id defined which is a "base" attribute to inherit other values from - -e.g. `````` defines an attribute with ID obj1 that also includes the sub-values from the "base" attritube - -Subvalues can be one of two values : - -``` -a -defines a variable ( term used interchangeably with attribute ) -alias dedefines a variable -``` - -Bodies (Body1/Body2 above) - The second value in each set is the body element it will map to. A body is simply a template of code to insert into the generated CS file - it allows variable substitution through the use of `````` tags (whose values are set based on the attribute part of the pair). They are identified by the "id" attribute of the "body" element in gen.xml. - -e.g. ``` … ``` defines a body with ID "1" that is generated within the class definition - -An example of the code generated we'll use the table class as an example. In cfg.xml it includes a gen_body like this : - -```gen_body="obj1,1;obj2,1;enobj,2;col1,1;col2,1;encol,2;table,server_events"``` - -The first set is obj1,1 - which if you look at the body element with id = 1 means that it's going to generate 8 methods : - -Method name Parameters (mapped to values from attribute) -public void Deny - -• permission -• granteeNames -• columnNames - -public void Deny - -• permission -• granteeNames -• columnNames -• Cascade - -public void Grant -• permission -• granteeNames -• columnNames - -public void Grant -• permission -• granteeNames -• columnNames -• grantGrant - -public void Grant -• permission -• granteeNames -• columnNames -• grantGrant -• asRole - -public void Revoke -• permission -• granteeNames -• columnNames - -public void Revoke -• permission -• granteeNames -• columnNames -• Cascade -• revokeGrant - -public void Revoke -• permission -• granteeNames -• columnNames -• Cascade -• revokeGrant -• asRole - -The parameters map to the values in the attribute obj1 as explained above. So obj1 has the following attributes : - -```xml - - -``` - -But it also inherits the following from the "base" attribute : - -```xml - - - - - - - - - - - -``` - -So you can see how the first method above (Deny with 3 parameters) uses the permission, granteeNames and columnNames values, which map to ObjectPermissionSet permission, System.String[] granteeNames and null respectively. Note that null means that parameter is ignored (so the actual method generated will only have 2 parameters) - -This all ends up creating the final method signature : - -```C# -public void Deny(ObjectPermissionSet permission, System.String[] granteeNames, System.String[] columnNames) -``` - -The rest of the method body is defined in gen.xml as - -```xml - - - - - - - - - - - - - -``` - -This will use the same process to generate the code - replacing any a/alias tags with the appropriate attribute. - -The final result is the method : - -```C# -public void Deny(ObjectPermissionSet permission, System.String granteeName) -{ - PermissionWorker.Execute(PermissionState.Deny, this, permission, new String [] { granteeName }, null, false, false, null); -} -``` - -#### Has_new - -#### Singleton - -#### Ini_defaults - -#### Parent_has_setter - -#### is_design_mode - -Set this property to `true` to allow your object to participate in `DesignMode`. Such objects can be unit tested with an offline connection. Most objects should have this set. - -#### Parent_mode - - ## Additional attributes read if cfg file isn't specified in SFC Config.xml ### Type diff --git a/src/Codegen/SmoCodeGen.csproj b/src/Codegen/SmoCodeGen.csproj index e9e6b1ec..69ce11ff 100644 --- a/src/Codegen/SmoCodeGen.csproj +++ b/src/Codegen/SmoCodeGen.csproj @@ -19,7 +19,6 @@ - @@ -29,6 +28,7 @@ + @@ -133,9 +133,6 @@ - - - @@ -145,4 +142,9 @@ + + + + diff --git a/src/Codegen/cfg.xml b/src/Codegen/cfg.xml index 3aff87c4..b1881f7d 100644 --- a/src/Codegen/cfg.xml +++ b/src/Codegen/cfg.xml @@ -1,5 +1,5 @@ - + @@ -22,7 +22,7 @@ - + @@ -168,6 +168,7 @@ + @@ -460,6 +461,18 @@ + + + + + + + + + + + + @@ -1385,7 +1398,7 @@ - /> + @@ -1416,7 +1429,7 @@ - + @@ -1493,7 +1506,7 @@ - + diff --git a/src/Codegen/cfg.xsd b/src/Codegen/cfg.xsd new file mode 100644 index 00000000..6c2d9705 --- /dev/null +++ b/src/Codegen/cfg.xsd @@ -0,0 +1,418 @@ + + + + + + + + Root element containing all namespace definitions for SMO code generation. + Defines the object model structure for SQL Server Management Objects. + + + + + + + + + Minimum SQL Server major version supported. + + + + + Maximum SQL Server major version supported. + + + + + + + + + + Defines a .NET namespace containing SMO object class definitions. + Example: Microsoft.SqlServer.Management.Smo, Microsoft.SqlServer.Management.Smo.Broker + + + + + + + + The fully qualified .NET namespace name (e.g., "Microsoft.SqlServer.Management.Smo"). + + + + + + + + + Defines a class in the SMO object model with its properties and collections. + CodeGen.exe processes these definitions to generate partial class files. + + + + + + + + + + The name of the class being generated (e.g., "Table", "Database", "Index"). + + + + + + The parent class's name for the object collection containing instances of this object. + Typically the pluralization of the class name (e.g., "Tables", "Databases", "Indexes"). + + + + + + + The type of the Parent property. If not defined, the Parent property will not be generated. + Example: "Server" for Database, "Database" for Table. + + + + + + + The SFC (SQL Foundation Classes) URN skeleton for the object. + Defines the hierarchical path to this object type. + Example: "Server[@Name='']/Database/Table" + + + + + + + If it exists and the value isn't AbstractCollectionBase, the "new" keyword is added to the Parent property signature (public new T Parent). + + + + + + + If true, appends the "new" keyword to the Parent property declaration. + Same as ctor_parent but uses a boolean value. + + + + + + + The base class for the object. If not specified, uses the default base class for the object type. + + + + + + + If true, sets the key (for collection lookups) to SchemaObjectKey(name, schema) and generates a constructor that takes a schema parameter. + If false (default), the key will be SimpleObjectKey. + Should be true if the object is schema-owned (e.g., Table, View, StoredProcedure). + + + + + + + Whether the basic constructors are public (default true). + Set to false for singleton objects or objects with custom constructor logic. + + + + + + + The list of interfaces that this class implements (comma delimited). + Common interfaces: IObjectPermission (if the object is a securable), IColumnPermission (for column-level permissions). + + + + + + + Whether the class has the "sealed" keyword (default true). + Set to false if the class is designed to be inherited from. + + + + + + + Uses gen.xml to insert commonly-used code snippets with minor differences. + Format: "attrib1,body1;attrib2,body2;..." + + For IObjectPermission objects, must contain "obj1,1;obj2,1;enobj,2" to generate permission accessors (deny/grant/revoke methods). + + Each set contains an attribute ID (mapping to gen.xml attributes) and body ID (mapping to gen.xml body templates). + The attribute defines variables used to fill in the body template. + + Example: "obj1,1;obj2,1;enobj,2;table,server_events" + + + + + + Flag for code generation behavior (see gen.xml for details). + + + + + + If true, this object is a singleton (only one instance exists per parent). + Examples: DatabaseOptions, FullTextService, Information. + + + + + + If true, the Parent property will have a setter in addition to a getter. + + + + + + Set to true to allow your object to participate in DesignMode. + Such objects can be unit tested with an offline connection. + Most objects should have this set to true. + + + + + + + Specifies the mode(s) in which the parent is available. + Possible values include "Design", "Deploy", "Design;Deploy". + + + + + + + Semicolon-delimited list of possible parent types for objects that can belong to multiple parent types. + Example: "Table;View" for Column, "Table;UserDefinedTableType;UserDefinedFunction" for Check. + + + + + + Whether this object supports extended schema metadata operations. + + + + + + If true, generates XSchemaProps and XRuntimeProps metadata classes for this object. + Controls whether is_intrinsic attribute on properties matters. + + + + + + If true, removes the Name property from the generated class. + + + + + + Whether to initialize default values for properties during object construction. + When true, properties with default values will be set during object initialization. + + + + + + + + + + Defines a property within a class definition. + CodeGen.exe processes these to generate property declarations in the partial class files. + + + + + The name of the property (e.g., "Name", "ID", "Collation"). + + + + + + Controls whether the property is automatically generated by CodeGen.exe. + If false, you must define the property in a partial class (usually in SMO\Main\src). + Default: true + + + + + + + Controls whether the property belongs to XSchemaProps (true) or XRuntimeProps (false) class. + Only matters if the object's gen_metadata attribute is true. + + Intrinsic properties are prefetched in batch queries (via GetScriptFields() and stored in XSchemaProps). + Non-intrinsic properties are fetched on-demand (stored in XRuntimeProps). + + Mark as true if the property is commonly needed for scripting and should be batched during enumeration. + + + + + + + If true, this property is ignored by DMF (Declarative Management Framework) facets. + Use when a property should not be exposed in policy-based management. + + + + + + + The default value returned when GetPropertyDefaultValue is called. + Used when the object is in Creating state or in Design mode. + Will also add the default value to the SfcProperty attribute. + + Example: default="SQL_Latin1_General_CP1_CI_AS" for Database.Collation + + + + + + If true, suppresses writing the SFC (SQL Foundation Classes) attributes for this property. + + + + + + The type of the referenced object for SfcReference attribute generation. + Used when this property references another object but isn't an instance of that object (e.g., property is just a name). + + Example: reference_type="ExternalFileFormat" for Table.FileFormatName property. + + + + + + + The URN template for constructing a link to the referenced object during SFC serialization. + Uses {0}, {1}, etc. as placeholders that are filled from reference_template_parameters. + + Example: "Server[@Name = '{0}']/Database[@Name = '{1}']/ExternalFileFormat[@Name='{2}']" + + + + + + + Comma-separated list of property paths evaluated using reflection to fill reference_template placeholders. + Properties are evaluated as properties of the current object. + + Example: "Parent.Parent.ConnectionContext.TrueName,Parent.Name,FileFormatName" + + + + + + + If true, this property is required and must be set during object creation or configuration. + Typically used for properties that are essential for the object's identity or basic functionality. + + Example: Identity property on Credential, DllPath on CryptographicProvider. + + + + + + + The .NET type of the property. + Can be a primitive type (e.g., "System.String", "System.Int32", "System.Boolean") or a complex type. + If not specified, the type is inferred from metadata or defaults to appropriate type based on context. + + Example: type="System.String", type="System.Boolean", type="Microsoft.SqlServer.Management.Smo.Wmi.ServiceState" + + + + + + + If true, the property is read-only and does not have a setter. + Read-only properties can only be queried, not modified. + + Example: readonly="true" for ID properties, system-calculated values, or metadata properties. + + + + + + + If true, indicates that retrieving this property requires an expensive operation such as a separate query or significant computation. + Expensive properties are typically fetched individually on-demand rather than being batched with other properties. + Used to optimize performance by avoiding unnecessary expensive operations when the property isn't needed. + + Example: Properties that require complex joins, aggregations, or large data retrieval operations. + + + + + + + + + + Defines a child collection property on the parent object. + Indicates that this object type can contain a collection of the specified element type. + + Example: A Database object has collections of Tables, Views, StoredProcedures, etc. + + + + + + The type of elements in the collection (e.g., "Table", "Column", "Index"). + Must correspond to a class_name defined elsewhere in the configuration. + + + + + + + + + + Defines an additional property bag for an object that provides access to advanced or extended properties. + Used to group related properties that are queried from a separate URN or have special access patterns. + + Example: Service object has an additional_property_bag for ServiceAdvancedProperty which provides advanced configuration properties. + + + + + + + + + The SFC URN for the additional property bag. + Defines the path used to query these extended properties. + + Example: "ManagedComputer[@Name='']/ServiceAdvancedProperty" + + + + + + + The suffix appended to property accessor names in the property bag. + + Example: suffix="Advanced" creates an "Advanced" property bag accessor. + + + + + + diff --git a/src/CollectionGenerator/CollectionGenerator.csproj b/src/CollectionGenerator/CollectionGenerator.csproj index 9cdc5f01..f133f70c 100644 --- a/src/CollectionGenerator/CollectionGenerator.csproj +++ b/src/CollectionGenerator/CollectionGenerator.csproj @@ -4,6 +4,8 @@ netstandard2.0 true $(DefineConstants);DEBUGCOLLECTIONGENERATOR + + $(NoWarn);NU1701 diff --git a/src/Directory.Build.props b/src/Directory.Build.props index d205f12e..aa1178dc 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -86,7 +86,7 @@ 173.0.0 Microsoft.Data.SqlClient - 5.1.6 + 6.1.3 diff --git a/src/FunctionalTest/Directory.Packages.props b/src/FunctionalTest/Directory.Packages.props new file mode 100644 index 00000000..cfda45ac --- /dev/null +++ b/src/FunctionalTest/Directory.Packages.props @@ -0,0 +1,22 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/FunctionalTest/Dockerfiles/150Linux/dockerfile b/src/FunctionalTest/Dockerfiles/150Linux/dockerfile deleted file mode 100644 index b426ec8a..00000000 --- a/src/FunctionalTest/Dockerfiles/150Linux/dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -FROM ubuntu:18.04 - -# Install prerequisites including repo config for SQL server and PolyBase. -RUN export DEBIAN_FRONTEND=noninteractive && \ - apt-get update && \ - apt-get install -y gnupg && \ - apt-get install -yq apt-transport-https curl && \ - # Get official Microsoft repository configuration - curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \ - curl https://packages.microsoft.com/config/ubuntu/18.04/mssql-server-2019.list | tee /etc/apt/sources.list.d/mssql-server-2019.list && \ - curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list | tee /etc/apt/sources.list.d/msprod.list && \ - apt-get update && \ - # Install PolyBase will also install SQL Server via dependency mechanism. - apt-get install -y mssql-server-polybase && \ - # Cleanup the Dockerfile - apt-get clean && \ - rm -rf /var/lib/apt/lists - -# Run SQL Server process -CMD /opt/mssql/bin/sqlservr diff --git a/src/FunctionalTest/Framework/Helpers/AzureKeyVaultHelper.cs b/src/FunctionalTest/Framework/Helpers/AzureKeyVaultHelper.cs index aea27c30..d3e7130e 100644 --- a/src/FunctionalTest/Framework/Helpers/AzureKeyVaultHelper.cs +++ b/src/FunctionalTest/Framework/Helpers/AzureKeyVaultHelper.cs @@ -40,6 +40,12 @@ public class AzureKeyVaultHelper : ICredential public static readonly string SSMS_TEST_SECRET_PREFIX = "SQLA-SSMS-Test-"; private SecretClient secretClient = null; + private static readonly bool isAzureVM; + + static AzureKeyVaultHelper() + { + isAzureVM = DetectAzureVM(); + } /// /// Constructs a new AzureKeyVaultHelper that relies on an instance of Azure.Identity.DefaultAzureCredential to access the given vault. @@ -71,7 +77,6 @@ public string GetDecryptedSecret(string secretName) } if (string.IsNullOrEmpty(secret)) { - TraceHelper.TraceInformation("Looking for secret {0} using name {1}. Starting with environment variables.", secretName, lookupName); secret = Environment.GetEnvironmentVariable(lookupName); } if (string.IsNullOrEmpty(secret)) @@ -83,7 +88,6 @@ public string GetDecryptedSecret(string secretName) secretClient = new SecretClient(new Uri($"https://{KeyVaultName}.vault.azure.net"), credential); } var secretIdentifier = $"https://{KeyVaultName}.vault.azure.net/secrets/{lookupName}"; - TraceHelper.TraceInformation("Secret {0} not set as environment variable. Looking in AKV for {1}.", secretName, secretIdentifier); try { secret = secretClient.GetSecret(lookupName).Value.Value; @@ -109,8 +113,17 @@ public string GetDecryptedSecret(string secretName) public Azure.Core.TokenCredential GetCredential() { TraceHelper.TraceInformation($"Getting credential for Azure in tenant {AzureTenantId}"); - // prefer managed identity then local user on dev machine over the certificate - var credentials = new List() { new ManagedIdentityCredential(AzureManagedIdentityClientId), new DefaultAzureCredential(new DefaultAzureCredentialOptions { ExcludeManagedIdentityCredential = true, TenantId = AzureTenantId }) }; + var credentials = new List(); + + // Only add ManagedIdentityCredential if we're running on an Azure VM + if (isAzureVM) + { + TraceHelper.TraceInformation("Detected Azure VM environment. Adding ManagedIdentityCredential."); + credentials.Add(new ManagedIdentityCredential(AzureManagedIdentityClientId)); + } + + credentials.Add(new DefaultAzureCredential(new DefaultAzureCredentialOptions { ExcludeManagedIdentityCredential = true, TenantId = AzureTenantId })); + var options = new AzureDevOpsFederatedTokenCredentialOptions() { TenantId = AzureTenantId, ClientId = AzureApplicationId }; if (options.ServiceConnectionId != null) { @@ -120,6 +133,57 @@ public Azure.Core.TokenCredential GetCredential() return new ChainedTokenCredential(credentials.ToArray()); } + /// + /// Detects whether the current environment is an Azure VM by checking for the Azure Instance Metadata Service (IMDS). + /// + /// True if running on an Azure VM, false otherwise. + private static bool DetectAzureVM() + { + // Check for well-known environment variables that indicate Azure VM/App Service/Container Instances + var azureEnvironmentVariables = new[] + { + "WEBSITE_INSTANCE_ID", // Azure App Service + "CONTAINER_APP_NAME", // Azure Container Apps + "ACI_ENVIRONMENT", // Azure Container Instances + "IDENTITY_ENDPOINT", // Managed Identity endpoint + "IMDS_ENDPOINT" // Azure Instance Metadata Service + }; + + foreach (var envVar in azureEnvironmentVariables) + { + if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable(envVar))) + { + TraceHelper.TraceInformation($"Azure environment detected via {envVar} environment variable."); + return true; + } + } + + // Try to reach the Azure Instance Metadata Service (IMDS) + // IMDS is available at a well-known, non-routable IP address (169.254.169.254) + try + { + using (var client = new System.Net.Http.HttpClient()) + { + client.Timeout = TimeSpan.FromSeconds(2); + client.DefaultRequestHeaders.Add("Metadata", "true"); + + var response = client.GetAsync("http://169.254.169.254/metadata/instance?api-version=2021-02-01").Result; + if (response.IsSuccessStatusCode) + { + TraceHelper.TraceInformation("Azure VM detected via IMDS endpoint."); + return true; + } + } + } + catch (Exception ex) + { + TraceHelper.TraceInformation($"IMDS check failed (not running on Azure VM): {ex.Message}"); + } + + TraceHelper.TraceInformation("Not running on Azure VM."); + return false; + } + /// /// Returns the account access key for the given storage account resource id. /// @@ -127,7 +191,6 @@ public Azure.Core.TokenCredential GetCredential() /// public string GetStorageAccountAccessKey(string storageAccountResourceId) { - TraceHelper.TraceInformation($"Fetching storage access key for {storageAccountResourceId}"); return new AzureStorageHelper(storageAccountResourceId, this).GetStorageAccountAccessKey(storageAccountResourceId); } } diff --git a/src/FunctionalTest/Framework/Helpers/AzureStorageHelper.cs b/src/FunctionalTest/Framework/Helpers/AzureStorageHelper.cs index f5a91424..d8b28381 100644 --- a/src/FunctionalTest/Framework/Helpers/AzureStorageHelper.cs +++ b/src/FunctionalTest/Framework/Helpers/AzureStorageHelper.cs @@ -38,7 +38,6 @@ public Credential EnsureCredential(Management.Smo.Server server) public string GetStorageAccountAccessKey(string storageAccountResourceId) { - TraceHelper.TraceInformation($"Fetching storage access key for {storageAccountResourceId}"); var storageAccount = ArmClient.GetStorageAccountResource(new Azure.Core.ResourceIdentifier(storageAccountResourceId)); return storageAccount.GetKeys().First().Value; } diff --git a/src/FunctionalTest/Framework/Helpers/DataExtensions.cs b/src/FunctionalTest/Framework/Helpers/DataExtensions.cs deleted file mode 100644 index abb845ed..00000000 --- a/src/FunctionalTest/Framework/Helpers/DataExtensions.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -namespace Microsoft.SqlServer.Test.Manageability.Utils.Helpers -{ -#if NETSTANDARD2_0 - public static class DataExtensions - { - - // - // Summary: - // Provides strongly-typed access to each of the column values in the specified - // row. The System.Data.DataRowExtensions.Field``1(System.Data.DataRow,System.String) - // method also supports nullable types. - // - // Parameters: - // row: - // The input System.Data.DataRow, which acts as the this instance for the extension - // method. - // - // columnName: - // The name of the column to return the value of. - // - // Type parameters: - // T: - // A generic parameter that specifies the return type of the column. - // - // Returns: - // The value, of type T, of the System.Data.DataColumn specified by columnName. - // - // Exceptions: - // T:System.InvalidCastException: - // The value type of the underlying column could not be cast to the type specified - // by the generic parameter, T. - // - // T:System.IndexOutOfRangeException: - // The column specified by columnName does not occur in the System.Data.DataTable - // that the System.Data.DataRow is a part of. - // - // T:System.NullReferenceException: - // A null value was assigned to a non-nullable type. - public static T Field(this System.Data.DataRow row, string columnName) - { - return (T)row[columnName]; - } - } -#endif -} diff --git a/src/FunctionalTest/Framework/Helpers/DatabaseObjectHelpers.cs b/src/FunctionalTest/Framework/Helpers/DatabaseObjectHelpers.cs index ecf58a47..2595a32d 100644 --- a/src/FunctionalTest/Framework/Helpers/DatabaseObjectHelpers.cs +++ b/src/FunctionalTest/Framework/Helpers/DatabaseObjectHelpers.cs @@ -388,6 +388,52 @@ public static ExternalLibrary CreateExternalLibrary(this SMO.Database db, string return externalLibrary; } + /// + /// Create an external model. + /// + /// The target database + /// The external model name + /// The newly created external model + public static ExternalModel CreateExternalModelDefinition(this SMO.Database db, string modelName) + { + TraceHelper.TraceInformation("Creating external model [{0}] for database [{1}]", modelName, db.Name); + SMO.ExternalModel model = new SMO.ExternalModel(db, modelName); + return model; + } + + /// + /// Creates an external model on the server. + /// + /// The target database + /// The name of the external model + /// The location of the model + /// The API format (e.g., "ONNX") + /// The model type (e.g., "EMBEDDINGS") + /// The model content or identifier + /// Any model parameters + /// Credential name used for access + /// The newly created ExternalModel object + public static ExternalModel CreateExternalModel( + this SMO.Database db, + string modelName, + string location, + string apiFormat, + string modelType, + string model, + string parameters, + string credential) + { + var externalModel = CreateExternalModelDefinition(db, modelName); + externalModel.Location = location; + externalModel.ApiFormat = apiFormat; + externalModel.ModelType = ExternalModelType.Embeddings; + externalModel.Model = model; + externalModel.Parameters = parameters; + externalModel.Credential = credential; + externalModel.Create(); + return externalModel; + } + /// /// Creates a user defined function definition with a uniquely generated name prefixed by the specified prefix and defined with the specified /// body and header. Optionally allows specifying the schema and whether the view is Schema Bound. diff --git a/src/FunctionalTest/Framework/Helpers/FabricDatabaseManager.cs b/src/FunctionalTest/Framework/Helpers/FabricDatabaseManager.cs index a072cba9..281c44a6 100644 --- a/src/FunctionalTest/Framework/Helpers/FabricDatabaseManager.cs +++ b/src/FunctionalTest/Framework/Helpers/FabricDatabaseManager.cs @@ -117,7 +117,7 @@ private string CreateFabricResource(string workspaceName, string resourceName, F created = true; Trace.TraceInformation($"Fabric {resourceTypeString.ToLowerInvariant()} created: {output}"); // Get the connection string for the newly created resource - string connectionString = ExecuteFabricCliCommand($"get {resourcePath} -q properties.connectionString")+DefaultAuthMethod; + string connectionString = ExecuteFabricCliCommand($"get {resourcePath} -q properties.connectionString -f")+DefaultAuthMethod; return connectionString; } catch (Exception ex) @@ -232,15 +232,15 @@ private string ExecuteFabricCliCommand(string arguments, bool interactiveInputNe Arguments = arguments, RedirectStandardOutput = !interactiveInputNeeded, RedirectStandardError = !interactiveInputNeeded, - UseShellExecute = interactiveInputNeeded, + UseShellExecute = false, CreateNoWindow = !interactiveInputNeeded, + EnvironmentVariables = + { + ["FAB_API_ENDPOINT_FABRIC"] = string.Equals(Environment, "daily", StringComparison.OrdinalIgnoreCase) ? "dailyapi.fabric.microsoft.com" : "api.fabric.microsoft.com", + // Ensure UTF-8 encoding for Python subprocesses because the error messages may contain non-ASCII characters + ["PYTHONIOENCODING"] = "utf-8" + } }; - // Set FAB_API_ENDPOINT_FABRIC if Environment == "daily" - if (string.Equals(Environment, "daily", StringComparison.OrdinalIgnoreCase)) - { - processStartInfo.FileName = "cmd.exe"; - processStartInfo.Arguments = $"/c set FAB_API_ENDPOINT_FABRIC=dailyapi.fabric.microsoft.com&{FabricCliPath} {arguments}"; - } Trace.WriteLine($"Executing Fabric CLI command: {processStartInfo.FileName} {processStartInfo.Arguments}"); using (var process = Process.Start(processStartInfo)) { diff --git a/src/FunctionalTest/Framework/Helpers/ServerObjectHelpers.cs b/src/FunctionalTest/Framework/Helpers/ServerObjectHelpers.cs index ea1c3621..bb4fb0ef 100644 --- a/src/FunctionalTest/Framework/Helpers/ServerObjectHelpers.cs +++ b/src/FunctionalTest/Framework/Helpers/ServerObjectHelpers.cs @@ -31,7 +31,7 @@ namespace Microsoft.SqlServer.Test.Manageability.Utils /// public static class ServerObjectHelpers { - private static readonly Semaphore azureDbCreateLock = new Semaphore(2, 2); + private static readonly Semaphore azureDbCreateLock = new Semaphore(3, 3); /// /// Restores a database from the specified backup file. It's the callers responsibility to ensure the server @@ -396,10 +396,10 @@ DatabaseParameters dbParameters RetryHelper.RetryWhenExceptionThrown( () => { - var databaseName = SmoObjectHelpers.GenerateUniqueObjectName(dbParameters.NamePrefix, - includeClosingBracket: dbParameters.UseEscapedCharacters, - includeDoubleClosingBracket: dbParameters.UseEscapedCharacters, - includeSingleQuote: dbParameters.UseEscapedCharacters, + var databaseName = SmoObjectHelpers.GenerateUniqueObjectName(dbParameters.NamePrefix, + includeClosingBracket: dbParameters.UseEscapedCharacters, + includeDoubleClosingBracket: dbParameters.UseEscapedCharacters, + includeSingleQuote: dbParameters.UseEscapedCharacters, includeDoubleSingleQuote: dbParameters.UseEscapedCharacters); try { @@ -424,7 +424,7 @@ DatabaseParameters dbParameters // VBUMP db = server.DatabaseEngineEdition == DatabaseEngineEdition.SqlOnDemand ? new Database(server, databaseName) - : new Database(server, databaseName) { ReadOnly = false, CompatibilityLevel = CompatibilityLevel.Version170 }; + : new Database(server, databaseName) { ReadOnly = false, CompatibilityLevel = CompatibilityLevel.Version170, AzureEdition = "GeneralPurpose"}; break; } case SqlTestBase.AzureDatabaseEdition.DataWarehouse: @@ -651,6 +651,9 @@ public static bool DropKillDatabaseNoThrow(this SMO.Server server, string dbName } } dbDropped = true; + } else + { + TraceHelper.TraceInformation($"Database '{dbName}' does not exist on server {server.Name}, no need to drop"); } } catch (Exception e) diff --git a/src/FunctionalTest/Framework/Helpers/SqlClientEventRecorder.cs b/src/FunctionalTest/Framework/Helpers/SqlClientEventRecorder.cs index f92e65a6..78433b60 100644 --- a/src/FunctionalTest/Framework/Helpers/SqlClientEventRecorder.cs +++ b/src/FunctionalTest/Framework/Helpers/SqlClientEventRecorder.cs @@ -3,65 +3,149 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Diagnostics.Tracing; +using System.Globalization; using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Runtime.CompilerServices; +using static System.FormattableString; namespace Microsoft.SqlServer.Test.Manageability.Utils.Helpers { + /// - /// SqlClientEventRecorder captures SqlClient traces + /// Base class for recording events from EventSource providers. + /// Provides common functionality for filtering by thread and managing event recording lifecycle. /// - public class SqlClientEventRecorder : EventListener + [DebuggerDisplay("Listener {ListenerName} <{EventSourceName}:{ThreadId}>")] + public abstract class EventRecorderBase : EventListener { private bool isRecording = false; + private readonly EventLevel eventLevel; + private readonly EventKeywords eventKeywords; + + /// + /// Optional name of the listener + /// + public string ListenerName { get; } + + /// /// The managed thread id to monitor for events. When set to -1, records events for all threads /// - public int ThreadId { get; private set; } + public int ThreadId { get; } /// /// The list of recorded events /// - public IList Events { get; private set; } + public IList Events { get; } /// - /// Constructs a new SqlClientEventRecorder that captures events on all threads + /// Gets or sets whether to log events to TraceHelper when they arrive. + /// When true (default), events are logged via TraceHelper.TraceInformation. + /// When false, events are only collected in the Events list without logging. /// - public SqlClientEventRecorder() : this(-1) - { + public bool EnableTraceLogging { get; set; } - } + /// + /// Gets the name of the EventSource being recorded + /// + protected string EventSourceName { get; } /// - /// Constructs a new SqlClientEventRecorder that captures events for a specific managed thread + /// Initializes a new instance of EventRecorderBase /// - /// - public SqlClientEventRecorder(int managedThreadId) + /// Name of the EventSource to record + /// Verbosity level for events to record + /// Keyword mask for filtering events + /// Thread ID to filter events by, or -1 for all threads + /// Optional name for the listener + protected EventRecorderBase(string eventSourceName, EventLevel eventLevel, EventKeywords eventKeywords, int managedThreadId = -1, string listenerName = "") { + if (string.IsNullOrEmpty(eventSourceName)) + { + throw new ArgumentNullException(nameof(eventSourceName)); + } + + EventSourceName = eventSourceName; + this.eventLevel = eventLevel; + this.eventKeywords = eventKeywords; + ListenerName = listenerName; ThreadId = managedThreadId; Events = new List(); + EnableTraceLogging = true; // Default to enabled for backward compatibility + EventSourceCreated += OnEventSourceCreated; } - protected override void OnEventSourceCreated(EventSource eventSource) + private void OnEventSourceCreated(object sender, EventSourceCreatedEventArgs e) { - if (eventSource.Name.Equals("Microsoft.Data.SqlClient.EventSource")) + if (e.EventSource.Name.Equals(EventSourceName, StringComparison.Ordinal)) { - EnableEvents(eventSource, EventLevel.Verbose, (EventKeywords)3); + EnableEvents(e.EventSource, eventLevel, eventKeywords); } } + /// + /// Called when an event is written. Records the event if recording is active and thread filter matches. + /// + /// The event data protected override void OnEventWritten(EventWrittenEventArgs eventData) { if (isRecording && (ThreadId == -1 || Environment.CurrentManagedThreadId == ThreadId)) { base.OnEventWritten(eventData); Events.Add(eventData); - TraceHelper.TraceInformation(string.Join(Environment.NewLine, eventData.Payload.Select(p => $"[{Environment.CurrentManagedThreadId}]: {p}")) + Environment.NewLine); + if (EnableTraceLogging) + { + LogEventData(eventData); + } } } + /// + /// Logs event data. Override to customize logging behavior. + /// This method is only called when EnableTraceLogging is true. + /// + /// The event data to log + public virtual void LogEventData(EventWrittenEventArgs eventData) + { + + // use same format as SSMS output window + var baseMessage = $"[{Environment.CurrentManagedThreadId}]: {eventData.EventName}: "; + string message; + if (!string.IsNullOrEmpty(eventData.Message)) + { + try + { + message = baseMessage + string.Format(CultureInfo.InvariantCulture, eventData.Message, eventData.Payload.ToArray()) + Environment.NewLine; + } + catch (FormatException) + { + message = baseMessage + Environment.NewLine; + } + } + else + { + message = baseMessage + string.Join($"{Environment.NewLine}\t", eventData.Payload.Select((p, i) => Invariant($"{eventData.PayloadNames[i]}:{p}"))) + Environment.NewLine; + } + switch (eventData.Level) + { + case EventLevel.Critical: + case EventLevel.Error: + case EventLevel.Warning: + TraceHelper.TraceWarning(message); + break; + default: + TraceHelper.TraceInformation(message); + break; + } + } + + /// + /// Gets a descriptive name for this recorder type, used in logging + /// + protected virtual string RecorderTypeName => GetType().Name; + /// /// Begins or resumes event recording /// @@ -69,10 +153,9 @@ public void Start() { if (!isRecording) { - TraceHelper.TraceInformation($"SqlClientEventRecorder.Start [{ThreadId}]"); + TraceHelper.TraceInformation($"{RecorderTypeName}.Start [{ThreadId}] for EventSource '{EventSourceName}'"); } isRecording = true; - } /// @@ -82,15 +165,77 @@ public void Stop() { if (isRecording) { - TraceHelper.TraceInformation($"SqlClientEventRecorder.Stop [{ThreadId}]"); + TraceHelper.TraceInformation($"{RecorderTypeName}.Stop [{ThreadId}] for EventSource '{EventSourceName}'"); } isRecording = false; } + /// + /// Disposes the recorder and stops recording + /// public override void Dispose() { Stop(); base.Dispose(); } } + + /// + /// SqlClientEventRecorder captures SqlClient traces + /// + public class SqlClientEventRecorder : EventRecorderBase + { + /// + /// Constructs a new SqlClientEventRecorder that captures events on all threads + /// + public SqlClientEventRecorder([CallerMemberName] string name = "") : this(-1, 3, name) + { + } + + /// + /// Constructs a new SqlClientEventRecorder that captures events for a specific managed thread + /// + /// Thread ID to filter events by, or -1 for all threads + /// The SqlClient event keywords from https://learn.microsoft.com/sql/connect/ado-net/enable-eventsource-tracing. + /// Defaults to ExecutionTrace | Trace. + /// + public SqlClientEventRecorder(int managedThreadId, int keywords = 3, [CallerMemberName] string name = "") + : base("Microsoft.Data.SqlClient.EventSource", EventLevel.Verbose, (EventKeywords)keywords, managedThreadId, name) + { + } + } + + /// + /// SmoTraceEventRecorder captures SQL Server Management Objects (SMO) traces + /// + public class SmoTraceEventRecorder : EventRecorderBase + { + /// + /// Constructs a new SmoTraceEventRecorder that captures all SMO events on all threads + /// + public SmoTraceEventRecorder([CallerMemberName] string name = "") : this(-1, name) + { + } + + /// + /// Constructs a new SmoTraceEventRecorder that captures all SMO events for a specific managed thread + /// + /// Thread ID to filter events by, or -1 for all threads + /// + public SmoTraceEventRecorder(int managedThreadId, [CallerMemberName] string name = "") + : base("Microsoft-SqlServer-Management-Smo", EventLevel.Verbose, EventKeywords.All, managedThreadId, name) + { + } + + /// + /// Constructs a new SmoTraceEventRecorder with custom event level and keywords + /// + /// Verbosity level for events to record + /// Keyword mask for filtering events by functional area + /// Thread ID to filter events by, or -1 for all threads + public SmoTraceEventRecorder(EventLevel eventLevel, EventKeywords eventKeywords, int managedThreadId = -1) + : base("Microsoft-SqlServer-Management-Smo", eventLevel, eventKeywords, managedThreadId) + { + } + } } diff --git a/src/FunctionalTest/Framework/Helpers/TraceHelper.cs b/src/FunctionalTest/Framework/Helpers/TraceHelper.cs index 8b63692a..f70764cd 100644 --- a/src/FunctionalTest/Framework/Helpers/TraceHelper.cs +++ b/src/FunctionalTest/Framework/Helpers/TraceHelper.cs @@ -34,7 +34,7 @@ public static void DisableAutoFlush() /// public static void TraceInformation(string message) { - Trace.TraceInformation($"{DateTime.Now.ToString("o")} - {message}"); + Trace.TraceInformation(AddTimestamp(message)); } /// @@ -44,7 +44,36 @@ public static void TraceInformation(string message) /// public static void TraceInformation(string format, params object[] args) { - Trace.TraceInformation($"{DateTime.Now.ToString("o")} - {format}", args); + Trace.TraceInformation(AddTimestamp(format), args); + } + + /// + /// The default trace output lacks timestamps, this adds it + /// + /// + public static void TraceWarning(string message) + { + Trace.TraceWarning(AddTimestamp(message)); + } + + /// + /// The default trace output lacks timestamps, this adds it + /// + /// + /// + public static void TraceWarning(string format, params object[] args) + { + Trace.TraceWarning(AddTimestamp(format), args); + } + + /// + /// Helper method to add timestamp prefix to messages + /// + /// The message or format string + /// Message with timestamp prefix + private static string AddTimestamp(string message) + { + return $"{DateTime.Now:o} - {message}"; } } } diff --git a/src/FunctionalTest/Framework/Microsoft.SqlServer.Test.Manageability.Utils.csproj b/src/FunctionalTest/Framework/Microsoft.SqlServer.Test.Manageability.Utils.csproj index f2ec32b2..afe98bf4 100644 --- a/src/FunctionalTest/Framework/Microsoft.SqlServer.Test.Manageability.Utils.csproj +++ b/src/FunctionalTest/Framework/Microsoft.SqlServer.Test.Manageability.Utils.csproj @@ -24,6 +24,7 @@ + diff --git a/src/FunctionalTest/Framework/TestFramework/FabricDatabaseHandler.cs b/src/FunctionalTest/Framework/TestFramework/FabricDatabaseHandler.cs index d08e320c..61a907ea 100644 --- a/src/FunctionalTest/Framework/TestFramework/FabricDatabaseHandler.cs +++ b/src/FunctionalTest/Framework/TestFramework/FabricDatabaseHandler.cs @@ -18,12 +18,8 @@ public class FabricDatabaseHandler : DatabaseHandlerBase { public FabricDatabaseHandler(TestDescriptor descriptor) { - if (descriptor == null || !(descriptor is FabricWorkspaceDescriptor)) - { + TestDescriptor = (descriptor as FabricWorkspaceDescriptor) ?? throw new ArgumentException($"The descriptor must be of type {nameof(FabricWorkspaceDescriptor)}.", nameof(descriptor)); - } - - TestDescriptor = descriptor; } public override Database HandleDatabaseCreation(DatabaseParameters dbParameters) { @@ -31,18 +27,12 @@ public override Database HandleDatabaseCreation(DatabaseParameters dbParameters) string fabricDbName; var currentUtcTime = DateTime.UtcNow.ToString("yyyyMMddHHmmss"); var dbNamePrefix = $"{fabricWorkspaceDescriptor.DbNamePrefix}{currentUtcTime}-"; - if (dbParameters == null) - { - fabricDbName = SmoObjectHelpers.GenerateUniqueObjectName(dbNamePrefix); - } - else - { - fabricDbName = SmoObjectHelpers.GenerateUniqueObjectName(dbNamePrefix, - includeClosingBracket: dbParameters.UseEscapedCharacters, - includeDoubleClosingBracket: dbParameters.UseEscapedCharacters, - includeSingleQuote: dbParameters.UseEscapedCharacters, - includeDoubleSingleQuote: dbParameters.UseEscapedCharacters); - } + // Fabric does not allow some special characters in database names + fabricDbName = SmoObjectHelpers.GenerateUniqueObjectName(dbNamePrefix, + includeClosingBracket: false, + includeDoubleClosingBracket: false, + includeSingleQuote: false, + includeDoubleSingleQuote: false); //create fabric database using fabric-cli var connectionString = fabricWorkspaceDescriptor.CreateDatabase(fabricDbName); Trace.TraceInformation($"Created fabric database {fabricDbName}"); diff --git a/src/FunctionalTest/Framework/TestFramework/SqlTestBase.cs b/src/FunctionalTest/Framework/TestFramework/SqlTestBase.cs index c6bc61be..40ec6545 100644 --- a/src/FunctionalTest/Framework/TestFramework/SqlTestBase.cs +++ b/src/FunctionalTest/Framework/TestFramework/SqlTestBase.cs @@ -136,6 +136,10 @@ protected SqlConnectionStringBuilder SqlConnectionStringBuilder // This IDisposable manages the lifetime of the assert messages raised during our test. private IDisposable nUnitDisposable; + // Event recorders for capturing SQL Client and SMO events during test execution + private SqlClientEventRecorder sqlClientEventRecorder; + private SmoTraceEventRecorder smoTraceEventRecorder; + // Specific to Azure databases, represent all edition types public enum AzureDatabaseEdition { @@ -160,20 +164,34 @@ public void BaseTestInitialize() //We need to get the Assembly containing the implementation of this type so GetType will resolve it correctly //as FullyQualifiedTestClassName only contains the type name and not the assembly info (and GetType only //looks in mscorlib and the current executing assembly) - Type testClass = this.GetType().GetTypeInfo().Assembly.GetType(this.TestContext.FullyQualifiedTestClassName); - this.TestMethod = testClass.GetMethod(this.TestContext.TestName); + var testClass = this.GetType().GetTypeInfo().Assembly.GetType(TestContext.FullyQualifiedTestClassName); + TestMethod = testClass.GetMethod(TestContext.TestName); nUnitDisposable = new NUnit.Framework.Internal.TestExecutionContext.IsolatedContext(); + + // Initialize event recorders to capture SQL Client and SMO events during test execution + // Disable trace logging by default to reduce performance overhead + sqlClientEventRecorder = new SqlClientEventRecorder(Environment.CurrentManagedThreadId); + sqlClientEventRecorder.Start(); + + smoTraceEventRecorder = new SmoTraceEventRecorder(Environment.CurrentManagedThreadId); + smoTraceEventRecorder.Start(); + MyTestInitialize(); } [TestCleanup] public void TestCleanup() { - if (nUnitDisposable != null) - { - nUnitDisposable.Dispose(); - } + sqlClientEventRecorder.Stop(); + sqlClientEventRecorder.Dispose(); + sqlClientEventRecorder = null; + smoTraceEventRecorder.Stop(); + smoTraceEventRecorder.Dispose(); + smoTraceEventRecorder = null; + + nUnitDisposable.Dispose(); } + public virtual void MyTestInitialize() { } @@ -254,11 +272,7 @@ private void ExecuteTestImpl(Action executeTestMethod) // Fabric databases do not support have server context or master database, hence creating database if (databaseHandler is FabricDatabaseHandler) { - var dbParameters = new DatabaseParameters - { - UseEscapedCharacters = UseEscapedCharactersInDatabaseNames - }; - db = databaseHandler.HandleDatabaseCreation(dbParameters); + db = databaseHandler.HandleDatabaseCreation(new DatabaseParameters()); } this.ServerContext = databaseHandler.ServerContext; this.SqlConnectionStringBuilder = new SqlConnectionStringBuilder(this.ServerContext.ConnectionContext.ConnectionString); diff --git a/src/FunctionalTest/Framework/azuresqldwgen3.runsettings b/src/FunctionalTest/Framework/azuresqldwgen3.runsettings deleted file mode 100644 index 1de2e16b..00000000 --- a/src/FunctionalTest/Framework/azuresqldwgen3.runsettings +++ /dev/null @@ -1,128 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - .*Microsoft\.SqlServer\.Test\..* - - .*Microsoft\.SqlServer\.Management\.SqlParser\.dll - .*Microsoft\.SqlServer\.RegSvrEnum\.dll - - .*Microsoft\.SqlServer\.Management\.Utility\.dll - .*NUnit.* - .*moq.* - - - - - - - - - ^System\.Diagnostics\.DebuggerHiddenAttribute$ - ^System\.Diagnostics\.DebuggerNonUserCodeAttribute$ - ^System\.Runtime\.CompilerServices.CompilerGeneratedAttribute$ - ^System\.CodeDom\.Compiler.GeneratedCodeAttribute$ - ^System\.Diagnostics\.CodeAnalysis.ExcludeFromCodeCoverageAttribute$ - - - - - - - .*\\atlmfc\\.* - .*\\vctools\\.* - .*\\public\\sdk\\.* - .*\\microsoft sdks\\.* - .*\\vc\\include\\.* - - - - - - - .*DesignMode.* - .*DoDatabaseSpecialCase\(.* - .*GenerateStretchHeapWithClause.* - .*GetPropertyDefaultValue\(.* - .*InitFromSqlServer2005Store.* - .*InvalidSqlServer2005StoreFormatException.* - Microsoft\.SqlServer\.Management\.RegisteredServers.\RegisteredServersStore\.AddGroupMember.* - Microsoft\.SqlServer\.Management\.Sdk\.Sfc\.SfcSerializer.* - Microsoft\.SqlServer\.Management\.Smo\.AvailableSQLServers.* - Microsoft\.SqlServer\.Management\.Smo\.DatabaseDdlTriggerEventSet.* - Microsoft\.SqlServer\.Management\.Smo\.PostProcessServerDdlTriggerEvents.* - Microsoft\.SqlServer\.Management\.Smo\.ServerDdlTriggerEvent.* - Microsoft\.SqlServer\.Management\.Smo\.SqlSmoObject\.GetChildSingleton.* - Microsoft\.SqlServer\.Management\.Smo\.SqlSmoObject\.SetAccessToken.* .*PopulateV7.* - .*PopulateV7.* - .*PopulateV9.* - .*ScriptAlterLess9.* - .*ScriptDbProps70Comp.* - .*ScriptCreateLess9.* - .*TestNetSend - .*ThrowIfBelowVersion80SP3.* - .*ThrowIfAboveVersion80.* - .*ThrowIfAboveVersion100.* - .*ThrowIfSourceOrDestBelowVersion80.* - .*ThrowIfSourceOrDestBelowVersion90.* - .*ThrowIfSourceOrDestBelowVersion100.* - .*UpgradeFromSqlServer2005.* - - - - - - - ^B03F5F7F11D50A3A$ - ^71E9BCE111E9429C$ - ^8F50407C4E9E73B6$ - ^E361AF139669C375$ - - ^AE41E2615877EB90$ - - - - - True - True - True - False - - - - - - - \ No newline at end of file diff --git a/src/FunctionalTest/Framework/fabricnative.runsettings b/src/FunctionalTest/Framework/fabricmsitworkspace.runsettings similarity index 91% rename from src/FunctionalTest/Framework/fabricnative.runsettings rename to src/FunctionalTest/Framework/fabricmsitworkspace.runsettings index 1e77fb06..c988640b 100644 --- a/src/FunctionalTest/Framework/fabricnative.runsettings +++ b/src/FunctionalTest/Framework/fabricmsitworkspace.runsettings @@ -1,8 +1,11 @@ + + true + - + @@ -35,8 +38,8 @@ Included items must then not match any entries in the exclude list to remain inc .*Microsoft\.SqlServer\.Test\..* - - .*Microsoft\.SqlServer\.Management\.SqlParser\.dll + + .*Microsoft\.SqlServer\.Management\.SqlParser\.dll .*NUnit.* .*moq.* diff --git a/src/FunctionalTest/Identity/Microsoft.SqlServer.ADO.Identity.csproj b/src/FunctionalTest/Identity/Microsoft.SqlServer.ADO.Identity.csproj index 05f8d592..162420ce 100644 --- a/src/FunctionalTest/Identity/Microsoft.SqlServer.ADO.Identity.csproj +++ b/src/FunctionalTest/Identity/Microsoft.SqlServer.ADO.Identity.csproj @@ -16,6 +16,11 @@ + + + + + diff --git a/src/FunctionalTest/Smo/DMF/ExecutionHistoryTests.cs b/src/FunctionalTest/Smo/DMF/ExecutionHistoryTests.cs index 89396aa5..d45a2288 100644 --- a/src/FunctionalTest/Smo/DMF/ExecutionHistoryTests.cs +++ b/src/FunctionalTest/Smo/DMF/ExecutionHistoryTests.cs @@ -39,7 +39,8 @@ public partial class PolicyTests : SqlTestBase /// [TestMethod] [SupportedServerVersionRange(DatabaseEngineType = DatabaseEngineType.Standalone, MinMajor = 10)] - + // This is flakey on MI so disabling for now + [UnsupportedDatabaseEngineEdition(DatabaseEngineEdition.SqlManagedInstance)] public void When_LogOnSuccess_is_true_Policy_EvaluationHistories_match_server_data() { ExecuteWithDbDrop(db => @@ -322,6 +323,7 @@ public void When_Database_is_offline_evaluate_does_not_record_an_exception() } finally { + db.SetOnline(); // bring the db back online so dropping it also deletes its files SmoObjectHelpers.SafeDrop(policy, condition, objectSet, dbNameCondition); } }); diff --git a/src/FunctionalTest/Smo/GeneralFunctionality/DatabaseSmoTests.cs b/src/FunctionalTest/Smo/GeneralFunctionality/DatabaseSmoTests.cs index 4bd85bf3..c92dbe28 100644 --- a/src/FunctionalTest/Smo/GeneralFunctionality/DatabaseSmoTests.cs +++ b/src/FunctionalTest/Smo/GeneralFunctionality/DatabaseSmoTests.cs @@ -54,7 +54,7 @@ public void Database_Scripting_Alter_When_Database_Is_Restoring_succeeds() // Get path to the backup file backupfile = Path.Combine(db.Parent.BackupDirectory, $"{db.Name}.bak"); - + // Restore database with NORECOVERY (in OE, it shos as "Restoring..." restoringDb = DatabaseObjectHelpers.RestoreDatabaseFromBackup(db.Parent, backupfile, db.Name + "_new", withNoRecovery: true); @@ -211,7 +211,8 @@ public void Database_Drop_DW_throws_when_Parent_is_user_database() public void Database_SpaceAvailable_Is_Zero_For_DW() { ExecuteTest( - srv => { + srv => + { Database_SpaceAvailable_Is_Zero(AzureDatabaseEdition.DataWarehouse); }); } @@ -226,7 +227,8 @@ public void Database_SpaceAvailable_Is_Zero_For_DW() public void Database_SpaceAvailable_Is_Zero_For_Hyperscale() { ExecuteTest( - srv => { + srv => + { Database_SpaceAvailable_Is_Zero(AzureDatabaseEdition.Hyperscale); }); } @@ -286,7 +288,7 @@ CREATE CERTIFICATE DEK_SmoTestSuite_ServerCertificate "DatabaseEncryptionKey.State post-Alter"); // We can't immediately toggle encryption until the first change is done var maxWaits = 300; - while (maxWaits-- > 0 && + while (maxWaits-- > 0 && (db.DatabaseEncryptionKey.EncryptionState == DatabaseEncryptionState.EncryptionInProgress || db.DatabaseEncryptionKey.EncryptionState == DatabaseEncryptionState.DecryptionInProgress)) { Thread.Sleep(100); @@ -372,13 +374,13 @@ public void Database_PrefetchObjects_does_not_fetch_extended_properties_unless_r { // make sure we have a table _ = db.CreateTable("Prefetch"); - + { fetchExtendedProperties = db.DatabaseEngineEdition != DatabaseEngineEdition.SqlDatabase; } - var scriptingOptions = fetchExtendedProperties.HasValue ? + var scriptingOptions = fetchExtendedProperties.HasValue ? new ScriptingOptions { ExtendedProperties = fetchExtendedProperties.Value } : null; - using (var eventRecorder = new SqlClientEventRecorder(Environment.CurrentManagedThreadId)) + using (var eventRecorder = new SqlClientEventRecorder(Environment.CurrentManagedThreadId) { EnableTraceLogging = false }) { eventRecorder.Start(); if (scriptingOptions != null) @@ -391,23 +393,10 @@ public void Database_PrefetchObjects_does_not_fetch_extended_properties_unless_r } eventRecorder.Stop(); var messages = string.Join(Environment.NewLine, eventRecorder.Events.SelectMany(e => e.Payload).Select(p => p.ToString())); - messages = messages.Replace(@"CAST( - case - when tbl.is_ms_shipped = 1 then 1 - when ( - select - major_id + messages = messages.Replace(@"select + 1 from - sys.extended_properties - where - major_id = tbl.object_id and - minor_id = 0 and - class = 1 and - name = N'microsoft_database_tools_support') - is not null then 1 - else 0 -end - AS bit) AS [IsSystemObject],".FixNewLines(), ""); + sys.extended_properties".FixNewLines(), ""); if (fetchExtendedProperties ?? true) { Assert.That(messages, Does.Contain("extended_properties"), "PrefetchObjects(Table, ScriptingOptions) should fetch extended properties"); @@ -437,7 +426,8 @@ is not null then 1 typeof(SymmetricKey), typeof(AsymmetricKey), typeof(ApplicationRole), - typeof(ExternalLanguage) + typeof(ExternalLanguage), + typeof(ExternalModel) }; private static readonly IEnumerable extraPrefetchedTypes = new[] @@ -483,7 +473,7 @@ private static void CheckTablesDataOnlyAllRepairTypes(_SMO.Database db) }), "CheckTablesDataOnly() messages"); Assert.That(commands, Is.EqualTo(new[] { $"DBCC CHECKDB(N{db.Name.SqlSingleQuoteString()}, NOINDEX)" }), "CheckTablesDataOnly"); - commands = db.ExecutionManager.RecordQueryText(() => + commands = db.ExecutionManager.RecordQueryText(() => messages = db.CheckTablesDataOnly(RepairOptions.AllErrorMessages | RepairOptions.ExtendedLogicalChecks | RepairOptions.NoInformationMessages | RepairOptions.TableLock | @@ -550,13 +540,13 @@ private static void CheckTablesAllRepairTypes(_SMO.Database db) Assert.That(messages, Is.Empty, "CheckTables(RepairType.Fast) messages"); Assert.That(commands, Is.EqualTo(new[] { $"DBCC CHECKDB(N{db.Name.SqlSingleQuoteString()}, REPAIR_FAST) WITH NO_INFOMSGS" }), "CheckTables(RepairType.Fast"); - commands = db.ExecutionManager.RecordQueryText(() => + commands = db.ExecutionManager.RecordQueryText(() => messages = db.CheckTables(RepairType.AllowDataLoss).Cast().ToList(), alsoExecute: true) .Cast().ToList(); Assert.That(messages, Is.Empty, "CheckTables(RepairType.AllowDataLoss) messages"); Assert.That(commands, Is.EqualTo(new[] { $"DBCC CHECKDB(N{db.Name.SqlSingleQuoteString()}, REPAIR_ALLOW_DATA_LOSS) WITH NO_INFOMSGS" }), "CheckTables(RepairType.AllowDataLoss"); - commands = db.ExecutionManager.RecordQueryText(() => + commands = db.ExecutionManager.RecordQueryText(() => messages = db.CheckTables(RepairType.AllowDataLoss, RepairStructure.DataPurity).Cast().ToList(), alsoExecute: true) .Cast().ToList(); Assert.That(messages.Take(1), Is.EqualTo(new object[] @@ -565,7 +555,7 @@ private static void CheckTablesAllRepairTypes(_SMO.Database db) }), "CheckTables(RepairType.AllowDataLoss, RepairStructure.DataPurity) messages"); Assert.That(commands, Is.EqualTo(new[] { $"DBCC CHECKDB(N{db.Name.SqlSingleQuoteString()}, REPAIR_ALLOW_DATA_LOSS) WITH DATA_PURITY " }), "CheckTables(RepairType.AllowDataLoss, RepairStructure.DataPurity"); - commands = db.ExecutionManager.RecordQueryText(() => + commands = db.ExecutionManager.RecordQueryText(() => messages = db.CheckTables(RepairType.AllowDataLoss, RepairOptions.EstimateOnly).Cast().ToList(), alsoExecute: true) .Cast().ToList(); Assert.That(messages, Has.Member("DBCC execution completed. If DBCC printed error messages, contact your system administrator."), "CheckTables(RepairType.AllowDataLoss, RepairOptions.EstimateOnly) messages"); @@ -573,7 +563,7 @@ private static void CheckTablesAllRepairTypes(_SMO.Database db) "CheckTables(RepairType.AllowDataLoss, RepairOptions.EstimateOnly"); if (db.DatabaseEngineType == DatabaseEngineType.SqlAzureDatabase || db.Parent.VersionMajor > 12) { - commands = db.ExecutionManager.RecordQueryText( () => + commands = db.ExecutionManager.RecordQueryText(() => messages = db.CheckTables(RepairType.None, RepairOptions.None, RepairStructure.PhysicalOnly, maxDOP: 2).Cast().ToList(), alsoExecute: true) .Cast().ToList(); @@ -599,7 +589,7 @@ private static void CheckTablesAllRepairTypes(_SMO.Database db) private static void CheckAllocationsAllRepairTypes(Database db) { var messages = Enumerable.Empty(); - var commands = db.ExecutionManager.RecordQueryText(() => + var commands = db.ExecutionManager.RecordQueryText(() => messages = db.CheckAllocations(RepairType.None).Cast().ToList(), alsoExecute: true) .Cast(); Assert.That(messages, Is.Empty, "CheckAllocations(RepairType.None) messages"); @@ -760,9 +750,9 @@ public void Database_EnumLocks() public void Database_SetDefaultFileStreamFileGroup_succeeds() { ExecuteWithDbDrop(db => - { - var fileGroup = new FileGroup(db, "filegroup1", isFileStream:false); - fileGroup.Files.Add(new DataFile(fileGroup, "datafile1", System.IO.Path.Combine(db.PrimaryFilePath, "filename1.mdf"))); + { + var fileGroup = new FileGroup(db, "filegroup1", isFileStream: false); + fileGroup.Files.Add(new DataFile(fileGroup, "datafile1", System.IO.Path.Combine(db.PrimaryFilePath, $"{db.Name}_FN1.mdf"))); db.FileGroups.Add(fileGroup); db.Alter(); Assert.That(() => db.SetDefaultFileStreamFileGroup(fileGroup.Name), Throws.Nothing, $"SetDefaultFileStreamFileGroup({fileGroup.Name})"); @@ -795,7 +785,7 @@ public void Database_IsLocalPrimaryReplica_returns_false_appropriately() ExecuteFromDbPool(db => { var expected = db.DatabaseEngineType != DatabaseEngineType.SqlAzureDatabase && db.IsSupportedProperty(nameof(db.AvailabilityGroupName)) && !string.IsNullOrEmpty(db.AvailabilityGroupName); - Assert.That(db.IsLocalPrimaryReplica, Is.EqualTo(expected), "IsLocalPrimaryReplica"); + Assert.That(db.IsLocalPrimaryReplica, Is.EqualTo(expected), "IsLocalPrimaryReplica"); }); } @@ -1063,7 +1053,7 @@ public void Database_Alter_ignores_accelerated_recovery_on_managed_instances(boo db.Alter(); db.Parent.Databases.ClearAndInitialize(string.Format("[@Name='{0}']", Urn.EscapeString(db.Name)), new string[] { nameof(Database.AcceleratedRecoveryEnabled) }); db = db.Parent.Databases[db.Name]; - + // Accelerated recovery should always be 'true' // Assert.IsTrue( @@ -1092,6 +1082,36 @@ public void Database_Alter_toggles_optimized_locking() }); } + /// + /// If at any point we attempt to run an alter command that would result in AcceleratedDatabaseRecovery (ADR) + /// being disabled while OptimizedLocking (OL) is enabled, we will get an error, as OL cannot be enabled without ADR. + /// This means that when both features get enabled, ADR must be enabled first, whereas when both features + /// get disabled, OL must be disabled first. If this order is not respected, we should see an error in this test. + /// + [TestMethod] + [SupportedServerVersionRange(Edition = DatabaseEngineEdition.Enterprise, MinMajor = 17)] + public void Database_Alter_accelerated_database_recovery_and_optimized_locking_get_scripted_in_right_order() + { + ExecuteFromDbPool(db => + { + var adrAndOl = new string[] { nameof(Database.AcceleratedRecoveryEnabled), nameof(Database.OptimizedLockingOn) }; + db.AcceleratedRecoveryEnabled = true; + db.OptimizedLockingOn = true; + db.Alter(); + db.Parent.Databases.ClearAndInitialize(string.Format("[@Name='{0}']", Urn.EscapeString(db.Name)), adrAndOl); + db = db.Parent.Databases[db.Name]; + Assert.That(db.AcceleratedRecoveryEnabled, Is.True, "AcceleratedRecoveryEnabled set to true by Alter"); + Assert.That(db.OptimizedLockingOn, Is.True, "OptimizedLockingOn set to true by Alter"); + db.AcceleratedRecoveryEnabled = false; + db.OptimizedLockingOn = false; + db.Alter(); + db.Parent.Databases.ClearAndInitialize(string.Format("[@Name='{0}']", Urn.EscapeString(db.Name)), adrAndOl); + db = db.Parent.Databases[db.Name]; + Assert.That(db.OptimizedLockingOn, Is.False, "AcceleratedRecoveryEnabled set to false by Alter"); + Assert.That(db.OptimizedLockingOn, Is.False, "OptimizedLockingOn set to false by Alter"); + }); + } + [TestMethod] [SupportedServerVersionRange(Edition = DatabaseEngineEdition.Enterprise, MinMajor = 12)] public void Database_ChangeMirroringState_creates_correct_script() @@ -1189,7 +1209,7 @@ public void Database_Size_succeeds_with_CaptureSql_on() #if MICROSOFTDATA [TestMethod] - [SupportedServerVersionRange(Edition=DatabaseEngineEdition.SqlDatabase)] + [SupportedServerVersionRange(Edition = DatabaseEngineEdition.SqlDatabase)] [UnsupportedFeature(SqlFeature.Fabric)] public void Database_enumerating_databases_does_not_login_to_each_database() { @@ -1197,16 +1217,16 @@ public void Database_enumerating_databases_does_not_login_to_each_database() { // Get the server's DatabaseEngineType first so that query doesn't get made during the collection enumeration Manageability.Utils.Helpers.TraceHelper.TraceInformation($"Main connection engine type: {ServerContext.DatabaseEngineType}"); - using (var eventRecorder = new SqlClientEventRecorder(Environment.CurrentManagedThreadId)) + using (var eventRecorder = new SqlClientEventRecorder(Environment.CurrentManagedThreadId) { EnableTraceLogging = false }) { eventRecorder.Start(); - ServerContext.Databases.ClearAndInitialize("[@IsSystemObject = false()]", new[] {nameof(Database.Status)}); + ServerContext.Databases.ClearAndInitialize("[@IsSystemObject = false()]", new[] { nameof(Database.Status) }); eventRecorder.Stop(); var messages = eventRecorder.Events.SelectMany(e => e.Payload).Select(p => p.ToString()); Assert.That(messages, Has.None.Contains("sc.TdsParser.SendPreLoginHandshake"), "No logins should have occurred - Status only"); Assert.That(messages, Has.None.Contains("SERVERPROPERTY('EngineEdition') AS DatabaseEngineEdition,"), "No query for DatabaseEngineEdition should have been made - Status only"); } - using (var eventRecorder = new SqlClientEventRecorder(Environment.CurrentManagedThreadId)) + using (var eventRecorder = new SqlClientEventRecorder(Environment.CurrentManagedThreadId) { EnableTraceLogging = false }) { eventRecorder.Start(); ServerContext.Databases.ClearAndInitialize(string.Empty, Enumerable.Empty()); @@ -1214,10 +1234,10 @@ public void Database_enumerating_databases_does_not_login_to_each_database() var messages = eventRecorder.Events.SelectMany(e => e.Payload).Select(p => p.ToString()); Assert.That(messages, Has.None.Contains("sc.TdsParser.SendPreLoginHandshake"), "No logins should have occurred - No properties"); Assert.That(messages, Has.None.Contains("SERVERPROPERTY('EngineEdition') AS DatabaseEngineEdition,"), "No query for DatabaseEngineEdition should have been made - No properties"); - Assert.That(ServerContext.Databases.Cast().Select( d=> d.Name), Has.Member("master"), "Should have at least master"); + Assert.That(ServerContext.Databases.Cast().Select(d => d.Name), Has.Member("master"), "Should have at least master"); } // Querying for Status and other properties goes through a different path. Don't use any PostProcess properties for the test, as they require a login to the user db. - using (var eventRecorder = new SqlClientEventRecorder(Environment.CurrentManagedThreadId)) + using (var eventRecorder = new SqlClientEventRecorder(Environment.CurrentManagedThreadId) { EnableTraceLogging = false }) { eventRecorder.Start(); ServerContext.Databases.ClearAndInitialize("[@IsSystemObject = false()]", new[] { nameof(Database.Status), nameof(Database.ChangeTrackingEnabled) }); @@ -1228,8 +1248,6 @@ public void Database_enumerating_databases_does_not_login_to_each_database() } }); } - #endif } - } diff --git a/src/FunctionalTest/Smo/GeneralFunctionality/WorkloadSmoTests.cs b/src/FunctionalTest/Smo/GeneralFunctionality/WorkloadSmoTests.cs index 8baf87ca..0cf94886 100644 --- a/src/FunctionalTest/Smo/GeneralFunctionality/WorkloadSmoTests.cs +++ b/src/FunctionalTest/Smo/GeneralFunctionality/WorkloadSmoTests.cs @@ -142,18 +142,26 @@ public void Workload_Verify_TempdbProperties_MinusOne_Excluded_From_Script() workloadGroup.GroupMaximumTempdbDataPercent = -1; } - var commands = server.ExecutionManager.RecordQueryText(workloadGroup.Create, false).Cast(); - - // When properties are set to -1, they should be excluded from the script (treated as null) - string expected = $"CREATE WORKLOAD GROUP [WorkloadTempdbMinusOne_] USING [default]"; - Assert.That(commands, Has.Member(expected), "Invalid Query to Create Workload Group - TempDB properties with -1 should be excluded from script"); + var createCommand = server.ExecutionManager.RecordQueryText(workloadGroup.Create, false).Cast().ToList(); - // Verify that the script does NOT contain the TempDB properties when set to -1 - foreach (string command in commands) - { - Assert.That(command, Does.Not.Contain("group_max_tempdb_data_mb"), "Script should not contain group_max_tempdb_data_mb when set to -1"); - Assert.That(command, Does.Not.Contain("group_max_tempdb_data_percent"), "Script should not contain group_max_tempdb_data_percent when set to -1"); - } + // Find the CREATE WORKLOAD GROUP statement (may be preceded by USE statement) + var createStatement = createCommand.FirstOrDefault(c => c.Contains("CREATE WORKLOAD GROUP")); + Assert.That(createStatement, Is.Not.Null, "CREATE WORKLOAD GROUP statement not found in script"); + + // When properties are set to -1, they should be included in the script (treated as null) + Assert.That(createStatement, Does.Contain("group_max_tempdb_data_mb=null"), "Script should contain group_max_tempdb_data_mb=null when set to -1"); + Assert.That(createStatement, Does.Contain("group_max_tempdb_data_percent=null"), "Script should contain group_max_tempdb_data_percent=null when set to -1"); + Assert.That(createStatement, Does.Contain("USING [default]"), "Script should specify USING [default]"); + + var alterCommand = server.ExecutionManager.RecordQueryText(workloadGroup.Alter, false).Cast().ToList(); + + // Find the ALTER WORKLOAD GROUP statement (may be preceded by USE statement) + var alterStatement = alterCommand.FirstOrDefault(c => c.Contains("ALTER WORKLOAD GROUP")); + Assert.That(alterStatement, Is.Not.Null, "ALTER WORKLOAD GROUP statement not found in script"); + + // When properties are set to -1, they should be included in the script (treated as null) + Assert.That(alterStatement, Does.Contain("group_max_tempdb_data_mb=null"), "Script should contain group_max_tempdb_data_mb=null when set to -1"); + Assert.That(alterStatement, Does.Contain("group_max_tempdb_data_percent=null"), "Script should contain group_max_tempdb_data_percent=null when set to -1"); }); } } diff --git a/src/FunctionalTest/Smo/Microsoft.SqlServer.Test.Smo.csproj b/src/FunctionalTest/Smo/Microsoft.SqlServer.Test.Smo.csproj index 067c4c9c..8ec6b165 100644 --- a/src/FunctionalTest/Smo/Microsoft.SqlServer.Test.Smo.csproj +++ b/src/FunctionalTest/Smo/Microsoft.SqlServer.Test.Smo.csproj @@ -10,7 +10,6 @@ $(NoWarn);NU1603;NU1202 - diff --git a/src/FunctionalTest/Smo/README.md b/src/FunctionalTest/Smo/README.md deleted file mode 100644 index 05377433..00000000 --- a/src/FunctionalTest/Smo/README.md +++ /dev/null @@ -1,34 +0,0 @@ -# Intro - -SMO tests are designed to executed by the vstest runner. We use NUnit for its fluent asserts and constraints which are extremely expressive. -See [ToolsConnectionInfo.xml](./ToolsConnectionInfo.xml) to learn how to point the tests at a SQL Server instance. - -## Test philosophy - -1. The name of the test should specify what is being tested and what the expected behavior is. Long names are great! Having the object type as the initial part of the method name helps group related tests visually and enables finding them in Test Explorer with a filter. -2. The test log should be sufficient to identify the reason for a test failure. We shouldn't have to go digging in the source code or run the test locally in the debugger to understand what failed. -3. All bug fixes must be accompanied by a test which would have failed before the fix and now passes with it. -4. SMO PR verification builds measure differential code coverage. We have a goal of covering 80% of all new code with tests. - - -## Test Categorization - -Use "Legacy" category to mark tests that cover old/deprecated functionality and shouldn't be run during Pull Request validation. - -## Implementation notes - -### SqlTestBase - -Test classes should inherit from SqlTestBase. If for some reason your test precludes such inheritance, replicate its workaround for NUnit Assert's incompatibility with the vstest runner. - -#### ExecuteWithDBDrop - -This method is the most common way to wrap test code in a delegate that gets invoked once for each supported target server version. It creates a new database using an optional name prefix and optional edition, invokes the test delegate, then deletes the database. - -##### Database caching - -For tests that aren't compatible with Azure SQL DW, you can use ExecuteFromDbPool to recycle an existing database associated with the current server. This Database object is guaranteed to have been created on the same thread as the test execution. - -### Use NUnit constraint-based asserts - -NUnit asserts print nice error messages when they fail, like the contents of a collection or subsets of mismatched strings showing where the comparison failed. diff --git a/src/FunctionalTest/Smo/ScriptingTests/Database_SmoTestSuite.cs b/src/FunctionalTest/Smo/ScriptingTests/Database_SmoTestSuite.cs index 904b0f34..d807f3de 100644 --- a/src/FunctionalTest/Smo/ScriptingTests/Database_SmoTestSuite.cs +++ b/src/FunctionalTest/Smo/ScriptingTests/Database_SmoTestSuite.cs @@ -147,27 +147,21 @@ public void SmoDatabase_AvailabilityDatabaseSynchronizationState_OnPremV11OrNewe [SupportedServerVersionRange(DatabaseEngineType = DatabaseEngineType.Standalone, Edition = DatabaseEngineEdition.SqlManagedInstance)] public void SmoDatabase_AvailabilityDatabaseSynchronizationState_ManagedInstance() { - ExecuteTest( - server => + ExecuteFromDbPool(db => + { + _ = Assert.Throws(() => { var state = db.AvailabilityDatabaseSynchronizationState; }, + "Accessing the property AvailabilityDatabaseSynchronizationState should throw an exception when it's not applicable."); + var databasesWithNonNullSyncState = GetDatabasesWithNonNullSynchronizationState(db.Parent); + foreach (Database nullSyncDb in db.Parent.Databases) { - var databasesWithNonNullSyncState = GetDatabasesWithNonNullSynchronizationState(server); - - foreach (_SMO.Database db in server.Databases) + if (databasesWithNonNullSyncState.Contains(nullSyncDb.Name)) { - if (databasesWithNonNullSyncState.Contains(db.Name)) - { - Assert.That(() => db.AvailabilityDatabaseSynchronizationState, - Is.EqualTo(AvailabilityDatabaseSynchronizationState.Synchronized), - "AvailabilityDatabaseSynchronizationState should be Synchronized."); - } - else - { - Assert.Throws(() => { var state = db.AvailabilityDatabaseSynchronizationState; }, - "Accessing the property AvailabilityDatabaseSynchronizationState should throw an exception when it's not applicable."); - } + Assert.That(() => db.AvailabilityDatabaseSynchronizationState, + Is.EqualTo(AvailabilityDatabaseSynchronizationState.Synchronized), + "AvailabilityDatabaseSynchronizationState should be Synchronized."); } - - }); + } + }); } private static List GetDatabasesWithNonNullSynchronizationState(_SMO.Server server) @@ -415,7 +409,7 @@ public void SmoDatabaseScriptAlter_AllServers() if (database.DatabaseEngineEdition == DatabaseEngineEdition.SqlDatabase) { database.MaxSizeInBytes = 250.0 * 1024 * 1024 * 1024; - database.AzureServiceObjective = database.AzureEdition == "Standard" ? "P0" : "S0"; + database.AzureServiceObjective = database.AzureEdition == "Standard" ? "P1" : "S0"; database.AzureEdition = database.AzureEdition == "Standard" ? "Premium" : "Standard"; } database.Alter(); diff --git a/src/FunctionalTest/Smo/ScriptingTests/ExternalModel_SmoTestSuite.cs b/src/FunctionalTest/Smo/ScriptingTests/ExternalModel_SmoTestSuite.cs new file mode 100644 index 00000000..a2fea834 --- /dev/null +++ b/src/FunctionalTest/Smo/ScriptingTests/ExternalModel_SmoTestSuite.cs @@ -0,0 +1,281 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +using System; +using System.Collections.Specialized; +using System.Linq; +using System.Text; +using Microsoft.SqlServer.Management.Common; +using Microsoft.SqlServer.Test.Manageability.Utils; +using Microsoft.SqlServer.Test.Manageability.Utils.Helpers; +using Microsoft.SqlServer.Test.Manageability.Utils.TestFramework; +using Microsoft.SqlServer.Management.Smo; +using NUnit.Framework; +using _SMO = Microsoft.SqlServer.Management.Smo; +using _VSUT = Microsoft.VisualStudio.TestTools.UnitTesting; +using static Microsoft.SqlServer.Management.SqlParser.MetadataProvider.MetadataProviderUtils.Names; + +namespace Microsoft.SqlServer.Test.SMO.ScriptingTests +{ + /// + /// Test suite for testing External Model properties and scripting. + /// + [_VSUT.TestClass] + [SupportedServerVersionRange(DatabaseEngineType = DatabaseEngineType.Standalone, MinMajor = 17)] + [UnsupportedDatabaseEngineEdition(DatabaseEngineEdition.SqlManagedInstance, DatabaseEngineEdition.SqlOnDemand)] + public class ExternalModel_SmoTestSuite : SmoObjectTestBase + { + #region Static Vars + + private static readonly string SetupScript = + "IF NOT EXISTS (SELECT * FROM sys.external_models WHERE name = N'TestModel') " + + "BEGIN " + + "EXEC sp_executesql N'" + + "CREATE EXTERNAL MODEL [TestModel] " + + "WITH ( " + + "LOCATION = ''https://models.example.com/testmodel.onnx'', " + + "API_FORMAT = ''OpenAI'', " + + "MODEL_TYPE = Embeddings, " + + "MODEL = ''all-minilm'', " + + "PARAMETERS = ''{\"valid\" : \"json\"}'', " + + "CREDENTIAL = OpenAiMSCred " + + ")' " + + "END"; + + #endregion + + #region Database Test Helpers + + /// + /// Runs the setup scripts for the specified targetServer. + /// + /// Database. + internal static void SetupDb(_SMO.Database db) + { + TraceHelper.TraceInformation($"Setting up database {db.Name}"); + + // Create the credential required for external model + db.ExecuteNonQuery( + "IF NOT EXISTS (SELECT * FROM sys.database_scoped_credentials WHERE name = N'OpenAiMSCred') " + + "BEGIN " + + "CREATE DATABASE SCOPED CREDENTIAL OpenAiMSCred " + + "WITH IDENTITY = 'System Managed Identity'; " + + "END"); + + db.ExecuteNonQuery(SetupScript); + } + + #endregion + + #region Helpers + + /// + /// Test Create, Alter, and Drop of ExternalModel. + /// + /// + private void TestCreateAlterDrop(_SMO.Database db) + { + // Ensure login and user exist + db.ExecuteNonQuery($@" +IF NOT EXISTS (SELECT name FROM sys.server_principals WHERE name = N'NewUserLogin') +BEGIN + CREATE LOGIN [NewUserLogin] WITH PASSWORD = '{SqlTestRandom.GeneratePassword()}'; +END; + +IF NOT EXISTS (SELECT name FROM sys.database_principals WHERE name = N'NewUser') +BEGIN + CREATE USER [NewUser] FOR LOGIN [NewUserLogin]; +END; +"); + + // Ensure credential exists + db.ExecuteNonQuery(@" +IF NOT EXISTS (SELECT * FROM sys.database_scoped_credentials WHERE name = N'OpenAiMSCred') +BEGIN + CREATE DATABASE SCOPED CREDENTIAL OpenAiMSCred + WITH IDENTITY = 'System Managed Identity'; +END; +"); + + // Grant permission on credential to the new user + db.ExecuteNonQuery(@" +GRANT REFERENCES ON DATABASE SCOPED CREDENTIAL::OpenAiMSCred TO [NewUser]; +"); + // Create a new external model + var modelName = GenerateUniqueSmoObjectName("ExternalModel"); + var model = new _SMO.ExternalModel(db, modelName) + { + Location = "https://models.example.com/testmodel.onnx", + ApiFormat = "OpenAI", + ModelType = ExternalModelType.Embeddings, + Model = "all-minilm", + Parameters = "{\"valid\" : \"json\"}", + Credential = "OpenAiMSCred", + Owner = "NewUser" + }; + + model.Create(); + db.ExternalModels.Refresh(); + + // Verify model exists in SMO collection + Assert.That(db.ExternalModels.Cast<_SMO.ExternalModel>().Select(m => m.Name), Has.Member(model.Name), + $"Model {model.Name} is not created in setup."); + + // Verify model exists in system catalog + var dataSet = db.ExecuteWithResults($"SELECT * FROM sys.external_models WHERE name = '{SmoObjectHelpers.SqlEscapeSingleQuote(model.Name)}'"); + var table = dataSet.Tables[0]; + Assert.That(table.Rows.Count, Is.EqualTo(1), $"The model {model.Name} is not created."); + + // Get principal_id from the table + var principalId = Convert.ToInt32(table.Rows[0]["principal_id"]); + + // Resolve OwnerName using USER_NAME(principal_id) + var ds = db.ExecuteWithResults($"SELECT USER_NAME({principalId}) AS OwnerName"); + var ownerName = ds.Tables[0].Rows[0]["OwnerName"].ToString(); + + // Assert OwnerName matches expected + Assert.That(ownerName, Is.EqualTo(model.Owner), + $"Expected Owner in sys.external_models to be '{model.Owner}', but got '{ownerName}'."); + + // Alter all properties + var newLocation = "https://models.example.com/updatedmodel.onnx"; + var newApiFormat = "Ollama"; + var newModelType = ExternalModelType.Embeddings; + var newModelName = "updated-minilm"; + var newParameters = "{\"updated\":\"json\"}"; + var newCredential = "OpenAiMSCred"; // Keep same or change if needed + + model.Location = newLocation; + model.ApiFormat = newApiFormat; + model.ModelType = newModelType; + model.Model = newModelName; + model.Parameters = newParameters; + model.Credential = newCredential; + + model.Alter(); + model.Refresh(); + + // Verify all updated properties + var updatedModel = db.ExternalModels[model.Name]; + Assert.That(updatedModel.Location, Is.EqualTo(newLocation), $"Expected Location to be updated to {newLocation}, but got {updatedModel.Location}"); + Assert.That(updatedModel.ApiFormat, Is.EqualTo(newApiFormat), $"Expected ApiFormat to be updated to {newApiFormat}, but got {updatedModel.ApiFormat}"); + Assert.That(updatedModel.ModelType, Is.EqualTo(newModelType), $"Expected ModelType to be updated to {newModelType}, but got {updatedModel.ModelType}"); + Assert.That(updatedModel.Model, Is.EqualTo(newModelName), $"Expected Model to be updated to {newModelName}, but got {updatedModel.Model}"); + Assert.That(updatedModel.Parameters, Is.EqualTo(newParameters), $"Expected Parameters to be updated to {newParameters}, but got {updatedModel.Parameters}"); + Assert.That(updatedModel.Credential, Is.EqualTo(newCredential), $"Expected Credential to be updated to {newCredential}, but got {updatedModel.Credential}"); + + // Drop the model + model.Drop(); + VerifyIsSmoObjectDropped(model, db); + } + + protected override void VerifyIsSmoObjectDropped(_SMO.SqlSmoObject obj, _SMO.SqlSmoObject objVerify) + { + _SMO.ExternalModel model = (_SMO.ExternalModel)obj; + _SMO.Database database = (_SMO.Database)objVerify; + + database.ExternalModels.Refresh(); + Assert.That(database.ExternalModels[model.Name], Is.Null, + $"Model {model.Name} is not dropped with DropIfExists."); + + var dataSet = database.ExecuteWithResults($"SELECT * FROM sys.external_models WHERE name = '{SmoObjectHelpers.SqlEscapeSingleQuote(model.Name)}'"); + var table = dataSet.Tables[0]; + Assert.That(table.Rows.Count, Is.EqualTo(0), $"The model {model.Name} is not dropped."); + } + + #endregion + + #region Scripting Tests + + /// + /// Validate that the Properties for ExternalModel can be enumerated. + /// Also validates that the state of the object is kept in sync after creation. + /// + [_VSUT.TestMethod] + public void ExternalModel_Can_Enumerate_Properties() + { + this.ExecuteWithDbDrop( + "ExternalModelProperties", + db => + { + // Ensure credential exists + db.ExecuteNonQuery( + "IF NOT EXISTS (SELECT * FROM sys.database_scoped_credentials WHERE name = N'OpenAiMSCred') " + + "BEGIN " + + "CREATE DATABASE SCOPED CREDENTIAL OpenAiMSCred " + + "WITH IDENTITY = 'System Managed Identity'; " + + "END"); + + var model = new _SMO.ExternalModel(db, "MyModel") + { + Location = "https://models.example.com/model.onn677yx", + ApiFormat = "OpenAI", + ModelType = ExternalModelType.Embeddings, + Model = "all-minilm", + Parameters = "{\"valid\":\"json\"}", + Credential = "OpenAiMSCred" + }; + + // Validate initial state + Assert.That(model.State, Is.EqualTo(_SMO.SqlSmoState.Creating), "Unexpected state before creation"); + + // Create the model + model.Create(); + Assert.That(model.State, Is.EqualTo(_SMO.SqlSmoState.Existing), "Unexpected state after creation"); + + // Enumerate properties + Assert.DoesNotThrow(() => model.Properties.Cast<_SMO.Property>().ToArray(), + "It should be possible to enumerate the properties of an ExternalModel object"); + + // Validate property values + Assert.That(model.Location, Is.EqualTo("https://models.example.com/model.onn677yx"), "Location mismatch"); + Assert.That(model.ApiFormat, Is.EqualTo("OpenAI"), "ApiFormat mismatch"); + Assert.That(model.ModelType, Is.EqualTo(ExternalModelType.Embeddings), "ModelType mismatch"); + Assert.That(model.Model, Is.EqualTo("all-minilm"), "Model mismatch"); + Assert.That(model.Parameters, Is.EqualTo("{\"valid\":\"json\"}"), "Parameters mismatch"); + Assert.That(model.Credential, Is.EqualTo("OpenAiMSCred"), "Credential mismatch"); + }); + } + + #endregion + + #region Create/Alter/Drop Tests + + [_VSUT.TestMethod] + [UnsupportedHostPlatform(SqlHostPlatforms.Linux)] + [SqlTestCategory(SqlTestCategory.Staging)] + public void ExternalModel_TestCreateAlterDrop() + { + this.ExecuteWithDbDrop( + database => + { + SetupDb(database); + TestCreateAlterDrop(database); + }); + } + + [_VSUT.TestMethod] + [UnsupportedHostPlatform(SqlHostPlatforms.Linux)] + [SqlTestCategory(SqlTestCategory.Staging)] + public void SmoDropIfExists_ExternalModel() + { + this.ExecuteWithDbDrop( + database => + { + SetupDb(database); + _SMO.ExternalModel model = new _SMO.ExternalModel(database, "MyModel") + { + Location = "https://models.example.com/model.onn677yx", + ApiFormat = "OpenAI", + ModelType = ExternalModelType.Embeddings, + Model = "all-minilm", + Parameters = "{\"valid\":\"json\"}", + Credential = "OpenAiMSCred" + }; + VerifySmoObjectDropIfExists(model, database); + }); + } + + #endregion + } +} diff --git a/src/FunctionalTest/Smo/ScriptingTests/ExternalStreamingJob_SmoTestSuite.cs b/src/FunctionalTest/Smo/ScriptingTests/ExternalStreamingJob_SmoTestSuite.cs deleted file mode 100644 index b21be7f2..00000000 --- a/src/FunctionalTest/Smo/ScriptingTests/ExternalStreamingJob_SmoTestSuite.cs +++ /dev/null @@ -1,165 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - - -using Microsoft.SqlServer.Management.Common; -using Microsoft.SqlServer.Management.Smo; -using Microsoft.SqlServer.Test.Manageability.Utils.TestFramework; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using NUnit.Framework; -using Assert = NUnit.Framework.Assert; -namespace Microsoft.SqlServer.Test.SMO.ScriptingTests -{ - /// - /// Test suite for testing External Language properties and scripting. - /// - [TestClass] - [SupportedServerVersionRange(DatabaseEngineType = DatabaseEngineType.Standalone, MinMajor = 15, HostPlatform = HostPlatformNames.Linux, Edition= DatabaseEngineEdition.SqlDatabaseEdge)] - public class ExternalStreamingJob_SmoTestSuite : SmoObjectTestBase - { - [TestMethod] - public void ExternalStreamingJob_TestCreateWithoutRequiredParameters() - { - this.ExecuteFromDbPool( - database => - { - Assert.Throws ( - () => - { - string ExternalStreamingJobName = GenerateUniqueSmoObjectName("ExternalStreamingJob"); - var obj = new ExternalStreamingJob(); - CreateSmoObject(obj); - }); - }); - } - - [TestMethod] - public void ExternalStreamingJob_TestCreateWithRequiredParametersOnly() - { - this.ExecuteFromDbPool( - database => - { - // Test the External Stream ICreateable interface - // - string externalStreamName = GenerateSmoObjectName("ExternalStream"); - var externalStream = new ExternalStream(database, externalStreamName); - externalStream.DataSourceName = GenerateUniqueSmoObjectName("ExternalStreamDataSourceName"); - - string externalStreamName1 = GenerateSmoObjectName("ExternalStream1"); - var externalStream1 = new ExternalStream(database, externalStreamName1); - externalStream1.DataSourceName = GenerateUniqueSmoObjectName("ExternalStreamDataSourceName1"); - - // The DataSource must exists in the database - // - ExternalDataSource testDataSource = new ExternalDataSource(database, externalStream.DataSourceName); - testDataSource.DataSourceType = ExternalDataSourceType.ExternalGenerics; - testDataSource.Location = "edgehub://"; - - ExternalDataSource testDataSource1 = new ExternalDataSource(database, externalStream1.DataSourceName); - testDataSource1.DataSourceType = ExternalDataSourceType.ExternalGenerics; - testDataSource1.Location = "edgehub://"; - - CreateSmoObject(testDataSource); - CreateSmoObject(testDataSource1); - - CreateSmoObject(externalStream); - CreateSmoObject(externalStream1); - - // Test the External Streaming Job ICreateable interface - // - string ExternalStreamingJobName = GenerateUniqueSmoObjectName("ExternalStreamingJob"); - var ExternalStreamingJob = new ExternalStreamingJob(database, ExternalStreamingJobName); - ExternalStreamingJob.Name = GenerateUniqueSmoObjectName("ExternalStreamingJobDataSourceName"); - ExternalStreamingJob.Statement = $"Select * INTO {externalStreamName1} from {externalStreamName}"; - CreateSmoObject(ExternalStreamingJob); - - // Verify that the object exists in the database - // - VerifyObjectExists(database, ExternalStreamingJobName); - Assert.That(ExternalStreamingJob.Status, - Is.EqualTo(ExternalStreamingJobStatusType.Created), - "The Stream Job status of created failed"); - - ExternalStreamingJob.Drop(); - VerifyIsSmoObjectDropped(ExternalStreamingJob, database); - }); - } - - [TestMethod] - public void ExternalStreamingJob_TestStartAndStopJobWithStatus() - { - this.ExecuteFromDbPool( - database => - { - // Test the External Stream ICreateable interface - // - string externalStreamName = GenerateSmoObjectName("ExternalStream"); - var externalStream = new ExternalStream(database, externalStreamName); - externalStream.DataSourceName = GenerateUniqueSmoObjectName("ExternalStreamDataSourceName"); - - string externalStreamName1 = GenerateSmoObjectName("ExternalStream1"); - var externalStream1 = new ExternalStream(database, externalStreamName1); - externalStream1.DataSourceName = GenerateUniqueSmoObjectName("ExternalStreamDataSourceName1"); - - // The DataSource must exists in the database - // - ExternalDataSource testDataSource = new ExternalDataSource(database, externalStream.DataSourceName); - testDataSource.DataSourceType = ExternalDataSourceType.ExternalGenerics; - testDataSource.Location = "edgehub://"; - - ExternalDataSource testDataSource1 = new ExternalDataSource(database, externalStream1.DataSourceName); - testDataSource1.DataSourceType = ExternalDataSourceType.ExternalGenerics; - testDataSource1.Location = "edgehub://"; - - CreateSmoObject(testDataSource); - CreateSmoObject(testDataSource1); - - CreateSmoObject(externalStream); - CreateSmoObject(externalStream1); - - // Test the External Streaming Job ICreateable interface - // - string ExternalStreamingJobName = GenerateUniqueSmoObjectName("ExternalStreamingJob"); - var ExternalStreamingJob = new ExternalStreamingJob(database, ExternalStreamingJobName); - ExternalStreamingJob.Name = GenerateUniqueSmoObjectName("ExternalStreamingJobDataSourceName"); - ExternalStreamingJob.Statement = $"Select * INTO {externalStreamName1} from {externalStreamName}"; - CreateSmoObject(ExternalStreamingJob); - - // Verify that the object exists in the database - // - VerifyObjectExists(database, ExternalStreamingJobName); - Assert.That(ExternalStreamingJob.Status, - Is.EqualTo(ExternalStreamingJobStatusType.Created), - "The Stream Job status of created failed"); - - try - { - ExternalStreamingJob.StartStreamingJob(); - ExternalStreamingJob.Refresh(); - Assert.That(ExternalStreamingJob.Status, - Is.EqualTo(ExternalStreamingJobStatusType.Starting), - "The Stream Job status of starting failed"); - } - finally - { - ExternalStreamingJob.StopStreamingJob(); - ExternalStreamingJob.Refresh(); - Assert.That(ExternalStreamingJob.Status, - Is.EqualTo(ExternalStreamingJobStatusType.Stopping), - "The Stream Job status of stopping failed" - ); - } - }); - } - - protected override void VerifyIsSmoObjectDropped(SqlSmoObject obj, SqlSmoObject objVerify) - { - var database = (Database)objVerify; - var extStream = (ExternalStreamingJob)obj; - NUnit.Framework.Assert.That(() => - { - return !database.ExternalStreamingJobs.Contains(extStream.Name); - }, "Unable to Drop External Stream Object"); - } - } -} \ No newline at end of file diff --git a/src/FunctionalTest/Smo/ScriptingTests/Index_SmoTestSuite.cs b/src/FunctionalTest/Smo/ScriptingTests/Index_SmoTestSuite.cs index 7034e4d4..0d6b91c6 100644 --- a/src/FunctionalTest/Smo/ScriptingTests/Index_SmoTestSuite.cs +++ b/src/FunctionalTest/Smo/ScriptingTests/Index_SmoTestSuite.cs @@ -44,8 +44,8 @@ public void SmoIndexProperties_AzureSterlingV12AndAfterCloud() database => { var result = new SqlTestResult(); - _SMO.Table table = database.CreateTable("tbl_" + this.TestContext.TestName); - _SMO.Index index = table.CreateIndex("idx_" + this.TestContext.TestName); + var table = database.CreateTable("tbl_" + this.TestContext.TestName); + var index = table.CreateIndex("idx_" + this.TestContext.TestName); //Read-Only properties result &= SqlTestHelpers.TestReadProperty(index, "HasCompressedPartitions", false); @@ -77,8 +77,8 @@ public void SmoIndexProperties_Sql2014() { var result = new SqlTestResult(); - _SMO.Table table = database.CreateTable("tbl_" + this.TestContext.TestName); - _SMO.Index index = table.CreateIndex("idx_" + this.TestContext.TestName); + var table = database.CreateTable("tbl_" + this.TestContext.TestName); + var index = table.CreateIndex("idx_" + this.TestContext.TestName); //Read-Only properties result &= SqlTestHelpers.TestReadProperty(index, "HasCompressedPartitions", false); @@ -110,8 +110,8 @@ public void SmoIndexProperties_Sql2016AndAfterOnPrem() { var result = new SqlTestResult(); - _SMO.Table table = database.CreateTable("tbl_" + this.TestContext.TestName); - _SMO.Index index = table.CreateIndex("idx_" + this.TestContext.TestName); + var table = database.CreateTable("tbl_" + this.TestContext.TestName); + var index = table.CreateIndex("idx_" + this.TestContext.TestName); //Read-Only properties result &= SqlTestHelpers.TestReadProperty(index, "HasCompressedPartitions", false); @@ -152,32 +152,47 @@ public void SmoIndexProperties_Sql2022AndAfterOnPrem() ('20200320', 'Partition1March', '3'), ('20200402', 'Partition1April', '4')"); - _SMO.Index index = CreatePartitionedIndex(db, tb); - - index.PhysicalPartitions[1].XmlCompression = _SMO.XmlCompressionType.On; - Assert.That(index.Rebuild, Throws.Nothing, "rebuild index should succeed"); - - db.Parent.SetDefaultInitFields(typeof(_SMO.PhysicalPartition), true); - index.PhysicalPartitions.ClearAndInitialize(string.Empty, new string[0]); - var physicalPartition = index.PhysicalPartitions[1]; - Assert.Multiple(() => - { - Assert.That(physicalPartition.XmlCompression, Is.EqualTo(_SMO.XmlCompressionType.On), "Xml Compression should be on"); - Assert.That(physicalPartition.DataCompression, Is.EqualTo(_SMO.DataCompressionType.None), "Data Compression should be off"); - }); - - // script the index and make sure creation succeeds - // - string script = ScriptSmoObject(index); - index.Drop(); + var index = CreatePartitionedIndex(db, tb); + var schemeName = index.PartitionScheme; try { - db.ExecuteNonQuery(script); - db.Tables.Refresh(); + index.PhysicalPartitions[1].XmlCompression = _SMO.XmlCompressionType.On; + Assert.That(index.Rebuild, Throws.Nothing, "rebuild index should succeed"); + + db.Parent.SetDefaultInitFields(typeof(_SMO.PhysicalPartition), true); + index.PhysicalPartitions.ClearAndInitialize(string.Empty, new string[0]); + var physicalPartition = index.PhysicalPartitions[1]; + Assert.Multiple(() => + { + Assert.That(physicalPartition.XmlCompression, Is.EqualTo(_SMO.XmlCompressionType.On), "Xml Compression should be on"); + Assert.That(physicalPartition.DataCompression, Is.EqualTo(_SMO.DataCompressionType.None), "Data Compression should be off"); + }); + + // script the index and make sure creation succeeds + // + string script = ScriptSmoObject(index); + index.Drop(); + try + { + db.ExecuteNonQuery(script); + db.Tables.Refresh(); + } + catch (Exception e) + { + Assert.Fail($"Index creation failed. {e}\r\n{script}"); + } } - catch(Exception e) + finally { - Assert.Fail($"Index creation failed. {e}\r\n{script}"); + tb.Drop(); + foreach (var fileGroup in db.PartitionSchemes[schemeName].FileGroups) + { + foreach (var file in db.FileGroups[fileGroup].Files.ToList()) + { + file.Shrink(0, ShrinkMethod.EmptyFile); + file.Drop(); + } + } } }); } @@ -225,7 +240,7 @@ public void SmoDropIfExists_Index_Sql16AndAfterOnPrem() this.ExecuteFromDbPool( database => { - _SMO.Table table = database.CreateTable(this.TestContext.TestName); + var table = database.CreateTable(this.TestContext.TestName); _SMO.Index index = new _SMO.Index(table, GenerateSmoObjectName("idx")); index.IndexedColumns.Add(new _SMO.IndexedColumn(index, table.Columns[0].Name)); @@ -248,10 +263,10 @@ public void SmoDropIfExists_PrimaryKey_Sql16AndAfterOnPrem() this.ExecuteFromDbPool( database => { - _SMO.Table table = database.CreateTable(this.TestContext.TestName); + var table = database.CreateTable(this.TestContext.TestName); _SMO.Index pk = new _SMO.Index(table, GenerateSmoObjectName("pk")); - _SMO.Column column = table.Columns[0]; + var column = table.Columns[0]; column.Nullable = false; column.Alter(); @@ -299,7 +314,8 @@ public void HekatonColumnstoreScripting() memoryOptimizedFg.Create(); - _SMO.DataFile dataFile = new _SMO.DataFile(memoryOptimizedFg, String.Format("{0}_hkfg", database.Name)) + // Memory optimized data files don't have to be manually deleted + var dataFile = new DataFile(memoryOptimizedFg, string.Format("{0}_hkfg", database.Name)) { FileName = _SMO.PathWrapper.Combine(_SMO.PathWrapper.GetDirectoryName(database.FileGroups["PRIMARY"].Files[0].FileName), @@ -327,7 +343,6 @@ public void HekatonColumnstoreScripting() table.Create(); string script = ScriptSmoObject(table); - var expectedScriptFragment = $"CREATE TABLE [dbo].[HekatonColumnstoreScripting_testTable]{Environment.NewLine}({Environment.NewLine}\t[c1] [int] NOT NULL,{Environment.NewLine}{Environment.NewLine} CONSTRAINT [c1_pk] PRIMARY KEY NONCLUSTERED {Environment.NewLine}({Environment.NewLine}\t[c1] ASC{Environment.NewLine}),{Environment.NewLine}INDEX [cci] CLUSTERED COLUMNSTORE WITH (COMPRESSION_DELAY = 0){Environment.NewLine})WITH ( MEMORY_OPTIMIZED = ON , DURABILITY = SCHEMA_AND_DATA )"; @@ -852,14 +867,14 @@ public void Index_ResumableRebuildOperation_SQL2017AndAfterOnPrem() private void TestResumableRebuildOnPrem(_SMO.Database database, bool useResumableIndex) { // Prepare: Create a table with the specified rows and columns data - _SMO.Table table = CreateBasicTable(database, 2, 50); + var table = CreateBasicTable(database, 2, 50); // Prepare: Create a clustered index for test. - _SMO.Index index = table.CreateIndex("idx_" + this.TestContext.TestName, new IndexProperties() {IsClustered = true}); - _SMO.Server server = database.Parent; + var index = table.CreateIndex("idx_" + this.TestContext.TestName, new IndexProperties() {IsClustered = true}); + var server = database.Parent; server.SetDefaultInitFields(typeof(_SMO.ResumableIndex), "ResumableOperationState", "MaxDOP", "PercentComplete"); - var initialExcutionModes = server.ConnectionContext.SqlExecutionModes; + var initialExecutionModes = server.ConnectionContext.SqlExecutionModes; server.ConnectionContext.SqlExecutionModes = SqlExecutionModes.ExecuteAndCaptureSql; _SMO.ResumableIndex resumableIndex = null; @@ -1082,7 +1097,7 @@ private void TestResumableRebuildOnPrem(_SMO.Database database, bool useResumabl } finally { - server.ConnectionContext.SqlExecutionModes = initialExcutionModes; + server.ConnectionContext.SqlExecutionModes = initialExecutionModes; try { table.Drop(); @@ -1121,11 +1136,11 @@ public void Index_ResumableRebuildOperation_Azure() private void TestResumableRebuildOnAzure(_SMO.Database database, bool useResumableIndex) { // Prepare: Create a table with the specified rows and columns data - _SMO.Table table = CreateBasicTable(database, 2, 50); + var table = CreateBasicTable(database, 2, 50); // Prepare: Create a clustered index for test. - _SMO.Index index = table.CreateIndex("idx_" + this.TestContext.TestName, new IndexProperties() { IsClustered = true }); - _SMO.Server server = database.Parent; + var index = table.CreateIndex("idx_" + this.TestContext.TestName, new IndexProperties() { IsClustered = true }); + var server = database.Parent; server.SetDefaultInitFields(typeof(_SMO.ResumableIndex), "ResumableOperationState", "MaxDOP", "PercentComplete"); _SMO.ResumableIndex resumableIndex = null; @@ -1266,8 +1281,8 @@ public void Index_ResumableCreateOperation_SQL2018AndAfterOnPrem() database => { // Prepare: Create a table with the specified rows and columns data - _SMO.Table table = CreateBasicTable(database, 2, 50); - _SMO.Server server = database.Parent; + var table = CreateBasicTable(database, 2, 50); + var server = database.Parent; // Enable the TF that allows us to run the index creation with the resumable setting enabled. // Only do this for on-prem DBs, as treaceflags are not support in Azure. @@ -1281,7 +1296,7 @@ public void Index_ResumableCreateOperation_SQL2018AndAfterOnPrem() // Create a clustered index on the table. // - _SMO.Index clIdx = table.CreateIndex("clIdx_" + this.TestContext.TestName, new IndexProperties() { IsClustered = true}); + var clIdx = table.CreateIndex("clIdx_" + this.TestContext.TestName, new IndexProperties() { IsClustered = true}); try { @@ -1294,7 +1309,7 @@ public void Index_ResumableCreateOperation_SQL2018AndAfterOnPrem() ncIdx.ResumableIndexOperation = true; ncIdx.ResumableMaxDuration = 5; - StringCollection stringColl = ncIdx.Script(); + var stringColl = ncIdx.Script(); StringBuilder sb = new StringBuilder(); foreach (string statement in stringColl) { @@ -1350,7 +1365,7 @@ public void Index_ResumableCreateConstraintOperation() columns[columnId] = new ColumnProperties($"C{columnId.ToString()}") { Nullable = false }; } - _SMO.Table table = DatabaseObjectHelpers.CreateTable( + var table = DatabaseObjectHelpers.CreateTable( database: database, tableNamePrefix: "tbl", columnProperties: columns); @@ -1396,9 +1411,9 @@ private void PutResumableIndexInPausedState(_SMO.Database database, _SMO.Table t // Create trigger that will delay for 10 minutes after the rebuild of an index. This will leave the index in the // "running" state for those 10 minutes, during which we can cancel the rebuild and then get the paused index. - _SMO.Server server = database.Parent; + var server = database.Parent; TraceHelper.TraceInformation("Creating the trigger on database."); - _SMO.DatabaseDdlTrigger triggerDb = DatabaseObjectHelpers.CreateDatabaseDdlTrigger(database, + var triggerDb = DatabaseObjectHelpers.CreateDatabaseDdlTrigger(database, "trg", "AFTER ALTER_INDEX", "WAITFOR DELAY '00:10:00'"); // the delay time is set as 10 minutes. // Execute the index rebuild on a separate thread so that we can cancel the operation after starting the rebuild, @@ -1471,7 +1486,7 @@ private static _SMO.Table CreateBasicTable(_SMO.Database database, int columnCou columns[columnId] = new ColumnProperties(String.Format("C{0}", columnId.ToString())) { Nullable = nullable }; } - _SMO.Table table = DatabaseObjectHelpers.CreateTable( + var table = DatabaseObjectHelpers.CreateTable( database: database, tableNamePrefix: "tbl", columnProperties: columns); @@ -1495,11 +1510,11 @@ public void Index_CreateWaitAtLowPriority() database => { // Prepare: Create a table with the specified rows and columns data - _SMO.Table table = CreateBasicTable(database, 2, 50); - _SMO.Server server = database.Parent; + var table = CreateBasicTable(database, 2, 50); + var server = database.Parent; int maxDuration = 2; _SMO.AbortAfterWait[] abortTypeValues = (_SMO.AbortAfterWait[])Enum.GetValues(typeof(_SMO.AbortAfterWait)); - foreach (_SMO.AbortAfterWait abortType in abortTypeValues) + foreach (var abortType in abortTypeValues) { database.Parent.ConnectionContext.CapturedSql.Clear(); // Create a simple non-clustered index on the first column of the table. @@ -1512,7 +1527,7 @@ public void Index_CreateWaitAtLowPriority() ncIdx.LowPriorityAbortAfterWait = abortType; ncIdx.DropExistingIndex = false; - StringCollection stringColl = ncIdx.Script(); + var stringColl = ncIdx.Script(); StringBuilder sb = new StringBuilder(); foreach (string statement in stringColl) { @@ -1549,11 +1564,11 @@ public void Index_DropWaitAtLowPriority_Sql2017AndAfterOnPrem() database => { // Prepare: Create table and insert some data; - _SMO.Table table = CreateBasicTable(database, 1, 10, false); + var table = CreateBasicTable(database, 1, 10, false); // Prepare: Set the execution mode to ExecuteAndCaptureSql for the connection. - _SMO.Server server = database.Parent; - var initialExcutionModes = server.ConnectionContext.SqlExecutionModes; + var server = database.Parent; + var initialExecutionModes = server.ConnectionContext.SqlExecutionModes; server.ConnectionContext.SqlExecutionModes = SqlExecutionModes.ExecuteAndCaptureSql; // Test the index drop and constraint drop with low priority option with considering all possible properties of the tested index. @@ -1597,7 +1612,7 @@ public void Index_DropWaitAtLowPriority_Sql2017AndAfterOnPrem() } finally { - server.ConnectionContext.SqlExecutionModes = initialExcutionModes; + server.ConnectionContext.SqlExecutionModes = initialExecutionModes; } }); } @@ -1617,14 +1632,14 @@ private void CheckIndexDroppingAtLowPriority(_SMO.Database database, _SMO.Table int maxDuration = 2; _SMO.AbortAfterWait[] abortTypeValues = (_SMO.AbortAfterWait[])Enum.GetValues(typeof(_SMO.AbortAfterWait)); - foreach (_SMO.AbortAfterWait abortType in abortTypeValues) + foreach (var abortType in abortTypeValues) { // Create an index whose properties are specified by the IndexProperties. - _SMO.Index index = table.CreateIndex(namePrefix, indexProperties); + var index = table.CreateIndex(namePrefix, indexProperties); // Save the default values of the sub-options related with the low priority option. int defaultMaxDuration = index.LowPriorityMaxDuration; - _SMO.AbortAfterWait defaultAbortType = index.LowPriorityAbortAfterWait; + var defaultAbortType = index.LowPriorityAbortAfterWait; // Set the sub-options values of the low priority so that the index will be dropped by low priority. index.LowPriorityMaxDuration = maxDuration; @@ -1704,39 +1719,23 @@ public void Index_DropOptions_ALL_ONPREM_SERVERS() this.ExecuteFromDbPool( database => { - // Prepare: Create table and insert some data; - _SMO.Table table = CreateBasicTable(database, 1, 10, false); - - // Prepare: Set the execution mode to ExecuteAndCaptureSql for the connection. - _SMO.Server server = database.Parent; - var initialExcutionModes = server.ConnectionContext.SqlExecutionModes; - server.ConnectionContext.SqlExecutionModes = SqlExecutionModes.ExecuteAndCaptureSql; - // Test the index drop operation with the helper function, where the type of the tested indexes include // the non_clustered regular index, the clustered regular index, the unique key constraint and the primary key constraint. - try - { - // Check 1: Check the non_clustered regular index dropped with the different options - DropIndexWithDifferentOptions(database, table, "non_cluster_index", - new IndexProperties() { IndexType = _SMO.IndexType.NonClusteredIndex, IsClustered = false }); - - // Check 2: Check the clustered regular index dropped with the different options. - DropIndexWithDifferentOptions(database, table, "cluster_index", - new IndexProperties() { IndexType = _SMO.IndexType.ClusteredIndex, IsClustered = true }); + // Check 1: Check the non_clustered regular index dropped with the different options + DropIndexWithDifferentOptions(database, "non_cluster_index", + new IndexProperties() { IndexType = _SMO.IndexType.NonClusteredIndex, IsClustered = false }); - // Check 3: Check the unique key constraint dropped with the different options. - DropIndexWithDifferentOptions(database, table, "unique_cluster_index", - new IndexProperties() { IndexType = _SMO.IndexType.ClusteredIndex, IsClustered = true, KeyType = _SMO.IndexKeyType.DriUniqueKey }); + // Check 2: Check the clustered regular index dropped with the different options. + DropIndexWithDifferentOptions(database, "cluster_index", + new IndexProperties() { IndexType = _SMO.IndexType.ClusteredIndex, IsClustered = true }); - // Check 4: Check the primary key constraint dropped with thedifferent options. - DropIndexWithDifferentOptions(database, table, "primary_cluster_index", - new IndexProperties() { IndexType = _SMO.IndexType.ClusteredIndex, IsClustered = true, KeyType = _SMO.IndexKeyType.DriPrimaryKey }); - } - finally - { - server.ConnectionContext.SqlExecutionModes = initialExcutionModes; - } + // Check 3: Check the unique key constraint dropped with the different options. + DropIndexWithDifferentOptions(database, "unique_cluster_index", + new IndexProperties() { IndexType = _SMO.IndexType.ClusteredIndex, IsClustered = true, KeyType = _SMO.IndexKeyType.DriUniqueKey }); + // Check 4: Check the primary key constraint dropped with thedifferent options. + DropIndexWithDifferentOptions(database, "primary_cluster_index", + new IndexProperties() { IndexType = _SMO.IndexType.ClusteredIndex, IsClustered = true, KeyType = _SMO.IndexKeyType.DriPrimaryKey }); }); } @@ -1746,78 +1745,108 @@ public void Index_DropOptions_ALL_ONPREM_SERVERS() /// The tested index properties are specified by the indexProperties that includes the IndexType, IsClustered, OnlineIndexOperation and IndexkeyType properties. /// Specifically, if the index is regular and clustered, it could also support the DropAndMove operation. /// - /// /// The prefix name of the index that will be created. /// The specified properties of the index. - private void DropIndexWithDifferentOptions(_SMO.Database database, _SMO.Table table, string namePrefix, IndexProperties indexProperties) + private void DropIndexWithDifferentOptions(_SMO.Database database, string namePrefix, IndexProperties indexProperties) { // The enumerated values for the online/maxdop/move-to options are set as the remainders of the iterator divided by 2, 5, 3 respectively. // These three numbers are relatively prime, so if the iteratorCount is setted as the lowest common multiple of them (30), // all combinations values of three dimensions ([0,1]*[0,4]*[0,2]) would be enumerated in the following loop. const int iteratorCount = 30; - for (int iterator = 0; iterator < iteratorCount; iterator++) + var initialExecutionModes = database.Parent.ConnectionContext.SqlExecutionModes; + try { - // Create an index whose properties are specified by the IndexProperties. - _SMO.Index index = table.CreateIndex(namePrefix, indexProperties); + for (int iterator = 0; iterator < iteratorCount; iterator++) + { + // Prepare: Create table and insert some data; + var table = CreateBasicTable(database, 1, 10, false); - // Generate the option values based on the iterator. - // For the value of the dropType here, 0 represents the Drop operation, 1 represents the DropAndMove operation with - // the file group parameter, 2 represents the DropAndMove operation with the partition scheme parameter. - bool isOnline = index.IsOnlineRebuildSupported ? (iterator % 2 == 0) : false; - int maxDegreeOfParallelism = iterator % 5; - int dropType = iterator % 3; + // Prepare: Set the execution mode to ExecuteAndCaptureSql for the connection. + var server = database.Parent; + server.ConnectionContext.SqlExecutionModes = SqlExecutionModes.ExecuteAndCaptureSql; + // Create an index whose properties are specified by the IndexProperties. + var index = table.CreateIndex(namePrefix, indexProperties); - index.OnlineIndexOperation = isOnline; - index.MaximumDegreeOfParallelism = maxDegreeOfParallelism; + // Generate the option values based on the iterator. + // For the value of the dropType here, 0 represents the Drop operation, 1 represents the DropAndMove operation with + // the file group parameter, 2 represents the DropAndMove operation with the partition scheme parameter. + bool isOnline = index.IsOnlineRebuildSupported ? (iterator % 2 == 0) : false; + int maxDegreeOfParallelism = iterator % 5; + int dropType = iterator % 3; - string dropScript; - bool isClusteredRegularIndex = (indexProperties.IsClustered == true && indexProperties.KeyType == _SMO.IndexKeyType.None); + index.OnlineIndexOperation = isOnline; + index.MaximumDegreeOfParallelism = maxDegreeOfParallelism; - // Only the regular and clustered index supports the DropAndMove operation for now. - if (isClusteredRegularIndex && dropType == 1) - { - // drop index and move data to a new fileGroup. - _SMO.FileGroup fileGroup = DatabaseObjectHelpers.CreateFileGroupWithDataFile(database, index.Name); - database.Parent.ConnectionContext.CapturedSql.Clear(); - index.DropAndMove(fileGroup.Name); - dropScript = database.Parent.ConnectionContext.CapturedSql.Text.ToSingleString(); + string dropScript; + bool isClusteredRegularIndex = (indexProperties.IsClustered == true && indexProperties.KeyType == _SMO.IndexKeyType.None); - // verify the "MOVE TO" option of the index drop. - Assert.That(dropScript, Does.Contain(String.Format("MOVE TO {0}", fileGroup.FullQualifiedName))); - } - else if (isClusteredRegularIndex && dropType == 2) - { - // drop index and move data to a new partition scheme. - object[] val = new object[] { "3", "5"}; - _SMO.PartitionScheme partitionScheme = DatabaseObjectHelpers.CreatePartitionSchemeWithFileGroups(database, index.Name, val, _SMO.DataType.Int); - database.Parent.ConnectionContext.CapturedSql.Clear(); - index.DropAndMove(partitionScheme.Name, new StringCollection { table.Columns[0].Name }); - dropScript = database.Parent.ConnectionContext.CapturedSql.Text.ToSingleString(); - - // verify the "MOVE TO" option of the index drop. - Assert.That(dropScript, Does.Contain(String.Format("MOVE TO {0}", partitionScheme.FullQualifiedName))); - } - else{ - // drop index - database.Parent.ConnectionContext.CapturedSql.Clear(); - index.Drop(); - dropScript = database.Parent.ConnectionContext.CapturedSql.Text.ToSingleString(); - } + // Only the regular and clustered index supports the DropAndMove operation for now. + if (isClusteredRegularIndex && dropType == 1) + { + // drop index and move data to a new fileGroup. + var fileGroup = DatabaseObjectHelpers.CreateFileGroupWithDataFile(database, index.Name); + database.Parent.ConnectionContext.CapturedSql.Clear(); + index.DropAndMove(fileGroup.Name); + dropScript = database.Parent.ConnectionContext.CapturedSql.Text.ToSingleString(); + table.Drop(); + foreach (var file in fileGroup.Files.ToList()) + { + // Clean up the created data files. + file.Shrink(0, ShrinkMethod.EmptyFile); + file.Drop(); + } + // verify the "MOVE TO" option of the index drop. + Assert.That(dropScript, Does.Contain(string.Format("MOVE TO {0}", fileGroup.FullQualifiedName))); - // Verify the tsql script of the index drop. - AssertDropOperationScript(dropScript, table, index, indexProperties); + } + else if (isClusteredRegularIndex && dropType == 2) + { + // drop index and move data to a new partition scheme. + object[] val = new object[] { "3", "5" }; + var partitionScheme = DatabaseObjectHelpers.CreatePartitionSchemeWithFileGroups(database, index.Name, val, _SMO.DataType.Int); + database.Parent.ConnectionContext.CapturedSql.Clear(); + index.DropAndMove(partitionScheme.Name, new StringCollection { table.Columns[0].Name }); + dropScript = database.Parent.ConnectionContext.CapturedSql.Text.ToSingleString(); + table.Drop(); + foreach (var fg in partitionScheme.FileGroups) + { + foreach (var df in database.FileGroups[fg].Files.ToList()) + { + df.Shrink(0, ShrinkMethod.EmptyFile); + df.Drop(); + } + } + // verify the "MOVE TO" option of the index drop. + Assert.That(dropScript, Does.Contain(string.Format("MOVE TO {0}", partitionScheme.FullQualifiedName))); + } + else + { + // drop index + database.Parent.ConnectionContext.CapturedSql.Clear(); + index.Drop(); + dropScript = database.Parent.ConnectionContext.CapturedSql.Text.ToSingleString(); + table.Drop(); + } - // Verify the ONLINE and MAXDOP options of the index drop. - if (indexProperties.IsClustered == true) - { - Assert.That(dropScript, Does.Contain(String.Format("ONLINE = {0}", isOnline? "ON":"OFF"))); + // Verify the tsql script of the index drop. + AssertDropOperationScript(dropScript, table, index, indexProperties); - if (maxDegreeOfParallelism != 0) + // Verify the ONLINE and MAXDOP options of the index drop. + if (indexProperties.IsClustered == true) { - Assert.That(dropScript, Does.Contain(String.Format("MAXDOP = {0}", maxDegreeOfParallelism))); + Assert.That(dropScript, Does.Contain(String.Format("ONLINE = {0}", isOnline ? "ON" : "OFF"))); + + if (maxDegreeOfParallelism != 0) + { + Assert.That(dropScript, Does.Contain(String.Format("MAXDOP = {0}", maxDegreeOfParallelism))); + } } } } + finally + { + database.Parent.ConnectionContext.SqlExecutionModes = initialExecutionModes; + } } #endregion diff --git a/src/FunctionalTest/Smo/ScriptingTests/SmoTestFramework/SmoTestBase.cs b/src/FunctionalTest/Smo/ScriptingTests/SmoTestFramework/SmoTestBase.cs index 35d8617d..82e1579b 100644 --- a/src/FunctionalTest/Smo/ScriptingTests/SmoTestFramework/SmoTestBase.cs +++ b/src/FunctionalTest/Smo/ScriptingTests/SmoTestFramework/SmoTestBase.cs @@ -13,7 +13,7 @@ // We can run our tests in parallel, scoped at the class level. // We set Workers to 3 because a higher value led to issues such as exceeding the DTU limit and being throttled on our Azure test servers including MI -[assembly: Microsoft.VisualStudio.TestTools.UnitTesting.Parallelize(Scope = Microsoft.VisualStudio.TestTools.UnitTesting.ExecutionScope.ClassLevel, Workers = 3)] +[assembly: Microsoft.VisualStudio.TestTools.UnitTesting.Parallelize(Scope = Microsoft.VisualStudio.TestTools.UnitTesting.ExecutionScope.ClassLevel, Workers = 4)] namespace Microsoft.SqlServer.Test.SMO.ScriptingTests { diff --git a/src/FunctionalTest/Smo/ScriptingTests/Table_SmoTestSuite.cs b/src/FunctionalTest/Smo/ScriptingTests/Table_SmoTestSuite.cs index f35531cd..393d3cea 100644 --- a/src/FunctionalTest/Smo/ScriptingTests/Table_SmoTestSuite.cs +++ b/src/FunctionalTest/Smo/ScriptingTests/Table_SmoTestSuite.cs @@ -3977,43 +3977,24 @@ public void ScriptingInsertTableWithJsonColumnTest() { if (database.Parent.IsJsonDataTypeEnabled && !database.IsFabricDatabase) { - string jsonString = @"[\ -]"; - string queryMatch = @"INSERT \[.*\]\.\[.*\] \(\[jsonColumn\]\) VALUES \(CAST\(N'\[\]' AS Json\)\)"; + var jsonString = @"{""key"":""value""}"; var table = new _SMO.Table(database, "jsonTable" + Guid.NewGuid().ToString()); var jsonColumn = new _SMO.Column(table, "jsonColumn", new _SMO.DataType(_SMO.SqlDataType.Json)); table.Columns.Add(jsonColumn); table.Create(); - string insertQuery = "INSERT INTO " + table.Name.SqlBracketQuoteString() + string.Format(" values('{0}')", jsonString); - - database.ExecuteNonQuery(insertQuery); + + database.ExecuteNonQuery("INSERT INTO " + table.Name.SqlBracketQuoteString() + $" values('{jsonString}')"); - _SMO.Scripter scripter = new _SMO.Scripter(database.Parent); + var scripter = new _SMO.Scripter(database.Parent); scripter.Options.ScriptData = true; scripter.Options.ScriptSchema = true; - bool isRecordInserted = false; - IEnumerable scripts = scripter.EnumScript(new Urn[] { table.Urn }); - foreach (string script in scripts) - { - if (script.StartsWith(string.Format("INSERT {0}", table.FullQualifiedName), ignoreCase: true, culture: CultureInfo.InvariantCulture)) - { - if (!Regex.IsMatch(script, queryMatch, RegexOptions.IgnoreCase)) - { - Assert.Fail(string.Format("Unexpected data row found during script generation of JSON tables that fails match with expected value, the data row generated was {0}", script)); - } - - isRecordInserted = true; - } - } + var scripts = scripter.EnumScript(new Urn[] { table.Urn }); - Assert.True(isRecordInserted, string.Format("The expected data row was not inserted correctly. The table DDLs are as follows: \n {0}", string.Join("\n", scripts))); + Assert.That(scripts, Has.Member("INSERT [dbo]." + table.Name.SqlBracketQuoteString() + $" ([jsonColumn]) VALUES (N'{jsonString}')")); - table.DropIfExists(); - string tableCreateScript = (from string script in scripts where script.StartsWith("CREATE", StringComparison.InvariantCultureIgnoreCase) select script).First(); - Assert.DoesNotThrow(() => database.ExecuteNonQuery(tableCreateScript), string.Format("The generated table DDL was invalid and failed to create the table, script generated was {0}", tableCreateScript)); } }); } @@ -4073,7 +4054,6 @@ public void ScriptingJsonColumnCrossVersionTest() // TODO: Azure and MI currently don't support the 2-parameter vector declaration. That will be // enabled soon, and we aren't planning on being backwards compatible with the 1-param version so // for now just disable this test. - // https://msdata.visualstudio.com/SQLToolsAndLibraries/_workitems/edit/4698232 // [SupportedServerVersionRange(DatabaseEngineType = DatabaseEngineType.SqlAzureDatabase)] [SupportedServerVersionRange(DatabaseEngineType = DatabaseEngineType.Standalone, MinMajor = 17)] [UnsupportedDatabaseEngineEdition(DatabaseEngineEdition.SqlDataWarehouse, DatabaseEngineEdition.SqlManagedInstance)] @@ -4085,14 +4065,12 @@ public void ScriptingInsertTableWithVectorColumnTest() { if (database.Parent.ServerType != DatabaseEngineType.Standalone || database.Parent.VersionMajor >= 17) { - string queryMatch = @"INSERT \[.*\]\.\[.*\] \(\[vectorColumn\]\) VALUES \(CAST\(N'\[0\.0000000e\+000,0\.0000000e\+000\]' AS Vector\(2\)\)\)"; - var table = new Table(database, "vectorTable"); var vectorColumn = new Column(table, "vectorColumn", DataType.Vector(2)); table.Columns.Add(vectorColumn); table.Create(); - string insertQuery = $"INSERT INTO {table.Name.SqlBracketQuoteString()} values('[0,0]')"; + var insertQuery = $"INSERT INTO {table.Name.SqlBracketQuoteString()} values('[1,0]')"; database.ExecuteNonQuery(insertQuery); @@ -4100,14 +4078,9 @@ public void ScriptingInsertTableWithVectorColumnTest() scripter.Options.ScriptData = true; scripter.Options.ScriptSchema = true; - IEnumerable scripts = scripter.EnumScript(new Urn[] { table.Urn }); - Assert.That(scripts, Has.One.Matches(queryMatch).IgnoreCase, "Scripting of Vector tables is expected to generate a valid INSERT statement"); - - table.DropIfExists(); - string tableCreateScript = (from string script in scripts where script.StartsWith("CREATE", StringComparison.InvariantCultureIgnoreCase) select script).First(); - database.ExecuteNonQuery(tableCreateScript); - database.Tables.ClearAndInitialize(string.Empty, null); - Assert.That(database.Tables, Has.One.Items.Matches(i => i.Name == table.Name), "Table should be created successfully."); + var scripts = scripter.EnumScript(new Urn[] { table.Urn }); + // SqlClient 5 used scientific notation for vector components but sqlclient 6 gets the string from the server which does not use scientific notation unless needed + Assert.That(scripts, Has.Member("INSERT [dbo]." + table.Name.SqlBracketQuoteString() + $" ([vectorColumn]) VALUES (N'[1,0]')"), "Scripting of Vector tables is expected to generate a valid INSERT statement"); } }); } @@ -4413,8 +4386,6 @@ [t_ftyp] ASC /// public static Database CreateDbWithLotsOfTables(_SMO.Server serverContext, int tableCount = 20000, bool withData = false) { - var timeout = serverContext.ConnectionContext.StatementTimeout; - serverContext.ConnectionContext.StatementTimeout = Math.Max(900, timeout); var db = serverContext.CreateDatabaseDefinition("lotsoftables"); var fileGroupName = "PRIMARY"; var indexFileGroupName = "PRIMARY"; @@ -4439,8 +4410,19 @@ public static Database CreateDbWithLotsOfTables(_SMO.Server serverContext, int t indexFileGroupName = "AE_INDEX"; } db.Create(); - db.ExecuteNonQuery(CreateLotsOfTables(fileGroupName, indexFileGroupName, tableCount, withData)); - serverContext.ConnectionContext.StatementTimeout = timeout; + var timeout = db.ExecutionManager.ConnectionContext.StatementTimeout; + db.ExecutionManager.ConnectionContext.StatementTimeout = Math.Max(1200, timeout); + try + { + db.ExecuteNonQuery(CreateLotsOfTables(fileGroupName, indexFileGroupName, tableCount, withData)); + + } + finally + { + // in case the ExecutionManager is also the Server's ExecutionManager, restore the timeout + db.ExecutionManager.ConnectionContext.StatementTimeout = timeout; + } + return db; } @@ -4457,16 +4439,28 @@ public void SmoTable_enumerating_twenty_thousand_tables_with_scripting_propertie { db = CreateDbWithLotsOfTables(ServerContext); - var rowTimeout = db.DatabaseEngineType == DatabaseEngineType.Standalone ? 10 : 60; - var queryGoalSeconds = db.DatabaseEngineType == DatabaseEngineType.Standalone ? 12 : 80; + var rowTimeout = db.DatabaseEngineType == DatabaseEngineType.Standalone ? 10 : 20; + var queryGoalSeconds = db.DatabaseEngineType == DatabaseEngineType.Standalone ? 12 : 30; var fields = Table.GetScriptFields(typeof(Database), db.Parent.ServerVersion, db.Parent.DatabaseEngineType, db.Parent.DatabaseEngineEdition, true); db.ExecutionManager.ConnectionContext.StatementTimeout = rowTimeout; var stopwatch = new Stopwatch(); - Trace.TraceInformation("Fetching Tables collection"); + db.ExecutionManager.ConnectionContext.SqlConnectionObject.StatisticsEnabled = true; + + // We want to ignore connection time because it varies wildly depending on the environment + if (!db.ExecutionManager.ConnectionContext.IsOpen) + { + db.ExecutionManager.ConnectionContext.Connect(); + } + Trace.TraceInformation("Fetching Tables collection"); + db.ExecutionManager.ConnectionContext.SqlConnectionObject.ResetStatistics(); stopwatch.Start(); - Assert.DoesNotThrow(() => db.Tables.ClearAndInitialize("", fields)); + // Add tracing of more detailed sql client events around this call to help diagnose any performance issues. 0x3 is already covered by the base test recorder. + using (new SqlClientEventRecorder(Environment.CurrentManagedThreadId, keywords: 0xfffc)) + { + db.Tables.ClearAndInitialize("", fields); + } stopwatch.Stop(); var statistics = db.ExecutionManager.ConnectionContext.SqlConnectionObject.RetrieveStatistics(); Trace.TraceInformation($"Tables population took {stopwatch.ElapsedMilliseconds} ms"); @@ -4832,47 +4826,72 @@ public void SmoTable_SwitchPartition_supports_all_variations() table.FileGroup = $"{prefix}_FG0"; } table.Create(); - var table2 = new Table(db, "UnpartitionedTable2"); - table2.Columns.Add(new Column(table2, "ItemDate", DataType.DateTime)); - table2.Columns.Add(new Column(table2, "ItemName", DataType.SysName)); - table2.Checks.Add(new Check(table2, "checkit2") { Text = "ItemDate <= '20200201'" }); - if (db.DatabaseEngineEdition != DatabaseEngineEdition.SqlDatabase) + try { - table2.FileGroup = $"{prefix}_FG0"; - } - table2.Create(); + table2.Columns.Add(new Column(table2, "ItemDate", DataType.DateTime)); + table2.Columns.Add(new Column(table2, "ItemName", DataType.SysName)); + table2.Checks.Add(new Check(table2, "checkit2") { Text = "ItemDate <= '20200201'" }); + if (db.DatabaseEngineEdition != DatabaseEngineEdition.SqlDatabase) + { + table2.FileGroup = $"{prefix}_FG0"; + } + table2.Create(); - db.ExecuteNonQuery(@"INSERT INTO partitionedTable1(ItemDate, ItemName) VALUES + db.ExecuteNonQuery(@"INSERT INTO partitionedTable1(ItemDate, ItemName) VALUES ('20200110', 'Partition1January'), ('20200215', 'Partition1February'), ('20200320', 'Partition1March'), ('20200402', 'Partition1April')"); - db.ExecuteNonQuery(@"INSERT INTO partitionedTable2(ItemDate, ItemName) VALUES + db.ExecuteNonQuery(@"INSERT INTO partitionedTable2(ItemDate, ItemName) VALUES ('20200110', 'Partition2January'), ('20200215', 'Partition2February'), ('20200320', 'Partition2March'), ('20200402', 'Partition2April')"); - Assert.That(() => table.SwitchPartition(null), Throws.InstanceOf(), "SwitchPartition(null)"); - partitionedTable1.SwitchPartition(1, table); - var itemName = db.ExecutionManager.ExecuteScalar("select top 1 ItemName from UnpartitionedTable"); - Assert.That(itemName, Is.EqualTo("Partition1January"), "SwitchPartition of partitioned table into unpartitioned table"); - partitionedTable2.SwitchPartition(1, partitionedTable1, 1); - itemName = db.ExecutionManager.ExecuteScalar("select top 1 ItemName from partitionedTable1 where ItemDate <= '20200201'"); - Assert.That(itemName, Is.EqualTo("Partition2January"), "SwitchPartition of partitioned table into partitioned table"); - if (db.ServerVersion.Major >= 12) + Assert.That(() => table.SwitchPartition(null), Throws.InstanceOf(), "SwitchPartition(null)"); + partitionedTable1.SwitchPartition(1, table); + var itemName = db.ExecutionManager.ExecuteScalar("select top 1 ItemName from UnpartitionedTable"); + Assert.That(itemName, Is.EqualTo("Partition1January"), "SwitchPartition of partitioned table into unpartitioned table"); + partitionedTable2.SwitchPartition(1, partitionedTable1, 1); + itemName = db.ExecutionManager.ExecuteScalar("select top 1 ItemName from partitionedTable1 where ItemDate <= '20200201'"); + Assert.That(itemName, Is.EqualTo("Partition2January"), "SwitchPartition of partitioned table into partitioned table"); + if (db.ServerVersion.Major >= 12) + { + table.LowPriorityMaxDuration = 1; + } + table.SwitchPartition(partitionedTable2, 1); + itemName = db.ExecutionManager.ExecuteScalar("select top 1 ItemName from partitionedTable2 where ItemDate <= '20200201'"); + Assert.That(itemName, Is.EqualTo("Partition1January"), "SwitchPartition of unpartitioned table to partitioned table"); + db.ExecuteNonQuery(@"INSERT INTO UnpartitionedTable(ItemDate, ItemName) VALUES + ('20200110', 'January')"); + table.SwitchPartition(table2); + itemName = db.ExecutionManager.ExecuteScalar("select top 1 ItemName from UnpartitionedTable2 where ItemDate <= '20200201'"); + Assert.That(itemName, Is.EqualTo("January"), "Switch unpartitioned table to unpartitioned table"); + } + finally { - table.LowPriorityMaxDuration = 1; + partitionedTable1.DropIfExists(); + partitionedTable2.DropIfExists(); + table.DropIfExists(); + if (table2.State == SqlSmoState.Existing) + { + table2.Drop(); + } + // Delete all the files from the partition scheme otherwise they will be left orphaned + if (partitionScheme.IsSupportedObject()) + { + foreach (var fg in partitionScheme.FileGroups) + { + foreach (var df in db.FileGroups[fg].Files.ToList()) + { + df.Shrink(0, ShrinkMethod.EmptyFile); + df.Drop(); + } + } + } + partitionScheme.Drop(); } - table.SwitchPartition(partitionedTable2, 1); - itemName = db.ExecutionManager.ExecuteScalar("select top 1 ItemName from partitionedTable2 where ItemDate <= '20200201'"); - Assert.That(itemName, Is.EqualTo("Partition1January"), "SwitchPartition of unpartitioned table to partitioned table"); - db.ExecuteNonQuery(@"INSERT INTO UnpartitionedTable(ItemDate, ItemName) VALUES - ('20200110', 'January')"); - table.SwitchPartition(table2); - itemName = db.ExecutionManager.ExecuteScalar("select top 1 ItemName from UnpartitionedTable2 where ItemDate <= '20200201'"); - Assert.That(itemName, Is.EqualTo("January"), "Switch unpartitioned table to unpartitioned table"); }); } @@ -4989,7 +5008,7 @@ public void SmoTable_Create_should_not_query_indexes() { var table = db.CreateTableDefinition("NoQuery"); var view = db.CreateViewDefinition("NoQuery", "dbo", "select 1"); - var recorder = new SqlClientEventRecorder(Environment.CurrentManagedThreadId); + var recorder = new SqlClientEventRecorder(Environment.CurrentManagedThreadId){ EnableTraceLogging = false }; using (recorder) { recorder.Start(); diff --git a/src/FunctionalTest/Smo/XEvent/SessionUnitTest.cs b/src/FunctionalTest/Smo/XEvent/SessionUnitTest.cs index 18ceafc2..5fdeb33f 100644 --- a/src/FunctionalTest/Smo/XEvent/SessionUnitTest.cs +++ b/src/FunctionalTest/Smo/XEvent/SessionUnitTest.cs @@ -40,6 +40,7 @@ public void TestDefaultValue() Assert.IsFalse(session.TrackCausality); Assert.IsFalse(session.AutoStart); Assert.AreEqual(Session.NotStarted, session.StartTime); + Assert.That(Session.DefaultMaxDuration, Is.EqualTo(session.MaxDuration)); session = new Session(store, "ut1"); Assert.AreEqual(-1, session.ID); @@ -54,6 +55,7 @@ public void TestDefaultValue() Assert.IsFalse(session.TrackCausality); Assert.IsFalse(session.AutoStart); Assert.AreEqual(Session.NotStarted, session.StartTime); + Assert.That(Session.DefaultMaxDuration,Is.EqualTo(session.MaxDuration)); } [TestMethod] @@ -71,6 +73,8 @@ public void DbScoped_Session_Tests() TestRemoveActionFromExistingSession(); TestSQLInjection(); TestScriptCreateDrop(); + // TODO: Bug:4806316 Re-enable after its enabled in Azure SQL DB. As of now only enabled on SQL Server 2025 + // TestMaxDurationScripting(); TestStartStopExistingSession(); TestValidateByWrongMethodName(); TestValidateEvent(); @@ -247,6 +251,41 @@ ADD TARGET package0.ring_buffer(SET max_memory=(8192)) Assert.AreEqual("DROP EVENT SESSION [" + name + "] ON DATABASE", sql); } + /// + /// Tests MaxDuration property scripting. + /// + public void TestMaxDurationScripting() + { + string name = "TestMaxDurationScripting-" + Guid.NewGuid(); + if (store.Sessions[name] != null) + { + store.Sessions[name].Drop(); + } + + Session session = store.CreateSession(name); + Event evt = session.AddEvent(store.ObjectInfoSet.Get("sqlserver.rpc_starting")); + Target target = session.AddTarget(store.RingBufferTargetInfo); + + // Test default behavior - MAX_DURATION should NOT be in script when not explicitly set + string sql = session.ScriptCreate().ToString(); + Assert.That(sql, Does.Not.Contain("MAX_DURATION"), "MAX_DURATION should not appear in script when using default value"); + + // Test unlimited duration (explicitly set to 0) + session.MaxDuration = Session.UnlimitedDuration; + sql = session.ScriptCreate().ToString(); + Assert.That(sql, Does.Contain("MAX_DURATION=UNLIMITED"), "Expected MAX_DURATION=UNLIMITED in create script when explicitly set"); + + // Test specific duration in seconds + session.MaxDuration = 3600; // 1 hour + sql = session.ScriptCreate().ToString(); + Assert.That(sql, Does.Contain("MAX_DURATION=3600 SECONDS"), "Expected MAX_DURATION=3600 SECONDS in create script"); + + // Test very long duration + session.MaxDuration = 86400; // 1 day + sql = session.ScriptCreate().ToString(); + Assert.That(sql, Does.Contain("MAX_DURATION=86400 SECONDS"), "Expected MAX_DURATION=86400 SECONDS in create script"); + } + public void When_session_has_multiple_targets_ScriptCreate_properly_delimits_the_list() { var sessionName = "testSession" + Guid.NewGuid(); diff --git a/src/FunctionalTest/Smo/XEvent/XEventSessionTests.cs b/src/FunctionalTest/Smo/XEvent/XEventSessionTests.cs index 7fa2dd66..f7f629c6 100644 --- a/src/FunctionalTest/Smo/XEvent/XEventSessionTests.cs +++ b/src/FunctionalTest/Smo/XEvent/XEventSessionTests.cs @@ -437,5 +437,336 @@ ADD EVENT sqlserver.sp_statement_starting session.Drop(); } + + #region MaxDuration Tests (Server-Scoped Only) + // TODO: Bug:4816977 Re-enable MaxDuration tests on Managed Instance + + [TestMethod] + [SqlTestArea(SqlTestArea.ExtendedEvents)] + [SupportedServerVersionRange(DatabaseEngineType = DatabaseEngineType.Standalone, MinMajor = 17)] + [UnsupportedDatabaseEngineEdition(DatabaseEngineEdition.SqlManagedInstance)] + public void MaxDuration_CreateSession_WithUnlimitedValue_IncludesInScript() + { + ExecuteTest(() => + { + var store = new XEStore(new SqlStoreConnection(ServerContext.ConnectionContext.SqlConnectionObject)); + var sessionName = "TestMaxDuration_" + Guid.NewGuid().ToString(); + + try + { + var session = store.CreateSession(sessionName); + session.MaxDuration = Session.UnlimitedDuration; // Explicitly set to UNLIMITED (0) + session.AddEvent(store.ObjectInfoSet.Get("sqlserver.rpc_starting")); + + var expectedCreateString = $@"CREATE EVENT SESSION [{sessionName}] ON SERVER +ADD EVENT sqlserver.rpc_starting +WITH (MAX_DURATION=UNLIMITED) +".FixNewLines(); + + var createScript = session.ScriptCreate().ToString(); + Assert.That(createScript, Is.EqualTo(expectedCreateString), + "CREATE script should match expected T-SQL when MAX_DURATION is explicitly set to UNLIMITED"); + } + finally + { + if (store.Sessions[sessionName] != null) + { + store.Sessions[sessionName].Drop(); + } + } + }); + } + + [TestMethod] + [SqlTestArea(SqlTestArea.ExtendedEvents)] + [SupportedServerVersionRange(DatabaseEngineType = DatabaseEngineType.Standalone, MinMajor = 17)] + [UnsupportedDatabaseEngineEdition(DatabaseEngineEdition.SqlManagedInstance)] + public void MaxDuration_CreateSession_WithValidValue_IncludesInScript() + { + ExecuteTest(() => + { + var store = new XEStore(new SqlStoreConnection(ServerContext.ConnectionContext.SqlConnectionObject)); + var sessionName = "TestMaxDuration_" + Guid.NewGuid().ToString(); + + try + { + var session = store.CreateSession(sessionName); + session.MaxDuration = 3600; // 1 hour + session.AddEvent(store.ObjectInfoSet.Get("sqlserver.rpc_starting")); + + var expectedCreateString = $@"CREATE EVENT SESSION [{sessionName}] ON SERVER +ADD EVENT sqlserver.rpc_starting +WITH (MAX_DURATION=3600 SECONDS) +".FixNewLines(); + var createScript = session.ScriptCreate().ToString(); + Assert.That(createScript, Is.EqualTo(expectedCreateString), + "CREATE script should match expected T-SQL when MAX_DURATION is explicitly set to 3600 seconds"); + } + finally + { + if (store.Sessions[sessionName] != null) + { + store.Sessions[sessionName].Drop(); + } + } + }); + } + + [TestMethod] + [SqlTestArea(SqlTestArea.ExtendedEvents)] + [SupportedServerVersionRange(DatabaseEngineType = DatabaseEngineType.Standalone, MinMajor = 17)] + public void MaxDuration_CreateSession_WithoutSettingValue_DoesNotIncludeInScript() + { + ExecuteTest(() => + { + var store = new XEStore(new SqlStoreConnection(ServerContext.ConnectionContext.SqlConnectionObject)); + var sessionName = "TestMaxDuration_" + Guid.NewGuid().ToString(); + + try + { + var session = store.CreateSession(sessionName); + // Do NOT set MaxDuration - should use default and not include in script + session.AddEvent(store.ObjectInfoSet.Get("sqlserver.rpc_starting")); + + var expectedCreateString = $@"CREATE EVENT SESSION [{sessionName}] ON SERVER +ADD EVENT sqlserver.rpc_starting +WITH (MAX_MEMORY=4096 KB,EVENT_RETENTION_MODE=ALLOW_SINGLE_EVENT_LOSS,MAX_DISPATCH_LATENCY=30 SECONDS,MAX_EVENT_SIZE=0 KB,MEMORY_PARTITION_MODE=NONE,TRACK_CAUSALITY=OFF,STARTUP_STATE=OFF) +".FixNewLines(); + + session.Create(); + + var createScript = session.ScriptCreate().ToString(); + Assert.That(createScript, Is.EqualTo(expectedCreateString), + "CREATE script should match expected T-SQL without MAX_DURATION when not explicitly set"); + } + finally + { + if (store.Sessions[sessionName] != null) + { + store.Sessions[sessionName].Drop(); + } + } + }); + } + + [TestMethod] + [SqlTestArea(SqlTestArea.ExtendedEvents)] + [SupportedServerVersionRange(DatabaseEngineType = DatabaseEngineType.Standalone, MinMajor = 17)] + [UnsupportedDatabaseEngineEdition(DatabaseEngineEdition.SqlManagedInstance)] + public void MaxDuration_ScriptExistingSession_WithDefaultValue_DoesNotIncludeInScript() + { + ExecuteTest(() => + { + var store = new XEStore(new SqlStoreConnection(ServerContext.ConnectionContext.SqlConnectionObject)); + var sessionName = "TestMaxDuration_" + Guid.NewGuid().ToString(); + + try + { + // Create session via T-SQL with default MAX_DURATION (UNLIMITED) + ServerContext.ConnectionContext.ExecuteNonQuery($@" + CREATE EVENT SESSION [{sessionName}] ON SERVER + ADD EVENT sqlserver.rpc_starting + WITH (MAX_MEMORY=4096 KB,MAX_DURATION=UNLIMITED)"); + + store.Refresh(); + var session = store.Sessions[sessionName]; + + Assert.That(session.MaxDuration, Is.EqualTo(Session.UnlimitedDuration), + "MaxDuration should be UnlimitedDuration (0) for existing session"); + + var expectedCreateString = $@"CREATE EVENT SESSION [{sessionName}] ON SERVER +ADD EVENT sqlserver.rpc_starting +WITH (MAX_MEMORY=4096 KB,EVENT_RETENTION_MODE=ALLOW_SINGLE_EVENT_LOSS,MAX_DISPATCH_LATENCY=30 SECONDS,MAX_EVENT_SIZE=0 KB,MEMORY_PARTITION_MODE=NONE,TRACK_CAUSALITY=OFF,STARTUP_STATE=OFF) +".FixNewLines(); + + var createScript = session.ScriptCreate().ToString(); + Assert.That(createScript, Is.EqualTo(expectedCreateString), + "ScriptCreate for existing session should match expected T-SQL without MAX_DURATION when value is default UNLIMITED"); + } + finally + { + if (store.Sessions[sessionName] != null) + { + store.Sessions[sessionName].Drop(); + } + } + }); + } + + [TestMethod] + [SqlTestArea(SqlTestArea.ExtendedEvents)] + [SupportedServerVersionRange(DatabaseEngineType = DatabaseEngineType.Standalone, MinMajor = 17)] + [UnsupportedDatabaseEngineEdition(DatabaseEngineEdition.SqlManagedInstance)] + public void MaxDuration_ScriptExistingSession_WithNonDefaultValue_IncludesInScript() + { + ExecuteTest(() => + { + var store = new XEStore(new SqlStoreConnection(ServerContext.ConnectionContext.SqlConnectionObject)); + var sessionName = "TestMaxDuration_" + Guid.NewGuid().ToString(); + + try + { + // Create session via T-SQL with non-default MAX_DURATION + ServerContext.ConnectionContext.ExecuteNonQuery($@" + CREATE EVENT SESSION [{sessionName}] ON SERVER + ADD EVENT sqlserver.rpc_starting + WITH (MAX_MEMORY=4096 KB, MAX_DURATION=7200 SECONDS)"); + + store.Refresh(); + var session = store.Sessions[sessionName]; + + Assert.That(session.MaxDuration, Is.EqualTo(7200), + "MaxDuration should be 7200 for existing session"); + + var expectedCreateString = $@"CREATE EVENT SESSION [{sessionName}] ON SERVER +ADD EVENT sqlserver.rpc_starting +WITH (MAX_MEMORY=4096 KB,EVENT_RETENTION_MODE=ALLOW_SINGLE_EVENT_LOSS,MAX_DISPATCH_LATENCY=30 SECONDS,MAX_EVENT_SIZE=0 KB,MEMORY_PARTITION_MODE=NONE,TRACK_CAUSALITY=OFF,STARTUP_STATE=OFF,MAX_DURATION=7200 SECONDS) +".FixNewLines(); + + var createScript = session.ScriptCreate().ToString(); + Assert.That(createScript, Is.EqualTo(expectedCreateString), + "ScriptCreate for existing session should match expected T-SQL with MAX_DURATION when value is non-default"); + } + finally + { + if (store.Sessions[sessionName] != null) + { + store.Sessions[sessionName].Drop(); + } + } + }); + } + + [TestMethod] + [SqlTestArea(SqlTestArea.ExtendedEvents)] + [SupportedServerVersionRange(DatabaseEngineType = DatabaseEngineType.Standalone, MinMajor = 17)] + [UnsupportedDatabaseEngineEdition(DatabaseEngineEdition.SqlManagedInstance)] + public void MaxDuration_AlterSession_FromValidValueToUnlimited_IncludesInScript() + { + ExecuteTest(() => + { + var store = new XEStore(new SqlStoreConnection(ServerContext.ConnectionContext.SqlConnectionObject)); + var sessionName = "TestMaxDuration_" + Guid.NewGuid().ToString(); + + try + { + // Create session via T-SQL with non-default MAX_DURATION + ServerContext.ConnectionContext.ExecuteNonQuery($@" + CREATE EVENT SESSION [{sessionName}] ON SERVER + ADD EVENT sqlserver.rpc_starting + WITH (MAX_MEMORY=4096 KB, MAX_DURATION=3600 SECONDS)"); + + store.Refresh(); + var session = store.Sessions[sessionName]; + + // Alter to set MaxDuration to UNLIMITED + session.MaxDuration = Session.UnlimitedDuration; + + var expectedAlterString = $@"ALTER EVENT SESSION [{sessionName}] ON SERVER + WITH (MAX_DURATION=UNLIMITED) +".FixNewLines(); + + var alterScript = session.ScriptAlter().ToString(); + Assert.That(alterScript, Is.EqualTo(expectedAlterString), + "ALTER script should match expected T-SQL when MAX_DURATION is explicitly changed to UNLIMITED"); + } + finally + { + if (store.Sessions[sessionName] != null) + { + store.Sessions[sessionName].Drop(); + } + } + }); + } + + [TestMethod] + [SqlTestArea(SqlTestArea.ExtendedEvents)] + [SupportedServerVersionRange(DatabaseEngineType = DatabaseEngineType.Standalone, Edition = DatabaseEngineEdition.Enterprise, MinMajor = 17)] + [UnsupportedDatabaseEngineEdition(DatabaseEngineEdition.SqlManagedInstance)] + public void MaxDuration_AlterSession_FromUnlimitedToValidValue_IncludesInScript() + { + ExecuteTest(() => + { + var store = new XEStore(new SqlStoreConnection(ServerContext.ConnectionContext.SqlConnectionObject)); + var sessionName = "TestMaxDuration_" + Guid.NewGuid().ToString(); + + try + { + // Create session via T-SQL with UNLIMITED MAX_DURATION + ServerContext.ConnectionContext.ExecuteNonQuery($@" + CREATE EVENT SESSION [{sessionName}] ON SERVER + ADD EVENT sqlserver.rpc_starting + WITH (MAX_MEMORY=4096 KB, MAX_DURATION=UNLIMITED)"); + + store.Refresh(); + var session = store.Sessions[sessionName]; + + // Alter to set MaxDuration to a specific value + session.MaxDuration = 1800; // 30 minutes + //session.Alter(); + + var expectedAlterString = $@"ALTER EVENT SESSION [{sessionName}] ON SERVER + WITH (MAX_DURATION=1800 SECONDS) +".FixNewLines(); + + var alterScript = session.ScriptAlter().ToString(); + Assert.That(alterScript, Is.EqualTo(expectedAlterString), + "ALTER script should match expected T-SQL when MAX_DURATION is changed from unlimited"); + } + finally + { + if (store.Sessions[sessionName] != null) + { + store.Sessions[sessionName].Drop(); + } + } + }); + } + + [TestMethod] + [SqlTestArea(SqlTestArea.ExtendedEvents)] + [SupportedServerVersionRange(DatabaseEngineType = DatabaseEngineType.Standalone, MinMajor = 17)] + [UnsupportedDatabaseEngineEdition(DatabaseEngineEdition.SqlManagedInstance)] + public void MaxDuration_AlterSession_WithoutChangingMaxDuration_DoesNotIncludeInScript() + { + ExecuteTest(() => + { + var store = new XEStore(new SqlStoreConnection(ServerContext.ConnectionContext.SqlConnectionObject)); + var sessionName = "TestMaxDuration_" + Guid.NewGuid().ToString(); + + try + { + // Create session via T-SQL + ServerContext.ConnectionContext.ExecuteNonQuery($@" + CREATE EVENT SESSION [{sessionName}] ON SERVER + ADD EVENT sqlserver.rpc_starting + WITH (MAX_MEMORY=4096 KB, MAX_DURATION=3600 SECONDS)"); + + store.Refresh(); + var session = store.Sessions[sessionName]; + + // Alter session but don't change MaxDuration - just add an event + session.AddEvent(store.ObjectInfoSet.Get("sqlserver.rpc_completed")); + + var expectedAlterString = $@"ALTER EVENT SESSION [{sessionName}] ON SERVER +ADD EVENT sqlserver.rpc_completed +".FixNewLines(); + + var alterScript = session.ScriptAlter().ToString(); + Assert.That(alterScript, Is.EqualTo(expectedAlterString), + "ALTER script should match expected T-SQL without MAX_DURATION when MaxDuration property is not dirty"); + } + finally + { + if (store.Sessions[sessionName] != null) + { + store.Sessions[sessionName].Drop(); + } + } + }); + } + + #endregion MaxDuration Tests } } diff --git a/src/Microsoft/SqlServer/Management/ConnectionInfo/ConnectionManager.cs b/src/Microsoft/SqlServer/Management/ConnectionInfo/ConnectionManager.cs index efa41216..d09181c0 100644 --- a/src/Microsoft/SqlServer/Management/ConnectionInfo/ConnectionManager.cs +++ b/src/Microsoft/SqlServer/Management/ConnectionInfo/ConnectionManager.cs @@ -15,6 +15,7 @@ namespace Microsoft.SqlServer.Management.Common #endif using System.Globalization; using System.Diagnostics; + using System.Diagnostics.Tracing; using Microsoft.SqlServer.Server; /// @@ -329,6 +330,26 @@ public bool IsFabricServer } } + /// + /// Returns the server collation + /// + public string Collation + { + get => m_collationOverride ?? GetServerInformation().Collation; + set + { + if (!IsForceDisconnected && IsOpen) + { + throw new ConnectionException(StringConnectionInfo.CannotBeSetWhileConnected); + } + if (m_collationOverride != value) + { + m_collationOverride = value; + m_serverInformation = null; + } + } + } + /// /// The host platform of the server (Linux/Windows/etc) /// @@ -420,7 +441,7 @@ private ServerInformation GetServerInformation() } else //Not Connected because of Offline/Design Mode. { - m_serverInformation = new ServerInformation(m_serverVersionOverride,new Version(m_serverVersionOverride.Major, m_serverVersionOverride.Minor, m_serverVersionOverride.BuildNumber), m_databaseEngineTypeOverride ?? DatabaseEngineType.Standalone, m_databaseEngineEditionOverride ?? DatabaseEngineEdition.Unknown, HostPlatformNames.Windows, NetworkProtocol.NotSpecified, m_isFabricServerOverride?? false); + m_serverInformation = new ServerInformation(m_serverVersionOverride,new Version(m_serverVersionOverride.Major, m_serverVersionOverride.Minor, m_serverVersionOverride.BuildNumber), m_databaseEngineTypeOverride ?? DatabaseEngineType.Standalone, m_databaseEngineEditionOverride ?? DatabaseEngineEdition.Unknown, HostPlatformNames.Windows, NetworkProtocol.NotSpecified, m_isFabricServerOverride?? false, m_collationOverride ?? "SQL_Latin1_General_CP1_CI_AS"); } } return m_serverInformation; @@ -648,6 +669,16 @@ public void Connect() return; } + + var startTime = System.Diagnostics.Stopwatch.StartNew(); + SqlConnectionStringBuilder connectionBuilder = null; + + // Log connection attempt (only parse connection string if logging is enabled) + if (SmoEventSource.Log.IsEnabled(EventLevel.Informational, SmoEventSource.Keywords.Connection)) + { + connectionBuilder = new SqlConnectionStringBuilder(this.ConnectionString); + SmoEventSource.Log.ConnectionAttemptStarted(connectionBuilder.DataSource ?? "", connectionBuilder.InitialCatalog ?? ""); + } SqlConnection sqlConnection = null; try @@ -672,9 +703,31 @@ public void Connect() this.BlockUpdates = true; m_InUse = true; + // Log successful connection + startTime.Stop(); + if (SmoEventSource.Log.IsEnabled(EventLevel.Informational, SmoEventSource.Keywords.Connection)) + { + if (connectionBuilder == null) + { + connectionBuilder = new SqlConnectionStringBuilder(this.ConnectionString); + } + SmoEventSource.Log.ConnectionEstablished(startTime.ElapsedMilliseconds, connectionBuilder.DataSource ?? "", connectionBuilder.InitialCatalog ?? ""); + } + } catch (Exception e) { + // Log connection failure + startTime.Stop(); + if (SmoEventSource.Log.IsEnabled(EventLevel.Warning, SmoEventSource.Keywords.Connection)) + { + if (connectionBuilder == null) + { + connectionBuilder = new SqlConnectionStringBuilder(this.ConnectionString); + } + SmoEventSource.Log.ConnectionFailure(false, connectionBuilder.DataSource ?? "", e.Message); + } + // Note: We cannot use 'this.ServerInstance' because it may not be be initialized // (i.e. it would have the default value of "(local)" which may be totally unrelated // to the ConnectionString value and thus provide an error message that would be @@ -723,30 +776,73 @@ protected object ExecuteTSql(ExecuteTSqlAction action, bool catchException) { //Connection should already be open. + var startTime = System.Diagnostics.Stopwatch.StartNew(); + string queryText = ""; + int commandTimeout = 0; + + // Extract query info for logging + if (execObject is SqlCommand cmd) + { + queryText = cmd.CommandText?.Length > 100 ? cmd.CommandText.Substring(0, 100) + "..." : cmd.CommandText ?? ""; + commandTimeout = cmd.CommandTimeout; + } try { + object result; switch (action) { case ExecuteTSqlAction.FillDataSet: - return (execObject as SqlDataAdapter).Fill(fillDataSet); + result = (execObject as SqlDataAdapter).Fill(fillDataSet); + break; case ExecuteTSqlAction.ExecuteNonQuery: - return (execObject as SqlCommand).ExecuteNonQuery(); + result = (execObject as SqlCommand).ExecuteNonQuery(); + break; case ExecuteTSqlAction.ExecuteReader: - return (execObject as SqlCommand).ExecuteReader(); + result = (execObject as SqlCommand).ExecuteReader(); + break; case ExecuteTSqlAction.ExecuteScalar: - return (execObject as SqlCommand).ExecuteScalar(); + result = (execObject as SqlCommand).ExecuteScalar(); + break; default: return null; } + + startTime.Stop(); + + // Log performance metrics (only if performance logging is enabled) + if (SmoEventSource.Log.IsEnabled(EventLevel.Verbose, SmoEventSource.Keywords.Performance)) + { + int rowsAffected = (result is int) ? (int)result : -1; + SmoEventSource.Log.QueryExecutionCompleted(startTime.ElapsedMilliseconds, rowsAffected, queryText); + + // Check for long-running queries (configurable threshold, defaulting to 5 seconds) + const long longRunningThreshold = 5000; + if (startTime.ElapsedMilliseconds > longRunningThreshold) + { + SmoEventSource.Log.LongRunningQuery(startTime.ElapsedMilliseconds, longRunningThreshold, queryText); + } + } + return result; } catch (SqlException exc) when (HandleExecuteException(exc, action, execObject, catchException, fillDataSet, out object result)) { + + // Check for timeout errors + if (exc.Number == -2) // Timeout error + { + SmoEventSource.Log.ConnectionTimeout(commandTimeout, $"SQL execution ({action})"); + } + return result; } + finally + { + startTime.Stop(); + } } private bool HandleExecuteException(SqlException exc, ExecuteTSqlAction action, @@ -803,11 +899,7 @@ private bool HandleExecuteException(SqlException exc, ExecuteTSqlAction action, } catch (SqlException caughtException) //Catch exceptions occuring in retries. { - Trace.TraceError(string.Format( - CultureInfo.CurrentCulture, - "Exception caught and not thrown while connection retry: {0}", - caughtException.Message) - ); + SmoEventSource.Log.ConnectionRetryException(caughtException.Message); } } result = null; @@ -832,11 +924,7 @@ private bool IsDatabaseValid(SqlConnection sqlConnection, string dbName) } catch (SqlException exp) { - Trace.TraceError(string.Format( - System.Globalization.CultureInfo.CurrentCulture, - "Exception caught and not thrown while connection retry: {0}", - exp.Message) - ); + SmoEventSource.Log.ConnectionRetryException(exp.Message); return false; } } @@ -873,6 +961,13 @@ public void Disconnect() sqlConnection.Close(); } bIsUserConnected = false; + + // Log connection closure (only parse connection string if logging is enabled) + if (SmoEventSource.Log.IsEnabled(EventLevel.Informational, SmoEventSource.Keywords.Connection)) + { + var connectionBuilder = new SqlConnectionStringBuilder(this.ConnectionString); + SmoEventSource.Log.ConnectionClosed(connectionBuilder.DataSource ?? "", "User requested disconnect"); + } } /// @@ -1017,6 +1112,7 @@ public event ServerMessageEventHandler ServerMessage private DatabaseEngineType? m_databaseEngineTypeOverride; private DatabaseEngineEdition? m_databaseEngineEditionOverride; private bool? m_isFabricServerOverride; + private string m_collationOverride; public event StatementEventHandler StatementExecuted { diff --git a/src/Microsoft/SqlServer/Management/ConnectionInfo/ConnectionSettings.cs b/src/Microsoft/SqlServer/Management/ConnectionInfo/ConnectionSettings.cs index f53d9a27..e4638f97 100644 --- a/src/Microsoft/SqlServer/Management/ConnectionInfo/ConnectionSettings.cs +++ b/src/Microsoft/SqlServer/Management/ConnectionInfo/ConnectionSettings.cs @@ -1243,7 +1243,7 @@ private void SetApplicationIntent(SqlConnectionStringBuilder sbConnectionString) } else { - Trace.TraceWarning("Unable to set ApplicationIntent property because it is not supported"); + SmoEventSource.Log.ConnectionConfigurationWarning("Unable to set ApplicationIntent property because it is not supported"); } } diff --git a/src/Microsoft/SqlServer/Management/ConnectionInfo/FxCopSupressions.cs b/src/Microsoft/SqlServer/Management/ConnectionInfo/FxCopSupressions.cs deleted file mode 100644 index d74325f2..00000000 --- a/src/Microsoft/SqlServer/Management/ConnectionInfo/FxCopSupressions.cs +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -using System.Diagnostics.CodeAnalysis; - -[module: SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "Microsoft.SqlServer.Management.Common.SqlConnectionInfo.get_NetworkProtocolString():System.String")] -[module: SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "Microsoft.SqlServer.Management.Trace.TraceReplay+TraceEventDataRecordChanger.set_Item(System.String,System.Object):System.Void")] -[module: SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "Microsoft.SqlServer.Management.Trace.TraceReplay+TraceEventDataRecordChanger.set_Item(System.Int32,System.Object):System.Void")] -[module: SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "Microsoft.SqlServer.Management.Trace.TraceReplay+TraceEventDataRecordChanger.GetTimeSpan(System.Int32):System.TimeSpan")] -[module: SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "Microsoft.SqlServer.Management.Trace.TraceReplay+TraceEventDataRecordChanger.GetStream(System.Int32):System.IO.Stream")] -[module: SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "Microsoft.SqlServer.Management.Trace.TraceReplay+TraceEventDataRecordChanger.GetChars(System.Int32,System.Char[],System.Int32,System.Int32,System.Int32):System.Int32")] - - -[module: SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", Scope = "member", Target = "Microsoft.SqlServer.Management.Common.SqlConnectionInfo.PoolConnectionLifeTime", MessageId = "LifeTime")] -[module: SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", Scope = "member", Target = "Microsoft.SqlServer.Management.Common.SqlOlapConnectionInfoBase.NoTimeOut", MessageId = "TimeOut")] -[module: SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", Scope = "member", Target = "Microsoft.SqlServer.Management.Common.StatementEventArgs..ctor(System.String,System.DateTime)", MessageId = "timeStamp")] -[module: SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", Scope = "member", Target = "Microsoft.SqlServer.Management.Common.StatementEventArgs.TimeStamp", MessageId = "TimeStamp")] -[module: SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", Scope = "member", Target = "Microsoft.SqlServer.Management.Common.ServerConnection.RollBackTransaction():System.Void", MessageId = "RollBack")] -[module: SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", Scope = "member", Target = "Microsoft.SqlServer.Management.Common.ServerConnection.IsInFixedServerRole(Microsoft.SqlServer.Management.Common.FixedServerRoles):System.Boolean", MessageId = "InFixed")] -[module: SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", Scope = "member", Target = "Microsoft.SqlServer.Management.Common.DataTransferProgressEventType.ExecutingDataFlow", MessageId = "DataFlow")] -[module: SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", Scope = "member", Target = "Microsoft.SqlServer.Management.Common.DataTransferProgressEventType.GenerateDataFlow", MessageId = "DataFlow")] - -[module: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Scope = "member", Target = "Microsoft.SqlServer.Management.Common.ConnectionSettings.ThrowIfPropertyNotSet(System.String,System.String):System.String", MessageId = "1#str")] -[module: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Scope = "member", Target = "Microsoft.SqlServer.Management.Common.ConnectionSettings.ThrowIfPropertyNotSet(System.String,System.String,System.Boolean):System.String", MessageId = "1#str")] -[module: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Scope = "member", Target = "Microsoft.SqlServer.Management.Common.SqlConnectionInfo..ctor(Microsoft.SqlServer.Management.Common.SqlConnectionInfo)", MessageId = "0#conn")] -[module: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Scope = "member", Target = "Microsoft.SqlServer.Management.Common.ConnectionInfoBase..ctor(Microsoft.SqlServer.Management.Common.ConnectionInfoBase)", MessageId = "0#conn")] -[module: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Scope = "member", Target = "Microsoft.SqlServer.Management.Common.ConnectionInfoBase.ConnectionParmsChanged():System.Void", MessageId = "Parms")] -[module: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Scope = "type", Target = "Microsoft.SqlServer.Management.Common.SqlOlapConnectionInfoBase", MessageId = "Olap")] -[module: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Scope = "member", Target = "Microsoft.SqlServer.Management.Common.SqlOlapConnectionInfoBase.DefaultConnTimeout", MessageId = "Conn")] -[module: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Scope = "member", Target = "Microsoft.SqlServer.Management.Common.SqlOlapConnectionInfoBase..ctor(Microsoft.SqlServer.Management.Common.SqlOlapConnectionInfoBase)", MessageId = "0#conn")] -[module: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Scope = "member", Target = "Microsoft.SqlServer.Management.Common.ConnectionType.Olap", MessageId = "Olap")] -[module: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Scope = "type", Target = "Microsoft.SqlServer.Management.Common.OlapConnectionInfo", MessageId = "Olap")] -[module: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Scope = "member", Target = "Microsoft.SqlServer.Management.Common.OlapConnectionInfo..ctor(Microsoft.SqlServer.Management.Common.OlapConnectionInfo)", MessageId = "0#conn")] -[module: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Scope = "member", Target = "Microsoft.SqlServer.Management.Common.NetworkProtocol.NWLinkIpxSpx", MessageId = "Ipx")] -[module: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Scope = "member", Target = "Microsoft.SqlServer.Management.Common.NetworkProtocol.Multiprotocol", MessageId = "Multiprotocol")] -[module: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Scope = "type", Target = "Microsoft.SqlServer.Management.Common.IRenamable", MessageId = "Renamable")] -[module: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Scope = "member", Target = "Microsoft.SqlServer.Management.Common.IRenamable.Rename(System.String):System.Void", MessageId = "0#newname")] -[module: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Scope = "member", Target = "Microsoft.SqlServer.Management.Common.DataTransferProgressEventType.ExecuteNonTransactableSql", MessageId = "Transactable")] -[module: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Scope = "member", Target = "Microsoft.SqlServer.Management.Trace.SqlTraceException.ProdVer", MessageId = "Ver")] -[module: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Scope = "member", Target = "Microsoft.SqlServer.Management.Trace.TraceReader.GetChars(System.Int32,System.Char[],System.Int32,System.Int32,System.Int32):System.Int32", MessageId = "3#bufferoffset")] -[module: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Scope = "member", Target = "Microsoft.SqlServer.Management.Trace.TraceReader.GetChars(System.Int32,System.Char[],System.Int32,System.Int32,System.Int32):System.Int32", MessageId = "4#fieldoffset")] -[module: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Scope = "member", Target = "Microsoft.SqlServer.Management.Trace.TraceServer.InitializeAsReader(Microsoft.SqlServer.Management.Common.ConnectionInfoBase,System.String):System.Void", MessageId = "0#Conn")] -[module: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Scope = "member", Target = "Microsoft.SqlServer.Management.Trace.TraceTable.InitializeAsReader(Microsoft.SqlServer.Management.Common.ConnectionInfoBase,System.String,System.String):System.Void", MessageId = "0#Conn")] -[module: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Scope = "member", Target = "Microsoft.SqlServer.Management.Trace.TraceTable.InitializeAsReplayOutputWriter(Microsoft.SqlServer.Management.Common.ConnectionInfoBase,System.String):System.Void", MessageId = "0#Conn")] -[module: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", Scope = "member", Target = "Microsoft.SqlServer.Management.Trace.TraceTable.InitializeAsWriter(Microsoft.SqlServer.Management.Trace.TraceReader,Microsoft.SqlServer.Management.Common.ConnectionInfoBase,System.String):System.Void", MessageId = "1#Conn")] -[module: SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix", Scope = "member", Target = "Microsoft.SqlServer.Management.Trace.TraceReplay.ReplayStop")] -[module: SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix", Scope = "member", Target = "Microsoft.SqlServer.Management.Trace.TraceReplay.ReplayStart")] -[module: SuppressMessage("Microsoft.Naming", "CA1710:IdentifiersShouldHaveCorrectSuffix", Scope = "member", Target = "Microsoft.SqlServer.Management.Trace.TraceReplay.ReplayPause")] -[module: SuppressMessage("Microsoft.Naming", "CA1705:LongAcronymsShouldBePascalCased", Scope = "type", Target = "Microsoft.SqlServer.Management.Trace.SqlTraceFailToLoadInstAPIAssemblyException")] -[module: SuppressMessage("Microsoft.Naming", "CA1706:ShortAcronymsShouldBeUppercase", Scope = "member", Target = "Microsoft.SqlServer.Management.Common.ServerConnection.ProcessID")] -[module: SuppressMessage("Microsoft.Naming", "CA1706:ShortAcronymsShouldBeUppercase", Scope = "member", Target = "Microsoft.SqlServer.Management.Common.NetworkProtocol.TcpIp")] - -[module: SuppressMessage("Microsoft.Globalization", "CA1305:SpecifyIFormatProvider", Scope = "member", Target = "Microsoft.SqlServer.Management.Common.StringConnectionInfo+Keys.GetString(System.String,System.Object[]):System.String", MessageId = "System.String.Format(System.String,System.Object[])")] - -[module: SuppressMessage("Microsoft.Reliability", "CA2001:AvoidCallingProblematicMethods", Scope = "member", Target = "Microsoft.SqlServer.Management.Common.SafeNativeMethods.GetMethodFromConnectionInfoExtended(System.String):System.Reflection.MethodInfo")] -[module: SuppressMessage("Microsoft.Security", "CA2100:ReviewSqlQueriesForSecurityVulnerabilities", Scope = "member", Target = "Microsoft.SqlServer.Management.Common.ConnectionManager.Connect():System.Void")] -[module: SuppressMessage("Microsoft.Security", "CA2100:ReviewSqlQueriesForSecurityVulnerabilities", Scope = "member", Target = "Microsoft.SqlServer.Management.Common.ConnectionManager.set_LockTimeout(System.Int32):System.Void")] -[module: SuppressMessage("Microsoft.Security", "CA2106:SecureAsserts", Scope = "member", Target = "Microsoft.SqlServer.Management.Common.EncryptionUtility.DecryptSecureString(System.Security.SecureString):System.String")] -[module: SuppressMessage("Microsoft.Security", "CA2106:SecureAsserts", Scope = "member", Target = "Microsoft.SqlServer.Management.Common.EncryptionUtility.#DecryptSecureString(System.Security.SecureString)")] -[module: SuppressMessage("Microsoft.MSInternal", "CA900:AptcaAssembliesShouldBeReviewed")] -[module: SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase", Scope = "member", Target = "Microsoft.SqlServer.Management.Common.SafeNativeMethods.GetMethodFromConnectionInfoExtended(System.String):System.Reflection.MethodInfo")] - - - diff --git a/src/Microsoft/SqlServer/Management/ConnectionInfo/Microsoft.SqlServer.ConnectionInfo.csproj b/src/Microsoft/SqlServer/Management/ConnectionInfo/Microsoft.SqlServer.ConnectionInfo.csproj index bbe1c0c1..2774d983 100644 --- a/src/Microsoft/SqlServer/Management/ConnectionInfo/Microsoft.SqlServer.ConnectionInfo.csproj +++ b/src/Microsoft/SqlServer/Management/ConnectionInfo/Microsoft.SqlServer.ConnectionInfo.csproj @@ -18,6 +18,7 @@ + diff --git a/src/Microsoft/SqlServer/Management/ConnectionInfo/ServerConnection.cs b/src/Microsoft/SqlServer/Management/ConnectionInfo/ServerConnection.cs index a0c7b588..38069315 100644 --- a/src/Microsoft/SqlServer/Management/ConnectionInfo/ServerConnection.cs +++ b/src/Microsoft/SqlServer/Management/ConnectionInfo/ServerConnection.cs @@ -9,6 +9,7 @@ namespace Microsoft.SqlServer.Management.Common using System.Collections; using System.Data; using System.Diagnostics; + using System.Diagnostics.Tracing; using System.Globalization; using System.Reflection; using System.Security; @@ -819,6 +820,8 @@ private void CaptureCommand(string query) if (SqlExecutionModes.CaptureSql == (SqlExecutionModes.CaptureSql & this.SqlExecutionModes)) { this.CapturedSql.Add(query); + // Log SQL capture for debugging + SmoEventSource.Log.ExecutionMessage($"SQL statement captured for replay: {query})"); } } diff --git a/src/Microsoft/SqlServer/Management/ConnectionInfo/ServerInformation.cs b/src/Microsoft/SqlServer/Management/ConnectionInfo/ServerInformation.cs index f25974b2..f5990b85 100644 --- a/src/Microsoft/SqlServer/Management/ConnectionInfo/ServerInformation.cs +++ b/src/Microsoft/SqlServer/Management/ConnectionInfo/ServerInformation.cs @@ -21,12 +21,6 @@ namespace Microsoft.SqlServer.Management.Common /// internal class ServerInformation { - private readonly ServerVersion serverVersion; - private readonly Version productVersion; - private readonly DatabaseEngineType databaseEngineType; - private readonly DatabaseEngineEdition databaseEngineEdition; - private readonly string hostPlatform; - private readonly NetworkProtocol connectionProtocol; /// /// Constructs a new ServerInformation object with the given values and HostPlatform of Windows @@ -37,7 +31,7 @@ internal class ServerInformation /// /// public ServerInformation(ServerVersion sv, Version productVersion, DatabaseEngineType dt, DatabaseEngineEdition databaseEngineEdition) - : this(sv, productVersion, dt, databaseEngineEdition, HostPlatformNames.Windows, NetworkProtocol.NotSpecified, isFabricServer: false) + : this(sv, productVersion, dt, databaseEngineEdition, HostPlatformNames.Windows, NetworkProtocol.NotSpecified, isFabricServer: false, collation: string.Empty) { } @@ -52,66 +46,50 @@ public ServerInformation(ServerVersion sv, Version productVersion, DatabaseEngin /// /// net_transport value from dm_exec_connections for the current spid /// + /// public ServerInformation(ServerVersion sv, Version productVersion, DatabaseEngineType dt, DatabaseEngineEdition databaseEngineEdition, - string hostPlatform, NetworkProtocol connectionProtocol, bool isFabricServer) + string hostPlatform, NetworkProtocol connectionProtocol, bool isFabricServer, string collation) { - serverVersion = sv; - this.productVersion = productVersion; - databaseEngineType = dt; - this.databaseEngineEdition = databaseEngineEdition; - this.hostPlatform = hostPlatform; - this.connectionProtocol = connectionProtocol; + ServerVersion = sv; + ProductVersion = productVersion; + DatabaseEngineType = dt; + DatabaseEngineEdition = databaseEngineEdition; + HostPlatform = hostPlatform; + ConnectionProtocol = connectionProtocol; IsFabricServer = isFabricServer; + Collation = collation; } /// /// The host platform of the connection as given by select host_platform from sys.dm_os_host_info /// /// Returns Windows prior to 2016 (when this DMV was introduced) - public string HostPlatform - { - get { return this.hostPlatform; } - } + public string HostPlatform { get; } /// /// The server version string given when this was initialized /// - public ServerVersion ServerVersion - { - get { return serverVersion; } - } + public ServerVersion ServerVersion { get; } /// /// The Product Version as given by SERVERPROPERTY('ProductVersion') /// - public Version ProductVersion - { - get { return productVersion; } - } + public Version ProductVersion { get; } /// /// The DatabaseEngineType of the connection as given by SERVERPROPERTY('EDITION') /// - public DatabaseEngineType DatabaseEngineType - { - get { return databaseEngineType; } - } + public DatabaseEngineType DatabaseEngineType { get; } /// /// The DatabaseEngineEdition of the connection as given by SERVERPROPERTY('EngineEdition') /// - public DatabaseEngineEdition DatabaseEngineEdition - { - get { return databaseEngineEdition; } - } + public DatabaseEngineEdition DatabaseEngineEdition { get; } /// /// Protocol used for the connection. /// - public NetworkProtocol ConnectionProtocol - { - get { return connectionProtocol; } - } + public NetworkProtocol ConnectionProtocol { get; } /// /// Returns true if the server is running in Microsoft Fabric @@ -121,6 +99,11 @@ public bool IsFabricServer get; } + /// + /// The server collation as given by SERVERPROPERTY('Collation') + /// + public string Collation { get; } + private static readonly HashSet validEditions = new HashSet(Enum.GetValues(typeof(DatabaseEngineEdition)).Cast()); // this query needs to be safe on all platforms. DW and Sql2005 don't support CONNECTIONPROPERTY private const string serverVersionQuery = @"DECLARE @edition sysname; @@ -129,7 +112,8 @@ public bool IsFabricServer SERVERPROPERTY('EngineEdition') AS DatabaseEngineEdition, SERVERPROPERTY('ProductVersion') AS ProductVersion, @@MICROSOFTVERSION AS MicrosoftVersion, -case when serverproperty('EngineEdition') = 12 then 1 when serverproperty('EngineEdition') = 11 and @@version like 'Microsoft Azure SQL Data Warehouse%' then 1 else 0 end as IsFabricServer; +case when serverproperty('EngineEdition') = 12 then 1 when serverproperty('EngineEdition') = 11 and @@version like 'Microsoft Azure SQL Data Warehouse%' then 1 else 0 end as IsFabricServer, +convert(sysname, SERVERPROPERTY(N'Collation')) AS Collation; "; static public ServerInformation GetServerInformation(IDbConnection sqlConnection, IDbDataAdapter dataAdapter, string serverVersionString) { @@ -146,17 +130,10 @@ static public ServerInformation GetServerInformation(IDbConnection sqlConnection cmdBuilder.AppendLine(@"select N'Windows' as host_platform"); } - if (serverVersion.Major >= 10) - { - cmdBuilder.AppendLine(@"if @edition = N'SQL Azure' + cmdBuilder.AppendLine(@"if @edition = N'SQL Azure' select 'TCP' as ConnectionProtocol else exec ('select CONVERT(nvarchar(40),CONNECTIONPROPERTY(''net_transport'')) as ConnectionProtocol')"); - } - else - { - cmdBuilder.AppendLine("select NULL as ConnectionProtocol"); - } using (var sqlCommand = sqlConnection.CreateCommand()) { @@ -196,6 +173,7 @@ static public ServerInformation GetServerInformation(IDbConnection sqlConnection } var isFabricServer = Convert.ToBoolean(dataSet.Tables[0].Rows[0]["IsFabricServer"]); var connectionProtocol = dataSet.Tables[2].Rows[0]["ConnectionProtocol"]; + var collation = (string)dataSet.Tables[0].Rows[0]["Collation"]; return new ServerInformation(serverVersion, new Version((string)dataSet.Tables[0].Rows[0]["ProductVersion"]), @@ -203,7 +181,8 @@ static public ServerInformation GetServerInformation(IDbConnection sqlConnection edition, (string)dataSet.Tables[1].Rows[0]["host_platform"], connectionProtocol == DBNull.Value ? NetworkProtocol.NotSpecified : ProtocolFromNetTransport((string)connectionProtocol), - isFabricServer + isFabricServer, + collation ); } } diff --git a/src/Microsoft/SqlServer/Management/ConnectionInfo/SmoEventSource.cs b/src/Microsoft/SqlServer/Management/ConnectionInfo/SmoEventSource.cs new file mode 100644 index 00000000..b39d9b0a --- /dev/null +++ b/src/Microsoft/SqlServer/Management/ConnectionInfo/SmoEventSource.cs @@ -0,0 +1,782 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +using System; +using System.Diagnostics.Tracing; + +namespace Microsoft.SqlServer.Management.Common +{ + /// + /// EventSource for SQL Server Management Objects (SMO) tracing. + /// Provides structured logging for database operations, scripting, and execution management. + /// + [EventSource(Name = "Microsoft-SqlServer-Management-Smo")] + #pragma warning disable CA1822 // EventSource methods must be instance methods + internal sealed class SmoEventSource : EventSource + { + /// + /// Singleton instance of the SmoEventSource. + /// + public static readonly SmoEventSource Log = new SmoEventSource(); + + /// + /// Keywords for categorizing SMO events by functional area. + /// Ordered by increasing likelihood of being needed for debugging (most common = lowest bit value). + /// + public static class Keywords + { + /// General informational events not specific to a functional area. + public const EventKeywords General = (EventKeywords)0x0001; + + /// Events related to database operations and connections. + public const EventKeywords Database = (EventKeywords)0x0002; + + /// Events related to execution management and SQL command processing. + public const EventKeywords Execution = (EventKeywords)0x0004; + + /// Events related to connection lifecycle and management. + public const EventKeywords Connection = (EventKeywords)0x0008; + + /// Events related to SFC (SQL Foundation Classes) operations. + public const EventKeywords Sfc = (EventKeywords)0x0010; + + /// Events related to SQL script generation and execution. + public const EventKeywords Scripting = (EventKeywords)0x0020; + + /// Events related to data enumeration and type handling. + public const EventKeywords DataEnumeration = (EventKeywords)0x0040; + + /// Events related to database object transfer operations. + public const EventKeywords Transfer = (EventKeywords)0x0080; + + /// Events related to performance and timing measurements. + public const EventKeywords Performance = (EventKeywords)0x0100; + + /// Events related to server event handling and subscriptions. + public const EventKeywords ServerEvents = (EventKeywords)0x0200; + + /// Events related to differencing operations. + public const EventKeywords Differencing = (EventKeywords)0x0400; + + /// Events related to serialization operations. + public const EventKeywords Serialization = (EventKeywords)0x0800; + } + + /// + /// Event IDs used throughout the SMO EventSource. + /// These IDs must remain stable for backwards compatibility. + /// + public static class EventIds + { + #region Database Events (1-9) + /// Database connection or operation failure. + public const int DatabaseConnectionFailure = 1; + + /// SQL exception during database operations. + public const int DatabaseSqlException = 2; + + /// General database operation message. + public const int DatabaseOperation = 3; + + /// HADR query failure. + public const int HadrQueryFailure = 4; + #endregion + + #region Execution Management Events (10-19) + /// URN data retrieval operation. + public const int GetDataForUrn = 10; + + /// Dependency resolution operation. + public const int GetDependencies = 11; + + /// General execution manager message. + public const int ExecutionMessage = 12; + + /// Connection retry exception caught and not thrown. + public const int ConnectionRetryException = 13; + + /// Connection configuration warning. + public const int ConnectionConfigurationWarning = 14; + #endregion + + #region Connection Events (20-29) + /// Connection attempt started. + public const int ConnectionAttemptStarted = 20; + + /// Connection established successfully. + public const int ConnectionEstablished = 21; + + /// Connection closed or disconnected. + public const int ConnectionClosed = 22; + + /// Connection failure with retry information. + public const int ConnectionFailure = 23; + #endregion + + #region Performance Events (30-39) + /// Long-running query detected. + public const int LongRunningQuery = 30; + + /// Query execution completed with timing. + public const int QueryExecutionCompleted = 31; + + /// Connection timeout occurred. + public const int ConnectionTimeout = 32; + #endregion + + #region Scripting Events (40-49) + /// Script generation invocation. + public const int ScriptWorkerInvoked = 40; + + /// Scripting progress update. + public const int ScriptingProgress = 41; + + /// URN discovery during script generation. + public const int UrnsDiscovered = 42; + + /// Object creation script generation. + public const int ScriptCreateObjects = 43; + + /// Script creation completion for individual objects. + public const int ScriptCreateComplete = 44; + #endregion + + #region Data Enumeration Events (50-59) + /// Error in data type scripting. + public const int DataTypeScriptingError = 50; + #endregion + + #region Server Events (60-69) + /// Removal of all server event subscriptions. + public const int RemoveAllSubscriptions = 60; + + /// Server event subscription updated. + public const int ServerEventSubscriptionUpdated = 61; + + /// Server event subscription added. + public const int ServerEventSubscriptionAdded = 62; + + /// Server event subscription removed. + public const int ServerEventSubscriptionRemoved = 63; + + /// Server event subscription started. + public const int ServerEventSubscriptionStarted = 64; + + /// Server event subscription query created. + public const int ServerEventSubscriptionQueryCreated = 65; + + /// Server event received. + public const int ServerEventReceived = 66; + + /// Server event raised to handler. + public const int ServerEventRaised = 67; + #endregion + + #region General Events (70-79) + /// General informational message. + public const int GeneralMessage = 70; + #endregion + + #region SFC Events (80-89) + /// SFC component trace message. + public const int SfcTrace = 80; + + /// SFC exception logging. + public const int SfcExceptionCaught = 81; + + /// SFC connection helper exception. + public const int SfcConnectionException = 82; + #endregion + + #region Differencing Events (90-99) + /// Differencing operation trace. + public const int DifferencingTrace = 90; + + /// Differencing exception logging. + public const int DifferencingException = 91; + #endregion + + #region Transfer Events (100-109) + /// Transfer dependency discovery started. + public const int TransferDiscoveringDependencies = 100; + + /// Transfer scripting all discovered objects. + public const int TransferScriptingObjects = 101; + + /// Transfer visiting object for dependency analysis. + public const int TransferVisitingObject = 102; + + /// Transfer marking node for cycle breaking. + public const int TransferMarkingNodeForBreaking = 103; + #endregion + + #region Initialization Events (110-119) + /// Missing property warning during initialization. + public const int PropertyMissing = 110; + #endregion + } + + /// + /// Initializes a new instance of the SmoEventSource class. + /// + private SmoEventSource() : base() { } + + #region Database Events + + /// + /// Logs database connection or operation failures. + /// + /// Current state of the database object. + /// State of the property bag. + /// Error message details. + [Event(EventIds.DatabaseConnectionFailure, Level = EventLevel.Warning, Keywords = Keywords.Database, + Message = "Failed to connect for edition fetch, defaulting to Unknown edition. State: {0} PropertyBagState: {1} Error: {2}")] + public void DatabaseConnectionFailure(string state, string propertyBagState, string errorMessage) + { + WriteEvent(EventIds.DatabaseConnectionFailure, state, propertyBagState, errorMessage); + } + + /// + /// Logs SQL exceptions during database operations. + /// + /// SQL exception number. + /// Current state of the database object. + [Event(EventIds.DatabaseSqlException, Level = EventLevel.Warning, Keywords = Keywords.Database, + Message = "Failed to connect for edition fetch. State: {1}, SqlException number: {0}")] + public void DatabaseSqlException(int sqlExceptionNumber, string state) + { + WriteEvent(EventIds.DatabaseSqlException, sqlExceptionNumber, state); + } + + /// + /// Logs general database operation messages. + /// + /// Database operation message. + [Event(EventIds.DatabaseOperation, Level = EventLevel.Informational, Keywords = Keywords.Database, + Message = "Database operation: {0}")] + public void DatabaseOperation(string message) + { + WriteEvent(EventIds.DatabaseOperation, message); + } + + /// + /// Logs HADR (High Availability Disaster Recovery) query failures. + /// + /// Primary error message. + /// Inner exception message if available. + [Event(EventIds.HadrQueryFailure, Level = EventLevel.Warning, Keywords = Keywords.Database, + Message = "Unable to query sys.fn_hadr_is_primary_replica. {0} {1}")] + public void HadrQueryFailure(string errorMessage, string innerErrorMessage) + { + WriteEvent(EventIds.HadrQueryFailure, errorMessage, innerErrorMessage); + } + + #endregion + + #region Execution Management Events + + /// + /// Logs URN (Uniform Resource Name) data retrieval operations. + /// + /// The URN being processed. + [Event(EventIds.GetDataForUrn, Level = EventLevel.Verbose, Keywords = Keywords.Execution, + Message = "Get data for urn: {0}")] + public void GetDataForUrn(string urn) + { + WriteEvent(EventIds.GetDataForUrn, urn); + } + + /// + /// Logs dependency resolution operations. + /// + [Event(EventIds.GetDependencies, Level = EventLevel.Informational, Keywords = Keywords.Execution, + Message = "Get dependencies")] + public void GetDependencies() + { + WriteEvent(EventIds.GetDependencies); + } + + /// + /// Logs general execution manager messages. + /// + /// Execution manager message. + [Event(EventIds.ExecutionMessage, Level = EventLevel.Verbose, Keywords = Keywords.Execution, + Message = "Execution: {0}")] + public void ExecutionMessage(string message) + { + WriteEvent(EventIds.ExecutionMessage, message); + } + + /// + /// Logs connection retry exceptions that are caught and not thrown. + /// + /// The exception message from the caught exception. + [Event(EventIds.ConnectionRetryException, Level = EventLevel.Error, Keywords = Keywords.Execution, + Message = "Exception caught and not thrown while connection retry: {0}")] + public void ConnectionRetryException(string exceptionMessage) + { + WriteEvent(EventIds.ConnectionRetryException, exceptionMessage); + } + + /// + /// Logs connection configuration warnings. + /// + /// The configuration warning message. + [Event(EventIds.ConnectionConfigurationWarning, Level = EventLevel.Warning, Keywords = Keywords.Execution, + Message = "Connection configuration warning: {0}")] + public void ConnectionConfigurationWarning(string warningMessage) + { + WriteEvent(EventIds.ConnectionConfigurationWarning, warningMessage); + } + + #endregion + + #region Connection Events + + /// + /// Logs connection attempt started. + /// + /// Name of the server being connected to. + /// Name of the database being connected to. + [Event(EventIds.ConnectionAttemptStarted, Level = EventLevel.Informational, Keywords = Keywords.Connection, + Message = "Connection attempt started to server: {0}, database: {1}")] + public void ConnectionAttemptStarted(string serverName, string databaseName) + { + WriteEvent(EventIds.ConnectionAttemptStarted, serverName ?? "", databaseName ?? ""); + } + + /// + /// Logs successful connection establishment. + /// + /// Time taken to establish connection in milliseconds. + /// Name of the server connected to. + /// Name of the database connected to. + [Event(EventIds.ConnectionEstablished, Level = EventLevel.Informational, Keywords = Keywords.Connection, + Message = "Connection established to server: {1}, database: {2}, duration: {0}ms")] + public void ConnectionEstablished(long durationMs, string serverName, string databaseName) + { + WriteEvent(EventIds.ConnectionEstablished, durationMs, serverName ?? "", databaseName ?? ""); + } + + /// + /// Logs connection closure or disconnection. + /// + /// Name of the server being disconnected from. + /// Reason for disconnection. + [Event(EventIds.ConnectionClosed, Level = EventLevel.Informational, Keywords = Keywords.Connection, + Message = "Connection closed to server: {0}, reason: {1}")] + public void ConnectionClosed(string serverName, string reason) + { + WriteEvent(EventIds.ConnectionClosed, serverName ?? "", reason ?? ""); + } + + /// + /// Logs connection failure with retry information. + /// + /// Whether a retry will be attempted. + /// Name of the server that failed to connect. + /// Error message from the connection failure. + [Event(EventIds.ConnectionFailure, Level = EventLevel.Warning, Keywords = Keywords.Connection, + Message = "Connection failed to server: {1}, error: {2}, will retry: {0}")] + public void ConnectionFailure(bool willRetry, string serverName, string errorMessage) + { + WriteEvent(EventIds.ConnectionFailure, willRetry, serverName ?? "", errorMessage ?? ""); + } + + #endregion + + #region Performance Events + + /// + /// Logs detection of long-running queries. + /// + /// Duration of the query in milliseconds. + /// Threshold that was exceeded. + /// Text of the long-running query (truncated if necessary). + [Event(EventIds.LongRunningQuery, Level = EventLevel.Warning, Keywords = Keywords.Performance, + Message = "Long-running query detected: duration {0}ms exceeded threshold {1}ms, query: {2}")] + public void LongRunningQuery(long durationMs, long threshold, string queryText) + { + WriteEvent(EventIds.LongRunningQuery, durationMs, threshold, queryText ?? ""); + } + + /// + /// Logs query execution completion with timing information. + /// + /// Duration of the query execution in milliseconds. + /// Number of rows affected by the query. + /// Text of the executed query (truncated if necessary). + [Event(EventIds.QueryExecutionCompleted, Level = EventLevel.Verbose, Keywords = Keywords.Performance, + Message = "Query execution completed: duration {0}ms, rows affected: {1}, query: {2}")] + public void QueryExecutionCompleted(long durationMs, int rowsAffected, string queryText) + { + WriteEvent(EventIds.QueryExecutionCompleted, durationMs, rowsAffected, queryText ?? ""); + } + + /// + /// Logs connection timeout occurrences. + /// + /// Timeout value in seconds. + /// Operation that timed out. + [Event(EventIds.ConnectionTimeout, Level = EventLevel.Error, Keywords = Keywords.Performance, + Message = "Connection timeout occurred during: {1}, timeout: {0}s")] + public void ConnectionTimeout(int timeoutSeconds, string operation) + { + WriteEvent(EventIds.ConnectionTimeout, timeoutSeconds, operation ?? ""); + } + + #endregion + + #region Scripting Events + + /// + /// Logs script generation operations. + /// + /// Number of URNs being scripted. + /// List of URNs being processed. + [Event(EventIds.ScriptWorkerInvoked, Level = EventLevel.Informational, Keywords = Keywords.Scripting, + Message = "ScriptWorker invoked for {0} Urns: {1}")] + public void ScriptWorkerInvoked(int urnCount, string urnList) + { + WriteEvent(EventIds.ScriptWorkerInvoked, urnCount, urnList); + } + + /// + /// Logs scripting progress updates. + /// + /// Current progress stage. + [Event(EventIds.ScriptingProgress, Level = EventLevel.Informational, Keywords = Keywords.Scripting, + Message = "OnScriptingProgress {0}")] + public void ScriptingProgress(string progressStage) + { + WriteEvent(EventIds.ScriptingProgress, progressStage); + } + + /// + /// Logs discovered URNs during script generation. + /// + /// Number of URNs discovered. + /// List of discovered URNs. + [Event(EventIds.UrnsDiscovered, Level = EventLevel.Informational, Keywords = Keywords.Scripting, + Message = "Discovered {0} Urns: {1}")] + public void UrnsDiscovered(int discoveredCount, string urnList) + { + WriteEvent(EventIds.UrnsDiscovered, discoveredCount, urnList); + } + + /// + /// Logs object creation script generation. + /// + /// Number of URNs for object creation. + /// List of URNs being created. + [Event(EventIds.ScriptCreateObjects, Level = EventLevel.Informational, Keywords = Keywords.Scripting, + Message = "ScriptCreateObjects for {0} Urns: {1}")] + public void ScriptCreateObjects(int urnCount, string urnList) + { + WriteEvent(EventIds.ScriptCreateObjects, urnCount, urnList); + } + + /// + /// Logs completion of script creation for individual objects. + /// + /// URN of the completed object. + [Event(EventIds.ScriptCreateComplete, Level = EventLevel.Verbose, Keywords = Keywords.Scripting, + Message = "ScriptCreate complete for {0}")] + public void ScriptCreateComplete(string urn) + { + WriteEvent(EventIds.ScriptCreateComplete, urn); + } + + #endregion + + #region Server Events + + /// + /// Logs removal of all server event subscriptions. + /// + [Event(EventIds.RemoveAllSubscriptions, Level = EventLevel.Informational, Keywords = Keywords.ServerEvents, + Message = "Removing all subscriptions")] + public void RemoveAllSubscriptions() + { + WriteEvent(EventIds.RemoveAllSubscriptions); + } + + /// + /// Logs when a server event subscription handler is updated. + /// + /// The event class being updated. + /// The target class name. + [Event(EventIds.ServerEventSubscriptionUpdated, Level = EventLevel.Informational, Keywords = Keywords.ServerEvents, + Message = "Updating event handler for event {0} on class {1}")] + public void ServerEventSubscriptionUpdated(string eventClass, string targetClassName) + { + WriteEvent(EventIds.ServerEventSubscriptionUpdated, eventClass, targetClassName); + } + + /// + /// Logs when a server event subscription is added. + /// + /// The event class being subscribed to. + /// The target class name. + [Event(EventIds.ServerEventSubscriptionAdded, Level = EventLevel.Informational, Keywords = Keywords.ServerEvents, + Message = "Adding subscription for event {0} on class {1}")] + public void ServerEventSubscriptionAdded(string eventClass, string targetClassName) + { + WriteEvent(EventIds.ServerEventSubscriptionAdded, eventClass, targetClassName); + } + + /// + /// Logs when a server event subscription is removed. + /// + /// The event class being unsubscribed from. + /// The target class name. + [Event(EventIds.ServerEventSubscriptionRemoved, Level = EventLevel.Informational, Keywords = Keywords.ServerEvents, + Message = "Removing subscription for event {0} on class {1}")] + public void ServerEventSubscriptionRemoved(string eventClass, string targetClassName) + { + WriteEvent(EventIds.ServerEventSubscriptionRemoved, eventClass, targetClassName); + } + + /// + /// Logs when a server event subscription is started. + /// + /// The WMI scope path. + /// The WQL query string. + [Event(EventIds.ServerEventSubscriptionStarted, Level = EventLevel.Informational, Keywords = Keywords.ServerEvents, + Message = "Starting event subscription on: {0}, query: {1}")] + public void ServerEventSubscriptionStarted(string scopePath, string queryString) + { + WriteEvent(EventIds.ServerEventSubscriptionStarted, scopePath, queryString); + } + + /// + /// Logs when a server event subscription query is created. + /// + /// The WQL query string. + [Event(EventIds.ServerEventSubscriptionQueryCreated, Level = EventLevel.Informational, Keywords = Keywords.ServerEvents, + Message = "Subscription query {0}")] + public void ServerEventSubscriptionQueryCreated(string queryString) + { + WriteEvent(EventIds.ServerEventSubscriptionQueryCreated, queryString); + } + + /// + /// Logs when a server event is received from WMI. + /// + /// The event class name. + /// The target class name. + [Event(EventIds.ServerEventReceived, Level = EventLevel.Informational, Keywords = Keywords.ServerEvents, + Message = "Received event {0} on class {1}")] + public void ServerEventReceived(string eventClassName, string targetClassName) + { + WriteEvent(EventIds.ServerEventReceived, eventClassName, targetClassName); + } + + /// + /// Logs when a server event is raised to a handler. + /// + /// The event class name. + /// The subscription key. + [Event(EventIds.ServerEventRaised, Level = EventLevel.Informational, Keywords = Keywords.ServerEvents, + Message = "Raising event {0} on subscription: {1}")] + public void ServerEventRaised(string eventClassName, string subscriptionKey) + { + WriteEvent(EventIds.ServerEventRaised, eventClassName, subscriptionKey); + } + + #endregion + + #region Data Enumeration Events + + /// + /// Logs errors in data type scripting. + /// + /// Data type that caused the error. + [Event(EventIds.DataTypeScriptingError, Level = EventLevel.Error, Keywords = Keywords.DataEnumeration, + Message = "ERROR: Attempting to script data for type {0}")] + public void DataTypeScriptingError(string dataType) + { + WriteEvent(EventIds.DataTypeScriptingError, dataType); + } + + #endregion + + #region General Events + + /// + /// Logs general informational messages. + /// + /// General message. + [Event(EventIds.GeneralMessage, Level = EventLevel.Informational, Keywords = Keywords.General, + Message = "{0}")] + public void GeneralMessage(string message) + { + WriteEvent(EventIds.GeneralMessage, message); + } + + #endregion + + #region SFC Events + + /// + /// Logs SFC component trace messages. + /// + /// Name of the SFC component. + /// Trace message. + [Event(EventIds.SfcTrace, Level = EventLevel.Verbose, Keywords = Keywords.Sfc, + Message = "[{0}] {1}")] + public void SfcTrace(string componentName, string message) + { + WriteEvent(EventIds.SfcTrace, componentName ?? "", message ?? ""); + } + + /// + /// Logs SFC exceptions that are caught. + /// + /// The exception message. + [Event(EventIds.SfcExceptionCaught, Level = EventLevel.Error, Keywords = Keywords.Sfc, + Message = "SFC exception caught: {0}")] + public void SfcExceptionCaught(string exceptionMessage) + { + WriteEvent(EventIds.SfcExceptionCaught, exceptionMessage ?? ""); + } + + /// + /// Logs SFC exceptions that are caught with full exception details. + /// + /// The exception to log. + [NonEvent] + public void SfcExceptionCaught(Exception exception) + { + // Use ToString() to get full exception details including stack trace and inner exceptions + SfcExceptionCaught(exception?.ToString() ?? "Unknown exception"); + } + + /// + /// Logs SFC connection helper exceptions. + /// + /// The exception message. + [Event(EventIds.SfcConnectionException, Level = EventLevel.Error, Keywords = Keywords.Sfc, + Message = "SFC connection exception: {0}")] + public void SfcConnectionException(string exceptionMessage) + { + WriteEvent(EventIds.SfcConnectionException, exceptionMessage ?? ""); + } + + /// + /// Logs SFC connection helper exceptions with full exception details. + /// + /// The exception to log. + [NonEvent] + public void SfcConnectionException(Exception exception) + { + // Use ToString() to get full exception details including stack trace and inner exceptions + SfcConnectionException(exception?.ToString() ?? "Unknown exception"); + } + + #endregion + + #region Differencing Events + + /// + /// Logs differencing operation trace messages. + /// + /// Trace message. + [Event(EventIds.DifferencingTrace, Level = EventLevel.Verbose, Keywords = Keywords.Differencing, + Message = "{0}")] + public void DifferencingTrace(string message) + { + WriteEvent(EventIds.DifferencingTrace, message ?? ""); + } + + /// + /// Logs differencing exceptions that are caught. + /// + /// The exception message. + [Event(EventIds.DifferencingException, Level = EventLevel.Error, Keywords = Keywords.Differencing, + Message = "Differencing exception: {0}")] + public void DifferencingException(string exceptionMessage) + { + WriteEvent(EventIds.DifferencingException, exceptionMessage ?? ""); + } + + /// + /// Logs differencing exceptions that are caught with full exception details. + /// + /// The exception to log. + [NonEvent] + public void DifferencingException(Exception exception) + { + // Use ToString() to get full exception details including stack trace and inner exceptions + DifferencingException(exception?.ToString() ?? "Unknown exception"); + } + + #endregion + + #region Transfer Events + + /// + /// Logs transfer dependency discovery phase. + /// + [Event(EventIds.TransferDiscoveringDependencies, Level = EventLevel.Informational, Keywords = Keywords.Transfer, + Message = "Transfer: Discovering dependencies")] + public void TransferDiscoveringDependencies() + { + WriteEvent(EventIds.TransferDiscoveringDependencies); + } + + /// + /// Logs transfer scripting phase. + /// + [Event(EventIds.TransferScriptingObjects, Level = EventLevel.Informational, Keywords = Keywords.Transfer, + Message = "Transfer: Script all discovered objects")] + public void TransferScriptingObjects() + { + WriteEvent(EventIds.TransferScriptingObjects); + } + + /// + /// Logs transfer visiting an object for dependency analysis. + /// + /// True if only non-system objects are added + /// Information about the object being visited. + [Event(EventIds.TransferVisitingObject, Level = EventLevel.Verbose, Keywords = Keywords.Transfer, + Message = "Transfer: Visiting object {0}")] + public void TransferVisitingObject(bool nonSystemOnly, string objectInfo) + { + WriteEvent(EventIds.TransferVisitingObject, nonSystemOnly, objectInfo ?? ""); + } + + /// + /// Logs transfer marking node for cycle breaking. + /// + /// Information about the node being marked. + [Event(EventIds.TransferMarkingNodeForBreaking, Level = EventLevel.Verbose, Keywords = Keywords.Transfer, + Message = "Transfer: Marking node for breaking - {0}")] + public void TransferMarkingNodeForBreaking(string nodeInfo) + { + WriteEvent(EventIds.TransferMarkingNodeForBreaking, nodeInfo ?? ""); + } + + #endregion + + #region Initialization Events + + /// + /// Logs missing property warnings during object initialization. + /// + /// Whether the property is an expensive property. + /// Whether the object is in design mode. + /// Name of the missing property. + /// Type name of the object. + /// Current property bag state. + [Event(EventIds.PropertyMissing, Level = EventLevel.Warning, Keywords = Keywords.General, + Message = "Missing property '{2}' for type {3}: IsExpensive={0}, DesignMode={1}, PropertyBagState={4}")] + public void PropertyMissing(bool isExpensive, bool isDesignMode, string propertyName, string typeName, string propertyBagState) + { + WriteEvent(EventIds.PropertyMissing, isExpensive, isDesignMode, propertyName ?? "", typeName ?? "", propertyBagState ?? ""); + } + + #endregion + } +} \ No newline at end of file diff --git a/src/Microsoft/SqlServer/Management/ConnectionInfo/SqlConnectionInfo.cs b/src/Microsoft/SqlServer/Management/ConnectionInfo/SqlConnectionInfo.cs index 34a08757..09a515de 100644 --- a/src/Microsoft/SqlServer/Management/ConnectionInfo/SqlConnectionInfo.cs +++ b/src/Microsoft/SqlServer/Management/ConnectionInfo/SqlConnectionInfo.cs @@ -71,7 +71,14 @@ public enum AuthenticationMethod /// sequentially to acquire an access token. This method does not fallback to the /// Active Directory Interactive authentication method. /// - ActiveDirectoryDefault = 9 + ActiveDirectoryDefault = 9, + /// + /// The authentication method uses Active Directory Workload Identity. Use a federated + /// User Assigned Managed Identity to connect to SQL Database from Azure client environments + /// that have enabled support for Workload Identity. The 'User Id' or 'UID' is required + /// to be set to the "client ID" of the user identity. + /// + ActiveDirectoryWorkloadIdentity = 10 } private StringBuilder m_sbApplicationName = null; diff --git a/src/Microsoft/SqlServer/Management/ConnectionInfo/safenativemethods.cs b/src/Microsoft/SqlServer/Management/ConnectionInfo/safenativemethods.cs index dfb2dd6b..38ba1b29 100644 --- a/src/Microsoft/SqlServer/Management/ConnectionInfo/safenativemethods.cs +++ b/src/Microsoft/SqlServer/Management/ConnectionInfo/safenativemethods.cs @@ -35,7 +35,7 @@ internal static SafeAccessTokenHandle GetUserToken(string user, string domain, s if (!returnValue) { var ret = Marshal.GetLastWin32Error(); - Trace.TraceInformation("LogonUser failed with error code : {0}", ret); + SmoEventSource.Log.ExecutionMessage($"LogonUser failed with error code : {ret}"); throw new System.ComponentModel.Win32Exception(ret); } return safeAccessTokenHandle; diff --git a/src/Microsoft/SqlServer/Management/Dmf/ObjectSet.cs b/src/Microsoft/SqlServer/Management/Dmf/ObjectSet.cs index 6820fe81..8ae2430a 100644 --- a/src/Microsoft/SqlServer/Management/Dmf/ObjectSet.cs +++ b/src/Microsoft/SqlServer/Management/Dmf/ObjectSet.cs @@ -254,9 +254,8 @@ public IEnumerable CalculateTargets(SqlStoreConnection sqlStoreConnection, strin } PolicyCategory pc = null; - if (!String.IsNullOrEmpty(policyCategory) && sqlStoreConnection.ServerVersion.Major >= 10) + if (!String.IsNullOrEmpty(policyCategory)) { - // if target is downlevel, we ignore policyCategory if (this.Parent.SqlStoreConnection == null || this.Parent.SqlStoreConnection != sqlStoreConnection) { diff --git a/src/Microsoft/SqlServer/Management/HadrData/AvailabilityGroupData.cs b/src/Microsoft/SqlServer/Management/HadrData/AvailabilityGroupData.cs index 79dca005..50d43a51 100644 --- a/src/Microsoft/SqlServer/Management/HadrData/AvailabilityGroupData.cs +++ b/src/Microsoft/SqlServer/Management/HadrData/AvailabilityGroupData.cs @@ -375,6 +375,16 @@ public bool IsCrossPlatform get { return this.Secondaries.Any(replica => replica.GetServer().HostPlatform != this.PrimaryServer.HostPlatform); } } + /// + /// Specifies the cluster connection options used by WSFC to connect to SQL Server via ODBC. + /// This enables TDS 8.0 and is only applicable when the cluster type is set to "WSFC" + /// and the SQL Server version is 2025 or later. + /// + public string ClusterConnectionOptions + { + get; + set; + } #endregion #region Methods diff --git a/src/Microsoft/SqlServer/Management/HadrModel/CreateAvailabilityGroupTask.cs b/src/Microsoft/SqlServer/Management/HadrModel/CreateAvailabilityGroupTask.cs index e37e6b00..9d6d0cfe 100644 --- a/src/Microsoft/SqlServer/Management/HadrModel/CreateAvailabilityGroupTask.cs +++ b/src/Microsoft/SqlServer/Management/HadrModel/CreateAvailabilityGroupTask.cs @@ -87,6 +87,11 @@ protected override void Perform(IExecutionPolicy policy) availabilityGroup.IsContained = this.availabilityGroupData.IsContained; } + if (availabilityGroup.IsSupportedProperty(nameof(availabilityGroup.ClusterConnectionOptions))) + { + availabilityGroup.ClusterConnectionOptions = this.availabilityGroupData.ClusterConnectionOptions; + } + foreach (var db in this.availabilityGroupData.NewAvailabilityDatabases) { availabilityGroup.AvailabilityDatabases.Add(new SMO.AvailabilityDatabase(availabilityGroup, db.Name)); diff --git a/src/Microsoft/SqlServer/Management/Sdk/Sfc/Differencing/API/DifferencingService.cs b/src/Microsoft/SqlServer/Management/Sdk/Sfc/Differencing/API/DifferencingService.cs index 3d787662..51624ba7 100644 --- a/src/Microsoft/SqlServer/Management/Sdk/Sfc/Differencing/API/DifferencingService.cs +++ b/src/Microsoft/SqlServer/Management/Sdk/Sfc/Differencing/API/DifferencingService.cs @@ -2,8 +2,8 @@ // Licensed under the MIT license. using System; - -using Microsoft.SqlServer.Management.Sdk.Sfc; +using System.Diagnostics.Tracing; +using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.Sdk.Differencing.Impl; using Microsoft.SqlServer.Management.Sdk.Differencing.SPI; @@ -82,7 +82,10 @@ private static void RegisterProvider(ProviderRegistry myRegistry, Provider provi } else { - TraceHelper.Trace(Differencer.ComponentName, "The type of provider, '{0}', is not in recognized.", provider.GetType().Name); + if (SmoEventSource.Log.IsEnabled(EventLevel.Verbose, SmoEventSource.Keywords.Differencing)) + { + SmoEventSource.Log.DifferencingTrace($"The type of provider, '{provider.GetType().Name}', is not recognized."); + } } } @@ -97,13 +100,13 @@ private static Provider CreateProviderInstance(String assemblyName, String name) } else { - TraceHelper.Trace(Differencer.ComponentName, "The type of provider, '{0}', is not in recognized.", name); + SmoEventSource.Log.DifferencingTrace($"The type of provider, '{name}', is not recognized."); return null; } } catch (Exception e) when (!Differencer.IsSystemGeneratedException(e)) { - TraceHelper.Trace(Differencer.ComponentName, "Exception loading provider, '{0}'.", name); + SmoEventSource.Log.DifferencingTrace($"Exception loading provider, '{name}'."); return null; } } diff --git a/src/Microsoft/SqlServer/Management/Sdk/Sfc/Differencing/Impl/Differencer.cs b/src/Microsoft/SqlServer/Management/Sdk/Sfc/Differencing/Impl/Differencer.cs index 7292adec..22a60523 100644 --- a/src/Microsoft/SqlServer/Management/Sdk/Sfc/Differencing/Impl/Differencer.cs +++ b/src/Microsoft/SqlServer/Management/Sdk/Sfc/Differencing/Impl/Differencer.cs @@ -4,7 +4,10 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Diagnostics; +using System.Diagnostics.Tracing; using System.Linq; +using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.Sdk.Differencing.SPI; using Microsoft.SqlServer.Management.Sdk.Sfc; @@ -16,8 +19,6 @@ namespace Microsoft.SqlServer.Management.Sdk.Differencing.Impl /// internal class Differencer : IDifferencer { - internal const string ComponentName = "Differencing"; - // A default available value provider that always return true private readonly static AvailablePropertyValueProvider DEFAULT_AVAILABLE_PROPERTY_VALUE_PROVIDER = new DefaultAvailablePropertyValueProvider(); @@ -39,6 +40,20 @@ private readonly static PropertyComparerProvider DEFAULT_PROP_COMPARER // option to indicate what type to emit private DiffType emittedChangeType; + /// + /// Helper method to log differencing trace messages with performance optimization. + /// + /// The message to log. + /// Optional format arguments. + private static void LogTrace(string message, params object[] args) + { + if (SmoEventSource.Log.IsEnabled(EventLevel.Verbose, SmoEventSource.Keywords.Differencing)) + { + string formattedMessage = args.Length == 0 ? message : string.Format(message, args); + SmoEventSource.Log.DifferencingTrace(formattedMessage); + } + } + /// /// Constructor /// @@ -72,28 +87,28 @@ public void UnsetTypeEmitted(DiffType type) // implement the diff method public IDiffgram CompareGraphs(Object source, Object target) { - TraceHelper.Trace(Differencer.ComponentName, "CompareGraphs: entering public method."); + LogTrace("CompareGraphs: entering public method."); if (source == null) { - TraceHelper.Trace(Differencer.ComponentName, "CompareGraphs: argument null 'source'."); + LogTrace("CompareGraphs: argument null 'source'."); throw new ArgumentNullException("source"); } if (target == null) { - TraceHelper.Trace(Differencer.ComponentName, "CompareGraphs: argument null 'target'."); + LogTrace("CompareGraphs: argument null 'target'."); throw new ArgumentNullException("target"); } if (source.GetType() != target.GetType()) { - TraceHelper.Trace(Differencer.ComponentName, "CompareGraphs: argument types do not match."); + LogTrace("CompareGraphs: argument types do not match."); throw new ArgumentException(StringDifferencing.MismatchType(source.ToString(), target.ToString())); } SfcNodeAdapterProvider nodeAdapter = FindNodeAdapterProvider(source); if (nodeAdapter == null) { - TraceHelper.Trace(Differencer.ComponentName, "CompareGraphs: cannot find node adapter that can navigate the specified input."); + LogTrace("CompareGraphs: cannot find node adapter that can navigate the specified input."); throw new ArgumentException(StringDifferencing.NotRecognizedGraph); } @@ -102,40 +117,40 @@ public IDiffgram CompareGraphs(Object source, Object target) NodeItemNamesAdapterProvider nameProvider = FindNameProvider(sourceAdapted); if (nameProvider == null) { - TraceHelper.Trace(Differencer.ComponentName, "CompareGraphs: cannot find name (metadata) provider that can navigate the specified input."); + LogTrace("CompareGraphs: cannot find name (metadata) provider that can navigate the specified input."); throw new ArgumentException(StringDifferencing.CannotFindMetadataProvider); } AvailablePropertyValueProvider sourceValueProvider = FindAvailableValueProvider(sourceAdapted); if (sourceValueProvider == null) { - TraceHelper.Trace(Differencer.ComponentName, "CompareGraphs: cannot find value available provider. default is used."); + LogTrace("CompareGraphs: cannot find value available provider. default is used."); sourceValueProvider = DEFAULT_AVAILABLE_PROPERTY_VALUE_PROVIDER; } AvailablePropertyValueProvider targetValueProvider = FindAvailableValueProvider(targetAdapted); if (targetValueProvider == null) { - TraceHelper.Trace(Differencer.ComponentName, "CompareGraphs: cannot find value available provider. default is used."); + LogTrace("CompareGraphs: cannot find value available provider. default is used."); targetValueProvider = DEFAULT_AVAILABLE_PROPERTY_VALUE_PROVIDER; } PropertyComparerProvider propComparer = FindPropertyComparerProvider(sourceAdapted, targetAdapted); if (propComparer == null) { - TraceHelper.Trace(Differencer.ComponentName, "CompareGraphs: cannot find property comparer provider. default is used."); + LogTrace("CompareGraphs: cannot find property comparer provider. default is used."); propComparer = DEFAULT_PROP_COMPARER; } ContainerSortingProvider sortProvider = FindContainerSortingProvider(sourceAdapted, targetAdapted); if (sortProvider == null) { - TraceHelper.Trace(Differencer.ComponentName, "CompareGraphs: cannot find value sorting provider. default is used."); + LogTrace("CompareGraphs: cannot find value sorting provider. default is used."); sortProvider = DEFAULT_SORT_PROVIDER; } - TraceHelper.Trace(Differencer.ComponentName, "CompareGraphs: parameter verified."); - LateActivatedDiffgram result = new LateActivatedDiffgram(this, nameProvider, + LogTrace("CompareGraphs: parameter verified."); + LateActivatedDiffgram result = new LateActivatedDiffgram(this, nameProvider, sourceValueProvider, targetValueProvider, sortProvider, propComparer, emittedChangeType, sourceAdapted, targetAdapted); - TraceHelper.Trace(Differencer.ComponentName, "CompareGraphs: exiting public method."); + LogTrace("CompareGraphs: exiting public method."); return result; } @@ -186,31 +201,31 @@ protected void ProcessNodes(IDiffContext context, ISfcSimpleNode source, ISfcSim protected void CompareNodes(IDiffContext context, ISfcSimpleNode source, ISfcSimpleNode target) { - TraceHelper.Assert(source != null && target != null, "assert input nodes are not null"); - TraceHelper.Assert(source.Urn != null && target.Urn != null, "assert input nodes' Urns are not null"); - TraceHelper.Trace(Differencer.ComponentName, "CompareNodes: comparing two nodes {0} and {1}.", source.Urn, target.Urn); + Debug.Assert(source != null && target != null, "assert input nodes are not null"); + Debug.Assert(source.Urn != null && target.Urn != null, "assert input nodes' Urns are not null"); + LogTrace("CompareNodes: comparing two nodes {0} and {1}.", source.Urn, target.Urn); CompareProperties(context, source, target); // Compare each children list - TraceHelper.Trace(Differencer.ComponentName, "CompareNodes: looping all related containers (collection) of the node."); + LogTrace("CompareNodes: looping all related containers (collection) of the node."); foreach (string name in GetRelatedContainerNames(context.NodeItemNamesAdapterProvider, source)) { bool naturalOrder = GetNaturalOrder(context.NodeItemNamesAdapterProvider, source, name); CompareRelatedContainer(context, source.RelatedContainers[name], target.RelatedContainers[name], naturalOrder); } - TraceHelper.Trace(Differencer.ComponentName, "CompareNodes: looped all related containers (collection) of the node."); + LogTrace("CompareNodes: looped all related containers (collection) of the node."); // Compare each children singleton - TraceHelper.Trace(Differencer.ComponentName, "CompareNodes: looping all related object (singleton) of the node."); + LogTrace("CompareNodes: looping all related object (singleton) of the node."); foreach (string name in GetRelatedObjectNames(context.NodeItemNamesAdapterProvider, source)) { CompareRelatedObject(context, source.RelatedObjects[name], target.RelatedObjects[name]); } - TraceHelper.Trace(Differencer.ComponentName, "CompareNodes: looped all related object (singleton) of the node."); + LogTrace("CompareNodes: looped all related object (singleton) of the node."); - TraceHelper.Trace(Differencer.ComponentName, "CompareNodes: compared two nodes."); + LogTrace("CompareNodes: compared two nodes."); } protected void CompareRelatedContainer(IDiffContext context, ISfcSimpleList source, ISfcSimpleList target, bool naturalOrder) @@ -225,15 +240,16 @@ protected void CompareRelatedContainer(IDiffContext context, ISfcSimpleList sour // moved. Vice versa for the (-) case. // The implementation uses IEnumerator instead of arrays and cursors. - TraceHelper.Assert(source != null && target != null, "assert input is not null"); - TraceHelper.Trace(Differencer.ComponentName, "CompareRelatedContainer: comparing element in two container."); + Debug.Assert(source != null && target != null, "assert input is not null"); + LogTrace("CompareRelatedContainer: comparing element in two container."); IEnumerator leftEnum = null; IEnumerator rightEnum = null; - try { + try + { if (naturalOrder) { - TraceHelper.Trace(Differencer.ComponentName, "CompareRelatedContainer: use natural order (no sorting)."); + LogTrace("CompareRelatedContainer: use natural order (no sorting)."); leftEnum = source.GetEnumerator(); rightEnum = target.GetEnumerator(); } @@ -258,7 +274,7 @@ protected void CompareRelatedContainer(IDiffContext context, ISfcSimpleList sour if (hasSourceElement && hasTargetElement) { - TraceHelper.Trace(Differencer.ComponentName, "CompareRelatedContainer: use sorting."); + LogTrace("CompareRelatedContainer: use sorting."); IEnumerable leftList = null; IEnumerable rightList = null; GetSortedLists(context.ContainerSortingProvider, source, target, out leftList, @@ -289,7 +305,7 @@ protected void CompareRelatedContainer(IDiffContext context, ISfcSimpleList sour // nesting, to make it shorter and to increase readablity. // move cursor - TraceHelper.Trace(Differencer.ComponentName, "CompareRelatedContainer: move cursor."); + LogTrace("CompareRelatedContainer: move cursor."); if (left == null && leftEnum.MoveNext()) { left = leftEnum.Current; @@ -328,20 +344,20 @@ protected void CompareRelatedContainer(IDiffContext context, ISfcSimpleList sour // process each of the 4 cases if (comp < 0) // case: created { - TraceHelper.Trace(Differencer.ComponentName, "CompareRelatedContainer: could not find matched element on the other side (created case)."); + LogTrace("CompareRelatedContainer: could not find matched element on the other side (created case)."); EmitCreatedEntry(context, left); left = null; // clear the pointer so that we will move the cursor at the next round continue; // = exit = } else if (comp > 0) // case: deleted { - TraceHelper.Trace(Differencer.ComponentName, "CompareRelatedContainer: could not find matched element on the other side (deleted case)."); + LogTrace("CompareRelatedContainer: could not find matched element on the other side (deleted case)."); EmitDeletedEntry(context, right); right = null; // clear the pointer so that we will move the cursor at the next round continue; // = exit = } - TraceHelper.Trace(Differencer.ComponentName, "CompareRelatedContainer: found matched elements. push for later comparison (breadth first)"); + LogTrace("CompareRelatedContainer: found matched elements. push for later comparison (breadth first)"); // case: updated (or unchanged) --> Push to the stack context.Push(left, right); @@ -349,12 +365,12 @@ protected void CompareRelatedContainer(IDiffContext context, ISfcSimpleList sour right = null; } } - finally + finally { Dispose(leftEnum); Dispose(rightEnum); } - TraceHelper.Trace(Differencer.ComponentName, "CompareRelatedContainer: compared element in two containers."); + LogTrace("CompareRelatedContainer: compared element in two containers."); } protected void CompareRelatedObject(IDiffContext context, ISfcSimpleNode source, ISfcSimpleNode target) @@ -363,21 +379,21 @@ protected void CompareRelatedObject(IDiffContext context, ISfcSimpleNode source, { // no object to compare return; - } + } else if (target == null) { - TraceHelper.Trace(Differencer.ComponentName, "CompareRelatedObject: related object is null (create case)."); + LogTrace("CompareRelatedObject: related object is null (create case)."); EmitCreatedEntry(context, source); } else if (source == null) { - TraceHelper.Trace(Differencer.ComponentName, "CompareRelatedObject: related object is null (delete case)."); + LogTrace("CompareRelatedObject: related object is null (delete case)."); EmitDeletedEntry(context, target); } else { // need to look deeper to see if they are Equivalent or Updated - TraceHelper.Trace(Differencer.ComponentName, "CompareRelatedContainer: found matched elements. push for later comparison (breadth first)"); + LogTrace("CompareRelatedContainer: found matched elements. push for later comparison (breadth first)"); context.Push(source, target); } } @@ -387,7 +403,7 @@ protected void CompareProperties(IDiffContext context, ISfcSimpleNode source, IS // Assumption: to this diff service, Property lists are always a static list. It is defined // by the type of the graphs, and they're always fixed. New Property cannot be added or removed. // It is specified in the API that only structurally identical graphs can be compared. - TraceHelper.Trace(Differencer.ComponentName, "CompareGraphs: comparing properties of two nodes."); + LogTrace("CompareGraphs: comparing properties of two nodes."); IDictionary> pairedProps = null; foreach (string name in GetPropertyNames(context.NodeItemNamesAdapterProvider, source)) @@ -424,7 +440,7 @@ protected void CompareProperties(IDiffContext context, ISfcSimpleNode source, IS EmitEquivalentEntry(context, source, target); } - TraceHelper.Trace(Differencer.ComponentName, "CompareGraphs: compared properties of two nodes."); + LogTrace("CompareGraphs: compared properties of two nodes."); } protected int CompareIdentities(ISfcSimpleNode left, ISfcSimpleNode right, IComparer comparer) @@ -539,8 +555,8 @@ private static void Dispose(IDisposable disposable) { // otherwise simple log and return - TraceHelper.LogExCatch(e); - TraceHelper.Trace(Differencer.ComponentName, "Exception occurs in cleanup: {0}.", e); + SmoEventSource.Log.DifferencingException(e); + LogTrace($"Exception occurs in cleanup: {e}"); } } @@ -548,23 +564,23 @@ private static void Dispose(IDisposable disposable) #region Provider protected ISfcSimpleNode AdaptNode(SfcNodeAdapterProvider provider, Object node) { - TraceHelper.Trace(Differencer.ComponentName, "AdaptNode: obtaining adapter for node {0}.", node); + LogTrace("AdaptNode: obtaining adapter for node {0}.", node); try { ISfcSimpleNode result = provider.GetGraphAdapter(node); - TraceHelper.Trace(Differencer.ComponentName, "AdaptNode: obtained adapter for node {0}.", node); + LogTrace("AdaptNode: obtained adapter for node {0}.", node); return result; } catch (ArgumentException ae) { - TraceHelper.LogExCatch(ae); - TraceHelper.Trace(Differencer.ComponentName, "AdaptNode: exception occurred {0}.", ae); + SmoEventSource.Log.DifferencingException(ae); + LogTrace("AdaptNode: exception occurred {0}.", ae); throw new ArgumentException("node", ae); } catch (Exception e) when (!IsSystemGeneratedException(e)) { - TraceHelper.LogExCatch(e); - TraceHelper.Trace(Differencer.ComponentName, "AdaptNode: exception occurred {0}.", e); + SmoEventSource.Log.DifferencingException(e); + LogTrace("AdaptNode: exception occurred {0}.", e); String msg = StringDifferencing.FailedProviderLookup(provider.ToString(), node.ToString()); throw new InvalidOperationException(msg, e); } @@ -574,22 +590,23 @@ protected IEnumerable GetRelatedContainerNames(NodeItemNamesAdapterProvi { // It calls to provider code that is outside of our control. Should handle exception in // every calls to provider. - TraceHelper.Trace(Differencer.ComponentName, "GetRelatedContainerNames: obtaining container (meta) names provider {0}.", node); - try { + LogTrace("GetRelatedContainerNames: obtaining container (meta) names provider {0}.", node); + try + { IEnumerable result = provider.GetRelatedContainerNames(node); - TraceHelper.Trace(Differencer.ComponentName, "GetRelatedContainerNames: obtained container (meta) names provider {0}.", node); + LogTrace("GetRelatedContainerNames: obtained container (meta) names provider {0}.", node); return result; } catch (ArgumentException ae) { - TraceHelper.LogExCatch(ae); - TraceHelper.Trace(Differencer.ComponentName, "GetRelatedContainerNames: exception occurred {0}.", ae); + SmoEventSource.Log.DifferencingException(ae); + LogTrace("GetRelatedContainerNames: exception occurred {0}.", ae); throw new ArgumentException("node", ae); } catch (Exception e) when (!IsSystemGeneratedException(e)) { - TraceHelper.LogExCatch(e); - TraceHelper.Trace(Differencer.ComponentName, "GetRelatedContainerNames: exception occurred {0}.", e); + SmoEventSource.Log.DifferencingException(e); + LogTrace("GetRelatedContainerNames: exception occurred {0}.", e); String msg = StringDifferencing.FailedProviderOperation(provider.ToString(), node.ToString()); throw new InvalidOperationException(msg, e); } @@ -599,23 +616,23 @@ protected bool GetNaturalOrder(NodeItemNamesAdapterProvider provider, ISfcSimple { // It calls to provider code that is outside of our control. Should handle exception in // every calls to provider. - TraceHelper.Trace(Differencer.ComponentName, "GetNaturalOrder: determining if it is natural order {0}.", node); + LogTrace("GetNaturalOrder: determining if it is natural order {0}.", node); try { bool result = provider.IsContainerInNatrualOrder(node, name); - TraceHelper.Trace(Differencer.ComponentName, "GetNaturalOrder: determined {0}.", result); + LogTrace("GetNaturalOrder: determined {0}.", result); return result; } catch (ArgumentException ae) { - TraceHelper.LogExCatch(ae); - TraceHelper.Trace(Differencer.ComponentName, "GetNaturalOrder: exception occurred {0}.", ae); + SmoEventSource.Log.DifferencingException(ae); + LogTrace("GetNaturalOrder: exception occurred {0}.", ae); throw new ArgumentException("node", ae); } catch (Exception e) when (!IsSystemGeneratedException(e)) { - TraceHelper.LogExCatch(e); - TraceHelper.Trace(Differencer.ComponentName, "GetNaturalOrder: exception occurred {0}.", e); + SmoEventSource.Log.DifferencingException(e); + LogTrace("GetNaturalOrder: exception occurred {0}.", e); String msg = StringDifferencing.FailedProviderOperation(provider.ToString(), node.ToString()); throw new InvalidOperationException(msg, e); } @@ -625,34 +642,34 @@ protected bool GetIsValueAvailable(AvailablePropertyValueProvider provider, ISfc { // It calls to provider code that is outside of our control. Should handle exception in // every calls to provider. - TraceHelper.Trace(Differencer.ComponentName, "GetIsValueAvailable: determining if it property is available {0}.", node); + LogTrace("GetIsValueAvailable: determining if it property is available {0}.", node); try { bool result = provider.IsValueAvailable(node, name); - TraceHelper.Trace(Differencer.ComponentName, "GetIsValueAvailable: determined {0}.", result); + LogTrace("GetIsValueAvailable: determined {0}.", result); return result; } catch (ArgumentException ae) { - TraceHelper.LogExCatch(ae); - TraceHelper.Trace(Differencer.ComponentName, "GetIsValueAvailable: exception occurred {0}.", ae); + SmoEventSource.Log.DifferencingException(ae); + LogTrace("GetIsValueAvailable: exception occurred {0}.", ae); throw new ArgumentException("node", ae); } catch (Exception e) when (!IsSystemGeneratedException(e)) { - TraceHelper.LogExCatch(e); - TraceHelper.Trace(Differencer.ComponentName, "GetIsValueAvailable: exception occurred {0}.", e); + SmoEventSource.Log.DifferencingException(e); + LogTrace("GetIsValueAvailable: exception occurred {0}.", e); String msg = StringDifferencing.FailedProviderOperation(provider.ToString(), node.ToString()); throw new InvalidOperationException(msg, e); } } - protected void GetSortedLists(ContainerSortingProvider provider, ISfcSimpleList source, ISfcSimpleList target, + protected void GetSortedLists(ContainerSortingProvider provider, ISfcSimpleList source, ISfcSimpleList target, out IEnumerable sortedSource, out IEnumerable sortedTarget) { // It calls to provider code that is outside of our control. Should handle exception in // every calls to provider. - TraceHelper.Trace(Differencer.ComponentName, "GetSortedLists: obtaining sorted lists {0} and {1}.", source, target); + LogTrace("GetSortedLists: obtaining sorted lists {0} and {1}.", source, target); try { IEnumerable sourceResult = null; @@ -663,18 +680,18 @@ protected void GetSortedLists(ContainerSortingProvider provider, ISfcSimpleList // delay the change-of-state unless we know we don't get an exception sortedSource = sourceResult; sortedTarget = targetResult; - TraceHelper.Trace(Differencer.ComponentName, "GetSortedLists: obtained sorted lists {0}.", source); + LogTrace("GetSortedLists: obtained sorted lists {0}.", source); } catch (ArgumentException ae) { - TraceHelper.LogExCatch(ae); - TraceHelper.Trace(Differencer.ComponentName, "GetSortedList: exception occurred {0}.", ae); + SmoEventSource.Log.DifferencingException(ae); + LogTrace("GetSortedList: exception occurred {0}.", ae); throw new ArgumentException("list", ae); } catch (Exception e) when (!IsSystemGeneratedException(e)) { - TraceHelper.LogExCatch(e); - TraceHelper.Trace(Differencer.ComponentName, "GetSortedList: exception occurred {0}.", e); + SmoEventSource.Log.DifferencingException(e); + LogTrace("GetSortedList: exception occurred {0}.", e); String msg = StringDifferencing.FailedProviderOperation(provider.ToString(), source.ToString()); throw new InvalidOperationException(msg, e); } @@ -684,23 +701,23 @@ protected IComparer GetComparer(ContainerSortingProvider provide { // It calls to provider code that is outside of our control. Should handle exception in // every calls to provider. - TraceHelper.Trace(Differencer.ComponentName, "GetComparer: obtaining comparer {0}.", list); + LogTrace("GetComparer: obtaining comparer {0}.", list); try { IComparer result = provider.GetComparer(list, list2); - TraceHelper.Trace(Differencer.ComponentName, "GetComparer: obtained comparer {0}.", list); + LogTrace("GetComparer: obtained comparer {0}.", list); return result; } catch (ArgumentException ae) { - TraceHelper.LogExCatch(ae); - TraceHelper.Trace(Differencer.ComponentName, "GetComparer: exception occurred {0}.", ae); + SmoEventSource.Log.DifferencingException(ae); + LogTrace("GetComparer: exception occurred {0}.", ae); throw new ArgumentException("list", ae); } catch (Exception e) when (!IsSystemGeneratedException(e)) { - TraceHelper.LogExCatch(e); - TraceHelper.Trace(Differencer.ComponentName, "GetComparer: exception occurred {0}.", e); + SmoEventSource.Log.DifferencingException(e); + LogTrace("GetComparer: exception occurred {0}.", e); String msg = StringDifferencing.FailedProviderOperation(provider.ToString(), list.ToString()); throw new InvalidOperationException(msg, e); } @@ -708,23 +725,23 @@ protected IComparer GetComparer(ContainerSortingProvider provide protected IEnumerable GetRelatedObjectNames(NodeItemNamesAdapterProvider provider, ISfcSimpleNode node) { - TraceHelper.Trace(Differencer.ComponentName, "GetRelatedObjectNames: obtaining related object name for node {0}.", node); - try + LogTrace("GetRelatedObjectNames: obtaining related object name for node {0}.", node); + try { IEnumerable result = provider.GetRelatedObjectNames(node); - TraceHelper.Trace(Differencer.ComponentName, "GetRelatedObjectNames: obtained related object name for node."); + LogTrace("GetRelatedObjectNames: obtained related object name for node."); return result; } catch (ArgumentException ae) { - TraceHelper.LogExCatch(ae); - TraceHelper.Trace(Differencer.ComponentName, "GetRelatedObjectNames: exception occurred {0}.", ae); + SmoEventSource.Log.DifferencingException(ae); + LogTrace("GetRelatedObjectNames: exception occurred {0}.", ae); throw new ArgumentException("node", ae); } catch (Exception e) when (!IsSystemGeneratedException(e)) { - TraceHelper.LogExCatch(e); - TraceHelper.Trace(Differencer.ComponentName, "GetRelatedObjectNames: exception occurred {0}.", e); + SmoEventSource.Log.DifferencingException(e); + LogTrace("GetRelatedObjectNames: exception occurred {0}.", e); String msg = StringDifferencing.FailedProviderOperation(provider.ToString(), node.ToString()); throw new InvalidOperationException(msg, e); } @@ -732,23 +749,23 @@ protected IEnumerable GetRelatedObjectNames(NodeItemNamesAdapterProvider protected IEnumerable GetPropertyNames(NodeItemNamesAdapterProvider provider, ISfcSimpleNode node) { - TraceHelper.Trace(Differencer.ComponentName, "GetPropertyNames: obtaining prop names for node {0}.", node); + LogTrace("GetPropertyNames: obtaining prop names for node {0}.", node); try { IEnumerable result = provider.GetPropertyNames(node); - TraceHelper.Trace(Differencer.ComponentName, "GetPropertyNames: obtained prop names for node."); + LogTrace("GetPropertyNames: obtained prop names for node."); return result; } catch (ArgumentException ae) { - TraceHelper.LogExCatch(ae); - TraceHelper.Trace(Differencer.ComponentName, "GetPropertyNames: exception occurred {0}.", ae); + SmoEventSource.Log.DifferencingException(ae); + LogTrace("GetPropertyNames: exception occurred {0}.", ae); throw new ArgumentException("node", ae); } catch (Exception e) when (!IsSystemGeneratedException(e)) { - TraceHelper.LogExCatch(e); - TraceHelper.Trace(Differencer.ComponentName, "GetPropertyNames: exception occurred {0}.", e); + SmoEventSource.Log.DifferencingException(e); + LogTrace("GetPropertyNames: exception occurred {0}.", e); String msg = StringDifferencing.FailedProviderOperation(provider.ToString(), node.ToString()); throw new InvalidOperationException(msg, e); } @@ -756,126 +773,126 @@ protected IEnumerable GetPropertyNames(NodeItemNamesAdapterProvider prov protected SfcNodeAdapterProvider FindNodeAdapterProvider(Object node) { - TraceHelper.Trace(Differencer.ComponentName, "AdaptNode: finding adapter for node {0}.", node); + LogTrace("AdaptNode: finding adapter for node {0}.", node); foreach (SfcNodeAdapterProvider provider in registry.SfcNodeAdapterProviders) { try { if (provider.IsGraphSupported(node)) { - TraceHelper.Trace(Differencer.ComponentName, "AdaptNode: found adapter for node."); + LogTrace("AdaptNode: found adapter for node."); return provider; } } catch (Exception e) when (!IsSystemGeneratedException(e)) { - TraceHelper.LogExCatch(e); - TraceHelper.Trace(Differencer.ComponentName, "AdaptNode: exception occurred {0}.", e); + SmoEventSource.Log.DifferencingException(e); + LogTrace("AdaptNode: exception occurred {0}.", e); String msg = StringDifferencing.FailedProviderLookup(provider.ToString(), node.ToString()); throw new InvalidOperationException(msg, e); } } - TraceHelper.Trace(Differencer.ComponentName, "AdaptNode: not found"); + LogTrace("AdaptNode: not found"); return null; } protected NodeItemNamesAdapterProvider FindNameProvider(ISfcSimpleNode node) { - TraceHelper.Trace(Differencer.ComponentName, "FindNameProvider: finding name provider for node {0}.", node); + LogTrace("FindNameProvider: finding name provider for node {0}.", node); foreach (NodeItemNamesAdapterProvider provider in registry.NodeItemNameAdapterProviders) { try { if (provider.IsGraphSupported(node)) { - TraceHelper.Trace(Differencer.ComponentName, "FindNameProvider: found name provider for node."); + LogTrace("FindNameProvider: found name provider for node."); return provider; } } catch (Exception e) when (!IsSystemGeneratedException(e)) { - TraceHelper.LogExCatch(e); - TraceHelper.Trace(Differencer.ComponentName, "FindNameProvider: exception occurred {0}.", e); + SmoEventSource.Log.DifferencingException(e); + LogTrace("FindNameProvider: exception occurred {0}.", e); String msg = StringDifferencing.FailedProviderLookup(provider.ToString(), node.ToString()); throw new InvalidOperationException(msg, e); } } - TraceHelper.Trace(Differencer.ComponentName, "FindNameProvider: not found"); + LogTrace("FindNameProvider: not found"); return null; } protected AvailablePropertyValueProvider FindAvailableValueProvider(ISfcSimpleNode node) { - TraceHelper.Trace(Differencer.ComponentName, "FindAvailableValueProvider: finding provider for node {0}.", node); + LogTrace("FindAvailableValueProvider: finding provider for node {0}.", node); foreach (AvailablePropertyValueProvider provider in registry.AvailablePropertyValueProviders) { try { if (provider.IsGraphSupported(node)) { - TraceHelper.Trace(Differencer.ComponentName, "FindAvailableValueProvider: found provider for node."); + LogTrace("FindAvailableValueProvider: found provider for node."); return provider; } } catch (Exception e) when (!IsSystemGeneratedException(e)) { - TraceHelper.LogExCatch(e); - TraceHelper.Trace(Differencer.ComponentName, "FindAvailableValueProvider: exception occurred {0}.", e); + SmoEventSource.Log.DifferencingException(e); + LogTrace("FindAvailableValueProvider: exception occurred {0}.", e); String msg = StringDifferencing.FailedProviderLookup(provider.ToString(), node.ToString()); throw new InvalidOperationException(msg, e); } } - TraceHelper.Trace(Differencer.ComponentName, "FindAvailableValueProvider: not found"); + LogTrace("FindAvailableValueProvider: not found"); return null; } protected ContainerSortingProvider FindContainerSortingProvider(ISfcSimpleNode source, ISfcSimpleNode target) { - TraceHelper.Trace(Differencer.ComponentName, "FindContainerSortingProvider: finding provider for node {0} and {1}.", source, target); + LogTrace("FindContainerSortingProvider: finding provider for node {0} and {1}.", source, target); foreach (ContainerSortingProvider provider in registry.ContainerSortingProviders) { try { if (provider.AreGraphsSupported(source, target)) { - TraceHelper.Trace(Differencer.ComponentName, "FindContainerSortingProvider: found provider for node {0} and {1}.", source, target); + LogTrace("FindContainerSortingProvider: found provider for node {0} and {1}.", source, target); return provider; } } catch (Exception e) when (!IsSystemGeneratedException(e)) { - TraceHelper.LogExCatch(e); - TraceHelper.Trace(Differencer.ComponentName, "FindContainerSortingProvider: exception occurred {0}.", e); + SmoEventSource.Log.DifferencingException(e); + LogTrace("FindContainerSortingProvider: exception occurred {0}.", e); String msg = StringDifferencing.FailedProviderLookup(provider.ToString(), source.ToString()); throw new InvalidOperationException(msg, e); } } - TraceHelper.Trace(Differencer.ComponentName, "FindContainerSortingProvider: not found"); + LogTrace("FindContainerSortingProvider: not found"); return null; } protected PropertyComparerProvider FindPropertyComparerProvider(ISfcSimpleNode source, ISfcSimpleNode target) { - TraceHelper.Trace(Differencer.ComponentName, "FindPropertyComparerProvider: finding provider for node {0} and {1}.", source, target); + LogTrace("FindPropertyComparerProvider: finding provider for node {0} and {1}.", source, target); foreach (PropertyComparerProvider provider in registry.PropertyComparerProviders) { try { if (provider.AreGraphsSupported(source, target)) { - TraceHelper.Trace(Differencer.ComponentName, "FindPropertyComparerProvider: found provider for node {0} and {1}.", source, target); + LogTrace("FindPropertyComparerProvider: found provider for node {0} and {1}.", source, target); return provider; } } catch (Exception e) when (!IsSystemGeneratedException(e)) { - TraceHelper.LogExCatch(e); - TraceHelper.Trace(Differencer.ComponentName, "FindPropertyComparerProvider: exception occurred {0}.", e); + SmoEventSource.Log.DifferencingException(e); + LogTrace("FindPropertyComparerProvider: exception occurred {0}.", e); String msg = StringDifferencing.FailedProviderLookup(provider.ToString(), source.ToString()); throw new InvalidOperationException(msg, e); } } - TraceHelper.Trace(Differencer.ComponentName, "FindPropertyComparerProvider: not found"); + LogTrace("FindPropertyComparerProvider: not found"); return null; } @@ -948,7 +965,7 @@ protected class LateActivatedDiffgram : Diffgram, IDiffgram private AvailablePropertyValueProvider sourceValueProvider; private AvailablePropertyValueProvider targetValueProvider; - + private ContainerSortingProvider sortProvider; private PropertyComparerProvider propComparer; @@ -957,10 +974,10 @@ protected class LateActivatedDiffgram : Diffgram, IDiffgram private ISfcSimpleNode target; - public LateActivatedDiffgram(Differencer differencer, + public LateActivatedDiffgram(Differencer differencer, NodeItemNamesAdapterProvider nameProvider, - AvailablePropertyValueProvider sourceValueProvider, - AvailablePropertyValueProvider targetValueProvider, + AvailablePropertyValueProvider sourceValueProvider, + AvailablePropertyValueProvider targetValueProvider, ContainerSortingProvider sortProvider, PropertyComparerProvider propComparer, DiffType emitDiffTypes, @@ -977,7 +994,7 @@ public LateActivatedDiffgram(Differencer differencer, this.source = source; this.target = target; - TraceHelper.Trace(Differencer.ComponentName, "Diffgram: created late-activated diffgram."); + LogTrace("Diffgram: created late-activated diffgram."); } public Differencer Differencer @@ -1059,10 +1076,10 @@ public ISfcSimpleNode TargetSimpleNode public override IEnumerator GetEnumerator() { - TraceHelper.Trace(Differencer.ComponentName, "Diffgram: entering GetEnumerator"); + LogTrace("Diffgram: entering GetEnumerator"); LateActivatedDiffEntryEnumerator e = new LateActivatedDiffEntryEnumerator(this); e.Push(SourceSimpleNode, TargetSimpleNode); - TraceHelper.Trace(Differencer.ComponentName, "Diffgram: exiting GetEnumerator"); + LogTrace("Diffgram: exiting GetEnumerator"); return e; } } @@ -1128,7 +1145,7 @@ public AvailablePropertyValueProvider TargetAvailablePropertyValueProvider return envelope.TargetAvailablePropertyValueProvider; } } - + public ContainerSortingProvider ContainerSortingProvider { get @@ -1157,20 +1174,20 @@ public bool IsTypeEmitted(DiffType type) /// public void Push(ISfcSimpleNode source, ISfcSimpleNode target) { - TraceHelper.Assert(source != null && target != null, "assert added node is not null"); - TraceHelper.Assert(source.Urn != null && target.Urn != null, "assert added node's urn is not null"); - TraceHelper.Trace(Differencer.ComponentName, "DiffEntryEnumerator: pushing a pair {0} and {1} for later comparison.", source.Urn, target.Urn); + Debug.Assert(source != null && target != null, "assert added node is not null"); + Debug.Assert(source.Urn != null && target.Urn != null, "assert added node's urn is not null"); + LogTrace("DiffEntryEnumerator: pushing a pair {0} and {1} for later comparison.", source.Urn, target.Urn); Pair newPair = new Pair(source, target); stack.Push(newPair); - TraceHelper.Trace(Differencer.ComponentName, "DiffEntryEnumerator: pushed."); + LogTrace("DiffEntryEnumerator: pushed."); } public void Add(IDiffEntry entry) { - TraceHelper.Assert(entry != null, "assert enqueueing entry is not null"); - TraceHelper.Trace(Differencer.ComponentName, "DiffEntryEnumerator: enqueueing result {0}.", entry); + Debug.Assert(entry != null, "assert enqueueing entry is not null"); + LogTrace("DiffEntryEnumerator: enqueueing result {0}.", entry); result.Enqueue(entry); - TraceHelper.Trace(Differencer.ComponentName, "DiffEntryEnumerator: enqueued result."); + LogTrace("DiffEntryEnumerator: enqueued result."); } public IDiffEntry Current { @@ -1204,20 +1221,20 @@ object IEnumerator.Current /// public bool MoveNext() { - TraceHelper.Trace(Differencer.ComponentName, "DiffEntryEnumerator: entering MoveNext."); + LogTrace("DiffEntryEnumerator: entering MoveNext."); current = null; while (true) { if (result.Count > 0) { current = result.Dequeue(); - TraceHelper.Trace(Differencer.ComponentName, "DiffEntryEnumerator: exiting MoveNext (returning true)."); + LogTrace("DiffEntryEnumerator: exiting MoveNext (returning true)."); return true; } if (stack.Count <= 0) { // if stack is empty, we reach the end - TraceHelper.Trace(Differencer.ComponentName, "DiffEntryEnumerator: exiting MoveNext (no more to compare. returning false.)."); + LogTrace("DiffEntryEnumerator: exiting MoveNext (no more to compare. returning false.)."); return false; } Pair pair = stack.Pop(); diff --git a/src/Microsoft/SqlServer/Management/Sdk/Sfc/Enumerator/SqlObjectBase.cs b/src/Microsoft/SqlServer/Management/Sdk/Sfc/Enumerator/SqlObjectBase.cs index 9c10892f..d9e0f9d3 100644 --- a/src/Microsoft/SqlServer/Management/Sdk/Sfc/Enumerator/SqlObjectBase.cs +++ b/src/Microsoft/SqlServer/Management/Sdk/Sfc/Enumerator/SqlObjectBase.cs @@ -15,6 +15,7 @@ namespace Microsoft.SqlServer.Management.Sdk.Sfc using System.Collections.Specialized; using Microsoft.SqlServer.Management.Common; using System.Runtime.InteropServices; + using System.Diagnostics; /// /// main work horse for the sql enumerator. it generates the tsql for a level and @@ -723,12 +724,9 @@ internal EnumResult BuildResult(EnumResult result) // PostProcessCreateSqlSecureString can be done directly continue; } - else if ((postProcess.Value is PostProcessBodyText) && - ((ServerConnection)this.ConnectionInfo).ServerVersion.Major >= 9) + else if (postProcess.Value is PostProcessBodyText) { - // PostProcessBodyText can be done directly only on 9.0 - // on 8.0 we need to execute additional queries and paste - // the syscomments fields + // PostProcessBodyText can be done directly continue; } else @@ -743,8 +741,7 @@ internal EnumResult BuildResult(EnumResult result) { if (resultType == ResultType.IDataReader) { - TraceHelper.Trace("w", SQLToolsCommonTraceLvl.Always, - "IDataReader will be returned from a DataTable because post processing is needed"); + SmoEventSource.Log.SfcTrace("SqlObjectBase", "IDataReader will be returned from a DataTable because post processing is needed"); } resultType = ResultType.DataTable; @@ -792,7 +789,7 @@ protected virtual Object FillData(ResultType resultType, StringCollection sql, O } else { - TraceHelper.Assert( resultType == ResultType.DataTable || resultType == ResultType.DataSet ); + Debug.Assert( resultType == ResultType.DataTable || resultType == ResultType.DataSet ); DataTable dt = ExecuteSql.ExecuteWithResults(sql, connectionInfo, sb); if( resultType == ResultType.DataTable ) { diff --git a/src/Microsoft/SqlServer/Management/Sdk/Sfc/Enumerator/Util.cs b/src/Microsoft/SqlServer/Management/Sdk/Sfc/Enumerator/Util.cs index 3f1f67e2..901067ce 100644 --- a/src/Microsoft/SqlServer/Management/Sdk/Sfc/Enumerator/Util.cs +++ b/src/Microsoft/SqlServer/Management/Sdk/Sfc/Enumerator/Util.cs @@ -6,6 +6,7 @@ namespace Microsoft.SqlServer.Management.Sdk.Sfc using System; using System.Collections.Specialized; using System.Data; + using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Text; @@ -120,7 +121,7 @@ protected EnumResult TransformToRequest(DataSet ds, ResultType res) } else { - TraceHelper.Assert( ResultType.DataTable == res ); + Debug.Assert( ResultType.DataTable == res ); return new EnumResult(ds.Tables[0], res); } } @@ -294,7 +295,7 @@ internal static string EscapeLikePattern(string pattern) } // if we are going to escape this character, then sb should not be null - TraceHelper.Assert(!escape || sb != null); + Debug.Assert(!escape || sb != null); if (escape) diff --git a/src/Microsoft/SqlServer/Management/Sdk/Sfc/Enumerator/XmlRead.cs b/src/Microsoft/SqlServer/Management/Sdk/Sfc/Enumerator/XmlRead.cs index 1ba034ed..6fb50252 100644 --- a/src/Microsoft/SqlServer/Management/Sdk/Sfc/Enumerator/XmlRead.cs +++ b/src/Microsoft/SqlServer/Management/Sdk/Sfc/Enumerator/XmlRead.cs @@ -477,19 +477,8 @@ public void LoadFile(Assembly a, String strFile) if (minMajor > this.Version.Major || maxMajor < this.Version.Major) { - switch (this.Version.Major) - { - case 9: - throw new InvalidVersionEnumeratorException( - SfcStrings.InvalidSqlServer(SfcStrings.SqlServer90Name)); - case 8: - throw new InvalidVersionEnumeratorException( - SfcStrings.InvalidSqlServer(SfcStrings.SqlServer80Name)); - //version 7.0 or earlier is not supported, therefore verion number is used. - default: - throw new InvalidVersionEnumeratorException( - SfcStrings.InvalidVersion(this.Version.ToString())); - } + throw new InvalidVersionEnumeratorException( + SfcStrings.InvalidVersion(this.Version.ToString())); } } diff --git a/src/Microsoft/SqlServer/Management/Sdk/Sfc/Enumerator/enumerator.cs b/src/Microsoft/SqlServer/Management/Sdk/Sfc/Enumerator/enumerator.cs index 2c7cf499..bc37f246 100644 --- a/src/Microsoft/SqlServer/Management/Sdk/Sfc/Enumerator/enumerator.cs +++ b/src/Microsoft/SqlServer/Management/Sdk/Sfc/Enumerator/enumerator.cs @@ -22,19 +22,20 @@ public class Enumerator /// /// enumerator common trace function /// - [Conditional("DEBUG")] static public void TraceInfo(string trace) { - TraceHelper.Trace("w", SQLToolsCommonTraceLvl.L1, "{0}", trace); + SmoEventSource.Log.SfcTrace("Enumerator", trace); } /// /// enumerator common trace function /// - [Conditional("DEBUG")] static public void TraceInfo(string strFormat, params Object[] arg) { - TraceHelper.Trace("w", SQLToolsCommonTraceLvl.L1, strFormat, arg); + if (SmoEventSource.Log.IsEnabled(System.Diagnostics.Tracing.EventLevel.Verbose, SmoEventSource.Keywords.Sfc)) + { + SmoEventSource.Log.SfcTrace("Enumerator", string.Format(strFormat, arg)); + } } /// diff --git a/src/Microsoft/SqlServer/Management/Sdk/Sfc/Enumerator/xml/Config.xml b/src/Microsoft/SqlServer/Management/Sdk/Sfc/Enumerator/xml/Config.xml index b1eba786..49b279d1 100644 --- a/src/Microsoft/SqlServer/Management/Sdk/Sfc/Enumerator/xml/Config.xml +++ b/src/Microsoft/SqlServer/Management/Sdk/Sfc/Enumerator/xml/Config.xml @@ -482,7 +482,11 @@ - + + + + + diff --git a/src/Microsoft/SqlServer/Management/Sdk/Sfc/LocalizableTypeConverter.cs b/src/Microsoft/SqlServer/Management/Sdk/Sfc/LocalizableTypeConverter.cs index 8693b7cb..bf9418f8 100644 --- a/src/Microsoft/SqlServer/Management/Sdk/Sfc/LocalizableTypeConverter.cs +++ b/src/Microsoft/SqlServer/Management/Sdk/Sfc/LocalizableTypeConverter.cs @@ -5,9 +5,11 @@ using System.Collections; using System.Collections.Generic; using System.ComponentModel; +using System.Diagnostics; using System.Linq; using System.Reflection; using System.Resources; +using Microsoft.SqlServer.Management.Common; // !!!! IMPORTANT !!!! // @@ -84,8 +86,8 @@ public LocalizedPropertyResourcesAttribute(string resourcesName) throw new ArgumentNullException("resourcesName"); } - TraceHelper.Assert(resourcesName != null, "unexpected null resourcesName parameter"); - TraceHelper.Assert(0 < resourcesName.Length, "unexpected empty resourcesName"); + Debug.Assert(resourcesName != null, "unexpected null resourcesName parameter"); + Debug.Assert(0 < resourcesName.Length, "unexpected empty resourcesName"); this.resourcesName = resourcesName; this.useDefaultKeys = false; @@ -98,8 +100,8 @@ public LocalizedPropertyResourcesAttribute(string resourcesName) /// public LocalizedPropertyResourcesAttribute(string resourcesName, bool useDefaultKeys) { - TraceHelper.Assert(resourcesName != null, "unexpected null resourcesName parameter"); - TraceHelper.Assert(0 < resourcesName.Length, "unexpected empty resourcesName"); + Debug.Assert(resourcesName != null, "unexpected null resourcesName parameter"); + Debug.Assert(0 < resourcesName.Length, "unexpected empty resourcesName"); this.resourcesName = resourcesName; this.useDefaultKeys = useDefaultKeys; } @@ -114,7 +116,7 @@ public LocalizedPropertyResourcesAttribute(Type resourceType) throw new ArgumentNullException("resourceType"); } - TraceHelper.Assert(resourceType != null, "unexpected null resourceType parameter"); + Debug.Assert(resourceType != null, "unexpected null resourceType parameter"); this.resourcesName = resourceType.FullName; } } @@ -158,7 +160,7 @@ static private IDisplayKey GetDisplayKey(Type keyAttribute) } else { - TraceHelper.Assert(false, "keyAttribute " + keyAttribute.Name + " is of unknown type"); + Debug.Assert(false, "keyAttribute " + keyAttribute.Name + " is of unknown type"); } return key; @@ -382,8 +384,8 @@ public string GetDefaultKey(FieldInfo field) /// The key used to look up the localized property category public DisplayCategoryKeyAttribute(string key) { - TraceHelper.Assert(key != null, "unexpected null key parameter"); - TraceHelper.Assert(0 < key.Length, "unexpected empty key"); + Debug.Assert(key != null, "unexpected null key parameter"); + Debug.Assert(0 < key.Length, "unexpected empty key"); this.key = key; } @@ -452,8 +454,8 @@ public string GetDefaultKey(FieldInfo field) /// The key used to look up the localized property name public DisplayNameKeyAttribute(string key) { - TraceHelper.Assert(key != null, "unexpected null key parameter"); - TraceHelper.Assert(0 < key.Length, "unexpected empty key"); + Debug.Assert(key != null, "unexpected null key parameter"); + Debug.Assert(0 < key.Length, "unexpected empty key"); this.key = key; } @@ -518,8 +520,8 @@ public string GetDefaultKey(FieldInfo field) /// The key used to look up the localized property description public DisplayDescriptionKeyAttribute(string key) { - TraceHelper.Assert(key != null, "unexpected null key parameter"); - TraceHelper.Assert(0 < key.Length, "unexpected empty key"); + Debug.Assert(key != null, "unexpected null key parameter"); + Debug.Assert(0 < key.Length, "unexpected empty key"); this.key = key; } @@ -709,8 +711,8 @@ public class LocalizablePropertyDescriptor : PropertyDescriptor public LocalizablePropertyDescriptor(PropertyInfo property, ResourceManager resourceManager, bool isDefaultResourceManager) : base(property.Name, null) { - TraceHelper.Assert(property != null, "unexpected null property object"); - TraceHelper.Assert(resourceManager != null, "resourceManager is null, is the resource string name correct?"); + Debug.Assert(property != null, "unexpected null property object"); + Debug.Assert(resourceManager != null, "resourceManager is null, is the resource string name correct?"); // throw exceptions for null parameters if (property == null) @@ -1153,8 +1155,8 @@ public class LocalizableMemberDescriptor : MemberDescriptor public LocalizableMemberDescriptor(Type type, ResourceManager resourceManager, bool isDefaultResourceManager) : base(type.Name, null) { - TraceHelper.Assert(type != null, "unexpected null type object"); - TraceHelper.Assert(resourceManager != null, "resourceManager is null, is the resource string name correct?"); + Debug.Assert(type != null, "unexpected null type object"); + Debug.Assert(resourceManager != null, "resourceManager is null, is the resource string name correct?"); // throw exceptions for null parameters if (type == null) @@ -1377,7 +1379,7 @@ private PropertyDescriptorCollection GetPropertiesFromObject(ITypeDescriptorCont private PropertyDescriptorCollection GetPropertiesFromType(Type valueType) { - TraceHelper.Assert(valueType != null, "unexpected null value"); + Debug.Assert(valueType != null, "unexpected null value"); if (valueType == null) { @@ -1500,7 +1502,7 @@ public override bool GetPropertiesSupported(ITypeDescriptorContext context) /// public LocalizableMemberDescriptor GetTypeMemberDescriptor(Type type) { - TraceHelper.Assert(type != null, "unexpected null value"); + Debug.Assert(type != null, "unexpected null value"); if (type == null) { throw new ArgumentNullException("value"); @@ -1563,8 +1565,8 @@ private void LoadLocalizedNames(Type type, ResourceManager manager) /// The resource manager used to load localized field names private void LoadLocalizedFieldNames(Type type, ResourceManager manager) { - TraceHelper.Assert(type.IsEnum(), "type is not an Enum"); - TraceHelper.Assert(manager != null, "manager is null"); + Debug.Assert(type.IsEnum(), "type is not an Enum"); + Debug.Assert(manager != null, "manager is null"); // we get the FieldInfo for each field and then pull off the DisplayNameKey if it has one // and then use that to get the localized value @@ -1606,7 +1608,7 @@ private void LoadLocalizedFieldNames(Type type, ResourceManager manager) /// The .NET Type for the enum private void LoadUnlocalizedFieldNames(Type type) { - TraceHelper.Assert(type.IsEnum(), "type is not an Enum"); + Debug.Assert(type.IsEnum(), "type is not an Enum"); foreach (string fieldName in Enum.GetNames(type)) { diff --git a/src/Microsoft/SqlServer/Management/Sdk/Sfc/SQLToolsOutputDebugStringListener.cs b/src/Microsoft/SqlServer/Management/Sdk/Sfc/SQLToolsOutputDebugStringListener.cs deleted file mode 100644 index 228f8563..00000000 --- a/src/Microsoft/SqlServer/Management/Sdk/Sfc/SQLToolsOutputDebugStringListener.cs +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -namespace Microsoft.SqlServer.Management.Sdk.Sfc.Diagnostics -{ - using System; - using System.Diagnostics; - using System.Runtime.InteropServices; - - /// - /// Summary description for SQLToolsOutputDebugStringWriter. - /// - - internal class SQLToolsOutputDebugStringListener : TraceListener - { - private string myName = "SQLToolsOutputDebugStringListener"; - - public SQLToolsOutputDebugStringListener() - { - //not much to do - } - - public SQLToolsOutputDebugStringListener(string name) - : base(name) - { - myName = name; - } - - //overriden members - public override void Write(string message) - { - #if !NETSTANDARD2_0 - if (Debugger.IsLogging()) - { - Debugger.Log(0, null, message); - } - else - { - if (message != null) - { - OutputDebugString(message); - } - else - { - OutputDebugString(String.Empty); - } - } - #endif - } - - public override void WriteLine(string message) - { - Write(message + "\r\n"); - } - - #if !NETSTANDARD2_0 - [DllImport("kernel32.dll", CharSet=System.Runtime.InteropServices.CharSet.Auto)] - #else - [DllImport("kernel32.dll", CharSet=System.Runtime.InteropServices.CharSet.Ansi)] -#endif - internal static extern void OutputDebugString(String message); - }; - -} diff --git a/src/Microsoft/SqlServer/Management/Sdk/Sfc/SQLToolsTraceListenerCollection.cs b/src/Microsoft/SqlServer/Management/Sdk/Sfc/SQLToolsTraceListenerCollection.cs deleted file mode 100644 index 91dcf18c..00000000 --- a/src/Microsoft/SqlServer/Management/Sdk/Sfc/SQLToolsTraceListenerCollection.cs +++ /dev/null @@ -1,235 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -#define TRACE - -namespace Microsoft.SqlServer.Management.Sdk.Sfc.Diagnostics -{ - using System; - using System.Collections; - using System.Diagnostics; - - - internal class SQLToolsTraceListenerCollection : IList - { - ArrayList list; - - public SQLToolsTraceListenerCollection() - { - list = new ArrayList(1); - } - - public TraceListener this[int i] - { - get - { - return (TraceListener)list[i]; - } - - set - { - list[i] = value; - } - } - - public TraceListener this[string name] - { - get - { - foreach (TraceListener listener in this) - { - if (listener.Name == name) - { - return listener; - } - } - return null; - } - } - - public int Count - { - get - { - return list.Count; - } - } - - public int Add(TraceListener listener) - { - return ((IList)this).Add(listener); - } - - public void AddRange(TraceListener[] value) - { - for (int i = 0; ((i) < (value.Length)); i = ((i) + (1))) - { - this.Add(value[i]); - } - } - - public void AddRange(SQLToolsTraceListenerCollection value) - { - for (int i = 0; ((i) < (value.Count)); i = ((i) + (1))) - { - this.Add(value[i]); - } - } - - public void Clear() - { - list = new ArrayList(); - } - - public bool Contains(TraceListener listener) - { - return ((IList)this).Contains(listener); - } - - public void CopyTo(TraceListener[] listeners, int index) - { - ((ICollection)this).CopyTo((Array) listeners, index); - } - public IEnumerator GetEnumerator() - { - return list.GetEnumerator(); - } - - - public int IndexOf(TraceListener listener) - { - return ((IList)this).IndexOf(listener); - } - - public void Insert(int index, TraceListener listener) - { - ((IList)this).Insert(index, listener); - } - - public void Remove(TraceListener listener) - { - ((IList)this).Remove(listener); - } - - public void Remove(string name) - { - TraceListener listener = this[name]; - if (listener != null) - { - ((IList)this).Remove(listener); - } - } - - public void RemoveAt(int index) - { - ArrayList newList = new ArrayList(list.Count); - lock (this) - { - newList.AddRange(list); - newList.RemoveAt(index); - list = newList; - } - } - - object IList.this[int index] - { - get - { - return list[index]; - } - - set - { - list[index] = value; - } - } - - bool IList.IsReadOnly - { - get - { - return false; - } - } - - bool IList.IsFixedSize - { - get - { - return false; - } - } - - int IList.Add(object value) - { - int i; - ArrayList newList = new ArrayList(list.Count + 1); - lock (this) - { - newList.AddRange(list); - i = newList.Add(value); - list = newList; - } - return i; - } - - bool IList.Contains(object value) - { - return list.Contains(value); - } - - int IList.IndexOf(object value) - { - return list.IndexOf(value); - } - - void IList.Insert(int index, object value) - { - ArrayList newList = new ArrayList(list.Count + 1); - lock (this) - { - newList.AddRange(list); - newList.Insert(index, value); - list = newList; - } - } - - void IList.Remove(object value) - { - ArrayList newList = new ArrayList(list.Count); - lock (this) - { - newList.AddRange(list); - newList.Remove(value); - list = newList; - } - } - - object ICollection.SyncRoot - { - get { - return this; - } - } - - bool ICollection.IsSynchronized - { - get - { - return true; - } - } - - void ICollection.CopyTo(Array array, int index) - { - ArrayList newList = new ArrayList(list.Count + array.Length); - lock (this) - { - newList.AddRange(list); - newList.CopyTo(array, index); - list = newList; - } - } - } - -} diff --git a/src/Microsoft/SqlServer/Management/Sdk/Sfc/Serializer.cs b/src/Microsoft/SqlServer/Management/Sdk/Sfc/Serializer.cs index ed8c24b8..a30a06cb 100644 --- a/src/Microsoft/SqlServer/Management/Sdk/Sfc/Serializer.cs +++ b/src/Microsoft/SqlServer/Management/Sdk/Sfc/Serializer.cs @@ -5,6 +5,7 @@ using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Diagnostics; using System.IO; using System.Reflection; using System.Text; @@ -1167,7 +1168,7 @@ private void SetParent(IAlienObject instance, string instanceUri) /// adapter object or null if no adapter type was specified private static IXmlSerializationAdapter GetSerializationAdapter(SfcMetadataRelation propertyRelation) { - TraceHelper.Assert(propertyRelation != null); + Debug.Assert(propertyRelation != null); //create the serialization adapter for this property if it is specified IXmlSerializationAdapter serializationAdapter = null; @@ -1177,7 +1178,7 @@ private static IXmlSerializationAdapter GetSerializationAdapter(SfcMetadataRelat if (attribute != null) { - TraceHelper.Assert(attribute is SfcSerializationAdapterAttribute); + Debug.Assert(attribute is SfcSerializationAdapterAttribute); SfcSerializationAdapterAttribute adapterAttribute = attribute as SfcSerializationAdapterAttribute; try @@ -1186,13 +1187,13 @@ private static IXmlSerializationAdapter GetSerializationAdapter(SfcMetadataRelat serializationAdapter = adapter as IXmlSerializationAdapter; //the given adapter should implement IXmlSerializationAdapter - TraceHelper.Assert(serializationAdapter != null, "Specified serialization adapter of type " + adapterAttribute.SfcSerializationAdapterType.Name + Debug.Assert(serializationAdapter != null, "Specified serialization adapter of type " + adapterAttribute.SfcSerializationAdapterType.Name + " does not implement IXmlSerializationAdapter"); } catch (System.MissingMethodException mme) { //adapter should allow construction using default constructor, but here it doesn't. - TraceHelper.Assert(false, "Serialization adapter is specified but cannot be constructed using default constructor. Caught exception: " + mme.Message); + Debug.Assert(false, "Serialization adapter is specified but cannot be constructed using default constructor. Caught exception: " + mme.Message); } } diff --git a/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcAttributes.cs b/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcAttributes.cs index 034ec07f..8ea5566b 100644 --- a/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcAttributes.cs +++ b/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcAttributes.cs @@ -4,9 +4,11 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Text; +using Microsoft.SqlServer.Management.Common; namespace Microsoft.SqlServer.Management.Sdk.Sfc.Metadata { @@ -240,7 +242,7 @@ public SfcReferenceAttribute(Type resolverType, string[] parameters) MethodInfo resolverFactoryMethod = resolverType.GetMethod(SfcReferenceAttribute.SfcReferenceResolverFactoryMethodName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); // Not optional and a bug if not defined - TraceHelper.Assert(resolverFactoryMethod != null, String.Format(System.Globalization.CultureInfo.InvariantCulture, + Debug.Assert(resolverFactoryMethod != null, String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0} resolver factory method on type '{1}' not found. Note: this method must be defined as a static method.", SfcReferenceAttribute.SfcReferenceResolverFactoryMethodName, resolverType.FullName)); Delegate factory = resolverFactoryMethod.CreateDelegate(typeof(SfcReferenceResolverFactoryDelegate)); @@ -307,7 +309,7 @@ public SfcReferenceAttribute(Type referenceType, string[] keys, Type resolverTyp MethodInfo resolver = resolverType.GetMethod(methodName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); // Not optional and a bug if not defined - TraceHelper.Assert(resolver != null, String.Format(System.Globalization.CultureInfo.InvariantCulture, + Debug.Assert(resolver != null, String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0} method on type {1} not found. Note: this method must be defined as a static method.", methodName, resolverType.FullName)); m_resolver = resolver.CreateDelegate(typeof(ReferenceResolverDelegate)); @@ -490,7 +492,7 @@ private object ResolveDelegateOrPath(object instance) string domainRoot = objectUrn.XPathExpression[0].Name; if(string.Compare(domainRoot,"Server",StringComparison.OrdinalIgnoreCase) == 0)//SMO { - TraceHelper.Assert(false); // can't happen any more + Debug.Assert(false); // can't happen any more } else { @@ -668,7 +670,7 @@ public SfcReferenceCollectionAttribute(Type resolverType, params string[] parame MethodInfo resolverFactoryMethod = resolverType.GetMethod(SfcReferenceAttribute.SfcReferenceCollectionResolverFactoryMethodName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); // Not optional and a bug if not defined - TraceHelper.Assert(resolverFactoryMethod != null, String.Format(System.Globalization.CultureInfo.InvariantCulture, + Debug.Assert(resolverFactoryMethod != null, String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0} resolver factory method on type '{1}' not found. Note: this method must be defined as a static method.", SfcReferenceAttribute.SfcReferenceCollectionResolverFactoryMethodName, resolverType.FullName)); Delegate factory = resolverFactoryMethod.CreateDelegate(typeof(SfcReferenceCollectionResolverFactoryDelegate)); diff --git a/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcCollatedDictionaryBase.cs b/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcCollatedDictionaryBase.cs index 5cb52ee0..226b4921 100644 --- a/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcCollatedDictionaryBase.cs +++ b/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcCollatedDictionaryBase.cs @@ -2,9 +2,8 @@ // Licensed under the MIT license. using System.Collections.Generic; +using System.Diagnostics; using System.Globalization; -using System.Text; -using Microsoft.SqlServer.Management.Sdk.Sfc; namespace Microsoft.SqlServer.Management.Sdk.Sfc { @@ -245,7 +244,7 @@ protected override bool AddShadow(T obj) { m_shadow.Add(obj.AbstractIdentityKey as K, obj); // The object must already be parented correctly - TraceHelper.Assert(obj.Parent == this.Parent); + Debug.Assert(obj.Parent == this.Parent); return true; } return false; diff --git a/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcCollection.cs b/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcCollection.cs index b7dea6ee..55f0d66d 100644 --- a/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcCollection.cs +++ b/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcCollection.cs @@ -5,6 +5,7 @@ using System.Collections; using System.Collections.Generic; using System.ComponentModel; +using System.Diagnostics; namespace Microsoft.SqlServer.Management.Sdk.Sfc { @@ -79,7 +80,7 @@ public virtual void Add(T obj) this.AddImpl(obj); // The object must already be parented correctly - TraceHelper.Assert(obj.Parent == this.Parent); + Debug.Assert(obj.Parent == this.Parent); } public abstract void Clear(); @@ -351,7 +352,7 @@ internal protected void Rename(T obj, K newKey) try { keyProp = obj.Properties[keyPropName]; - TraceHelper.Assert(keyProp != null); + Debug.Assert(keyProp != null); } catch { @@ -517,7 +518,7 @@ public bool IsSynchronized //to the fact that KJ assemblies carry the same version as Katmai ones, removes this will be changing the public //interface, and will be breaking applications that use Katmai assemblies because due to the same version, they //will be using KJ without any knowledge of that. - TraceHelper.Assert(false, "Setting IsSynchronized property is not supported"); + Debug.Assert(false, "Setting IsSynchronized property is not supported"); } get { @@ -533,7 +534,7 @@ public object SyncRoot //to the fact that KJ assemblies carry the same version as Katmai ones, removes this will be changing the public //interface, and will be breaking applications that use Katmai assemblies because due to the same version, they //will be using KJ without any knowledge of that. - TraceHelper.Assert(false, "Setting SyncRoot property is not supported"); + Debug.Assert(false, "Setting SyncRoot property is not supported"); } get { diff --git a/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcDictionaryBase.cs b/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcDictionaryBase.cs index 3e1a3922..bc10903f 100644 --- a/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcDictionaryBase.cs +++ b/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcDictionaryBase.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. using System.Collections.Generic; +using System.Diagnostics; namespace Microsoft.SqlServer.Management.Sdk.Sfc { @@ -144,7 +145,7 @@ protected override bool AddShadow(T obj) { m_shadow.Add(obj.AbstractIdentityKey as K, obj); // The object must already be parented correctly - TraceHelper.Assert(obj.Parent == this.Parent); + Debug.Assert(obj.Parent == this.Parent); return true; } return false; diff --git a/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcExecutionEngine.cs b/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcExecutionEngine.cs index 433c588e..0e33d2d3 100644 --- a/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcExecutionEngine.cs +++ b/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcExecutionEngine.cs @@ -6,6 +6,7 @@ namespace Microsoft.SqlServer.Management.Sdk.Sfc { + using System.Diagnostics; #if MICROSOFTDATA using Microsoft.Data.SqlClient; #else @@ -49,7 +50,7 @@ internal static object Execute(Common.ServerConnection connection, string script object dataSet = connection.ExecuteWithResults(script); return dataSet; default: - TraceHelper.Assert(false, "Unknown ExecutionMode supplied"); + Debug.Assert(false, "Unknown ExecutionMode supplied"); return null; } } diff --git a/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcInstance.cs b/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcInstance.cs index 5cd825ab..ce43791c 100644 --- a/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcInstance.cs +++ b/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcInstance.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Data; +using System.Diagnostics; using System.Globalization; using System.Xml; using Microsoft.SqlServer.Management.Common; @@ -400,7 +401,7 @@ protected internal SfcKey AbstractIdentityKey } // there is no real check here other than to try and get a hashcode. Every key must hash. - // Note: Removed TraceHelper.Assert(m_key.GetHashCode() != 0), since 0 is a perfectly valid hash value! + // Note: Removed Debug.Assert(m_key.GetHashCode() != 0), since 0 is a perfectly valid hash value! } return m_key; } @@ -436,7 +437,7 @@ public SfcKeyChain KeyChain if (this is ISfcDomain) { // Better not have a parent if we are the root - TraceHelper.Assert(m_parent == null); + Debug.Assert(m_parent == null); // This would be an InvalidCast exception but we don't want to throw, just return null. // The key from a ISfcDomain root object should always be a DomainRootKey. @@ -460,7 +461,7 @@ public SfcKeyChain KeyChain } internal set // setting a keychain is now done in very few places and should be avoided altogether { - TraceHelper.Assert(value != null); // don't try setting a null keychain + Debug.Assert(value != null); // don't try setting a null keychain // When we set the keychain we have to make sure that we aren't stepping on a // preset parent @@ -742,7 +743,7 @@ private void InitObjectsFromEnumResultsRec( object[] parentRow) { // have we finished the table already? - TraceHelper.Assert(!reader.IsClosed); + Debug.Assert(!reader.IsClosed); // Check for merging via key only if collection is not empty, // otherwise assume we can just add new items in via the reader. @@ -859,7 +860,7 @@ private bool AdvanceInitRec( /// private static bool CompareRows(IDataReader reader, object[] parentRow, int columnStartIdx, int columnStopIdx) { - TraceHelper.Assert(!reader.IsClosed); + Debug.Assert(!reader.IsClosed); for (int i = columnStartIdx; i < columnStopIdx; i++) { @@ -918,7 +919,7 @@ protected void MarkRootAsConnected() return; } - TraceHelper.Assert(this is ISfcDomain); // not supposed to be used for other things + Debug.Assert(this is ISfcDomain); // not supposed to be used for other things this.State = SfcObjectState.Existing; this.Initialize(); } @@ -939,7 +940,7 @@ protected void CheckObjectState() } //This check is needed for Deserialization: Root of the deserialized tree might not be able to access parent - TraceHelper.Assert(this.KeyChain != null); + Debug.Assert(this.KeyChain != null); if (this.State == SfcObjectState.Dropped) { @@ -1023,7 +1024,7 @@ private void PostCrud(SfcDependencyAction depAction, SfcKeyChain oldKeyChain, ob if (collection.GetExisting(this.AbstractIdentityKey, out existingObj)) { // This is temporary solution to support DMF's deep creation. The object already exists, don't add it to the collection - TraceHelper.Assert(Object.ReferenceEquals(existingObj, this)); + Debug.Assert(Object.ReferenceEquals(existingObj, this)); } else { @@ -1041,7 +1042,7 @@ private void PostCrud(SfcDependencyAction depAction, SfcKeyChain oldKeyChain, ob { // Before housekeeping event // pass New keychain, New key - TraceHelper.Assert(extraParam is SfcKey); + Debug.Assert(extraParam is SfcKey); SfcKey newKey = (extraParam as SfcKey); SfcKeyChain newKeyChain = new SfcKeyChain(newKey, this.KeyChain.Parent); SfcApplication.Events.OnBeforeObjectRenamed(this, new SfcBeforeObjectRenamedEventArgs(this.KeyChain.Urn, this, newKeyChain.Urn, newKey)); @@ -1050,12 +1051,12 @@ private void PostCrud(SfcDependencyAction depAction, SfcKeyChain oldKeyChain, ob SfcKey oldKey = this.KeyChain.LeafKey; ISfcCollection collection = GetParentCollection(); SfcInstance existingObj; - TraceHelper.Assert(collection.GetExisting(this.AbstractIdentityKey, out existingObj)); // can't remove if it doesn't exist - TraceHelper.Assert(object.ReferenceEquals(this, existingObj)); // must refer to us + Debug.Assert(collection.GetExisting(this.AbstractIdentityKey, out existingObj)); // can't remove if it doesn't exist + Debug.Assert(object.ReferenceEquals(this, existingObj)); // must refer to us collection.Rename(this, newKey); - TraceHelper.Assert(!collection.GetExisting(oldKey, out existingObj)); // old key must not exist after removal - TraceHelper.Assert(collection.GetExisting(this.AbstractIdentityKey, out existingObj)); // new key must now exist - TraceHelper.Assert(object.ReferenceEquals(this, existingObj)); // must still refer to us + Debug.Assert(!collection.GetExisting(oldKey, out existingObj)); // old key must not exist after removal + Debug.Assert(collection.GetExisting(this.AbstractIdentityKey, out existingObj)); // new key must now exist + Debug.Assert(object.ReferenceEquals(this, existingObj)); // must still refer to us // User housekeeping PostRename(executionResult); @@ -1087,7 +1088,7 @@ private void PostCrud(SfcDependencyAction depAction, SfcKeyChain oldKeyChain, ob // Before housekeeping event // pass New keychain, New parent - TraceHelper.Assert(extraParam is SfcInstance); + Debug.Assert(extraParam is SfcInstance); SfcInstance newParent = (extraParam as SfcInstance); SfcKeyChain newKeyChain = new SfcKeyChain(this.AbstractIdentityKey, newParent.KeyChain); SfcApplication.Events.OnBeforeObjectMoved(this, new SfcBeforeObjectMovedEventArgs(this.KeyChain.Urn, this, newKeyChain.Urn, newParent)); @@ -1114,9 +1115,9 @@ private void PostCrud(SfcDependencyAction depAction, SfcKeyChain oldKeyChain, ob ISfcCollection collection = GetParentCollection(); SfcInstance existingObj; collection.Add(this); - TraceHelper.Assert(!oldCollection.GetExisting(this.AbstractIdentityKey, out existingObj)); // old collection entry for us must not exist - TraceHelper.Assert(collection.GetExisting(this.AbstractIdentityKey, out existingObj)); // new collection entry must now exist - TraceHelper.Assert(object.ReferenceEquals(this, existingObj)); // must still refer to us + Debug.Assert(!oldCollection.GetExisting(this.AbstractIdentityKey, out existingObj)); // old collection entry for us must not exist + Debug.Assert(collection.GetExisting(this.AbstractIdentityKey, out existingObj)); // new collection entry must now exist + Debug.Assert(object.ReferenceEquals(this, existingObj)); // must still refer to us // User housekeeping PostMove(executionResult); @@ -1152,7 +1153,7 @@ private void PostCrud(SfcDependencyAction depAction, SfcKeyChain oldKeyChain, ob break; default: - TraceHelper.Assert(false); // Unknown action + Debug.Assert(false); // Unknown action break; } } @@ -1232,7 +1233,7 @@ private void CRUDImplWorker( string operationName, SfcObjectState requiredState, CheckObjectStateAndParent(requiredState); List depObjects = GetDependentObjects(depAction); - TraceHelper.Assert(depObjects.Count > 0); // could not get any objects to script + Debug.Assert(depObjects.Count > 0); // could not get any objects to script // Save a copy of the original Keychain in case this is a rename or move. // Eitehr operation will mutate the original, so make a COPY. @@ -1259,7 +1260,7 @@ private void CRUDImplWorker( string operationName, SfcObjectState requiredState, ResetKey(); // Better be equal now... - TraceHelper.Assert(mostCurrentKey.Equals(this.AbstractIdentityKey)); + Debug.Assert(mostCurrentKey.Equals(this.AbstractIdentityKey)); } SfcInstance existingObj; diff --git a/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcListBase.cs b/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcListBase.cs index 47167cf9..209bc478 100644 --- a/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcListBase.cs +++ b/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcListBase.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. using System.Collections.Generic; +using System.Diagnostics; namespace Microsoft.SqlServer.Management.Sdk.Sfc { @@ -100,7 +101,7 @@ public override bool Contains(K key) K loopKey = loopObj.AbstractIdentityKey as K; if (loopKey.Equals(key)) { - TraceHelper.Assert(loopObj.State != SfcObjectState.Dropped); // drop should remove objects from collections, so this should never happen + Debug.Assert(loopObj.State != SfcObjectState.Dropped); // drop should remove objects from collections, so this should never happen return true; } } @@ -158,7 +159,7 @@ protected override bool AddShadow(T obj) { m_shadow.Add(obj); // The object must already be parented correctly - TraceHelper.Assert(obj.Parent == this.Parent); + Debug.Assert(obj.Parent == this.Parent); return true; } return false; diff --git a/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcMetadata.cs b/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcMetadata.cs index 4302b487..ced3a868 100644 --- a/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcMetadata.cs +++ b/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcMetadata.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; +using System.Diagnostics; using System.Reflection; using Microsoft.SqlServer.Server; @@ -233,8 +234,8 @@ internal struct TypeHandlePropertyNameKey internal TypeHandlePropertyNameKey(string propertyName, RuntimeTypeHandle typeHandle) { - TraceHelper.Assert(propertyName != null, "PropertyName can't be null in TypeHandlePropertyNameKey"); - TraceHelper.Assert(typeHandle != null, "TypeHandle can't be null in TypeHandlePropertyNameKey"); + Debug.Assert(propertyName != null, "PropertyName can't be null in TypeHandlePropertyNameKey"); + Debug.Assert(typeHandle != null, "TypeHandle can't be null in TypeHandlePropertyNameKey"); this.propertyName = propertyName; this.typeHandle = typeHandle; @@ -504,7 +505,7 @@ internal static List GetTypeRelations(Type sfcType) } } - TraceHelper.Assert(typeRelations != null, "TypeRelations list can't be null"); + Debug.Assert(typeRelations != null, "TypeRelations list can't be null"); return typeRelations; } @@ -525,7 +526,7 @@ internal static List GetTypeKeys(Type sfcType) } } - TraceHelper.Assert(typeKeys != null, "TypeKeys list can't be null"); + Debug.Assert(typeKeys != null, "TypeKeys list can't be null"); return typeKeys; } @@ -668,7 +669,7 @@ private static string GetUrnSuffixForType(Type type) object[] attributes = type.GetCustomAttributes(typeof(SfcElementTypeAttribute), false); if (attributes != null && attributes.Length > 0) { - TraceHelper.Assert(attributes.Length == 1, "SfcElementType attribute should exist only once"); + Debug.Assert(attributes.Length == 1, "SfcElementType attribute should exist only once"); SfcElementTypeAttribute elementType = (SfcElementTypeAttribute)attributes[0]; urnSuffix = elementType.ElementTypeName; } @@ -1193,7 +1194,7 @@ internal ReadOnlyCollection ReadOnlyCollectionProperties } } - TraceHelper.Assert(list != null, "ReadOnlyProperties return list can't be null"); + Debug.Assert(list != null, "ReadOnlyProperties return list can't be null"); return list.AsReadOnly(); } } @@ -1484,7 +1485,7 @@ public object Resolve(object instance) } PropertyInfo property = instance.GetType().GetProperty(this.PropertyName); - TraceHelper.Assert(property != null); + Debug.Assert(property != null); // Just return the property value directly for non-reference properties return property.GetValue(instance, null); } @@ -1509,7 +1510,7 @@ public T Resolve(S instance) } PropertyInfo property = instance.GetType().GetProperty(this.PropertyName); - TraceHelper.Assert(property != null); + Debug.Assert(property != null); // Just return the property value directly for non-reference properties return (T)property.GetValue(instance, null); } @@ -1534,7 +1535,7 @@ public IEnumerable ResolveCollection(object instance) // Yield normal property values if we didn't find any reference collection attributes PropertyInfo property = instance.GetType().GetProperty(this.PropertyName); - TraceHelper.Assert(property != null); + Debug.Assert(property != null); // Just yield the property values directly for non-reference collection properties return (IEnumerable)property.GetValue(instance, null); } @@ -1561,7 +1562,7 @@ public IEnumerable ResolveCollection(S instance) // Yield normal property values if we didn't find any reference collection attributes PropertyInfo property = instance.GetType().GetProperty(this.PropertyName); - TraceHelper.Assert(property != null); + Debug.Assert(property != null); // Just yield the property values directly for non-reference collection properties return (IEnumerable)property.GetValue(instance, null); } diff --git a/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcObjectIterator.cs b/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcObjectIterator.cs index 3e055f91..e0dacc6b 100644 --- a/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcObjectIterator.cs +++ b/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcObjectIterator.cs @@ -4,6 +4,7 @@ using System; using System.Collections; using System.Data; +using System.Diagnostics; using System.Globalization; using System.Reflection; using Microsoft.SqlServer.Management.Common; @@ -66,7 +67,7 @@ public SfcObjectIterator(ISfcDomain root, SfcObjectQueryMode activeQueriesMode, // of the query. When the type factory gets cleaner we will likely be able to cache // the actual type factory here and not just the name _type = _root.GetType(_urn.Type); - TraceHelper.Assert(_type != null); + Debug.Assert(_type != null); // Determine the actual connection to use now. Only do this once in this object instance (not on Reset). GetConnection(); @@ -107,7 +108,7 @@ private object CreateObjectHierarchy(Urn urn) // Get the type and create the object Type type = _root.GetType(urn.Type); object obj = SfcRegistration.CreateObject(type.FullName); - TraceHelper.Assert(obj != null); + Debug.Assert(obj != null); // Set the object root to disconnected (design) mode if (obj is IAlienRoot) @@ -183,13 +184,13 @@ Object IEnumerator.Current SfcKeyChain kc = new SfcKeyChain(_ResultsDataReader.GetString(_urnColIndex), _root); if( kc.Parent == null ) { - TraceHelper.Assert( kc.LeafKey is DomainRootKey ); + Debug.Assert( kc.LeafKey is DomainRootKey ); _currentInstance = kc.GetObject(); } else { SfcInstance parent = kc.Parent.GetObject(); - TraceHelper.Assert(parent != null); + Debug.Assert(parent != null); string elementTypeName = kc.LeafKey.InstanceType.Name; ISfcCollection collection = parent.GetChildCollection(elementTypeName); diff --git a/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcObjectQuery.cs b/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcObjectQuery.cs index a8bfe228..3918d897 100644 --- a/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcObjectQuery.cs +++ b/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcObjectQuery.cs @@ -4,6 +4,7 @@ using System; using System.Collections; using System.Data; +using System.Diagnostics; using Microsoft.SqlServer.Management.Common; namespace Microsoft.SqlServer.Management.Sdk.Sfc @@ -171,11 +172,11 @@ private void Init(ISfcDomain domain, SfcObjectQueryMode mode) // Any connection sent into OQ must be a SfcConnection-derived one ISfcHasConnection hasConn = domain as ISfcHasConnection; - TraceHelper.Assert(null != hasConn); + Debug.Assert(null != hasConn); // The connection can be null if we are Offline (disconnected) this.domainConn = hasConn.GetConnection(); - TraceHelper.Assert(null != domainConn || this.domain.ConnectionContext.Mode == SfcConnectionContextMode.Offline); + Debug.Assert(null != domainConn || this.domain.ConnectionContext.Mode == SfcConnectionContextMode.Offline); } // Validate the query string. diff --git a/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcQueryExpression.cs b/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcQueryExpression.cs index f9449919..84bf12d0 100644 --- a/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcQueryExpression.cs +++ b/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcQueryExpression.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. using System; +using System.Diagnostics; using System.Xml; using System.Xml.Serialization; @@ -72,7 +73,7 @@ public string GetLeafTypeName() if (this.expression.ToString().StartsWith("Server", StringComparison.Ordinal)) { // Can't do that any more for SMO types. Caller beware! - TraceHelper.Assert(false); + Debug.Assert(false); } return this.expression.Type; diff --git a/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcSimpleNodeAdapter.cs b/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcSimpleNodeAdapter.cs index 82b07f39..1def9aa2 100644 --- a/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcSimpleNodeAdapter.cs +++ b/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcSimpleNodeAdapter.cs @@ -4,6 +4,7 @@ using System; using System.Collections; using System.Reflection; +using Microsoft.SqlServer.Management.Common; namespace Microsoft.SqlServer.Management.Sdk.Sfc { @@ -107,7 +108,7 @@ internal object CheckedGetProperty(object reference, string propertyName) } catch (Exception e) when (!IsSystemGeneratedException(e)) { - TraceHelper.LogExCatch(e); + SmoEventSource.Log.SfcExceptionCaught(e); return null; } } @@ -120,7 +121,7 @@ internal object CheckedGetObject(object reference, string childName) } catch (Exception e) when (!IsSystemGeneratedException(e)) { - TraceHelper.LogExCatch(e); + SmoEventSource.Log.SfcExceptionCaught(e); return null; } } @@ -133,7 +134,7 @@ internal IEnumerable CheckedGetEnumerable(object reference, string enumName) } catch (Exception e) when (!IsSystemGeneratedException(e)) { - TraceHelper.LogExCatch(e); + SmoEventSource.Log.SfcExceptionCaught(e); return null; } } @@ -146,7 +147,7 @@ internal Urn CheckedGetUrn(object reference) } catch (Exception e) when (!IsSystemGeneratedException(e)) { - TraceHelper.LogExCatch(e); + SmoEventSource.Log.SfcExceptionCaught(e); return null; } } @@ -159,7 +160,7 @@ internal bool CheckedIsCriteriaMatched(object reference) } catch (Exception e) when (!IsSystemGeneratedException(e)) { - TraceHelper.LogExCatch(e); + SmoEventSource.Log.SfcExceptionCaught(e); return false; } } @@ -172,7 +173,7 @@ internal bool CheckedIsSupported(object reference) } catch (Exception e) when (!IsSystemGeneratedException(e)) { - TraceHelper.LogExCatch(e); + SmoEventSource.Log.SfcExceptionCaught(e); return false; } } @@ -237,7 +238,7 @@ public override object GetProperty(object instance, string propertyName) } catch (TargetInvocationException tie) { - TraceHelper.LogExCatch(tie); + SmoEventSource.Log.SfcExceptionCaught(tie); propertyVal = null; } return propertyVal; diff --git a/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcTsqlProcFormatter.cs b/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcTsqlProcFormatter.cs index 44188de8..fc30fdb0 100644 --- a/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcTsqlProcFormatter.cs +++ b/src/Microsoft/SqlServer/Management/Sdk/Sfc/SfcTsqlProcFormatter.cs @@ -5,6 +5,8 @@ using System.Collections.Generic; using System.Globalization; using System.Text; +using System.Diagnostics; + #if !NETCOREAPP using System.Runtime.Remoting.Metadata.W3cXsd2001; #endif @@ -31,7 +33,7 @@ public struct SprocArg public SprocArg(string name, string property, bool required, bool output) { this.argName = name; - TraceHelper.Assert(!String.IsNullOrEmpty(property)); + Debug.Assert(!String.IsNullOrEmpty(property)); this.property = property; this.required = required; this.output = output; @@ -191,7 +193,7 @@ public string GenerateScript(SfcInstance sfcObject, IEnumerable runt if (hasOutput) { - TraceHelper.Assert(false, "More than one OUTPUT parameters specified!"); + Debug.Assert(false, "More than one OUTPUT parameters specified!"); } else { @@ -223,7 +225,7 @@ public string GenerateScript(SfcInstance sfcObject, IEnumerable runt } else { - TraceHelper.Assert(false, "Unexpected OUTPUT parameter type!"); + Debug.Assert(false, "Unexpected OUTPUT parameter type!"); } sb.AppendLine(); @@ -266,7 +268,7 @@ public string GenerateScript(SfcInstance sfcObject, IEnumerable runt if (String.IsNullOrEmpty(arg.property)) { - TraceHelper.Assert(!(null == runtimeArgsEnum), String.Format("No runtimeArgsEnum but there is no property with the name '!{0}", arg.argName)); + Debug.Assert(!(null == runtimeArgsEnum), String.Format("No runtimeArgsEnum but there is no property with the name '!{0}", arg.argName)); RuntimeArg runtime = runtimeArgsEnum.Current; runtimeArgsEnum.MoveNext(); type = runtime.type; diff --git a/src/Microsoft/SqlServer/Management/Sdk/Sfc/TraceHelper.cs b/src/Microsoft/SqlServer/Management/Sdk/Sfc/TraceHelper.cs index d2a46450..d17b2076 100644 --- a/src/Microsoft/SqlServer/Management/Sdk/Sfc/TraceHelper.cs +++ b/src/Microsoft/SqlServer/Management/Sdk/Sfc/TraceHelper.cs @@ -86,30 +86,6 @@ public static void Trace(string strComponentName, uint traceLevel, string strFor #endif } - /// - /// This API supports the product infrastructure and is not intended to be used directly from your code. - /// - public static void Assert(bool condition) - { -#if STRACE - STrace.Assert(condition); -#else - System.Diagnostics.Debug.Assert(condition); -#endif - } - - /// - /// This API supports the product infrastructure and is not intended to be used directly from your code. - /// - public static void Assert(bool condition, string strFormat) - { -#if STRACE - STrace.Assert(condition, strFormat); -#else - System.Diagnostics.Debug.Assert(condition, strFormat); -#endif - } - /// /// This API supports the product infrastructure and is not intended to be used directly from your code. /// diff --git a/src/Microsoft/SqlServer/Management/Sdk/Sfc/XmlTextReader.cs b/src/Microsoft/SqlServer/Management/Sdk/Sfc/XmlTextReader.cs deleted file mode 100644 index 1b8e994d..00000000 --- a/src/Microsoft/SqlServer/Management/Sdk/Sfc/XmlTextReader.cs +++ /dev/null @@ -1,638 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -#if NETSTANDARD2_0 -//------------------------------------------------------------------------------ -// -// Copyright (c) Microsoft Corporation. All rights reserved. -// -//------------------------------------------------------------------------------ - -using System; -using System.IO; -using System.Threading.Tasks; -using System.Xml; - -namespace Microsoft.SqlServer.Management.Sdk.Sfc -{ - public class XmlTextReader : XmlReader - { - // - // Member fields - // - XmlReader impl; - // - // - // Constructors - // - - public XmlTextReader(Stream input, XmlReaderSettings setting) - { - impl = XmlReader.Create(input, setting); - } - // - // XmlReader members - // - public override XmlNodeType NodeType - { - get { return impl.NodeType; } - } - - public override string Name - { - get { return impl.Name; } - } - - public override string LocalName - { - get { return impl.LocalName; } - } - - public override string NamespaceURI - { - get { return impl.NamespaceURI; } - } - - public override string Prefix - { - get { return impl.Prefix; } - } - - public override bool HasValue - { - get { return impl.HasValue; } - } - - public override string Value - { - get { return impl.Value; } - } - - public override int Depth - { - get { return impl.Depth; } - } - - public string implURI - { - get { throw new NotImplementedException(); } - } - - public override bool IsEmptyElement - { - get { return impl.IsEmptyElement; } - } - - public override bool IsDefault - { - get { return impl.IsDefault; } - } - - public override XmlSpace XmlSpace - { - get { return impl.XmlSpace; } - } - - public override string XmlLang - { - get { return impl.XmlLang; } - } - - public override int AttributeCount { get { return impl.AttributeCount; } } - - public override string GetAttribute(string name) - { - return impl.GetAttribute(name); - } - - public override string GetAttribute(string localName, string namespaceURI) - { - return impl.GetAttribute(localName, namespaceURI); - } - - public override string GetAttribute(int i) - { - return impl.GetAttribute(i); - } - - public override bool MoveToAttribute(string name) - { - return impl.MoveToAttribute(name); - } - - public override bool MoveToAttribute(string localName, string namespaceURI) - { - return impl.MoveToAttribute(localName, namespaceURI); - } - - public override void MoveToAttribute(int i) - { - impl.MoveToAttribute(i); - } - - public override bool MoveToFirstAttribute() - { - return impl.MoveToFirstAttribute(); - } - - public override bool MoveToNextAttribute() - { - return impl.MoveToNextAttribute(); - } - - public override bool MoveToElement() - { - return impl.MoveToElement(); - } - - public override bool ReadAttributeValue() - { - return impl.ReadAttributeValue(); - } - - public override bool Read() - { - return impl.Read(); - } - - public override bool EOF - { - get { return impl.EOF; } - } - - public override void Close() - { - impl.Dispose(); - } - - public override ReadState ReadState - { - get { return impl.ReadState; } - } - - public override void Skip() - { - impl.Skip(); - } - - public override XmlNameTable NameTable - { - get { return impl.NameTable; } - } - - public override String LookupNamespace(String prefix) - { - string ns = impl.LookupNamespace(prefix); - if (ns != null && ns.Length == 0) - { - ns = null; - } - return ns; - } - - public override bool CanResolveEntity - { - get { return true; } - } - - public override void ResolveEntity() - { - impl.ResolveEntity(); - } - - // Binary content access methods - public override bool CanReadBinaryContent - { - get { return true; } - } - - public int ReadContentAsimpl64(byte[] buffer, int index, int count) - { - throw new NotImplementedException(); - } - - public int ReadElementContentAsimpl64(byte[] buffer, int index, int count) - { - throw new NotImplementedException(); - } - - public override int ReadContentAsBinHex(byte[] buffer, int index, int count) - { - return impl.ReadContentAsBinHex(buffer, index, count); - } - - public override int ReadElementContentAsBinHex(byte[] buffer, int index, int count) - { - return impl.ReadElementContentAsBinHex(buffer, index, count); - } - - // Text streaming methods - - // XmlTextReader does do support streaming of Value (there are backwards compatibility issues when enabled) - public override bool CanReadValueChunk - { - get { return false; } - } - - // - // IXmlLineInfo members - // - public bool HasLineInfo() { return true; } - - [Obsolete("Use DtdProcessing property instead.")] - public bool ProhibitDtd - { - get { return impl.Settings.DtdProcessing == DtdProcessing.Prohibit; } - set { impl.Settings.DtdProcessing = value ? DtdProcessing.Prohibit : DtdProcessing.Ignore; } - } - - public DtdProcessing DtdProcessing - { - get { return impl.Settings.DtdProcessing; } - set { impl.Settings.DtdProcessing = value; } - } - - public override string this[string name] - { - get { return impl[name]; } - } - - public override string this[string name, string namespaceURI] - { - get { return impl[name, namespaceURI]; } - } - - public override string this[int i] - { - get { return impl[i]; } - } - - protected override void Dispose(bool disposing) - { - impl.Dispose(); - } - - public override bool Equals(object obj) - { - return impl.Equals(obj); - } - - public override int GetHashCode() - { - return impl.GetHashCode(); - } - - public override Task GetValueAsync() - { - return impl.GetValueAsync(); - } - - public override bool HasAttributes - { - get - { - return impl.HasAttributes; - } - } - - public override bool IsStartElement() - { - return impl.IsStartElement(); - } - - public override bool IsStartElement(string localname, string ns) - { - return impl.IsStartElement(localname, ns); - } - - public override bool IsStartElement(string name) - { - return impl.IsStartElement(name); - } - - public override XmlNodeType MoveToContent() - { - return impl.MoveToContent(); - } - - public override Task MoveToContentAsync() - { - return impl.MoveToContentAsync(); - } - - public override Task ReadAsync() - { - return impl.ReadAsync(); - } - - public override object ReadContentAs(Type returnType, IXmlNamespaceResolver namespaceResolver) - { - return impl.ReadContentAs(returnType, namespaceResolver); - } - - public override Task ReadContentAsAsync(Type returnType, IXmlNamespaceResolver namespaceResolver) - { - return impl.ReadContentAsAsync(returnType, namespaceResolver); - } - - public Task ReadContentAsimpl64Async(byte[] buffer, int index, int count) - { - throw new NotImplementedException(); - } - - public override Task ReadContentAsBinHexAsync(byte[] buffer, int index, int count) - { - return impl.ReadContentAsBinHexAsync(buffer, index, count); - } - - public override bool ReadContentAsBoolean() - { - return impl.ReadContentAsBoolean(); - } - - public override DateTimeOffset ReadContentAsDateTimeOffset() - { - return impl.ReadContentAsDateTimeOffset(); - } - - public override decimal ReadContentAsDecimal() - { - return impl.ReadContentAsDecimal(); - } - - public override double ReadContentAsDouble() - { - return impl.ReadContentAsDouble(); - } - - public override float ReadContentAsFloat() - { - return impl.ReadContentAsFloat(); - } - - public override int ReadContentAsInt() - { - return impl.ReadContentAsInt(); - } - - public override long ReadContentAsLong() - { - return impl.ReadContentAsLong(); - } - - public override object ReadContentAsObject() - { - return impl.ReadContentAsObject(); - } - - public override Task ReadContentAsObjectAsync() - { - return impl.ReadContentAsObjectAsync(); - } - - public override string ReadContentAsString() - { - return impl.ReadContentAsString(); - } - - public override Task ReadContentAsStringAsync() - { - return impl.ReadContentAsStringAsync(); - } - - public override object ReadElementContentAs(Type returnType, IXmlNamespaceResolver namespaceResolver) - { - return impl.ReadElementContentAs(returnType, namespaceResolver); - } - - public override object ReadElementContentAs(Type returnType, IXmlNamespaceResolver namespaceResolver, string localName, string namespaceURI) - { - return impl.ReadElementContentAs(returnType, namespaceResolver, localName, namespaceURI); - } - - public override Task ReadElementContentAsAsync(Type returnType, IXmlNamespaceResolver namespaceResolver) - { - return impl.ReadElementContentAsAsync(returnType, namespaceResolver); - } - - public Task ReadElementContentAsimpl64Async(byte[] buffer, int index, int count) - { - throw new NotImplementedException(); - } - - public override Task ReadElementContentAsBinHexAsync(byte[] buffer, int index, int count) - { - return impl.ReadElementContentAsBinHexAsync(buffer, index, count); - } - - public override bool ReadElementContentAsBoolean() - { - return impl.ReadElementContentAsBoolean(); - } - - public override bool ReadElementContentAsBoolean(string localName, string namespaceURI) - { - return impl.ReadElementContentAsBoolean(localName, namespaceURI); - } - - public override decimal ReadElementContentAsDecimal() - { - return impl.ReadElementContentAsDecimal(); - } - - public override decimal ReadElementContentAsDecimal(string localName, string namespaceURI) - { - return impl.ReadElementContentAsDecimal(localName, namespaceURI); - } - - public override double ReadElementContentAsDouble() - { - return impl.ReadElementContentAsDouble(); - } - - public override double ReadElementContentAsDouble(string localName, string namespaceURI) - { - return impl.ReadElementContentAsDouble(localName, namespaceURI); - } - - public override float ReadElementContentAsFloat() - { - return impl.ReadElementContentAsFloat(); - } - - public override float ReadElementContentAsFloat(string localName, string namespaceURI) - { - return impl.ReadElementContentAsFloat(localName, namespaceURI); - } - - public override int ReadElementContentAsInt() - { - return impl.ReadElementContentAsInt(); - } - - public override int ReadElementContentAsInt(string localName, string namespaceURI) - { - return impl.ReadElementContentAsInt(localName, namespaceURI); - } - - public override long ReadElementContentAsLong() - { - return impl.ReadElementContentAsLong(); - } - - public override long ReadElementContentAsLong(string localName, string namespaceURI) - { - return impl.ReadElementContentAsLong(localName, namespaceURI); - } - - public override object ReadElementContentAsObject() - { - return impl.ReadElementContentAsObject(); - } - - public override object ReadElementContentAsObject(string localName, string namespaceURI) - { - return impl.ReadElementContentAsObject(localName, namespaceURI); - } - - public override Task ReadElementContentAsObjectAsync() - { - return impl.ReadElementContentAsObjectAsync(); - } - - public override string ReadElementContentAsString() - { - return impl.ReadElementContentAsString(); - } - - public override string ReadElementContentAsString(string localName, string namespaceURI) - { - return impl.ReadElementContentAsString(localName, namespaceURI); - } - - public override Task ReadElementContentAsStringAsync() - { - return impl.ReadElementContentAsStringAsync(); - } - - public override void ReadEndElement() - { - impl.ReadEndElement(); - } - - public override string ReadInnerXml() - { - return impl.ReadInnerXml(); - } - - public override Task ReadInnerXmlAsync() - { - return impl.ReadInnerXmlAsync(); - } - - public override string ReadOuterXml() - { - return impl.ReadOuterXml(); - } - - public override Task ReadOuterXmlAsync() - { - return impl.ReadOuterXmlAsync(); - } - - public override void ReadStartElement() - { - impl.ReadStartElement(); - } - - public override void ReadStartElement(string localname, string ns) - { - impl.ReadStartElement(localname, ns); - } - - public override void ReadStartElement(string name) - { - impl.ReadStartElement(name); - } - - public override XmlReader ReadSubtree() - { - return impl.ReadSubtree(); - } - - public override bool ReadToDescendant(string localName, string namespaceURI) - { - return impl.ReadToDescendant(localName, namespaceURI); - } - - public override bool ReadToDescendant(string name) - { - return impl.ReadToDescendant(name); - } - - public override bool ReadToFollowing(string localName, string namespaceURI) - { - return impl.ReadToFollowing(localName, namespaceURI); - } - - public override bool ReadToFollowing(string name) - { - return impl.ReadToFollowing(name); - } - - public override bool ReadToNextSibling(string localName, string namespaceURI) - { - return impl.ReadToNextSibling(localName, namespaceURI); - } - - public override bool ReadToNextSibling(string name) - { - return impl.ReadToNextSibling(name); - } - - public override int ReadValueChunk(char[] buffer, int index, int count) - { - return impl.ReadValueChunk(buffer, index, count); - } - - public override Task ReadValueChunkAsync(char[] buffer, int index, int count) - { - return impl.ReadValueChunkAsync(buffer, index, count); - } - - public override XmlReaderSettings Settings - { - get - { - return impl.Settings; - } - } - - public override Task SkipAsync() - { - return impl.SkipAsync(); - } - - public override string ToString() - { - return impl.ToString(); - } - - public override Type ValueType - { - get - { - return impl.ValueType; - } - } - - public override string BaseURI - { - get - { - return impl.BaseURI; - } - } - } -} -#endif \ No newline at end of file diff --git a/src/Microsoft/SqlServer/Management/Sdk/Sfc/connectionhelpers.cs b/src/Microsoft/SqlServer/Management/Sdk/Sfc/connectionhelpers.cs index c838ac53..b6cf1b68 100644 --- a/src/Microsoft/SqlServer/Management/Sdk/Sfc/connectionhelpers.cs +++ b/src/Microsoft/SqlServer/Management/Sdk/Sfc/connectionhelpers.cs @@ -117,7 +117,7 @@ internal static void UpdateConnectionInfoIfContainedAuthentication(ref Object co && (sqlExc.Number == 916 //The server principal is not able to access the database under the current security context. || sqlExc.Number == 911)) //Database does not exist. Make sure that the name is entered correctly.) { - TraceHelper.LogExCatch(exc); + SmoEventSource.Log.SfcConnectionException(exc); } finally { diff --git a/src/Microsoft/SqlServer/Management/Smo.Extended/BackupRestoreBase.cs b/src/Microsoft/SqlServer/Management/Smo.Extended/BackupRestoreBase.cs index cb2a7d69..5cacd627 100644 --- a/src/Microsoft/SqlServer/Management/Smo.Extended/BackupRestoreBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo.Extended/BackupRestoreBase.cs @@ -15,6 +15,7 @@ using Microsoft.SqlServer.Management.Smo.Internal; using System.IO; using Microsoft.SqlServer.Management.Sdk.Sfc; +using System.Diagnostics; namespace Microsoft.SqlServer.Management.Smo @@ -479,7 +480,7 @@ private void OnInfoMessage(object sender, ServerMessageEventArgs e) #endif protected void GetDevicesScript(StringBuilder query, BackupDeviceList devices, ServerVersion targetVersion) { - Sdk.Sfc.TraceHelper.Assert(null != devices); + Debug.Assert(null != devices); string format = string.Empty; bool isIdentifier = false; bool first = true; @@ -539,7 +540,7 @@ protected void GetDevicesScript(StringBuilder query, BackupDeviceList devices, S first = false; } - Sdk.Sfc.TraceHelper.Assert(null != bd.Name); + Debug.Assert(null != bd.Name); query.AppendFormat(SmoApplication.DefaultCulture, format, isIdentifier ? SqlSmoObject.SqlBraket(bd.Name) : SqlSmoObject.SqlString(bd.Name)); @@ -1296,8 +1297,8 @@ public override int GetHashCode() internal static void CheckType(object obj, string operation, object thisptr) { - Sdk.Sfc.TraceHelper.Assert(null != operation && operation.Length > 0); - Sdk.Sfc.TraceHelper.Assert(null != thisptr); + Debug.Assert(null != operation && operation.Length > 0); + Debug.Assert(null != thisptr); if (null == obj) throw new FailedOperationException(operation, thisptr, new ArgumentNullException()); diff --git a/src/Microsoft/SqlServer/Management/Smo.Extended/Transfer.cs b/src/Microsoft/SqlServer/Management/Smo.Extended/Transfer.cs index da20f6ee..812a7a9f 100644 --- a/src/Microsoft/SqlServer/Management/Smo.Extended/Transfer.cs +++ b/src/Microsoft/SqlServer/Management/Smo.Extended/Transfer.cs @@ -14,6 +14,7 @@ using System.Text; using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.Sdk.Sfc; +using System.Diagnostics; namespace Microsoft.SqlServer.Management.Smo { @@ -277,9 +278,9 @@ private static void MarkNodeForBreaking(Dependency[] cycle, Server server, bool { nodeForWhichToBreakLink = 0; - Sdk.Sfc.TraceHelper.Assert(false, "We could not find a node to break for the cycle"); + Debug.Assert(false, "We could not find a node to break for the cycle"); - SqlSmoObject.Trace("We could not find a node to break for the cycle"); + SmoEventSource.Log.TransferMarkingNodeForBreaking("Could not find a node to break for the cycle"); } } diff --git a/src/Microsoft/SqlServer/Management/Smo.Extended/TransferBase.cs b/src/Microsoft/SqlServer/Management/Smo.Extended/TransferBase.cs index 7f224859..1f69bf66 100644 --- a/src/Microsoft/SqlServer/Management/Smo.Extended/TransferBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo.Extended/TransferBase.cs @@ -5,6 +5,7 @@ using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; +using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Linq; using Microsoft.SqlServer.Management.Common; @@ -135,6 +136,7 @@ private void Init() public bool CopyAllLogins { get; set; } public bool CopyAllExternalLanguages { get; set; } public bool CopyAllExternalLibraries { get; set; } + public bool CopyAllExternalModels { get; set; } public bool CopySchema { get; set; } public bool CopyData { get; set; } public bool DropDestinationObjectsFirst { get; set; } @@ -381,10 +383,7 @@ public IEnumerable EnumScriptTransfer() // transfer with no parameters a try { -#if DEBUG - SqlSmoObject.Trace("Transfer: Entering"); - SqlSmoObject.Trace("Transfer: Script all discovered objects"); -#endif + SmoEventSource.Log.TransferScriptingObjects(); EnumerableContainer queryEnumerable = new EnumerableContainer(); this.Scripter.PrefetchObjects = false; this.Options.IncludeDatabaseContext = false; @@ -562,15 +561,13 @@ private HashSet DiscoverDependencies(HashSet depDiscInputList) HashSet result = new HashSet(); // Get the list of objects in the right order with // Dependency discovery -#if DEBUG - SqlSmoObject.Trace("Transfer: Discovering dependencies"); -#endif + SmoEventSource.Log.TransferDiscoveringDependencies(); #if INCLUDE_PERF_COUNT DateTime now = DateTime.Now; #endif // if no filtering is needed then we don't have to redo // the topological sorting on the client side - Sdk.Sfc.TraceHelper.Assert(null != this.Database, "null == this.Database"); + Debug.Assert(null != this.Database, "null == this.Database"); bool getDropDependencies = this.Options.ScriptSchema && this.Options.ScriptDrops; Urn[] urnArray = new Urn[depDiscInputList.Count]; @@ -579,7 +576,7 @@ private HashSet DiscoverDependencies(HashSet depDiscInputList) DependencyChainCollection deps = depTree.Dependencies; - Sdk.Sfc.TraceHelper.Assert(null != deps, "GetDependencies() returned null"); + Debug.Assert(null != deps, "GetDependencies() returned null"); // generate flat dependencies list for scripting HashSet orderedList = new HashSet(); @@ -1120,6 +1117,12 @@ private void AddDiscoverableObjects(HashSet depDiscInputList, Dictionary(preferences)) + { + this.AddAllObjects(depDiscInputList, Database.ExternalModels, + CopyAllExternalModels, Database.PrefetchExternalModels, null); + } + if (this.IsSupportedObject(preferences)) { this.AddAllObjects(depDiscInputList, Database.UserDefinedDataTypes, @@ -1154,9 +1157,7 @@ private void AddDiscoverableObjects(HashSet depDiscInputList, Dictionary(ICollection List, IEnumerable collection) where T : SqlSmoObject { -#if DEBUG - SqlSmoObject.Trace(string.Format(SmoApplication.DefaultCulture, "Transfer: Adding all objects {0} to dependency list", collection.GetType().Name)); -#endif + SmoEventSource.Log.TransferVisitingObject(false, collection.GetType().Name); foreach (T item in collection) { List.Add(item.Urn); @@ -1188,9 +1189,7 @@ private void AddAllObjects(ICollection List, IEnumerable collection, private void AddAllNonSystemObjects(ICollection List, IEnumerable collection, Func filterLedgerObjects) where T : SqlSmoObject { -#if DEBUG - SqlSmoObject.Trace(string.Format(SmoApplication.DefaultCulture, "Transfer: Adding all objects in {0} to dependency list", collection.GetType().Name)); -#endif + SmoEventSource.Log.TransferVisitingObject(true, collection.GetType().Name); foreach (T item in collection) { if (!item.GetPropValueOptional("IsSystemObject", false) && filterLedgerObjects(item)) @@ -1208,10 +1207,7 @@ private void AddAllNonSystemObjects(ICollection List, IEnumerable col { if (PrefetchObjects && CopySchema) { - if (prefetch != null) - { - prefetch(this.Options.GetScriptingPreferences()); - } + prefetch?.Invoke(this.Options.GetScriptingPreferences()); } else if (originalDefaultFields != null) { @@ -1423,7 +1419,7 @@ private void RestoreDefaultInitFields(Dictionary origina /// private bool CanScriptDownlevel(Urn urn, SqlServerVersion targetVersion) { - Sdk.Sfc.TraceHelper.Assert(null != urn, "null == urn"); + Debug.Assert(null != urn, "null == urn"); SqlSmoObject smoObject = this.Database.Parent.GetSmoObject(urn); @@ -1579,7 +1575,7 @@ private DependencyCollection GetDependencyOrderedCollection(HashSet transfe { //Change data entries to table entries - Sdk.Sfc.TraceHelper.Assert((urn.Type.Equals("Special") && urn.Parent.Type == "Data"), "only data entries expected"); + Debug.Assert((urn.Type.Equals("Special") && urn.Parent.Type == "Data"), "only data entries expected"); result.Add(new DependencyCollectionNode(urn.Parent.Parent, true, true)); } diff --git a/src/Microsoft/SqlServer/Management/Smo.Wmi/coll_macros.h b/src/Microsoft/SqlServer/Management/Smo.Wmi/coll_macros.h deleted file mode 100644 index cb2e1149..00000000 --- a/src/Microsoft/SqlServer/Management/Smo.Wmi/coll_macros.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef COLLECTION_SUFFIX -#define COLLECTION_SUFFIX Collection -#endif - -#ifdef SEALED -#define SEALED_IMP sealed -#else -#define SEALED_IMP -#endif - -#define IDENTITY(x) x -#define TOKEN_PASTE(x,y) IDENTITY(x)##IDENTITY(y) -#define TOKEN_PASTE3(x,y,z) IDENTITY(x)##IDENTITY(y)##IDENTITY(z) - -#define STRINGIZE(x) #x -#define STRINGER(x) STRINGIZE(x) - - -#ifndef PARTIAL_KEYWORD - #define PARTIAL_KEYWORD -#endif diff --git a/src/Microsoft/SqlServer/Management/Smo/AffinityInfo.cs b/src/Microsoft/SqlServer/Management/Smo/AffinityInfo.cs index f20bb1db..91c10d62 100644 --- a/src/Microsoft/SqlServer/Management/Smo/AffinityInfo.cs +++ b/src/Microsoft/SqlServer/Management/Smo/AffinityInfo.cs @@ -7,6 +7,7 @@ using System.Data; using System.Linq; using System.Text; +using System.Diagnostics; using Microsoft.SqlServer.Management.Sdk.Sfc; using Microsoft.SqlServer.Management.Sdk.Sfc.Metadata; diff --git a/src/Microsoft/SqlServer/Management/Smo/AlertBase.cs b/src/Microsoft/SqlServer/Management/Smo/AlertBase.cs index a1f3c9ae..8f4fe520 100644 --- a/src/Microsoft/SqlServer/Management/Smo/AlertBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/AlertBase.cs @@ -106,12 +106,8 @@ private void GetAllParams(StringBuilder sb, ScriptingPreferences sp, ref int cou GetStringParameter(sb, sp, "CategoryName", "@category_name=N'{0}'", ref count); GetStringParameter(sb, sp, "PerformanceCondition", "@performance_condition=N'{0}'", ref count); - // add wmi parameters only if version 9.0+ - if (ServerVersion.Major >= 9) - { - GetStringParameter(sb, sp, "WmiEventNamespace", "@wmi_namespace=N'{0}'", ref count); - GetStringParameter(sb, sp, "WmiEventQuery", "@wmi_query=N'{0}'", ref count); - } + GetStringParameter(sb, sp, "WmiEventNamespace", "@wmi_namespace=N'{0}'", ref count); + GetStringParameter(sb, sp, "WmiEventQuery", "@wmi_query=N'{0}'", ref count); // Attempt to script JobName only if corresponding scripting option is set, // if fail still script job id instead diff --git a/src/Microsoft/SqlServer/Management/Smo/Application.cs b/src/Microsoft/SqlServer/Management/Smo/Application.cs index 2a306ccd..68cd36d3 100644 --- a/src/Microsoft/SqlServer/Management/Smo/Application.cs +++ b/src/Microsoft/SqlServer/Management/Smo/Application.cs @@ -11,6 +11,7 @@ using System.IO; using Microsoft.SqlServer.Management.Sdk.Sfc; using Microsoft.SqlServer.Server; +using SmoEventSource = Microsoft.SqlServer.Management.Common.SmoEventSource; #pragma warning disable 1590,1591,1592,1573,1571,1570,1572,1587 namespace Microsoft.SqlServer.Management.Smo @@ -723,7 +724,7 @@ public static void Dump(bool toLogFile) { if( toLogFile ) { - Diagnostics.TraceHelper.Trace(SmoApplication.ModuleName, SmoApplication.trAlways, "{0}", s); + SmoEventSource.Log.GeneralMessage(s); } else { diff --git a/src/Microsoft/SqlServer/Management/Smo/ApplicationRoleBase.cs b/src/Microsoft/SqlServer/Management/Smo/ApplicationRoleBase.cs index 79fb883f..e13aeb7e 100644 --- a/src/Microsoft/SqlServer/Management/Smo/ApplicationRoleBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/ApplicationRoleBase.cs @@ -50,20 +50,14 @@ public ExtendedPropertyCollection ExtendedProperties private SqlSecureString password; /// - /// Scripts permissions for this object. returns without scripting anything if source version is less - /// than 9 since permissions on AppRoles were not supported in 8. + /// Scripts permissions for this object. /// /// /// internal override void AddScriptPermission(StringCollection query, ScriptingPreferences sp) { - // return if source version is less than 9 because permissions on ApplicationRoles were - // not supported prior to that - if(Parent.Parent.Information.Version.Major < 9) - { - return; - } - + // Permissions on ApplicationRoles were introduced in SQL Server 2005 (version 9). + // Since minimum supported version is now SQL Server 2008 (version 10), this is always supported. base.AddScriptPermission(query, sp); } @@ -353,12 +347,8 @@ public void ChangePassword(System.Security.SecureString password) new ArgumentNullException("password")); } - if (this.ServerVersion.Major < 9) - { - throw new FailedOperationException(ExceptionTemplates.ChangePassword, - this, - new InvalidVersionSmoOperationException(this.ServerVersion)); - } + // ChangePassword was introduced in SQL Server 2005 (version 9). + // Since minimum supported version is now SQL Server 2008 (version 10), this is always supported. try { diff --git a/src/Microsoft/SqlServer/Management/Smo/AsymmetricKeyBase.cs b/src/Microsoft/SqlServer/Management/Smo/AsymmetricKeyBase.cs index 44d8e464..496379ca 100644 --- a/src/Microsoft/SqlServer/Management/Smo/AsymmetricKeyBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/AsymmetricKeyBase.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Specialized; +using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Text; using Microsoft.SqlServer.Management.Smo.Internal; @@ -400,7 +401,7 @@ internal override void ScriptDrop(StringCollection query, ScriptingPreferences s StringBuilder sb = new StringBuilder("DROP ASYMMETRIC KEY "); sb.Append(FormatFullNameForScripting(sp)); - if (removeProviderKey && ServerVersion.Major >= 10) + if (removeProviderKey) { sb.Append(" REMOVE PROVIDER KEY"); } @@ -423,7 +424,7 @@ internal override void ScriptCreate(StringCollection query, ScriptingPreferences this.ThrowIfNotSupported(typeof(AsymmetricKey)); - Diagnostics.TraceHelper.Assert(null != createInfo, "caller should initialize createInfo it before calling"); + Debug.Assert(null != createInfo, "caller should initialize createInfo it before calling"); //build script StringBuilder sb = new StringBuilder("CREATE ASYMMETRIC KEY "); @@ -446,26 +447,26 @@ internal override void ScriptCreate(StringCollection query, ScriptingPreferences switch (createInfo.sourceType) { case AsymmetricKeySourceType.File: - Diagnostics.TraceHelper.Assert(null != createInfo.keySource, "keySource cannot be null"); + Debug.Assert(null != createInfo.keySource, "keySource cannot be null"); sb.Append("FILE = "); sb.Append(MakeSqlString(createInfo.keySource)); break; case AsymmetricKeySourceType.Executable: - Diagnostics.TraceHelper.Assert(null != createInfo.keySource, "keySource cannot be null"); + Debug.Assert(null != createInfo.keySource, "keySource cannot be null"); sb.Append("EXECUTABLE FILE = "); sb.Append(MakeSqlString(createInfo.keySource)); break; case AsymmetricKeySourceType.SqlAssembly: - Diagnostics.TraceHelper.Assert(null != createInfo.keySource, "keySource cannot be null"); + Debug.Assert(null != createInfo.keySource, "keySource cannot be null"); sb.Append("ASSEMBLY "); sb.Append(MakeSqlString(createInfo.keySource)); break; case AsymmetricKeySourceType.Provider: - Diagnostics.TraceHelper.Assert(null != createInfo.providerKeyName, "providerKeyName cannot be null"); - Diagnostics.TraceHelper.Assert(null != createInfo.providerAlgorithm, "providerAlgorithm cannot be null"); + Debug.Assert(null != createInfo.providerKeyName, "providerKeyName cannot be null"); + Debug.Assert(null != createInfo.providerAlgorithm, "providerAlgorithm cannot be null"); sb.Append("PROVIDER "); string providerName = (string)this.GetPropValue("ProviderName"); if (string.IsNullOrEmpty(providerName)) diff --git a/src/Microsoft/SqlServer/Management/Smo/AuditBase.cs b/src/Microsoft/SqlServer/Management/Smo/AuditBase.cs index 6c16eb78..e28f2135 100644 --- a/src/Microsoft/SqlServer/Management/Smo/AuditBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/AuditBase.cs @@ -6,6 +6,7 @@ using System.ComponentModel; using System.Data; using System.Text; +using System.Diagnostics; using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.Sdk.Sfc; using Microsoft.SqlServer.Management.Sdk.Sfc.Metadata; @@ -198,7 +199,7 @@ public string EnumServerAuditSpecification() string[] fields = new string[] { "Name" }; Request request = new Request(urn, fields); DataTable dt = this.ExecutionManager.GetEnumeratorData(request); - Diagnostics.TraceHelper.Assert(dt.Rows.Count <= 1, "There can be max one ServerAuditSpecification per Audit"); + Debug.Assert(dt.Rows.Count <= 1, "There can be max one ServerAuditSpecification per Audit"); if (dt.Rows.Count == 1) { return dt.Rows[0]["Name"].ToString(); diff --git a/src/Microsoft/SqlServer/Management/Smo/AuditSpecification.cs b/src/Microsoft/SqlServer/Management/Smo/AuditSpecification.cs index d2a83920..acf81dda 100644 --- a/src/Microsoft/SqlServer/Management/Smo/AuditSpecification.cs +++ b/src/Microsoft/SqlServer/Management/Smo/AuditSpecification.cs @@ -8,6 +8,7 @@ using System.Collections.Specialized; using System.Data; using System.Text; +using System.Diagnostics; using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.Sdk.Sfc; using Microsoft.SqlServer.Management.Sdk.Sfc.Metadata; @@ -101,7 +102,7 @@ public ICollection EnumAuditSpecificationDetails() { if (!isInitialized) { - Diagnostics.TraceHelper.Assert(this.Urn.Value != null, "The Urn value is null"); + Debug.Assert(this.Urn.Value != null, "The Urn value is null"); Urn urn = new Urn(this.Urn.Value + "/" + this.Urn.Type + "Detail"); Request req = new Request(urn); DataTable dt = this.ExecutionManager.GetEnumeratorData(req); diff --git a/src/Microsoft/SqlServer/Management/Smo/AvailabilityDatabaseBase.cs b/src/Microsoft/SqlServer/Management/Smo/AvailabilityDatabaseBase.cs index 12e6381f..190845a3 100644 --- a/src/Microsoft/SqlServer/Management/Smo/AvailabilityDatabaseBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/AvailabilityDatabaseBase.cs @@ -5,7 +5,6 @@ using System.Collections.Specialized; using System.Globalization; using System.Text; -using Microsoft.SqlServer.Diagnostics.STrace; using Microsoft.SqlServer.Management.Common; namespace Microsoft.SqlServer.Management.Smo @@ -215,7 +214,7 @@ public void ResumeDataMovement() internal override void ScriptCreate(System.Collections.Specialized.StringCollection query, ScriptingPreferences sp) { //sanity checks - tc.Assert(null != query, "String collection should not be null"); + System.Diagnostics.Debug.Assert(null != query, "String collection should not be null"); /* * ALTER AVAILABILITY GROUP 'group_name' @@ -271,7 +270,7 @@ internal override void ScriptCreate(System.Collections.Specialized.StringCollect internal override void ScriptDrop(System.Collections.Specialized.StringCollection dropQuery, ScriptingPreferences sp) { //sanity checks - tc.Assert(null != dropQuery, "String collection should not be null"); + System.Diagnostics.Debug.Assert(null != dropQuery, "String collection should not be null"); //ALTER AVAILABILITY GROUP 'group_name' //REMOVE DATABASE database_name <,..n> @@ -318,8 +317,6 @@ internal override void ScriptDrop(System.Collections.Specialized.StringCollectio #endregion #region private members - - private static readonly TraceContext tc = TraceContext.GetTraceContext(SmoApplication.ModuleName, "AvailabilityDatabase"); #endregion } diff --git a/src/Microsoft/SqlServer/Management/Smo/AvailabilityGroupBase.cs b/src/Microsoft/SqlServer/Management/Smo/AvailabilityGroupBase.cs index c753cc8b..923ffb19 100644 --- a/src/Microsoft/SqlServer/Management/Smo/AvailabilityGroupBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/AvailabilityGroupBase.cs @@ -6,7 +6,6 @@ using System.Data; using System.Linq; using System.Text; -using Microsoft.SqlServer.Diagnostics.STrace; using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.Sdk.Sfc; using Microsoft.SqlServer.Management.Sdk.Sfc.Metadata; @@ -495,7 +494,7 @@ internal override void ScriptCreate(System.Collections.Specialized.StringCollect */ // sanity checks - tc.Assert(null != query, "String collection should not be null"); + System.Diagnostics.Debug.Assert(null != query, "String collection should not be null"); // Ensure target server version is >= 11, and database engine is not azure ThrowIfBelowVersion110(sp.TargetServerVersion); @@ -665,7 +664,10 @@ internal override void ScriptCreate(System.Collections.Specialized.StringCollect var createScript = script.ToString(); query.Add(createScript); - tc.TraceInformation("Generated Create Script: {0}", createScript); + if (SmoEventSource.Log.IsEnabled()) + { + SmoEventSource.Log.ScriptingProgress($"Generated Create Script: {createScript}"); + } } /// @@ -701,7 +703,7 @@ internal override void ScriptAlter(StringCollection alterQuery, ScriptingPrefere */ //sanity checks - tc.Assert(null != alterQuery, "String collection should not be null"); + System.Diagnostics.Debug.Assert(null != alterQuery, "String collection should not be null"); //Ensure target server version is >= 11, and database engine is not azure ThrowIfBelowVersion110(sp.TargetServerVersion); @@ -735,7 +737,7 @@ internal override void ScriptDrop(System.Collections.Specialized.StringCollectio //DROP AVAILABILITY GROUP 'group_name' //sanity checks - tc.Assert(null != dropQuery, "String collection for the drop query should not be null"); + System.Diagnostics.Debug.Assert(null != dropQuery, "String collection for the drop query should not be null"); //Ensure target server version is >= 11, and database engine is not azure ThrowIfBelowVersion110(sp.TargetServerVersion); @@ -766,7 +768,10 @@ internal override void ScriptDrop(System.Collections.Specialized.StringCollectio string dropScript = script.ToString(); dropQuery.Add(dropScript); - tc.TraceInformation("Generated drop script: " + dropScript); + if (SmoEventSource.Log.IsEnabled()) + { + SmoEventSource.Log.ScriptingProgress($"Generated drop script: {dropScript}"); + } } /// @@ -950,8 +955,6 @@ internal static string GetAvailabilityGroupClusterType(AvailabilityGroupClusterT #region Private members - private static readonly TraceContext tc = TraceContext.GetTraceContext(SmoApplication.ModuleName, "AvailabilityGroup"); - private bool IsDirty(string property) { return this.Properties.IsDirty(this.Properties.LookupID(property, PropertyAccessPurpose.Read)); diff --git a/src/Microsoft/SqlServer/Management/Smo/AvailabilityGroupListenerBase.cs b/src/Microsoft/SqlServer/Management/Smo/AvailabilityGroupListenerBase.cs index 1cb7065b..28be4e9a 100644 --- a/src/Microsoft/SqlServer/Management/Smo/AvailabilityGroupListenerBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/AvailabilityGroupListenerBase.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Specialized; using System.Text; -using Microsoft.SqlServer.Diagnostics.STrace; using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.Sdk.Sfc.Metadata; @@ -168,7 +167,7 @@ public StringCollection Script(ScriptingOptions scriptingOptions) internal override void ScriptCreate(System.Collections.Specialized.StringCollection query, ScriptingPreferences sp) { // sanity checks - tc.Assert(null != query, "String collection should not be null"); + System.Diagnostics.Debug.Assert(null != query, "String collection should not be null"); /* * ALTER AVAILABILITY GROUP 'group_name' @@ -344,7 +343,7 @@ internal string ScriptListenerOptions() internal override void ScriptAlter(StringCollection query, ScriptingPreferences sp) { // sanity checks - tc.Assert(null != query, "String collection should not be null"); + System.Diagnostics.Debug.Assert(null != query, "String collection should not be null"); /* * ALTER AVAILABILITY GROUP 'group_name' @@ -402,7 +401,7 @@ internal override void ScriptAlter(StringCollection query, ScriptingPreferences internal override void ScriptDrop(System.Collections.Specialized.StringCollection dropQuery, ScriptingPreferences sp) { // sanity checks - tc.Assert(null != dropQuery, "String collection should not be null"); + System.Diagnostics.Debug.Assert(null != dropQuery, "String collection should not be null"); // ALTER AVAILABILITY GROUP ag_name // REMOVE LISTENER 'dnsName' @@ -498,7 +497,6 @@ protected override void PostCreate() #region private members - private static readonly TraceContext tc = TraceContext.GetTraceContext(SmoApplication.ModuleName, "AvailabilityGroupListener"); private AvailabilityGroupListenerIPAddressCollection availabilityGroupListenerIPAddresses = null; #endregion diff --git a/src/Microsoft/SqlServer/Management/Smo/AvailabilityGroupListenerIPAddressBase.cs b/src/Microsoft/SqlServer/Management/Smo/AvailabilityGroupListenerIPAddressBase.cs index 7ee8dc64..98fc2c05 100644 --- a/src/Microsoft/SqlServer/Management/Smo/AvailabilityGroupListenerIPAddressBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/AvailabilityGroupListenerIPAddressBase.cs @@ -6,7 +6,6 @@ using System.Data; using System.Globalization; using System.Text; -using Microsoft.SqlServer.Diagnostics.STrace; using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.Sdk.Sfc; using Microsoft.SqlServer.Management.Sdk.Sfc.Metadata; @@ -210,7 +209,7 @@ public StringCollection Script(ScriptingOptions scriptingOptions) internal override void ScriptCreate(System.Collections.Specialized.StringCollection query, ScriptingPreferences sp) { // sanity checks - tc.Assert(null != query, "String collection should not be null"); + System.Diagnostics.Debug.Assert(null != query, "String collection should not be null"); /* * ALTER AVAILABILITY GROUP 'group_name' @@ -278,7 +277,7 @@ internal override void ScriptCreate(System.Collections.Specialized.StringCollect internal override void ScriptDrop(StringCollection query, ScriptingPreferences sp) { // sanity checks - tc.Assert(query != null, "String collection for the drop query should not be null"); + System.Diagnostics.Debug.Assert(query != null, "String collection for the drop query should not be null"); /* * ALTER AVAILABILITY GROUP 'group_name' @@ -402,7 +401,6 @@ internal void FetchKeyPostCreate() #region private members - private static readonly TraceContext tc = TraceContext.GetTraceContext(SmoApplication.ModuleName, "AvailabilityGroupListenerIPAddress"); private const string IPScript = "IP"; #endregion diff --git a/src/Microsoft/SqlServer/Management/Smo/AvailabilityReplicaBase.cs b/src/Microsoft/SqlServer/Management/Smo/AvailabilityReplicaBase.cs index 11b26979..d011f06f 100644 --- a/src/Microsoft/SqlServer/Management/Smo/AvailabilityReplicaBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/AvailabilityReplicaBase.cs @@ -7,7 +7,6 @@ using System.Linq; using System.Text; -using Microsoft.SqlServer.Diagnostics.STrace; using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.Sdk.Sfc; using Microsoft.SqlServer.Management.Sdk.Sfc.Metadata; @@ -353,7 +352,7 @@ internal override void ScriptCreate(System.Collections.Specialized.StringCollect */ //sanity checks - tc.Assert(null != query, "String collection should not be null"); + System.Diagnostics.Debug.Assert(null != query, "String collection should not be null"); //Ensure target server version is >= 11, and database engine is not azure ThrowIfBelowVersion110(sp.TargetServerVersion); @@ -454,7 +453,7 @@ internal override void ScriptAlter(StringCollection query, ScriptingPreferences */ //sanity checks - tc.Assert(null != query, "String collection should not be null"); + System.Diagnostics.Debug.Assert(null != query, "String collection should not be null"); //Ensure target server version is >= 11, and database engine is not azure ThrowIfBelowVersion110(sp.TargetServerVersion); @@ -566,7 +565,7 @@ internal string ScriptAlterOneOption(string propertyName, ScriptingPreferences s internal override void ScriptDrop(System.Collections.Specialized.StringCollection dropQuery, ScriptingPreferences sp) { //sanity checks - tc.Assert(null != dropQuery, "String collection should not be null"); + System.Diagnostics.Debug.Assert(null != dropQuery, "String collection should not be null"); //ALTER AVAILABILITY GROUP group_name //REMOVE REPLICA ON server_name @@ -949,8 +948,6 @@ private String ReadonlyRoutingListDelimited get { return (String)this.Properties.GetValueWithNullReplacement("ReadonlyRoutingListDelimited"); } } - private static readonly TraceContext tc = TraceContext.GetTraceContext(SmoApplication.ModuleName, "AvailabilityReplica"); - private bool IsDirty(string property) { return this.Properties.IsDirty(this.Properties.LookupID(property, PropertyAccessPurpose.Read)); @@ -974,7 +971,7 @@ private bool IsAlterableProperty(string propertyName) PropertyType propertyType; bool found = AlterableReplicaProperties.TryGetValue(propertyName, out propertyType); - tc.Assert(found, "Invalid property name: " + propertyName); + System.Diagnostics.Debug.Assert(found, "Invalid property name: " + propertyName); return (propertyType & PropertyType.Alterable) == PropertyType.Alterable; } @@ -984,7 +981,7 @@ private bool IsPrimaryRoleProperty(string propertyName) PropertyType propertyType; bool found = AlterableReplicaProperties.TryGetValue(propertyName, out propertyType); - tc.Assert(found, "Invalid property name: " + propertyName); + System.Diagnostics.Debug.Assert(found, "Invalid property name: " + propertyName); return (propertyType & PropertyType.PrimaryRoleProperty) == PropertyType.PrimaryRoleProperty; } @@ -994,7 +991,7 @@ private bool IsSecondaryRoleProperty(string propertyName) PropertyType propertyType; bool found = AlterableReplicaProperties.TryGetValue(propertyName, out propertyType); - tc.Assert(found, "Invalid property name: " + propertyName); + System.Diagnostics.Debug.Assert(found, "Invalid property name: " + propertyName); return (propertyType & PropertyType.SecondaryRoleProperty) == PropertyType.SecondaryRoleProperty; } diff --git a/src/Microsoft/SqlServer/Management/Smo/BackupMedia.cs b/src/Microsoft/SqlServer/Management/Smo/BackupMedia.cs index 8325f808..d7cb3b11 100644 --- a/src/Microsoft/SqlServer/Management/Smo/BackupMedia.cs +++ b/src/Microsoft/SqlServer/Management/Smo/BackupMedia.cs @@ -478,17 +478,7 @@ private void Populate(int mediaSetID) { String query = null; //BackupMediaSet properties - if (this.server.Version.Major < 9) - { - query = string.Format(SmoApplication.DefaultCulture, - "SELECT bkms.media_uuid, bkms.name, bkms.description, bkms.media_family_count FROM msdb.dbo.backupmediaset bkms WHERE bkms.media_set_id = {0}", mediaSetID); - } - else if (this.server.Version.Major == 9) - { - query = string.Format(SmoApplication.DefaultCulture, - "SELECT bkms.media_uuid, bkms.name, bkms.description, bkms.media_family_count, bkms.mirror_count FROM msdb.dbo.backupmediaset bkms WHERE bkms.media_set_id = {0}", mediaSetID); - } - else if (this.server.Version.Major <= 11) + if (this.server.Version.Major <= 11) { query = string.Format(SmoApplication.DefaultCulture, "SELECT bkms.media_uuid, bkms.name, bkms.description, bkms.media_family_count, bkms.mirror_count, bkms.is_compressed FROM msdb.dbo.backupmediaset bkms WHERE bkms.media_set_id = {0}", mediaSetID); @@ -513,22 +503,12 @@ private void Populate(int mediaSetID) { this.mediaSetGuid = (Guid)datarow["media_uuid"]; } - if (this.server.Version.Major >= 9) - { - this.mirrorCount = (byte)datarow["mirror_count"]; - } + this.mirrorCount = (byte)datarow["mirror_count"]; //BackupMedia properties - if (this.server.Version.Major < 9) - { - query = string.Format(SmoApplication.DefaultCulture, - "SELECT bkms.logical_device_name, bkms.physical_device_name, bkms.device_type, family_sequence_number FROM msdb.dbo.backupmediafamily bkms WHERE bkms.media_set_id = {0} ORDER BY bkms.family_sequence_number", mediaSetID); - } - else - { - query = string.Format(SmoApplication.DefaultCulture, + query = string.Format(SmoApplication.DefaultCulture, "SELECT bkms.logical_device_name, bkms.physical_device_name, bkms.device_type, family_sequence_number, mirror FROM msdb.dbo.backupmediafamily bkms WHERE bkms.media_set_id = {0} ORDER BY bkms.family_sequence_number, bkms.mirror", mediaSetID); - } + DataSet ds = server.ExecutionManager.ExecuteWithResults(query); foreach (DataRow dr1 in ds.Tables[0].Rows) @@ -563,10 +543,7 @@ private void Populate(List backupMediaList) this.description = (string)datarow["MediaDescription"]; } this.familyCount = (byte)(int)datarow["FamilyCount"]; - if (this.server.Version.Major >= 9) - { - this.mirrorCount = (byte)(int)datarow["MirrorCount"]; - } + this.mirrorCount = (byte)(int)datarow["MirrorCount"]; if (datarow["MediaSetId"] is Guid) { this.mediaSetGuid = (Guid)datarow["MediaSetId"]; diff --git a/src/Microsoft/SqlServer/Management/Smo/BackupSet.cs b/src/Microsoft/SqlServer/Management/Smo/BackupSet.cs index 0dd5e9d0..f261326d 100644 --- a/src/Microsoft/SqlServer/Management/Smo/BackupSet.cs +++ b/src/Microsoft/SqlServer/Management/Smo/BackupSet.cs @@ -1,8 +1,9 @@ -// Copyright (c) Microsoft Corporation. +// Copyright (c) Microsoft Corporation. // Licensed under the MIT license. using System; using System.Linq; +using System.Diagnostics; using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.Sdk.Sfc; using System.Data; @@ -1305,7 +1306,7 @@ internal static bool IsBackupSetsInSequence(BackupSet first, BackupSet second, o { //Not supported for version less than 9 - Diagnostics.TraceHelper.Assert(first != null && second != null); + Debug.Assert(first != null && second != null); stopAtLsn = 0m; errMsg = null; errSource = null; diff --git a/src/Microsoft/SqlServer/Management/Smo/BackupSetCollection.cs b/src/Microsoft/SqlServer/Management/Smo/BackupSetCollection.cs index 3f8cfe22..591fd733 100644 --- a/src/Microsoft/SqlServer/Management/Smo/BackupSetCollection.cs +++ b/src/Microsoft/SqlServer/Management/Smo/BackupSetCollection.cs @@ -73,9 +73,9 @@ private void GetBackupSetsFromMsdb(bool includeSnapshotBackups) { DataSet ds = null; String query = null; - var snapshotClause = (this.server.ServerVersion.Major < 9 || includeSnapshotBackups) ? string.Empty : "and bkps.is_snapshot = 0"; + var snapshotClause = includeSnapshotBackups ? string.Empty : "and bkps.is_snapshot = 0"; - if (this.server.ServerVersion.Major < 9 || parent == null || this.parent.Status == DatabaseStatus.Offline) + if (parent == null || this.parent.Status == DatabaseStatus.Offline) { query = string.Format(SmoApplication.DefaultCulture, "SELECT bkps.backup_set_uuid FROM msdb.dbo.backupset bkps WHERE bkps.database_name = {0} {1} ORDER BY bkps.backup_set_id ASC", diff --git a/src/Microsoft/SqlServer/Management/Smo/CertificateBase.cs b/src/Microsoft/SqlServer/Management/Smo/CertificateBase.cs index b4dd9e46..a7fdb95f 100644 --- a/src/Microsoft/SqlServer/Management/Smo/CertificateBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/CertificateBase.cs @@ -6,6 +6,7 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text; +using System.Diagnostics; using Microsoft.SqlServer.Management.Common; namespace Microsoft.SqlServer.Management.Smo @@ -528,7 +529,7 @@ internal override void ScriptAlter(StringCollection query, ScriptingPreferences StringBuilder sb = GetCertificateBuilder("ALTER", sp); //cannot be null if dirty - Diagnostics.TraceHelper.Assert(null != prop.Value); + Debug.Assert(null != prop.Value); AddToStringBuilderIfNotNull(sb, " WITH ACTIVE FOR BEGIN_DIALOG = ", prop.Value, false); @@ -601,7 +602,7 @@ private void ImportInternal(string certificateSource, CertificateSourceType sour } // add the source - Diagnostics.TraceHelper.Assert(null != certificateSource, "certificateSource cannot be null"); + Debug.Assert(null != certificateSource, "certificateSource cannot be null"); sb.Append(" FROM "); switch (sourceType) { diff --git a/src/Microsoft/SqlServer/Management/Smo/Collections/EdgeCollection.cs b/src/Microsoft/SqlServer/Management/Smo/Collections/EdgeCollection.cs deleted file mode 100644 index 511a23c1..00000000 --- a/src/Microsoft/SqlServer/Management/Smo/Collections/EdgeCollection.cs +++ /dev/null @@ -1,253 +0,0 @@ - - /////////////////////////////////////////////////////////////// - // - // WARNING : DO NOT ATTEMPT TO MODIFY THIS FILE MANUALLY - // - // This class is autogenerated from generic_collection.cs - // - /////////////////////////////////////////////////////////////// - -using System; -using System.Collections; -using System.Collections.Specialized; -using System.Text; -using System.Globalization; -#pragma warning disable 1590,1591,1592,1573,1571,1570,1572,1587 - - - -using Microsoft.SqlServer.Management.Sdk.Sfc; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -namespace Microsoft.SqlServer.Management.Smo -{ - - /// - /// Strongly typed list of MAPPED_TYPE objects - /// Has strongly typed support for all of the methods of the sorted list class - /// - public sealed class EdgeCollection : SimpleObjectCollectionBase - { - - - - - - - - - - - - - - - - - - - internal EdgeCollection(SqlSmoObject parentInstance) : base(parentInstance) - { - } - - - - public SqlSmoObject Parent - { - get - { - return this.ParentInstance as SqlSmoObject; - } - } - - - public Edge this[Int32 index] - { - get - { - return GetObjectByIndex(index) as Edge; - } - } - - - // returns wrapper class - public Edge this[string name] - { - get - { - - - - - - - - return GetObjectByName(name) as Edge; - - - - - - - - - - - - - - - - - - - - - - } - } - - - public void CopyTo(Edge[] array, int index) - { - ((ICollection)this).CopyTo(array, index); - } - - - public Edge ItemById(int id) - { - return (Edge)GetItemById(id); - } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - protected override Type GetCollectionElementType() - { - return typeof(Edge); - } - - internal override SqlSmoObject GetCollectionElementInstance(ObjectKeyBase key, SqlSmoState state) - { - return new Edge(this, key, state); - } - - - - - public void Remove(Edge edge) - { - if( null == edge ) - throw new FailedOperationException(ExceptionTemplates.RemoveCollection, this, new ArgumentNullException("edge")); - - RemoveObj(edge, new SimpleObjectKey(edge.Name)); - } - - public void Remove(string name) - { - this.Remove(new SimpleObjectKey(name)); - } - - - - public void Add(Edge edge) - { - AddImpl(edge); - } - - - internal SqlSmoObject GetObjectByName(string name) - { - return GetObjectByKey(new SimpleObjectKey(name)); - } - - - internal override ObjectKeyBase CreateKeyFromUrn(Urn urn) - { - string name = urn.GetAttribute("Name"); - - - - if( null == name || name.Length == 0) - - throw new SmoException(ExceptionTemplates.PropertyMustBeSpecifiedInUrn("Name", urn.Type)); - return new SimpleObjectKey(name); - } - - - - - - - - - - - - - - - - - - - } -} diff --git a/src/Microsoft/SqlServer/Management/Smo/Collections/ExternalModelCollection.cs b/src/Microsoft/SqlServer/Management/Smo/Collections/ExternalModelCollection.cs new file mode 100644 index 00000000..13e64a06 --- /dev/null +++ b/src/Microsoft/SqlServer/Management/Smo/Collections/ExternalModelCollection.cs @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +namespace Microsoft.SqlServer.Management.Smo +{ + public sealed partial class ExternalModelCollection : SimpleObjectCollectionBase + { + } +} \ No newline at end of file diff --git a/src/Microsoft/SqlServer/Management/Smo/ColumnBase.cs b/src/Microsoft/SqlServer/Management/Smo/ColumnBase.cs index 7d4b2e87..16abde12 100644 --- a/src/Microsoft/SqlServer/Management/Smo/ColumnBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/ColumnBase.cs @@ -9,6 +9,7 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Text; +using System.Diagnostics; using Microsoft.SqlServer.Management.Sdk.Sfc; using Microsoft.SqlServer.Management.Sdk.Sfc.Metadata; @@ -508,32 +509,30 @@ private void ScriptDdlCreateImpl(StringBuilder sb, ScriptingPreferences sp) { throw new WrongPropertyValueException(ExceptionTemplates.NoDataMaskingOnComputedColumns); } - if (sp.TargetServerVersion >= SqlServerVersion.Version90 && - this.ServerVersion.Major >= 9) + // PERSISTED keyword for computed columns is supported since SQL Server 2005 (Version90) + // Since minimum supported version is now SQL Server 2008 (Version100), this is always available + if (GetPropValueOptional("IsPersisted", false)) { - if (GetPropValueOptional("IsPersisted", false)) + sb.Append(" PERSISTED"); + //you can set a computed column to be not null if it is persisted + if (!GetPropValueOptional("Nullable", false)) { - sb.Append(" PERSISTED"); - //you can set a computed column to be not null if it is persisted - if (!GetPropValueOptional("Nullable", false)) - { - sb.Append(" NOT NULL"); - } + sb.Append(" NOT NULL"); } + } - if (Cmn.DatabaseEngineType.SqlAzureDatabase != sp.TargetDatabaseEngineType) + if (Cmn.DatabaseEngineType.SqlAzureDatabase != sp.TargetDatabaseEngineType) + { + // we need to force the collation of the computed columns + // when we script optimizer data because it is dependent on the + // collation of the database and it might not match the stats blob + if (sp.Data.OptimizerData && RequiresCollate(sp)) { - // we need to force the collation of the computed columns - // when we script optimizer data because it is dependent on the - // collation of the database and it might not match the stats blob - if (sp.Data.OptimizerData && RequiresCollate(sp)) + string sCollation = Properties.Get("Collation").Value as string; + if (null != sCollation && 0 < sCollation.Length) { - string sCollation = Properties.Get("Collation").Value as string; - if (null != sCollation && 0 < sCollation.Length) - { - CheckCollation(sCollation, sp); - sb.AppendFormat(SmoApplication.DefaultCulture, " COLLATE {0}", sCollation); - } + CheckCollation(sCollation, sp); + sb.AppendFormat(SmoApplication.DefaultCulture, " COLLATE {0}", sCollation); } } } @@ -692,7 +691,7 @@ private void ScriptDdlCreateImpl(StringBuilder sb, ScriptingPreferences sp) case GeneratedAlwaysType.None: break; default: - Diagnostics.TraceHelper.Assert(false, "Unknown 'GeneratedAlwaysType' property value encountered."); + Debug.Assert(false, "Unknown 'GeneratedAlwaysType' property value encountered."); break; } @@ -906,7 +905,7 @@ private SqlDataType GetNativeDataType() /// private void CheckSupportedType(ScriptingPreferences options) { - Diagnostics.TraceHelper.Assert(options != null); + Debug.Assert(options != null); // Get the SqlDataType for the column, in the event // that it's a UDDT and we need to infer it's underlying type @@ -1162,18 +1161,18 @@ internal override void ScriptAlter(StringCollection alterQuery, ScriptingPrefere } // mark the column as persisted if needed - if (sp.TargetServerVersion >= SqlServerVersion.Version90) + // PERSISTED keyword for computed columns is supported since SQL Server 2005 (Version90) + // Since minimum supported version is now SQL Server 2008 (Version100), this is always available + Property propPersisted = Properties.Get("IsPersisted"); + if (propPersisted.Dirty) { - Property propPersisted = Properties.Get("IsPersisted"); - if (propPersisted.Dirty) - { - alterQuery.Add(string.Format(SmoApplication.DefaultCulture, - "ALTER TABLE {0} ALTER COLUMN {1} {2} PERSISTED", - ParentColl.ParentInstance.FullQualifiedName, FullQualifiedName, - (bool)propPersisted.Value ? "ADD" : "DROP")); - } + alterQuery.Add(string.Format(SmoApplication.DefaultCulture, + "ALTER TABLE {0} ALTER COLUMN {1} {2} PERSISTED", + ParentColl.ParentInstance.FullQualifiedName, FullQualifiedName, + (bool)propPersisted.Value ? "ADD" : "DROP")); } + bool isColumnSet = false; bool isGeneratedAlwaysColumn = false; bool isComputedColumn = false; @@ -1558,8 +1557,8 @@ internal DefaultConstraint GetDefaultConstraintBaseByName(string name) /// that is we have to init all properties internal void InitializeDefault(System.Data.IDataReader reader, int colIdx, bool forScripting) { - Diagnostics.TraceHelper.Assert(null != reader, "reader == null"); - Diagnostics.TraceHelper.Assert(colIdx < reader.FieldCount, "colIdx >= reader.FieldCount"); + Debug.Assert(null != reader, "reader == null"); + Debug.Assert(colIdx < reader.FieldCount, "colIdx >= reader.FieldCount"); // // initalize the default @@ -1585,16 +1584,16 @@ internal void InitializeDefault(System.Data.IDataReader reader, int colIdx, bool } catch (IndexOutOfRangeException) { - Diagnostics.TraceHelper.Assert(false, + Debug.Assert(false, "Text column should be present when initializing for scripting" + " or if it is an init field"); } Object oText = reader.GetValue(textColumnIdx); - Diagnostics.TraceHelper.Assert(propText.Type.Equals(typeof (string)), + Debug.Assert(propText.Type.Equals(typeof (string)), "text for the default should be of type string"); - Diagnostics.TraceHelper.Assert(null != oText, "enumerator is expected to return DBNull instead of null"); + Debug.Assert(null != oText, "enumerator is expected to return DBNull instead of null"); if (DBNull.Value.Equals(oText)) { @@ -1622,16 +1621,16 @@ internal void InitializeDefault(System.Data.IDataReader reader, int colIdx, bool } catch (IndexOutOfRangeException) { - Diagnostics.TraceHelper.Assert(false, + Debug.Assert(false, "IsSystemNamed column should be present when initializing for scripting" + " or if it is an init field"); } Object oSysName = reader.GetValue(isSystemNamedColumnIdx); - Diagnostics.TraceHelper.Assert(propSysName.Type.Equals(typeof (bool)), + Debug.Assert(propSysName.Type.Equals(typeof (bool)), "IsSystemNamed should be of type bool"); - Diagnostics.TraceHelper.Assert(null != oSysName, + Debug.Assert(null != oSysName, "enumerator is expected to return DBNull instead of null"); if (DBNull.Value.Equals(oSysName)) @@ -1656,16 +1655,16 @@ internal void InitializeDefault(System.Data.IDataReader reader, int colIdx, bool } catch (IndexOutOfRangeException) { - Diagnostics.TraceHelper.Assert(false, + Debug.Assert(false, "IsFileTableDefined column should be present when initializing for scripting" + " or if it is an init field"); } Object oSysName = reader.GetValue(isFileTableDefinedIdx); - Diagnostics.TraceHelper.Assert(propIsFileTableDefined.Type.Equals(typeof(bool)), + Debug.Assert(propIsFileTableDefined.Type.Equals(typeof(bool)), "IsFileTableDefined should be of type bool"); - Diagnostics.TraceHelper.Assert(null != oSysName, + Debug.Assert(null != oSysName, "enumerator is expected to return DBNull instead of null"); if (DBNull.Value.Equals(oSysName)) @@ -1776,8 +1775,9 @@ internal override PropagateInfo[] GetPropagateInfo(PropagateAction action) ArrayList propInfo = new ArrayList(); if (this.IsSupportedObject()) { - propInfo.Add(new PropagateInfo(ServerVersion.Major < 8 ? null : ExtendedProperties, true, - ExtendedProperty.UrnSuffix)); + // Extended Properties are supported since SQL Server 2000 (version 8) + // Since minimum supported version is now SQL Server 2008 (version 10), they are always available + propInfo.Add(new PropagateInfo(ExtendedProperties, true, ExtendedProperty.UrnSuffix)); } if (this.Parent is Table) { @@ -1974,70 +1974,33 @@ private void ValidatePropertyChangeForText(Property prop, object value) /// internal override void ValidateProperty(Property prop, object value) { - switch (this.ServerVersion.Major) + switch (prop.Name) { - case 7: - switch (prop.Name) - { - case "Computed": - ValidatePropertyChangeForText(prop, value); - break; - case "ComputedText": goto case "Computed"; - case "Default": goto case "Computed"; - case "DefaultSchema": goto case "Computed"; - case "Identity": goto case "Computed"; - case "IdentityIncrement": goto case "Computed"; - case "IdentityIncrementAsDecimal": goto case "Computed"; - case "IdentitySeed": goto case "Computed"; - case "IdentitySeedAsDecimal": goto case "Computed"; - case "NotForReplication": goto case "Computed"; - case "Nullable": goto case "Computed"; - case "RowGuidCol": - if (!prop.Dirty) - { - oldRowGuidColValue = prop.Value; - } - goto case "Computed"; - case "Rule": goto case "Computed"; - case "RuleSchema": goto case "Computed"; - - default: - // other properties are not validated - break; - } + case "Collation": + ValidatePropertyChangeForText(prop, value); break; - case 8: - switch (prop.Name) + case "Computed": goto case "Collation"; + case "ComputedText": goto case "Collation"; + case "Default": goto case "Collation"; + case "DefaultSchema": goto case "Collation"; + case "Identity": goto case "Collation"; + case "IdentityIncrement": goto case "Collation"; + case "IdentitySeed": goto case "Collation"; + case "IdentityIncrementAsDecimal": goto case "Collation"; + case "IdentitySeedAsDecimal": goto case "Collation"; + case "NotForReplication": goto case "Collation"; + case "Nullable": goto case "Collation"; + case "RowGuidCol": + if (!prop.Dirty) { - case "Collation": - ValidatePropertyChangeForText(prop, value); - break; - case "Computed": goto case "Collation"; - case "ComputedText": goto case "Collation"; - case "Default": goto case "Collation"; - case "DefaultSchema": goto case "Collation"; - case "Identity": goto case "Collation"; - case "IdentityIncrement": goto case "Collation"; - case "IdentitySeed": goto case "Collation"; - case "IdentityIncrementAsDecimal": goto case "Collation"; - case "IdentitySeedAsDecimal": goto case "Collation"; - case "NotForReplication": goto case "Collation"; - case "Nullable": goto case "Collation"; - case "RowGuidCol": - if (!prop.Dirty) - { - oldRowGuidColValue = prop.Value; - } - goto case "Collation"; - case "Rule": goto case "Collation"; - case "RuleSchema": goto case "Collation"; - default: - // other properties are not validated - break; + oldRowGuidColValue = prop.Value; } + goto case "Collation"; + case "Rule": goto case "Collation"; + case "RuleSchema": goto case "Collation"; + default: + // other properties are not validated break; - case 9: goto case 8; - default: goto case 9; } } @@ -2067,7 +2030,7 @@ internal static string[] GetScriptFields(Type parentType, bool defaultTextMode) { // Column should always have a parent,. - Diagnostics.TraceHelper.Assert(null != parentType, "null == parentType"); + Debug.Assert(null != parentType, "null == parentType"); // in the case of views we don't need to prefetch all those // properties for scripting if (!parentType.Equals(typeof(View)) || !defaultTextMode) diff --git a/src/Microsoft/SqlServer/Management/Smo/Configuration.cs b/src/Microsoft/SqlServer/Management/Smo/Configuration.cs index 2fdf754e..48b90abd 100644 --- a/src/Microsoft/SqlServer/Management/Smo/Configuration.cs +++ b/src/Microsoft/SqlServer/Management/Smo/Configuration.cs @@ -583,11 +583,6 @@ public ConfigProperty WebXPsEnabled get { Version serverVersion = Parent.Version; - if(serverVersion.Major < 10) - { - return new ConfigProperty(this, 16389); - } - //web assistant XPs have been removed since SQL Server 2008. throw new UnsupportedVersionException(ExceptionTemplates.UnsupportedVersion(serverVersion.Major.ToString())); } diff --git a/src/Microsoft/SqlServer/Management/Smo/ConfigurationBase.cs b/src/Microsoft/SqlServer/Management/Smo/ConfigurationBase.cs index ab7a3f3b..bea73a55 100644 --- a/src/Microsoft/SqlServer/Management/Smo/ConfigurationBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/ConfigurationBase.cs @@ -126,7 +126,7 @@ bool ShowAdvancedOptionsIsSet() string GetSchema() { - return m_server.ServerVersion.Major < 9 ? "master.dbo" : "sys"; + return "sys"; } private void ScriptAlterWithStatistics(StringCollection configStrings, diff --git a/src/Microsoft/SqlServer/Management/Smo/CredentialBase.cs b/src/Microsoft/SqlServer/Management/Smo/CredentialBase.cs index b5701453..f4b9faf0 100644 --- a/src/Microsoft/SqlServer/Management/Smo/CredentialBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/CredentialBase.cs @@ -242,18 +242,8 @@ public StringCollection EnumLogins() else { DataTable dataTable; - if (ServerVersion.Major < 10) - { - string loginUrn = String.Format(SmoApplication.DefaultCulture, - this.Parent.Urn.Value + "/Login[@Credential = '{0}']", Urn.EscapeString(this.Name)); - Request req = new Request(loginUrn, new string[] { "Name" }); - dataTable = this.ExecutionManager.GetEnumeratorData(req); - } - else - { - string query = string.Format(SmoApplication.DefaultCulture, "select name from sys.server_principal_credentials as c join sys.server_principals as p on p.principal_id = c.principal_id where c.credential_id = {0}", this.ID.ToString()); - dataTable = this.ExecutionManager.ExecuteWithResults(query).Tables[0]; - } + string query = string.Format(SmoApplication.DefaultCulture, "select name from sys.server_principal_credentials as c join sys.server_principals as p on p.principal_id = c.principal_id where c.credential_id = {0}", this.ID.ToString()); + dataTable = this.ExecutionManager.ExecuteWithResults(query).Tables[0]; foreach (DataRow row in dataTable.Rows) { @@ -329,7 +319,7 @@ private string CreateAlterScript(bool create, ScriptingPreferences sp) this.secret = null; } - if (create && ServerVersion.Major >= 10) + if (create) { Property mappedClassType = Properties.Get("MappedClassType"); if (mappedClassType.Dirty && (MappedClassType)mappedClassType.Value == MappedClassType.CryptographicProvider) diff --git a/src/Microsoft/SqlServer/Management/Smo/DataEnumerator.cs b/src/Microsoft/SqlServer/Management/Smo/DataEnumerator.cs index 8c75029d..0c7fb463 100644 --- a/src/Microsoft/SqlServer/Management/Smo/DataEnumerator.cs +++ b/src/Microsoft/SqlServer/Management/Smo/DataEnumerator.cs @@ -13,6 +13,7 @@ using System.Data; using System.Diagnostics; using System.Globalization; +using SmoEventSource = Microsoft.SqlServer.Management.Common.SmoEventSource; #pragma warning disable 1590,1591,1592,1573,1571,1570,1572,1587 namespace Microsoft.SqlServer.Management.Smo @@ -364,7 +365,7 @@ public bool MoveNext() moveNext = false; break; default: - Diagnostics.TraceHelper.Assert(false, "Bug in dev code"); + Debug.Assert(false, "Bug in dev code"); throw new Exception("Unknown state"); } @@ -375,7 +376,7 @@ public bool MoveNext() if (moveNext == null) { - Diagnostics.TraceHelper.Assert(false, "MoveNext not initialized. Bug in code"); + Debug.Assert(false, "MoveNext not initialized. Bug in code"); throw new Exception("MoveNext not initialized. Bug in code"); } return moveNext.Value; @@ -964,22 +965,10 @@ private string FormatValueByType(string columnName, int columnIndex) formattedValue = this.FormatSqlVariantValue(columnIndex); break; - case SqlDataType.Json: - formattedValue = String.Format( - CultureInfo.InvariantCulture, - "CAST({0} AS Json)", SqlSmoObject.MakeSqlString(this.reader.GetProviderSpecificValue(columnIndex).ToString())); - break; - case SqlDataType.Vector: - string sqlStringValue = SqlSmoObject.MakeSqlString(this.reader.GetProviderSpecificValue(columnIndex).ToString()); - if (!string.IsNullOrEmpty(columnData.VectorBaseType)) - { - formattedValue = $"CAST({sqlStringValue} AS Vector({columnData.VectorDimensions}, {columnData.VectorBaseType}))"; - } - else - { - formattedValue = $"CAST({sqlStringValue} AS Vector({columnData.VectorDimensions}))"; - } + // GetString returns JSON-encoded Vector data + case SqlDataType.Json: + formattedValue = SqlSmoObject.MakeSqlString(reader.GetString(columnIndex)); break; default: @@ -987,7 +976,7 @@ private string FormatValueByType(string columnName, int columnIndex) // to support types that we don't understand. // - Diagnostics.TraceHelper.Trace(SmoApplication.ModuleName, SmoApplication.trAlways, $"ERROR: Attempting to script data for type {columnData.DataType}"); + SmoEventSource.Log.DataTypeScriptingError(columnData.DataType.ToString()); throw new InvalidSmoOperationException( ExceptionTemplates.DataScriptingUnsupportedDataTypeException( diff --git a/src/Microsoft/SqlServer/Management/Smo/DataType.cs b/src/Microsoft/SqlServer/Management/Smo/DataType.cs index 80b186f2..20d74e53 100644 --- a/src/Microsoft/SqlServer/Management/Smo/DataType.cs +++ b/src/Microsoft/SqlServer/Management/Smo/DataType.cs @@ -5,6 +5,7 @@ using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Xml.Serialization; +using System.Diagnostics; using Microsoft.SqlServer.Management.Common; namespace Microsoft.SqlServer.Management.Smo @@ -981,14 +982,7 @@ public SqlDataType SqlDataType { parent.Properties.Get("Length").Value = -1; } - if (parent.ServerVersion.Major >= 9) - { - schema = "sys"; - } - else - { - schema = "dbo"; - } + schema = "sys"; } else { @@ -1261,7 +1255,7 @@ internal void ReadFromPropBag(SqlSmoObject sqlObject) string dt = sqlObject.GetPropValueOptional("DataType", string.Empty) as string; string st = sqlObject.GetPropValueOptional("SystemType", string.Empty) as string; - if (sqlObject is Parameter && !(sqlObject is NumberedStoredProcedureParameter) && parent.ServerVersion.Major >= 10) + if (sqlObject is Parameter && !(sqlObject is NumberedStoredProcedureParameter)) { bool isReadOnly = (bool)(sqlObject.GetPropValueOptional("IsReadOnly", false)); if (isReadOnly) // IsReadOnly is true only for Parameters of UserDefinedTableType type @@ -1454,7 +1448,7 @@ internal static SqlDataType UserDefinedDataTypeToEnum(UserDefinedDataType uddt) } else if (sqlDataType == SqlDataType.UserDefinedDataType) { - Diagnostics.TraceHelper.Assert(false, "UDDT cannot have another UDDT as the system type"); + Debug.Assert(false, "UDDT cannot have another UDDT as the system type"); } diff --git a/src/Microsoft/SqlServer/Management/Smo/DatabaseBase.cs b/src/Microsoft/SqlServer/Management/Smo/DatabaseBase.cs index 2d77ec53..8e052e6a 100644 --- a/src/Microsoft/SqlServer/Management/Smo/DatabaseBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/DatabaseBase.cs @@ -1,9 +1,10 @@ -// Copyright (c) Microsoft Corporation. +// Copyright (c) Microsoft Corporation. // Licensed under the MIT license. using System; using System.Text; using System.Data; +using System.Diagnostics; #if MICROSOFTDATA using Microsoft.Data.SqlClient; #else @@ -186,7 +187,7 @@ public override DatabaseEngineEdition DatabaseEngineEdition (State == SqlSmoState.Creating && se.Number == 18456)) { // Pass args as params since cfe may contain {#} in it which will cause formatting to fail if inserted directly - Diagnostics.TraceHelper.Trace("Database SMO Object", "Failed to connect for edition fetch, defaulting to Unknown edition. State: {0} PropertyBagState: {1} {2}", State, propertyBagState, cfe); + SmoEventSource.Log.DatabaseConnectionFailure(State.ToString(), propertyBagState.ToString(), cfe.ToString()); // - 916 is "Cannot open database <...> requested by the login.. The login failed.... // - 18456 is Login failed for user <...> // - 4060 is "Database not accessible" error. It might still be in sys.databases but being deleted. @@ -199,7 +200,7 @@ public override DatabaseEngineEdition DatabaseEngineEdition } else { - Diagnostics.TraceHelper.Trace("Database SMO Object", $"Failed to connect for edition fetch. State: {State}, SqlException number: {(cfe.InnerException as SqlException)?.Number}"); + SmoEventSource.Log.DatabaseSqlException((cfe.InnerException as SqlException)?.Number ?? 0, State.ToString()); throw; } } @@ -261,22 +262,7 @@ internal override void ValidateProperty(Property prop, object value) else { switch (this.ServerVersion.Major) - { - // SMO that is external to users exposes versions greater than 8, so there are no cases less than 8 - case 8: // Shiloh - if ((CompatibilityLevel)value <= CompatibilityLevel.Version80) - { - compatIsValid = true; // we're fine - } - break; - - case 9: // Yukon - if ((CompatibilityLevel)value <= CompatibilityLevel.Version90) - { - compatIsValid = true; // we're fine - } - break; - case 10: // Katmai + {case 10: // Katmai if ((CompatibilityLevel)value <= CompatibilityLevel.Version100) { compatIsValid = true; // we're fine @@ -556,12 +542,6 @@ internal override void ScriptCreate(StringCollection createQuery, ScriptingPrefe } else { - if (sp.TargetServerVersion < SqlServerVersion.Version90) - { - throw new UnsupportedVersionException(ExceptionTemplates.SupportedOnlyOn90).SetHelpContext( - "SupportedOnlyOn90"); - } - sbStatement.AppendFormat(SmoApplication.DefaultCulture, " AS SNAPSHOT OF [{0}]", SqlBraket(viewName)); } @@ -636,11 +616,8 @@ internal override void ScriptCreate(StringCollection createQuery, ScriptingPrefe } // enable vardecimal compression as needed - if (sp.TargetServerVersion >= SqlServerVersion.Version90) - { - bool forCreateScript = true; - ScriptVardecimalCompression(createQuery, sp, forCreateScript); - } + bool forCreateScript = true; + ScriptVardecimalCompression(createQuery, sp, forCreateScript); // Script for Change tracking options on database if (IsSupportedProperty("ChangeTrackingEnabled", sp) && sp.Data.ChangeTracking) @@ -1023,10 +1000,8 @@ private void ScriptDbProps80Comp(StringCollection query, ScriptingPreferences sp if (!isAzureDb && IsSupportedProperty("IsFullTextEnabled", sp)) { Property propFullTextEnabled = Properties.Get("IsFullTextEnabled"); - // The last line of the condition is to only avoid emitting the statement for scripts/create when version80 if (null != propFullTextEnabled.Value && - (propFullTextEnabled.Dirty || !sp.ScriptForAlter) && - (sp.TargetServerVersion >= SqlServerVersion.Version90 || sp.ScriptForAlter || (bool)propFullTextEnabled.Value)) + (propFullTextEnabled.Dirty || !sp.ScriptForAlter)) { query.Add(string.Format(SmoApplication.DefaultCulture, "IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled')){0}begin{0}EXEC {1}.[dbo].[sp_fulltext_database] @action = '{2}'{0}end", @@ -1085,16 +1060,6 @@ private void AddCompatibilityLevel(StringCollection query, ScriptingPreferences (sp.TargetServerVersion == SqlServerVersion.Version100) && ((int)(CompatibilityLevel)propCompat.Value <= 100); - bool isVersion90WithCompatLevelLessThan90 = - (sp.TargetServerVersion == SqlServerVersion.Version90) && - ((int)(CompatibilityLevel)propCompat.Value <= 90); - - bool isVersion80WithCompatLevelLessThan80 = - (sp.TargetServerVersion == SqlServerVersion.Version80) && - ((int)(CompatibilityLevel)propCompat.Value <= 80); - - bool isVersion80Or90WithLowerCompatLevel = isVersion90WithCompatLevelLessThan90 || isVersion80WithCompatLevelLessThan80; - bool isVersionWithLowerCompatLevel = isVersion105WithCompatLevelLessThan105 || isVersion100WithCompatLevelLessThan100 || @@ -1110,7 +1075,7 @@ private void AddCompatibilityLevel(StringCollection query, ScriptingPreferences //script only if compatibility level is less than the target server // on Alter() we just script it and let the server fail if it is not correct - if (IsSupportedProperty("CompatibilityLevel", sp) && (sp.ScriptForAlter || isVersionWithLowerCompatLevel || isVersion80Or90WithLowerCompatLevel)) + if (IsSupportedProperty("CompatibilityLevel", sp) && (sp.ScriptForAlter || isVersionWithLowerCompatLevel)) { CompatibilityLevel upgradedCompatLevel = UpgradeCompatibilityValueIfRequired(sp, (CompatibilityLevel)propCompat.Value); if (isVersionWithLowerCompatLevel) @@ -1122,15 +1087,6 @@ private void AddCompatibilityLevel(StringCollection query, ScriptingPreferences FormatFullNameForScripting(sp), Enum.Format(typeof(CompatibilityLevel), upgradedCompatLevel, "d"))); } - else if (isVersion80Or90WithLowerCompatLevel) - { - query.Add( - string.Format( - SmoApplication.DefaultCulture, - "EXEC dbo.sp_dbcmptlevel @dbname={0}, @new_cmptlevel={1}", - this.FormatFullNameForScripting(sp, false), - Enum.Format(typeof(CompatibilityLevel), upgradedCompatLevel, "d"))); - } } } } @@ -1151,11 +1107,6 @@ private CompatibilityLevel UpgradeCompatibilityValueIfRequired(ScriptingPreferen return CompatibilityLevel.Version80; } - //Return Compatibility level 70 if it is less when Scripting for Server version 90 - if (sp.TargetServerVersion == SqlServerVersion.Version90 && compatibilityLevel <= CompatibilityLevel.Version65) - { - return CompatibilityLevel.Version70; - } return compatibilityLevel; } @@ -1183,11 +1134,7 @@ internal override PropagateInfo[] GetPropagateInfo(PropagateAction action) pi = piList.ToArray(); } - // bWithScript flag is only set to true for Database.Alter() - // therefore it's sufficient to check for the current server - // version to be Yukon or higher. Otherwise FullTextCatalog object - // cannot be altered - else if (this.ServerVersion.Major >= 9) + else { //for mirroring -> propagate only if exists if (action == PropagateAction.Alter) @@ -1199,7 +1146,7 @@ internal override PropagateInfo[] GetPropagateInfo(PropagateAction action) new PropagateInfo(m_LogFiles, bWithScript, bWithScript), new PropagateInfo(m_FullTextCatalogs, bWithScript, bWithScript), //Propagating the DEK object is taken care in the ScriptAlter method - new PropagateInfo((ServerVersion.Major < 10)? (FullTextStopListCollection)null : m_FullTextStopLists, bWithScript, bWithScript) + new PropagateInfo(m_FullTextStopLists, bWithScript, bWithScript) }; } else @@ -1218,31 +1165,12 @@ internal override PropagateInfo[] GetPropagateInfo(PropagateAction action) new PropagateInfo(LogFiles, bWithScript, bWithScript), new PropagateInfo(m_FullTextCatalogs, bWithScript, bWithScript), //Propagating the DEK object is taken care in the ScriptCreate method - new PropagateInfo((ServerVersion.Major < 10)? null : m_FullTextStopLists, bWithScript, bWithScript) + new PropagateInfo(m_FullTextStopLists, bWithScript, bWithScript) //Propagating the DEK object is taken care in the ScriptCreate method }; } } - else if (this.ServerVersion.Major >= 8) - { - //fisrt parameter controls if the next level is scripted - //second parameter controls if the levels after the first level is scripted - pi = new PropagateInfo[] { - new PropagateInfo(ServerVersion.Major < 8 ? null : ExtendedProperties, true, ExtendedProperty.UrnSuffix ), - new PropagateInfo(FileGroups, bWithScript, bWithScript), - new PropagateInfo(LogFiles, bWithScript, bWithScript) - }; - } - else - { - //fisrt parameter controls if the next level is scripted - //second parameter controls if the levels after the first level is scripted - pi = new PropagateInfo[] { - new PropagateInfo(FileGroups, bWithScript, bWithScript), - new PropagateInfo(LogFiles, bWithScript, bWithScript) - }; - } return pi; } @@ -1282,11 +1210,6 @@ public void SetSnapshotIsolation(bool enabled) throw new InvalidSmoOperationException("SetSnapshotIsolation", State); } - if (ServerVersion.Major < 9) - { - throw new SmoException(ExceptionTemplates.UnsupportedVersion(ServerVersion.ToString())); - } - this.ExecutionManager.ExecuteNonQuery( string.Format(SmoApplication.DefaultCulture, "ALTER DATABASE [{0}] SET ALLOW_SNAPSHOT_ISOLATION {1}", SqlBraket(this.Name), enabled ? "ON" : "OFF")); @@ -1852,11 +1775,8 @@ internal override void ScriptAlter(StringCollection alterQuery, ScriptingPrefere } } - if (sp.TargetServerVersion >= SqlServerVersion.Version90) - { - bool forCreateScript = false; - ScriptVardecimalCompression(alterQuery, sp, forCreateScript); - } + bool forCreateScript = false; + ScriptVardecimalCompression(alterQuery, sp, forCreateScript); // Script for change tracking options on database if (sp.Data.ChangeTracking && IsSupportedProperty("ChangeTrackingEnabled", sp)) @@ -2615,6 +2535,23 @@ public ExternalLibraryCollection ExternalLibraries } } + //ExternalModels collection + ExternalModelCollection m_ExternalModels; + [SfcObject(SfcContainerRelationship.ObjectContainer, SfcContainerCardinality.ZeroToAny, typeof(ExternalModel))] + public ExternalModelCollection ExternalModels + { + get + { + CheckObjectState(); + this.ThrowIfNotSupported(typeof(ExternalModel)); + if (m_ExternalModels == null) + { + m_ExternalModels = new ExternalModelCollection(this); + } + return m_ExternalModels; + } + } + UserDefinedTypeCollection m_UserDefinedTypes; [SfcObject(SfcContainerRelationship.ObjectContainer, SfcContainerCardinality.ZeroToAny, typeof(UserDefinedType))] public UserDefinedTypeCollection UserDefinedTypes @@ -2947,7 +2884,7 @@ private bool IsDatabaseEncryptionKeyPresent() sqlExc.Number == 262 )) //No permission in Database { // In case user doesn't have permission to view sys.dm_database_encryption_keys, we shall only return false instead of throwing exception. - Diagnostics.TraceHelper.Trace("Database SMO Object", exc.Message); + SmoEventSource.Log.DatabaseOperation(exc.Message); } else { @@ -4621,6 +4558,18 @@ internal void PrefetchExternalLibraries(ScriptingPreferences options) } } + internal void PrefetchExternalModels(ScriptingPreferences options) + { + if (this.IsSupportedObject(options)) + { + InitChildLevel(ExternalModel.UrnSuffix, options, true); + if (options.IncludeScripts.ExtendedProperties && this.IsSupportedObject(options)) + { + InitChildLevel("ExternalModel/ExtendedProperty", options, true); + } + } + } + internal void PrefetchUserDefinedFunctions(ScriptingPreferences options) { if (this.IsSupportedObject(options)) @@ -5103,6 +5052,7 @@ internal void PrefetchOtherObjects(ScriptingPreferences options) PrefetchUserDefinedTypes(options); PrefetchExternalLanguages(options); PrefetchExternalLibraries(options); + PrefetchExternalModels(options); PrefetchUserDefinedTableTypes(options); PrefetchUserDefinedAggregates(options); PrefetchXmlSchemaCollections(options); @@ -5160,10 +5110,6 @@ public DataTable EnumTransactions(TransactionTypes transactionType) throw new InvalidSmoOperationException("EnumTransactions", State); } - if (ServerVersion.Major < 9) - { - throw new SmoException(ExceptionTemplates.UnsupportedVersion(ServerVersion.ToString())); - } return this.ExecutionManager.GetEnumeratorData(new Request("Server/Transaction" + GetTranFilterExpr(transactionType))); } @@ -5347,31 +5293,14 @@ public void SetDefaultFileGroup(string fileGroupName) private StringCollection GetDefaultFileGroupScript(ScriptingPreferences sp, string dataSpaceName) { StringCollection results = new StringCollection(); - if (sp.TargetServerVersion == SqlServerVersion.Version80) - { - // we check whether the filegroup exists and is already default. engine throws if - // we try to make set default on a filegroup that is already default. - this.AddUseDb(results, sp); - results.Add(string.Format(SmoApplication.DefaultCulture, - "IF NOT EXISTS (SELECT groupname FROM dbo.sysfilegroups WHERE (status & 0x10) != 0 AND groupname = {2}) ALTER DATABASE {0} MODIFY FILEGROUP [{1}] DEFAULT", - this.FormatFullNameForScripting(sp), - SqlBraket(dataSpaceName), - MakeSqlString(dataSpaceName))); - } - else - { - // Yukon - we could have other data spaces become default, but there is - // no DDL support for this yet. - // - // we check whether the filegroup exists and is already default. engine throws if - // we try to make set default on a filegroup that is already default. - this.AddUseDb(results, sp); - results.Add(string.Format(SmoApplication.DefaultCulture, - "IF NOT EXISTS (SELECT name FROM sys.filegroups WHERE is_default=1 AND name = {2}) ALTER DATABASE {0} MODIFY FILEGROUP [{1}] DEFAULT", - this.FormatFullNameForScripting(sp), - SqlBraket(dataSpaceName), - MakeSqlString(dataSpaceName))); - } + // we check whether the filegroup exists and is already default. engine throws if + // we try to make set default on a filegroup that is already default. + this.AddUseDb(results, sp); + results.Add(string.Format(SmoApplication.DefaultCulture, + "IF NOT EXISTS (SELECT name FROM sys.filegroups WHERE is_default=1 AND name = {2}) ALTER DATABASE {0} MODIFY FILEGROUP [{1}] DEFAULT", + this.FormatFullNameForScripting(sp), + SqlBraket(dataSpaceName), + MakeSqlString(dataSpaceName))); return results; } @@ -5560,8 +5489,8 @@ public void UpdateIndexStatistics() if (dt.Rows.Count > 0) { //assert that we have schema on the first column and name on second - Diagnostics.TraceHelper.Assert("View_Schema" == dt.Columns[0].Caption); - Diagnostics.TraceHelper.Assert("View_Name" == dt.Columns[1].Caption); + Debug.Assert("View_Schema" == dt.Columns[0].Caption); + Debug.Assert("View_Name" == dt.Columns[1].Caption); // iterate through the list of views, it may contain duplicates string schema = string.Empty; @@ -5844,27 +5773,10 @@ public DataTable EnumObjects(DatabaseObjectTypes types) /// /// Truncate log. This is supported in SQL Server 2005 for backwards compatibility reasons. /// + [Obsolete] public void TruncateLog() { - if (this.ServerVersion.Major >= 10) - { - throw new UnsupportedVersionException(ExceptionTemplates.SupportedOnlyBelow100).SetHelpContext("SupportedOnlyBelow100"); - } - - try - { - CheckObjectState(); - - string stmt = string.Format(SmoApplication.DefaultCulture, "BACKUP LOG {0} WITH TRUNCATE_ONLY ", - this.FormatFullNameForScripting(new ScriptingPreferences())); - this.ExecutionManager.ExecuteNonQuery(stmt); - } - catch (Exception e) - { - FilterException(e); - - throw new FailedOperationException(ExceptionTemplates.TruncateLog, this, e); - } + throw new UnsupportedVersionException(ExceptionTemplates.SupportedOnlyBelow100).SetHelpContext("SupportedOnlyBelow100"); } /// @@ -6164,52 +6076,48 @@ private void ScriptDbOptionsProps(StringCollection query, ScriptingPreferences s ScriptAlterPropBool("QuotedIdentifiersEnabled", "QUOTED_IDENTIFIER", sp, query); ScriptAlterPropBool("RecursiveTriggersEnabled", "RECURSIVE_TRIGGERS", sp, query); - //script only if we are on Yukon or target Yukon and later - if (this.ServerVersion.Major >= 9 && - sp.TargetServerVersion >= SqlServerVersion.Version90) + // Don't script for Managed Instances - not supported + // + if (IsSupportedProperty("BrokerEnabled", sp) && !targetEditionIsManagedServer) { - // Don't script for Managed Instances - not supported - // - if (IsSupportedProperty("BrokerEnabled", sp) && !targetEditionIsManagedServer) - { - ScriptAlterPropBool("BrokerEnabled", string.Empty, sp, query, "ENABLE_BROKER", "DISABLE_BROKER"); - } - ScriptAlterPropBool("AutoUpdateStatisticsAsync", "AUTO_UPDATE_STATISTICS_ASYNC", sp, query); + ScriptAlterPropBool("BrokerEnabled", string.Empty, sp, query, "ENABLE_BROKER", "DISABLE_BROKER"); + } + ScriptAlterPropBool("AutoUpdateStatisticsAsync", "AUTO_UPDATE_STATISTICS_ASYNC", sp, query); - // trying to enable or disable date_correlation_optimization on Azure also hangs indefinitely - if (!targetEditionIsManagedServer && !isAzureDb) - { - ScriptAlterPropBool("DateCorrelationOptimization", "DATE_CORRELATION_OPTIMIZATION", sp, query); - } + // trying to enable or disable date_correlation_optimization on Azure also hangs indefinitely + if (!targetEditionIsManagedServer && !isAzureDb) + { + ScriptAlterPropBool("DateCorrelationOptimization", "DATE_CORRELATION_OPTIMIZATION", sp, query); + } - if (!isAzureDb) - { - ScriptAlterPropBool("Trustworthy", "TRUSTWORTHY", sp, query); - } - if (IsSupportedProperty("SnapshotIsolationState", sp)) - { - ScriptSnapshotIsolationState(sp, query); - } - ScriptAlterPropBool("IsParameterizationForced", "PARAMETERIZATION", sp, query, "FORCED", "SIMPLE"); - ScriptAlterPropBool("IsReadCommittedSnapshotOn", "READ_COMMITTED_SNAPSHOT", sp, query); + if (!isAzureDb) + { + ScriptAlterPropBool("Trustworthy", "TRUSTWORTHY", sp, query); + } + if (IsSupportedProperty("SnapshotIsolationState", sp)) + { + ScriptSnapshotIsolationState(sp, query); + } + ScriptAlterPropBool("IsParameterizationForced", "PARAMETERIZATION", sp, query, "FORCED", "SIMPLE"); + ScriptAlterPropBool("IsReadCommittedSnapshotOn", "READ_COMMITTED_SNAPSHOT", sp, query); - if (IsSupportedProperty("MirroringPartner", sp)) + + if (IsSupportedProperty("MirroringPartner", sp)) + { + if (this.GetPropValueOptional("IsMirroringEnabled", false)) { - if (this.GetPropValueOptional("IsMirroringEnabled", false)) + Property propMirroringTimeout = Properties.Get("MirroringTimeout"); + if (null != propMirroringTimeout.Value && (propMirroringTimeout.Dirty || !sp.ForDirectExecution)) { - Property propMirroringTimeout = Properties.Get("MirroringTimeout"); - if (null != propMirroringTimeout.Value && (propMirroringTimeout.Dirty || !sp.ForDirectExecution)) - { - query.Add(string.Format(SmoApplication.DefaultCulture, "ALTER DATABASE {0} SET PARTNER TIMEOUT {1} {2}", - this.FormatFullNameForScripting(sp), - Convert.ToInt32(propMirroringTimeout.Value, SmoApplication.DefaultCulture), - null != optionTerminationStatement ? optionTerminationStatement.GetTerminationScript() : "")); - } + query.Add(string.Format(SmoApplication.DefaultCulture, "ALTER DATABASE {0} SET PARTNER TIMEOUT {1} {2}", + this.FormatFullNameForScripting(sp), + Convert.ToInt32(propMirroringTimeout.Value, SmoApplication.DefaultCulture), + null != optionTerminationStatement ? optionTerminationStatement.GetTerminationScript() : "")); } } + } - } if (IsSupportedProperty("HonorBrokerPriority", sp) && !isAzureDb && !targetEditionIsManagedServer) { ScriptAlterPropBool("HonorBrokerPriority", "HONOR_BROKER_PRIORITY", sp, query); @@ -6280,20 +6188,7 @@ private void ScriptDbOptionsProps(StringCollection query, ScriptingPreferences s ScriptPageVerify(sp, query); } - if (sp.TargetServerVersion < SqlServerVersion.Version90)//for 8.0 - { - Property propDbChaining = Properties.Get("DatabaseOwnershipChaining"); - if (null != propDbChaining.Value && - (propDbChaining.Dirty || !sp.ForDirectExecution)) - { - query.Add(string.Format(SmoApplication.DefaultCulture, - "if ( ((@@microsoftversion / power(2, 24) = 8) and (@@microsoftversion & 0xffff >= 760)) or \n\t\t(@@microsoftversion / power(2, 24) >= 9) )" + - "begin \n\texec dbo.sp_dboption @dbname = {0}, @optname = 'db chaining', @optvalue = '{1}'\n end", - this.FormatFullNameForScripting(sp, false), - (bool)propDbChaining.Value ? "ON" : "OFF")); - } - } - else if (!isAzureDb)//for 9.0 + if (!isAzureDb) { ScriptAlterPropBool("DatabaseOwnershipChaining", "DB_CHAINING", sp, query); } @@ -6366,9 +6261,35 @@ private void ScriptDbOptionsProps(StringCollection query, ScriptingPreferences s } } - // eg: ALTER DATABASE [MyDatabase] SET ACCELERATED_DATABASE_RECOVERY = ON (PERSISTENT_VERSION_STORE_FILEGROUP = [VersionStoreFG]) - // The filegroup can only be changed if one disables ADR first - // https://docs.microsoft.com/sql/relational-databases/accelerated-database-recovery-management?view=sql-server-ver15 + /// If at any point we attempt to run an alter command that would result in AcceleratedDatabaseRecovery (ADR) + /// being disabled while OptimizedLocking (OL) is enabled, we will get an error, as OL cannot be enabled without ADR. + /// This means that when both features get enabled, ADR must be enabled first, whereas when both features + /// get disabled, OL must be disabled first. + /// So we check if ADR is being disabled and in that case we process OL first, otherwise we process ADR first. + /// Of course there are more scenarios than just enabling/disabling them both simoultaneously, but in those cases + /// the order is not going to make a difference. For instance, if ADR gets disabled while OL gets enabled, that will + /// still result in an error no matter the order, but that behavior would be expected. + if (IsSupportedProperty(nameof(AcceleratedRecoveryEnabled), sp) + && Properties.Get(nameof(AcceleratedRecoveryEnabled)).Value != null + && ! (bool)Properties.Get(nameof(AcceleratedRecoveryEnabled)).Value) + { + ScriptAlterOptimizedLocking(sp, query, isAzureDb, targetEditionIsManagedServer); + ScriptAlterAcceleratedDatabaseRecovery(sp, query, isAzureDb, targetEditionIsManagedServer); + } + else + { + ScriptAlterAcceleratedDatabaseRecovery(sp, query, isAzureDb, targetEditionIsManagedServer); + ScriptAlterOptimizedLocking(sp, query, isAzureDb, targetEditionIsManagedServer); + } + + ScriptAlterPropBool(nameof(DataRetentionEnabled), "DATA_RETENTION", sp, query, false); + } + + // eg: ALTER DATABASE [MyDatabase] SET ACCELERATED_DATABASE_RECOVERY = ON (PERSISTENT_VERSION_STORE_FILEGROUP = [VersionStoreFG]) + // The filegroup can only be changed if one disables ADR first + // https://docs.microsoft.com/sql/relational-databases/accelerated-database-recovery-management?view=sql-server-ver15 + private void ScriptAlterAcceleratedDatabaseRecovery(ScriptingPreferences sp, StringCollection query, bool isAzureDb, bool targetEditionIsManagedServer) + { if (IsSupportedProperty(nameof(AcceleratedRecoveryEnabled), sp) && !isAzureDb && !targetEditionIsManagedServer) { var propAdr = Properties.Get(nameof(AcceleratedRecoveryEnabled)); @@ -6393,14 +6314,15 @@ private void ScriptDbOptionsProps(StringCollection query, ScriptingPreferences s useEqualityOperator: true); } } + } - // https://docs.microsoft.com/en-us/sql/relational-databases/performance/optimized-locking?view=sql-server-ver17 + // https://docs.microsoft.com/en-us/sql/relational-databases/performance/optimized-locking?view=sql-server-ver17 + private void ScriptAlterOptimizedLocking(ScriptingPreferences sp, StringCollection query, bool isAzureDb, bool targetEditionIsManagedServer) + { if (IsSupportedProperty(nameof(OptimizedLockingOn), sp) && !isAzureDb && !targetEditionIsManagedServer) { ScriptAlterPropBool(nameof(OptimizedLockingOn), "OPTIMIZED_LOCKING", sp, query, true); } - - ScriptAlterPropBool(nameof(DataRetentionEnabled), "DATA_RETENTION", sp, query, false); } private void ScriptAlterFileStreamProp(ScriptingPreferences sp,StringCollection query ) @@ -6555,55 +6477,32 @@ void ScriptPageVerify(ScriptingPreferences sp, StringCollection queries) { if (IsSupportedProperty("PageVerify", sp)) { - if (sp.TargetServerVersion < SqlServerVersion.Version90) //for 8.0 + Property prop = Properties.Get("PageVerify"); + if (null == prop.Value || !(prop.Dirty || !sp.ForDirectExecution)) { - string dbName = this.FormatFullNameForScripting(sp, false); - switch (GetPageVerify(sp)) - { - case PageVerify.TornPageDetection: - ScriptAlterPropBool("PageVerify", "TORN_PAGE_DETECTION", sp, queries, "ON"); - break; - case PageVerify.None: - ScriptAlterPropBool("PageVerify", "TORN_PAGE_DETECTION", sp, queries, "OFF"); - break; - default: - //throw if for direct execution, ignore if for scripting - if (sp.ScriptForCreateDrop) - { - throw new WrongPropertyValueException(Properties.Get("PageVerify")); - } - break; - } + return; } - else //for 9.0 + string valPageVerify = string.Empty; + switch (GetPageVerify(sp)) { - Property prop = Properties.Get("PageVerify"); - if (null == prop.Value || !(prop.Dirty || !sp.ForDirectExecution)) - { - return; - } - string valPageVerify = string.Empty; - switch (GetPageVerify(sp)) - { - case PageVerify.TornPageDetection: - valPageVerify = "TORN_PAGE_DETECTION "; - break; - case PageVerify.Checksum: - valPageVerify = "CHECKSUM "; - break; - case PageVerify.None: - valPageVerify = "NONE "; - break; - default: - //throw if for direct execution, ignore if for scripting - if (sp.ScriptForCreateDrop) - { - throw new WrongPropertyValueException(prop); - } - break; - } - ScriptAlterPropBool("PageVerify", "PAGE_VERIFY", sp, queries, valPageVerify); + case PageVerify.TornPageDetection: + valPageVerify = "TORN_PAGE_DETECTION "; + break; + case PageVerify.Checksum: + valPageVerify = "CHECKSUM "; + break; + case PageVerify.None: + valPageVerify = "NONE "; + break; + default: + //throw if for direct execution, ignore if for scripting + if (sp.ScriptForCreateDrop) + { + throw new WrongPropertyValueException(prop); + } + break; } + ScriptAlterPropBool("PageVerify", "PAGE_VERIFY", sp, queries, valPageVerify); } } @@ -6797,7 +6696,7 @@ public bool IsLocalPrimaryReplica() } catch (Exception e) { - Diagnostics.TraceHelper.Trace("Database SMO Object", "Unable to query sys.fn_hadr_is_primary_replica. {0} {1}", e.Message, e.InnerException?.Message ?? ""); + SmoEventSource.Log.HadrQueryFailure(e.Message, e.InnerException?.Message ?? ""); } // If the query fails for some reason fall back to the old behavior var primaryReplicaServerName = ag.PrimaryReplicaServerName; @@ -6868,10 +6767,6 @@ internal override void AddObjectPropsFromDataReader(IDataReader reader, bool ski m_edition = (DatabaseEngineEdition)reader["RealEngineEdition"]; } -#if DEBUG - var name = (string)reader["Name"]; - TraceHelper.Trace("SMO", "Database: {0} Edition: {1} ", name, m_edition?.ToString() ?? ""); -#endif } base.AddObjectPropsFromDataReader(reader, skipIfDirty, startColIdx, endColIdx); } diff --git a/src/Microsoft/SqlServer/Management/Smo/DatabaseEncryptionKeyBase.cs b/src/Microsoft/SqlServer/Management/Smo/DatabaseEncryptionKeyBase.cs index ee5078b5..70a294af 100644 --- a/src/Microsoft/SqlServer/Management/Smo/DatabaseEncryptionKeyBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/DatabaseEncryptionKeyBase.cs @@ -89,7 +89,7 @@ internal override void ScriptCreate(StringCollection createQuery, ScriptingPrefe StringBuilder sb = new StringBuilder(Globals.INIT_BUFFER_SIZE); - if (sp.TargetServerVersion >= SqlServerVersion.Version100 && ServerVersion.Major >= 10) + if (sp.TargetServerVersion >= SqlServerVersion.Version100) { if (sp.IncludeScripts.Header) { @@ -159,7 +159,7 @@ internal override void ScriptAlter(StringCollection alterQuery, ScriptingPrefere StringBuilder sb = new StringBuilder(Globals.INIT_BUFFER_SIZE); bool scriptAlter = false; - if (sp.TargetServerVersion >= SqlServerVersion.Version100 && ServerVersion.Major >= 10) + if (sp.TargetServerVersion >= SqlServerVersion.Version100) { //We need this if we try to alter the DEK object from the Alter method of the Database as it needs the database's context if (sp.IncludeScripts.DatabaseContext) @@ -230,7 +230,7 @@ internal override void ScriptDrop(StringCollection dropQuery, ScriptingPreferenc { StringBuilder sb = new StringBuilder(Globals.INIT_BUFFER_SIZE); - if (sp.TargetServerVersion >= SqlServerVersion.Version100 && ServerVersion.Major >= 10) + if (sp.TargetServerVersion >= SqlServerVersion.Version100) { if (sp.IncludeScripts.Header) { diff --git a/src/Microsoft/SqlServer/Management/Smo/DatabaseOptionsBase.cs b/src/Microsoft/SqlServer/Management/Smo/DatabaseOptionsBase.cs index 5fea91f1..f4008030 100644 --- a/src/Microsoft/SqlServer/Management/Smo/DatabaseOptionsBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/DatabaseOptionsBase.cs @@ -94,11 +94,6 @@ public void SetSnapshotIsolation(bool enabled) throw new InvalidSmoOperationException("SetSnapshotIsolation", State); } - if (ServerVersion.Major < 9) - { - throw new SmoException(ExceptionTemplates.UnsupportedVersion(ServerVersion.ToString())); - } - this.ExecutionManager.ExecuteNonQuery( string.Format(SmoApplication.DefaultCulture, "ALTER DATABASE [{0}] SET ALLOW_SNAPSHOT_ISOLATION {1}", SqlBraket(this.Parent.Name), enabled ? "ON" : "OFF")); diff --git a/src/Microsoft/SqlServer/Management/Smo/DatabaseReplicaStateCollectionBase.cs b/src/Microsoft/SqlServer/Management/Smo/DatabaseReplicaStateCollectionBase.cs index 2c4e260a..441ab686 100644 --- a/src/Microsoft/SqlServer/Management/Smo/DatabaseReplicaStateCollectionBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/DatabaseReplicaStateCollectionBase.cs @@ -1,9 +1,10 @@ -// Copyright (c) Microsoft Corporation. +// Copyright (c) Microsoft Corporation. // Licensed under the MIT license. using System; using System.Collections; using System.Collections.Specialized; +using System.Diagnostics; using Microsoft.SqlServer.Management.Sdk.Sfc; @@ -63,7 +64,7 @@ public override int Compare(object obj1, object obj2) var dbr1 = obj1 as DatabaseReplicaStateObjectKey; var dbr2 = obj2 as DatabaseReplicaStateObjectKey; - Diagnostics.TraceHelper.Assert(null != dbr1 || null != dbr2, "Can't compare null objects for DatabaseReplicaState"); + Debug.Assert(null != dbr1 || null != dbr2, "Can't compare null objects for DatabaseReplicaState"); //We order first by Avaialbility Replica name, then by Database name var replicaNameComparison = stringComparer.Compare(dbr1.ReplicaName, dbr2.ReplicaName); diff --git a/src/Microsoft/SqlServer/Management/Smo/DatabaseRoleBase.cs b/src/Microsoft/SqlServer/Management/Smo/DatabaseRoleBase.cs index cb613c8e..6c0c2d92 100644 --- a/src/Microsoft/SqlServer/Management/Smo/DatabaseRoleBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/DatabaseRoleBase.cs @@ -70,14 +70,12 @@ internal override void ScriptDrop(StringCollection dropQuery, ScriptingPreferenc // Check if exists check should be included if (sp.IncludeScripts.ExistenceCheck && sp.TargetServerVersion < SqlServerVersion.Version130) { - strBuilder.Append((sp.TargetServerVersion >= SqlServerVersion.Version90) ? Scripts.INCLUDE_EXISTS_ROLE_MEMBERS90 : Scripts.INCLUDE_EXISTS_ROLE_MEMBERS80); + strBuilder.Append(Scripts.INCLUDE_EXISTS_ROLE_MEMBERS90); } //Check if not a Fixed role or 'public' - if (sp.TargetServerVersion >= SqlServerVersion.Version90) - { - strBuilder.Append(Scripts.IS_DBROLE_FIXED_OR_PUBLIC_90); - } + strBuilder.Append(Scripts.IS_DBROLE_FIXED_OR_PUBLIC_90); + bool isSqlDw = this.Parent.GetPropValueOptional("IsSqlDw", false); @@ -91,9 +89,7 @@ internal override void ScriptDrop(StringCollection dropQuery, ScriptingPreferenc strBuilder.Append( VersionUtils.IsTargetServerVersionSQl11OrLater(sp.TargetServerVersion) ? Scripts.DROP_DATABASEROLE_MEMBERS_110 - : (sp.TargetServerVersion >= SqlServerVersion.Version90) - ? Scripts.DROP_DATABASEROLE_MEMBERS_90 - : Scripts.DROP_DATABASEROLE_MEMBERS_80 + : Scripts.DROP_DATABASEROLE_MEMBERS_90 ); } @@ -109,23 +105,15 @@ internal override void ScriptDrop(StringCollection dropQuery, ScriptingPreferenc { strBuilder.Append(string.Format(SmoApplication.DefaultCulture, - sp.TargetServerVersion < SqlServerVersion.Version90 ? Scripts.INCLUDE_EXISTS_DBROLE80 : Scripts.INCLUDE_EXISTS_DBROLE90, + Scripts.INCLUDE_EXISTS_DBROLE90, "", FormatFullNameForScripting(sp, false))); strBuilder.Append(sp.NewLine); } - //if 7.0, 8.0 - if (SqlServerVersion.Version90 > sp.TargetServerVersion) - { - strBuilder.Append("EXEC dbo.sp_droprole @rolename = " + FormatFullNameForScripting(sp, false)); - } - else // > 9.0 - { - strBuilder.Append("DROP ROLE " + - ((sp.IncludeScripts.ExistenceCheck && sp.TargetServerVersion >= SqlServerVersion.Version130) ? "IF EXISTS " : string.Empty) + - FormatFullNameForScripting(sp, true)); - } + strBuilder.Append("DROP ROLE " + + ((sp.IncludeScripts.ExistenceCheck && sp.TargetServerVersion >= SqlServerVersion.Version130) ? "IF EXISTS " : string.Empty) + + FormatFullNameForScripting(sp, true)); dropQuery.Add(strBuilder.ToString()); } @@ -183,7 +171,7 @@ internal override void ScriptCreate(StringCollection createQuery, ScriptingPrefe if (sp.IncludeScripts.ExistenceCheck) { statement.AppendFormat(SmoApplication.DefaultCulture, - sp.TargetServerVersion < SqlServerVersion.Version90 ? Scripts.INCLUDE_EXISTS_DBROLE80 : Scripts.INCLUDE_EXISTS_DBROLE90, + Scripts.INCLUDE_EXISTS_DBROLE90, "NOT", FormatFullNameForScripting(sp, false)); statement.Append(sp.NewLine); } @@ -340,30 +328,7 @@ private string ScriptAddToRole(System.String role, ScriptingPreferences sp) myrolename = MakeSqlString(this.Name); } - string prefix; - - if (sp != null) - { - if (sp.TargetServerVersion >= SqlServerVersion.Version90) - { - prefix = "sys"; - } - else - { - prefix = "dbo"; - } - } - else - { - if (this.ServerVersion.Major >= 9) - { - prefix = "sys"; - } - else - { - prefix = "dbo"; - } - } + string prefix = "sys"; return string.Format(SmoApplication.DefaultCulture, "EXEC {0}.sp_addrolemember @rolename = {1}, @membername = {2}", @@ -432,20 +397,10 @@ public StringCollection EnumRoles() //Work for cloud as the context is same database. AddDatabaseContext(query); - if (this.ServerVersion.Major >= 9) - { - statement.AppendLine("SELECT p1.name FROM sys.database_role_members as r "); - statement.AppendLine("JOIN sys.database_principals as p1 on p1.principal_id = r.role_principal_id "); - statement.AppendLine("JOIN sys.database_principals as p2 on p2.principal_id = r.member_principal_id "); - statement.AppendFormat(SmoApplication.DefaultCulture, "WHERE p2.name = {0}", MakeSqlString(this.Name)); - } - else - { - statement.AppendLine("SELECT g.name FROM sysusers u, sysusers g, sysmembers m "); - statement.AppendFormat(SmoApplication.DefaultCulture, - "WHERE u.name = {0} AND u.uid = m.memberuid AND g.uid = m.groupuid AND u.issqlrole = 1 ", - MakeSqlString(this.Name)); - } + statement.AppendLine("SELECT p1.name FROM sys.database_role_members as r "); + statement.AppendLine("JOIN sys.database_principals as p1 on p1.principal_id = r.role_principal_id "); + statement.AppendLine("JOIN sys.database_principals as p2 on p2.principal_id = r.member_principal_id "); + statement.AppendFormat(SmoApplication.DefaultCulture, "WHERE p2.name = {0}", MakeSqlString(this.Name)); query.Add(statement.ToString()); DataTable dt = this.ExecutionManager.ExecuteWithResults(query).Tables[0]; #endif @@ -481,11 +436,6 @@ public void Rename(string newname) internal override void ScriptRename(StringCollection renameQuery, ScriptingPreferences sp, string newName) { - if (this.ServerVersion.Major < 9) - { - throw new InvalidVersionSmoOperationException(this.ServerVersion); - } - this.AddDatabaseContext(renameQuery, sp); renameQuery.Add(string.Format(SmoApplication.DefaultCulture, "ALTER ROLE {0} WITH NAME={1}", FormatFullNameForScripting(new ScriptingPreferences()), MakeSqlBraket(newName))); @@ -554,7 +504,7 @@ internal override PropagateInfo[] GetPropagateInfo(PropagateAction action) { if (this.DatabaseEngineType != Microsoft.SqlServer.Management.Common.DatabaseEngineType.SqlAzureDatabase) { - return new PropagateInfo[] { new PropagateInfo(ServerVersion.Major <= 8 ? null : ExtendedProperties, true, ExtendedProperty.UrnSuffix) }; + return new PropagateInfo[] { new PropagateInfo(ExtendedProperties, true, ExtendedProperty.UrnSuffix) }; } return null; @@ -567,13 +517,6 @@ internal override PropagateInfo[] GetPropagateInfo(PropagateAction action) /// internal override void AddScriptPermission(StringCollection query, ScriptingPreferences sp) { - // on 8.0 and below we do not have permissions on database roles - if (sp.TargetServerVersion <= SqlServerVersion.Version80 || - this.ServerVersion.Major <= 8) - { - return; - } - base.AddScriptPermission(query, sp); } diff --git a/src/Microsoft/SqlServer/Management/Smo/DdlTriggerBase.cs b/src/Microsoft/SqlServer/Management/Smo/DdlTriggerBase.cs index 2bd048fa..546dffec 100644 --- a/src/Microsoft/SqlServer/Management/Smo/DdlTriggerBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/DdlTriggerBase.cs @@ -239,11 +239,8 @@ private void GetInternalDDL(StringCollection queries, ScriptingPreferences sp, S { if (ImplementationType.SqlClr == (ImplementationType)property.Value) { - // CLR triggers are not supported on versions prior to 9.0 - if (ServerVersion.Major < 9) - { - throw new WrongPropertyValueException(ExceptionTemplates.ClrNotSupported("ImplementationType", ServerVersion.ToString())); - } + // CLR triggers were introduced in SQL Server 2005 (version 9.0). + // Since minimum supported version is now SQL Server 2008 (version 10), this is always supported. bTransactSql = false; @@ -299,7 +296,7 @@ private void GetInternalDDL(StringCollection queries, ScriptingPreferences sp, S } } - if (ServerVersion.Major >= 9 && sp.TargetServerVersion >= SqlServerVersion.Version90) + if (sp.TargetServerVersion >= SqlServerVersion.Version90) { sbSpExec.Append(" "); if (this is ServerDdlTrigger) diff --git a/src/Microsoft/SqlServer/Management/Smo/ExecutionManager.cs b/src/Microsoft/SqlServer/Management/Smo/ExecutionManager.cs index 8156d3f1..9e089def 100644 --- a/src/Microsoft/SqlServer/Management/Smo/ExecutionManager.cs +++ b/src/Microsoft/SqlServer/Management/Smo/ExecutionManager.cs @@ -1,23 +1,24 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -namespace Microsoft.SqlServer.Management.Smo -{ - using System; - using System.Globalization; - using System.Data; +using System; +using System.Globalization; +using System.Data; #if MICROSOFTDATA - using Microsoft.Data.SqlClient; +using Microsoft.Data.SqlClient; #else using System.Data.SqlClient; #endif - using System.Collections.Specialized; - using System.Threading; - using Microsoft.SqlServer.Management.Common; - using Microsoft.SqlServer.Server; - using Microsoft.SqlServer.Management.Sdk.Sfc; - using Diagnostics = Microsoft.SqlServer.Management.Diagnostics; +using System.Collections.Specialized; +using System.Diagnostics.Tracing; +using System.Threading; +using Microsoft.SqlServer.Management.Common; +using EventSource = Microsoft.SqlServer.Management.Common.SmoEventSource; +using Microsoft.SqlServer.Server; +using Microsoft.SqlServer.Management.Sdk.Sfc; +namespace Microsoft.SqlServer.Management.Smo +{ #pragma warning disable 1590, 1591, 1592, 1573, 1571, 1570, 1572, 1587 /// @@ -88,10 +89,11 @@ internal DataTable GetEnumeratorData(Request req) #endif try { -#if DEBUG - Diagnostics.TraceHelper.Trace(SmoApplication.ModuleName, SmoApplication.trAlways, - "get data for urn: {0}", req.Urn); -#endif + // Only convert URN to string if execution logging is enabled + if (EventSource.Log.IsEnabled(EventLevel.Informational, EventSource.Keywords.Execution)) + { + EventSource.Log.GetDataForUrn(req.Urn.ToString()); + } return new Enumerator().Process(this.ConnectionContext, req); } finally @@ -116,8 +118,7 @@ internal DataTable GetEnumeratorData(Request req) framepath.Append(mi.Name); } } - Diagnostics.TraceHelper.Trace(SmoApplication.ModuleName, SmoApplication.trAlways, - framepath.ToString()); + SmoEventSource.Log.ExecutionMessage(framepath.ToString()); } #endif } @@ -138,8 +139,11 @@ internal System.Data.IDataReader GetEnumeratorDataReader(Request req) #endif try { - Diagnostics.TraceHelper.Trace(SmoApplication.ModuleName, SmoApplication.trAlways, - "get data for urn: {0}", req.Urn); + // Only convert URN to string if execution logging is enabled + if (EventSource.Log.IsEnabled(EventLevel.Informational, EventSource.Keywords.Execution)) + { + EventSource.Log.GetDataForUrn(req.Urn.ToString()); + } return EnumResult.ConvertToDataReader(Enumerator.GetData(this.ConnectionContext, req)); } finally @@ -164,8 +168,7 @@ internal System.Data.IDataReader GetEnumeratorDataReader(Request req) framepath.Append(mi.Name); } } - Diagnostics.TraceHelper.Trace(SmoApplication.ModuleName, SmoApplication.trAlways, - framepath.ToString()); + EventSource.Log.ExecutionMessage(framepath.ToString()); } #endif } @@ -184,8 +187,11 @@ internal ObjectInfo GetEnumeratorInfo(RequestObjectInfo roi) if( PerformanceCounters.DoCount ) PerformanceCounters.ObjectInfoRequestCount++; #endif - Diagnostics.TraceHelper.Trace(SmoApplication.ModuleName, SmoApplication.trAlways, - "get object info for urn: {0}", roi.Urn); + // Only format string if execution logging is enabled + if (EventSource.Log.IsEnabled(EventLevel.Informational, EventSource.Keywords.Execution)) + { + EventSource.Log.ExecutionMessage($"get object info for urn: {roi.Urn}"); + } return new Enumerator().Process(this.ConnectionContext, roi); } @@ -203,7 +209,7 @@ internal DependencyChainCollection GetDependencies(DependencyRequest dependencyR #endif try { - Diagnostics.TraceHelper.Trace(SmoApplication.ModuleName, SmoApplication.trAlways, "get dependencies "); + EventSource.Log.GetDependencies(); return new Enumerator().EnumDependencies(this.ConnectionContext, dependencyRequest); } catch(ConnectionException e) @@ -307,8 +313,7 @@ internal void ExecuteNonQuery(StringCollection queries, ExecutionTypes execution BeforeSql(); foreach(string q in queries) { - Diagnostics.TraceHelper.Trace(SmoApplication.ModuleName, SmoApplication.trAlways, - "execute sql: " + q); + EventSource.Log.ExecutionMessage("execute sql: " + q); } #endif foreach(string q in queries) @@ -338,7 +343,7 @@ internal void ExecuteNonQuery(string sqlCommand, ExecutionTypes executionType) { #if INCLUDE_PERF_COUNT BeforeSql(); - Diagnostics.TraceHelper.Trace(SmoApplication.ModuleName, SmoApplication.trAlways, "execute sql: " + sqlCommand); + EventSource.Log.ExecuteSql(sqlCommand); #endif DumpTraceString("execute sql: " + sqlCommand); @@ -762,8 +767,7 @@ internal bool Recording get { #if DEBUGTRACE - Diagnostics.TraceHelper.Trace(SmoApplication.ModuleName, SmoApplication.trAlways, - "recording: " + (SqlExecutionModes.ExecuteSql != ( SqlExecutionModes.ExecuteSql & this.ConnectionContext.SqlExecutionModes )).ToString(SmoApplication.DefaultCulture)); + EventSource.Log.ExecutionMessage("recording: " + (SqlExecutionModes.ExecuteSql != ( SqlExecutionModes.ExecuteSql & this.ConnectionContext.SqlExecutionModes )).ToString(SmoApplication.DefaultCulture)); #endif return SqlExecutionModes.ExecuteSql != ( SqlExecutionModes.ExecuteSql & this.ConnectionContext.SqlExecutionModes ); } @@ -832,12 +836,16 @@ internal void Abort() private void DumpTraceString(string s) { - if (s.ToLower(SmoApplication.DefaultCulture).Contains("password")) + // Only perform expensive string operations if execution logging is enabled + if (EventSource.Log.IsEnabled(EventLevel.Informational, EventSource.Keywords.Execution)) { - s = "This statement contains sensitive information and has been replaced for security reasons."; - } + if (s.ToLower(SmoApplication.DefaultCulture).Contains("password")) + { + s = "This statement contains sensitive information and has been replaced for security reasons."; + } - Diagnostics.TraceHelper.Trace(SmoApplication.ModuleName, SmoApplication.trAlways, "{0}", s); + EventSource.Log.ExecutionMessage(s); + } } #if INCLUDE_PERF_COUNT diff --git a/src/Microsoft/SqlServer/Management/Smo/ExtendedPropertyBase.cs b/src/Microsoft/SqlServer/Management/Smo/ExtendedPropertyBase.cs index 34b7e055..701cc3b6 100644 --- a/src/Microsoft/SqlServer/Management/Smo/ExtendedPropertyBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/ExtendedPropertyBase.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Specialized; using System.Text; +using System.Diagnostics; using Microsoft.SqlServer.Management.Sdk.Sfc.Metadata; using Cmn = Microsoft.SqlServer.Management.Common; @@ -67,14 +68,14 @@ private struct TypeNamePair // Fills in the slot of typeNames_ pair array private void SetTypeNamePair(int level, string type, string name) { - Diagnostics.TraceHelper.Assert(level >= 0 && level <= 2); + Debug.Assert(level >= 0 && level <= 2); // Trying to fill higher slots when lower are not filled indicates a bug #if DEBUG for (int i = 0; i < level; ++i) { - Diagnostics.TraceHelper.Assert(typeNames_[i].type != null); - Diagnostics.TraceHelper.Assert(typeNames_[i].name != null); + Debug.Assert(typeNames_[i].type != null); + Debug.Assert(typeNames_[i].name != null); } #endif @@ -259,6 +260,9 @@ internal ScriptingParameters(SqlSmoObject objParent, ScriptingPreferences sp) case "ExternalLibrary": SetTypeNamePair(0, "EXTERNAL LIBRARY", objParent.InternalName); break; + case nameof(ExternalModel): + SetTypeNamePair(0, "EXTERNAL MODEL", objParent.InternalName); + break; case "UserDefinedType": SetSchema(objParent, sp); SetTypeNamePair(1, "TYPE", objParent.InternalName); diff --git a/src/Microsoft/SqlServer/Management/Smo/ExtendedStoredProcedureBase.cs b/src/Microsoft/SqlServer/Management/Smo/ExtendedStoredProcedureBase.cs index 46a3b0b4..f32e5044 100644 --- a/src/Microsoft/SqlServer/Management/Smo/ExtendedStoredProcedureBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/ExtendedStoredProcedureBase.cs @@ -136,7 +136,7 @@ internal override void ScriptDrop(StringCollection queries, ScriptingPreferences internal override PropagateInfo[] GetPropagateInfo(PropagateAction action) { return new PropagateInfo[] { - new PropagateInfo(ServerVersion.Major < 9 ? null : ExtendedProperties, true, ExtendedProperty.UrnSuffix ) + new PropagateInfo(ExtendedProperties, true, ExtendedProperty.UrnSuffix ) }; } diff --git a/src/Microsoft/SqlServer/Management/Smo/ExternalModelBase.cs b/src/Microsoft/SqlServer/Management/Smo/ExternalModelBase.cs new file mode 100644 index 00000000..571e4b3b --- /dev/null +++ b/src/Microsoft/SqlServer/Management/Smo/ExternalModelBase.cs @@ -0,0 +1,493 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +using System; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.ComponentModel; +using System.Text; +using Microsoft.SqlServer.Management.Sdk.Sfc.Metadata; +using Microsoft.SqlServer.Management.Sdk.Sfc; +using Microsoft.SqlServer.Server; +using Cmn = Microsoft.SqlServer.Management.Common; + +namespace Microsoft.SqlServer.Management.Smo +{ + + /// + /// Represents an external model in SQL Server, which can be created, altered, or dropped. + /// Provides scripting capabilities for T-SQL statements like CREATE, ALTER, and DROP. + /// + public partial class ExternalModel : NamedSmoObject, Cmn.ICreatable, Cmn.IAlterable, Cmn.IDroppable, + Cmn.IDropIfExists, IExtendedProperties, IScriptable + { + private static class Scripts + { + public const string BEGIN = "BEGIN"; + public const string END = "END"; + public const string INCLUDE_EXISTS_EXTERNAL_MODEL = + "IF {0} EXISTS (SELECT * FROM sys.external_models WHERE name = N{1})"; + } + + #region Constructors + + internal ExternalModel(AbstractCollectionBase parentColl, ObjectKeyBase key, SqlSmoState state) + : base(parentColl, key, state) + { + } + + + #endregion + + #region Properties + + /// + /// Gets the URN suffix for the ExternalModel object. + /// + public static string UrnSuffix + { + get { return nameof(ExternalModel); } + } + + /// + /// Extended properties of the model. + /// + [SfcObject(SfcContainerRelationship.ChildContainer, SfcContainerCardinality.ZeroToAny, typeof(ExtendedProperty))] + public ExtendedPropertyCollection ExtendedProperties + { + get + { + CheckObjectState(); + if (null == this.m_ExtendedProperties) + { + this.m_ExtendedProperties = new ExtendedPropertyCollection(this); + } + return this.m_ExtendedProperties; + } + } + + internal override PropagateInfo[] GetPropagateInfo(PropagateAction action) + { + return new PropagateInfo[] { new PropagateInfo(this.IsSupportedObject() ? null : ExtendedProperties, true, ExtendedProperty.UrnSuffix) }; + } + + #endregion + + #region Create Methods + + public void Create() + { + base.CreateImpl(); + } + + #endregion + + #region Drop Methods + + public void Drop() + { + base.DropImpl(); + } + + public void DropIfExists() + { + base.DropImpl(true); + } + + #endregion + + #region Alter Methods + + public void Alter() + { + base.AlterImpl(); + } + + + #endregion + + #region InternalOverrides + + /// + /// Generates the T-SQL script for dropping the external model. + /// + /// The collection to which the script will be added. + /// Scripting preferences. + internal override void ScriptDrop(StringCollection dropQuery, ScriptingPreferences sp) + { + string fullyFormattedName = FormatFullNameForScripting(sp); + + // check the external model object state + CheckObjectState(); + + StringBuilder sb = new StringBuilder(Globals.INIT_BUFFER_SIZE); + + // build the T-SQL script to drop the specified external model, if it exists + // add a comment header to the T-SQL script + if (sp.IncludeScripts.Header) + { + sb.Append(ExceptionTemplates.IncludeHeader( + ExternalModel.UrnSuffix, fullyFormattedName, DateTime.Now.ToString(GetDbCulture()))); + sb.Append(sp.NewLine); + } + + // check if the specified external model object exists before attempting to drop it + if (sp.IncludeScripts.ExistenceCheck) + { + sb.AppendFormat(SmoApplication.DefaultCulture, IncludeExistsExternalModel(exists: true, GetName(sp))); + sb.Append(sp.NewLine); + sb.Append(Scripts.BEGIN); + sb.Append(sp.NewLine); + } + + sb.Append("DROP EXTERNAL MODEL " + fullyFormattedName); + + if (sp.IncludeScripts.ExistenceCheck) + { + sb.Append(sp.NewLine); + sb.Append(Scripts.END); + sb.Append(sp.NewLine); + } + + dropQuery.Add(sb.ToString()); + } + + /// + /// Generates the T-SQL script for creating the external model. + /// + /// The collection to which the script will be added. + /// Scripting preferences. + internal override void ScriptCreate(StringCollection createQuery, ScriptingPreferences sp) + { + /* CREATE EXTERNAL MODEL [model_name] AUTHORIZATION [owner_name] + * WITH ( + * LOCATION = N'https://path/to/model', + * API_FORMAT = N'OpenAI', + * MODEL_TYPE = Embeddings, + * MODEL = N'model-name', + * [PARAMETERS = '{ "valid": "json" }'], + * [CREDENTIAL = credential_name] + * ) + */ + + const string LocationPropertyName = nameof(Location); + const string ApiFormatPropertyName = nameof(ApiFormat); + const string ModelTypePropertyName = nameof(ModelType); + const string ModelPropertyName = nameof(Model); + const string ParametersPropertyName = nameof(Parameters); + const string CredentialPropertyName = nameof(Credential); + + // Check SQL Server version supports external models + this.ThrowIfNotSupported(typeof(ExternalModel), sp); + + ExternalModelType externalModelType = ExternalModelType.Embeddings; + + // Validate required properties exist + ValidatePropertySet(LocationPropertyName, sp); + ValidatePropertySet(ApiFormatPropertyName, sp); + ValidatePropertySet(ModelPropertyName, sp); + + string location = string.Empty; + string apiFormat = string.Empty; + string model = string.Empty; + + // Get required property values + location = (string)this.GetPropValue(LocationPropertyName); + apiFormat = (string)this.GetPropValue(ApiFormatPropertyName); + model = (string)this.GetPropValue(ModelPropertyName); + + externalModelType = (ExternalModelType)this.GetPropValue(ModelTypePropertyName); + // Validate enum + if (!Enum.IsDefined(typeof(ExternalModelType), externalModelType)) + { + throw new WrongPropertyValueException(ExceptionTemplates.UnknownEnumeration(externalModelType.ToString())); + } + + string fullyFormattedName = FormatFullNameForScripting(sp); + StringBuilder sb = new StringBuilder(Globals.INIT_BUFFER_SIZE); + TypeConverter typeConverter = SmoManagementUtil.GetTypeConverter(typeof(ExternalModelType)); + + // Add header comment if requested + if (sp.IncludeScripts.Header) + { + sb.Append(ExceptionTemplates.IncludeHeader( + ExternalModel.UrnSuffix, fullyFormattedName, + DateTime.Now.ToString(GetDbCulture()))); + sb.Append(sp.NewLine); + } + + // Add existence check if requested + if (sp.IncludeScripts.ExistenceCheck) + { + sb.AppendFormat(SmoApplication.DefaultCulture, Scripts.INCLUDE_EXISTS_EXTERNAL_MODEL, + "NOT", FormatFullNameForScripting(sp, false)); + sb.Append(sp.NewLine); + sb.Append(Scripts.BEGIN); + sb.Append(sp.NewLine); + } + + sb.AppendFormat(SmoApplication.DefaultCulture, + "CREATE EXTERNAL MODEL {0} ", fullyFormattedName); + + // AUTHORIZATION block + Property property; + if (sp.IncludeScripts.Owner && (null != (property = this.Properties.Get(nameof(Owner))).Value)) + { + sb.AppendFormat(" AUTHORIZATION [{0}]", SqlBraket(property.Value.ToString())); + sb.Append(sp.NewLine); + } + + sb.Append("WITH "); + sb.Append(Globals.LParen); + + // Required properties + sb.AppendFormat(SmoApplication.DefaultCulture, "LOCATION = {0}", Util.MakeSqlString(location)); + sb.Append(", "); + sb.AppendFormat(SmoApplication.DefaultCulture, "API_FORMAT = {0}", Util.MakeSqlString(apiFormat)); + sb.Append(", "); + sb.AppendFormat(SmoApplication.DefaultCulture, "MODEL_TYPE = {0}", typeConverter.ConvertToInvariantString(externalModelType)); + sb.Append(", "); + sb.AppendFormat(SmoApplication.DefaultCulture, "MODEL = {0}", Util.MakeSqlString(model)); + + // Optional properties + var appendComma = true; + + // Parameters (as JSON) + AppendStringPropertyToScript(sb, ParametersPropertyName, "PARAMETERS", sp, ref appendComma); + + // Credential (optional) + AppendNamedPropertyToScript(sb, CredentialPropertyName, "CREDENTIAL", sp, ref appendComma); + + sb.Append(Globals.RParen); + + if (sp.IncludeScripts.ExistenceCheck) + { + sb.Append(sp.NewLine); + sb.Append(Scripts.END); + sb.Append(sp.NewLine); + } + + createQuery.Add(sb.ToString()); + } + + /// + /// Generates the T-SQL script for altering the external model. + /// + /// The collection to which the script will be added. + /// Scripting preferences. + internal override void ScriptAlter(StringCollection alterQuery, ScriptingPreferences sp) + { + /* ALTER EXTERNAL MODEL model_name + * SET ( + * LOCATION = N'https://path/to/model', + * API_FORMAT = N'OpenAI', + * MODEL_TYPE = Embeddings, + * MODEL = N'modelname', + * [PARAMETERS = '{ "valid": "json" }'], + * [CREDENTIAL = credential_name] + * ) + */ + + const string LocationPropertyName = nameof(Location); + const string ApiFormatPropertyName = nameof(ApiFormat); + const string ModelTypePropertyName = nameof(ModelType); + const string ModelPropertyName = nameof(Model); + const string ParametersPropertyName = nameof(Parameters); + const string CredentialPropertyName = nameof(Credential); + + // Check SQL Server version supports external models + this.ThrowIfNotSupported(typeof(ExternalModel), sp); + + // Skip scripting ALTER if the object is in the Creating state + if (this.State == SqlSmoState.Creating) + { + return; + } + + string fullyFormattedName = FormatFullNameForScripting(sp); + StringBuilder sb = new StringBuilder(Globals.INIT_BUFFER_SIZE); + TypeConverter typeConverter = SmoManagementUtil.GetTypeConverter(typeof(ExternalModelType)); + + // Add a comment header to the T-SQL script + if (sp.IncludeScripts.Header) + { + sb.Append(ExceptionTemplates.IncludeHeader( + ExternalModel.UrnSuffix, fullyFormattedName, + DateTime.Now.ToString(GetDbCulture()))); + sb.Append(sp.NewLine); + } + + sb.AppendFormat(SmoApplication.DefaultCulture, + "ALTER EXTERNAL MODEL {0} SET ", fullyFormattedName); + sb.Append(Globals.LParen); + + var addComma = false; + + // All properties are alterable + var location = AppendStringPropertyToScript(sb, LocationPropertyName, "LOCATION", sp, ref addComma); + var apiFormat = AppendStringPropertyToScript(sb, ApiFormatPropertyName, "API_FORMAT", sp, ref addComma); + var model = AppendStringPropertyToScript(sb, ModelPropertyName, "MODEL", sp, ref addComma); + var parameters = AppendStringPropertyToScript(sb, ParametersPropertyName, "PARAMETERS", sp, ref addComma); + var credential = AppendNamedPropertyToScript(sb, CredentialPropertyName, "CREDENTIAL", sp, ref addComma); + + if (IsSupportedProperty(ModelTypePropertyName, sp) && !GetPropertyOptional(ModelTypePropertyName).IsNull) + { + var externalModelType = (ExternalModelType)GetPropValueOptional(ModelTypePropertyName); + if (addComma) + { + sb.Append(", "); + } + sb.AppendFormat(SmoApplication.DefaultCulture, "MODEL_TYPE = {0}", typeConverter.ConvertToInvariantString(externalModelType)); + addComma = true; + } + + // If no properties are being altered, return without generating a script + if (string.IsNullOrEmpty(location) && + string.IsNullOrEmpty(apiFormat) && + string.IsNullOrEmpty(model) && + string.IsNullOrEmpty(parameters) && + string.IsNullOrEmpty(credential)) + { + // No properties to alter, this could be called as part of a larger operation + // so we just return without throwing an error + return; + } + + sb.Append(Globals.RParen); + + alterQuery.Add(sb.ToString()); + } + + #endregion + + #region Helpers + + /// + /// Validates the specified property is not null and has a + /// non-null value. + /// Throws exception, + /// if the property is null, or + /// its value is null or an empty string. + /// + /// The property name. + /// The scripting preferences. + private void ValidatePropertySet(string propertyName, ScriptingPreferences sp) + { + if (IsSupportedProperty(propertyName, sp)) + { + if (this.GetPropertyOptional(propertyName).IsNull) + { + throw new ArgumentNullException(propertyName); + } + + string propertyValue = this.GetPropValue(propertyName).ToString(); + if (string.IsNullOrEmpty(propertyValue)) + { + throw new PropertyNotSetException(propertyName); + } + } + } + + /// + /// Appends a property and its value to a sql script in the provided string builder. Property value will be wrapped in string quotes. + /// + /// StringBuilder that contains the sql script to append to. + /// Name of the property. + /// The T-SQL name for the property to use in the script. + /// Scripting preferences to use when checking if the property is supported. + /// Whether to add a comma and space to the beginning of the appended script text. + /// A string representing the property's value. + private string AppendStringPropertyToScript(StringBuilder sb, string propName, string sqlPropName, ScriptingPreferences sp, ref bool addComma) + => AppendPropertyToScript(sb, propName, sqlPropName, sp, useBrackets: false, ref addComma); + + /// + /// Appends a property and its value to a sql script in the provided string builder. Property value will be wrapped in square brackets. + /// + /// StringBuilder that contains the sql script to append to. + /// Name of the property. + /// The T-SQL name for the property to use in the script. + /// Scripting preferences to use when checking if the property is supported. + /// Whether to add a comma and space to the beginning of the appended script text. + /// A string representing the property's value. + private string AppendNamedPropertyToScript(StringBuilder sb, string propName, string sqlPropName, ScriptingPreferences sp, ref bool addComma) + => AppendPropertyToScript(sb, propName, sqlPropName, sp, useBrackets: true, ref addComma); + + /// + /// Appends a property and its value to a sql script in the provided string builder. + /// + /// StringBuilder that contains the sql script to append to. + /// Name of the property. + /// The T-SQL name for the property to use in the script. + /// Scripting preferences to use when checking if the property is supported. + /// Whether to wrap the property value in string quotes or square brackets. + /// Whether to add a comma and space to the beginning of the appended script text. + /// A string representing the property's value. + private string AppendPropertyToScript(StringBuilder sb, string propName, string sqlPropName, ScriptingPreferences sp, bool useBrackets, ref bool addComma) + { + string propertyValue = string.Empty; + if (IsSupportedProperty(propName, sp) + && !GetPropertyOptional(propName).IsNull) + { + propertyValue = Convert.ToString(GetPropValueOptional(propName), SmoApplication.DefaultCulture); + if (!string.IsNullOrEmpty(propertyValue)) + { + if (addComma) + { + sb.Append(", "); + } + var propertyStr = useBrackets ? MakeSqlBraket(propertyValue) : Util.MakeSqlString(propertyValue); + sb.Append($"{sqlPropName.ToUpper()} = {propertyStr}"); + addComma = true; + } + } + return propertyValue; + } + #endregion + + public StringCollection Script() + { + return ScriptImpl(); + } + + public StringCollection Script(ScriptingOptions scriptingOptions) + { + return ScriptImpl(scriptingOptions); + } + + protected override bool IsObjectDirty() + { + return (base.IsObjectDirty()); + } + + protected override void MarkDropped() + { + base.MarkDropped(); + } + + /// + /// Returns a script to check existence or not existence of an external model. + /// + /// check existence or not existence + /// Name of the external model + private static string IncludeExistsExternalModel(bool exists, string name) + { + return $"IF {(exists ? "" : "NOT")} EXISTS (SELECT * from sys.external_models models WHERE models.name = '{SqlString(name)}')"; + } + + internal static string[] GetScriptFields(Type parentType, + Microsoft.SqlServer.Management.Common.ServerVersion version, + Cmn.DatabaseEngineType databaseEngineType, + Cmn.DatabaseEngineEdition databaseEngineEdition, + bool defaultTextMode) + { + return new string[] { + nameof(ApiFormat), + nameof(Credential), + nameof(Location), + nameof(Model), + nameof(ModelType), + nameof(Parameters) + }; + } + } +} \ No newline at end of file diff --git a/src/Microsoft/SqlServer/Management/Smo/Facets/DatabaseAdapter.cs b/src/Microsoft/SqlServer/Management/Smo/Facets/DatabaseAdapter.cs index 2628d85a..1477fba2 100644 --- a/src/Microsoft/SqlServer/Management/Smo/Facets/DatabaseAdapter.cs +++ b/src/Microsoft/SqlServer/Management/Smo/Facets/DatabaseAdapter.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.Facets; using Sfc = Microsoft.SqlServer.Management.Sdk.Sfc; @@ -227,7 +228,7 @@ public string GetVolume(string file) /// protected bool DataFileVolumeNotIn(List checkVolumes) { - Diagnostics.TraceHelper.Assert(checkVolumes != null, "DataFileVolumeNotIn parameter checkVolumes should not be null"); + Debug.Assert(checkVolumes != null, "DataFileVolumeNotIn parameter checkVolumes should not be null"); bool dataNotInCheck = true; if (checkVolumes.Count > 0) // skip the check if there are no dives to compare against. diff --git a/src/Microsoft/SqlServer/Management/Smo/Facets/DatabasePerformance.cs b/src/Microsoft/SqlServer/Management/Smo/Facets/DatabasePerformance.cs index ffc1c4b8..81602c56 100644 --- a/src/Microsoft/SqlServer/Management/Smo/Facets/DatabasePerformance.cs +++ b/src/Microsoft/SqlServer/Management/Smo/Facets/DatabasePerformance.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; +using System.Diagnostics; using Microsoft.SqlServer.Management.Facets; using Sfc = Microsoft.SqlServer.Management.Sdk.Sfc; @@ -119,9 +120,9 @@ public bool CollationMatchesModelOrMaster { get { - Diagnostics.TraceHelper.Assert(null != this.Database.Parent, "Database Performance facet Database Parent object is null"); - Diagnostics.TraceHelper.Assert(null != this.Database.Parent.Databases["master"], "Database Performance facet master database is null"); - Diagnostics.TraceHelper.Assert(null != this.Database.Parent.Databases["model"], "Database Performance facet model database is null"); + Debug.Assert(null != this.Database.Parent, "Database Performance facet Database Parent object is null"); + Debug.Assert(null != this.Database.Parent.Databases["master"], "Database Performance facet master database is null"); + Debug.Assert(null != this.Database.Parent.Databases["model"], "Database Performance facet model database is null"); return ((this.Database.Collation == this.Database.Parent.Databases["master"].Collation) || (this.Database.Collation == this.Database.Parent.Databases["model"].Collation)); } @@ -138,9 +139,9 @@ public override void Refresh() this.Database.LogFiles.Refresh(); this.Database.FileGroups.Refresh(); - Diagnostics.TraceHelper.Assert(null != this.Database.Parent, "Database Performance facet Database Parent object is null"); - Diagnostics.TraceHelper.Assert(null != this.Database.Parent.Databases["master"], "Database Performance facet master database is null"); - Diagnostics.TraceHelper.Assert(null != this.Database.Parent.Databases["model"], "Database Performance facet master database is null"); + Debug.Assert(null != this.Database.Parent, "Database Performance facet Database Parent object is null"); + Debug.Assert(null != this.Database.Parent.Databases["master"], "Database Performance facet master database is null"); + Debug.Assert(null != this.Database.Parent.Databases["model"], "Database Performance facet model database is null"); this.Database.Parent.Databases["master"].Refresh(); this.Database.Parent.Databases["model"].Refresh(); diff --git a/src/Microsoft/SqlServer/Management/Smo/Facets/DatabaseSecurity.cs b/src/Microsoft/SqlServer/Management/Smo/Facets/DatabaseSecurity.cs index bfe5f1cb..59608842 100644 --- a/src/Microsoft/SqlServer/Management/Smo/Facets/DatabaseSecurity.cs +++ b/src/Microsoft/SqlServer/Management/Smo/Facets/DatabaseSecurity.cs @@ -4,6 +4,7 @@ using System; using System.ComponentModel; using System.Data; +using System.Diagnostics; using System.Globalization; using Microsoft.SqlServer.Management.Diagnostics; using Microsoft.SqlServer.Management.Facets; @@ -59,7 +60,7 @@ public bool IsOwnerSysadmin { get { - Diagnostics.TraceHelper.Assert(this.Database.Parent != null, "Database Security Adapter database Parent is null"); + Debug.Assert(this.Database.Parent != null, "Database Security Adapter database Parent is null"); // Owner can be lost for attached database // @@ -98,7 +99,7 @@ public override void Refresh() this.Database.SymmetricKeys.Refresh(); this.Database.AsymmetricKeys.Refresh(); - Diagnostics.TraceHelper.Assert(this.Database.Parent != null, "Database Security Adapter database Parent is null"); + Debug.Assert(this.Database.Parent != null, "Database Security Adapter database Parent is null"); this.Database.Parent.Logins.Refresh(); } #endregion diff --git a/src/Microsoft/SqlServer/Management/Smo/FullTextCatalogBase.cs b/src/Microsoft/SqlServer/Management/Smo/FullTextCatalogBase.cs index 87506f72..9ade5a1a 100644 --- a/src/Microsoft/SqlServer/Management/Smo/FullTextCatalogBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/FullTextCatalogBase.cs @@ -142,8 +142,7 @@ private void ScriptCreateCatalog(StringCollection queries, ScriptingPreferences // ON FILEGROUP if (sp.TargetServerVersion == SqlServerVersion.Version90) { - if (ServerVersion.Major >= 9 && - sp.Storage.FileGroup) + if (sp.Storage.FileGroup) { if ((null != (property = this.GetPropertyOptional("FileGroup")).Value) && (property.Value.ToString().Length > 0)) { @@ -171,28 +170,25 @@ private void ScriptCreateCatalog(StringCollection queries, ScriptingPreferences } } - if (ServerVersion.Major >= 9) + // WITH ACCENT_SENSITIVITY {ON | OFF} + if (null != (property = this.Properties.Get("IsAccentSensitive")).Value) { - // WITH ACCENT_SENSITIVITY {ON | OFF} - if (null != (property = this.Properties.Get("IsAccentSensitive")).Value) - { - sb.AppendFormat(SmoApplication.DefaultCulture, "WITH ACCENT_SENSITIVITY = {0}", ((bool)property.Value) ? "ON" : "OFF"); - sb.Append(sp.NewLine); - } + sb.AppendFormat(SmoApplication.DefaultCulture, "WITH ACCENT_SENSITIVITY = {0}", ((bool)property.Value) ? "ON" : "OFF"); + sb.Append(sp.NewLine); + } - // AS DEFAULT - if ((null != (property = this.Properties.Get("IsDefault")).Value) && (true == (bool)property.Value)) - { - sb.Append("AS DEFAULT"); - sb.Append(sp.NewLine); - } + // AS DEFAULT + if ((null != (property = this.Properties.Get("IsDefault")).Value) && (true == (bool)property.Value)) + { + sb.Append("AS DEFAULT"); + sb.Append(sp.NewLine); + } - // AUTHORIZATION - if (sp.IncludeScripts.Owner && (null != (property = this.Properties.Get("Owner")).Value) && (property.Value.ToString().Length > 0)) - { - sb.AppendFormat("AUTHORIZATION [{0}]", SqlBraket(property.Value.ToString())); - sb.Append(sp.NewLine); - } + // AUTHORIZATION + if (sp.IncludeScripts.Owner && (null != (property = this.Properties.Get("Owner")).Value) && (property.Value.ToString().Length > 0)) + { + sb.AppendFormat("AUTHORIZATION [{0}]", SqlBraket(property.Value.ToString())); + sb.Append(sp.NewLine); } } @@ -224,7 +220,7 @@ private void ScriptAlterCatalog(StringCollection queries, ScriptingPreferences s bool altered = false; // Target version >= 9 - if (sp.TargetServerVersion >= SqlServerVersion.Version90 && ServerVersion.Major >= 9) + if (sp.TargetServerVersion >= SqlServerVersion.Version90) { // For now, only one property, Owner, is supported by this method. // If adding more properties, put them in front of Owner and @@ -271,13 +267,8 @@ public void DropIfExists() /// internal override void AddScriptPermission(StringCollection query, ScriptingPreferences sp) { - // return if source version is less than 9 because permissions on ApplicationRoles were - // not supported prior to that - if (Parent.Parent.Information.Version.Major < 9) - { - return; - } - + // Permissions on FullText Catalogs were introduced in SQL Server 2005 (version 9). + // Since minimum supported version is now SQL Server 2008 (version 10), this is always supported. base.AddScriptPermission(query, sp); } @@ -360,53 +351,30 @@ public void Rebuild() Database db = (Database)ParentColl.ParentInstance; statements.Add(string.Format(SmoApplication.DefaultCulture, Scripts.USEDB, SqlBraket(db.Name))); - if (ServerVersion.Major >= 9) - { - statements.Add(string.Format(SmoApplication.DefaultCulture, - "ALTER FULLTEXT CATALOG [{0}] REBUILD", SqlBraket(this.Name))); - } - else - { - statements.Add(string.Format(SmoApplication.DefaultCulture, - "EXEC dbo.sp_fulltext_catalog @ftcat=N'{0}', @action=N'rebuild'", - SqlString(this.Name))); - } + statements.Add(string.Format(SmoApplication.DefaultCulture, + "ALTER FULLTEXT CATALOG [{0}] REBUILD", SqlBraket(this.Name))); this.ExecutionManager.ExecuteNonQuery(statements); } public void Rebuild(bool accentSensitive) { - if (ServerVersion.Major >= 9) - { - StringCollection statements = new StringCollection(); - Database db = (Database)ParentColl.ParentInstance; - statements.Add(string.Format(SmoApplication.DefaultCulture, Scripts.USEDB, SqlBraket(db.Name))); - statements.Add(string.Format(SmoApplication.DefaultCulture, - "ALTER FULLTEXT CATALOG [{0}] REBUILD WITH ACCENT_SENSITIVITY = {1}", - SqlBraket(this.Name), accentSensitive ? "ON" : "OFF")); - this.ExecutionManager.ExecuteNonQuery(statements); - } - else - { - throw new UnsupportedVersionException(ExceptionTemplates.UnsupportedVersion(ServerVersion.ToString())); - } + StringCollection statements = new StringCollection(); + Database db = (Database)ParentColl.ParentInstance; + statements.Add(string.Format(SmoApplication.DefaultCulture, Scripts.USEDB, SqlBraket(db.Name))); + statements.Add(string.Format(SmoApplication.DefaultCulture, + "ALTER FULLTEXT CATALOG [{0}] REBUILD WITH ACCENT_SENSITIVITY = {1}", + SqlBraket(this.Name), accentSensitive ? "ON" : "OFF")); + this.ExecutionManager.ExecuteNonQuery(statements); } public void Reorganize() { - if (ServerVersion.Major >= 9) - { - StringCollection statements = new StringCollection(); - Database db = (Database)ParentColl.ParentInstance; - statements.Add(string.Format(SmoApplication.DefaultCulture, Scripts.USEDB, SqlBraket(db.Name))); - statements.Add(string.Format(SmoApplication.DefaultCulture, - "ALTER FULLTEXT CATALOG [{0}] REORGANIZE", SqlBraket(this.Name))); - this.ExecutionManager.ExecuteNonQuery(statements); - } - else - { - throw new UnsupportedVersionException(ExceptionTemplates.UnsupportedVersion(ServerVersion.ToString())); - } + StringCollection statements = new StringCollection(); + Database db = (Database)ParentColl.ParentInstance; + statements.Add(string.Format(SmoApplication.DefaultCulture, Scripts.USEDB, SqlBraket(db.Name))); + statements.Add(string.Format(SmoApplication.DefaultCulture, + "ALTER FULLTEXT CATALOG [{0}] REORGANIZE", SqlBraket(this.Name))); + this.ExecutionManager.ExecuteNonQuery(statements); } private enum CatalogPopulationActionEx @@ -422,45 +390,23 @@ private void StartOrStopPopulation(CatalogPopulationActionEx action) // sp_fulltext_catalog has been deprecated in Yukon, so we need to iterate over FT indexes // in the catalog and generate ALTER FULLTEXT INDEX - if (ServerVersion.Major >= 9) // Yukon or later server + DataTable dt = EnumTables(); + foreach (DataRow dr in dt.Rows) { - DataTable dt = EnumTables(); - foreach (DataRow dr in dt.Rows) - { - Table table = db.Tables[(string)dr["Table_Name"], (string)dr["Table_Schema"]]; + Table table = db.Tables[(string)dr["Table_Name"], (string)dr["Table_Schema"]]; - Debug.Assert(table != null); - Debug.Assert(table.FullTextIndex != null); + Debug.Assert(table != null); + Debug.Assert(table.FullTextIndex != null); - if (action == CatalogPopulationActionEx.Stop) - { - table.FullTextIndex.StopPopulation(); - } - else - { - IndexPopulationAction indexAction = (action == CatalogPopulationActionEx.Incremental ? IndexPopulationAction.Incremental : IndexPopulationAction.Full); - table.FullTextIndex.StartPopulation(indexAction); - } - } - } - else - { - StringCollection statements = new StringCollection(); - string action_stmt; if (action == CatalogPopulationActionEx.Stop) { - action_stmt = "stop"; + table.FullTextIndex.StopPopulation(); } else { - action_stmt = (action == CatalogPopulationActionEx.Incremental ? "start_incremental" : "start_full"); + IndexPopulationAction indexAction = (action == CatalogPopulationActionEx.Incremental ? IndexPopulationAction.Incremental : IndexPopulationAction.Full); + table.FullTextIndex.StartPopulation(indexAction); } - statements.Add(string.Format(SmoApplication.DefaultCulture, Scripts.USEDB, SqlBraket(db.Name))); - statements.Add(string.Format(SmoApplication.DefaultCulture, - "EXEC dbo.sp_fulltext_catalog @ftcat=N'{0}', @action=N'{1}'", - SqlString(this.Name), - action_stmt)); - db.ExecutionManager.ExecuteNonQuery(statements); } } @@ -522,7 +468,7 @@ internal void Validate_set_IsDefault(Property prop, object newValue) /// internal override void ValidateProperty(Property prop, object value) { - if (this.ServerVersion.Major >= 9 && prop.Name == "IsDefault") + if (prop.Name == "IsDefault") { Validate_set_IsDefault(prop, value); } @@ -530,16 +476,13 @@ internal override void ValidateProperty(Property prop, object value) protected override void PostCreate() { - if (this.ServerVersion.Major >= 9) - { - Property pDef = this.Properties.Get("IsDefault"); + Property pDef = this.Properties.Get("IsDefault"); - if (null != pDef.Value && (bool)pDef.Value) - { - Property parentDef = this.Parent.Properties.Get("DefaultFullTextCatalog"); - parentDef.SetValue(this.Name); - parentDef.SetRetrieved(true); - } + if (null != pDef.Value && (bool)pDef.Value) + { + Property parentDef = this.Parent.Properties.Get("DefaultFullTextCatalog"); + parentDef.SetValue(this.Name); + parentDef.SetRetrieved(true); } } diff --git a/src/Microsoft/SqlServer/Management/Smo/FullTextIndexBase.cs b/src/Microsoft/SqlServer/Management/Smo/FullTextIndexBase.cs index abd028f2..9a1095ef 100644 --- a/src/Microsoft/SqlServer/Management/Smo/FullTextIndexBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/FullTextIndexBase.cs @@ -354,17 +354,14 @@ private void ScriptCreateFullTextIndex(StringCollection queries, ScriptingPrefer onClause.AppendFormat(SmoApplication.DefaultCulture, "{0}", MakeSqlBraket(strCatalog)); } - if (this.ServerVersion.Major >= 10) + String sFilegroup = this.Properties.Get("FilegroupName").Value as String; + if (null != sFilegroup && sFilegroup.Length > 0) { - String sFilegroup = this.Properties.Get("FilegroupName").Value as String; - if (null != sFilegroup && sFilegroup.Length > 0) + if (onClause.Length > 0) { - if (onClause.Length > 0) - { - onClause.Append(Globals.commaspace); - } - onClause.AppendFormat(SmoApplication.DefaultCulture, "FILEGROUP {0}", MakeSqlBraket(sFilegroup)); + onClause.Append(Globals.commaspace); } + onClause.AppendFormat(SmoApplication.DefaultCulture, "FILEGROUP {0}", MakeSqlBraket(sFilegroup)); } if (onClause.Length > 0) @@ -404,58 +401,55 @@ private void ScriptCreateFullTextIndex(StringCollection queries, ScriptingPrefer } } - if (this.ServerVersion.Major >= 10) - { - Property propertyStopListOption = this.Properties.Get("StopListOption"); - String strStopListName = this.Properties.Get("StopListName").Value as String; + Property propertyStopListOption = this.Properties.Get("StopListOption"); + String strStopListName = this.Properties.Get("StopListName").Value as String; - if (null != propertyStopListOption.Value) + if (null != propertyStopListOption.Value) + { + if (withClause.Length > 0) { - if (withClause.Length > 0) - { - withClause.Append(Globals.commaspace); - } - withClause.Append("STOPLIST = "); - StopListOption slOption = (StopListOption)propertyStopListOption.Value; - switch (slOption) - { - case StopListOption.Off: - withClause.Append("OFF"); - if ((null != strStopListName) && (strStopListName.Length > 0)) - { - throw new SmoException(ExceptionTemplates.PropertyNotValidException("StopListName", "StopListOption", "OFF")); - } - break; - case StopListOption.System: - withClause.Append("SYSTEM"); - if ((null != strStopListName) && (strStopListName.Length > 0)) - { - throw new SmoException(ExceptionTemplates.PropertyNotValidException("StopListName", "StopListOption", "SYSTEM")); - } - break; - case StopListOption.Name: - if ((null != strStopListName) && (strStopListName.Length > 0)) - { - withClause.AppendFormat(SmoApplication.DefaultCulture, "{0}", MakeSqlBraket(strStopListName)); - } - else - { - throw new PropertyNotSetException("StopListName"); - } - break; - default: - throw new WrongPropertyValueException(ExceptionTemplates.UnknownEnumeration("StopList Name")); - } + withClause.Append(Globals.commaspace); } - else if ((null != strStopListName) && (strStopListName.Length > 0)) + withClause.Append("STOPLIST = "); + StopListOption slOption = (StopListOption)propertyStopListOption.Value; + switch (slOption) { - if (withClause.Length > 0) - { - withClause.Append(Globals.commaspace); - } - withClause.Append("STOPLIST = "); - withClause.AppendFormat(SmoApplication.DefaultCulture, "{0}", MakeSqlBraket(strStopListName)); + case StopListOption.Off: + withClause.Append("OFF"); + if ((null != strStopListName) && (strStopListName.Length > 0)) + { + throw new SmoException(ExceptionTemplates.PropertyNotValidException("StopListName", "StopListOption", "OFF")); + } + break; + case StopListOption.System: + withClause.Append("SYSTEM"); + if ((null != strStopListName) && (strStopListName.Length > 0)) + { + throw new SmoException(ExceptionTemplates.PropertyNotValidException("StopListName", "StopListOption", "SYSTEM")); + } + break; + case StopListOption.Name: + if ((null != strStopListName) && (strStopListName.Length > 0)) + { + withClause.AppendFormat(SmoApplication.DefaultCulture, "{0}", MakeSqlBraket(strStopListName)); + } + else + { + throw new PropertyNotSetException("StopListName"); + } + break; + default: + throw new WrongPropertyValueException(ExceptionTemplates.UnknownEnumeration("StopList Name")); + } + } + else if ((null != strStopListName) && (strStopListName.Length > 0)) + { + if (withClause.Length > 0) + { + withClause.Append(Globals.commaspace); } + withClause.Append("STOPLIST = "); + withClause.AppendFormat(SmoApplication.DefaultCulture, "{0}", MakeSqlBraket(strStopListName)); } // including SEARCH PROPERTY LIST [ = ] property_list_name in WITH clause @@ -645,7 +639,7 @@ private void ScriptAlterFullTextIndex(StringCollection queries, ScriptingPrefere } } - if (sp.TargetServerVersion >= SqlServerVersion.Version100 && ServerVersion.Major >= 10) + if (sp.TargetServerVersion >= SqlServerVersion.Version100) { StringBuilder sb = new StringBuilder(Globals.INIT_BUFFER_SIZE); @@ -942,19 +936,9 @@ public void Enable() TableViewBase table = this.Parent; Database db = (Database)table.ParentColl.ParentInstance; - if (ServerVersion.Major >= 9) - { - statements.Add(string.Format(SmoApplication.DefaultCulture, "USE [{0}]", SqlBraket(db.Name))); - statements.Add(string.Format(SmoApplication.DefaultCulture, - "ALTER FULLTEXT INDEX ON {0} ENABLE", table.FullQualifiedName)); - } - else - { - statements.Add(string.Format(SmoApplication.DefaultCulture, "USE [{0}]", SqlBraket(db.Name))); - statements.Add(string.Format(SmoApplication.DefaultCulture, - "EXEC dbo.sp_fulltext_table @tabname=N'{0}', @action=N'activate'", - SqlString(table.FullQualifiedName))); - } + statements.Add(string.Format(SmoApplication.DefaultCulture, "USE [{0}]", SqlBraket(db.Name))); + statements.Add(string.Format(SmoApplication.DefaultCulture, + "ALTER FULLTEXT INDEX ON {0} ENABLE", table.FullQualifiedName)); this.ExecutionManager.ExecuteNonQuery(statements); } catch (Exception e) @@ -969,48 +953,24 @@ public void StartPopulation(IndexPopulationAction action) { try { - if (ServerVersion.Major >= 8) - { - StringCollection statements = new StringCollection(); - - TableViewBase table = this.Parent; - Database db = (Database)table.ParentColl.ParentInstance; + StringCollection statements = new StringCollection(); - if (ServerVersion.Major >= 9) - { - statements.Add(string.Format(SmoApplication.DefaultCulture, "USE [{0}]", SqlBraket(db.Name))); - string actionString = string.Empty; - switch (action) - { - case IndexPopulationAction.Full: actionString = "FULL"; break; - case IndexPopulationAction.Incremental: actionString = "INCREMENTAL"; break; - default: actionString = "UPDATE"; break; - } - statements.Add(string.Format(SmoApplication.DefaultCulture, - "ALTER FULLTEXT INDEX ON {0} START {1} POPULATION", - table.FullQualifiedName, actionString)); - } - else - { - statements.Add(string.Format(SmoApplication.DefaultCulture, "USE [{0}]", SqlBraket(db.Name))); - string actionString = string.Empty; - switch (action) - { - case IndexPopulationAction.Full: actionString = "start_full"; break; - case IndexPopulationAction.Incremental: actionString = "start_incremental"; break; - default: actionString = "update_index"; break; - } - statements.Add(string.Format(SmoApplication.DefaultCulture, - "EXEC dbo.sp_fulltext_table @tabname=N'{0}', @action=N'{1}'", - SqlString(table.FullQualifiedName), actionString)); - } + TableViewBase table = this.Parent; + Database db = (Database)table.ParentColl.ParentInstance; - this.ExecutionManager.ExecuteNonQuery(statements); - } - else + statements.Add(string.Format(SmoApplication.DefaultCulture, "USE [{0}]", SqlBraket(db.Name))); + string actionString = string.Empty; + switch (action) { - throw new SmoException(ExceptionTemplates.UnsupportedVersion(ServerVersion.ToString())); + case IndexPopulationAction.Full: actionString = "FULL"; break; + case IndexPopulationAction.Incremental: actionString = "INCREMENTAL"; break; + default: actionString = "UPDATE"; break; } + statements.Add(string.Format(SmoApplication.DefaultCulture, + "ALTER FULLTEXT INDEX ON {0} START {1} POPULATION", + table.FullQualifiedName, actionString)); + + this.ExecutionManager.ExecuteNonQuery(statements); } catch (Exception e) { @@ -1024,33 +984,16 @@ public void StopPopulation() { try { - if (ServerVersion.Major >= 8) - { - StringCollection statements = new StringCollection(); + StringCollection statements = new StringCollection(); - TableViewBase table = this.Parent; - Database db = (Database)table.ParentColl.ParentInstance; + TableViewBase table = this.Parent; + Database db = (Database)table.ParentColl.ParentInstance; - if (ServerVersion.Major >= 9) - { - statements.Add(string.Format(SmoApplication.DefaultCulture, "USE [{0}]", SqlBraket(db.Name))); - statements.Add(string.Format(SmoApplication.DefaultCulture, - "ALTER FULLTEXT INDEX ON {0} STOP POPULATION", table.FullQualifiedName)); - } - else - { - statements.Add(string.Format(SmoApplication.DefaultCulture, "USE [{0}]", SqlBraket(db.Name))); - statements.Add(string.Format(SmoApplication.DefaultCulture, - "EXEC dbo.sp_fulltext_table @tabname=N'{0}', @action=N'stop'", - SqlString(table.FullQualifiedName))); - } + statements.Add(string.Format(SmoApplication.DefaultCulture, "USE [{0}]", SqlBraket(db.Name))); + statements.Add(string.Format(SmoApplication.DefaultCulture, + "ALTER FULLTEXT INDEX ON {0} STOP POPULATION", table.FullQualifiedName)); - this.ExecutionManager.ExecuteNonQuery(statements); - } - else - { - throw new SmoException(ExceptionTemplates.UnsupportedVersion(ServerVersion.ToString())); - } + this.ExecutionManager.ExecuteNonQuery(statements); } catch (Exception e) { diff --git a/src/Microsoft/SqlServer/Management/Smo/FullTextServiceBase.cs b/src/Microsoft/SqlServer/Management/Smo/FullTextServiceBase.cs index bccdf84f..ab5e0b1f 100644 --- a/src/Microsoft/SqlServer/Management/Smo/FullTextServiceBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/FullTextServiceBase.cs @@ -92,16 +92,9 @@ public void UpdateLanguageResources() { try { - if (ServerVersion.Major >= 9) - { - StringCollection statements = new StringCollection(); - statements.Add("EXEC master.dbo.sp_fulltext_service @action=N'update_languages'"); - this.ExecutionManager.ExecuteNonQuery(statements); - } - else - { - throw new SmoException(ExceptionTemplates.UnsupportedVersion(ServerVersion.ToString())); - } + StringCollection statements = new StringCollection(); + statements.Add("EXEC master.dbo.sp_fulltext_service @action=N'update_languages'"); + this.ExecutionManager.ExecuteNonQuery(statements); } catch (Exception e) { @@ -151,37 +144,34 @@ private void ScriptService(StringCollection queries, ScriptingPreferences sp) Property property; // AllowUnsignedBinaries - if (ServerVersion.Major >= 9) + if (null != (property = this.Properties.Get("AllowUnsignedBinaries")).Value) { - if (null != (property = this.Properties.Get("AllowUnsignedBinaries")).Value) + // Script Alter if dirty or Create if target version 9 or above + if ((sp.ScriptForAlter && property.Dirty) || + (!sp.ScriptForAlter && sp.TargetServerVersion >= SqlServerVersion.Version90)) { - // Script Alter if dirty or Create if target version 9 or above - if ((sp.ScriptForAlter && property.Dirty) || - (!sp.ScriptForAlter && sp.TargetServerVersion >= SqlServerVersion.Version90)) - { - statement.AppendFormat(SmoApplication.DefaultCulture, - "EXEC master.dbo.sp_fulltext_service @action=N'verify_signature', @value={0}", (bool)property.Value ? 0 : 1); - statement.Append(sp.NewLine); + statement.AppendFormat(SmoApplication.DefaultCulture, + "EXEC master.dbo.sp_fulltext_service @action=N'verify_signature', @value={0}", (bool)property.Value ? 0 : 1); + statement.Append(sp.NewLine); - queries.Add(statement.ToString()); - statement.Length = 0; - } + queries.Add(statement.ToString()); + statement.Length = 0; } + } - // LoadOSResourcesEnabled - if (null != (property = this.Properties.Get("LoadOSResourcesEnabled")).Value) + // LoadOSResourcesEnabled + if (null != (property = this.Properties.Get("LoadOSResourcesEnabled")).Value) + { + // Script Alter if dirty or Create if target version 9 or above + if ((sp.ScriptForAlter && property.Dirty) || + (!sp.ScriptForAlter && sp.TargetServerVersion >= SqlServerVersion.Version90)) { - // Script Alter if dirty or Create if target version 9 or above - if ((sp.ScriptForAlter && property.Dirty) || - (!sp.ScriptForAlter && sp.TargetServerVersion >= SqlServerVersion.Version90)) - { - statement.AppendFormat(SmoApplication.DefaultCulture, - "EXEC master.dbo.sp_fulltext_service @action=N'load_os_resources', @value={0}", (bool)property.Value ? 1 : 0); - statement.Append(sp.NewLine); + statement.AppendFormat(SmoApplication.DefaultCulture, + "EXEC master.dbo.sp_fulltext_service @action=N'load_os_resources', @value={0}", (bool)property.Value ? 1 : 0); + statement.Append(sp.NewLine); - queries.Add(statement.ToString()); - statement.Length = 0; - } + queries.Add(statement.ToString()); + statement.Length = 0; } } @@ -269,7 +259,7 @@ private void ScriptService(StringCollection queries, ScriptingPreferences sp) } //Catalog Upgrade Option - if (ServerVersion.Major >= 10 && sp.TargetServerVersion >= SqlServerVersion.Version100) + if (sp.TargetServerVersion >= SqlServerVersion.Version100) { property = this.Properties.Get("CatalogUpgradeOption"); diff --git a/src/Microsoft/SqlServer/Management/Smo/FullTextStopListBase.cs b/src/Microsoft/SqlServer/Management/Smo/FullTextStopListBase.cs index 359ff814..f534e187 100644 --- a/src/Microsoft/SqlServer/Management/Smo/FullTextStopListBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/FullTextStopListBase.cs @@ -106,7 +106,7 @@ internal override void ScriptCreate(StringCollection createQuery, ScriptingPrefe Property property; - if (sp.TargetServerVersion >= SqlServerVersion.Version100 && ServerVersion.Major >= 10) + if (sp.TargetServerVersion >= SqlServerVersion.Version100) { if (sp.IncludeScripts.Header) { @@ -230,7 +230,7 @@ internal override void ScriptDrop(StringCollection dropQuery, ScriptingPreferenc StringBuilder sb = new StringBuilder(Globals.INIT_BUFFER_SIZE); - if (sp.TargetServerVersion >= SqlServerVersion.Version100 && ServerVersion.Major >= 10) + if (sp.TargetServerVersion >= SqlServerVersion.Version100) { if (sp.IncludeScripts.Header) { diff --git a/src/Microsoft/SqlServer/Management/Smo/IndexBase.cs b/src/Microsoft/SqlServer/Management/Smo/IndexBase.cs index 253664e3..3ee20fe7 100644 --- a/src/Microsoft/SqlServer/Management/Smo/IndexBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/IndexBase.cs @@ -7,6 +7,7 @@ using System.Data; using System.Globalization; using System.Text; +using System.Diagnostics; using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.Sdk.Sfc; using Microsoft.SqlServer.Management.Sdk.Sfc.Metadata; @@ -647,8 +648,7 @@ private bool IsSpatialColumn(Column colBase) /// private bool IsCompressionCodeRequired(bool bAlter) { - Diagnostics.TraceHelper.Assert(this.ServerVersion.Major >= 10); - Diagnostics.TraceHelper.Assert((this.State == SqlSmoState.Existing) || (this.State == SqlSmoState.Creating)); + Debug.Assert((this.State == SqlSmoState.Existing) || (this.State == SqlSmoState.Creating)); if (this.State == SqlSmoState.Creating) { if (m_PhysicalPartitions != null) @@ -683,7 +683,7 @@ private bool IsXmlCompressionCodeRequired(bool isAlter) return false; } - Diagnostics.TraceHelper.Assert((this.State == SqlSmoState.Existing) || (this.State == SqlSmoState.Creating)); + Debug.Assert((this.State == SqlSmoState.Existing) || (this.State == SqlSmoState.Creating)); if (this.State == SqlSmoState.Creating) { @@ -706,8 +706,9 @@ private bool IsXmlCompressionCodeRequired(bool isAlter) internal bool HasXmlColumn(bool throwIfNotSet) { - // XML indexes supported only on version 9.0 - if (this.ServerVersion.Major < 9 || this.DatabaseEngineType != Microsoft.SqlServer.Management.Common.DatabaseEngineType.Standalone) + // XML indexes were introduced in SQL Server 2005 (version 9.0). + // Since minimum supported version is now SQL Server 2008 (version 10), only check database engine type. + if (this.DatabaseEngineType != Microsoft.SqlServer.Management.Common.DatabaseEngineType.Standalone) { return false; } @@ -724,8 +725,7 @@ internal bool HasXmlColumn(bool throwIfNotSet) internal bool HasSpatialColumn(bool throwIfNotSet) { - // Spatial indexes supported only on version 10.0 - if (this.ServerVersion.Major < 10 || this.DatabaseEngineType != Microsoft.SqlServer.Management.Common.DatabaseEngineType.Standalone) + if (this.DatabaseEngineType != Microsoft.SqlServer.Management.Common.DatabaseEngineType.Standalone) { return false; } @@ -1308,8 +1308,7 @@ private void RebuildImpl(bool allIndexes) this.GetContextDB().AddUseDb(queries, sp); - if (ServerVersion.Major < 9 || - (this.Parent is View && ((View)this.Parent).Parent.CompatibilityLevel < CompatibilityLevel.Version90)) + if (this.Parent is View && ((View)this.Parent).Parent.CompatibilityLevel < CompatibilityLevel.Version90) { TableViewTableTypeBase tvp = this.Parent as TableViewTableTypeBase; if (null != tvp) @@ -1341,8 +1340,7 @@ private void RebuildImpl(bool allIndexes) throw new FailedOperationException(ExceptionTemplates.Rebuild, this, e); } - if ((this.ServerVersion.Major >= 9) - && (null != m_PhysicalPartitions) + if ((null != m_PhysicalPartitions) && (scripter is RegularIndexScripter || (scripter is SpatialIndexScripter && this.ServerVersion.Major >= 11))) { @@ -1597,7 +1595,7 @@ public void Disable() //Disabled nonclustered or columnstore index do not have any physical partitions //So,refreshing the physical partitions collection - if (this.ServerVersion.Major > 9 && this.PhysicalPartitions != null && !this.ExecutionManager.Recording) + if (this.PhysicalPartitions != null && !this.ExecutionManager.Recording) { var indexType = this.InferredIndexType; @@ -1852,7 +1850,7 @@ internal override PropagateInfo[] GetPropagateInfo(PropagateAction action) { return new PropagateInfo[] { - new PropagateInfo(ServerVersion.Major < 10 ? null : m_PhysicalPartitions, false, false), + new PropagateInfo(m_PhysicalPartitions, false, false), new PropagateInfo(IndexedColumns, false,false), new PropagateInfo(SXIsupported ? IndexedXmlPaths : null, false,false), new PropagateInfo(SXIsupported ? IndexedXmlPathNamespaces : null, false,false), @@ -2240,12 +2238,6 @@ public DataTable EnumFragmentation(FragmentationOption fragmentationOption, int { CheckObjectState(); - //Yukon only - if (ServerVersion.Major < 9) - { - throw new UnsupportedVersionException(ExceptionTemplates.InvalidParamForVersion("EnumFragmentation", "partitionNumber", GetSqlServerVersionName())).SetHelpContext("InvalidParamForVersion"); - } - string urn = string.Format(SmoApplication.DefaultCulture, "{0}/{1}[@PartitionNumber={2}]", this.Urn.Value, GetFragOptionString(fragmentationOption), partitionNumber); Request req = new Request(urn); @@ -2549,7 +2541,6 @@ internal static string[] GetScriptFields(Type parentType, internal static string[] GetScriptFields2(Type parentType, Cmn.ServerVersion version, Cmn.DatabaseEngineType databaseEngineType, Cmn.DatabaseEngineEdition databaseEngineEdition, bool defaultTextMode, ScriptingPreferences sp) { if (((parentType.Name == "Table") || (parentType.Name == "View")) - && (version.Major > 9) && (sp.TargetServerVersion > SqlServerVersion.Version90) && (sp.Storage.DataCompression)) { @@ -2598,8 +2589,7 @@ public bool IsOnlineRebuildSupported { get { - if (this.ServerVersion.Major < 9 - || this.GetServerObject().Information.EngineEdition != Edition.EnterpriseOrDeveloper + if (this.GetServerObject().Information.EngineEdition != Edition.EnterpriseOrDeveloper || !(this.Parent is TableViewBase)) { return false; @@ -2739,4 +2729,4 @@ internal bool IsSqlDwIndex ColumnCollection IColumns.Columns => ((TableViewBase)Parent).Columns; } -} \ No newline at end of file +} diff --git a/src/Microsoft/SqlServer/Management/Smo/IndexScripter.cs b/src/Microsoft/SqlServer/Management/Smo/IndexScripter.cs index 55bd5abd..74236466 100644 --- a/src/Microsoft/SqlServer/Management/Smo/IndexScripter.cs +++ b/src/Microsoft/SqlServer/Management/Smo/IndexScripter.cs @@ -6,6 +6,7 @@ using System.Collections.Specialized; using System.ComponentModel; using System.Data; +using System.Diagnostics; #if MICROSOFTDATA #else using System.Data.SqlClient; @@ -36,7 +37,7 @@ public IndexScripter(Index index, ScriptingPreferences sp) { this.index = index; this.parent = (ScriptSchemaObjectBase)index.ParentColl.ParentInstance; - Diagnostics.TraceHelper.Assert(null != this.parent, "parent == null"); + Debug.Assert(null != this.parent, "parent == null"); this.preferences = sp; @@ -54,7 +55,7 @@ public IndexScripter(Index index, ScriptingPreferences sp) } else { - Diagnostics.TraceHelper.Assert(false, "Invalid parent"); + Debug.Assert(false, "Invalid parent"); } } @@ -419,7 +420,7 @@ private void ScriptIndexOptions(StringBuilder sb, bool forRebuild, int rebuildPa this.ScriptIndexOptionOnline(sb, forRebuild, forCreateIndex); } - if (index.ServerVersion.Major >= 9 && index.MaximumDegreeOfParallelism > 0) + if (index.MaximumDegreeOfParallelism > 0) { this.ScriptIndexOption(sb, "MAXDOP", index.MaximumDegreeOfParallelism); } @@ -837,7 +838,7 @@ private void ScriptPseudoColumn(ISet includedColumnSet, StringBuilder sb protected virtual bool ScriptColumn(IndexedColumn col, StringBuilder sb) { //IsIncludedColumnSupported - if (index.ServerVersion.Major > 9 && col.GetPropValueOptional("IsIncluded", false) && !this.IsIncludedColumnSupported) + if (col.GetPropValueOptional("IsIncluded", false) && !this.IsIncludedColumnSupported) { throw new WrongPropertyValueException(ExceptionTemplates.IncludedColumnNotSupported); } @@ -1086,7 +1087,7 @@ public string GetRebuildScript(bool allIndexes, int rebuildPartitionNumber) { //this.Validate(); - if (index.ServerVersion.Major < 9 || (parent is View && ((View)parent).Parent.CompatibilityLevel < CompatibilityLevel.Version90)) + if (parent is View && ((View)parent).Parent.CompatibilityLevel < CompatibilityLevel.Version90) { return Rebuild80(allIndexes); } @@ -1720,7 +1721,7 @@ protected override void ScriptIndexOptions(StringBuilder sb) this.ScriptIndexOption(sb, "ALLOW_PAGE_LOCKS", GetOnOffValue(RevertMeaning(index.GetPropValueOptional("DisallowPageLocks")))); } - if (alterTableScript && index.ServerVersion.Major >= 9 && index.MaximumDegreeOfParallelism > 0) + if (alterTableScript && index.MaximumDegreeOfParallelism > 0) { this.ScriptIndexOption(sb, "MAXDOP", index.MaximumDegreeOfParallelism); } @@ -1915,7 +1916,7 @@ protected override void Validate() protected override bool ScriptColumn(IndexedColumn col, StringBuilder sb) { - if (index.ServerVersion.Major < 9 || !col.GetPropValueOptional("IsIncluded", false)) + if (!col.GetPropValueOptional("IsIncluded", false)) { return base.ScriptColumn(col, sb); } @@ -2465,9 +2466,6 @@ protected override void ScriptIndexStorage(StringBuilder sb) private class VectorIndexScripter : IndexScripter { - Property vectorIndexMetric; - Property vectorIndexType; - public VectorIndexScripter(Index index, ScriptingPreferences sp) : base(index, sp) { @@ -2501,21 +2499,19 @@ protected override void ScriptIndexOptions(StringBuilder sb) private void ScriptVectorIndexOptions(StringBuilder sb) { - vectorIndexMetric = index.Properties.Get(nameof(Index.VectorIndexMetric)); - vectorIndexType = index.Properties.Get(nameof(Index.VectorIndexType)); + var vectorIndexMetric = index.GetPropValueOptional(nameof(Index.VectorIndexMetric), string.Empty); + var vectorIndexType = index.GetPropValueOptional(nameof(Index.VectorIndexType), string.Empty); // Script METRIC parameter - var strMetric = vectorIndexMetric.Value as string; - var strType = vectorIndexType.Value as string; - if (!string.IsNullOrEmpty(strMetric)) + if (!string.IsNullOrEmpty(vectorIndexMetric)) { - _ = sb.AppendFormat(SmoApplication.DefaultCulture, $"METRIC = '{SqlSmoObject.SqlString(strMetric)}'{Globals.commaspace}"); + _ = sb.AppendFormat(SmoApplication.DefaultCulture, $"METRIC = '{SqlSmoObject.SqlString(vectorIndexMetric)}'{Globals.commaspace}"); } // Script TYPE parameter - if (!string.IsNullOrEmpty(strType)) + if (!string.IsNullOrEmpty(vectorIndexType)) { - _ = sb.AppendFormat(SmoApplication.DefaultCulture, $"TYPE = '{SqlSmoObject.SqlString(strType)}'{Globals.commaspace}"); + _ = sb.AppendFormat(SmoApplication.DefaultCulture, $"TYPE = '{SqlSmoObject.SqlString(vectorIndexType)}'{Globals.commaspace}"); } } diff --git a/src/Microsoft/SqlServer/Management/Smo/JobBase.cs b/src/Microsoft/SqlServer/Management/Smo/JobBase.cs index dbb20436..b147a8c2 100644 --- a/src/Microsoft/SqlServer/Management/Smo/JobBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/JobBase.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.Data; +using System.Diagnostics; using System.Globalization; using System.Linq; @@ -433,7 +434,7 @@ public static string UrnSuffix // consructor and Alter/Create private void UpdateCategoryIDFromCategoryProperty() { - Diagnostics.TraceHelper.Assert(this.Parent != null); + Debug.Assert(this.Parent != null); string categoryName = (string)Properties.Get("Category").Value; diff --git a/src/Microsoft/SqlServer/Management/Smo/JobServerBase.cs b/src/Microsoft/SqlServer/Management/Smo/JobServerBase.cs index 924cd032..f2721237 100644 --- a/src/Microsoft/SqlServer/Management/Smo/JobServerBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/JobServerBase.cs @@ -203,8 +203,7 @@ private void ScriptProperties(StringCollection queries, ScriptingPreferences sp GetParameter(statement, sp, "LoginTimeout", "@login_timeout={0}", ref count); GetStringParameter(statement, sp, "LocalHostAlias", "@local_host_server=N'{0}'", ref count); - if (this.ServerVersion.Major >= 9 && - sp.TargetServerVersion >= SqlServerVersion.Version90) + if (sp.TargetServerVersion >= SqlServerVersion.Version90) { GetBoolParameter(statement, sp, "ReplaceAlertTokensEnabled", "@alert_replace_runtime_tokens={0}", ref count); } @@ -463,30 +462,8 @@ public void SetMsxAccount(string account, string password) { try { - ThrowIfBelowVersion80SP3(); - if (this.ServerVersion.Major >= 9) - { - throw new UnsupportedVersionException(ExceptionTemplates.UnsupportedVersion(ServerVersion.ToString())); - } - if( null == account ) - { - throw new SmoException(ExceptionTemplates.InnerException, new ArgumentNullException("account")); - } - - if ( null == password ) - { - throw new SmoException(ExceptionTemplates.InnerException, new ArgumentNullException("password")); - } - - var domainName = new StringBuilder(); - var userName = new StringBuilder(); - ParseAccountName( account, domainName, userName ); - this.ExecutionManager.ExecuteNonQuery( string.Format( - SmoApplication.DefaultCulture, - "EXEC master.dbo.xp_sqlagent_msx_account N'SET', N'{0}', N'{1}', N'{2}'", - SqlString( domainName.ToString()), - SqlString(userName.ToString()), - SqlString(password))); + // This method is not supported on SQL Server 2008 and later + throw new UnsupportedVersionException(ExceptionTemplates.UnsupportedVersion(ServerVersion.ToString())); } catch(Exception e) { @@ -811,11 +788,8 @@ public bool SysAdminOnly { get { - if (this.ServerVersion.Major >= 9) // Property is not supported on Yukon server - { - throw new PropertyCannotBeRetrievedException("SysAdminOnly", this, ExceptionTemplates.ReasonPropertyIsNotSupportedOnCurrentServerVersion); - } - return (bool)this.Properties.GetValueWithNullReplacement("SysAdminOnly"); + // Property is not supported on SQL Server 2008 and later + throw new PropertyCannotBeRetrievedException("SysAdminOnly", this, ExceptionTemplates.ReasonPropertyIsNotSupportedOnCurrentServerVersion); } } diff --git a/src/Microsoft/SqlServer/Management/Smo/JobStepBase.cs b/src/Microsoft/SqlServer/Management/Smo/JobStepBase.cs index d4f8de25..ef4ba523 100644 --- a/src/Microsoft/SqlServer/Management/Smo/JobStepBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/JobStepBase.cs @@ -125,7 +125,7 @@ private void GetAllParams(StringBuilder sb, ScriptingPreferences sp, ref int cou GetStringParameter( sb, sp, "OutputFileName", "@output_file_name=N'{0}'" , ref count); GetEnumParameter(sb, sp, "JobStepFlags", "@flags={0}", typeof(JobStepFlags), ref count); - if (ServerVersion.Major >= 9 && sp.TargetServerVersion >= SqlServerVersion.Version90) + if (sp.TargetServerVersion >= SqlServerVersion.Version90) { GetStringParameter(sb, sp, "ProxyName", "@proxy_name=N'{0}'", ref count); } diff --git a/src/Microsoft/SqlServer/Management/Smo/KeyEncryptionBase.cs b/src/Microsoft/SqlServer/Management/Smo/KeyEncryptionBase.cs deleted file mode 100644 index e6df2974..00000000 --- a/src/Microsoft/SqlServer/Management/Smo/KeyEncryptionBase.cs +++ /dev/null @@ -1,202 +0,0 @@ -using System; -using System.Text; -using System.Data; -using System.Globalization; -using System.Collections; -using System.Collections.Specialized; -using System.Security.Cryptography; - -using Cmn = Microsoft.SqlServer.Management.Common; - -#pragma warning disable 1590,1591,1592,1573,1571,1570,1572,1587 -namespace Microsoft.SqlServer.Management.Smo -{ - public partial class KeyEncryption : SqlSmoObject, Cmn.ICreatable, Cmn.IDroppable, Cmn.IMarkForDrop, IScriptable - { - - internal KeyEncryption(AbstractCollectionBase parentColl, ObjectKeyBase key, SqlSmoState state) : - base(parentColl, key, state) - { - } - - public KeyEncryption(SymmetricKey parent, SymmetricKeyEncryptionType symmetricKeyEncryptionType, string certificateOrPasswordOrSymmetricKey) : - base(parent.KeyEncryptions, new KeyEncryptionKey(certificateOrPasswordOrSymmetricKey, symmetricKeyEncryptionType), SqlSmoState.Creating) - { - this.symmetricKeyEncryptionType = symmetricKeyEncryptionType; - this.optionValue = certificateOrPasswordOrSymmetricKey; - } - - - // returns the name of the type in the urn expression - internal static string UrnSuffix - { - get - { - return "KeyEncryption"; - } - } - - public void Create() - { - base.CreateImpl(); - } - - protected override sealed void GetUrnRecursive(StringBuilder urnbuilder, UrnIdOption idOption) - { - Parent.GetUrnRecImpl(urnbuilder, idOption); - - Encoding encoding = Encoding.Unicode; - - - string thumbPrint = String.Empty; - - /* - Explanation of the - SHA-1 hash of the certificate with which the key is encrypted - OR - The guid of the symmetric key with which the key is encrypted - */ - - switch (symmetricKeyEncryptionType) - { - case SymmetricKeyEncryptionType.Password: - { - - HashAlgorithm sha = new SHA1CryptoServiceProvider(); - - byte[] result = sha.ComputeHash(encoding.GetBytes(this.optionValue.ToString())); - - thumbPrint = encoding.GetString(result); - break; - } - - case SymmetricKeyEncryptionType.Certificate: - { - Server server = (Server)(Parent.Parent.Parent); - thumbPrint = encoding.GetString(server.Certificates[this.optionValue.ToString()].Signature); - break; - } - - case SymmetricKeyEncryptionType.SymmetricKey: - { - Database db = (Database)(Parent.Parent); - thumbPrint = db.SymmetricKeys[this.optionValue.ToString].KeyGuid.ToString(); - break; - } - - } - - - KeyEncryptionKey key = new KeyEncryptionKey(thumbPrint, this.symmetricKeyEncryptionType); - - urnbuilder.AppendFormat(SmoApplication.DefaultCulture, "/{0}[{1}]", UrnSuffix, key.UrnFilter); - } - - - internal override void ScriptCreate(StringCollection queries, ScriptingPreferences sp) - { - StringBuilder createQuery = new StringBuilder(Globals.INIT_BUFFER_SIZE); - - ScriptIncludeHeaders(createQuery, sp, "Symmetric Key"); - - createQuery.AppendFormat(SmoApplication.DefaultCulture, "ALTER SYMMETRIC KEY [{0}] ", - SqlBraket(((SymmetricKey)(ParentColl.ParentInstance)).FormatFullNameForScripting(sp))); - createQuery.AppendFormat(SmoApplication.DefaultCulture, "ADD ENCRYPTION BY {0} ", GetEncryptingMechanism()); - - queries.Add(createQuery.ToString()); - } - - public void Drop() - { - base.DropImpl(); - } - - internal override void ScriptDrop(StringCollection queries, ScriptingPreferences sp) - { - StringBuilder sb = new StringBuilder(Globals.INIT_BUFFER_SIZE); - SymmetricKey parent = (SymmetricKey)ParentColl.ParentInstance; - - ScriptIncludeHeaders(sb, sp, "Symmetric Key"); - - sb.AppendFormat(SmoApplication.DefaultCulture, "ALTER SYMMETRIC KEY {1} ", parent.Name); - sb.AppendFormat(SmoApplication.DefaultCulture, "DROP ENCRYPTION BY {1} ", GetEncryptingMechanism()); - - queries.Add(sb.ToString()); - } - - internal StringBuilder GetEncryptingMechanism() - { - StringBuilder sb = new StringBuilder(Globals.INIT_BUFFER_SIZE); - - switch (symmetricKeyEncryptionType) - { - case SymmetricKeyEncryptionType.Password: sb.AppendFormat(SmoApplication.DefaultCulture, "PASSWORD = '{0}' ", SqlString(optionValue.ToString())); break; - case SymmetricKeyEncryptionType.Certificate: sb.AppendFormat(SmoApplication.DefaultCulture, "CERTIFICATE [{0}] ", SqlBraket(optionValue.ToString())); break; - case SymmetricKeyEncryptionType.SymmetricKey: sb.AppendFormat(SmoApplication.DefaultCulture, "SYMMETRIC KEY [{0}] ", SqlBraket(optionValue.ToString())); break; - } - return sb; - } - - private SymmetricKeyEncryptionType symmetricKeyEncryptionType; - private SqlSecureString optionValue; - - /// - /// Sets the Password that is used by the proxy - /// - public void SetEncryptionOptions(SymmetricKeyEncryptionType symmetricKeyEncryptionType, string optionValue) - { - - try - { - this.symmetricKeyEncryptionType = symmetricKeyEncryptionType; - - if (null == optionValue) - throw new ArgumentNullException("optionValue"); - - this.optionValue = optionValue; - - } - catch (Exception e) - { - FilterException(e); - - throw new FailedOperationException(ExceptionTemplates.SetEncryptionOptions, this, e); - } - } - - /// - /// Generate object creation script using default scripting options - /// - /// - public StringCollection Script() - { - return ScriptImpl(); - } - - /// - /// Script object with specific scripting options - /// - /// - /// - public StringCollection Script(ScriptingOptions scriptingOptions) - { - return ScriptImpl(scriptingOptions); - } - - /// - /// Marks the opbject for drop - /// - /// - /// - public void MarkForDrop(bool dropOnAlter) - { - base.MarkForDropImpl(dropOnAlter); - } - - - } - -} - - - diff --git a/src/Microsoft/SqlServer/Management/Smo/LinkedServerBase.cs b/src/Microsoft/SqlServer/Management/Smo/LinkedServerBase.cs index 25e3003a..b3de6051 100644 --- a/src/Microsoft/SqlServer/Management/Smo/LinkedServerBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/LinkedServerBase.cs @@ -231,7 +231,7 @@ internal override void ScriptAlter(StringCollection query, ScriptingPreferences } // the following work only for 10.0 and beyond - if ((this.ServerVersion.Major >= 10) && ((int)SqlServerVersion.Version100 <= (int)sp.TargetServerVersion)) + if ((int)SqlServerVersion.Version100 <= (int)sp.TargetServerVersion) { GetStringOption(query, sp, "IsPromotionofDistributedTransactionsForRPCEnabled", "remote proc transaction promotion"); } diff --git a/src/Microsoft/SqlServer/Management/Smo/LoginBase.cs b/src/Microsoft/SqlServer/Management/Smo/LoginBase.cs index c5bf88cb..c5c51f24 100644 --- a/src/Microsoft/SqlServer/Management/Smo/LoginBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/LoginBase.cs @@ -542,26 +542,14 @@ void ExecuteLoginPasswordOptions(SqlSecureString password, StringCollection sc = new StringCollection(); - if (this.ServerVersion.Major < 9) - { - // for standard logins, we can try to change their password - sc.Add(string.Format(SmoApplication.DefaultCulture, - "EXEC master.dbo.sp_password @old={0}, @new={1}, @loginame={2}", - oldPassword == null ? "NULL" : MakeSqlString((string)oldPassword), - MakeSqlString((string)password), - FormatFullNameForScripting(new ScriptingPreferences()))); - } - else - { - sc.Add("USE [master]"); - StringBuilder sb = new StringBuilder(); - sb.Append("ALTER LOGIN "); - sb.Append(FormatFullNameForScripting(new ScriptingPreferences())); - sb.Append(" WITH "); + sc.Add("USE [master]"); + StringBuilder sb = new StringBuilder(); + sb.Append("ALTER LOGIN "); + sb.Append(FormatFullNameForScripting(new ScriptingPreferences())); + sb.Append(" WITH "); - AddPasswordOptions(null, sb, password, oldPassword, false, bMustChange, bUnlock); - sc.Add(sb.ToString()); - } + AddPasswordOptions(null, sb, password, oldPassword, false, bMustChange, bUnlock); + sc.Add(sb.ToString()); this.ExecutionManager.ExecuteNonQuery(sc); } @@ -798,51 +786,48 @@ void ScriptLogin(StringCollection sc, ScriptingPreferences sp, bool bForCreate, sbOption.Append(MakeSqlBraket(s)); } - if (this.ServerVersion.Major >= 9) + Object o = GetPropValueOptional("PasswordExpirationEnabled"); + + if (null != o) { - Object o = GetPropValueOptional("PasswordExpirationEnabled"); + AddComma(sbOption, ref bStuffAdded); + sbOption.Append("CHECK_EXPIRATION="); + sbOption.Append(BoolToOnOff(o)); + } - if (null != o) - { - AddComma(sbOption, ref bStuffAdded); - sbOption.Append("CHECK_EXPIRATION="); - sbOption.Append(BoolToOnOff(o)); - } + o = GetPropValueOptional("PasswordPolicyEnforced"); + if (null != o) + { + AddComma(sbOption, ref bStuffAdded); + sbOption.Append("CHECK_POLICY="); + sbOption.Append(BoolToOnOff(o)); + } - o = GetPropValueOptional("PasswordPolicyEnforced"); - if (null != o) + //Here control will only reach if targetenginetype is not cloud. + if (Cmn.DatabaseEngineType.SqlAzureDatabase != this.DatabaseEngineType) + { + Property credential = this.Properties.Get("Credential"); + if (null != credential.Value && (credential.Dirty || bForCreate)) { - AddComma(sbOption, ref bStuffAdded); - sbOption.Append("CHECK_POLICY="); - sbOption.Append(BoolToOnOff(o)); - } + string credentialStr = (string)credential.Value; - //Here control will only reach if targetenginetype is not cloud. - if (Cmn.DatabaseEngineType.SqlAzureDatabase != this.DatabaseEngineType) - { - Property credential = this.Properties.Get("Credential"); - if (null != credential.Value && (credential.Dirty || bForCreate)) + if (credentialStr.Length == 0) { - string credentialStr = (string)credential.Value; - - if (credentialStr.Length == 0) - { - if (!bForCreate) - { - AddComma(sbOption, ref bStuffAdded); - // if we are altering the login and the credential is - // an empty string then we remove the mapping of the login to - // the existing credential - sbOption.Append("NO CREDENTIAL"); - } - } - else + if (!bForCreate) { AddComma(sbOption, ref bStuffAdded); - sbOption.Append("CREDENTIAL = "); - sbOption.Append(MakeSqlBraket(credentialStr)); + // if we are altering the login and the credential is + // an empty string then we remove the mapping of the login to + // the existing credential + sbOption.Append("NO CREDENTIAL"); } } + else + { + AddComma(sbOption, ref bStuffAdded); + sbOption.Append("CREDENTIAL = "); + sbOption.Append(MakeSqlBraket(credentialStr)); + } } } } //end standard login @@ -1608,11 +1593,6 @@ public void Rename(string newname) internal override void ScriptRename(StringCollection renameQuery, ScriptingPreferences sp, string newName) { - if (this.ServerVersion.Major < 9) - { - throw new InvalidVersionSmoOperationException(this.ServerVersion); - } - // the user is responsible to put the database in single user mode on 7.0 server AddDatabaseContext(renameQuery, sp); renameQuery.Add(string.Format(SmoApplication.DefaultCulture, "ALTER LOGIN {0} WITH NAME={1}", diff --git a/src/Microsoft/SqlServer/Management/Smo/MailServerBase.cs b/src/Microsoft/SqlServer/Management/Smo/MailServerBase.cs index b223496b..3a7605c9 100644 --- a/src/Microsoft/SqlServer/Management/Smo/MailServerBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/MailServerBase.cs @@ -167,17 +167,9 @@ internal void ScriptMailServer(StringCollection queries, ScriptingPreferences sp { bool bIncludeCredentialChangeFlag = true; - // This is the build of the first SQL 2005 hotfix that contains the fix. - Version sql2005Sp3Cu5 = new Version(9,0,4230); - Version connectedServerVersion = (Version)this.ServerVersion; - if ((this.ServerVersion.Major == 9) && - (connectedServerVersion < sql2005Sp3Cu5)) - { - bIncludeCredentialChangeFlag = false; - } - else if (this.ServerVersion.Major == 10) + if (this.ServerVersion.Major == 10) { // This is the last SQL 2008 RTM CU build before the fix in CU 7. Version sql2008RtmCu6 = new Version(10,0,1815); diff --git a/src/Microsoft/SqlServer/Management/Smo/Microsoft.SqlServer.Smo.csproj b/src/Microsoft/SqlServer/Management/Smo/Microsoft.SqlServer.Smo.csproj index b528a368..e1b8349d 100644 --- a/src/Microsoft/SqlServer/Management/Smo/Microsoft.SqlServer.Smo.csproj +++ b/src/Microsoft/SqlServer/Management/Smo/Microsoft.SqlServer.Smo.csproj @@ -84,6 +84,7 @@ + @@ -233,6 +234,7 @@ + @@ -415,6 +417,7 @@ + diff --git a/src/Microsoft/SqlServer/Management/Smo/ParamBase.cs b/src/Microsoft/SqlServer/Management/Smo/ParamBase.cs index 146f0b2f..efebd2d9 100644 --- a/src/Microsoft/SqlServer/Management/Smo/ParamBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/ParamBase.cs @@ -195,7 +195,7 @@ internal override void ScriptDdl(StringCollection queries, ScriptingPreferences } } - if (bIsReadOnly && !(this is NumberedStoredProcedureParameter) && ServerVersion.Major >= 10) + if (bIsReadOnly && !(this is NumberedStoredProcedureParameter)) { if (null != Properties.Get("IsReadOnly").Value && true == (bool)Properties.Get("IsReadOnly").Value) { diff --git a/src/Microsoft/SqlServer/Management/Smo/ParameterCollectionBase.cs b/src/Microsoft/SqlServer/Management/Smo/ParameterCollectionBase.cs index 755edf45..fa85057c 100644 --- a/src/Microsoft/SqlServer/Management/Smo/ParameterCollectionBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/ParameterCollectionBase.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. using System; +using System.Diagnostics; using Microsoft.SqlServer.Management.Sdk.Sfc; namespace Microsoft.SqlServer.Management.Smo @@ -102,7 +103,7 @@ internal override ObjectKeyBase CreateKeyFromUrn(Urn urn) /// protected override void ImplAddExisting(SqlSmoObject obj) { - Diagnostics.TraceHelper.Assert(obj.Properties.Contains("ID")); + Debug.Assert(obj.Properties.Contains("ID")); // use the most generic version of the GetPropValueOptional because // ID is int in most cases, but it's byte for some objects (IndexedColumn) @@ -112,7 +113,7 @@ protected override void ImplAddExisting(SqlSmoObject obj) for (var i = 0; i < InternalStorage.Count; i++) { var currObj = InternalStorage.GetByIndex(i); - Diagnostics.TraceHelper.Assert(currObj.Properties.Contains("ID")); + Debug.Assert(currObj.Properties.Contains("ID")); var currObjId = Convert.ToInt32(currObj.GetPropValueOptional("ID", -1), SmoApplication.DefaultCulture); diff --git a/src/Microsoft/SqlServer/Management/Smo/PhysicalPartitionBase.cs b/src/Microsoft/SqlServer/Management/Smo/PhysicalPartitionBase.cs index ee04cfb6..d3c17527 100644 --- a/src/Microsoft/SqlServer/Management/Smo/PhysicalPartitionBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/PhysicalPartitionBase.cs @@ -39,10 +39,7 @@ public PhysicalPartition(SqlSmoObject parent, Int32 partitionNumber, DataCompres SetParentImpl(parent); Init(); PartitionNumber = partitionNumber; - if (this.ServerVersion.Major >= 10) - { - DataCompression = dataCompressionType; - } + DataCompression = dataCompressionType; this.key = new PartitionNumberedObjectKey((short)PartitionNumber); } @@ -59,10 +56,7 @@ public PhysicalPartition(SqlSmoObject parent, Int32 partitionNumber, DataCompres SetParentImpl(parent); Init(); PartitionNumber = partitionNumber; - if (this.ServerVersion.Major >= 10) - { - DataCompression = dataCompressionType; - } + DataCompression = dataCompressionType; if (this.IsSupportedProperty(nameof(XmlCompression))) { @@ -186,12 +180,6 @@ public Microsoft.SqlServer.Management.Smo.DataCompressionType DataCompression get { this.ThrowIfNotSupported(typeof(PhysicalPartition)); - //Even if somebody checking the data compression state for the partition on - //yukon server then returing compression state none is OK - if (this.ServerVersion.Major < 10) - { - return DataCompressionType.None; - } return (Microsoft.SqlServer.Management.Smo.DataCompressionType)this.Properties.GetValueWithNullReplacement("DataCompression"); } set diff --git a/src/Microsoft/SqlServer/Management/Smo/PhysicalPartitionCollectionBase.cs b/src/Microsoft/SqlServer/Management/Smo/PhysicalPartitionCollectionBase.cs index c5e3e870..d00c23d4 100644 --- a/src/Microsoft/SqlServer/Management/Smo/PhysicalPartitionCollectionBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/PhysicalPartitionCollectionBase.cs @@ -115,13 +115,13 @@ private bool IsAppropriateForCompression() /// internal void Reset(int partitionNumber) { - Diagnostics.TraceHelper.Assert(partitionNumber > 0); + Debug.Assert(partitionNumber > 0); this[partitionNumber - 1].Refresh(); } internal bool IsDataCompressionStateDirty(int partitionNumber) { - Diagnostics.TraceHelper.Assert(partitionNumber > 0); + Debug.Assert(partitionNumber > 0); if (!IsAppropriateForCompression()) { return false; @@ -131,7 +131,7 @@ internal bool IsDataCompressionStateDirty(int partitionNumber) internal string GetCompressionCode(int partitionNumber) { - Diagnostics.TraceHelper.Assert(partitionNumber > 0); + Debug.Assert(partitionNumber > 0); switch (this[partitionNumber - 1].DataCompression) { case DataCompressionType.None: return string.Format(SmoApplication.DefaultCulture, "DATA_COMPRESSION = NONE "); @@ -183,13 +183,13 @@ internal bool IsCompressionCodeRequired(bool isOnAlter) internal bool IsXmlCompressionStateDirty(int partitionNumber) { - Diagnostics.TraceHelper.Assert(partitionNumber > 0); + Debug.Assert(partitionNumber > 0); return this[partitionNumber - 1].IsDirty("XmlCompression"); } internal string GetXmlCompressionCode(int partitionNumber) { - Diagnostics.TraceHelper.Assert(partitionNumber > 0); + Debug.Assert(partitionNumber > 0); switch (this[partitionNumber - 1].XmlCompression) { case XmlCompressionType.Invalid: return string.Empty; @@ -335,7 +335,7 @@ private bool IsNonDescriptiveScriptAllowed() //So, let count should decide the game return true; } - Diagnostics.TraceHelper.Assert(Parent.State == SqlSmoState.Creating); + Debug.Assert(Parent.State == SqlSmoState.Creating); //We don't know whether Table or index is parent. Table tbl = this.Parent as Table; @@ -411,7 +411,7 @@ internal string GetCompressionCode(bool isOnAlter, bool isOnTable, ScriptingPref { //If you are getting this assert failure that implies you are not checking at very early stage whether //caller has supressed the option to generate the DataCompression related script. - Diagnostics.TraceHelper.Assert(sp.Storage.DataCompression); + Debug.Assert(sp.Storage.DataCompression); int rowCompressionCount = 0; int pageCompressionCount = 0; @@ -540,7 +540,7 @@ internal string GetCompressionCode(bool isOnAlter, bool isOnTable, ScriptingPref { return string.Format(SmoApplication.DefaultCulture, "DATA_COMPRESSION = ROW"); } - Diagnostics.TraceHelper.Assert(string.IsNullOrEmpty(retString)); + Debug.Assert(string.IsNullOrEmpty(retString)); retString = string.Format(SmoApplication.DefaultCulture, "DATA_COMPRESSION = ROW ON PARTITIONS ({0})", rowCompressedList); } @@ -583,7 +583,7 @@ internal string GetXmlCompressionCode(bool isOnAlter, bool isOnTable, ScriptingP { // If you are getting this assert failure that implies you are not checking at very early stage whether // caller has suppressed the option to generate the XmlCompression related script. - Diagnostics.TraceHelper.Assert(sp.Storage.XmlCompression); + Debug.Assert(sp.Storage.XmlCompression); int offXmlCompressionCount = 0; int onXmlCompressionCount = 0; diff --git a/src/Microsoft/SqlServer/Management/Smo/PlanGuideBase.cs b/src/Microsoft/SqlServer/Management/Smo/PlanGuideBase.cs index 35c37077..891b87aa 100644 --- a/src/Microsoft/SqlServer/Management/Smo/PlanGuideBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/PlanGuideBase.cs @@ -61,7 +61,7 @@ public ExtendedPropertyCollection ExtendedProperties internal override PropagateInfo[] GetPropagateInfo(PropagateAction action) { - return new PropagateInfo[] { new PropagateInfo(ServerVersion.Major > 9 ? ExtendedProperties : null, true, ExtendedProperty.UrnSuffix) }; + return new PropagateInfo[] { new PropagateInfo(ExtendedProperties, true, ExtendedProperty.UrnSuffix) }; } /// diff --git a/src/Microsoft/SqlServer/Management/Smo/ProxyAccountBase.cs b/src/Microsoft/SqlServer/Management/Smo/ProxyAccountBase.cs index 95441f44..56c34fac 100644 --- a/src/Microsoft/SqlServer/Management/Smo/ProxyAccountBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/ProxyAccountBase.cs @@ -5,6 +5,7 @@ using System.Collections.Specialized; using System.Data; using System.Text; +using System.Diagnostics; using Microsoft.SqlServer.Management.Sdk.Sfc; using Cmn = Microsoft.SqlServer.Management.Common; @@ -82,7 +83,7 @@ internal override void ScriptCreate(StringCollection queries, ScriptingPreferenc foreach (DataRow dr in dt.Rows) { createQuery.Length = 0; - Diagnostics.TraceHelper.Assert(!(string.IsNullOrEmpty(dr["Name"].ToString())), "Invalid login name"); + Debug.Assert(!(string.IsNullOrEmpty(dr["Name"].ToString())), "Invalid login name"); createQuery.AppendFormat(SmoApplication.DefaultCulture, "EXEC msdb.dbo.sp_grant_login_to_proxy @proxy_name={0}, @login_name={1}", MakeSqlString(this.Name), MakeSqlString(dr["Name"].ToString())); diff --git a/src/Microsoft/SqlServer/Management/Smo/ScriptMaker.cs b/src/Microsoft/SqlServer/Management/Smo/ScriptMaker.cs index 9e6aa209..b5cd447b 100644 --- a/src/Microsoft/SqlServer/Management/Smo/ScriptMaker.cs +++ b/src/Microsoft/SqlServer/Management/Smo/ScriptMaker.cs @@ -1,17 +1,18 @@ -// Copyright (c) Microsoft Corporation. +// Copyright (c) Microsoft Corporation. // Licensed under the MIT license. using System; using System.Collections.Generic; using System.Collections.Specialized; +using System.Diagnostics.Tracing; using System.Globalization; using System.Linq; using System.Text; using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.Sdk.Sfc; +using SmoEventSource = Microsoft.SqlServer.Management.Common.SmoEventSource; using Microsoft.SqlServer.Server; using Environment = System.Environment; -using TraceHelper = Microsoft.SqlServer.Management.Diagnostics.TraceHelper; namespace Microsoft.SqlServer.Management.Smo { @@ -356,12 +357,13 @@ internal StringCollection Script(SqlSmoObject obj) /// void ScriptWorker(List urns, ISmoScriptWriter writer) { - TraceHelper.Trace("ScriptMaker", "ScriptWorker invoked for {0} Urns: {1}", urns.Count, string.Join(Environment.NewLine + "\t", urns.Select(urn => urn.Value).ToArray())); - if (null == writer) + // Only perform expensive string join operation if scripting logging is enabled + if (SmoEventSource.Log.IsEnabled(EventLevel.Informational, SmoEventSource.Keywords.Scripting)) { - throw new SmoException(ExceptionTemplates.InnerException, new ArgumentNullException("writer")); + SmoEventSource.Log.ScriptWorkerInvoked(urns.Count, string.Join(Environment.NewLine + "\t", urns.Select(urn => urn.Value).ToArray())); } - this.writer = writer; + + this.writer = writer ?? throw new SmoException(ExceptionTemplates.InnerException, new ArgumentNullException("writer")); this.currentRetryArgs = null; this.scriptContainerFactory = null; @@ -733,7 +735,7 @@ private HashSet GetFilteredTypes() private void OnScriptingProgress(ScriptingProgressStages scriptingProgressStages, IEnumerable urns) { - TraceHelper.Trace("ScriptMaker", "OnScriptingProgress {0}", scriptingProgressStages); + SmoEventSource.Log.ScriptingProgress(scriptingProgressStages.ToString()); if (this.scriptingProgress != null) { this.scriptingProgress(this, new ScriptingProgressEventArgs(scriptingProgressStages, new List(urns))); @@ -903,7 +905,11 @@ private IEnumerable Discover(IEnumerable urns) } discoveredUrns = this.discoverer.Discover(urns); } - TraceHelper.Trace("ScriptMaker", "Discovered {0} Urns: {1}", discoveredUrns.Count(), string.Join(Environment.NewLine + "\t", discoveredUrns.Select(urn => urn.Value).ToArray())); + // Only perform expensive string join operation if scripting logging is enabled + if (SmoEventSource.Log.IsEnabled(EventLevel.Informational, SmoEventSource.Keywords.Scripting)) + { + SmoEventSource.Log.UrnsDiscovered(discoveredUrns.Count(), string.Join(Environment.NewLine + "\t", discoveredUrns.Select(urn => urn.Value).ToArray())); + } return discoveredUrns; } @@ -961,7 +967,11 @@ private void ScriptCreateObjects(IEnumerable urns) { int count = 0; HashSet urnHashSet = new HashSet(); - TraceHelper.Trace("ScriptMaker", "ScriptCreateObjects for {0} Urns: {1}", urns.Count(), string.Join(Environment.NewLine + "\t", urns.Select(u => u.Value).ToArray())); + // Only perform expensive string join operation if scripting logging is enabled + if (SmoEventSource.Log.IsEnabled(EventLevel.Informational, SmoEventSource.Keywords.Scripting)) + { + SmoEventSource.Log.ScriptCreateObjects(urns.Count(), string.Join(Environment.NewLine + "\t", urns.Select(u => u.Value).ToArray())); + } foreach (Urn urn in urns) { @@ -1009,9 +1019,7 @@ private void ScriptCreateObjects(IEnumerable urns) this.objectScripting(this, new ObjectScriptingEventArgs(objecturn, urn, count, this.totalObjectsToScript, scriptType)); } -#if DEBUG - TraceHelper.Trace("ScriptMaker", "ScriptCreate complete for {0}", urn); -#endif + SmoEventSource.Log.ScriptCreateComplete(urn.ToString()); } } @@ -1777,7 +1785,11 @@ private bool IsSystemObject(SqlSmoObject obj) ExternalStream.UrnSuffix, // External Streaming Job - ExternalStreamingJob.UrnSuffix + ExternalStreamingJob.UrnSuffix, + + //External Model + ExternalModel.UrnSuffix + }; /// diff --git a/src/Microsoft/SqlServer/Management/Smo/ScriptNameObjectBase.cs b/src/Microsoft/SqlServer/Management/Smo/ScriptNameObjectBase.cs index 770b9ecb..85ad67af 100644 --- a/src/Microsoft/SqlServer/Management/Smo/ScriptNameObjectBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/ScriptNameObjectBase.cs @@ -8,6 +8,7 @@ using System.Globalization; using System.Text; using System.Xml.Linq; +using System.Diagnostics; using Microsoft.SqlServer.Management.Diagnostics; using Cmn = Microsoft.SqlServer.Management.Common; @@ -504,7 +505,7 @@ private string ScriptDDLPartialInternal(ScriptDDLPartialOptions options) // if (ScriptDDLPartialOptions.ScriptHeaderForAlter == options) { - TraceHelper.Assert(queries.Count > 0, "queries.Count > 0 failed. queries.Count=" + queries.Count); + Debug.Assert(queries.Count > 0, "queries.Count > 0 failed. queries.Count=" + queries.Count); // modify for alter // header starts at index 0, there are no commentaries @@ -512,7 +513,7 @@ private string ScriptDDLPartialInternal(ScriptDDLPartialOptions options) } else if (ScriptDDLPartialOptions.ScriptHeaderForCreateOrAlter == options) { - Diagnostics.TraceHelper.Assert(queries.Count > 0, "queries.Count > 0 failed. queries.Count=" + queries.Count); + Debug.Assert(queries.Count > 0, "queries.Count > 0 failed. queries.Count=" + queries.Count); // modify for alter // header starts at index 0, there are no commentaries @@ -828,10 +829,10 @@ private string ModifyTextForAlter(string text, int indexCreate) { //callers should take actions to ensure the validity //and report the runtime error for the following 2 assertions - Diagnostics.TraceHelper.Assert(indexCreate >= 0, "indexCreate >= 0 failed, indexCreate=" + indexCreate); - Diagnostics.TraceHelper.Assert(indexCreate <= text.Length - Scripts.CREATE.Length, + Debug.Assert(indexCreate >= 0, "indexCreate >= 0 failed, indexCreate=" + indexCreate); + Debug.Assert(indexCreate <= text.Length - Scripts.CREATE.Length, "The statement \"" + text + "\" is shorter than \"" + Scripts.CREATE + "\""); - Diagnostics.TraceHelper.Assert(Scripts.CREATE == text.Substring(indexCreate, Scripts.CREATE.Length).ToUpper(SmoApplication.DefaultCulture), + Debug.Assert(Scripts.CREATE == text.Substring(indexCreate, Scripts.CREATE.Length).ToUpper(SmoApplication.DefaultCulture), "\"CREATE\" == text.Substring(indexCreate, 6).ToUpper() failed. text=" + text); text = text.Remove(indexCreate, Scripts.CREATE.Length/*CREATE length*/); @@ -882,7 +883,7 @@ protected override bool IsObjectDirty() //it should be only called when we script with TextMode = true; internal string GetTextForScript(ScriptingPreferences sp, string[] expectedObjectTypes, bool forceCheckNameAndManipulateIfRequired, ScriptHeaderType scriptHeaderType) { - Diagnostics.TraceHelper.Assert(true == GetTextMode(), "true == GetTextMode() failed"); + Debug.Assert(true == GetTextMode(), "true == GetTextMode() failed"); //if for scripting and we don't enforce scripting options if (!sp.ForDirectExecution && !sp.OldOptions.EnforceScriptingPreferences) @@ -962,7 +963,7 @@ private void CheckObjectSupportability(DdlTextParserHeaderInfo headerInfo, Scrip //we are preparing to script, "create" or "alter" or "create or alter" string BuildText(ScriptingPreferences sp) { - Diagnostics.TraceHelper.Assert(true == GetTextMode(), "true == GetTextMode() failed"); + Debug.Assert(true == GetTextMode(), "true == GetTextMode() failed"); //if text is not dirty and it must not be cut , just return it if (false == GetIsTextDirty() && !(sp.OldOptions.DdlBodyOnly || sp.OldOptions.DdlHeaderOnly)) @@ -978,7 +979,7 @@ string BuildText(ScriptingPreferences sp) if (!sp.OldOptions.DdlBodyOnly) { textHeader = GetTextHeader(false); - Diagnostics.TraceHelper.Assert(null != textHeader, "null == textHeader"); + Debug.Assert(null != textHeader, "null == textHeader"); //text header cannot be empty if (textHeader.Length <= 0) @@ -993,7 +994,7 @@ string BuildText(ScriptingPreferences sp) if (!sp.OldOptions.DdlHeaderOnly) { textBody = GetTextBody(); - Diagnostics.TraceHelper.Assert(null != textBody, "null == textBody"); + Debug.Assert(null != textBody, "null == textBody"); //text header should end in space if (textHeader.Length > 0 && !char.IsWhiteSpace(textHeader[textHeader.Length - 1])) @@ -1022,16 +1023,16 @@ protected virtual string GetBraketNameForText() internal void CheckNameInTextCorrectness(string expectedName, string expectedSchema, string foundName, string foundSchema, string foundProcedureNumber) { - Diagnostics.TraceHelper.Assert(true == GetTextMode(), "true == GetTextMode() failed"); - Diagnostics.TraceHelper.Assert(null != expectedName && expectedName.Length > 1 && expectedName[0] == '['); - Diagnostics.TraceHelper.Assert(null != expectedSchema && (expectedSchema.Length == 0 + Debug.Assert(true == GetTextMode(), "true == GetTextMode() failed"); + Debug.Assert(null != expectedName && expectedName.Length > 1 && expectedName[0] == '['); + Debug.Assert(null != expectedSchema && (expectedSchema.Length == 0 || (expectedSchema.Length > 1 && expectedSchema[0] == '['))); - Diagnostics.TraceHelper.Assert(null != foundName && foundName.Length > 1 && foundName[0] == '['); - Diagnostics.TraceHelper.Assert(null != foundSchema && (foundSchema.Length == 0 + Debug.Assert(null != foundName && foundName.Length > 1 && foundName[0] == '['); + Debug.Assert(null != foundSchema && (foundSchema.Length == 0 || (foundSchema.Length > 1 && foundSchema[0] == '['))); - Diagnostics.TraceHelper.Assert(null != foundProcedureNumber && (foundProcedureNumber.Length == 0 + Debug.Assert(null != foundProcedureNumber && (foundProcedureNumber.Length == 0 || (foundProcedureNumber.Length > 1 && foundProcedureNumber[0] == ';'))); - Diagnostics.TraceHelper.Assert((this is ScriptSchemaObjectBase && expectedSchema.Length > 0) || + Debug.Assert((this is ScriptSchemaObjectBase && expectedSchema.Length > 0) || (!(this is ScriptSchemaObjectBase) && expectedSchema.Length == 0 && foundSchema.Length == 0) || this.State == SqlSmoState.Creating || this is Trigger); // @@ -1057,7 +1058,7 @@ internal void CheckNameInTextCorrectness(string expectedName, string expectedSch // if (expectedSchema.Length > 0) { - Diagnostics.TraceHelper.Assert(this is ScriptSchemaObjectBase); + Debug.Assert(this is ScriptSchemaObjectBase); if (foundSchema.Length > 0) { @@ -1108,7 +1109,7 @@ protected void CheckTextCorrectness(string ddlText, bool enforceCreate, bool che protected void CheckTextCorrectness(string ddlText, bool enforceCreate, bool checkName, bool isOrAlterSupported, string[] expectedObjectTypes, out DdlTextParserHeaderInfo headerInfo) { - Diagnostics.TraceHelper.Assert(true == GetTextMode(), "true == GetTextMode() failed"); + Debug.Assert(true == GetTextMode(), "true == GetTextMode() failed"); // PARSE and check syntax, get header info, extract text info // like object type, name and schema as found in text @@ -1176,7 +1177,7 @@ protected void CheckTextCorrectness(string ddlText, bool enforceCreate, bool che private string CheckAndManipulateText(string ddlText, string[] expectedObjectTypes, ScriptingPreferences sp, ScriptHeaderType scriptHeaderType) { //it should be only called when we script with TextMode = true; - Diagnostics.TraceHelper.Assert(true == GetTextMode(), "true == GetTextMode() failed"); + Debug.Assert(true == GetTextMode(), "true == GetTextMode() failed"); // //check text corectness @@ -1257,7 +1258,7 @@ private void CheckAndManipulateName(ref string ddlText, ScriptingPreferences sp, // note: fix it before the object's name so that the text indexes are not affected if (0 == string.Compare("TRIGGER", headerInfo.objectType, StringComparison.OrdinalIgnoreCase)) { - Diagnostics.TraceHelper.Assert(headerInfo.indexNameStartSecondary > 0 && headerInfo.indexNameEndSecondary > 0 + Debug.Assert(headerInfo.indexNameStartSecondary > 0 && headerInfo.indexNameEndSecondary > 0 && headerInfo.indexNameEndSecondary > headerInfo.indexNameStartSecondary); Trigger tr = this as Trigger; @@ -1286,7 +1287,7 @@ private void CheckAndManipulateName(ref string ddlText, ScriptingPreferences sp, } } // fix the object name - Diagnostics.TraceHelper.Assert(headerInfo.indexNameStart > 0 && headerInfo.indexNameEnd > 0 + Debug.Assert(headerInfo.indexNameStart > 0 && headerInfo.indexNameEnd > 0 && headerInfo.indexNameEnd > headerInfo.indexNameStart); ddlText = ddlText.Remove(headerInfo.indexNameStart, headerInfo.indexNameEnd - headerInfo.indexNameStart); @@ -1468,14 +1469,6 @@ string GetTextProperty(string requestingProperty, ScriptingPreferences sp, bool return GetTextPropertyDesignMode(requestingProperty, sp, bThrowIfCreating); } - if (this.ServerVersion.Major < 9 && State != SqlSmoState.Creating) - { - if (this.Properties.Contains("IsEncrypted") && true == (bool)GetPropValue("IsEncrypted")) - { - throw new PropertyCannotBeRetrievedException(requestingProperty, this, ExceptionTemplates.ReasonTextIsEncrypted); - } - } - string text = (string)this.GetPropValueOptional("Text"); // check to see if we have this property diff --git a/src/Microsoft/SqlServer/Management/Smo/ScriptSchemaObjectBase.cs b/src/Microsoft/SqlServer/Management/Smo/ScriptSchemaObjectBase.cs index 7af1576c..f03e324e 100644 --- a/src/Microsoft/SqlServer/Management/Smo/ScriptSchemaObjectBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/ScriptSchemaObjectBase.cs @@ -249,21 +249,13 @@ private StringCollection ScriptChangeSchema(String oldSchema, String newSchema) string fullName = string.Format(SmoApplication.DefaultCulture, "[{0}].[{1}]", SqlBraket(oldSchema), SqlBraket(Name)); queries.Add(string.Format(SmoApplication.DefaultCulture, Scripts.USEDB, SqlBraket(GetDBName()))); - if (ServerVersion.Major < 9) + if (this is UserDefinedType) { - queries.Add(string.Format(SmoApplication.DefaultCulture, "EXEC sp_changeobjectowner @objname=N'{0}', @newowner=N'{1}'", - SqlString(fullName), SqlString(newSchema))); + queries.Add(string.Format(SmoApplication.DefaultCulture, "ALTER SCHEMA {0} TRANSFER TYPE :: {1}", MakeSqlBraket(newSchema), fullName)); } - else //version >= 9 + else { - if (this is UserDefinedType) - { - queries.Add(string.Format(SmoApplication.DefaultCulture, "ALTER SCHEMA {0} TRANSFER TYPE :: {1}", MakeSqlBraket(newSchema), fullName)); - } - else - { - queries.Add(string.Format(SmoApplication.DefaultCulture, "ALTER SCHEMA {0} TRANSFER {1}", MakeSqlBraket(newSchema), fullName)); - } + queries.Add(string.Format(SmoApplication.DefaultCulture, "ALTER SCHEMA {0} TRANSFER {1}", MakeSqlBraket(newSchema), fullName)); } return queries; } diff --git a/src/Microsoft/SqlServer/Management/Smo/Scripter.cs b/src/Microsoft/SqlServer/Management/Smo/Scripter.cs index 28df0f03..50886681 100644 --- a/src/Microsoft/SqlServer/Management/Smo/Scripter.cs +++ b/src/Microsoft/SqlServer/Management/Smo/Scripter.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.IO; +using System.Diagnostics; using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.Sdk.Sfc; using Microsoft.SqlServer.Server; @@ -239,11 +240,10 @@ internal ScriptingOptions GetOptions() if (!op.GetScriptingPreferences().TargetVersionAndDatabaseEngineTypeDirty) { // default target server version should be set equal to the server we are scripting - if (GetServerObject().ServerVersion == null) + if (GetServerObject().ServerVersion == null) // would only be null if ServerConnection.IsForceDisconnected is true { // going to the server for the version should populate ServerVersion structure string sVersion = GetServerObject().Information.VersionString; - Diagnostics.TraceHelper.Trace(SmoApplication.ModuleName, SmoApplication.trAlways, sVersion); } op.SetTargetServerInfo(GetServerObject(), false); @@ -445,7 +445,7 @@ private IEnumerable ScriptWithList(DependencyCollection depList, SqlSmoO } } - Diagnostics.TraceHelper.Assert(null != mainObj, "null == mainObj"); + Debug.Assert(null != mainObj, "null == mainObj"); throw new FailedOperationException(ExceptionTemplates.Script, mainObj, e); } } diff --git a/src/Microsoft/SqlServer/Management/Smo/ScriptingOptions.cs b/src/Microsoft/SqlServer/Management/Smo/ScriptingOptions.cs index 54d83dbe..1762db8c 100644 --- a/src/Microsoft/SqlServer/Management/Smo/ScriptingOptions.cs +++ b/src/Microsoft/SqlServer/Management/Smo/ScriptingOptions.cs @@ -2179,7 +2179,7 @@ private void SetScriptingPreference(EnumScriptOptions eso, bool value) this.PrimaryObject = value; break; default: - Diagnostics.TraceHelper.Assert(false, "incorrect index specified"); + Debug.Assert(false, "incorrect index specified"); break; } } @@ -2281,7 +2281,7 @@ private bool GetScriptingPreference(EnumScriptOptions eso) case EnumScriptOptions.PrimaryObject: return this.PrimaryObject; default: - Diagnostics.TraceHelper.Assert(false, "incorrect index specified"); + Debug.Assert(false, "incorrect index specified"); return false; } } @@ -2325,14 +2325,7 @@ public static SqlServerVersion ConvertToSqlServerVersion(int majorVersion, int m { SqlServerVersion sqlSvrVersion; switch (majorVersion) - { - case 8: - sqlSvrVersion = SqlServerVersion.Version80; - break; - case 9: - sqlSvrVersion = SqlServerVersion.Version90; - break; - case 10: + {case 10: if (minorVersion == 0) { sqlSvrVersion = SqlServerVersion.Version100; diff --git a/src/Microsoft/SqlServer/Management/Smo/ScriptingPreferences.cs b/src/Microsoft/SqlServer/Management/Smo/ScriptingPreferences.cs index 45132223..544f078e 100644 --- a/src/Microsoft/SqlServer/Management/Smo/ScriptingPreferences.cs +++ b/src/Microsoft/SqlServer/Management/Smo/ScriptingPreferences.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. +// Copyright (c) Microsoft Corporation. // Licensed under the MIT license. using System; @@ -171,22 +171,13 @@ internal void SetTargetServerVersion(ServerVersion ver) { this.VersionDirty = true; switch (ver.Major) - { - case 8: - m_eTargetServerVersion = SqlServerVersion.Version80; - break; - - case 9: - m_eTargetServerVersion = SqlServerVersion.Version90; - break; - - case 10: + {case 10: if (ver.Minor == 0) { m_eTargetServerVersion = SqlServerVersion.Version100; break; } - Diagnostics.TraceHelper.Assert(ver.Minor == 50, "unexpected server version"); + Debug.Assert(ver.Minor == 50, "unexpected server version"); m_eTargetServerVersion = SqlServerVersion.Version105; break; diff --git a/src/Microsoft/SqlServer/Management/Smo/ServerEventsWorker.cs b/src/Microsoft/SqlServer/Management/Smo/ServerEventsWorker.cs index e6743683..75b2cb66 100644 --- a/src/Microsoft/SqlServer/Management/Smo/ServerEventsWorker.cs +++ b/src/Microsoft/SqlServer/Management/Smo/ServerEventsWorker.cs @@ -6,7 +6,9 @@ using System.Collections.ObjectModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.Tracing; using System.Globalization; +using SmoEventSource = Microsoft.SqlServer.Management.Common.SmoEventSource; using System.Management; using System.Text; using Microsoft.SqlServer.Management.Smo.Broker; @@ -90,11 +92,6 @@ internal EventsWorkerBase(SqlSmoObject target, Type eventSetType, Type eventEnum // This may throw an exception if target is in Pending state Server server = target.GetServerObject(); - // Check for correct server version - if (server.ServerVersion.Major < 9) - { - throw new InvalidVersionSmoOperationException(server.ServerVersion); - } this.eventEnumType = eventEnumType; this.events = (EventSetBase)Activator.CreateInstance(eventSetType); @@ -152,8 +149,7 @@ public void SubscribeToEvents(EventSetBase addEvents, ServerEventHandler eventHa EventSubscription subscription = (EventSubscription)eventSubscriptions[eventClass]; if (null != subscription) { - Diagnostics.TraceHelper.Trace(SmoApplication.ModuleName, SmoApplication.trAlways, - "Updating event handler for event " + eventClass + " on class " + this.Target.GetType().Name); + SmoEventSource.Log.ServerEventSubscriptionUpdated(eventClass, this.Target.GetType().Name); // We do not subscribe the second time, // just update the handler @@ -161,8 +157,7 @@ public void SubscribeToEvents(EventSetBase addEvents, ServerEventHandler eventHa } else { - Diagnostics.TraceHelper.Trace(SmoApplication.ModuleName, SmoApplication.trAlways, - "Adding subscription for event " + eventClass + " on class " + this.Target.GetType().Name); + SmoEventSource.Log.ServerEventSubscriptionAdded(eventClass, this.Target.GetType().Name); // Create a new subscription CreateSubscription(eventID, eventClass, eventHandlerKey); @@ -190,8 +185,7 @@ public void UnsubscribeFromEvents(EventSetBase removeEvents) EventSubscription subscription = (EventSubscription)eventSubscriptions[eventClass]; if (null != subscription) { - Diagnostics.TraceHelper.Trace(SmoApplication.ModuleName, SmoApplication.trAlways, - "Removing subscription for event " + eventClass + " on class " + this.Target.GetType().Name); + SmoEventSource.Log.ServerEventSubscriptionRemoved(eventClass, this.Target.GetType().Name); // Remove subscription this.eventSubscriptions.Remove(eventClass); @@ -213,8 +207,7 @@ public void StartEvents() { foreach (EventSubscription subscription in this.eventSubscriptions.Values) { - Diagnostics.TraceHelper.Trace(SmoApplication.ModuleName, SmoApplication.trAlways, - "Starting event subscription on: {0}, query: {1}", subscription.EventWatcher.Scope.Path, subscription.EventWatcher.Query.QueryString); + SmoEventSource.Log.ServerEventSubscriptionStarted(subscription.EventWatcher.Scope.Path.Path, subscription.EventWatcher.Query.QueryString); subscription.EventWatcher.Start(); } @@ -243,7 +236,7 @@ public void StopEvents() public void Dispose() { - Diagnostics.TraceHelper.Trace(SmoApplication.ModuleName, SmoApplication.trAlways, "Removing all subscriptions"); + SmoEventSource.Log.RemoveAllSubscriptions(); // Stop all subscriptions and release all resources foreach (EventSubscription subscription in this.eventSubscriptions.Values) @@ -354,8 +347,7 @@ private void CreateSubscription(int eventID, string eventClass, object eventHand // EventQuery query = CreateWqlQuery(eventClass); - Diagnostics.TraceHelper.Trace(SmoApplication.ModuleName, SmoApplication.trAlways, - "Subscription query {0}", query.QueryString); + SmoEventSource.Log.ServerEventSubscriptionQueryCreated(query.QueryString); // // Connect to WMI service and create a watcher object for @@ -399,8 +391,7 @@ private void OnEventArrived(object sender, EventArrivedEventArgs args) EventType eventType = ConvertFromEventClass(args.NewEvent.ClassPath.ClassName); EventSubscription subscription = null; - Diagnostics.TraceHelper.Trace(SmoApplication.ModuleName, SmoApplication.trAlways, - "Received event {0} on class {1}", args.NewEvent.ClassPath.ClassName, this.Target.GetType().Name); + SmoEventSource.Log.ServerEventReceived(args.NewEvent.ClassPath.ClassName, this.Target.GetType().Name); while (subscriptionKey != null && subscriptionKey.Length > 0) { @@ -411,8 +402,7 @@ private void OnEventArrived(object sender, EventArrivedEventArgs args) ServerEventHandler eventHandler = (ServerEventHandler)this.eventHandlers[subscription.EventHandlerKey]; if (null != eventHandler) { - Diagnostics.TraceHelper.Trace(SmoApplication.ModuleName, SmoApplication.trAlways, - "Raising event {0} on subscription: {1}", args.NewEvent.ClassPath.ClassName, subscriptionKey); + SmoEventSource.Log.ServerEventRaised(args.NewEvent.ClassPath.ClassName, subscriptionKey); eventHandler(this.Target, new ServerEventArgs(eventType, args.NewEvent.Properties)); } diff --git a/src/Microsoft/SqlServer/Management/Smo/ServiceQueueBase.cs b/src/Microsoft/SqlServer/Management/Smo/ServiceQueueBase.cs index 4a32c771..797e3859 100644 --- a/src/Microsoft/SqlServer/Management/Smo/ServiceQueueBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/ServiceQueueBase.cs @@ -284,7 +284,7 @@ [ POISON_MESSAGE_HANDLING ([ STATUS = {ON | OFF} ] ) } if (sp.TargetServerVersion >= SqlServerVersion.Version105 && - (this.ServerVersion.Major > 10 || (this.ServerVersion.Major >= 10 && this.ServerVersion.Minor >= 50))) + (this.ServerVersion.Major > 10 || this.ServerVersion.Minor >= 50)) { object isPoisonMessageHandlingEnabled = GetPropValueOptional("IsPoisonMessageHandlingEnabled"); if (null != isPoisonMessageHandlingEnabled) diff --git a/src/Microsoft/SqlServer/Management/Smo/SfcResolver.cs b/src/Microsoft/SqlServer/Management/Smo/SfcResolver.cs index b7cd1ce3..3b7e38b8 100644 --- a/src/Microsoft/SqlServer/Management/Smo/SfcResolver.cs +++ b/src/Microsoft/SqlServer/Management/Smo/SfcResolver.cs @@ -3,6 +3,7 @@ using System; using System.Reflection; +using System.Diagnostics; using Microsoft.SqlServer.Management.Sdk.Sfc; #pragma warning disable 1590,1591,1592,1573,1571,1570,1572,1587 @@ -29,11 +30,11 @@ internal static Database GetDatabase(object obj) Type t = cur.GetType(); PropertyInfo pi = t.GetProperty("Parent"); - Diagnostics.TraceHelper.Assert(pi != null, String.Format("{0} is missing Parent property.", t.FullName)); + Debug.Assert(pi != null, String.Format("{0} is missing Parent property.", t.FullName)); cur = pi.GetValue(cur, null); - Diagnostics.TraceHelper.Assert(cur != null, String.Format("{0}.Parent property returned null.", t.FullName)); + Debug.Assert(cur != null, String.Format("{0}.Parent property returned null.", t.FullName)); if (cur.GetType() == typeof(Database)) { @@ -69,11 +70,11 @@ internal static string GetSchemaName(object obj) Type t = obj.GetType(); PropertyInfo pi = t.GetProperty("Schema"); - Diagnostics.TraceHelper.Assert(pi != null, String.Format("{0} is missing Schema property.", t.FullName)); + Debug.Assert(pi != null, String.Format("{0} is missing Schema property.", t.FullName)); string name = (string)pi.GetValue(obj, null); - Diagnostics.TraceHelper.Assert(name != null, String.Format("{0}.Schema property returned null.", t.FullName)); + Debug.Assert(name != null, String.Format("{0}.Schema property returned null.", t.FullName)); return name; } diff --git a/src/Microsoft/SqlServer/Management/Smo/SmoDependencyDiscoverer.cs b/src/Microsoft/SqlServer/Management/Smo/SmoDependencyDiscoverer.cs index f2cfc368..11fbd516 100644 --- a/src/Microsoft/SqlServer/Management/Smo/SmoDependencyDiscoverer.cs +++ b/src/Microsoft/SqlServer/Management/Smo/SmoDependencyDiscoverer.cs @@ -1,9 +1,10 @@ -// Copyright (c) Microsoft Corporation. +// Copyright (c) Microsoft Corporation. // Licensed under the MIT license. using System; using System.Collections; using System.Collections.Generic; +using System.Diagnostics; using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.Sdk.Sfc; @@ -243,7 +244,7 @@ private SqlSmoObject.PropagateAction GetPropagateAction() case ScriptBehavior.DropAndCreate: return SqlSmoObject.PropagateAction.Create; default: - Diagnostics.TraceHelper.Assert(false, "Invalid Condition"); + Debug.Assert(false, "Invalid Condition"); return SqlSmoObject.PropagateAction.Create; } } @@ -327,6 +328,7 @@ private bool DiscoverSupported(Urn urn) case "SqlAssembly": case nameof(ExternalLanguage): case "ExternalLibrary": + case nameof(ExternalModel): case "PartitionScheme": case "PartitionFunction": case "UserDefinedTableType": diff --git a/src/Microsoft/SqlServer/Management/Smo/SmoDependencyOrderer.cs b/src/Microsoft/SqlServer/Management/Smo/SmoDependencyOrderer.cs index 1751f714..7189f2ab 100644 --- a/src/Microsoft/SqlServer/Management/Smo/SmoDependencyOrderer.cs +++ b/src/Microsoft/SqlServer/Management/Smo/SmoDependencyOrderer.cs @@ -1,9 +1,10 @@ -// Copyright (c) Microsoft Corporation. +// Copyright (c) Microsoft Corporation. // Licensed under the MIT license. using System; using System.Collections.Generic; using System.Collections.Specialized; +using System.Diagnostics; using System.Data; using System.Linq; @@ -597,7 +598,7 @@ private void ResolveIndexDependenciesWithFactory() jsonIndex.Add(index); break; default: - Diagnostics.TraceHelper.Assert(false, "Invalid IndexType"); + Debug.Assert(false, "Invalid IndexType"); break; } } @@ -718,7 +719,7 @@ private void EmbedForeignKeysChecksDefaultConstraints() { foreach (ForeignKey item in foreignKeyList) { - Diagnostics.TraceHelper.Assert(item.Urn.Parent.Equals(table.Urn), "invalid call"); + Debug.Assert(item.Urn.Parent.Equals(table.Urn), "invalid call"); table.AddToEmbeddedForeignKeyChecksList(item); } } @@ -728,7 +729,7 @@ private void EmbedForeignKeysChecksDefaultConstraints() { foreach (Check item in checkContraintsList) { - Diagnostics.TraceHelper.Assert(item.Urn.Parent.Equals(table.Urn), "invalid call"); + Debug.Assert(item.Urn.Parent.Equals(table.Urn), "invalid call"); table.AddToEmbeddedForeignKeyChecksList(item); } } @@ -738,7 +739,7 @@ private void EmbedForeignKeysChecksDefaultConstraints() { foreach (DefaultConstraint item in defaultContraintsList) { - Diagnostics.TraceHelper.Assert(item.Urn.Parent.Parent.Equals(table.Urn), "invalid call"); + Debug.Assert(item.Urn.Parent.Parent.Equals(table.Urn), "invalid call"); item.forceEmbedDefaultConstraint = true; } } @@ -1130,8 +1131,8 @@ private void OrderAndStoreSchemaBound(List schemaboundList) private void OrderAndStoreSchemaBoundInSingleDatabase(List list, string query) { - Diagnostics.TraceHelper.Assert(list.Count > 0); - Diagnostics.TraceHelper.Assert(this.urnTypeDictionary.ContainsKey(new UrnTypeKey(SmoDependencyOrderer.TABLEVIEWUDF))); + Debug.Assert(list.Count > 0); + Debug.Assert(this.urnTypeDictionary.ContainsKey(new UrnTypeKey(SmoDependencyOrderer.TABLEVIEWUDF))); List objectList = this.urnTypeDictionary[new UrnTypeKey(SmoDependencyOrderer.TABLEVIEWUDF)]; diff --git a/src/Microsoft/SqlServer/Management/Smo/SmoDiffAdapters.cs b/src/Microsoft/SqlServer/Management/Smo/SmoDiffAdapters.cs index 188f3c6e..00363fce 100644 --- a/src/Microsoft/SqlServer/Management/Smo/SmoDiffAdapters.cs +++ b/src/Microsoft/SqlServer/Management/Smo/SmoDiffAdapters.cs @@ -345,8 +345,8 @@ public override bool AreGraphsSupported(ISfcSimpleNode left, ISfcSimpleNode righ { throw new ArgumentNullException("right"); } - Diagnostics.TraceHelper.Assert(left.ObjectReference != null, "Expect non-null left.ObjectReference"); - Diagnostics.TraceHelper.Assert(right.ObjectReference != null, "Expect non-null right.ObjectReference"); + Debug.Assert(left.ObjectReference != null, "Expect non-null left.ObjectReference"); + Debug.Assert(right.ObjectReference != null, "Expect non-null right.ObjectReference"); if (left.ObjectReference is SqlSmoObject && right.ObjectReference is SqlSmoObject) { @@ -370,8 +370,8 @@ public override bool Compare(ISfcSimpleNode left, ISfcSimpleNode right, String p throw new ArgumentNullException("propName"); } - Diagnostics.TraceHelper.Assert(left.ObjectReference != null, "Expect non-null left.ObjectReference"); - Diagnostics.TraceHelper.Assert(right.ObjectReference != null, "Expect non-null right.ObjectReference"); + Debug.Assert(left.ObjectReference != null, "Expect non-null left.ObjectReference"); + Debug.Assert(right.ObjectReference != null, "Expect non-null right.ObjectReference"); Object leftValue = left.Properties[propName]; Object rightValue = right.Properties[propName]; @@ -393,8 +393,8 @@ public override bool Compare(ISfcSimpleNode left, ISfcSimpleNode right, String p private static bool CompareDataTypeWorkaround(Column leftCol, Column rightCol) { - Diagnostics.TraceHelper.Assert(leftCol != null, "Expect non-null leftCol"); - Diagnostics.TraceHelper.Assert(rightCol != null, "Expect non-null rightCol"); + Debug.Assert(leftCol != null, "Expect non-null leftCol"); + Debug.Assert(rightCol != null, "Expect non-null rightCol"); DataType designMode = null; DataType connectedMode = null; diff --git a/src/Microsoft/SqlServer/Management/Smo/SmoSortedList.cs b/src/Microsoft/SqlServer/Management/Smo/SmoSortedList.cs index ed581bb3..6cf701f9 100644 --- a/src/Microsoft/SqlServer/Management/Smo/SmoSortedList.cs +++ b/src/Microsoft/SqlServer/Management/Smo/SmoSortedList.cs @@ -4,6 +4,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Diagnostics; namespace Microsoft.SqlServer.Management.Smo { @@ -98,7 +99,7 @@ internal override void Add(ObjectKeyBase key, T o) internal override void InsertAt(int position, T o) => // this should never be called - Diagnostics.TraceHelper.Assert(false); + Debug.Assert(false); internal override void RemoveAt(int position) => innerCollection.RemoveAt(position); diff --git a/src/Microsoft/SqlServer/Management/Smo/SmoUrnFilter.cs b/src/Microsoft/SqlServer/Management/Smo/SmoUrnFilter.cs index f2c9fa7c..69baa9e7 100644 --- a/src/Microsoft/SqlServer/Management/Smo/SmoUrnFilter.cs +++ b/src/Microsoft/SqlServer/Management/Smo/SmoUrnFilter.cs @@ -89,6 +89,7 @@ internal enum ObjectOrder externalfileformat, externalStream, externalStreamingJob, + externalModel, columnmasterkey, columnencryptionkey, columnencryptionkeyvalue, diff --git a/src/Microsoft/SqlServer/Management/Smo/SmoUtility.cs b/src/Microsoft/SqlServer/Management/Smo/SmoUtility.cs index bfc58ddf..6bc0668c 100644 --- a/src/Microsoft/SqlServer/Management/Smo/SmoUtility.cs +++ b/src/Microsoft/SqlServer/Management/Smo/SmoUtility.cs @@ -123,6 +123,7 @@ public static bool IsSupportedObject(Type type, ServerVersion serverVersion, Dat switch (type.Name) { case nameof(IndexedJsonPath): + case nameof(ExternalModel): return false; } } @@ -182,7 +183,7 @@ public static bool IsSupportedObject(Type type, ServerVersion serverVersion, Dat switch (type.Name) { case "AffinityInfo": - if ((serverVersion.Major >= 10 && serverVersion.Minor < 50) || (serverVersion.Major < 10)) + if (serverVersion.Minor < 50) { return false; } @@ -210,70 +211,6 @@ public static bool IsSupportedObject(Type type, ServerVersion serverVersion, Dat return false; } } - if (serverVersion.Major < 10) - { - switch (type.Name) - { - case "Audit" : - case "AuditSpecification" : - case "CryptographicProvider": - case "DatabaseAuditSpecification" : - case "DatabaseEncryptionKey": - case "FullTextStopList": - case "OrderColumn": - case "ResourceGovernor": - case "ResourcePool": - case nameof(SensitivityClassification) : - case "ServerAuditSpecification": - case "UserDefinedTableType" : - case "WorkLoadGroup": - return false; - } - } - if (serverVersion.Major < 9) - { - switch (type.Name) - { - case "BrokerPriority" : - case "BrokerService" : - case "Certificate" : - case "Credential" : - case "DatabaseDdlTrigger" : - case "DatabaseMirroringPayload": - case "Endpoint" : - case "EndpointPayload" : - case "EndpointProtocol" : - case "FullTextCatalog": - case "MailAccount" : - case "MailProfile": - case "MailServer" : - case "MessageType" : - case "MessageTypeMapping" : - case "PartitionFunction" : - case "PartitionFunctionParameter" : - case "PartitionScheme" : - case "PartitionSchemeParameter" : - case "PhysicalPartition" : - case "PlanGuide" : - case "RemoteServiceBinding": - case "Schema" : - case "ServerDdlTrigger" : - case "ServiceBroker": - case "ServiceContract": - case "ServiceMasterKey" : - case "ServiceContractMapping": - case "ServiceQueue": - case "ServiceRoute": - case "SqlAssembly" : - case "Synonym" : - case "SymmetricKey" : - case "UserDefinedAggregate": - case "UserDefinedAggregateParameter": - case "UserDefinedType" : - case "XmlSchemaCollection" : - return false; - } - } } else if (databaseEngineType == DatabaseEngineType.SqlAzureDatabase) { @@ -329,6 +266,7 @@ public static bool IsSupportedObject(Type type, ServerVersion serverVersion, Dat case nameof(DatabaseScopedConfiguration): case nameof(DatabaseScopedCredential) : case nameof(Default) : + case nameof(ExternalModel): case nameof(ExtendedProperty): case nameof(ExternalDataSource): case nameof(FullTextCatalog) : @@ -359,7 +297,7 @@ public static bool IsSupportedObject(Type type, ServerVersion serverVersion, Dat case nameof(UserDefinedAggregateParameter) : case nameof(UserDefinedType) : case nameof(UserOptions) : - case nameof(XmlSchemaCollection): + case nameof(XmlSchemaCollection) : return true; case nameof(ExternalFileFormat): case nameof(WorkloadManagementWorkloadGroup): @@ -466,6 +404,7 @@ internal static void ThrowIfNotSupported(this SqlSmoObject smoObject, Type type, smoObject.ThrowIfNotSupported(type, message: null, sp: sp); } + //VBUMP /// /// Checks if the specified type is supported by the , /// and of the root server for this object. If ScriptingPreferences are non-null @@ -621,7 +560,9 @@ internal static ServerVersion GetMinimumSupportedVersion(Type type, DatabaseEngi (new ServerVersion(12, 0)), //2014 (new ServerVersion(13, 0)), //2016 (new ServerVersion(14, 0)), //2017 - (new ServerVersion(15, 0)) //2019 + (new ServerVersion(15, 0)), //2019 + (new ServerVersion(16, 0)), //2022 + (new ServerVersion(17, 0)) //2025 (VBUMP) }; /// diff --git a/src/Microsoft/SqlServer/Management/Smo/SqlSmoObject.cs b/src/Microsoft/SqlServer/Management/Smo/SqlSmoObject.cs index b601678a..ffc8b1a0 100644 --- a/src/Microsoft/SqlServer/Management/Smo/SqlSmoObject.cs +++ b/src/Microsoft/SqlServer/Management/Smo/SqlSmoObject.cs @@ -230,6 +230,9 @@ internal string PermissionPrefix case nameof(ExternalLibrary): prefix = "EXTERNAL LIBRARY"; break; + case nameof(ExternalModel): + prefix = "EXTERNAL MODEL"; break; + case nameof(SqlAssembly): prefix = "ASSEMBLY"; break; @@ -1277,7 +1280,7 @@ public virtual void Refresh() // limit the request to fields composing the key if we have any // if there are no fields in the key this is a singleton and // it does not make sense to check for its existance - Diagnostics.TraceHelper.Assert(null != key, "null == key"); + Debug.Assert(null != key, "null == key"); StringCollection keyFields = key.GetFieldNames(); if (keyFields.Count > 0) { @@ -1418,9 +1421,12 @@ internal override object GetPropertyDefaultValue(string propname) } } - Trace("DesignMode Missing " + - ((Properties.Get(propname).Expensive) ? "expensive" : "regular") + - " property " + propname + " for type " + this.GetType().Name); + SmoEventSource.Log.PropertyMissing( + Properties.Get(propname).Expensive, + true, + propname, + GetType().Name, + "DesignMode"); } return base.GetPropertyDefaultValue(propname); @@ -1453,20 +1459,26 @@ internal override object OnPropertyMissing(string propname, bool useDefaultValue switch (this.State) { case SqlSmoState.Pending: - Diagnostics.TraceHelper.Assert(false); // can't happen through user code, intercepted earlier + Debug.Assert(false); // can't happen through user code, intercepted earlier break; case SqlSmoState.Creating: throw new PropertyNotSetException(propname); } } - System.Diagnostics.Trace.TraceWarning("Missing " + - ((Properties.Get(propname).Expensive) ? "expensive" : "regular") + - " property " + propname + " property bag state " + propertyBagState + - " for type " + this.GetType().Name); var missingPropertyArgs = new PropertyMissingEventArgs(propname, this.GetType().Name); //treat first the expensive properties Property prop = Properties.Get(propname); + + if (SmoEventSource.Log.IsEnabled()) + { + SmoEventSource.Log.PropertyMissing( + prop.Expensive, + false, + propname, + GetType().Name, + propertyBagState.ToString()); + } if (prop.Expensive) { String[] fields = new String[1]; @@ -1667,14 +1679,12 @@ private System.Data.IDataReader GetInitDataReader(string[] fields, OrderBy[] ord // retrieve the data into the property collection // This query should return just one row ! System.Data.IDataReader reader = this.ExecutionManager.GetEnumeratorDataReader(req); - Diagnostics.TraceHelper.Assert(null != reader, "reader == null"); + Debug.Assert(null != reader, "reader == null"); // if the table has no rows this means that initialization of the object has failed if (!reader.Read()) { reader.Close(); - System.Diagnostics.Trace.TraceWarning("Failed to Initialize urn " + urn); - //throw new FailedOperationException(ExceptionTemplates.FailedtoInitialize(urn)); return null; // this seems to be "normal", so why throw? } @@ -1763,16 +1773,16 @@ internal virtual void AddObjectPropsFromDataReader(System.Data.IDataReader reade int startColIdx, int endColIdx) { var schemaTable = reader.GetSchemaTable(); - Diagnostics.TraceHelper.Assert(null != schemaTable, "reader.GetSchemaTable()==null"); - Diagnostics.TraceHelper.Assert(schemaTable.Rows.Count == reader.FieldCount, "schemaTable.Rows.Count != reader.FieldCount"); + Debug.Assert(null != schemaTable, "reader.GetSchemaTable()==null"); + Debug.Assert(schemaTable.Rows.Count == reader.FieldCount, "schemaTable.Rows.Count != reader.FieldCount"); int colNameIdx = schemaTable.Columns.IndexOf("ColumnName"); - Diagnostics.TraceHelper.Assert(colNameIdx > -1, "IndexOf(\"ColumnName\")==-1"); + Debug.Assert(colNameIdx > -1, "IndexOf(\"ColumnName\")==-1"); for (int i = startColIdx; i < (endColIdx >= 0 ? endColIdx : schemaTable.Rows.Count); i++) { string columnName = schemaTable.Rows[i][colNameIdx] as string; - Diagnostics.TraceHelper.Assert(null != columnName, "schemaTable.Rows[i][\"ColumnName\"]==null"); + Debug.Assert(null != columnName, "schemaTable.Rows[i][\"ColumnName\"]==null"); object colValue = reader.GetValue(i); @@ -2179,13 +2189,6 @@ internal protected Database GetContextDB() } - // tracing stuff - internal protected static void Trace(string traceText) - { - Diagnostics.TraceHelper.Trace(SmoApplication.ModuleName, SmoApplication.trAlways, "{0}", traceText); - } - - /// /// Controls how CreateImpl executes a query. true means a single record is fetched after the query executes and the /// value is stored in the property ScalarResult @@ -2684,13 +2687,13 @@ PermissionInfo[] GetPermissionsFromCache(PermissionWorker.PermissionEnumKind kin { if (null == objIdent) { - Diagnostics.TraceHelper.Assert(null == columnName, "null == columnName"); + Debug.Assert(null == columnName, "null == columnName"); objIdent = new PermissionInfo.ObjIdent(perm.ObjectClass); if (kind == PermissionWorker.PermissionEnumKind.Column) { // in the case of columns we need to set the info // of the parent - Diagnostics.TraceHelper.Assert(this is Column, "this is Column"); + Debug.Assert(this is Column, "this is Column"); objIdent.SetData(((Column)this).Parent); columnName = ((Column)this).Name; } @@ -3024,7 +3027,7 @@ internal StringComparer StringComparer get { InitializeStringComparer(); - Diagnostics.TraceHelper.Assert(m_comparer != null); + Debug.Assert(m_comparer != null); return m_comparer; } } @@ -3106,8 +3109,10 @@ private bool TryGetProperty(string propertyName, ref T value) // The collation value used for in-database comparisons depends on a combination of 3 properties: // ContainmentType, CatalogCollation, and Collation. This method fetches the subset of those 3 properties - // that is valid for the current database in one fetch at most, avoiding a full Database object fetch - // Only valid if this object is of type Database + // that is valid for the current database in one fetch at most, avoiding a full Database object fetch. + // If the current object is the Database, we can write those fetched properties to it to avoid another fetch. + // This code could handle some further refactoring, as only Database objects support CatalogCollation and ContainmentType properties, and a Server's + // Collation property comes from a ServerProperty query not from the master database Collation, but that level of rewrite is risky. private string GetCollationRelatedProperties(string dbName, out ContainmentType containmentType, out CatalogCollationType catalogCollation) { var propertiesToFetch = new List(); @@ -3115,34 +3120,46 @@ private string GetCollationRelatedProperties(string dbName, out ContainmentType CatalogCollationType localCatalogCollationType = CatalogCollationType.DatabaseDefault; string collation = null; - if (!TryGetProperty("ContainmentType", ref localContainmentType)) + Debug.Assert(!(this is Database database) || string.Compare(dbName, database.Name, StringComparison.OrdinalIgnoreCase) == 0, + "dbName parameter should match Database.Name property when called from Database object"); + if (!(this is Database) || State != SqlSmoState.Creating) { - if (dbName != "master" && dbName != "msdb" && IsSupportedProperty("ContainmentType")) + if (!TryGetProperty("ContainmentType", ref localContainmentType)) { - propertiesToFetch.Add("ContainmentType"); + if (dbName != "master" && dbName != "msdb" && IsSupportedProperty("ContainmentType")) + { + propertiesToFetch.Add("ContainmentType"); + } } - } - if (!TryGetProperty("CatalogCollation", ref localCatalogCollationType) && IsSupportedProperty("CatalogCollation")) - { - propertiesToFetch.Add("CatalogCollation"); - } - - if (!TryGetProperty("Collation", ref collation)) - { - // Azure SQL database masters are fixed around the world to the same collation - if (this.DatabaseEngineType == DatabaseEngineType.SqlAzureDatabase && - string.Compare(dbName, "master", StringComparison.OrdinalIgnoreCase) == 0) + if (!TryGetProperty("CatalogCollation", ref localCatalogCollationType) && IsSupportedProperty(nameof(Database.CatalogCollation))) { - collation = "SQL_Latin1_General_CP1_CI_AS"; + if (DatabaseEngineType == DatabaseEngineType.SqlAzureDatabase && + string.Compare(dbName, "master", StringComparison.OrdinalIgnoreCase) == 0) + { + localCatalogCollationType = CatalogCollationType.SQLLatin1GeneralCP1CIAS; + } + else + { + propertiesToFetch.Add("CatalogCollation"); + } } - else + + if (!TryGetProperty("Collation", ref collation)) { - propertiesToFetch.Add("Collation"); + // Azure SQL database masters are fixed around the world to the same collation + if (DatabaseEngineType == DatabaseEngineType.SqlAzureDatabase && + string.Compare(dbName, "master", StringComparison.OrdinalIgnoreCase) == 0) + { + collation = "SQL_Latin1_General_CP1_CI_AS"; + } + else + { + propertiesToFetch.Add("Collation"); + } } } - - if (propertiesToFetch.Any()) + if (propertiesToFetch.Count > 0) { // Use an SFC request to fetch needed properties var request = new Request(string.Format(SmoApplication.DefaultCulture, @@ -3150,33 +3167,50 @@ private string GetCollationRelatedProperties(string dbName, out ContainmentType Urn.EscapeString(dbName)), propertiesToFetch.ToArray()); - // handles the cloud DB case too (using Server's Execution Manager) - var dataTable = this.GetServerObject().ExecutionManager.GetEnumeratorData(request); + var dataTable = ExecutionManager.GetEnumeratorData(request); if (dataTable.Rows.Count > 0) { - if (dataTable.Columns.Contains("Collation") && dataTable.Rows[0]["Collation"] != DBNull.Value) + if (dataTable.Columns.Contains(nameof(Database.Collation)) && dataTable.Rows[0][nameof(Database.Collation)] != DBNull.Value) { - collation = (string) dataTable.Rows[0]["Collation"]; + collation = (string)dataTable.Rows[0][nameof(Database.Collation)]; + if (this is Database) + { + var pid = Properties.LookupID(nameof(Database.Collation), PropertyAccessPurpose.Read); + Properties.SetValue(pid, collation); + Properties.SetRetrieved(pid, true); + } } - if (dataTable.Columns.Contains("CatalogCollation") && - dataTable.Rows[0]["CatalogCollation"] != DBNull.Value) + if (dataTable.Columns.Contains(nameof(Database.CatalogCollation)) && + dataTable.Rows[0][nameof(Database.CatalogCollation)] != DBNull.Value) { - localCatalogCollationType = (CatalogCollationType) dataTable.Rows[0]["CatalogCollation"]; + localCatalogCollationType = (CatalogCollationType)dataTable.Rows[0][nameof(Database.CatalogCollation)]; + if (this is Database) + { + var pid = Properties.LookupID(nameof(Database.CatalogCollation), PropertyAccessPurpose.Read); + Properties.SetValue(pid, localCatalogCollationType); + Properties.SetRetrieved(pid, true); + } } - if (dataTable.Columns.Contains("ContainmentType") && - dataTable.Rows[0]["ContainmentType"] != DBNull.Value) + if (dataTable.Columns.Contains(nameof(Database.ContainmentType)) && + dataTable.Rows[0][nameof(Database.ContainmentType)] != DBNull.Value) { - localContainmentType = (ContainmentType) dataTable.Rows[0]["ContainmentType"]; + localContainmentType = (ContainmentType)dataTable.Rows[0][nameof(Database.ContainmentType)]; + if (this is Database) + { + var pid = Properties.LookupID(nameof(Database.ContainmentType), PropertyAccessPurpose.Read); + Properties.SetValue(pid, localContainmentType); + Properties.SetRetrieved(pid, true); + } } } } catalogCollation = localCatalogCollationType; containmentType = localContainmentType; - return collation ?? String.Empty; + return collation ?? string.Empty; } internal protected virtual string CollationDatabaseInServer => "master"; @@ -3214,7 +3248,7 @@ internal StringComparer GetDbComparer(bool inServer) //Couldn't get the collation from the database //so fall back to the server's dbcoll = this.GetServerObject().Collation; - Trace(string.Format( + SmoEventSource.Log.GeneralMessage(string.Format( "Got null/empty DB Collation for DB {0}, falling back to using server collation {1}", dbName, dbcoll)); } @@ -3405,7 +3439,8 @@ internal ServerInformation ServerInfo ExecutionManager.GetDatabaseEngineEdition(), hostPlatform: server == null ? HostPlatformNames.Windows : server.HostPlatform, connectionProtocol: ExecutionManager.GetConnectionProtocol(), - isFabricServer: ExecutionManager.IsFabricConnection); + isFabricServer: ExecutionManager.IsFabricConnection, + collation: ExecutionManager.ConnectionContext.Collation); } } @@ -3468,7 +3503,7 @@ public static String QuoteString(String name, char cStart = '\'', char cEnd = '\ /// internal static String MakeSqlStringForInsert(String s) { - Diagnostics.TraceHelper.Assert(s != null); + Debug.Assert(s != null); return MakeSqlString(s).Replace("\\" + System.Environment.NewLine, "\\\' + N'" + System.Environment.NewLine); } @@ -4014,7 +4049,7 @@ internal List InitQueryUrns(Urn levelFilter, { currType = GetChildType(parsedUrn[reverseIdx].Name, (reverseIdx > 0) ? parsedUrn[reverseIdx - 1].Name : this.GetType().Name); - Diagnostics.TraceHelper.Assert(null != currType, "currType == null"); + Debug.Assert(null != currType, "currType == null"); if (null == parentType) { @@ -4574,7 +4609,7 @@ internal void InitChildLevel(Urn levelFilter, ScriptingPreferences sp, bool forS { currType = GetChildType(parsedUrn[reverseIdx].Name, (reverseIdx > 0) ? parsedUrn[reverseIdx - 1].Name : this.GetType().Name); - Diagnostics.TraceHelper.Assert(null != currType, "currType == null"); + Debug.Assert(null != currType, "currType == null"); if (null == parentType) { @@ -5579,8 +5614,8 @@ private bool AdvanceInitRec(SqlSmoObject currentSmoObject, int startLeafIdx) { // verify that we have received a valid parent row - Diagnostics.TraceHelper.Assert(null != parentRow, "parentRow == null"); - Diagnostics.TraceHelper.Assert(parentRow.Length == reader.FieldCount, + Debug.Assert(null != parentRow, "parentRow == null"); + Debug.Assert(parentRow.Length == reader.FieldCount, "parentRow.Length != reader.FieldCount"); // if we are on the last level of the Urn, the eat the current row @@ -5723,7 +5758,7 @@ private static int CompareObjectToRow(SqlSmoObject currObj, System.Data.IDataRea } catch (IndexOutOfRangeException) { - Diagnostics.TraceHelper.Assert(false, "currentRow.GetOrdinal(" + idRowName + ") failed"); + Debug.Assert(false, "currentRow.GetOrdinal(" + idRowName + ") failed"); } Int32 rowObjectID = Convert.ToInt32(currentRow.GetValue(idRowIdx), SmoApplication.DefaultCulture); return (objectID - rowObjectID); @@ -5744,15 +5779,15 @@ private static int CompareObjectToRow(SqlSmoObject currObj, System.Data.IDataRea /// private bool CompareRows(System.Data.IDataReader reader, object[] parentRow, int columnStartIdx, int columnStopIdx) { - Diagnostics.TraceHelper.Assert(null != reader, "reader == null"); + Debug.Assert(null != reader, "reader == null"); if (reader.IsClosed) { return false; } - Diagnostics.TraceHelper.Assert(null != parentRow, "parentRow == null"); - Diagnostics.TraceHelper.Assert(columnStartIdx >= 0, "columnStartIdx < 0"); - Diagnostics.TraceHelper.Assert(columnStopIdx < reader.FieldCount, "columnStopIdx >= reader.FieldCount"); + Debug.Assert(null != parentRow, "parentRow == null"); + Debug.Assert(columnStartIdx >= 0, "columnStartIdx < 0"); + Debug.Assert(columnStopIdx < reader.FieldCount, "columnStopIdx >= reader.FieldCount"); for (int i = columnStartIdx; i < columnStopIdx; i++) @@ -6162,7 +6197,7 @@ public virtual ExecutionManager ExecutionManager //if it is not the Server it must have a parent // And Server should override this method to return proper ExecutionManager - Diagnostics.TraceHelper.Assert(null != parent, "parent == null"); + Debug.Assert(null != parent, "parent == null"); return parent.ExecutionManager; } @@ -6194,14 +6229,13 @@ protected void ThrowIfBelowVersion80(string exceptionMessage = null) } /// - /// Throws an exception if the ServerVersion major version for this object is below 9.0 (SQL 2005) + /// This method previously threw an exception if the ServerVersion major version was below 9.0 (SQL 2005). + /// Since the minimum supported version is now SQL Server 2008 (version 10), this check is no longer needed. + /// The method is retained for API compatibility but no longer throws exceptions. /// protected void ThrowIfBelowVersion90(string exceptionMessage = null) { - if (ServerVersion.Major < 9) - { - throw new UnsupportedVersionException(string.IsNullOrEmpty(exceptionMessage) ? ExceptionTemplates.SupportedOnlyOn90 : exceptionMessage).SetHelpContext("SupportedOnlyOn90"); - } + // No-op: Minimum supported version is SQL Server 2008 (version 10), which is >= 9.0 } /// @@ -6234,10 +6268,7 @@ protected void ThrowIfAboveVersion100(string exceptionMessage = null) /// protected void ThrowIfBelowVersion100(string exceptionMessage = null) { - if (ServerVersion.Major < 10) - { - throw new UnsupportedVersionException(string.IsNullOrEmpty(exceptionMessage) ? ExceptionTemplates.SupportedOnlyOn100 : exceptionMessage).SetHelpContext("SupportedOnlyOn100"); - } + // Minimum supported version is now SQL Server 2008 (10.0), so this check is no longer needed } /// @@ -6461,8 +6492,7 @@ public bool IsExpressSku() return false; } Server svr = this.GetServerObject(); - return (svr.Information.ServerVersion.Major >= 9 && - svr.Information.Edition.StartsWith("Express Edition", StringComparison.OrdinalIgnoreCase)); + return svr.Information.Edition.StartsWith("Express Edition", StringComparison.OrdinalIgnoreCase); } /// @@ -6696,10 +6726,10 @@ private static void ThrowIfBelowVersionLimit(SqlServerVersion targetVersion, Sql internal CompatibilityLevel GetCompatibilityLevel() { Server srv = GetServerObject(); - Diagnostics.TraceHelper.Assert(null != srv, "srv == null"); + Debug.Assert(null != srv, "srv == null"); string dbName = GetDBName(); - Diagnostics.TraceHelper.Assert(null != dbName, "dbName == null"); + Debug.Assert(null != dbName, "dbName == null"); if (dbName.Length != 0) { @@ -6729,10 +6759,6 @@ internal static CompatibilityLevel GetCompatibilityLevel(ServerVersion ver) { switch (ver.Major) { - case 8: - return CompatibilityLevel.Version80; - case 9: - return CompatibilityLevel.Version90; case 10: return CompatibilityLevel.Version100; case 11: @@ -6839,12 +6865,6 @@ internal static string GetSqlServerName(SqlSmoObject srv) switch (srv.ServerVersion.Major) { - case 7: - return LocalizableResources.ServerSphinx; - case 8: - return LocalizableResources.ServerShiloh; - case 9: - return LocalizableResources.ServerYukon; case 10: if (srv.ServerVersion.Minor == 0) { @@ -6931,11 +6951,6 @@ protected string GetFragOptionString(FragmentationOption fragmentationOption) break; case FragmentationOption.Sampled: - if (ServerVersion.Major < 9) - { - throw new UnsupportedVersionException(ExceptionTemplates.InvalidOptionForVersion("EnumFragmentation", fragmentationOption.ToString(), GetSqlServerVersionName())); - } - optStr = "FragmentationSampled"; break; @@ -7418,7 +7433,7 @@ protected bool IsVersion80SP3() protected bool IsVersion90AndAbove() { - return (ServerVersion.Major >= 9); + return true; } @@ -8577,8 +8592,8 @@ private object GetPropertyValueByReflection(string propertyName, Type propertyTy /// private bool IsSpeciallyLoaded(Type t, string propertyName) { - Diagnostics.TraceHelper.Assert(t != null, "Expect non-null type"); - Diagnostics.TraceHelper.Assert(propertyName != null, "Expect non-null property name"); + Debug.Assert(t != null, "Expect non-null type"); + Debug.Assert(propertyName != null, "Expect non-null property name"); switch (t.Name) { diff --git a/src/Microsoft/SqlServer/Management/Smo/StatisticBase.cs b/src/Microsoft/SqlServer/Management/Smo/StatisticBase.cs index 142bc0ba..34f6206d 100644 --- a/src/Microsoft/SqlServer/Management/Smo/StatisticBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/StatisticBase.cs @@ -101,7 +101,6 @@ internal override void ScriptCreate(StringCollection queries, ScriptingPreferenc } bool updateStream = sp.Data.OptimizerData && - this.ServerVersion.Major >= 9 && sp.TargetServerVersion >= SqlServerVersion.Version90; // skip statistics that are created automatically for index // if we don't require optimizer data @@ -223,7 +222,7 @@ private void GetDDL(StringBuilder sb, ScriptingPreferences sp, bool creating) //We are not checking for SQL injection //Adding the WHERE clause for FILTER, except in the case of UPDATE STATISTICS (which does not support filters). - if (this.ServerVersion.Major >= 10 && sp.TargetServerVersion >= SqlServerVersion.Version100) + if (sp.TargetServerVersion >= SqlServerVersion.Version100) { string FilterDefinition = Properties.Get("FilterDefinition").Value as string; if (null != FilterDefinition && 0 < FilterDefinition.Length && !isUpdateStatistics) @@ -236,7 +235,6 @@ private void GetDDL(StringBuilder sb, ScriptingPreferences sp, bool creating) if (sp.Data.OptimizerData && - this.ServerVersion.Major >= 9 && sp.TargetServerVersion >= SqlServerVersion.Version90 && this.ServerInfo.DatabaseEngineEdition != Cmn.DatabaseEngineEdition.SqlDataWarehouse) { diff --git a/src/Microsoft/SqlServer/Management/Smo/SymmetricKeyBase.cs b/src/Microsoft/SqlServer/Management/Smo/SymmetricKeyBase.cs index aaca2052..7beee19b 100644 --- a/src/Microsoft/SqlServer/Management/Smo/SymmetricKeyBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/SymmetricKeyBase.cs @@ -6,6 +6,7 @@ using System.Data; using System.Diagnostics.CodeAnalysis; using System.Text; +using System.Diagnostics; using Microsoft.SqlServer.Management.Sdk.Sfc; using Microsoft.SqlServer.Management.Smo.Internal; using Cmn = Microsoft.SqlServer.Management.Common; @@ -428,7 +429,7 @@ public void AddKeyEncryption(SymmetricKeyEncryption[] keyEncryptions) CheckNullArgument(keyEncryptions, "keyEncryptions"); - Diagnostics.TraceHelper.Assert(keyEncryptions.Length > 0); + Debug.Assert(keyEncryptions.Length > 0); if (keyEncryptions.Length > 0) { @@ -438,7 +439,7 @@ public void AddKeyEncryption(SymmetricKeyEncryption[] keyEncryptions) sb.Append(" ADD "); string keyEncryptionsScript = ScriptSymmetricKeyEncryptions(keyEncryptions); - Diagnostics.TraceHelper.Assert(keyEncryptionsScript.Length > 0); + Debug.Assert(keyEncryptionsScript.Length > 0); sb.Append(keyEncryptionsScript); @@ -480,7 +481,7 @@ public void DropKeyEncryption(SymmetricKeyEncryption[] keyEncryptions) CheckNullArgument(keyEncryptions, "keyEncryptions"); - Diagnostics.TraceHelper.Assert(keyEncryptions.Length > 0); + Debug.Assert(keyEncryptions.Length > 0); if (keyEncryptions.Length > 0) { @@ -490,7 +491,7 @@ public void DropKeyEncryption(SymmetricKeyEncryption[] keyEncryptions) sb.Append(" DROP "); string keyEncryptionsScript = ScriptSymmetricKeyEncryptions(keyEncryptions); - Diagnostics.TraceHelper.Assert(keyEncryptionsScript.Length > 0); + Debug.Assert(keyEncryptionsScript.Length > 0); sb.Append(keyEncryptionsScript); @@ -762,7 +763,7 @@ internal override void ScriptCreate(StringCollection query, ScriptingPreferences CreateInfo createInfo = this.createInfo; this.createInfo = null; - Diagnostics.TraceHelper.Assert(null != createInfo, "caller should initialize createInfo it before calling"); + Debug.Assert(null != createInfo, "caller should initialize createInfo it before calling"); StringBuilder sb = new StringBuilder("CREATE SYMMETRIC KEY "); sb.Append(FormatFullNameForScripting(sp)); @@ -779,13 +780,13 @@ internal override void ScriptCreate(StringCollection query, ScriptingPreferences if (createInfo.keyEncryptionAlgorithm == SymmetricKeyEncryptionAlgorithm.CryptographicProviderDefined) { ThrowIfBelowVersion100(); - Diagnostics.TraceHelper.Assert(createInfo.keyEncryptions.Length == 1, "There should be only one keyEncryptionType which is the provider"); + Debug.Assert(createInfo.keyEncryptions.Length == 1, "There should be only one keyEncryptionType which is the provider"); SymmetricKeyEncryption keyEncryption = createInfo.keyEncryptions[0]; CheckNullArgument(keyEncryption, "keyEncryption"); CheckNullArgument(keyEncryption.ObjectNameOrPassword, "keyEncryption.ObjectNameOrPassword"); // sanity check - Diagnostics.TraceHelper.Assert(keyEncryption.KeyEncryptionType == KeyEncryptionType.Provider); + Debug.Assert(keyEncryption.KeyEncryptionType == KeyEncryptionType.Provider); sb.Append(string.Format(SmoApplication.DefaultCulture, "FROM PROVIDER {0}", MakeSqlBraket(keyEncryption.ObjectNameOrPassword))); sb.Append(Globals.newline); @@ -861,7 +862,7 @@ internal override void ScriptCreate(StringCollection query, ScriptingPreferences private string ScriptSymmetricKeyEncryptions(SymmetricKeyEncryption[] keyEncryptions) { //condition also verified by the caller - Diagnostics.TraceHelper.Assert(null != keyEncryptions); + Debug.Assert(null != keyEncryptions); //if we have key encriptions, prepare to script them if (keyEncryptions.Length <= 0) diff --git a/src/Microsoft/SqlServer/Management/Smo/TableViewBase.cs b/src/Microsoft/SqlServer/Management/Smo/TableViewBase.cs index 447641c2..06248ebf 100644 --- a/src/Microsoft/SqlServer/Management/Smo/TableViewBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/TableViewBase.cs @@ -157,11 +157,6 @@ public DataTable EnumFragmentation(FragmentationOption fragmentationOption, int } CheckObjectState(); - //Yukon only - if(ServerVersion.Major < 9) - { - throw new UnsupportedVersionException(ExceptionTemplates.InvalidParamForVersion("EnumFragmentation", "partitionNumber", GetSqlServerVersionName())).SetHelpContext("InvalidParamForVersion"); - } string urn = string.Format(SmoApplication.DefaultCulture, "{0}/Index/{1}[@PartitionNumber={2}]", this.Urn.Value, GetFragOptionString(fragmentationOption), partitionNumber); diff --git a/src/Microsoft/SqlServer/Management/Smo/TriggerBase.cs b/src/Microsoft/SqlServer/Management/Smo/TriggerBase.cs index 57f0452a..23f4110f 100644 --- a/src/Microsoft/SqlServer/Management/Smo/TriggerBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/TriggerBase.cs @@ -223,16 +223,13 @@ bool ShouldScriptBodyAtAlter() sc.Add("NotForReplication"); sc.Add("ImplementationType"); - if( this.ServerVersion.Major >= 9 ) + sc.Add("ExecutionContext"); + sc.Add("ExecutionContextPrincipal"); + if (Cmn.DatabaseEngineType.SqlAzureDatabase != this.DatabaseEngineType) { - sc.Add("ExecutionContext"); - sc.Add("ExecutionContextPrincipal"); - if (Cmn.DatabaseEngineType.SqlAzureDatabase != this.DatabaseEngineType) - { - sc.Add("AssemblyName"); - sc.Add("ClassName"); - sc.Add("MethodName"); - } + sc.Add("AssemblyName"); + sc.Add("ClassName"); + sc.Add("MethodName"); } if (this.Properties.ArePropertiesDirty(sc)) @@ -330,11 +327,8 @@ private void GetInternalDDL(StringCollection queries, ScriptingPreferences sp, S { if (ImplementationType.SqlClr == (ImplementationType)property.Value) { - // CLR triggers are not supported on versions prior to 9.0 - if (ServerVersion.Major < 9) - { - throw new WrongPropertyValueException(ExceptionTemplates.ClrNotSupported("ImplementationType", ServerVersion.ToString())); - } + // CLR triggers were introduced in SQL Server 2005 (version 9.0). + // Since minimum supported version is now SQL Server 2008 (version 10), this is always supported. bTransactSql = false; @@ -402,7 +396,7 @@ private void GetInternalDDL(StringCollection queries, ScriptingPreferences sp, S AppendWithOption(sbTmp, "IsEncrypted", "ENCRYPTION", ref bNeedsComma); } - if (ServerVersion.Major >= 9 && sp.TargetServerVersion >= SqlServerVersion.Version90) + if (sp.TargetServerVersion >= SqlServerVersion.Version90) { AddScriptExecuteAs(sbTmp, sp, this.Properties, ref bNeedsComma); } diff --git a/src/Microsoft/SqlServer/Management/Smo/UserBase.cs b/src/Microsoft/SqlServer/Management/Smo/UserBase.cs index 01bcb240..9759ed98 100644 --- a/src/Microsoft/SqlServer/Management/Smo/UserBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/UserBase.cs @@ -167,8 +167,7 @@ internal override void ScriptDrop(StringCollection dropQuery, ScriptingPreferenc sb.Append(sp.NewLine); } - if (sp.TargetServerVersion >= SqlServerVersion.Version90 - && this.ServerVersion.Major >= 9) + if (sp.TargetServerVersion >= SqlServerVersion.Version90) { if (sp.IncludeScripts.ExistenceCheck && sp.TargetServerVersion < SqlServerVersion.Version130) { @@ -339,8 +338,7 @@ internal override void ScriptCreate(StringCollection createQuery, ScriptingPrefe sb.Append(sp.NewLine); } - if (sp.TargetServerVersion >= SqlServerVersion.Version90 - && this.ServerVersion.Major >= 9) + if (sp.TargetServerVersion >= SqlServerVersion.Version90) { StringBuilder sbOption = new StringBuilder(); bool optionAdded = false; @@ -1160,8 +1158,7 @@ internal override void ScriptAlter(StringCollection query, ScriptingPreferences { ValidateVersionAndEngineTypeForScripting(sp); - if (sp.TargetServerVersion >= SqlServerVersion.Version90 - && this.Parent.Parent.ConnectionContext.ServerVersion.Major >= 9) + if (sp.TargetServerVersion >= SqlServerVersion.Version90) { ValidateAlterInputs(); @@ -1312,14 +1309,7 @@ private string ScriptAddToRole(System.String role, ScriptingPreferences sp) } else { - if (this.ServerVersion.Major >= 9) - { - prefix = "sys"; - } - else - { - prefix = "dbo"; - } + prefix = "sys"; } string username; if (sp != null) @@ -1367,10 +1357,6 @@ public void Rename(string newname) internal override void ScriptRename(StringCollection renameQuery, ScriptingPreferences sp, string newName) { - if (this.ServerVersion.Major < 9) - { - throw new InvalidVersionSmoOperationException(this.ServerVersion); - } // the user is responsible to put the database in single user mode on 7.0 server renameQuery.Add(string.Format(SmoApplication.DefaultCulture, Scripts.USEDB, SqlBraket(Parent.Name))); diff --git a/src/Microsoft/SqlServer/Management/Smo/UserDefinedFunctionBase.cs b/src/Microsoft/SqlServer/Management/Smo/UserDefinedFunctionBase.cs index 49930f6a..c538202f 100644 --- a/src/Microsoft/SqlServer/Management/Smo/UserDefinedFunctionBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/UserDefinedFunctionBase.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.Text; +using System.Diagnostics; using Microsoft.SqlServer.Management.Sdk.Sfc; using Microsoft.SqlServer.Management.Sdk.Sfc.Metadata; using Cmn = Microsoft.SqlServer.Management.Common; @@ -156,11 +157,8 @@ private void ScriptUDF(StringCollection queries, ScriptingPreferences sp, Script { if (ImplementationType.SqlClr == (ImplementationType)property.Value) { - // CLR procedures are not supported on versions prior to 9.0 - if (ServerVersion.Major < 9) - { - throw new WrongPropertyValueException(ExceptionTemplates.ClrNotSupported("ImplementationType", ServerVersion.ToString())); - } + // CLR procedures were introduced in SQL Server 2005 (version 9.0). + // Since minimum supported version is now SQL Server 2008 (version 10), this is always supported. //CLR UDF is not supported if target server is Azure below v12.0 if (sp.TargetDatabaseEngineType != Cmn.DatabaseEngineType.SqlAzureDatabase) @@ -182,7 +180,7 @@ private void ScriptUDF(StringCollection queries, ScriptingPreferences sp, Script { string sExists; sExists = (sp.ScriptForAlter) ? string.Empty : "NOT"; - if (sp.TargetServerVersion >= SqlServerVersion.Version90 && this.ServerVersion.Major >= 9) + if (sp.TargetServerVersion >= SqlServerVersion.Version90) { sb.AppendFormat(Scripts.INCLUDE_EXISTS_FUNCTION90, sExists, SqlString(sFullScriptingName)); } @@ -277,7 +275,7 @@ private void ScriptUDF(StringCollection queries, ScriptingPreferences sp, Script } } - if (ServerVersion.Major >= 9 && sp.TargetServerVersion >= SqlServerVersion.Version90) + if (sp.TargetServerVersion >= SqlServerVersion.Version90) { // we can't specify execution context for inline table-valued functions if (type != UserDefinedFunctionType.Inline) @@ -887,49 +885,7 @@ public bool TextMode /// internal override void ValidateProperty(Property prop, object value) { - switch (this.ServerVersion.Major) - { - case 7: - // we should not have UDFs on 7.0 - Diagnostics.TraceHelper.Assert(false, "ServerVersion.Major == 7"); - break; - case 8: - switch (prop.Name) - { - case "FunctionType": - Validate_set_TextObjectDDLProperty(prop, value); - break; - case "IsSchemaBound": goto case "FunctionType"; - case "IsEncrypted": goto case "FunctionType"; - case "TableVariableName": goto case "FunctionType"; - - default: - // other properties are not validated - break; - } - break; - case 9: - switch (prop.Name) - { - case "FunctionType": - Validate_set_TextObjectDDLProperty(prop, value); - break; - case "IsSchemaBound": goto case "FunctionType"; - case "IsEncrypted": goto case "FunctionType"; - case "ExecutionContext": goto case "FunctionType"; - case "TableVariableName": goto case "FunctionType"; - case "ExecutionContextPrincipal": goto case "FunctionType"; - case "AssemblyName": goto case "FunctionType"; - case "ClassName": goto case "FunctionType"; - case "MethodName": goto case "FunctionType"; - - default: - // other properties are not validated - break; - } - break; - default: goto case 9; - } + // No version-specific validation needed for SQL Server 2008+ } diff --git a/src/Microsoft/SqlServer/Management/Smo/ViewBase.cs b/src/Microsoft/SqlServer/Management/Smo/ViewBase.cs index bb34fea9..3514e9f2 100644 --- a/src/Microsoft/SqlServer/Management/Smo/ViewBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/ViewBase.cs @@ -332,7 +332,7 @@ private void GetDDL(StringCollection queries, ScriptingPreferences sp, ScriptHea AppendWithOption(sbForSpExec, "IsEncrypted", "ENCRYPTION", ref bNeedsComma); } - if (ServerVersion.Major >= 9 && sp.TargetServerVersion >= SqlServerVersion.Version90) + if (sp.TargetServerVersion >= SqlServerVersion.Version90) { AppendWithOption(sbForSpExec, "ReturnsViewMetadata", "VIEW_METADATA", ref bNeedsComma); } @@ -486,7 +486,7 @@ private PropagateInfo[] GetPropagateInfoImpl(bool forDiscovery) propInfo.Add(new PropagateInfo(ExtendedProperties, true, ExtendedProperty.UrnSuffix)); } - if (this.DatabaseEngineType == DatabaseEngineType.Standalone && ServerVersion.Major >= 9) + if (this.DatabaseEngineType == DatabaseEngineType.Standalone) { propInfo.Add(new PropagateInfo(FullTextIndex, true, FullTextIndex.UrnSuffix)); } @@ -607,38 +607,7 @@ public bool TextMode /// internal override void ValidateProperty(Property prop, object value) { - switch (this.ServerVersion.Major) - { - case 7: - switch (prop.Name) - { - case "IsEncrypted": - Validate_set_TextObjectDDLProperty(prop, value); - break; - case "HasColumnSpecification": goto case "IsEncrypted"; - - default: - // other properties are not validated - break; - } - break; - case 8: - switch (prop.Name) - { - case "IsSchemaBound": - Validate_set_TextObjectDDLProperty(prop, value); - break; - case "IsEncrypted": goto case "IsSchemaBound"; - case "HasColumnSpecification": goto case "IsSchemaBound"; - - default: - // other properties are not validated - break; - } - break; - case 9: goto case 8; - default: goto case 9; - } + // No version-specific validation needed for SQL Server 2008+ } diff --git a/src/Microsoft/SqlServer/Management/Smo/WorkloadGroupBase.cs b/src/Microsoft/SqlServer/Management/Smo/WorkloadGroupBase.cs index 7f6c4c2e..9ba180d6 100644 --- a/src/Microsoft/SqlServer/Management/Smo/WorkloadGroupBase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/WorkloadGroupBase.cs @@ -357,18 +357,22 @@ private void GetAllParams(StringBuilder sb, ScriptingPreferences sp, ref int cou if (IsSupportedProperty(nameof(GroupMaximumTempdbDataMB), sp)) { // For ALTER operations: convert -1 to null to explicitly reset the value in the script only if the property is dirty - // For CREATE operations: exclude -1 values entirely + // For CREATE operations: always include as null when -1 var tempdbMBProperty = Properties.Get(nameof(GroupMaximumTempdbDataMB)); var originalValue = tempdbMBProperty.Value; if (originalValue is double doubleValue && doubleValue == -1.0) { - if (isAlterOperation && tempdbMBProperty.Dirty) + if ((isAlterOperation && tempdbMBProperty.Dirty) || !isAlterOperation) { - // For ALTER: include as null to reset the value on the server + // For ALTER: include as null to reset the value on the server when dirty + // For CREATE: always include as null when -1 if (count++ > 0) { - _ = parameters.Append(", "); + _ = parameters.Append(Globals.commaspace); + _ = parameters.Append(Globals.newline); + _ = parameters.Append(Globals.tab); + _ = parameters.Append(Globals.tab); } _ = parameters.Append("group_max_tempdb_data_mb=null"); } @@ -381,17 +385,21 @@ private void GetAllParams(StringBuilder sb, ScriptingPreferences sp, ref int cou if (IsSupportedProperty(nameof(GroupMaximumTempdbDataPercent), sp)) { // For ALTER operations: convert -1 to null to explicitly reset the value in the script only if the property is dirty - // For CREATE operations: exclude -1 values entirely + // For CREATE operations: always include as null when -1 var tempdbPercentProperty = Properties.Get(nameof(GroupMaximumTempdbDataPercent)); var originalValue = tempdbPercentProperty.Value; if (originalValue is double doubleValue && doubleValue == -1.0) { - if (isAlterOperation && tempdbPercentProperty.Dirty) + if ((isAlterOperation && tempdbPercentProperty.Dirty) || !isAlterOperation) { - // For ALTER: include as null to reset the value on the server + // For ALTER: include as null to reset the value on the server when dirty + // For CREATE: always include as null when -1 if (count++ > 0) { - _ = parameters.Append(", "); + _ = parameters.Append(Globals.commaspace); + _ = parameters.Append(Globals.newline); + _ = parameters.Append(Globals.tab); + _ = parameters.Append(Globals.tab); } _ = parameters.Append("group_max_tempdb_data_percent=null"); } diff --git a/src/Microsoft/SqlServer/Management/Smo/coll_macros.h b/src/Microsoft/SqlServer/Management/Smo/coll_macros.h deleted file mode 100644 index cb2e1149..00000000 --- a/src/Microsoft/SqlServer/Management/Smo/coll_macros.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef COLLECTION_SUFFIX -#define COLLECTION_SUFFIX Collection -#endif - -#ifdef SEALED -#define SEALED_IMP sealed -#else -#define SEALED_IMP -#endif - -#define IDENTITY(x) x -#define TOKEN_PASTE(x,y) IDENTITY(x)##IDENTITY(y) -#define TOKEN_PASTE3(x,y,z) IDENTITY(x)##IDENTITY(y)##IDENTITY(z) - -#define STRINGIZE(x) #x -#define STRINGER(x) STRINGIZE(x) - - -#ifndef PARTIAL_KEYWORD - #define PARTIAL_KEYWORD -#endif diff --git a/src/Microsoft/SqlServer/Management/Smo/enumerations.cs b/src/Microsoft/SqlServer/Management/Smo/enumerations.cs index 3e3ba688..ed8ceefd 100644 --- a/src/Microsoft/SqlServer/Management/Smo/enumerations.cs +++ b/src/Microsoft/SqlServer/Management/Smo/enumerations.cs @@ -352,12 +352,13 @@ public enum DatabaseObjectTypes : long ExternalLanguage = 0x0000800000000000, ExternalStream = 0x0001000000000000, ExternalStreamingJob = 0x0002000000000000, + ExternalModel = 0x0004000000000000, // If any of the above is changed, please change the "All" line as well. The "All" value is a minimal mask. // For example, if the last value is 0x10000000, then the mask is 0x1fffffff. // If the last value is 0x20000000, then the mask is 0x3fffffff. // If the last value is 0x40000000, then the mask is 0x7fffffff. // If the last value is 0x80000000, then the mask is 0xffffffff. - All = 0x0003ffffffffffff // all above combined + All = 0x0007ffffffffffff // all above combined } [Flags] diff --git a/src/Microsoft/SqlServer/Management/Smo/exception.cs b/src/Microsoft/SqlServer/Management/Smo/exception.cs index ba3ca27c..d64762fc 100644 --- a/src/Microsoft/SqlServer/Management/Smo/exception.cs +++ b/src/Microsoft/SqlServer/Management/Smo/exception.cs @@ -1111,20 +1111,44 @@ public override string Message { if (null != version) { - if (this.version.Major >= 9) - { - return ExceptionTemplates.InvalidVersionSmoOperation(LocalizableResources.ServerYukon); - } - else if (this.version.Major == 8) + string versionName = GetVersionName(this.version); + return ExceptionTemplates.InvalidVersionSmoOperation(versionName); + } + return string.Empty; + } + } + + private string GetVersionName(ServerVersion version) + { + switch (version.Major) + { + case 10: + if (version.Minor == 0) { - return ExceptionTemplates.InvalidVersionSmoOperation(LocalizableResources.ServerShiloh); + return LocalizableResources.ServerKatmai; } - else if (this.version.Major == 7) + else if (version.Minor == 50) { - return ExceptionTemplates.InvalidVersionSmoOperation(LocalizableResources.ServerSphinx); + return LocalizableResources.ServerKilimanjaro; } - } - return string.Empty; + return version.ToString(); + case 11: + return LocalizableResources.ServerDenali; + case 12: + return LocalizableResources.ServerSQL14; + case 13: + return LocalizableResources.ServerSQL15; + case 14: + return LocalizableResources.ServerSQL2017; + case 15: + return LocalizableResources.ServerSQLv150; + case 16: + return LocalizableResources.ServerSQLv160; + case 17: + return LocalizableResources.ServerSQLv170; + default: + // VBUMP + return version.ToString(); } } diff --git a/src/Microsoft/SqlServer/Management/Smo/files.cs b/src/Microsoft/SqlServer/Management/Smo/files.cs index 1d134703..5d252c2f 100644 --- a/src/Microsoft/SqlServer/Management/Smo/files.cs +++ b/src/Microsoft/SqlServer/Management/Smo/files.cs @@ -985,8 +985,7 @@ private void ScriptPrimaryFileGroup(ScriptingPreferences sp, StringBuilder ddl, //Default not allowed for primary filegroup at time of creation of database as it is default automatically. if (Properties.Get("IsDefault").Value != null && this.Properties["IsDefault"].Dirty && this.IsDefault - && sp.TargetServerVersion >= SqlServerVersion.Version100 && - this.ServerVersion.Major >= 10) + && sp.TargetServerVersion >= SqlServerVersion.Version100) { throw new SmoException(ExceptionTemplates.PrimaryAlreadyDefault); } diff --git a/src/Microsoft/SqlServer/Management/Smo/generic_collection.cs b/src/Microsoft/SqlServer/Management/Smo/generic_collection.cs deleted file mode 100644 index f683385d..00000000 --- a/src/Microsoft/SqlServer/Management/Smo/generic_collection.cs +++ /dev/null @@ -1,236 +0,0 @@ - /////////////////////////////////////////////////////////////// - // - // Copyright (c) Microsoft Corporation. - // Licensed under the MIT license. - // WARNING : DO NOT ATTEMPT TO MODIFY THIS FILE MANUALLY - // - // This class is autogenerated from generic_collection.cs - // - /////////////////////////////////////////////////////////////// - -using System; -using System.Collections; -using System.Collections.Specialized; -using System.Text; -using System.Globalization; -#ifdef USE_SMO -using Microsoft.SqlServer.Management.Smo; -#endif -using Microsoft.SqlServer.Management.Sdk.Sfc; -#ifdef DATABASE -using Microsoft.SqlServer.Management.Common; -#endif -#ifdef DATABASE -#define EMPTY -EMPTY#if MICROSOFTDATA -using Microsoft.Data.SqlClient; -EMPTY#else -using System.Data.SqlClient; -EMPTY#endif -#endif -#include "coll_macros.h" - -namespace NAMESPACE_NAME -{ - - /// - /// Strongly typed list of MAPPED_TYPE objects - /// Has strongly typed support for all of the methods of the sorted list class - /// - public SEALED_IMP PARTIAL_KEYWORD class TOKEN_PASTE( MAPPED_TYPE, COLLECTION_SUFFIX) : SimpleObjectCollectionBase - { -#ifdef CUSTOM_COLLATION - //has custom string comparer - StringComparer m_comparer; - - //must initialize in constructor - internal TOKEN_PASTE( MAPPED_TYPE, COLLECTION_SUFFIX)(SqlSmoObject parentInstance, StringComparer comparer) : base(parentInstance) - { - m_comparer = comparer; - } - - override internal StringComparer StringComparer - { - get - { - return m_comparer; - } - } -#else - internal TOKEN_PASTE( MAPPED_TYPE, COLLECTION_SUFFIX)(SqlSmoObject parentInstance) : base(parentInstance) - { - } -#endif - -#ifdef PARENT - public PARENT Parent - { - get - { - return this.ParentInstance as PARENT; - } - } -#endif - - public MAPPED_TYPE this[Int32 index] - { - get - { - return GetObjectByIndex(index) as MAPPED_TYPE; - } - } - -#ifndef EXCLUDE_NAME_ACCESSOR - // returns wrapper class - public MAPPED_TYPE this[KEY_TYPE name] - { - get - { - #ifdef DATABASE - - try - { - - #endif - - return GetObjectByName(name) as MAPPED_TYPE; - - #ifdef DATABASE - - } - catch (Microsoft.SqlServer.Management.Common.ConnectionFailureException cfe) - { - if (cfe.InnerException is SqlException) - { - if ((cfe.InnerException as SqlException).Number == 4060) - { - Microsoft.SqlServer.Management.Diagnostics.TraceHelper.LogExCatch(cfe); - // this exception occurs if the user doesn't have access to - // the database with the input name - // in such a case the expected behavior is to return null - return null; - } - } - throw cfe; - } - #endif - - } - } -#endif - - public void CopyTo(MAPPED_TYPE[] array, int index) - { - ((ICollection)this).CopyTo(array, index); - } - -#ifdef ITEM_BY_ID - public MAPPED_TYPE ItemById(int id) - { - return (MAPPED_TYPE)GetItemById(id); - } -#endif - -#ifdef ITEM_BY_LANGID - public MAPPED_TYPE ItemById(int id) - { - return (MAPPED_TYPE)GetItemById(id, "LocaleID"); - } -#endif - -#ifdef SCRIPT_OBJECTS - public StringCollection Script() - { - return this.Script(new ScriptingOptions()); - } - - public StringCollection Script(ScriptingOptions scriptingOptions) - { - if( this.Count <= 0 ) - { - return new StringCollection(); - } - - SqlSmoObject [] scriptList = new SqlSmoObject[this.Count]; - int i = 0; - foreach(SqlSmoObject o in this) - { - scriptList[i++] = o; - } - Scripter scr = new Scripter(scriptList[0].GetServerObject()); - scr.Options = scriptingOptions; - return scr.Script(scriptList); - } -#endif - - protected override Type GetCollectionElementType() - { - return typeof(MAPPED_TYPE); - } - - internal override SqlSmoObject GetCollectionElementInstance(ObjectKeyBase key, SqlSmoState state) - { - return new MAPPED_TYPE(this, key, state); - } - - -#ifdef REMOVE - - public void Remove(MAPPED_TYPE MAPPED_TYPE_VAR) - { - if( null == MAPPED_TYPE_VAR ) - throw new FailedOperationException(ExceptionTemplates.RemoveCollection, this, new ArgumentNullException(STRINGER(MAPPED_TYPE_VAR))); - - RemoveObj(MAPPED_TYPE_VAR, new SimpleObjectKey(MAPPED_TYPE_VAR.Name)); - } - - public void Remove(string name) - { - this.Remove(new SimpleObjectKey(name)); - } - -#endif // REMOVE - - public void Add(MAPPED_TYPE MAPPED_TYPE_VAR) - { - AddImpl(MAPPED_TYPE_VAR); - } - -#ifndef EXCLUDE_NAME_ACCESSOR - internal SqlSmoObject GetObjectByName(string name) - { - return GetObjectByKey(new SimpleObjectKey(name)); - } -#endif - - internal override ObjectKeyBase CreateKeyFromUrn(Urn urn) - { - string name = urn.GetAttribute("Name"); -#ifdef ALLOW_EMPTY_NAME_ATTRIBUTE - if( null == name) -#else - if( null == name || name.Length == 0) -#endif - throw new SmoException(ExceptionTemplates.PropertyMustBeSpecifiedInUrn("Name", urn.Type)); - return new SimpleObjectKey(name); - } -#ifdef CASE_SENSITIVE - /// - /// Initializes the storage - /// - protected override void InitInnerCollection() - { - InternalStorage = new SmoSortedList(new SimpleObjectCaseSensitiveComparer()); - } - - internal class SimpleObjectCaseSensitiveComparer : IComparer - { - int IComparer.Compare(object obj1, object obj2) - { - return string.Compare((obj1 as SimpleObjectKey).Name, (obj2 as SimpleObjectKey).Name, false, SmoApplication.DefaultCulture); - } - } -#endif - - } -} diff --git a/src/Microsoft/SqlServer/Management/Smo/permissionWorker.cs b/src/Microsoft/SqlServer/Management/Smo/permissionWorker.cs index d710321a..683d5467 100644 --- a/src/Microsoft/SqlServer/Management/Smo/permissionWorker.cs +++ b/src/Microsoft/SqlServer/Management/Smo/permissionWorker.cs @@ -96,7 +96,7 @@ internal bool IsValidPermissionForVersion(SqlServerVersion ver) internal void AddPermissionFilter(StringBuilder sb, ServerVersion ver) { - string attribute = ver.Major < 9 ? "@SqlInt = " : "@StringCode = "; + string attribute = "@StringCode = "; bool bFirst = true; for (int i = 0; i < m_storage.Length; i++) @@ -113,19 +113,7 @@ internal void AddPermissionFilter(StringBuilder sb, ServerVersion ver) } sb.Append(attribute); string s = PermissionCodeToPermissionType(i); - if (ver.Major < 9) - { - int code = YukonToShilohPermission(s); - if (code < 0) - { - throw new SmoException(ExceptionTemplates.UnsupportedPermission(code.ToString())); - } - sb.Append(code); - } - else - { - sb.Append("'" + s + "'"); - } + sb.Append("'" + s + "'"); } } } @@ -431,14 +419,6 @@ static void AddArrayToStringBuider(StringBuilder sb, string[] list) /// internal static void CheckPermissionsAllowed(SqlSmoObject obj) { - if (obj.ServerVersion.Major < 9) - { - string typeName = obj.GetType().Name; - if (typeName == "Login" || typeName == "User") - { - throw new UnsupportedVersionException(ExceptionTemplates.SupportedOnlyOn90); - } - } } internal static string ScriptPermissionInfo(SqlSmoObject obj, PermissionInfo pi, ScriptingPreferences sp, bool grantGrant, bool cascade) diff --git a/src/Microsoft/SqlServer/Management/Smo/propertiesCollection.cs b/src/Microsoft/SqlServer/Management/Smo/propertiesCollection.cs index 3389ada2..98b8ce42 100644 --- a/src/Microsoft/SqlServer/Management/Smo/propertiesCollection.cs +++ b/src/Microsoft/SqlServer/Management/Smo/propertiesCollection.cs @@ -4,6 +4,7 @@ using System; using System.Collections; using System.Collections.Specialized; +using System.Diagnostics; using Microsoft.SqlServer.Management.Common; #pragma warning disable 1590,1591,1592,1573,1571,1570,1572,1587 @@ -52,7 +53,7 @@ internal BitStorage(int itemCount) protected void SetBit(int itemIndex, BitStorage.BitIndex bitIndex, bool value) { - Diagnostics.TraceHelper.Assert(itemIndex >= 0 && itemIndex < this.count); + Debug.Assert(itemIndex >= 0 && itemIndex < this.count); int index = itemIndex * BitsPerItem + (int)bitIndex; @@ -68,7 +69,7 @@ protected void SetBit(int itemIndex, BitStorage.BitIndex bitIndex, bool value) protected bool GetBit(int itemIndex, BitStorage.BitIndex bitIndex) { - Diagnostics.TraceHelper.Assert(itemIndex >= 0 && itemIndex < this.count); + Debug.Assert(itemIndex >= 0 && itemIndex < this.count); int index = itemIndex * BitsPerItem + (int)bitIndex; return (this.bitArray[index / 32] & (1 << (index % 32))) != 0; diff --git a/src/Microsoft/SqlServer/Management/Smo/propertiesMetadata.cs b/src/Microsoft/SqlServer/Management/Smo/propertiesMetadata.cs index cc5d0cff..0cce998a 100644 --- a/src/Microsoft/SqlServer/Management/Smo/propertiesMetadata.cs +++ b/src/Microsoft/SqlServer/Management/Smo/propertiesMetadata.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. +// Copyright (c) Microsoft Corporation. // Licensed under the MIT license. using System; @@ -268,23 +268,7 @@ internal static int GetCurrentVersionIndex(ServerVersion sv, DatabaseEngineType if (databaseEngineType == DatabaseEngineType.Standalone) { switch (sv.Major) - { - case 7: - { - versionIndex = (int)StandaloneVersionIndex.v70; - break; - } - case 8: - { - versionIndex = (int)StandaloneVersionIndex.v80; - break; - } - case 9: - { - versionIndex = (int)StandaloneVersionIndex.v90; - break; - } - case 10: + {case 10: { if (sv.Minor == 0) { @@ -381,7 +365,7 @@ internal static int GetCurrentVersionIndex(ServerVersion sv, DatabaseEngineType } else { //Unknown DatabaseEngineType, just return the default value in this case since it's not a critical issue - Diagnostics.TraceHelper.Assert(false, string.Format(CultureInfo.InvariantCulture, "Unknown DatabaseEngineType {0} when getting current version index", databaseEngineType.ToString())); + Debug.Assert(false, string.Format(CultureInfo.InvariantCulture, "Unknown DatabaseEngineType {0} when getting current version index", databaseEngineType.ToString())); } return versionIndex; @@ -485,10 +469,10 @@ internal override bool TryPropertyNameToIDLookup(string propertyName, out int in /// /// The exception text should be: - /// Cannot read property ‘{0}.IsSparse’. This property is not available on {1}. - /// Cannot write property ‘{0}.IsSparse’. This property is not available on {1}. + /// Cannot read property ?{0}.IsSparse?. This property is not available on {1}. + /// Cannot write property ?{0}.IsSparse?. This property is not available on {1}. /// {0} = class (as there are 2 classes that have IsSparse) - /// {1} = “SQL Server 7.0” or “SQL Server 2000” or “SQL Server 2005” + /// {1} = ?SQL Server 7.0? or ?SQL Server 2000? or ?SQL Server 2005? /// Of course, if a property is Unknown (through indexer/getter) then it still be the same old 'Unknown' error message. /// /// @@ -606,7 +590,7 @@ private string GetServerNameFromVersionIndex(int index) default: // VBUMP { //Index is unknown, leave as default value but log the error since it shouldn't happen - Diagnostics.TraceHelper.Assert(false, string.Format(CultureInfo.InvariantCulture, "Unknown server version index {0}", index)); + Debug.Assert(false, string.Format(CultureInfo.InvariantCulture, "Unknown server version index {0}", index)); break; } } @@ -625,7 +609,7 @@ private string GetServerNameFromVersionIndex(int index) } else { //Just leave as default version but log the error since this shouldn't happen normally - Diagnostics.TraceHelper.Assert(false, string.Format(CultureInfo.InvariantCulture, "Unknown DatabaseEngineType {0}", this.databaseEngineType)); + Debug.Assert(false, string.Format(CultureInfo.InvariantCulture, "Unknown DatabaseEngineType {0}", this.databaseEngineType)); } return versionName; @@ -640,7 +624,7 @@ private string GetServerNameFromVersionIndex(int index) private SqlServerVersions GetSupportedVersions(int index) { //check out of range - Diagnostics.TraceHelper.Assert(index >= 0 && index < this.VersionCount[this.VersionCount.Length - 1] + Debug.Assert(index >= 0 && index < this.VersionCount[this.VersionCount.Length - 1] , "SuportedVersions: index out of range"); if (index < 0 || index >= this.VersionCount[this.VersionCount.Length - 1]) { diff --git a/src/Microsoft/SqlServer/Management/Smo/serverbase.cs b/src/Microsoft/SqlServer/Management/Smo/serverbase.cs index 1c5fd0f5..6a9a8df4 100644 --- a/src/Microsoft/SqlServer/Management/Smo/serverbase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/serverbase.cs @@ -95,7 +95,7 @@ void Init() { if (this.serverConnection == null) { - Diagnostics.TraceHelper.Assert(m_ExecutionManager != null, "m_ExecutionManager == null"); + Debug.Assert(m_ExecutionManager != null, "m_ExecutionManager == null"); this.serverConnection = m_ExecutionManager.ConnectionContext; } @@ -170,7 +170,7 @@ internal set } else { - Diagnostics.TraceHelper.Assert(false, "Version property of Server can only be set in design mode"); + Debug.Assert(false, "Version property of Server can only be set in design mode"); } } } @@ -210,6 +210,10 @@ public Version BuildClrVersion } } + + [SfcProperty(SfcPropertyFlags.Standalone | SfcPropertyFlags.SqlAzureDatabase)] + public string Collation => ExecutionManager.ConnectionContext.Collation; + /// /// Overrides the standard behavior of scripting object permissions. /// @@ -860,44 +864,37 @@ private void AttachDatabaseWorker(string name, statement.Append(Globals.newline); - if (this.ServerVersion.Major >= 9) + if (attachOptions == AttachOptions.RebuildLog) { - if (attachOptions == AttachOptions.RebuildLog) - { - statement.Append(" FOR ATTACH_REBUILD_LOG"); - } - else - { - statement.Append(" FOR ATTACH"); - - switch (attachOptions) - { - case AttachOptions.EnableBroker: - statement.Append(" WITH ENABLE_BROKER"); - break; - - case AttachOptions.NewBroker: - statement.Append(" WITH NEW_BROKER"); - break; - - case AttachOptions.ErrorBrokerConversations: - statement.Append(" WITH ERROR_BROKER_CONVERSATIONS"); - break; - - case AttachOptions.None: - // - // do nothing. - // - break; - - default: - throw new ArgumentException(ExceptionTemplates.UnknownEnumeration("AttachOptions")); - } - } + statement.Append(" FOR ATTACH_REBUILD_LOG"); } else { statement.Append(" FOR ATTACH"); + + switch (attachOptions) + { + case AttachOptions.EnableBroker: + statement.Append(" WITH ENABLE_BROKER"); + break; + + case AttachOptions.NewBroker: + statement.Append(" WITH NEW_BROKER"); + break; + + case AttachOptions.ErrorBrokerConversations: + statement.Append(" WITH ERROR_BROKER_CONVERSATIONS"); + break; + + case AttachOptions.None: + // + // do nothing. + // + break; + + default: + throw new ArgumentException(ExceptionTemplates.UnknownEnumeration("AttachOptions")); + } } @@ -1753,14 +1750,7 @@ private CollationVersion FindCollationVersion(string collationName) version value 0 means shiloh supported collation version value 1 means yukon supported collation version value 2 means katmai supported collation */ - if (this.ServerVersion.Major < 9) - { - collations = this.ExecutionManager.ExecuteWithResults("SELECT CollationVersion = CASE WHEN COLLATIONPROPERTY('" + collationName + "', 'lcid') IS NOT NULL THEN '0' END").Tables[0]; - } - else - { - collations = this.ExecutionManager.ExecuteWithResults("SELECT COLLATIONPROPERTY('" + collationName + "', 'Version') as CollationVersion").Tables[0]; - } + collations = this.ExecutionManager.ExecuteWithResults("SELECT COLLATIONPROPERTY('" + collationName + "', 'Version') as CollationVersion").Tables[0]; } finally { @@ -2134,8 +2124,8 @@ public void KillAllProcesses(string databaseName) spidColumn = "request_session_id"; } - Diagnostics.TraceHelper.Assert(null != spids, "null == spids"); - Diagnostics.TraceHelper.Assert(null != spidColumn, "null == spidColumn"); + Debug.Assert(null != spids, "null == spids"); + Debug.Assert(null != spidColumn, "null == spidColumn"); var col = new StringCollection(); if (DatabaseEngineType == DatabaseEngineType.Standalone) @@ -2780,7 +2770,7 @@ public void SetDefaultInitFields(Type typeObject, StringCollection fields) /// /// Type of the object /// List of the fields - /// This value is ignored by the method. Field names not relevant for the active Database will be filtered from the query. + /// This value is only used when the type of the object is Database. For child objects of Database, properties not supported for the edition can be passed here and will be ignored. public void SetDefaultInitFields(Type typeObject, StringCollection fields, DatabaseEngineEdition databaseEngineEdition) { // validate input parameters @@ -2800,7 +2790,7 @@ public void SetDefaultInitFields(Type typeObject, StringCollection fields, Datab throw new FailedOperationException(ExceptionTemplates.CannotSetDefInitFlds(typeObject.Name)).SetHelpContext("CannotSetDefInitFlds"); } - var initFields = CreateInitFieldsColl(typeObject).ToList(); + var initFields = CreateInitFieldsColl(typeObject, databaseEngineEdition).ToList(); initFields.AddRange(fields.Cast().Where(f => !initFields.Contains(f))); TypeInitFields[typeObject] = initFields; } @@ -2952,11 +2942,11 @@ internal bool IsInitField(Type typeObject, string fieldName) internal string[] GetDefaultInitFieldsInternal(Type typeObject, DatabaseEngineEdition databaseEngineEdition) { // Has the existing fields already been inited - var requiredFields = CreateInitFieldsColl(typeObject); + var requiredFields = CreateInitFieldsColl(typeObject, databaseEngineEdition); IList existingFields; if (!(TypeInitFields.TryGetValue(typeObject, out existingFields))) { - var fields = CreateInitFieldsColl(typeObject).ToList(); + var fields = CreateInitFieldsColl(typeObject, databaseEngineEdition).ToList(); // Should we init with all fields if (useAllFieldsForInit) { @@ -2982,7 +2972,7 @@ internal string[] GetDefaultInitFieldsInternal(Type typeObject, DatabaseEngineEd return existingFields.Where(f => requiredFields.Contains(f) || IsSupportedProperty(typeObject, f, databaseEngineEdition)).ToArray(); } - private IEnumerable CreateInitFieldsColl(Type typeObject) + private IEnumerable CreateInitFieldsColl(Type typeObject, DatabaseEngineEdition databaseEngineEdition) { // add fields that are mandatory // we will strip those fields when the user is requesting them @@ -3046,6 +3036,12 @@ private IEnumerable CreateInitFieldsColl(Type typeObject) if (DatabaseEngineEdition == DatabaseEngineEdition.SqlDatabase) { yield return "RealEngineEdition"; } + // Fetch collation properties because they are used frequently to compare collection members + if (IsSupportedProperty(typeof(Database), nameof(Database.CatalogCollation), databaseEngineEdition)) + { + yield return nameof(Database.CatalogCollation); + } + yield return nameof(Database.Collation); } else if (typeObject.IsSubclassOf(typeof(NamedSmoObject))) { @@ -3153,7 +3149,7 @@ internal string[] GetScriptInitFieldsInternal2(Type childType, Type parentType, { return mi.Invoke(null, new object[] { parentType, this.ServerVersion, this.DatabaseEngineType, databaseEngineEdition, this.DefaultTextMode && (!sp.OldOptions.EnforceScriptingPreferences) }) as string[]; } - Diagnostics.TraceHelper.Assert(null != mi, childType.Name + " is missing GetScriptFields method!"); + Debug.Assert(null != mi, childType.Name + " is missing GetScriptFields method!"); return new string[] { }; } diff --git a/src/Microsoft/SqlServer/Management/Smo/sqlexec.cs b/src/Microsoft/SqlServer/Management/Smo/sqlexec.cs index 851f3f58..0ebd38f5 100644 --- a/src/Microsoft/SqlServer/Management/Smo/sqlexec.cs +++ b/src/Microsoft/SqlServer/Management/Smo/sqlexec.cs @@ -6,6 +6,7 @@ using System.Collections.Specialized; using Microsoft.SqlServer.Management.Diagnostics; using Diagnostics = Microsoft.SqlServer.Management.Diagnostics; +using SmoEventSource = Microsoft.SqlServer.Management.Common.SmoEventSource; #pragma warning disable 1590,1591,1592,1573,1571,1570,1572,1587 namespace Microsoft.SqlServer.Management.Smo @@ -96,10 +97,7 @@ internal SqlConnection GetConnection(string connectionString) m_connection.ConnectionString = connectionString + ";pooling=false"; oldConnectionString = connectionString; -#if DEBUG - Diagnostics.TraceHelper.Trace(SmoApplication.ModuleName, SmoApplication.trAlways, - "Getting a new connection with connection string =\"" + m_connection.ConnectionString + "\""); -#endif + SmoEventSource.Log.ExecutionMessage("Getting a new connection with connection string =\"" + m_connection.ConnectionString + "\""); } // open the connection if necessary @@ -112,10 +110,7 @@ internal SqlConnection GetConnection(string connectionString) { m_connection = new SqlConnection(connectionString); m_connection.Open(); -#if DEBUG - Diagnostics.TraceHelper.Trace(SmoApplication.ModuleName, SmoApplication.trAlways, - "Getting a new connection with connection string =\"" + m_connection.ConnectionString + "\""); -#endif + SmoEventSource.Log.ExecutionMessage("Getting a new connection with connection string =\"" + m_connection.ConnectionString + "\""); } return m_connection; diff --git a/src/Microsoft/SqlServer/Management/Smo/storedprocedurebase.cs b/src/Microsoft/SqlServer/Management/Smo/storedprocedurebase.cs index b93113d1..ea91b0e7 100644 --- a/src/Microsoft/SqlServer/Management/Smo/storedprocedurebase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/storedprocedurebase.cs @@ -274,7 +274,7 @@ void ScriptSPHeaderInternal(StringBuilder sb, ScriptingPreferences sp, ScriptHea } } - if (ServerVersion.Major >= 9 && sp.TargetServerVersion >= SqlServerVersion.Version90) + if (sp.TargetServerVersion >= SqlServerVersion.Version90) { AddScriptExecuteAs(sb, sp, this.Properties, ref bNeedsComma); } @@ -350,12 +350,8 @@ bool IsTransactSql(ScriptingPreferences sp) object obj = this.GetPropValueOptional("ImplementationType"); if (this.DatabaseEngineType != Cmn.DatabaseEngineType.SqlAzureDatabase && obj != null && (ImplementationType)obj == ImplementationType.SqlClr) { - // CLR procedures are not supported on versions prior to 9.0 - // so throw an error saying we can't create it there - if (ServerVersion.Major < 9) - { - throw new WrongPropertyValueException(ExceptionTemplates.ClrNotSupported("ImplementationType", ServerVersion.ToString())); - } + // CLR procedures were introduced in SQL Server 2005 (version 9.0). + // Since minimum supported version is now SQL Server 2008 (version 10), this is always supported. // this check ensures we can't script a CLR Stored Proc that targets Cloud Engine ThrowIfCloud(sp.TargetDatabaseEngineType, ExceptionTemplates.ClrStoredProcedureDownlevel( @@ -806,44 +802,7 @@ public bool TextMode /// internal override void ValidateProperty(Property prop, object value) { - switch (this.ServerVersion.Major) - { - case 7: - switch (prop.Name) - { - case "Recompile": - Validate_set_TextObjectDDLProperty(prop, value); - break; - case "ForReplication": goto case "Recompile"; - case "IsEncrypted": goto case "Recompile"; - - default: - // other properties are not validated - break; - } - break; - case 8: goto case 7; - case 9: - switch (prop.Name) - { - case "Recompile": - Validate_set_TextObjectDDLProperty(prop, value); - break; - case "ForReplication": goto case "Recompile"; - case "IsEncrypted": goto case "Recompile"; - case "ExecutionContext": goto case "Recompile"; - case "ExecutionContextPrincipal": goto case "Recompile"; - case "AssemblyName": goto case "Recompile"; - case "ClassName": goto case "Recompile"; - case "MethodName": goto case "Recompile"; - - default: - // other properties are not validated - break; - } - break; - default: goto case 9; - } + // No version-specific validation needed for SQL Server 2008+ } // after object creation we do not support text mode = true diff --git a/src/Microsoft/SqlServer/Management/Smo/tablebase.cs b/src/Microsoft/SqlServer/Management/Smo/tablebase.cs index 9e8b6d87..7741896a 100644 --- a/src/Microsoft/SqlServer/Management/Smo/tablebase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/tablebase.cs @@ -11,6 +11,7 @@ using System.IO; using System.Linq; using System.Text; +using System.Diagnostics; using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.Sdk.Sfc; using Microsoft.SqlServer.Management.Sdk.Sfc.Metadata; @@ -858,7 +859,7 @@ where idx.IsClustered if (sp.IncludeScripts.AnsiPadding && HasMultiplePaddings()) { // at this point the table-level ansi_padding should have a valid value - Diagnostics.TraceHelper.Assert(tablePaddingSetting.HasValue); + Debug.Assert(tablePaddingSetting.HasValue); GetTableCreationScriptWithAnsiPadding(sp, sb, tablePaddingSetting.Value); } else @@ -922,7 +923,6 @@ where idx.IsClustered // page and row count on the heap index that represents the storage // for that table. if (sp.Data.OptimizerData && - this.ServerVersion.Major >= 9 && sp.TargetServerVersion >= SqlServerVersion.Version90 && !isMemoryOptimized && !isSqlDw && @@ -972,8 +972,8 @@ where idx.IsClustered /// The string builder to hold scripts private void GetMemoryOptimizedTableCreationScript(ScriptingPreferences sp, StringBuilder sb) { - Diagnostics.TraceHelper.Assert(null != sp); - Diagnostics.TraceHelper.Assert(null != sb); + Debug.Assert(null != sp); + Debug.Assert(null != sb); // first make sure both current object and target scripting environment // support memory optimized table @@ -1045,8 +1045,8 @@ private void GetExternalTableCreationScript(ScriptingPreferences sp, StringBuild const string DataSourceNamePropertyName = "DataSourceName"; - Diagnostics.TraceHelper.Assert(null != sp); - Diagnostics.TraceHelper.Assert(null != sb); + Debug.Assert(null != sp); + Debug.Assert(null != sb); // first make sure both current object and target scripting environment // support external table @@ -1101,8 +1101,8 @@ private void GetSqlDwTableCreationScript(ScriptingPreferences sp, StringBuilder * FOR VALUES ( [ boundary_value [,...n] ] ) */ - Diagnostics.TraceHelper.Assert(null != sp); - Diagnostics.TraceHelper.Assert(null != sb); + Debug.Assert(null != sp); + Debug.Assert(null != sb); // first make sure both current object and target scripting environment // support SQL DW table @@ -1218,8 +1218,7 @@ internal void ScriptBindings(StringCollection scqueries, ScriptingPreferences sp /// private bool IsCompressionCodeRequired(bool bAlter) { - Diagnostics.TraceHelper.Assert(this.ServerVersion.Major >= 10); - Diagnostics.TraceHelper.Assert((this.State == SqlSmoState.Existing) || (this.State == SqlSmoState.Creating)); + Debug.Assert((this.State == SqlSmoState.Existing) || (this.State == SqlSmoState.Creating)); if (this.State == SqlSmoState.Creating) { if (m_PhysicalPartitions != null) @@ -1252,8 +1251,8 @@ private bool IsXmlCompressionCodeRequired(bool bAlter) return false; } - Diagnostics.TraceHelper.Assert(this.IsSupportedProperty(nameof(HasXmlCompressedPartitions))); - Diagnostics.TraceHelper.Assert((this.State == SqlSmoState.Existing) || (this.State == SqlSmoState.Creating)); + Debug.Assert(this.IsSupportedProperty(nameof(HasXmlCompressedPartitions))); + Debug.Assert((this.State == SqlSmoState.Existing) || (this.State == SqlSmoState.Creating)); if (this.State == SqlSmoState.Creating) { if (m_PhysicalPartitions != null) @@ -1284,8 +1283,8 @@ private bool IsXmlCompressionCodeRequired(bool bAlter) /// private void GetTableCreationScript(ScriptingPreferences sp, StringBuilder sb) { - Diagnostics.TraceHelper.Assert(null != sp); - Diagnostics.TraceHelper.Assert(null != sb); + Debug.Assert(null != sp); + Debug.Assert(null != sb); bool isEdgeTable = GetPropValueIfSupportedWithThrowOnTarget("IsEdge", false, sp); @@ -1351,7 +1350,7 @@ private void GetTableCreationScript(ScriptingPreferences sp, StringBuilder sb) /// private void ScriptPeriodForSystemTime(StringBuilder sb) { - Diagnostics.TraceHelper.Assert(IsSupportedProperty("HasSystemTimePeriod")); + Debug.Assert(IsSupportedProperty("HasSystemTimePeriod")); string startCol = string.Empty; string endCol = string.Empty; @@ -1393,8 +1392,8 @@ private void ScriptPeriodForSystemTime(StringBuilder sb) /// private void GetFileTableCreationScript(ScriptingPreferences sp, StringBuilder sb) { - Diagnostics.TraceHelper.Assert(null != sp); - Diagnostics.TraceHelper.Assert(null != sb); + Debug.Assert(null != sp); + Debug.Assert(null != sb); //Code that follows from here is not supported on Cloud. GenerateDataSpaceScript(sb, sp); @@ -1486,8 +1485,8 @@ private bool HasClusteredPrimaryOrUniqueKey(ScriptingPreferences sp) /// use initial padding private void GetTableCreationScriptWithAnsiPadding(ScriptingPreferences sp, StringBuilder sb, bool initialPadding) { - Diagnostics.TraceHelper.Assert(null != sp); - Diagnostics.TraceHelper.Assert(null != sb); + Debug.Assert(null != sp); + Debug.Assert(null != sb); StringCollection col_strings = new StringCollection(); bool fFirstColumn = true; @@ -1511,7 +1510,7 @@ private void GetTableCreationScriptWithAnsiPadding(ScriptingPreferences sp, Stri while (enumColls.MoveNext()) { Column column = enumColls.Current as Column; - Diagnostics.TraceHelper.Assert(null != column); + Debug.Assert(null != column); // prepare to script column only if in direct execution mode or not explicitly directed to ignore it if (sp.ScriptForCreateDrop || !column.IgnoreForScripting) @@ -1539,7 +1538,7 @@ private void GetTableCreationScriptWithAnsiPadding(ScriptingPreferences sp, Stri } sb.Append(Globals.tab); // there needs to be just one string in this collection - Diagnostics.TraceHelper.Assert(col_strings.Count == 1); + Debug.Assert(col_strings.Count == 1); sb.Append(col_strings[0]); col_strings.Clear(); @@ -1562,7 +1561,7 @@ private void GetTableCreationScriptWithAnsiPadding(ScriptingPreferences sp, Stri GenerateGraphScript(sb, sp); // we should exit the loop before we finish the collection - Diagnostics.TraceHelper.Assert(paddingHasFlipped); + Debug.Assert(paddingHasFlipped); // generate script for the location of the table GenerateDataSpaceScript(sb, sp); @@ -1598,7 +1597,7 @@ private void GetTableCreationScriptWithAnsiPadding(ScriptingPreferences sp, Stri do { Column col = enumColls.Current as Column; - Diagnostics.TraceHelper.Assert(null != col); + Debug.Assert(null != col); Nullable thisPadding = GetColumnPadding(col); // check if we need to change the ANSI_PADDING @@ -1634,8 +1633,8 @@ private void GetTableCreationScriptWithAnsiPadding(ScriptingPreferences sp, Stri /// private void GenerateWithOptionScript(StringBuilder sb, ScriptingPreferences sp) { - Diagnostics.TraceHelper.Assert(null != sp); - Diagnostics.TraceHelper.Assert(null != sb); + Debug.Assert(null != sp); + Debug.Assert(null != sb); StringBuilder withOptions = new StringBuilder(); @@ -1646,7 +1645,6 @@ private void GenerateWithOptionScript(StringBuilder sb, ScriptingPreferences sp) // bool fDataCompression = ((sp.TargetDatabaseEngineEdition != Cmn.DatabaseEngineEdition.SqlDataWarehouse) && (sp.TargetServerVersion >= SqlServerVersion.Version100) - && (this.ServerVersion.Major >= 10) && !sp.TargetEngineIsAzureStretchDb() && sp.Storage.DataCompression && (!this.HasClusteredPrimaryOrUniqueKey(sp)) @@ -2193,7 +2191,7 @@ private void ProcessExternalTableOptionalProperties(StringBuilder script, Script { case ExternalTableDistributionType.Sharded: Property shardingColNameProperty = this.GetPropertyOptional(ShardingColumnPropertyName); - Diagnostics.TraceHelper.Assert(!shardingColNameProperty.IsNull); + Debug.Assert(!shardingColNameProperty.IsNull); string distributionWithShardingColName = string.Format("{0}({1})", typeConverter.ConvertToInvariantString(distribution), MakeSqlBraket(Convert.ToString(shardingColNameProperty.Value, SmoApplication.DefaultCulture))); @@ -2204,7 +2202,7 @@ private void ProcessExternalTableOptionalProperties(StringBuilder script, Script this.AddPropertyToScript(typeConverter.ConvertToInvariantString(distribution), "DISTRIBUTION = {0}", script); break; default: - Diagnostics.TraceHelper.Assert(distribution == ExternalTableDistributionType.None); + Debug.Assert(distribution == ExternalTableDistributionType.None); break; } } @@ -2302,7 +2300,7 @@ private void ProcessSqlDwTableProperties(StringBuilder script, ScriptingPreferen this.AddPropertyToScript(typeConverter.ConvertToInvariantString(distribution), "DISTRIBUTION = {0}", script); break; default: - Diagnostics.TraceHelper.Assert(distribution == DwTableDistributionType.None); + Debug.Assert(distribution == DwTableDistributionType.None); break; } } @@ -2623,7 +2621,6 @@ private Nullable GetColumnPadding(Column c) return c.GetPropValueOptional("AnsiPaddingStatus"); } else if (c.GetPropValueOptional("Computed", false) && - this.ServerVersion.Major >= 9 && c.GetPropValueOptional("IsPersisted", false)) { // persisted columns always need ansi_padding set to true @@ -2744,9 +2741,9 @@ internal bool IsPaddingType(Column col) internal static void ScriptTableInternal(ScriptingPreferences sp, StringBuilder sb, IEnumerable columns, ICollection indexes, bool isEdgeTable = false) { - Diagnostics.TraceHelper.Assert(null != sp); - Diagnostics.TraceHelper.Assert(null != sb); - Diagnostics.TraceHelper.Assert(null != columns); + Debug.Assert(null != sp); + Debug.Assert(null != sb); + Debug.Assert(null != columns); ScriptColumns(sp, sb, columns, isEdgeTable: isEdgeTable); @@ -2855,7 +2852,7 @@ private static void GenerateMemoryOptimizedIndexes(StringBuilder sb, ScriptingPr // script all non-primary indexes foreach (Index idx in indexes) { - Diagnostics.TraceHelper.Assert(idx.IsMemoryOptimizedIndex); + Debug.Assert(idx.IsMemoryOptimizedIndex); if (firstIndex) { @@ -2870,7 +2867,7 @@ private static void GenerateMemoryOptimizedIndexes(StringBuilder sb, ScriptingPr if (sp.ScriptForCreateDrop || !idx.IgnoreForScripting) { idx.ScriptDdl(col_strings, sp, true, true); - Diagnostics.TraceHelper.Assert(col_strings.Count != 0); + Debug.Assert(col_strings.Count != 0); sb.Append(sp.NewLine); sb.Append(col_strings[0]); @@ -2900,7 +2897,7 @@ private static void ScriptSqlDwClusteredIndexes(StringBuilder sb, ScriptingPrefe // script all clustered indexes foreach (Index idx in indexes) { - Diagnostics.TraceHelper.Assert(idx.IndexType == IndexType.ClusteredIndex); + Debug.Assert(idx.IndexType == IndexType.ClusteredIndex); if (firstIndex) { @@ -2915,7 +2912,7 @@ private static void ScriptSqlDwClusteredIndexes(StringBuilder sb, ScriptingPrefe if (sp.ScriptForCreateDrop || !idx.IgnoreForScripting) { idx.ScriptDdl(scripts, sp, true, true); - Diagnostics.TraceHelper.Assert(scripts.Count == 1); + Debug.Assert(scripts.Count == 1); sb.Append(sp.NewLine); sb.Append(scripts[0]); scripts.Clear(); @@ -2983,7 +2980,7 @@ private static void GeneratePkUkInCreateTable(StringBuilder sb, ScriptingPrefere // as the second parameter has been abused to generate partial DDL // to inject into the CREATE TABLE idx.ScriptDdl(col_strings, sp, !embedded, true); - Diagnostics.TraceHelper.Assert(col_strings.Count != 0); + Debug.Assert(col_strings.Count != 0); if (embedded) { @@ -3025,7 +3022,7 @@ private static void GeneratePkUkInCreateTable(StringBuilder sb, ScriptingPrefere // as the second parameter has been abused to generate partial DDL // to inject into the CREATE TABLE idx.ScriptDdl(col_strings, sp, !embedded, true); - Diagnostics.TraceHelper.Assert(col_strings.Count != 0); + Debug.Assert(col_strings.Count != 0); if (embedded) { @@ -3832,10 +3829,7 @@ public void EnableAllIndexes(IndexEnableAction action) if (action == IndexEnableAction.Rebuild) { StringBuilder rebuildOptions = new StringBuilder(Globals.INIT_BUFFER_SIZE); - if (this.ServerVersion.Major >= 10) - { - ScriptRebuildOptions(rebuildOptions, new ScriptingPreferences(this)); - } + ScriptRebuildOptions(rebuildOptions, new ScriptingPreferences(this)); if (rebuildOptions.Length > 0) { queries.Add(string.Format(SmoApplication.DefaultCulture, "ALTER INDEX ALL ON {0} REBUILD WITH ({1})", @@ -3965,7 +3959,7 @@ private PropagateInfo[] GetPropagateInfoImpl(PropagateAction action, bool forDis bool bWithScript = action != PropagateAction.Create; ArrayList propInfo = new ArrayList(); - propInfo.Add(new PropagateInfo(ServerVersion.Major < 10 ? null : m_PhysicalPartitions, false, false)); + propInfo.Add(new PropagateInfo(m_PhysicalPartitions, false, false)); propInfo.Add(new PropagateInfo(Columns, bWithScript, true)); propInfo.Add(new PropagateInfo(Statistics, true, Statistic.UrnSuffix)); @@ -4300,7 +4294,7 @@ private void ValidateExternalTableOptionalProperties(ScriptingPreferences sp) { if (this.IsSupportedProperty(DistributionPropertyName)) { - Diagnostics.TraceHelper.Assert(this.IsSupportedProperty(ShardingColumnPropertyName)); + Debug.Assert(this.IsSupportedProperty(ShardingColumnPropertyName)); Property distributionProperty = this.GetPropertyOptional(DistributionPropertyName); Property shardingColProperty = this.GetPropertyOptional(ShardingColumnPropertyName); @@ -4345,7 +4339,7 @@ private void ValidateExternalTableOptionalProperties(ScriptingPreferences sp) // Either both remote schema and remote object proerties be used, or none. if (this.IsSupportedProperty(RemoteSchemaPropertyName)) { - Diagnostics.TraceHelper.Assert(this.IsSupportedProperty(RemoteObjectPropertyName)); + Debug.Assert(this.IsSupportedProperty(RemoteObjectPropertyName)); Property remoteSchemaProperty = this.GetPropertyOptional(RemoteSchemaPropertyName); Property remoteObjectProperty = this.GetPropertyOptional(RemoteObjectPropertyName); @@ -4511,8 +4505,7 @@ internal static string[] GetScriptFields2(Type parentType, Cmn.ServerVersion ver { return new string[] { nameof(HasCompressedPartitions), nameof(HasXmlCompressedPartitions) }; } - else if ((version.Major > 9) - && (sp.TargetServerVersion > SqlServerVersion.Version90) + else if ((sp.TargetServerVersion > SqlServerVersion.Version90) && (sp.Storage.DataCompression)) { return new string[] { nameof(HasCompressedPartitions) }; diff --git a/src/Microsoft/SqlServer/Management/Smo/uddtbase.cs b/src/Microsoft/SqlServer/Management/Smo/uddtbase.cs index 210bcd80..9744e258 100644 --- a/src/Microsoft/SqlServer/Management/Smo/uddtbase.cs +++ b/src/Microsoft/SqlServer/Management/Smo/uddtbase.cs @@ -378,8 +378,7 @@ static private string GetTypeDefinitionScript(ScriptingPreferences sp, SqlSmoObj // throw an exception if the target server is less than 9.0 SqlSmoObject.ThrowIfBelowVersion90(sp.TargetServerVersion); - if (true == sp.DataType.XmlNamespaces && sp.TargetServerVersion >= SqlServerVersion.Version90 && - oObj.ServerVersion.Major >= 9) + if (true == sp.DataType.XmlNamespaces && sp.TargetServerVersion >= SqlServerVersion.Version90) { // set the xml collection name if supplied string xmlNamespaceName = oObj.Properties.Get("XmlSchemaNamespace").Value as string; @@ -573,7 +572,6 @@ static internal void AppendScriptTypeDefinition(StringBuilder sb, ScriptingPrefe // script only the name of the type if we don't have the schema // or we're on 8.0 if (SqlServerVersion.Version80 == sp.TargetServerVersion || - oObj.ServerVersion.Major < 9 || null == sTypeSchema) { sb.AppendFormat("[{0}]", SqlBraket(sType)); diff --git a/src/Microsoft/SqlServer/Management/SqlAssessment/Microsoft.SqlServer.Management.Assessment.csproj b/src/Microsoft/SqlServer/Management/SqlAssessment/Microsoft.SqlServer.Management.Assessment.csproj index f9126e45..6b6e995b 100644 --- a/src/Microsoft/SqlServer/Management/SqlAssessment/Microsoft.SqlServer.Management.Assessment.csproj +++ b/src/Microsoft/SqlServer/Management/SqlAssessment/Microsoft.SqlServer.Management.Assessment.csproj @@ -15,7 +15,6 @@ - diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/DatabaseLevel.CS b/src/Microsoft/SqlServer/Management/SqlEnum/DatabaseLevel.CS index 7d8cf59c..f3b78a18 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/DatabaseLevel.CS +++ b/src/Microsoft/SqlServer/Management/SqlEnum/DatabaseLevel.CS @@ -6,6 +6,7 @@ namespace Microsoft.SqlServer.Management.Smo using System; using System.Collections.Specialized; using System.Data; + using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Runtime.InteropServices; @@ -169,7 +170,7 @@ namespace Microsoft.SqlServer.Management.Smo internal DataTable GetRequestedDatabases(SqlEnumResult serParent) { - TraceHelper.Assert( true == m_bForChildren, "should only be called when this is an intermediate level"); + Debug.Assert( true == m_bForChildren, "should only be called when this is an intermediate level"); // if database name is available in the filter use it directly string database = this.GetFixedStringProperty(this.NameProperty, removeEscape:true); @@ -249,7 +250,7 @@ namespace Microsoft.SqlServer.Management.Smo /// private bool IsDatabaseNameOrDerivate(string fieldName) { - TraceHelper.Assert( true == m_bForChildren, "should only be called when this is an intermediate level"); + Debug.Assert( true == m_bForChildren, "should only be called when this is an intermediate level"); //check if it is the database name if( fieldName == this.NameProperty ) @@ -287,7 +288,7 @@ namespace Microsoft.SqlServer.Management.Smo /// private void CleanupFilter() { - TraceHelper.Assert( true == m_bForChildren, "should only be called when this is an intermediate level"); + Debug.Assert( true == m_bForChildren, "should only be called when this is an intermediate level"); if( ( null == this.SqlRequest.Fields || 0 == this.SqlRequest.Fields.Length || 2 > this.SqlRequest.Fields.Length ) && ( null == this.SqlRequest.LinkFields || 0 == this.SqlRequest.LinkFields.Count || 2 > this.SqlRequest.LinkFields.Count ) ) diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/DdlParser.cs b/src/Microsoft/SqlServer/Management/SqlEnum/DdlParser.cs index 7e868397..b9183655 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/DdlParser.cs +++ b/src/Microsoft/SqlServer/Management/SqlEnum/DdlParser.cs @@ -4,6 +4,7 @@ namespace Microsoft.SqlServer.Management.Smo { using System; + using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; using System.Text.RegularExpressions; @@ -277,7 +278,7 @@ private static bool ReadFullNameFromDdl(ref Match m, bool useQuotedIdentifier, r } //check some basic rules - TraceHelper.Assert(headerInfo.name.Length > 0 && headerInfo.indexNameStart > 0 && + Debug.Assert(headerInfo.name.Length > 0 && headerInfo.indexNameStart > 0 && headerInfo.indexNameEnd > headerInfo.indexNameStart); return true; } @@ -426,7 +427,7 @@ public static bool CheckDdlHeader(string objectText, bool useQuotedIdentifier, b if( !retVal || 0 != String.Compare("TRIGGER", headerInfo.objectType, StringComparison.OrdinalIgnoreCase) ) { - TraceHelper.Assert(headerInfo.objectType.Length > 0 && headerInfo.name.Length > 0 && + Debug.Assert(headerInfo.objectType.Length > 0 && headerInfo.name.Length > 0 && headerInfo.indexCreate >= 0 && headerInfo.indexNameStart > 0 && headerInfo.indexNameEnd > headerInfo.indexNameStart && headerInfo.indexNameStartSecondary == -1); @@ -468,7 +469,7 @@ public static bool CheckDdlHeader(string objectText, bool useQuotedIdentifier, b headerInfo.nameSecondary= headerInfoTmp.name; headerInfo.databaseSecondary = headerInfoTmp.database; - TraceHelper.Assert(headerInfo.objectType.Length > 0 && headerInfo.name.Length > 0 && + Debug.Assert(headerInfo.objectType.Length > 0 && headerInfo.name.Length > 0 && headerInfo.indexCreate >= 0 && headerInfo.indexNameStart > 0 && headerInfo.indexNameEnd > headerInfo.indexNameStart && headerInfo.nameSecondary.Length > 0 && headerInfo.indexNameStartSecondary > 0 && diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/Microsoft.SqlServer.SqlEnum.csproj b/src/Microsoft/SqlServer/Management/SqlEnum/Microsoft.SqlServer.SqlEnum.csproj index 562479d7..96d0cfac 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/Microsoft.SqlServer.SqlEnum.csproj +++ b/src/Microsoft/SqlServer/Management/SqlEnum/Microsoft.SqlServer.SqlEnum.csproj @@ -442,6 +442,10 @@ ExternalLibraryFile.xml xml\ExternalLibraryFile.xml + + ExternalModel.xml + xml\ExternalModel.xml + ExternalResourcePool.xml xml\ExternalResourcePool.xml @@ -1279,4 +1283,9 @@ + + + + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/PostProcessCreateDateTime.cs b/src/Microsoft/SqlServer/Management/SqlEnum/PostProcessCreateDateTime.cs index f3918615..790d5ccb 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/PostProcessCreateDateTime.cs +++ b/src/Microsoft/SqlServer/Management/SqlEnum/PostProcessCreateDateTime.cs @@ -147,18 +147,6 @@ private int GetSmoCodeFromSqlCodeYukon(string sqlCode, ObjectClass objClass) return smoCode; } - private int GetSmoCodeFromSqlCodeShiloh(string sqlCode) - { - int smoCode; - sqlCode = sqlCode.TrimEnd(); - - if (!GetSmoCodeFromSqlCode(sqlCode, out smoCode)) - { - smoCode = (int)PermissionDecode.ToPermissionSetValueEnum(sqlCode); - } - - return smoCode; - } /// /// Gets server or database permission code @@ -188,35 +176,9 @@ private bool GetSmoCodeFromSqlCode(string sqlCode, out int smoCode) return result; } - string ShilohToYukonPermission(int permType) - { - switch (permType) - { - case 26: return "RF"; //References - case 178: return "CRFN"; //Create Function - case 193: return "SL"; //Select - case 195: return "IN"; //Insert - case 196: return "DL"; //Delete - case 197: return "UP"; //Update - case 198: return "CRTB"; //Create Table - case 203: return "CRDB"; //Create Database - case 207: return "CRVW"; //Create View - case 222: return "CRPR"; //Create Procedure - case 224: return "EX"; //Execute - case 228: return "BADB"; //Backup Database - case 233: return "CRDF"; //Create Default - case 235: return "BALO"; //Backup Transaction ( LOG ) - case 236: return "CRRU"; //Create Rule - } - return ""; - } public override object GetColumnData(string name, object data, DataProvider dp) { - if (ExecuteSql.GetServerVersion(this.ConnectionInfo).Major < 9) - { - return GetSmoCodeFromSqlCodeShiloh(ShilohToYukonPermission(GetTriggeredInt32(dp, 0))); - } return GetSmoCodeFromSqlCodeYukon(GetTriggeredString(dp, 0), (ObjectClass)GetTriggeredInt32(dp, 1)); } } diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/PostProcessDatabaseInsideAttribs.cs b/src/Microsoft/SqlServer/Management/SqlEnum/PostProcessDatabaseInsideAttribs.cs index 6b7cb5c5..7211bd62 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/PostProcessDatabaseInsideAttribs.cs +++ b/src/Microsoft/SqlServer/Management/SqlEnum/PostProcessDatabaseInsideAttribs.cs @@ -56,9 +56,7 @@ protected override string SqlQuery { if ( null == sqlQuery ) { - sqlQuery = ExecuteSql.GetServerVersion(this.ConnectionInfo).Major < 9 ? - BuildSqlStatementLess90() : - BuildSqlStatementMoreEqual90(); + sqlQuery = BuildSqlStatementMoreEqual90(); sqlQuery = String.Format(CultureInfo.InvariantCulture, sqlQuery, Util.EscapeString(this.databaseName, '\'')); } return sqlQuery; @@ -289,63 +287,13 @@ private string BuildSqlStatementMoreEqual90() return sb.SqlStatement; } - private string BuildSqlStatementLess90() - { - var sb = new StatementBuilder(); - - BuildCommonSql(sb); - - if ( GetIsFieldHit("SpaceAvailable") || GetIsFieldHit("Size") ) - { - sb.AddProperty("DbSize", "(select sum(convert(float,size)) from dbo.sysfiles where (status & 64 = 0))"); - } - if ( GetIsFieldHit("SpaceAvailable") ) - { - sb.AddProperty("SpaceUsed", "(select sum(convert(float,reserved)) from dbo.sysindexes where indid in (0, 1, 255))"); - } - if ( GetIsFieldHit("Size") ) - { - sb.AddProperty("LogSize", "(select sum(convert(float,size)) from dbo.sysfiles where (status & 64 <> 0))"); - } - if ( GetIsFieldHit("DataSpaceUsage") || GetIsFieldHit("IndexSpaceUsage") ) - { - sb.AddProperty("DataSpaceUsage", "((select sum(convert(float,dpages)) from dbo.sysindexes where indid < 2) + (select isnull(sum(convert(float,used)), 0) from dbo.sysindexes where indid = 255))"); - } - if ( GetIsFieldHit("IndexSpaceUsage") ) - { - sb.AddProperty("IndexSpaceTotal", "(select sum(convert(float,used)) from dbo.sysindexes where indid in (0, 1, 255))"); - } - if ( GetIsFieldHit("DefaultSchema") ) - { - sb.AddProperty("DefaultSchema", "user_name()"); - } - if (GetIsFieldHit("DefaultFileGroup")) - { - sb.AddProperty("DefaultFileGroup", "(select top 1 fg.groupname from dbo.sysfilegroups as fg where fg.status & 0x10 <> 0)"); - } - ServerVersion sv = ExecuteSql.GetServerVersion(this.ConnectionInfo); - if ( sv.Major >= 8 && sv.BuildNumber >= 760 ) //db chaining implmented starting with build 760 - { - AddDbChaining(sb); - } - - return sb.SqlStatement; - } private void AddDbChaining(StatementBuilder sb) { if ( GetIsFieldHit("DatabaseOwnershipChaining")) { sb.AddPrefix("create table #tmpdbchaining( name sysname , dbc sysname )"); - ServerVersion sv = ExecuteSql.GetServerVersion(this.ConnectionInfo); - if (sv.Major < 9) - { - sb.AddPrefix("insert into #tmpdbchaining exec dbo.sp_dboption N'{0}', 'db chaining'\n"); - } - else - { - sb.AddPrefix("insert into #tmpdbchaining SELECT 'db chaining' AS 'OptionName', CASE WHEN (SELECT is_db_chaining_on FROM sys.databases WHERE name=N'{0}') = 1 THEN 'ON' ELSE 'OFF' END AS 'CurrentSetting'\n"); - } + sb.AddPrefix("insert into #tmpdbchaining SELECT 'db chaining' AS 'OptionName', CASE WHEN (SELECT is_db_chaining_on FROM sys.databases WHERE name=N'{0}') = 1 THEN 'ON' ELSE 'OFF' END AS 'CurrentSetting'\n"); sb.AddPrefix("declare @DBChaining bit\nset @DBChaining = null\nselect @DBChaining = case LOWER(dbc) when 'off' then 0 else 1 end from #tmpdbchaining"); sb.AddProperty("DatabaseOwnershipChaining", "@DBChaining"); sb.AddPostfix("drop table #tmpdbchaining"); @@ -373,14 +321,7 @@ public override object GetColumnData(string name, object data, DataProvider dp) { logSpaceAvailable = (double)data; } - if (sv.Major < 9) - { - data = ((double)this.rowResults[0]["DbSize"] - (double)this.rowResults[0]["SpaceUsed"]) * this.BytesPerPage + logSpaceAvailable; - } - else - { - data = ((double)this.rowResults[0]["DbSize"] - (Int64)this.rowResults[0]["SpaceUsed"]) * this.BytesPerPage + logSpaceAvailable; - } + data = ((double)this.rowResults[0]["DbSize"] - (Int64)this.rowResults[0]["SpaceUsed"]) * this.BytesPerPage + logSpaceAvailable; if ((double)data < 0) { data = (double)0; @@ -404,14 +345,7 @@ public override object GetColumnData(string name, object data, DataProvider dp) break; //when modify check table.xml DataSpaceUsed for consistency case "DataSpaceUsage": - if (sv.Major < 9) - { - data = ((double)this.rowResults[0]["DataSpaceUsage"]) * this.BytesPerPage; - } - else - { - data = ((Int64)this.rowResults[0]["DataSpaceUsage"]) * this.BytesPerPage; - } + data = ((Int64)this.rowResults[0]["DataSpaceUsage"]) * this.BytesPerPage; break; // Property indicates whether database has Hekaton objects or not by checking for existence of memory optimized filegroup @@ -452,14 +386,7 @@ public override object GetColumnData(string name, object data, DataProvider dp) break; //when modify check table.xml IndexSpaceUsed and index.xml IndexSpaceUsed for consistency case "IndexSpaceUsage": - if (sv.Major < 9) - { - data = ((double)this.rowResults[0]["IndexSpaceTotal"] - (double)this.rowResults[0]["DataSpaceUsage"]) * this.BytesPerPage; - } - else - { - data = ((Int64)this.rowResults[0]["IndexSpaceTotal"] - (Int64)this.rowResults[0]["DataSpaceUsage"]) * this.BytesPerPage; - } + data = ((Int64)this.rowResults[0]["IndexSpaceTotal"] - (Int64)this.rowResults[0]["DataSpaceUsage"]) * this.BytesPerPage; break; case "UserName": case "IsMailHost": @@ -486,52 +413,30 @@ public override object GetColumnData(string name, object data, DataProvider dp) data = this.rowResults[0][name]; break; case "DefaultFileStreamFileGroup": - if (sv.Major >= 10) - { - data = this.rowResults[0]["DefaultFileStreamFileGroup"]; - } + data = this.rowResults[0]["DefaultFileStreamFileGroup"]; break; case "DatabaseOwnershipChaining": - if (sv.Major >= 8 && sv.BuildNumber >= 760) //db chaining implmented starting with build 760 - { - data = this.rowResults[0]["DatabaseOwnershipChaining"]; - } + // db chaining implemented starting with build 760 of SQL Server 2000 (version 8) + // Since minimum supported version is now SQL Server 2008 (version 10), this check is always true + data = this.rowResults[0]["DatabaseOwnershipChaining"]; break; case "IsManagementDataWarehouse": // Data Collector is a Katmai feature - if (sv.Major >= 10) - { - data = this.rowResults[0]["IsManagementDataWarehouse"]; - } + data = this.rowResults[0]["IsManagementDataWarehouse"]; break; case "PrimaryFilePath": - if (sv.Major < 9) + if (ExecuteSql.IsContainedAuthentication(this.ConnectionInfo)) { - if (IsNull(data)) - { - return data; - } - else - { - //cut the file name - data = GetPath((string)data); - } + data = this.rowResults[0]["PrimaryFilePath"]; + } + + if (IsNull(data)) + { + return String.Empty; } else { - if (ExecuteSql.IsContainedAuthentication(this.ConnectionInfo)) - { - data = this.rowResults[0]["PrimaryFilePath"]; - } - - if (IsNull(data)) - { - return String.Empty; - } - else - { - data = GetPath((string)data); - } + data = GetPath((string)data); } break; } @@ -582,13 +487,9 @@ protected override string SqlQuery { queryInDb = "SELECT dtb.collation_name AS [Collation], CAST(DATABASEPROPERTYEX(dtb.name, 'Version') AS int) AS [Version], dtb.compatibility_level AS [CompatibilityLevel], CAST(CHARINDEX(N'_CS_', dtb.collation_name) AS bit) AS [CaseSensitive], dtb.target_recovery_time_in_seconds AS [TargetRecoveryTime] FROM master.sys.databases AS dtb where name = db_name()"; } - else if (sv.Major >= 9) - { - queryInDb = "SELECT dtb.collation_name AS [Collation], CAST(DATABASEPROPERTYEX(dtb.name, 'Version') AS int) AS [Version], dtb.compatibility_level AS [CompatibilityLevel], CAST(CHARINDEX(N'_CS_', dtb.collation_name) AS bit) AS [CaseSensitive] FROM master.sys.databases AS dtb where name = db_name()"; - } else { - queryInDb = "SELECT CAST(DATABASEPROPERTYEX(dtb.name, 'Collation') AS sysname) AS [Collation], CAST(DATABASEPROPERTYEX(dtb.name, 'Version') AS int) AS [Version], dtb.cmptlevel AS [CompatibilityLevel], CAST(CHARINDEX(N'_CS_', CAST(DATABASEPROPERTYEX(dtb.name, 'Collation') AS nvarchar(255))) AS bit) AS [CaseSensitive] FROM master.dbo.sysdatabases AS dtb where name = db_name()"; + queryInDb = "SELECT dtb.collation_name AS [Collation], CAST(DATABASEPROPERTYEX(dtb.name, 'Version') AS int) AS [Version], dtb.compatibility_level AS [CompatibilityLevel], CAST(CHARINDEX(N'_CS_', dtb.collation_name) AS bit) AS [CaseSensitive] FROM master.sys.databases AS dtb where name = db_name()"; } return queryInDb; diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/PostProcessParam.cs b/src/Microsoft/SqlServer/Management/SqlEnum/PostProcessParam.cs index e33e68e4..a283f555 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/PostProcessParam.cs +++ b/src/Microsoft/SqlServer/Management/SqlEnum/PostProcessParam.cs @@ -150,25 +150,7 @@ private void ParseParams(String sKey, String text, bool bQI) String GetText(int id, String sDatabase, int number, Object ci, ref bool bQI) { - String query = null; - - ServerVersion sVersion = ExecuteSql.GetServerVersion(ci); - - if (sVersion.Major >= 9) //Yukon or later - { - query = String.Format(CultureInfo.InvariantCulture, "select c.definition,convert(bit,OBJECTPROPERTY(c.object_id,N'ExecIsQuotedIdentOn')) from [{0}].sys.sql_modules c where c.object_id = {1}", Util.EscapeString(sDatabase, ']'), id); - } - else //Shiloh or earlier - { - if (number > 0) - { - query = String.Format(CultureInfo.InvariantCulture, "select c.text,convert(bit,OBJECTPROPERTY(c.id,N'ExecIsQuotedIdentOn')) from [{0}].dbo.syscomments c where c.id = {1} and c.number = {2} order by c.colid", Util.EscapeString(sDatabase, ']'), id, number); - } - else - { - query = String.Format(CultureInfo.InvariantCulture, "select c.text,convert(bit,OBJECTPROPERTY(c.id,N'ExecIsQuotedIdentOn')) from [{0}].dbo.syscomments c where c.id = {1} order by c.colid", Util.EscapeString(sDatabase, ']'), id); - } - } + String query = String.Format(CultureInfo.InvariantCulture, "select c.definition,convert(bit,OBJECTPROPERTY(c.object_id,N'ExecIsQuotedIdentOn')) from [{0}].sys.sql_modules c where c.object_id = {1}", Util.EscapeString(sDatabase, ']'), id); DataTable dtText = ExecuteSql.ExecuteWithResults(query, ci); diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/PostProcessRemoteDataArchiveDatabaseProperties.cs b/src/Microsoft/SqlServer/Management/SqlEnum/PostProcessRemoteDataArchiveDatabaseProperties.cs deleted file mode 100644 index f9b9763b..00000000 --- a/src/Microsoft/SqlServer/Management/SqlEnum/PostProcessRemoteDataArchiveDatabaseProperties.cs +++ /dev/null @@ -1,155 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -using System; -using System.Globalization; -using Microsoft.SqlServer.Management.Common; -using Microsoft.SqlServer.Management.Sdk.Sfc; - -namespace Microsoft.SqlServer.Management.Smo -{ - /// - /// A class that post processes the RemoteDataArchive properties for a database. - /// - /// Post-Processing is necessary in this case because we need to run a query against the DB itself. - /// The query generated from the Database.xml file runs in the context of the master DB so will not work. - internal class PostProcessRemoteDataArchiveDatabaseProperties : PostProcessWithRowCaching - { - /// - /// Name of RemoteDataArchiveEndpoint property - /// - private const string remoteDataArchiveEndpoint = "RemoteDataArchiveEndpoint"; - - /// - /// Name of RemoteDataArchiveDatabaseName property - /// - private const string remoteDataArchiveDatabaseName = "RemoteDatabaseName"; - - /// - /// Name of RemoteDataArchiveLinkedServer property - /// - private const string remoteDataArchiveLinkedServer = "RemoteDataArchiveLinkedServer"; - - /// - /// Name of FederatedServiceAccount property - /// - private const string remoteDataArchiveFederatedServiceAccount = "RemoteDataArchiveUseFederatedServiceAccount"; - - /// - /// Name of RemoteDataArchiveCredential property - /// - private const string remoteDataArchiveCredential = "RemoteDataArchiveCredential"; - - /// - /// Build T-Sql queries to get values for PostProcess RemoteDataArchiveEndpoint, RemoteDataArchiveLinkedServer, RemoteDataArchiveDatabaseName - /// - /// - protected override string SqlQuery - { - get - { - var selectQuery = new StatementBuilder(); - - // add property to SELECT list - selectQuery.AddProperty(remoteDataArchiveEndpoint, @"eds.location"); - selectQuery.AddProperty(remoteDataArchiveLinkedServer, @"eds.name"); - selectQuery.AddProperty(remoteDataArchiveDatabaseName, @"rdad.remote_database_name"); - selectQuery.AddProperty(remoteDataArchiveFederatedServiceAccount, @"rdad.federated_service_account"); - selectQuery.AddProperty(remoteDataArchiveCredential, @"case when rdad.federated_service_account = 1 then null else cred.name end"); - selectQuery.AddFrom(@"sys.remote_data_archive_databases rdad"); - selectQuery.AddJoin(@"INNER JOIN sys.external_data_sources eds ON rdad.data_source_id = eds.data_source_id"); - selectQuery.AddJoin(@"LEFT OUTER JOIN sys.database_scoped_credentials cred ON eds.credential_id = cred.credential_id"); - return selectQuery.SqlStatement; - } - - } - - /// - /// Returns a boolean indicating if the current stretch queries - /// will work on metadata views on the target server. - /// - /// The check is based on a version check of the server. - /// The metaviews related to stretch were changed between ctp2.4 - /// and ctp3.0 - /// - /// The new queries added in ctp3.0 smo should not be allowed - /// to run on ctp2.4 or lower server. - /// - /// - /// - private bool IsStretchSmoSupportedOnVersion(Version sqlServerVersion) - { - // Smo can only query stretch related properties - // for server versions higher or equal than 13.0.700. - // This is because considerable changes have happened - // in the DMVs between versions prior to 13.0.700 and 13.0.700. - if (sqlServerVersion < new Version(13, 0, 700)) - { - return false; - } - - return true; - } - - /// - /// Returns the value of required property - /// - /// Name of a table property - /// data - /// data provider - /// Value of the property - public override object GetColumnData(string name, object data, DataProvider dp) - { - if(!string.IsNullOrEmpty(name)) - { - ServerVersion targetSqlServerVersion = ExecuteSql.GetServerVersion(this.ConnectionInfo); - bool isValidSqlServerVersion = this.IsStretchSmoSupportedOnVersion(new Version(targetSqlServerVersion.Major, targetSqlServerVersion.Minor, targetSqlServerVersion.BuildNumber)); - - if (isValidSqlServerVersion) - { - bool isRemoteDataArchivePropertyName = (name.Equals(remoteDataArchiveEndpoint, StringComparison.InvariantCultureIgnoreCase) || - name.Equals(remoteDataArchiveDatabaseName, StringComparison.InvariantCultureIgnoreCase) || - name.Equals(remoteDataArchiveLinkedServer, StringComparison.InvariantCultureIgnoreCase) || - name.Equals(remoteDataArchiveFederatedServiceAccount, StringComparison.InvariantCultureIgnoreCase) || - name.Equals(remoteDataArchiveCredential, StringComparison.InvariantCultureIgnoreCase)); - if (isRemoteDataArchivePropertyName) - { - this.GetCachedRowResultsForDatabase(dp, databaseName : GetTriggeredString(dp, 0)); - } - - } - - data = DBNull.Value; - switch (name) - { - case remoteDataArchiveEndpoint: - case remoteDataArchiveLinkedServer: - case remoteDataArchiveDatabaseName: - case remoteDataArchiveFederatedServiceAccount: - case remoteDataArchiveCredential: - if (this.rowResults != null && this.rowResults.Count > 0) - { - data = this.rowResults[0][name]; - } - break; - default: - TraceHelper.Assert(false, - string.Format(CultureInfo.InvariantCulture, - "PostProcessRemoteDataArchiveDatabaseProperties - Unknown property {0}", - name)); - break; - } - - return data; - } - else - { - TraceHelper.Assert(false, - string.Format(CultureInfo.InvariantCulture, - "PostProcessRemoteDataArchiveDatabaseProperties - Column name is null")); - return null; - } - } - - } -} diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/PostProcessText.cs b/src/Microsoft/SqlServer/Management/SqlEnum/PostProcessText.cs index a56d980b..cd4c437c 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/PostProcessText.cs +++ b/src/Microsoft/SqlServer/Management/SqlEnum/PostProcessText.cs @@ -4,7 +4,6 @@ namespace Microsoft.SqlServer.Management.Smo { using System; - using System.Data; using System.Diagnostics.CodeAnalysis; using Microsoft.SqlServer.Management.Sdk.Sfc; @@ -12,50 +11,13 @@ internal class PostProcessText : PostProcess { protected object m_text; bool m_btextSet; - DataTable m_dtText; [SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")] public PostProcessText() { CleanRowData(); - m_dtText = null; } - protected DataTable GetTextForAllRows() - { - Request reqtext = new Request(); - reqtext.Urn = this.Request.Urn.Value + "/Text"; - - reqtext.ResultType = ResultType.DataTable; - reqtext.RequestFieldsTypes = RequestFieldsTypes.Request; - reqtext.Fields = new String[] { "ObjectIdentifier", "ID", "Text" }; - - reqtext.OrderByList = new OrderBy [] - { - new OrderBy("ObjectIdentifier", OrderBy.Direction.Asc), - new OrderBy("ID", OrderBy.Direction.Asc) - }; - - return new Enumerator().Process(this.ConnectionInfo, reqtext); - } - - protected String GetTextForObject(string sObjectIdentifier) - { - int i = BinarySearchSetOnFirst(m_dtText.Rows, sObjectIdentifier, "ObjectIdentifier"); - - if( 0 > i ) - { - return string.Empty; // this can't be - } - - String s = String.Empty; - do - { - s += (String)m_dtText.Rows[i++]["Text"]; - } - while( i < m_dtText.Rows.Count && "1" != m_dtText.Rows[i]["ID"].ToString() ); - return s; - } protected bool IsTextSet { @@ -71,18 +33,7 @@ protected void SetText(object data, DataProvider dp) return; } - if( ExecuteSql.GetServerVersion(this.ConnectionInfo).Major < 9 ) - { - if( null == m_dtText ) - { - m_dtText = GetTextForAllRows(); - } - m_text = GetTextForObject((string)data); - } - else - { - m_text = GetTextFor90(data, dp); - } + m_text = GetTextFor90(data, dp); if( null == m_text ) { @@ -99,10 +50,6 @@ protected override bool SupportDataReader { get { - if( ExecuteSql.GetServerVersion(this.ConnectionInfo).Major < 9 ) - { - return false; - } return true; } } @@ -124,7 +71,6 @@ public override void CleanRowData() } - internal class PostProcessBodyText : PostProcessText { int m_idx; diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/SqlEnumDependencies.cs b/src/Microsoft/SqlServer/Management/SqlEnum/SqlEnumDependencies.cs index 574651bc..539f09cb 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/SqlEnumDependencies.cs +++ b/src/Microsoft/SqlServer/Management/SqlEnum/SqlEnumDependencies.cs @@ -746,89 +746,48 @@ static SqlTypeConvert FindByNo(int no) ///build a DependencyChainCollection based on the result from the dependency discovery tsql DependencyChainCollection BuildResult(DataTable dt) { - DependencyChainCollection deferredLink = new DependencyChainCollection(); DependencyChainCollection deps = new DependencyChainCollection(); Type dbnull = typeof(System.DBNull); - if (m_targetVersion.Major >= 10) // only for >= Katmai + foreach (DataRow row in dt.Rows) { - foreach (DataRow row in dt.Rows) - { - ServerDbSchemaName objectKey = BuildKey(row, true); + ServerDbSchemaName objectKey = BuildKey(row, true); - Dependency dep = (Dependency)m_tempDependencies[objectKey]; + Dependency dep = (Dependency)m_tempDependencies[objectKey]; - if (null == dep) - { - //have to build the urn - String surn = null; - surn = BuildUrn(row, true); - - dep = new Dependency(); - dep.Urn = surn; - m_tempDependencies[objectKey] = dep; - deps.Add(dep); - } - // Dependency of object might already exist with the IsSchemaBound value not set - // Always set the IsSchemaBound for the object with the parent - dep.IsSchemaBound = (bool)row["schema_bound"]; - ServerDbSchemaName relativeKey = BuildKey(row, false); - if (objectKey.CompareTo(relativeKey) != 0) - { - Dependency d = (Dependency)m_tempDependencies[relativeKey]; - if (null != d) - { - d.Links.Add(dep); - } - else - { - d = new Dependency(); - d.Urn = BuildUrn(row, false); - m_tempDependencies[relativeKey] = d; - deps.Add(d); - d.Links.Add(dep); - } - } + if (null == dep) + { + //have to build the urn + String surn = null; + surn = BuildUrn(row, true); + + dep = new Dependency(); + dep.Urn = surn; + m_tempDependencies[objectKey] = dep; + deps.Add(dep); } - deps.Reverse(); - } - else - { - foreach (DataRow row in dt.Rows) + // Dependency of object might already exist with the IsSchemaBound value not set + // Always set the IsSchemaBound for the object with the parent + dep.IsSchemaBound = (bool)row["schema_bound"]; + ServerDbSchemaName relativeKey = BuildKey(row, false); + if (objectKey.CompareTo(relativeKey) != 0) { - IDKey idk = BuildIDKey(row, false); - - Dependency dep = (Dependency)m_tempDependencies[idk]; - - if (null == dep) + Dependency d = (Dependency)m_tempDependencies[relativeKey]; + if (null != d) { - //have to build the urn - String surn = null; - surn = BuildUrn(idk.type, row); - - dep = new Dependency(); - dep.Urn = surn; - m_tempDependencies[idk] = dep; - deps.Add(dep); + d.Links.Add(dep); } - if (dbnull != row["relative_id"].GetType()) + else { - idk = BuildIDKey(row, true); - Dependency d = (Dependency)m_tempDependencies[idk]; - if (null != d) - { - dep.Links.Add(d); - } - else - { - //object not yet added. Defer resolution of key until all objects are added - dep.Links.Add(idk); - deferredLink.Add(dep); - } + d = new Dependency(); + d.Urn = BuildUrn(row, false); + m_tempDependencies[relativeKey] = d; + deps.Add(d); + d.Links.Add(dep); } } - ResolveDeferredLinks(deferredLink); } + deps.Reverse(); return deps; } @@ -892,25 +851,6 @@ static string DumpRow(DataRow row) return sb.ToString(); } - /// - ///resolve links which were defered - void ResolveDeferredLinks(DependencyChainCollection deferredLink) - { - TraceHelper.Assert(m_targetVersion.Major < 10, "ResolvedDeferredLinks should not be called for version >= Katmai"); - - foreach (Dependency dep in deferredLink) - { - for (int i = 0; i < dep.Links.Count; i++) - { - IDKey idk = ((ArrayList)dep.Links)[i] as IDKey; - if (null != idk) - { - ((ArrayList)dep.Links)[i] = m_tempDependencies[idk]; - } - } - } - } - /// ///given an idkey get the urn for that object: ///expensive, makes query to resolve the urn from id @@ -936,51 +876,8 @@ Urn GetUrnByQuery(IDKey idk) return (String)dt.Rows[0][0]; } - /// - ///builds urn based on the data row returned from dependency discovery - Urn BuildUrn(int type, DataRow row) - { - TraceHelper.Assert(m_targetVersion.Major < 10, "BuildUrn should never be called by server version >= Katmai"); - - SqlTypeConvert stc = FindByNo(type); - string surn = null; - - if (null != m_server) - { - surn = String.Format(CultureInfo.InvariantCulture, "Server[@Name='{0}']/Database[@Name='{1}']/", Urn.EscapeString(m_server), Urn.EscapeString(m_database)); - } - else - { - surn = String.Format(CultureInfo.InvariantCulture, "Server/Database[@Name='{0}']/", Urn.EscapeString(m_database)); - } - try - { - - if ("Trigger" == stc.Name) - { - surn += $"{FindByNo(((short)(row["relative_type"]))).Name}[@Name='{Urn.EscapeString((string)row["relative_name"])}' and @Schema='{Urn.EscapeString((string)row["relative_schema"])}']/{stc.Name}[@Name='{Urn.EscapeString((string)row["object_name"])}']"; - return surn; - } - if (typeof(System.DBNull) == row["object_schema"].GetType()) - { - surn += String.Format(CultureInfo.InvariantCulture, "{0}[@Name='{1}']", stc.Name, Urn.EscapeString((string)row["object_name"])); - return surn; - } - surn += String.Format(CultureInfo.InvariantCulture, "{0}[@Name='{1}' and @Schema='{2}']", - stc.Name, Urn.EscapeString((string)row["object_name"]), Urn.EscapeString((string)row["object_schema"])); - } - catch (InvalidCastException e) - { - throw new InternalEnumeratorException(StringSqlEnumerator.CouldNotGetInfoFromDependencyRow(DumpRow(row)), e); - } - return surn; - } - - Urn BuildUrn(DataRow row, bool forParent) { - TraceHelper.Assert(m_targetVersion.Major >= 10, "BuildUrn should be called by server version >= Katmai only"); - string surn = null; string serverName = forParent ? (string)row["object_svr"] : (string)row["relative_svr"]; string dbName = forParent ? (string)row["object_db"] : (string)row["relative_db"]; diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/SqlObjectBase.cs b/src/Microsoft/SqlServer/Management/SqlEnum/SqlObjectBase.cs index 47ca56b7..53e07d62 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/SqlObjectBase.cs +++ b/src/Microsoft/SqlServer/Management/SqlEnum/SqlObjectBase.cs @@ -758,12 +758,9 @@ internal EnumResult BuildResult(EnumResult result) continue; } #if !SMOCODEGEN - else if ((postProcess.Value is PostProcessBodyText) && - ((ServerConnection)this.ConnectionInfo).ServerVersion.Major >= 9) + else if (postProcess.Value is PostProcessBodyText) { - // PostProcessBodyText can be done directly only on 9.0 - // on 8.0 we need to execute additional queries and paste - // the syscomments fields + // PostProcessBodyText can be done directly on supported server versions continue; } #endif diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/Util.cs b/src/Microsoft/SqlServer/Management/SqlEnum/Util.cs index d03d5316..98340aa1 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/Util.cs +++ b/src/Microsoft/SqlServer/Management/SqlEnum/Util.cs @@ -6,6 +6,7 @@ namespace Microsoft.SqlServer.Management.Smo using System; using System.Collections.Specialized; using System.Data; + using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; @@ -301,7 +302,7 @@ internal static string EscapeLikePattern(string pattern) } // if we are going to escape this character, then sb should not be null - TraceHelper.Assert(!escape || sb != null); + Debug.Assert(!escape || sb != null); if (escape) diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/XmlRead.CS b/src/Microsoft/SqlServer/Management/SqlEnum/XmlRead.CS index 5e601a19..25858b00 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/XmlRead.CS +++ b/src/Microsoft/SqlServer/Management/SqlEnum/XmlRead.CS @@ -561,13 +561,6 @@ namespace Microsoft.SqlServer.Management.Smo { switch (this.Version.Major) { - case 9: - throw new InvalidVersionEnumeratorException( - StringSqlEnumerator.InvalidSqlServer(StringSqlEnumerator.SqlServer90Name)); - case 8: - throw new InvalidVersionEnumeratorException( - StringSqlEnumerator.InvalidSqlServer(StringSqlEnumerator.SqlServer80Name)); - //version 7.0 or earlier is not supported, therefore verion number is used. default: if (this.DatabaseEngineType == DatabaseEngineType.Standalone) { diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/enumstructs.cs b/src/Microsoft/SqlServer/Management/SqlEnum/enumstructs.cs index 6bb5ecb5..db375c70 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/enumstructs.cs +++ b/src/Microsoft/SqlServer/Management/SqlEnum/enumstructs.cs @@ -317,6 +317,18 @@ public enum ExternalDataSourceType ExternalGenerics = 6 } + /// + /// Types of an External Model. + /// + public enum ExternalModelType + { + /// + /// EMBEDDINGS Model Type. + /// + [TsqlSyntaxString("EMBEDDINGS")] + Embeddings = 1, + } + /// /// The enumeration specifies the external file format types /// diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/AditionalParameters.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/AditionalParameters.xml index 5fffe24e..4d4a9c61 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/AditionalParameters.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/AditionalParameters.xml @@ -1,5 +1,5 @@ - - + + @@ -18,12 +18,7 @@ begin select @Arg='SqlArg'+convert(nvarchar,@n) - - - exec master.dbo.xp_regread N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer\Parameters', @Arg, @Param OUTPUT - - - + exec master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer\Parameters', @Arg, @Param OUTPUT diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/AffinityInfo.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/AffinityInfo.xml index c708bc0f..e253fa5b 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/AffinityInfo.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/AffinityInfo.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/AgentPerfInfo.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/AgentPerfInfo.xml index de0d673c..376826f1 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/AgentPerfInfo.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/AgentPerfInfo.xml @@ -1,15 +1,8 @@ - + - - -DECLARE @instance_name sysname -SELECT @instance_name = null -SELECT @instance_name = N'SQLAgent:' - - - + DECLARE @instance_name sysname SELECT @instance_name = CONVERT(sysname, SERVERPROPERTY('InstanceName')) @@ -39,49 +32,7 @@ SELECT @instance_name = N'SQLAgent:' --JobStep object - - - CREATE TABLE #temp_jobstep_instances (subsystem NVARCHAR(40) NULL) - - insert #temp_jobstep_instances values('ActiveScripting') - insert #temp_jobstep_instances values('CmdExec') - insert #temp_jobstep_instances values('TSQL') - - -- Check if replication is installed - DECLARE @replication_installed int - - - - - EXECUTE master.dbo.xp_regread N'HKEY_LOCAL_MACHINE', N'SOFTWARE\Microsoft\MSSQLServer\Replication', N'IsInstalled', @replication_installed OUTPUT, N'no_output' - - - - - EXECUTE master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'SOFTWARE\Microsoft\MSSQLServer\Replication', N'IsInstalled', @replication_installed OUTPUT, N'no_output' - - - - - SELECT @replication_installed = ISNULL(@replication_installed, 0) - if 1 = @replication_installed - begin - insert #temp_jobstep_instances values('Distribution') - insert #temp_jobstep_instances values('LogReader') - insert #temp_jobstep_instances values('Merge') - insert #temp_jobstep_instances values('Snapshot') - end - - - - - if 1 = @replication_installed - begin - insert #temp_jobstep_instances values('QueueReader') - end - - - + CREATE TABLE #temp_jobstep_instances (subsystem NVARCHAR(40) NULL, description NVARCHAR(80) NULL, subsystem_dll NVARCHAR(255) NULL, agent_exe NVARCHAR(80) NULL, start_entry_point NVARCHAR(30) NULL, event_entry_point NVARCHAR(30) NULL, stop_entry_point NVARCHAR(30) NULL, max_worker_threads INT NULL, subsystem_id INT NULL) INSERT #temp_jobstep_instances EXEC msdb.dbo.sp_enum_sqlagent_subsystems diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/AgentSubSystems.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/AgentSubSystems.xml index d31adfb5..566ae14f 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/AgentSubSystems.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/AgentSubSystems.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/AlertNotification.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/AlertNotification.xml index f5e43372..23a085a0 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/AlertNotification.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/AlertNotification.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ApplicationRole.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ApplicationRole.xml index 56b11e44..3ab09726 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ApplicationRole.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ApplicationRole.xml @@ -1,26 +1,14 @@ - + - - rl.isapprole = 1 - - + rl.type = 'A' rl.name - - rl.uid - - rl.createdate - rl.updatedate - - - - - + rl.principal_id rl.default_schema_name diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/AsymmetricKey.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/AsymmetricKey.xml index fdf93257..a818ea81 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/AsymmetricKey.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/AsymmetricKey.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/Audit.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/Audit.xml index e9191cfb..bfacd1ed 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/Audit.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/Audit.xml @@ -1,5 +1,5 @@ - - + + fileau.audit_id = au.audit_id AND fileau.audit_guid = au.audit_guid diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/AvailabilityDatabase.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/AvailabilityDatabase.xml index 73281415..8a9bd384 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/AvailabilityDatabase.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/AvailabilityDatabase.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/AvailabilityGroup.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/AvailabilityGroup.xml index 49aac8c1..cac18791 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/AvailabilityGroup.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/AvailabilityGroup.xml @@ -1,5 +1,5 @@ - + - + @@ -21,4 +21,3 @@ - diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/AvailabilityGroupListenerIPAddress.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/AvailabilityGroupListenerIPAddress.xml index abf14615..f3f119a1 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/AvailabilityGroupListenerIPAddress.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/AvailabilityGroupListenerIPAddress.xml @@ -1,5 +1,5 @@ - + @@ -45,4 +45,3 @@ - diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/AvailabilityReplica.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/AvailabilityReplica.xml index 69196de3..e63d8f49 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/AvailabilityReplica.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/AvailabilityReplica.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/AvailableMedia.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/AvailableMedia.xml index a3a8ce48..4a80148b 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/AvailableMedia.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/AvailableMedia.xml @@ -1,7 +1,7 @@ - + - + convert(nchar(1), am.name)= convert(nchar(1), srddrv.DriveName) @@ -11,20 +11,16 @@ insert #avmed exec master.dbo.xp_availablemedia update #avmed set name = convert(nchar(2), name) where type != 4 - - - create table #tmpsrdDrive ( DriveName nvarchar(255) ) - insert #tmpsrdDrive select * from ::fn_servershareddrives() - - - - + + + create table #tmpsrdDrive ( DriveName nvarchar(255) ) insert #tmpsrdDrive select * from sys.fn_servershareddrives() - + + create table #tmpsrdDrive ( DriveName nvarchar(512) ) insert #tmpsrdDrive select path_name from sys.dm_io_cluster_valid_path_names @@ -32,7 +28,7 @@ insert #tmpsrdDrive select path_name from sys.dm_io_cluster_valid_path_names drop table #avmed - + drop table #tmpsrdDrive @@ -44,7 +40,7 @@ drop table #avmed am.high_free case when am.low_free >= 0 then 0. + am.low_free else 4294967296. + am.low_free end + 4294967296. * am.high_free am.type - + case when srddrv.DriveName is null then 0 else 1 end diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/BackupDevice.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/BackupDevice.xml index d000a0e2..8d65506a 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/BackupDevice.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/BackupDevice.xml @@ -1,10 +1,7 @@ - - + + - - (o.status & 0x10) <> 0 - - + @@ -14,12 +11,7 @@ o.name - - o.phyname - o.cntrltype - o.status & 0x08 - - + o.physical_name o.type diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/BoundColumn.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/BoundColumn.xml index 6eaecd0a..218c9757 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/BoundColumn.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/BoundColumn.xml @@ -1,14 +1,10 @@ - - + + - - - t.id = c.id and t.type = 'U' - - + t.object_id = c.object_id @@ -16,11 +12,7 @@ c.name t.name - - user_name(t.uid) - - - + schema_name(t.schema_id) diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/CdromDrive.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/CdromDrive.xml index 6d27fd0d..f73ffdec 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/CdromDrive.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/CdromDrive.xml @@ -1,5 +1,5 @@ - + create table #cdromdrv ( Name sysname NOT NULL, Size int NOT NULL ) insert #cdromdrv EXECUTE master.dbo.xp_fixeddrives 3 diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ClusterMemberState.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ClusterMemberState.xml index d766e085..9206a052 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ClusterMemberState.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ClusterMemberState.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ColumnEncryptionKey.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ColumnEncryptionKey.xml index 8387cbd3..1cdcf3af 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ColumnEncryptionKey.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ColumnEncryptionKey.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ColumnEncryptionKeyValue.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ColumnEncryptionKeyValue.xml index feeb4bcd..4ce13c7b 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ColumnEncryptionKeyValue.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ColumnEncryptionKeyValue.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ColumnMasterKey.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ColumnMasterKey.xml index 90d5aa67..00767365 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ColumnMasterKey.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ColumnMasterKey.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ComputedText.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ComputedText.xml index 37b16db8..ee4b04b5 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ComputedText.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ComputedText.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/Configuration.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/Configuration.xml index 06771d19..a4d01605 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/Configuration.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/Configuration.xml @@ -1,29 +1,13 @@ - + - - - v.type = 'C ' and not cfg.status is null and v.number = cfg.config - ucfg.config = cfg.config - - + - - v.name - v.number - v.low - v.high - cfg.status & 1 - cfg.status & 2 - ucfg.value - cfg.value - cfg.comment - - + cfg.name cfg.configuration_id cfg.minimum diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ConfigurationValue.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ConfigurationValue.xml index f6975272..bcef30ec 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ConfigurationValue.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ConfigurationValue.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/Connection.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/Connection.xml index 6d14b34f..f6c89751 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/Connection.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/Connection.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/Credential.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/Credential.xml index d795afd7..374883d2 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/Credential.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/Credential.xml @@ -1,7 +1,7 @@ - + - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/CryptographicProvider.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/CryptographicProvider.xml index d0d33206..a007187c 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/CryptographicProvider.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/CryptographicProvider.xml @@ -1,5 +1,5 @@ - - + + cp.provider_id = c.provider_id diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/Database.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/Database.xml index b9772648..2b376015 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/Database.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/Database.xml @@ -1,40 +1,15 @@ - + - - - t.dbname = dtb.name - - - v.name = 'db chaining' - - - - create table #tmplog (dbname sysname null, log_size float null, log_space_used float null, status int) - INSERT INTO #tmplog EXEC ('DBCC SQLPERF(LOGSPACE)') - - - create table #tempbackup (database_name nvarchar(128), [type] char(1), backup_finish_date datetime) - insert into #tempbackup select database_name, [type], max(backup_finish_date) from msdb..backupset where [type] = 'D' or [type] = 'L' or [type] = 'I' group by database_name, [type] - - - drop table #tmplog - - - drop table #tempbackup - - - - - + dmi.database_id = dtb.database_id @@ -50,7 +25,7 @@ dso.database_id = dtb.database_id - + df.database_id = dtb.database_id and 1=df.data_space_id and 1 = df.file_id @@ -149,7 +124,7 @@ - + create table #tmp_sp_db_vardecimal_storage_format (dbname sysname null, vardecimal_enabled varchar(3) null) @@ -187,22 +162,6 @@ drop table #dso - - - - - - - - - - - - dtb.name - dtb.dbid - suser_sname(dtb.sid) - dtb.crdate - rtrim(dtb.filename) - NULL - - t.log_size*(100-t.log_space_used)*10.24 - NULL - NULL - 0 - (select count(*) from master.dbo.sysprocesses p where dtb.dbid=p.dbid) - dtb.cmptlevel - '' - dtb.category - - case when dtb.name in ('master','model','msdb','tempdb') then 1 else category & 16 end - - dtb.status & <msparam>1</msparam> - dtb.status & <msparam>4194304</msparam> - - case when dtb.name in ('master') then 1 else dtb.is_distributor end @@ -307,7 +243,7 @@ ISNULL((select top 1 ftc.name from sys.fulltext_catalogs as ftc where ftc.is_default=1),N'') - + ISNULL((case dmi.mirroring_redo_queue_type when N'UNLIMITED' then 0 else dmi.mirroring_redo_queue end),0) ISNULL(dmi.mirroring_connection_timeout,0) 0 - + dtb.is_ansi_null_default_on dtb.is_ansi_nulls_on @@ -370,7 +306,7 @@ dtb.compatibility_level dtb.is_read_committed_snapshot_on - + isnull(dtb.source_database_id, 0) (select count(1) from sys.databases dtbmir where dtbmir.source_database_id = dtb.database_id) @@ -384,7 +320,7 @@ (dtb.is_published*1+dtb.is_subscribed*2+dtb.is_merge_published*4) - + dtb.is_local_cursor_default dtb.page_verify_option dtb.recovery_model @@ -483,94 +419,8 @@ - - DATABASEPROPERTYEX(dtb.name, 'IsFulltextEnabled') - DATABASEPROPERTYEX(dtb.name, 'Collation') - - - - - case - -- if all these are false then we are in the Normal state - -- except some return NULL if it's AutoClosed - when (DATABASEPROPERTY(dtb.name,'IsInLoad') = 0 and - (DATABASEPROPERTY(dtb.name,'IsInRecovery') = 0 or DATABASEPROPERTY(dtb.name,'IsInRecovery') is null) and - (DATABASEPROPERTY(dtb.name,'IsNotRecovered') = 0 or DATABASEPROPERTY(dtb.name,'IsNotRecovered') is null) and - DATABASEPROPERTY(dtb.name,'IsSuspect') = 0 and - DATABASEPROPERTY(dtb.name,'IsOffline') = 0 and - DATABASEPROPERTY(dtb.name,'IsInStandBy') = 0 and - (DATABASEPROPERTY(dtb.name,'IsShutDown') = 0 or DATABASEPROPERTY(dtb.name,'IsShutDown') is null) and - DATABASEPROPERTY(dtb.name,'IsEmergencyMode') = 0) then 1 - else 0 - end | - case - when DATABASEPROPERTY(dtb.name,'IsInLoad') = 1 then 2 - else 0 - end | - case - when DATABASEPROPERTY(dtb.name,'IsInRecovery') = 1 and - DATABASEPROPERTY(dtb.name,'IsNotRecovered') = 1 then 4 - else 0 - end | - case - when DATABASEPROPERTY(dtb.name,'IsInRecovery') = 1 then 8 - else 0 - end | - case - when DATABASEPROPERTY(dtb.name,'IsSuspect') = 1 then 16 - else 0 - end | - case - when DATABASEPROPERTY(dtb.name,'IsOffline') = 1 then 32 - else 0 - end | - case - when DATABASEPROPERTY(dtb.name,'IsInStandBy') = 1 then 64 - else 0 - end | - case - when DATABASEPROPERTY(dtb.name,'IsShutDown') = 1 then 128 - when DATABASEPROPERTY(dtb.name,'IsShutDown') is null then (512 + 128) - else 0 - end | - case - when DATABASEPROPERTY(dtb.name,'IsEmergencyMode') = 1 then 256 - else 0 - end - - - - - - - DATABASEPROPERTYEX(dtb.name, 'IsAnsiNullDefault') - DATABASEPROPERTYEX(dtb.name, 'IsAnsiNullsEnabled') - DATABASEPROPERTYEX(dtb.name, 'IsAnsiPaddingEnabled') - DATABASEPROPERTYEX(dtb.name, 'IsAnsiWarningsEnabled') - DATABASEPROPERTYEX(dtb.name, 'IsArithmeticAbortEnabled') - DATABASEPROPERTYEX(dtb.name, 'IsAutoCreateStatistics') - DATABASEPROPERTYEX(dtb.name, 'IsAutoUpdateStatistics') - DATABASEPROPERTYEX(dtb.name, 'IsCloseCursorsOnCommitEnabled') - DATABASEPROPERTYEX(dtb.name, 'IsNullConcat') - DATABASEPROPERTYEX(dtb.name, 'IsNumericRoundAbortEnabled') - DATABASEPROPERTYEX(dtb.name, 'IsQuotedIdentifiersEnabled') - DATABASEPROPERTY(dtb.name, 'IsReadOnly') - DATABASEPROPERTYEX(dtb.name, 'IsRecursiveTriggersEnabled') - DATABASEPROPERTYEX(dtb.name, 'IsLocalCursorsDefault') - CASE WHEN 1=DATABASEPROPERTYEX(dtb.name, 'IsTornPageDetectionEnabled') THEN 1 ELSE 0 END - CASE DATABASEPROPERTYEX(dtb.name, 'Recovery') WHEN 'SIMPLE' THEN 3 WHEN 'BULK_LOGGED' THEN 2 ELSE /*FULL*/ 1 END - CASE CONVERT(sysname,DATABASEPROPERTYEX(dtb.name, 'UserAccess')) WHEN 'SINGLE_USER' THEN 1 WHEN 'RESTRICTED_USER' THEN 2 ELSE /*MULTI_USER*/ 0 END - - case when (dtb.status2 & v.number != 0) then 1 else 0 end - - - - - @@ -593,11 +443,7 @@ ISNULL(DATABASEPROPERTYEX(dtb.name, 'ServiceObjective'), N'') - - CHARINDEX(N'_CS_', CAST(DATABASEPROPERTYEX(dtb.name, 'Collation') AS nvarchar(255))) - - - + case when CHARINDEX(N'_CS_', dtb.collation_name) > 0 then 1 when CHARINDEX(N'_BIN', dtb.collation_name) > 0 then 1 @@ -649,21 +495,17 @@ - + ( case LOWER(convert( nvarchar(128), DATABASEPROPERTYEX(dtb.name, 'Updateability'))) when 'read_write' then 1 else 0 end) DATABASEPROPERTYEX(dtb.name, 'Version') - - DATABASEPROPERTY(dtb.name,'IsFulltextEnabled') - - dtb.is_encrypted dtb.is_honor_broker_priority_on - + 0 0 @@ -683,17 +525,12 @@ - + has_dbaccess(dtb.name) N'' - - (select backup_finish_date from #tempbackup where type = <msparam>L</msparam> and db_id(database_name) = dtb.dbid) - (select backup_finish_date from #tempbackup where type = <msparam>D</msparam> and db_id(database_name) = dtb.dbid) - (select backup_finish_date from #tempbackup where type = <msparam>I</msparam> and db_id(database_name) = dtb.dbid) - - + (select backup_finish_date from #tempbackup where type = <msparam>L</msparam> and db_id(database_name) = dtb.database_id) (select backup_finish_date from #tempbackup where type = <msparam>D</msparam> and db_id(database_name) = dtb.database_id) (select backup_finish_date from #tempbackup where type = <msparam>I</msparam> and db_id(database_name) = dtb.database_id) diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseAuditSpecification.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseAuditSpecification.xml index 24906c4a..836d2300 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseAuditSpecification.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseAuditSpecification.xml @@ -1,5 +1,5 @@ - - + + das.audit_guid = au.audit_guid diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseAuditSpecificationDetail.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseAuditSpecificationDetail.xml index 0aa7feb3..bf122470 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseAuditSpecificationDetail.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseAuditSpecificationDetail.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseDdlTrigger.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseDdlTrigger.xml index 920a9542..6cf0f15c 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseDdlTrigger.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseDdlTrigger.xml @@ -1,12 +1,12 @@ - + tr.parent_class = 0 - + am2tr.object_id = tr.object_id - + sqlmod.object_id = tr.object_id @@ -18,7 +18,7 @@ - + @@ -32,7 +32,7 @@ - + tr.is_not_for_replication ~tr.is_disabled diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseDdlTriggerEvent.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseDdlTriggerEvent.xml index 21ba131f..e4f49ab4 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseDdlTriggerEvent.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseDdlTriggerEvent.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseDiagram.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseDiagram.xml index 3151df74..bd912c5e 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseDiagram.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseDiagram.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseEncryptionKey.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseEncryptionKey.xml index 90ec668e..e0e162ec 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseEncryptionKey.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseEncryptionKey.xml @@ -1,5 +1,5 @@ - + DB_ID()=dek.database_id diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseLocks.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseLocks.xml index d18f83ca..ac321884 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseLocks.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseLocks.xml @@ -1,21 +1,13 @@ - - + + - + v.number = l.mode AND v.type = N'L' v.number = l.mode - - - CREATE TABLE #t(spid int, mode int, dbid int NULL, objid int, objid2 int, indid int, status tinyint, ltype tinyint, objname sysname NULL, indname sysname NULL, dbname sysname NULL, sch sysname NULL) - - INSERT #t SELECT spid = req_spid, mode = req_mode + 1, dbid=rsc_dbid, objid=l.rsc_objid, objid2=l.rsc_objid, indid=l.rsc_indid, status = l.req_status, ltype = l.rsc_type, objname=NULL, indname=NULL, dbname = NULL, sch = NULL - FROM master.dbo.syslockinfo l WHERE rsc_dbid != db_id('tempdb') OR rsc_objid != object_id('#t') - - @@ -45,7 +37,7 @@ (N'RangeX-X', 22); - + CREATE TABLE #t(spid int, mode int, dbid int NULL, objid bigint, objid2 bigint, indid int, status tinyint, ltype nvarchar(120), objname sysname NULL, indname sysname NULL, dbname sysname NULL, sch sysname NULL) @@ -83,12 +75,7 @@ FROM sys.dm_tran_locks l WHERE resource_database_id = db_id() and resource_associated_entity_id != object_id('#t') - - -update #t set dbname = d.name FROM #t t LEFT OUTER JOIN master.dbo.sysdatabases d ON d.dbid = t.dbid - - - + update #t set dbname = d.name FROM #t t LEFT OUTER JOIN sys.databases d ON d.database_id = t.dbid update #t set objid2 = -objid2 where dbname is null @@ -107,14 +94,7 @@ update #t set dbname = d.name FROM #t t LEFT OUTER JOIN master.dbo.sysdatabases IF (@@FETCH_STATUS <> -2) BEGIN - - - SELECT @sql = 'use ' + quotename(@dbname) + ' update #t set objname = o.name, indname = i.name, sch=user_name(o.uid) FROM #t AS t ' + - 'LEFT JOIN dbo.sysobjects AS o ON o.id = t.objid LEFT OUTER JOIN dbo.sysindexes AS i ON i.id = t.objid AND i.indid = t.indid ' + - 'WHERE t.ltype in (4,5) AND t.dbid = ' + CAST(@dbid AS NVARCHAR(20)) - - - + IF( NOT @dbname IS NULL )--resource database SELECT @sql = 'use ' + quotename(@dbname) diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseMappings.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseMappings.xml index 97b6332a..924bbccf 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseMappings.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseMappings.xml @@ -1,5 +1,5 @@ - - + + @@ -10,12 +10,7 @@ create table #loginmappings( LoginName sysname NULL, DBName sysname NULL, UserNa declare @db_name nvarchar(512) declare crs cursor local fast_forward - - - for ( select name from master.dbo.sysdatabases where 1 = has_dbaccess(name)) - - - + for ( select name from sys.databases where 1 = has_dbaccess(name)) @@ -27,12 +22,7 @@ while @@fetch_status >= 0 begin set @db_name = quotename(@db_name) - - - exec('use ' + @db_name + ' INSERT #loginmappings select suser_sname(u.sid), db_name(), u.name, null from dbo.sysusers u where suser_sname(u.sid) is not null') - - - + exec('use ' + @db_name + ' INSERT #loginmappings select suser_sname(u.sid), db_name(), u.name, null from sys.database_principals AS u where suser_sname(u.sid) is not null') diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseMasterKey.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseMasterKey.xml index 9b59e719..b233c9bd 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseMasterKey.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseMasterKey.xml @@ -1,9 +1,9 @@ - + c.symmetric_key_id = 101 ok.key_id=c.symmetric_key_id and ok.database_id=db_id() - + mkdb.database_id=db_id() - + ISNULL(ok.status, 0) ISNULL(mkdb.is_master_key_encrypted_by_server, 0) diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseMirroringWitnessRole.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseMirroringWitnessRole.xml index 763817ad..c0f7d78b 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseMirroringWitnessRole.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseMirroringWitnessRole.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseOptions.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseOptions.xml index ca096a17..e6245f9f 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseOptions.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseOptions.xml @@ -1,13 +1,10 @@ - + - + dmi.database_id = dtb.database_id - - v.name = 'db chaining' - @@ -28,12 +25,7 @@ drop table #temp_data_retention_property2 - - - - + @@ -43,12 +35,7 @@ dtb.is_auto_create_stats_incremental_on - - dtb.status & 1 - dtb.status & 4194304 - - - + dtb.is_ansi_null_default_on dtb.is_ansi_nulls_on dtb.is_ansi_padding_on @@ -75,59 +62,12 @@ dtb.is_trustworthy_on dtb.is_parameterization_forced - + dtb.is_auto_close_on - + ISNULL((case dmi.mirroring_redo_queue_type when N'UNLIMITED' then 0 else dmi.mirroring_redo_queue end),0) ISNULL(dmi.mirroring_connection_timeout,0) - - DATABASEPROPERTYEX(dtb.name, 'IsAnsiNullDefault') - DATABASEPROPERTYEX(dtb.name, 'IsAnsiNullsEnabled') - DATABASEPROPERTYEX(dtb.name, 'IsAnsiPaddingEnabled') - DATABASEPROPERTYEX(dtb.name, 'IsAnsiWarningsEnabled') - DATABASEPROPERTYEX(dtb.name, 'IsArithmeticAbortEnabled') - DATABASEPROPERTYEX(dtb.name, 'IsAutoCreateStatistics') - DATABASEPROPERTYEX(dtb.name, 'IsAutoUpdateStatistics') - DATABASEPROPERTYEX(dtb.name, 'IsCloseCursorsOnCommitEnabled') - DATABASEPROPERTYEX(dtb.name, 'IsNullConcat') - DATABASEPROPERTYEX(dtb.name, 'IsNumericRoundAbortEnabled') - DATABASEPROPERTYEX(dtb.name, 'IsQuotedIdentifiersEnabled') - DATABASEPROPERTY(dtb.name, 'IsReadOnly') - DATABASEPROPERTYEX(dtb.name, 'IsRecursiveTriggersEnabled') - DATABASEPROPERTYEX(dtb.name, 'IsLocalCursorsDefault') - CASE WHEN 1=DATABASEPROPERTYEX(dtb.name, 'IsTornPageDetectionEnabled') THEN 1 ELSE 0 END - CASE DATABASEPROPERTYEX(dtb.name, 'Recovery') WHEN 'SIMPLE' THEN 3 WHEN 'BULK_LOGGED' THEN 2 ELSE /*FULL*/ 1 END - CASE CONVERT(sysname,DATABASEPROPERTYEX(dtb.name, 'UserAccess')) WHEN 'SINGLE_USER' THEN 1 WHEN 'RESTRICTED_USER' THEN 2 ELSE /*MULTI_USER*/ 0 END - - case when (dtb.status2 & v.number != 0) then 1 else 0 end - - - - - - DATABASEPROPERTY(dtb.name, 'IsAnsiNullDefault') - DATABASEPROPERTY(dtb.name, 'IsAnsiNullsEnabled') - DATABASEPROPERTY(dtb.name, 'IsAnsiWarngingsEnabled') - DATABASEPROPERTY(dtb.name, 'IsAutoCreateStatistics') - DATABASEPROPERTY(dtb.name, 'IsAutoUpdateStatistics') - DATABASEPROPERTY(dtb.name, 'IsCloseCursorsOnCommitEnabled') - DATABASEPROPERTY(dtb.name, 'IsQuotedIdentifiersEnabled') - DATABASEPROPERTY(dtb.name, 'IsRecursiveTriggersEnabled') - DATABASEPROPERTY(dtb.name, 'IsLocalCursorsDefault') - - CASE WHEN 1=DATABASEPROPERTY(dtb.name, 'IsTruncLog') THEN CASE WHEN 1=DATABASEPROPERTY(dtb.name, 'IsBulkCopy') THEN NULL ELSE 3/*SIMPLE=trunc. log on chkpt.*/ END - WHEN 1=DATABASEPROPERTY(dtb.name, 'IsBulkCopy') THEN 2 /*BULK_LOGGED*/ - ELSE 1 END /*FULL*/ - - - CASE DATABASEPROPERTY(dtb.name, 'IsSingleUser') WHEN 1 THEN 1 - ELSE (CASE DATABASEPROPERTY(dtb.name,'IsDboOnly') WHEN 0 THEN 0/*MULTI_USER*/ ELSE 1 END) - END - - - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseReplicaState.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseReplicaState.xml index b1e73e88..4b7728ff 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseReplicaState.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseReplicaState.xml @@ -1,5 +1,5 @@ - - + + @@ -72,7 +72,7 @@ ISNULL(dbr.is_suspended, 0) ISNULL(dbr.suspend_reason, 7) ISNULL(dbr.recovery_lsn, 0) - ISNULL(dbr.truncation_lsn, 0) + ISNULL(dbr.truncation_lsn, 0) ISNULL(dbr.last_sent_lsn, 0) ISNULL(dbr.last_sent_time, 0) ISNULL(dbr.last_received_lsn, 0) diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseRole.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseRole.xml index 02b504e2..e69992e2 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseRole.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseRole.xml @@ -1,11 +1,7 @@ - + - - rl.issqlrole = 1 - ou.uid = rl.altuid - - + rl.type = 'R' ou.principal_id = rl.owning_principal_id @@ -13,16 +9,7 @@ rl.name - - rl.uid - - rl.createdate - rl.updatedate - - - - - + rl.principal_id rl.create_date diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseRoleMember.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseRoleMember.xml index 4165a28b..ecfce7df 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseRoleMember.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseRoleMember.xml @@ -1,5 +1,5 @@ - + @@ -7,42 +7,7 @@ - - - u.uid = m.id - - - - - - - drop table #tmp_role_member_ids - - - + u.principal_id = m.id @@ -99,18 +64,7 @@ DELETE #tmp_role_member_ids WHERE generation = 0 u.name - - u.uid - suser_sname(u.sid) - - - - + u.principal_id - + suser_sname(u.sid) diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseScopedConfiguration.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseScopedConfiguration.xml index e60a2bb2..5221939a 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseScopedConfiguration.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseScopedConfiguration.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseScopedCredential.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseScopedCredential.xml index 7f63b2cb..3ca397cc 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseScopedCredential.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DatabaseScopedCredential.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DbExtendedProperty.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DbExtendedProperty.xml index 7081c566..4aac4408 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DbExtendedProperty.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DbExtendedProperty.xml @@ -1,10 +1,7 @@ - + - - - - + p.major_id=0 AND p.minor_id=0 AND p.class=0 diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/Default.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/Default.xml index bed66077..c36df0a1 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/Default.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/Default.xml @@ -1,10 +1,7 @@ - + - - obj.xtype=N'D' and obj.name not like N'#%%' and 0=(obj.category & 0x0800) - - + obj.type=N'D' and not(obj.parent_object_id > 0) @@ -12,11 +9,7 @@ - - - - - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DefaultColumn.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DefaultColumn.xml index 6ab804ae..5d7ac132 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DefaultColumn.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DefaultColumn.xml @@ -1,22 +1,15 @@ - - + + - - - - + - - - - - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DefaultConstrain.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DefaultConstrain.xml index 0c78167e..c9772d5b 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DefaultConstrain.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DefaultConstrain.xml @@ -1,14 +1,11 @@ - + - - cstr.xtype='D' and cstr.name not like N'#%%' and 0!=convert(bit,cstr.category & 0x0800) - - + @@ -21,38 +18,10 @@ - - - - - - - - - + CASE WHEN filetableobj.object_id IS NULL THEN 0 ELSE 1 END - + 0 diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DefaultDatatype.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DefaultDatatype.xml index cf415b34..2a46fa6b 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DefaultDatatype.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DefaultDatatype.xml @@ -1,21 +1,15 @@ - + - - - - + - - - - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DiskFile.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DiskFile.xml index 5a51a608..3e0e2b11 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DiskFile.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DiskFile.xml @@ -1,7 +1,7 @@ - - + + - + create table #filetmpfin (Name nvarchar(255) NOT NULL, IsFile bit NULL, FullName nvarchar(300) not NULL) if(@Name is null) diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DistributionColumn.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DistributionColumn.xml index 9ec9a088..1dff428b 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/DistributionColumn.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/DistributionColumn.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/Drive.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/Drive.xml index 953a8902..68643df7 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/Drive.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/Drive.xml @@ -1,5 +1,5 @@ - + @@ -13,7 +13,7 @@ update #fixdrv set Type = 'Removable' where Type IS NULL - + insert #fixdrv (Name, Size) EXECUTE master.dbo.xp_fixeddrives 3 update #fixdrv set Type = 'CD-ROM' where Type IS NULL diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/EnumObject.xsd b/src/Microsoft/SqlServer/Management/SqlEnum/xml/EnumObject.xsd new file mode 100644 index 00000000..bd3f8500 --- /dev/null +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/EnumObject.xsd @@ -0,0 +1,846 @@ + + + + + + + + Root element defining a SQL Server Management Object (SMO) type. + Used by both Code Generation (for creating class definitions) and runtime (for generating queries to populate/modify objects). + + + + + + + + + + Provides the definition of a property. This is used by codegen and during runtime to populate the Property value (usually from the value returned from the SQL query for the object). + Can be defined at the root level or within version-specific containers for version-gated properties. + + + + + + + Defines a union of multiple queries that combine results from different sources using SQL UNION. + Each union element contains its own settings and properties sections that define how to query and populate the object from a specific source. + Multiple union elements at the same level will have their results combined via UNION in the generated SQL query. + + + + + + + Version-specific settings or properties container at the root level. + Used to selectively include/exclude entire settings or properties sections based on SQL Server version. + Contents are only included if connection version meets the specified requirements. + + + + + + + The name of the class type this file is representing (e.g., "Table", "Index", "Column"). + + + + + Implementation type for the object (typically "SqlObject"). + + + + + Minimum major version (On-Prem) this object is supported in (e.g., '7' for SQL Server 7.0). + + + + + Maximum major version (On-Prem) this object is supported in. + + + + + Minimum minor version (On-Prem) this object is supported in. + + + + + Maximum minor version (On-Prem) this object is supported in. + + + + + Minimum build version (On-Prem) this object is supported in. + + + + + Maximum build version (On-Prem) this object is supported in. + + + + + Minimum major version (Cloud/Azure SQL) this object is supported in. + + + + + Maximum major version (Cloud/Azure SQL) this object is supported in. + + + + + Minimum minor version (Cloud/Azure SQL) this object is supported in. + + + + + Maximum minor version (Cloud/Azure SQL) this object is supported in. + + + + + Minimum build version (Cloud/Azure SQL) this object is supported in. + + + + + Maximum build version (Cloud/Azure SQL) this object is supported in. + + + + + Whether this object is enabled for Azure Synapse Analytics (Data Warehouse), in addition to other specified versions. + + + + + + + + + + Container for object settings including parent links, property links, and query modifications. + IMPORTANT: Child nodes MUST be defined in a specific order (see README.md for details). + + + + + + Specifies whether to use DISTINCT in the generated query (order 1). + + + + + Defines properties whose values are pulled from the parent object (order 2). + + + + + Condition that causes the enumeration to fail (order 3). + + + + + + Specifies which parent object properties should be selected and made available for child object queries (order 4). + Used when child objects need to reference parent property values in their queries. + + + + + + Includes another XML file's definitions into this object (order 5). + + + + + + Defines a join to a table or view (order 6). + Can be a FROM clause (table), JOIN clause (join), or LEFT JOIN clause (left_join). + Best practice: Use temp tables for new property_link entries on objects with many joins to avoid performance penalties. + + + + + + + SQL statements to execute before fetching properties (order 7). + Commonly used to create temp tables or declare variables. + + + + + + + SQL statements to execute after fetching properties (order 8). + Commonly used to drop temp tables or clean up resources. + + + + + + + Defines client-side post-processing for property values (order 9). + Allows calculations and transformations on returned data before properties are set. + + + + + + Redirects ordering to a different property (order 10). + + + + + + Special query modifications (order 11). + This tag has 2 specialized uses and one standard behavior. Originally it was a special case for table.xml, to add a filter to hide temp tables when enumerating tables in tempdb, and to enable adding a query hint for optimizing the overall tables query. + Now it also acts similarly to post_process by being a general purpose conditioned SQL tag with a fields attribute and a body which is added to the WHERE clause of the query with an AND condition. + + + + + + + Version-specific settings container. + Used to selectively include/exclude elements based on SQL Server version. + + + + + + + + Specifies the main table or temp table to use in the generated query. + Can be a system table, temp table, or catalog view with optional alias. + Examples: "#fixdrv" (temp table), "sys.partition_functions AS spf" (catalog view with alias), "dbo.syscomments c" (system table with alias). + + + + + + + Specifies whether to use DISTINCT in the generated query to eliminate duplicate rows. + When true, adds DISTINCT to the SELECT clause. + + + + + + + + + Defines mappings between parent object properties and child object properties. + + + + + + + The name of the property on the parent object. + + + + + The name of the property on the child object (will call parentObj.ParentProperty). + + + + + + + + Defines a complex expression for mapping parent properties to child properties using link_multiple syntax. + Used for advanced parent-child relationships where simple field mapping is insufficient. + + + + + + + + + + + Defines which parent object properties should be included in the parent SELECT query. + These properties are then available for use in child object queries via link_multiple expressions or other query constructs. + + + + + + + + + The name of the parent object property to select. + Example: 'ID', 'Name', 'JobID'. + + + + + + + + + + + + + Defines a join to a table or view. Join type is determined by attributes in this order: table, join, left_join. + + + + + + + + Object is added as a FROM clause (e.g., "sys.tables AS tbl"). + + + + + Object is joined via a JOIN clause (e.g., "sys.indexes AS idx"). + + + + + Object is joined via a LEFT JOIN clause (e.g., "sys.xml_indexes AS xi"). + + + + + Alias for the table/view being linked. + + + + + + The fields (properties) which trigger this property link to be applied. + Format: #-separated list surrounded by # (e.g., "#FieldName1#FieldName2#"). + Link is skipped if none of the listed properties are requested. + + + + + + + If true, the link_multiple expression is used as the table name rather than as a join condition. + + + + + + + + + Includes definitions from another XML file (relative path from xml directory). + + + + Relative path to the XML file to include (e.g., "parameter.xml", "include/inc_type.xml"). + + + + + Optional alias to use when including the file's definitions. + + + + + + The fields (properties) which trigger this include to be applied. + Format: #-separated list surrounded by # (e.g., "#IsSystemObject#", "#Name#ID#CreateDate#"). + Include is skipped if none of the listed properties are requested. + + + + + + + Properties from the included file that are read-only after object creation. + Format: #-separated list surrounded by # (e.g., "#Text#", "#DataType#NumericPrecision#NumericScale#"). + These properties can only be set during object creation, not modified afterward. + + + + + + + + + + SQL statements to execute before (prefix) or after (postfix) property fetching. + Can contain plain SQL text or link_multiple elements for dynamic SQL generation. + Best practice: Use prefix to create temp tables and postfix to drop them for performance optimization. + + + + + + + + + Fields that trigger this prefix/postfix to be executed. + Format: #-separated list surrounded by # (e.g., "#FieldName1#FieldName2#"). + + + + + + + + + + Post-processing for additional calculations on returned data. + Allows client-side manipulation before property values are set. + + + + + + The name of the class that handles post-processing (non-SMO types, used as-is). + Should extend PostProcess class. + + + + + + + The name of the SMO class that handles post-processing (prefixed with SMO namespace). + + + + + + + The list of fields which will cause the post-processing to happen. + Format: #-separated list surrounded by # (e.g., "#DefaultValue#"). + + + + + + + The list of fields needed to compute the value for the field requested by the user. + Format: #-separated list surrounded by # (e.g., "#IDText#DatabaseName#ParamName#"). + + + + + + + + + + Special query tag for adding conditional SQL to WHERE clause. + Acts as a general-purpose conditioned SQL tag with a fields attribute; body is added to WHERE clause with AND condition. + + + + + + + Fields that trigger this special query to be applied. + + + + + + Specifies the database context where this special query should be applied. + Example: "tempdb" to apply special filtering only when enumerating objects in the tempdb database. + + + + + + + Specifies a query hint to optimize the overall query. + Can be used to add query optimization hints to the generated SQL statement. + + + + + + + + + + + + Container for version-specific elements. + Contents are only included if connection version meets the specified requirements. + + + + + + Defines properties whose values are pulled from the parent object. + + + + + + Defines which parent object properties should be included in the parent SELECT query. + These properties are then available for use in child object queries via link_multiple expressions or other query constructs. + + + + + + + + + + + + + + + + Minimum major version (On-Prem) for contents to be included (e.g., '9' for SQL Server 2005). + + + + + Maximum major version (On-Prem) for contents to be included. + + + + + Minimum minor version (On-Prem) for contents to be included. + + + + + Maximum minor version (On-Prem) for contents to be included. + + + + + Minimum build version (On-Prem) for contents to be included (e.g., '950' for SQL Server 2025 CTP features). + + + + + Maximum build version (On-Prem) for contents to be included. + + + + + Minimum major version (Cloud/Azure SQL) for contents to be included. + + + + + Maximum major version (Cloud/Azure SQL) for contents to be included. + + + + + Minimum minor version (Cloud/Azure SQL) for contents to be included. + + + + + Maximum minor version (Cloud/Azure SQL) for contents to be included. + + + + + Minimum build version (Cloud/Azure SQL) for contents to be included. + + + + + Maximum build version (Cloud/Azure SQL) for contents to be included. + + + + + Whether contents are enabled for Azure Synapse Analytics (Data Warehouse). + + + + + + + + Container for property definitions used by codegen and runtime to populate property values. + + + + + + + + + + + + + Defines a property of the SMO object. + Used by codegen to create the property definition and during runtime to populate the property value from SQL query results. + + + + + + + + The name of the property (e.g., "Name", "ID", "IsReadOnly"). + + + + + + T-SQL type (e.g., "int", "bit", "nvarchar") which is mapped to the appropriate CLR type. + See Util.cs!DbTypeToClrType for the mapping. + + + + + + + CLR type for this property (prefixed with SMO namespace). + MUST be used for SMO types to ensure correct namespace (e.g., "IndexType", "ServerVersion"). + + + + + + + CLR type for this property (used as-is). + Should be used for non-SMO types (e.g., "System.String", "System.Int32"). + + + + + + + For post_process elements only. Class name that post_process is updating (prefixed with SMO namespace). + + + + + + + For post_process elements only. Class name that post_process is updating (used as-is for non-SMO types). + + + + + + Size for variable-length types (e.g., "4000" for nvarchar(4000)). + + + + + + If true, the generated T-SQL will CAST the property to the specified type. + Example: type='bit' cast='true' results in CAST(myPropValue AS bit). + + + + + + + If true, the generated T-SQL will use CONVERT function to explicitly convert the value to the specified type. + Similar to cast but uses CONVERT syntax instead of CAST. + + + + + + + Modes this property is available for (maps to PropertyMode enum). + Can accept either single values (e.g., "design", "deploy") or a #-separated list of values (e.g., "design#deploy"). + "design" mode adds SfcPropertyFlags.Design attribute and allows default values for readonly properties in unit testing. + "deploy" mode adds SfcPropertyFlags.Deploy attribute. + + + + + + + Marks property as expensive to fetch - only this property will be fetched when accessed (not batched). + Properties marked expensive are NOT pre-populated during Script() calls. + If set, Properties.Get returns NULL until property is explicitly requested via methods that fetch it. + + + + + + + If true (or attribute exists with any value), property is hidden from the user. + Hidden properties have no Request/Filter/OrderBy usages by default. + + + + + + + Access level for the property (case-insensitive). + Valid values: "Read" (read-only, cannot be modified), "ReadWrite" (can be read and modified), "Write" (write-only). + + + + + + + If true, property can only be set during object creation, not modified afterward (e.g., Identity, Computed). + + + + + + + What this property can be used for in SFC requests. + Valid values: "request" (ObjectPropertyUsages.Request), "filter" (ObjectPropertyUsages.Filter), "order" (ObjectPropertyUsages.OrderBy). + Defaults to All (all three) if neither usage nor notusage is specified and hidden=false. + Only one of usage or notusage is allowed; usage takes precedence. + + + + + + + What this property CANNOT be used for in SFC requests. + Valid values: "request", "filter", "order". + Only one of usage or notusage is allowed; usage takes precedence if both specified. + NOTE: Post-processed properties automatically have Filter and OrderBy usages removed (calculated client-side). + + + + + + + Default value for the property used during code generation. + Example: "0" for integer properties that should default to zero. + Used in conjunction with cfg.xml to set default values for properties in unit testing. + + + + + + + Specifies the position of this property in the object's key for URN construction and object identification. + Value is typically a numeric index (e.g., "0", "1") indicating the order of key properties. + Used by SMO to identify which properties form the unique key for the object. + + + + + + + Specifies an additional table to join for this property. + The table is added as a FROM clause specifically for retrieving this property's value. + Example: "master.dbo.spt_values v2" to join a lookup table for the property. + Used in conjunction with the 'link' attribute to define the join condition. + + + + + + + Specifies the join condition for the table specified in the 'table' attribute. + Defines how the additional table is linked to the main query. + Example: "v2.low=-1 and v2.type='SRV' and v1.number=v2.number" + Must be used together with the 'table' attribute. + + + + + + + + + + Defines a multi-field expression for building complex property values or URNs. + Used to compose values from multiple fields using parameterized expressions with placeholders ({0}, {1}, etc.). + + + + + + Defines a field that will be substituted into the expression's placeholder positions. + + + + + + The type of field link. + Common values: "parent" (refers to parent object property), "local" (refers to current object property). + + + + + + + The name of the field to link. + Example: "Urn", "FullName", "Name". + + + + + + + Optional default value to use when the field value is not available or null. + Examples: "null", "0", "'*'", "default". + Commonly used with type='filter' fields to provide fallback values. + + + + + + + + + + The number of link_field elements expected (e.g., '1', '2', '3'). + Used for validation to ensure the correct number of fields are provided for the expression. + + + + + + + The expression template with placeholders for field substitution. + Uses {0}, {1}, {2}, etc. as placeholders that will be replaced by values from link_field elements in order. + Example: "{0} + '/AlertSystem'" or "case COLUMNPROPERTY(clmns.id, clmns.name, N'IsIdentity') when 1 then ident_seed({0}) else 0 end" + + + + + + If true, the link_multiple result is hidden from the user. + + + + + + + + + Defines a union query component that combines results from multiple sources using SQL UNION. + Each union element represents one query in the UNION statement and contains its own settings and properties. + Used for objects that need to aggregate data from different system tables or views into a single result set. + + + + + + Defines the query settings for this union component, including table links and filters. + + + + + Defines the properties to be selected in this union component's query. + + + + + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ErrorLog.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ErrorLog.xml index 868be03f..2fc7b03c 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ErrorLog.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ErrorLog.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ErrorLogText.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ErrorLogText.xml index e691e20b..58ddd745 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ErrorLogText.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ErrorLogText.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalDataSource.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalDataSource.xml index c8df7af1..211f5984 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalDataSource.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalDataSource.xml @@ -1,5 +1,5 @@ - - + + c.credential_id = eds.credential_id diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalFileFormat.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalFileFormat.xml index 8496d3b1..603071e9 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalFileFormat.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalFileFormat.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalLanguage.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalLanguage.xml index 567c8404..c618f2c7 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalLanguage.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalLanguage.xml @@ -1,5 +1,5 @@ - + princip.principal_id = language.principal_id diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalLanguageFile.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalLanguageFile.xml index 39bca015..a8b1c7f9 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalLanguageFile.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalLanguageFile.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalLibrary.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalLibrary.xml index 146d6839..8d6ed444 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalLibrary.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalLibrary.xml @@ -1,5 +1,5 @@ - + princip.principal_id = library.principal_id diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalLibraryFile.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalLibraryFile.xml index b1d387e1..0155b20c 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalLibraryFile.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalLibraryFile.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalModel.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalModel.xml new file mode 100644 index 00000000..f7bf8767 --- /dev/null +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalModel.xml @@ -0,0 +1,58 @@ + + + + + c.credential_id = emds.credential_id + princip.principal_id = emds.principal_id + + + + create table #externalmodels ( + external_model_id int, + name sysname, + location nvarchar(4000), + api_format nvarchar(100), + model_type_id int, + model nvarchar(100), + parameters nvarchar(max), + credential_id int, + principal_id int + ); + begin try + exec sp_executesql N' + insert into #externalmodels ( + external_model_id, name, location, api_format, model_type_id, model, parameters, credential_id, principal_id + ) + select external_model_id, name, location, api_format, model_type_id, model, CONVERT(NVARCHAR(MAX),parameters), credential_id, principal_id + from sys.external_models'; + end try + begin catch + end catch + + + + drop table #externalmodels + + + + + emds.name + emds.external_model_id + princip.name + ISNULL(emds.location,N'') + ISNULL(emds.api_format,N'') + emds.model_type_id + ISNULL(emds.model,N'') + ISNULL(emds.parameters,N'{}') + ISNULL(c.name,N'') + + + + + + + \ No newline at end of file diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalResourcePool.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalResourcePool.xml index 5ef1654f..4547832d 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalResourcePool.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalResourcePool.xml @@ -1,5 +1,5 @@ - - + + @@ -14,4 +14,3 @@ - diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalResourcePoolAffinityInfo.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalResourcePoolAffinityInfo.xml index 0002391b..455b330f 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalResourcePoolAffinityInfo.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalResourcePoolAffinityInfo.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalStream.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalStream.xml index 2e30da99..3f5912ce 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalStream.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalStream.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalStreamingJob.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalStreamingJob.xml index 34c693aa..b473a4d7 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalStreamingJob.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ExternalStreamingJob.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/FKColumn.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/FKColumn.xml index d67d226c..6766ad73 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/FKColumn.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/FKColumn.xml @@ -1,17 +1,10 @@ - + - - - cfk.colid=fk.fkey and cfk.id = fk.fkeyid - crk.colid=fk.rkey and crk.id = fk.rkeyid - - + fk.parent_column_id = cfk.column_id and fk.parent_object_id = cfk.object_id @@ -21,13 +14,7 @@ - - cfk.name - fk.keyno - crk.name - - - + cfk.name fk.constraint_column_id crk.name diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/File.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/File.xml index 9c4c9421..365493cf 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/File.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/File.xml @@ -1,17 +1,14 @@ - + - - s.type = 0 and (s.drop_lsn IS NULL) - - + fs.database_id = db_id() AND fs.file_id = s.file_id - - CASE s.fileid WHEN 1 THEN 1 ELSE 0 END - CAST(FILEPROPERTY(s.name, 'SpaceUsed') AS float)* CONVERT(float,8) - - - - - - - - + CASE s.file_id WHEN 1 THEN 1 ELSE 0 END - + CASE s.type WHEN 2 THEN 0 ELSE CAST(FILEPROPERTY(s.name, 'SpaceUsed') AS float)* CONVERT(float,8) END @@ -97,7 +84,7 @@ mf.size as size 0.0 0.0 - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/FileGroup.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/FileGroup.xml index d4beefd2..5facba0c 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/FileGroup.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/FileGroup.xml @@ -1,27 +1,13 @@ - - + + - - - declare @PageSize float select @PageSize=v.low/1024.0 from master..spt_values v - where v.number=1 and v.type='E' - - - + - - g.groupname - g.groupid - g.status & 0x08 - g.status & 0x10 - - ISNULL((select sum(s.size * @PageSize) from dbo.sysfiles s where s.groupid = g.groupid), 0) - - + cast(g.name as varbinary(256)) g.data_space_id g.is_read_only diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/FixedDrive.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/FixedDrive.xml index 5dbefdee..156d86fb 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/FixedDrive.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/FixedDrive.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ForeignKey.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ForeignKey.xml index 905673bf..21921f53 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ForeignKey.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ForeignKey.xml @@ -1,19 +1,10 @@ - + - - cstr.type=N'F' - rfr.constid = cstr.id - ki.indid = rfr.rkeyindid AND ki.id = rfr.rkeyid - rfr.rkeyid = rtbl.id - - + ki.index_id = cstr.key_index_id and ki.object_id = cstr.referenced_object_id @@ -34,20 +25,8 @@ - - ki.name - rtbl.name - user_name(rtbl.uid) - OBJECTPROPERTY(cstr.id, N'CnstIsDeleteCascade') - OBJECTPROPERTY(cstr.id, N'CnstIsUpdateCascade') - - - - - - - + ki.name rtbl.name schema_name(rtbl.schema_id) diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/FullTextCatalog.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/FullTextCatalog.xml index d4ced716..7f52bad1 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/FullTextCatalog.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/FullTextCatalog.xml @@ -1,39 +1,12 @@ - + - + cat.data_space_id = fg.data_space_id cat.principal_id=dp.principal_id - - - ci.ftcatid = cat.ftcatid - - - -create table #tmpcatinfo ([ftcatid] smallint,[name] sysname,[path] nvarchar(260),[status] int,[number_fulltext_tables] int) -if( 1 = DATABASEPROPERTYEX(db_name(), 'IsFulltextEnabled') ) -begin - insert #tmpcatinfo execute dbo.sp_help_fulltext_catalogs -end - - - - -create table #tmpcatinfo ([ftcatid] smallint,[name] sysname,[path] nvarchar(260),[status] int,[number_fulltext_tables] int) -if( 1 = DATABASEPROPERTY(db_name(), 'IsFulltextEnabled') ) -begin - insert #tmpcatinfo execute dbo.sp_help_fulltext_catalogs -end - - - - -drop table #tmpcatinfo - - FULLTEXTCATALOGPROPERTY(cat.name,'UniqueKeyCount') - - FULLTEXTCATALOGPROPERTY(cat.name,'UniqueKeyCount') - - - + cat.fulltext_catalog_id FULLTEXTCATALOGPROPERTY(cat.name,'AccentSensitivity') cat.is_default @@ -59,10 +28,6 @@ drop table #tmpcatinfo dp.name - - cat.ftcatid - - FULLTEXTCATALOGPROPERTY(cat.name,'LogSize') FULLTEXTCATALOGPROPERTY(cat.name,'IndexSize') FULLTEXTCATALOGPROPERTY(cat.name,'ItemCount') @@ -74,12 +39,7 @@ drop table #tmpcatinfo cast(null as datetime) - - ISNULL(ci.path,N'') - ci.number_fulltext_tables - - - + ISNULL(cat.path,N'') (select (case when exists(select distinct object_id from sys.fulltext_indexes fti where cat.fulltext_catalog_id = fti.fulltext_catalog_id and OBJECTPROPERTY(object_id, 'IsTable')=1) then 1 else 0 end)) diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/FullTextFile.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/FullTextFile.xml index bbf7e158..10d7196c 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/FullTextFile.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/FullTextFile.xml @@ -1,11 +1,11 @@ - + - + ((s.type = 4) AND (s.drop_lsn IS NULL)) diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/FullTextIndex.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/FullTextIndex.xml index fb23e1d2..cb53fb8f 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/FullTextIndex.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/FullTextIndex.xml @@ -1,24 +1,7 @@ - - + + - - - - - - - - - - - - - - - - - - + @@ -55,33 +38,7 @@ cat.name - - - - - - - - - - - - - - - - - - - - - - - + fti.is_enabled OBJECTPROPERTY(fti.object_id,'TableFullTextPopulateStatus') (case change_tracking_state when 'M' then 1 when 'A' then 2 else 0 end) diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/FullTextIndexColumn.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/FullTextIndexColumn.xml index b4029ce8..aba6e30b 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/FullTextIndexColumn.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/FullTextIndexColumn.xml @@ -1,17 +1,10 @@ - - + + - - COLUMNPROPERTY(cols.id, cols.name, 'IsFulltextIndexed') <> 0 - - - sl.lcid=cols.language - - - + col.object_id = icol.object_id and col.column_id = icol.column_id sl.lcid=icol.language_id @@ -20,39 +13,7 @@ - - cols.name - - - - - ISNULL((select scol2.name from - sysdepends as sdep, - syscolumns as scol2 - where - cols.colid = sdep.number - and cols.id = sdep.id - and cols.id = scol2.id - and sdep.depnumber = scol2.colid),N'') - - - - - ISNULL((select scol2.name from - sysdepends as sdep, - syscolumns as scol2 - where - cols.colid = sdep.number - and cols.id = sdep.id - and sdep.deptype = 1 - and cols.id = scol2.id - and sdep.depnumber = scol2.colid),N'') - - - - sl.alias - - + col.name sl.name diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/FullTextLanguage.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/FullTextLanguage.xml index 0922e800..a12542ff 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/FullTextLanguage.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/FullTextLanguage.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/FullTextService.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/FullTextService.xml index 32d69abb..b40a115a 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/FullTextService.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/FullTextService.xml @@ -1,15 +1,6 @@ - - + + - - - DECLARE @FullTextDefaultPath NVARCHAR(512) - EXECUTE master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE', - N'SOFTWARE\Microsoft\MSSQLServer\MSSQLServer', - N'FullTextDefaultPath', - @FullTextDefaultPath OUTPUT - - DECLARE @FullTextDefaultPath NVARCHAR(512) @@ -28,24 +19,20 @@ - + @@SERVERNAME - + serverproperty(N'Servername') - + ISNULL(FULLTEXTSERVICEPROPERTY('ConnectTimeout'),0) * 10000000 ISNULL(@FullTextDefaultPath, N'') ISNULL(FULLTEXTSERVICEPROPERTY('ResourceUsage'), 0) - - ISNULL(FULLTEXTSERVICEPROPERTY('DataTimeout'),0) * 10000000 - - - + 0 CASE diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/FullTextStopList.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/FullTextStopList.xml index 84d73bed..7e11e9a3 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/FullTextStopList.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/FullTextStopList.xml @@ -1,5 +1,5 @@ - + sl.principal_id=dp.principal_id diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/FulltextSemanticLanguage.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/FulltextSemanticLanguage.xml index ef9a5904..c57f2efb 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/FulltextSemanticLanguage.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/FulltextSemanticLanguage.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/IndexFragDetail.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/IndexFragDetail.xml index 78bfbe88..35fec10b 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/IndexFragDetail.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/IndexFragDetail.xml @@ -1,40 +1,10 @@ - + - - - - - - - - + - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/IndexFragFast.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/IndexFragFast.xml index 232b1745..9a9e01b7 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/IndexFragFast.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/IndexFragFast.xml @@ -1,42 +1,12 @@ - + - - - - - - - - + - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/IndexFragSampled.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/IndexFragSampled.xml index 5f3c1684..86f061f0 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/IndexFragSampled.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/IndexFragSampled.xml @@ -1,42 +1,11 @@ - + - - - - - - - - + - + - diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/IndexedColumn.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/IndexedColumn.xml index 04af5516..a647947e 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/IndexedColumn.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/IndexedColumn.xml @@ -1,35 +1,19 @@ - + - - - clmns.id = ic.id and clmns.colid = ic.colid and clmns.number = 0 - - + ic.column_id > 0 and (ic.key_ordinal > 0 or ic.partition_ordinal = 0 or ic.is_included_column != 0) - clmns.object_id = ic.object_id and clmns.column_id = ic.column_id + clmns.object_id = ic.object_id and clmns.column_id = ic.column_id - - clmns.name - ic.keyno - - - COLUMNPROPERTY(ic.id, clmns.name, N'IsComputed') - - - INDEXKEY_PROPERTY(ic.id, ic.indid, ic.keyno, N'IsDescending') - - + clmns.name (case ic.key_ordinal when 0 then ic.index_column_id else ic.key_ordinal end) @@ -40,7 +24,7 @@ ISNULL(ic.column_store_order_ordinal,0) - + COLUMNPROPERTY(ic.object_id, clmns.name, N'IsComputed') diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/IndexedJsonPath.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/IndexedJsonPath.xml index 995c3c14..7ded4cfe 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/IndexedJsonPath.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/IndexedJsonPath.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/IndexedXmlPath.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/IndexedXmlPath.xml index 8aa4738d..86c0eb74 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/IndexedXmlPath.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/IndexedXmlPath.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/IndexedXmlPathNamespace.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/IndexedXmlPathNamespace.xml index bf512f27..c6a90272 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/IndexedXmlPathNamespace.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/IndexedXmlPathNamespace.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/Information.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/Information.xml index 7809d6b4..b80b04a7 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/Information.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/Information.xml @@ -1,62 +1,7 @@ - + - - - create table #SVer(ID int, Name sysname, Internal_Value int, Value nvarchar(512)) - insert #SVer exec master.dbo.xp_msver - - - declare @NetName sysname - exec master.dbo.xp_getnetname @NetName OUTPUT - - - declare @SmoRoot nvarchar(512) - exec master.dbo.xp_regread N'HKEY_LOCAL_MACHINE', N'SOFTWARE\Microsoft\MSSQLServer\Setup', N'SQLPath', @SmoRoot OUTPUT - - - declare @RegPathParams sysname - declare @Arg sysname - declare @Param sysname - declare @MasterPath nvarchar(512) - declare @LogPath nvarchar(512) - declare @ErrorLogPath nvarchar(512) - declare @n int - - select @n=0 - select @RegPathParams=N'Software\Microsoft\MSSQLServer\MSSQLServer'+'\Parameters' - select @Param='dummy' - while(not @Param is null) - begin - select @Param=null - select @Arg='SqlArg'+convert(nvarchar,@n) - - exec master.dbo.xp_regread N'HKEY_LOCAL_MACHINE', @RegPathParams, @Arg, @Param OUTPUT - if(@Param like '-d%') - begin - select @Param=substring(@Param, 3, 255) - select @MasterPath=substring(@Param, 1, len(@Param) - charindex('\', reverse(@Param))) - end - else if(@Param like '-l%') - begin - select @Param=substring(@Param, 3, 255) - select @LogPath=substring(@Param, 1, len(@Param) - charindex('\', reverse(@Param))) - end - else if(@Param like '-e%') - begin - select @Param=substring(@Param, 3, 255) - select @ErrorLogPath=substring(@Param, 1, len(@Param) - charindex('\', reverse(@Param))) - end - - select @n=@n+1 - end - - - drop table #SVer - - - - + declare @RegPathParams sysname declare @Arg sysname @@ -96,14 +41,14 @@ - + create table #SVer(ID int, Name sysname, Internal_Value int, Value nvarchar(512)) insert #SVer exec master.dbo.xp_msver - + declare @SmoRoot nvarchar(512) exec master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'SOFTWARE\Microsoft\MSSQLServer\Setup', N'SQLPath', @SmoRoot OUTPUT @@ -259,7 +204,7 @@ exec master.dbo.xp_getnetname @FullyQualifiedNetName OUTPUT, 1 - + drop table #SVer @@ -283,7 +228,7 @@ case when 'a' <> 'A' then 1 else 0 end @@MAX_PRECISION - + (select Value from #SVer where Name = N'ProductName') (select Value from #SVer where Name = N'WindowsVersion') (select Value from #SVer where Name = N'Language') @@ -308,23 +253,18 @@ SERVERPROPERTY('PathSeparator') - + FULLTEXTSERVICEPROPERTY('IsFullTextInstalled') 0 - + @LogPath @MasterPath - - (select Value from #SVer where Name = N'ProductVersion') - @NetName - SUBSTRING(@@version,PATINDEX(N'%Corporation%',@@version)+DATALENGTH('Corporation')+2,PATINDEX(N'% on %',@@version)-(PATINDEX(N'%Corporation%',@@version)+DATALENGTH('Corporation')+2)) - - + SERVERPROPERTY(N'ProductVersion') SERVERPROPERTY(N'Edition') SERVERPROPERTY(N'ProductLevel') @@ -333,7 +273,7 @@ SERVERPROPERTY('EngineEdition') convert(sysname, serverproperty(N'collation')) - + SERVERPROPERTY(N'MachineName') SERVERPROPERTY('IsClustered') @@ -342,10 +282,7 @@ ISNULL(SERVERPROPERTY(N'MachineName'),N'') ISNULL(SERVERPROPERTY('IsClustered'),N'') - - case when (select password from master.dbo.syslogins where sid = 0x01) is null then 1 else 0 end - - + SERVERPROPERTY(N'ResourceVersion') SERVERPROPERTY(N'ResourceLastUpdateDateTime') SERVERPROPERTY(N'CollationID') @@ -355,11 +292,11 @@ SERVERPROPERTY(N'SqlSortOrder') SERVERPROPERTY(N'SqlSortOrderName') - + null SERVERPROPERTY(N'BuildClrVersion') - + SERVERPROPERTY(N'ComputerNamePhysicalNetBIOS') @@ -389,7 +326,7 @@ - + 0 diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/Job.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/Job.xml index 12384153..864b54c1 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/Job.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/Job.xml @@ -1,5 +1,5 @@ - + @@ -14,30 +14,7 @@ (category_id int null, category_type tinyint null, name nvarchar(128) null) insert into #tmp_sp_help_category exec msdb.dbo.sp_help_category - - - - - - create table #tmp_sp_help_operator - (id int null, name nvarchar(128) null, enabled tinyint null, email_address nvarchar(100) null, last_email_date int null, last_email_time int null, pager_address nvarchar(100) null, last_pager_date int null, last_pager_time int null, weekday_pager_start_time int null, weekday_pager_end_time int null, saturday_pager_start_time int null, saturday_pager_end_time int null, sunday_pager_start_time int null, sunday_pager_end_time int null, pager_days tinyint null, netsend_address nvarchar(100) null, last_netsend_date int null, last_netsend_time int null, category_name nvarchar(128) null) - - if ((ISNULL(IS_SRVROLEMEMBER('sysadmin'), 0) != 0) or - exists (select * from sysprotects - where OBJECT_NAME(id) = 'sp_help_operator' - and action = 224 - and protecttype != 206 - and (uid = 0 or uid = USER_ID()) - ) - ) - insert into #tmp_sp_help_operator exec msdb.dbo.sp_help_operator - - - + create table #tmp_sp_help_operator (id int null, name nvarchar(128) null, enabled tinyint null, email_address nvarchar(100) null, last_email_date int null, last_email_time int null, pager_address nvarchar(100) null, last_pager_date int null, last_pager_time int null, weekday_pager_start_time int null, weekday_pager_end_time int null, saturday_pager_start_time int null, saturday_pager_end_time int null, sunday_pager_start_time int null, sunday_pager_end_time int null, pager_days tinyint null, netsend_address nvarchar(100) null, last_netsend_date int null, last_netsend_time int null, category_name nvarchar(128) null) diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/JobServer.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/JobServer.xml index 2e4aa7f8..95aac6cb 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/JobServer.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/JobServer.xml @@ -1,24 +1,6 @@ - + - - - - create table #tmp_sp_get_sqlagent_properties - (auto_start int null, msx_server_name sysname null, sqlagent_type int null, startup_account nvarchar(255) null, sqlserver_restart int null, jobhistory_max_rows int null, jobhistory_max_rows_per_job int null, errorlog_file nvarchar(255) null, errorlogging_level int null, error_recipient nvarchar(30) null, monitor_autostart int null, local_host_server sysname null, job_shutdown_timeout int null, cmdexec_account varbinary(64) null, regular_connections int null, host_login_name nvarchar(128) null, host_login_password varbinary(512) null, login_timeout int null, idle_cpu_percent int null, idle_cpu_duration int null, oem_errorlog int null, sysadmin_only int null, email_profile nvarchar(64) null, email_save_in_sent_folder int null, cpu_poller_enabled int null) - insert into #tmp_sp_get_sqlagent_properties(auto_start, msx_server_name, sqlagent_type, startup_account, sqlserver_restart, jobhistory_max_rows, jobhistory_max_rows_per_job, errorlog_file, errorlogging_level, error_recipient, monitor_autostart, local_host_server, job_shutdown_timeout, cmdexec_account, regular_connections, host_login_name, host_login_password, login_timeout, idle_cpu_percent, idle_cpu_duration, oem_errorlog, sysadmin_only, email_profile, email_save_in_sent_folder, cpu_poller_enabled) - exec msdb.dbo.sp_get_sqlagent_properties - - - - create table #tmpMsxAccountName ( domain nvarchar(255) null, username nvarchar(255) null) - if ( ( (@@microsoftversion / power(2, 24) = 8) and (@@microsoftversion & 0xffff >= 760) ) or (@@microsoftversion / power(2, 24) > 8)) - begin - insert into #tmpMsxAccountName(domain, username) exec master.dbo.xp_sqlagent_msx_account N'GET' - end - - - - + @@ -68,10 +50,7 @@ drop table #tmpMsxAccountName - - @@SERVERNAME - - + serverproperty(N'Servername') @@ -96,13 +75,7 @@ drop table #tmpMsxAccountName ISNULL(tsgsp.local_host_server,N'') tsgsp.auto_start - - ISNULL((select top 1 ISNULL(domain + N'\', N'') + username as [UserName] from #tmpMsxAccountName),N'') - tsgsp.sysadmin_only - - - + tsgsp.replace_alert_tokens_enabled ISNULL((select top 1 msx_login_name from #tmpMsxAccountName),N'') diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/JobStepOutputLog.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/JobStepOutputLog.xml index 8aa5b9ae..31770c49 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/JobStepOutputLog.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/JobStepOutputLog.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/KeyEncryption.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/KeyEncryption.xml index 46ebf3aa..d9b55e83 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/KeyEncryption.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/KeyEncryption.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/Lock.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/Lock.xml index 106b79ec..d4dab8f2 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/Lock.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/Lock.xml @@ -1,21 +1,13 @@ - - + + - + v.number = l.mode AND v.type = N'L' v.number = l.mode - - - CREATE TABLE #t(spid int, mode int, dbid int NULL, objid int, objid2 int, indid int, status tinyint, ltype tinyint, objname sysname NULL, indname sysname NULL, dbname sysname NULL, sch sysname NULL) - - INSERT #t SELECT spid = req_spid, mode = req_mode + 1, dbid=rsc_dbid, objid=l.rsc_objid, objid2=l.rsc_objid, indid=l.rsc_indid, status = l.req_status, ltype = l.rsc_type, objname=NULL, indname=NULL, dbname = NULL, sch = NULL - FROM master.dbo.syslockinfo l WHERE rsc_dbid != db_id('tempdb') OR rsc_objid != object_id('#t') - - @@ -45,7 +37,7 @@ (N'RangeX-X', 22); - + CREATE TABLE #t(spid int, mode int, dbid int NULL, objid bigint, objid2 bigint, indid int, status tinyint, ltype nvarchar(120), objname sysname NULL, indname sysname NULL, dbname sysname NULL, sch sysname NULL) @@ -83,12 +75,7 @@ FROM sys.dm_tran_locks l WHERE resource_database_id != isnull(db_id('tempdb'), -1) OR resource_associated_entity_id != object_id('#t') - - -update #t set dbname = d.name FROM #t t LEFT OUTER JOIN master.dbo.sysdatabases d ON d.dbid = t.dbid - - - + update #t set dbname = d.name FROM #t t LEFT OUTER JOIN sys.databases d ON d.database_id = t.dbid update #t set objid2 = -objid2 where dbname is null @@ -107,14 +94,7 @@ update #t set dbname = d.name FROM #t t LEFT OUTER JOIN master.dbo.sysdatabases IF (@@FETCH_STATUS <> -2) BEGIN - - - SELECT @sql = 'use ' + quotename(@dbname) + ' update #t set objname = o.name, indname = i.name, sch=user_name(o.uid) FROM #t AS t '+ - 'LEFT JOIN dbo.sysobjects AS o ON o.id = t.objid LEFT OUTER JOIN dbo.sysindexes AS i ON i.id = t.objid AND i.indid = t.indid '+ - 'WHERE t.ltype in (4,5) AND t.dbid = ' + CAST(@dbid AS NVARCHAR(20)) - - - + IF( NOT @dbname IS NULL )--resource database SELECT @sql = 'use ' + quotename(@dbname) diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/LogFile.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/LogFile.xml index 4c785ebd..342677e0 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/LogFile.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/LogFile.xml @@ -1,11 +1,7 @@ - + - - - s.groupid = 0 - - + s.type = 1 fs.database_id = db_id() AND fs.file_id = s.file_id @@ -13,7 +9,7 @@ - + CAST(FILEPROPERTY(s.name, 'SpaceUsed') AS float)* CONVERT(float,8) diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/LogMarkHistory.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/LogMarkHistory.xml index f2c49e05..0b71c170 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/LogMarkHistory.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/LogMarkHistory.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/Mail.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/Mail.xml index a7052fc9..bf0b86a4 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/Mail.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/Mail.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/MailAccount.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/MailAccount.xml index b0744b96..3a0fdf21 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/MailAccount.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/MailAccount.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/MailProfile.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/MailProfile.xml index 11a35c9c..a9c341e0 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/MailProfile.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/MailProfile.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/MailProfileAccounts.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/MailProfileAccounts.xml index 12d68088..3cffdcf5 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/MailProfileAccounts.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/MailProfileAccounts.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/MailProfilePrincipals.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/MailProfilePrincipals.xml index 362ff511..a4277441 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/MailProfilePrincipals.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/MailProfilePrincipals.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/MailServer.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/MailServer.xml index 379ebb73..4fe51cff 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/MailServer.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/MailServer.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/Mail_ErrorLog.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/Mail_ErrorLog.xml index 045497ee..7f2e1e8d 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/Mail_ErrorLog.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/Mail_ErrorLog.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/MaintSubPlanLog.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/MaintSubPlanLog.xml index 08469e7e..4b3b0987 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/MaintSubPlanLog.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/MaintSubPlanLog.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/MaintSubPlanLogDetail.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/MaintSubPlanLogDetail.xml index e7ef8ea5..74028b41 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/MaintSubPlanLogDetail.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/MaintSubPlanLogDetail.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/MaintenancePlan.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/MaintenancePlan.xml index 7b778ff0..c02c8bc2 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/MaintenancePlan.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/MaintenancePlan.xml @@ -1,5 +1,5 @@ - + @@ -15,11 +15,7 @@ s.version_build s.version_comments - - 0 - 0 - - + s.from_msx s.has_targets diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/MaintenancePlanDeprecated.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/MaintenancePlanDeprecated.xml index 7d6396c2..81538f20 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/MaintenancePlanDeprecated.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/MaintenancePlanDeprecated.xml @@ -1,5 +1,5 @@ - + @@ -12,7 +12,7 @@ s.max_history_rows s.remote_history_server s.max_remote_history_rows - + s.log_shipping diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/MaintenanceSubPlan.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/MaintenanceSubPlan.xml index a02ffc7d..f1627ca8 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/MaintenanceSubPlan.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/MaintenanceSubPlan.xml @@ -1,5 +1,5 @@ - + @@ -13,11 +13,7 @@ sp.subplan_description sp.job_id - - null - 0 - - + sp.msx_job_id sp.msx_plan diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/MasterKeyEncryption.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/MasterKeyEncryption.xml index 595afc4a..6bf74ec9 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/MasterKeyEncryption.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/MasterKeyEncryption.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/Member.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/Member.xml index 7fa2e2e9..b3956181 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/Member.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/Member.xml @@ -1,27 +1,7 @@ - - + + - - - - - - - - -create table #SmoMemberTemp -( - role_col sysname NOT NULL, - mem_col sysname NOT NULL, - id_col varbinary(85) -) -insert into #SmoMemberTemp (role_col, mem_col, id_col) exec master.dbo.sp_helpsrvrolemember - - -drop table #SmoMemberTemp - - - + @@ -63,10 +43,7 @@ drop table #SmoMemberTemp - - lgnmb.mem_col - - + p.name CASE p.type WHEN N'U' THEN 0 WHEN N'G' THEN 1 WHEN N'S' THEN 2 WHEN N'C' THEN 3 WHEN N'K' THEN 4 END diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NTGroup.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NTGroup.xml index 6d6d4619..fce2ce83 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NTGroup.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NTGroup.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NTLogin.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NTLogin.xml index 944daf03..e94f8aa8 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NTLogin.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NTLogin.xml @@ -1,5 +1,5 @@ - - + + create table #tmpntlogin ( [Account name] sysname NULL, Type sysname NULL, [Privilege] sysname NULL, [Mapped login name] sysname NULL, [Permission path] sysname NULL) diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/Application.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/Application.xml index 799e0c75..0cd86de6 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/Application.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/Application.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/ApplicationDatabaseFile.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/ApplicationDatabaseFile.xml index 09e097ff..56b8d3f6 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/ApplicationDatabaseFile.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/ApplicationDatabaseFile.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/ApplicationDatabaseFileGroup.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/ApplicationDatabaseFileGroup.xml index 1722801b..972461b1 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/ApplicationDatabaseFileGroup.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/ApplicationDatabaseFileGroup.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/ApplicationDatabaseLogFile.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/ApplicationDatabaseLogFile.xml index 96e85df2..16d41038 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/ApplicationDatabaseLogFile.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/ApplicationDatabaseLogFile.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/ApplicationDatabaseOptions.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/ApplicationDatabaseOptions.xml index f4478e57..8a1274e4 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/ApplicationDatabaseOptions.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/ApplicationDatabaseOptions.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/ContentFormatter.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/ContentFormatter.xml index 7ac4eb8e..63f7f902 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/ContentFormatter.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/ContentFormatter.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/ContentFormatterArgument.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/ContentFormatterArgument.xml index 9d87dad1..a4baaf20 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/ContentFormatterArgument.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/ContentFormatterArgument.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/DeliveryChannel.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/DeliveryChannel.xml index f52f85ce..bb9791a9 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/DeliveryChannel.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/DeliveryChannel.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/DeliveryChannelArgument.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/DeliveryChannelArgument.xml index bc51eaec..c8490985 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/DeliveryChannelArgument.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/DeliveryChannelArgument.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/Distributor.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/Distributor.xml index e7252a91..45959292 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/Distributor.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/Distributor.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/EventChronicle.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/EventChronicle.xml index 0a211a46..60d67fae 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/EventChronicle.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/EventChronicle.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/EventChronicleRule.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/EventChronicleRule.xml index 25f79ee3..28315742 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/EventChronicleRule.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/EventChronicleRule.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/EventClass.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/EventClass.xml index e8409639..d4d0509d 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/EventClass.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/EventClass.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/EventField.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/EventField.xml index 3419ba5d..82c813fa 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/EventField.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/EventField.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/Generator.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/Generator.xml index c5a8ac4e..02d306fa 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/Generator.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/Generator.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/HostedEventProvider.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/HostedEventProvider.xml index e67aa82f..1ec3feb8 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/HostedEventProvider.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/HostedEventProvider.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/HostedEventProviderArgument.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/HostedEventProviderArgument.xml index 9d8ec0c7..ac1d58f2 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/HostedEventProviderArgument.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/HostedEventProviderArgument.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/Instance.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/Instance.xml index a6eb8598..5269951f 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/Instance.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/Instance.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/InstanceDatabaseFile.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/InstanceDatabaseFile.xml index 65ec7e7e..baa46917 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/InstanceDatabaseFile.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/InstanceDatabaseFile.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/InstanceDatabaseFileGroup.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/InstanceDatabaseFileGroup.xml index 786682c1..26f7446a 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/InstanceDatabaseFileGroup.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/InstanceDatabaseFileGroup.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/InstanceDatabaseLogFile.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/InstanceDatabaseLogFile.xml index b2286333..f0b8e751 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/InstanceDatabaseLogFile.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/InstanceDatabaseLogFile.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/InstanceDatabaseOptions.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/InstanceDatabaseOptions.xml index 1c65e081..dc6f30f4 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/InstanceDatabaseOptions.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/InstanceDatabaseOptions.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/NonHostedEventProvider.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/NonHostedEventProvider.xml index 9a0a923e..3ceecebc 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/NonHostedEventProvider.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/NonHostedEventProvider.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/NotificationClass.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/NotificationClass.xml index 2b72ce76..7ae05df9 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/NotificationClass.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/NotificationClass.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/NotificationClassProtocol.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/NotificationClassProtocol.xml index 9ce4ef48..24cb3a7e 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/NotificationClassProtocol.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/NotificationClassProtocol.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/NotificationComputedField.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/NotificationComputedField.xml index 851e5734..a258d2d5 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/NotificationComputedField.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/NotificationComputedField.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/NotificationField.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/NotificationField.xml index e78869e7..3e57c09c 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/NotificationField.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/NotificationField.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/NotificationServices.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/NotificationServices.xml index 46ce1eb2..22e5df61 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/NotificationServices.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/NotificationServices.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/ProtocolDefinition.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/ProtocolDefinition.xml index 23c90f5f..88b3105a 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/ProtocolDefinition.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/ProtocolDefinition.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/ProtocolField.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/ProtocolField.xml index 26f6a484..77d7f88c 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/ProtocolField.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/ProtocolField.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/ProtocolRetrySchedule.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/ProtocolRetrySchedule.xml index 52c3ac67..34894ee7 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/ProtocolRetrySchedule.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/ProtocolRetrySchedule.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/SubscriptionChronicle.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/SubscriptionChronicle.xml index ce9e23bd..0a84a69e 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/SubscriptionChronicle.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/SubscriptionChronicle.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/SubscriptionClass.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/SubscriptionClass.xml index 9b7d158c..0520d672 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/SubscriptionClass.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/SubscriptionClass.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/SubscriptionConditionEventRule.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/SubscriptionConditionEventRule.xml index c95af4be..63d3f060 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/SubscriptionConditionEventRule.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/SubscriptionConditionEventRule.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/SubscriptionConditionScheduledRule.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/SubscriptionConditionScheduledRule.xml index 719cdb91..09bd6b4d 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/SubscriptionConditionScheduledRule.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/SubscriptionConditionScheduledRule.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/SubscriptionEventRule.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/SubscriptionEventRule.xml index 89e3357d..ae6d9cb3 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/SubscriptionEventRule.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/SubscriptionEventRule.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/SubscriptionField.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/SubscriptionField.xml index 4e53c68d..e62d9923 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/SubscriptionField.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/SubscriptionField.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/SubscriptionScheduledRule.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/SubscriptionScheduledRule.xml index 5100e573..e9962d03 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/SubscriptionScheduledRule.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/SubscriptionScheduledRule.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/VacuumSchedule.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/VacuumSchedule.xml index 979849e0..c678c6b9 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/VacuumSchedule.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NotificationServices/VacuumSchedule.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NumberedSPParams.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NumberedSPParams.xml index 415af640..619b99f3 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NumberedSPParams.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NumberedSPParams.xml @@ -1,14 +1,11 @@ - + - - - - + @@ -31,12 +28,7 @@ - - CASE param.isoutparam WHEN 1 THEN param.isoutparam WHEN 0 THEN CASE param.name WHEN '' THEN 1 ELSE 0 END END - - - + param.is_output diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NumberedStoredProcedure.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NumberedStoredProcedure.xml index 417b78a5..868197aa 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/NumberedStoredProcedure.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/NumberedStoredProcedure.xml @@ -1,14 +1,11 @@ - + - - nsp.colid = <msparam>1</msparam> and nsp.number > <msparam>1</msparam> - - + @@ -20,19 +17,7 @@ - - nsp.number - object_name(nsp.id) + ';' + cast(nsp.number as nvarchar(20)) - nsp.encrypted - - - - - - - - + nsp.procedure_number object_name(nsp.object_id) + ';' + cast(nsp.procedure_number as nvarchar(20)) CASE WHEN nsp.definition IS NULL THEN 1 ELSE 0 END diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/OLEDBProvProp.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/OLEDBProvProp.xml index 43bea0ae..d9dd12af 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/OLEDBProvProp.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/OLEDBProvProp.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/OLEDBProvider.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/OLEDBProvider.xml index b569b951..1d249af3 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/OLEDBProvider.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/OLEDBProvider.xml @@ -1,5 +1,5 @@ - - + + create table #OLEDBProv ( Name sysname NOT NULL, ParseName sysname NOT NULL,Description sysname NOT NULL ) insert #OLEDBProv EXECUTE master.dbo.xp_enum_oledb_providers diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/OLEDBProviderSetting.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/OLEDBProviderSetting.xml index 69d856a0..6498100e 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/OLEDBProviderSetting.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/OLEDBProviderSetting.xml @@ -1,5 +1,5 @@ - - + + - - -insert #OLEDBProv (Name, ParseName,Description) EXECUTE master.dbo.xp_enum_oledb_providers - - - + insert #OLEDBProv (Name, ParseName,Description) EXECUTE master.dbo.sp_enum_oledb_providers @@ -21,74 +16,7 @@ insert #OLEDBProv (Name, ParseName,Description) EXECUTE master.dbo.sp_enum_oledb delete from #OLEDBProv where exists ( select 1 from #OLEDBProv oprov where oprov.Name = #OLEDBProv.Name and oprov.id < #OLEDBProv.id ) - - -create table #oledbprop (allow_in_process bit, disallow_adhoc_access bit, dynamic_parameters bit, index_as_access_path bit, - level_zero_only bit, nested_queries bit, non_transacted_updates bit, sql_server_like bit, provider_name sysname null) - -declare name_cursor cursor local fast_forward - FOR (select Name from #OLEDBProv) -open name_cursor -DECLARE @providername sysname -FETCH NEXT FROM name_cursor INTO @providername -WHILE (@@FETCH_STATUS <> -1) -BEGIN - IF (@@FETCH_STATUS <> -2) - BEGIN - SELECT @providername = RTRIM(@providername) - - declare @regpath nvarchar(255) - set @regpath = N'SOFTWARE\Microsoft\MSSQLServer\Providers\' + @providername - - declare @allow_in_process int - declare @disallow_adhoc_access int - declare @dynamic_parameters int - declare @index_as_access_path int - declare @level_zero_only int - declare @nested_queries int - declare @non_transacted_updates int - declare @sql_server_like int - - - - - - exec master.dbo.xp_regread N'HKEY_LOCAL_MACHINE', @regpath, 'AllowInProcess', @allow_in_process OUTPUT - exec master.dbo.xp_regread N'HKEY_LOCAL_MACHINE', @regpath, 'DisallowAdHocAccess', @disallow_adhoc_access OUTPUT - exec master.dbo.xp_regread N'HKEY_LOCAL_MACHINE', @regpath, 'DynamicParameters', @dynamic_parameters OUTPUT - exec master.dbo.xp_regread N'HKEY_LOCAL_MACHINE', @regpath, 'IndexAsAccessPath', @index_as_access_path OUTPUT - exec master.dbo.xp_regread N'HKEY_LOCAL_MACHINE', @regpath, 'LevelZeroOnly', @level_zero_only OUTPUT - exec master.dbo.xp_regread N'HKEY_LOCAL_MACHINE', @regpath, 'NestedQueries', @nested_queries OUTPUT - exec master.dbo.xp_regread N'HKEY_LOCAL_MACHINE', @regpath, 'NonTransactedUpdates', @non_transacted_updates OUTPUT - exec master.dbo.xp_regread N'HKEY_LOCAL_MACHINE', @regpath, 'SqlServerLIKE', @sql_server_like OUTPUT - - - - - exec master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE', @regpath, 'AllowInProcess', @allow_in_process OUTPUT - exec master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE', @regpath, 'DisallowAdHocAccess', @disallow_adhoc_access OUTPUT - exec master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE', @regpath, 'DynamicParameters', @dynamic_parameters OUTPUT - exec master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE', @regpath, 'IndexAsAccessPath', @index_as_access_path OUTPUT - exec master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE', @regpath, 'LevelZeroOnly', @level_zero_only OUTPUT - exec master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE', @regpath, 'NestedQueries', @nested_queries OUTPUT - exec master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE', @regpath, 'NonTransactedUpdates', @non_transacted_updates OUTPUT - exec master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE', @regpath, 'SqlServerLIKE', @sql_server_like OUTPUT - - - - - insert #oledbprop (allow_in_process, disallow_adhoc_access, dynamic_parameters, index_as_access_path, level_zero_only, - nested_queries, non_transacted_updates, sql_server_like, provider_name) - select IsNull(@allow_in_process, 0), IsNull(@disallow_adhoc_access, 0), IsNull(@dynamic_parameters, 0), IsNull(@index_as_access_path, 0), IsNull(@level_zero_only, 0), - IsNull(@nested_queries, 0), IsNull(@non_transacted_updates, 0), IsNull(@sql_server_like, 0), @providername - END - FETCH NEXT FROM name_cursor INTO @providername -END -CLOSE name_cursor -DEALLOCATE name_cursor - - - + create table #oledbprop (allow_in_process bit, disallow_adhoc_access bit, dynamic_parameters bit, index_as_access_path bit, level_zero_only bit, nested_queries bit, non_transacted_updates bit, sql_server_like bit, provider_name sysname null) diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/OperatorJobNotification.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/OperatorJobNotification.xml index 6a27eb3e..2ee826a7 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/OperatorJobNotification.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/OperatorJobNotification.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/OperatorNotification.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/OperatorNotification.xml index ca2dcbcb..933a0809 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/OperatorNotification.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/OperatorNotification.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/OrderColumn.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/OrderColumn.xml index cfec44f8..d921ba2b 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/OrderColumn.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/OrderColumn.xml @@ -1,5 +1,5 @@ - + @@ -15,4 +15,3 @@ - diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/PartitionFunction.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/PartitionFunction.xml index a85a674b..7337c181 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/PartitionFunction.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/PartitionFunction.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/PartitionFunctionParameter.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/PartitionFunctionParameter.xml index d53bd502..8b48b83c 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/PartitionFunctionParameter.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/PartitionFunctionParameter.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/PartitionFunctionRangeValue.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/PartitionFunctionRangeValue.xml index df4bf8c9..1cdfe1e6 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/PartitionFunctionRangeValue.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/PartitionFunctionRangeValue.xml @@ -1,5 +1,5 @@ - + @@ -11,4 +11,3 @@ sprv.value - diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/PartitionScheme.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/PartitionScheme.xml index ac7500b0..5aae162e 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/PartitionScheme.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/PartitionScheme.xml @@ -1,5 +1,5 @@ - + - diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ResourcePoolAffinityInfo.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ResourcePoolAffinityInfo.xml index 8d348701..3476d975 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ResourcePoolAffinityInfo.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ResourcePoolAffinityInfo.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ResourcePoolScheduler.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ResourcePoolScheduler.xml index c574b9ac..c8ef0139 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ResourcePoolScheduler.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ResourcePoolScheduler.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/Rule.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/Rule.xml index 263267c4..df70c358 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/Rule.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/Rule.xml @@ -1,10 +1,7 @@ - + - - obj.xtype=N'R' - - + obj.type=N'R' and (0 = obj.parent_object_id or obj.parent_object_id is null) @@ -12,10 +9,6 @@ - - - - diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/RuleColumn.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/RuleColumn.xml index b97674c7..406ff91f 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/RuleColumn.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/RuleColumn.xml @@ -1,22 +1,15 @@ - + - - - - + - - - - - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/RuleDatatype.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/RuleDatatype.xml index f762b566..524b53d9 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/RuleDatatype.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/RuleDatatype.xml @@ -1,21 +1,15 @@ - + - - - - + - - - - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/SPParams.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/SPParams.xml index 9b0ef72d..d9b6ae06 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/SPParams.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/SPParams.xml @@ -1,24 +1,17 @@ - + - - param.number = <msparam>1</msparam> - - + - - CASE param.isoutparam WHEN 1 THEN param.isoutparam WHEN 0 THEN CASE param.name WHEN '' THEN 1 ELSE 0 END END - - + param.is_output param.is_cursor_ref @@ -27,7 +20,8 @@ - ISNULL(param.vector_dimensions, 0) + + ISNULL(param.vector_dimensions, 0) ISNULL(param.vector_base_type_desc, N'') diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/SPPerm.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/SPPerm.xml index 326a8e10..dc6fda4d 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/SPPerm.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/SPPerm.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/Schema.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/Schema.xml index 08701ec7..9f0c8eca 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/Schema.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/Schema.xml @@ -1,5 +1,5 @@ - + dp1.principal_id = s.principal_id diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/SearchProperty.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/SearchProperty.xml index 2b0d3f01..20c170cd 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/SearchProperty.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/SearchProperty.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/SearchPropertyList.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/SearchPropertyList.xml index a37c62cd..d3295427 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/SearchPropertyList.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/SearchPropertyList.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/SecurityPolicy.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/SecurityPolicy.xml index abbbccb1..422636c9 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/SecurityPolicy.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/SecurityPolicy.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/SecurityPredicate.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/SecurityPredicate.xml index 016d041c..6a31d24d 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/SecurityPredicate.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/SecurityPredicate.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/SensitivityClassification.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/SensitivityClassification.xml index 7387d996..ab67e1b0 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/SensitivityClassification.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/SensitivityClassification.xml @@ -1,6 +1,6 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ServerAuditSpecification.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ServerAuditSpecification.xml index 05d046b0..e19ff2a7 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ServerAuditSpecification.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ServerAuditSpecification.xml @@ -1,5 +1,5 @@ - - + + sas.audit_guid = au.audit_guid diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ServerAuditSpecificationDetail.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ServerAuditSpecificationDetail.xml index a0094cf8..d111dc30 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ServerAuditSpecificationDetail.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ServerAuditSpecificationDetail.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ServerDdlTrigger.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ServerDdlTrigger.xml index 607c82de..8fc521e5 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ServerDdlTrigger.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ServerDdlTrigger.xml @@ -1,8 +1,8 @@ - + tr.parent_class = 100 - mod.object_id = tr.object_id am2tr.object_id = tr.object_id diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ServerDdlTriggerEvent.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ServerDdlTriggerEvent.xml index 65241309..63668937 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ServerDdlTriggerEvent.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ServerDdlTriggerEvent.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ServerProxyAccount.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ServerProxyAccount.xml index fd98871c..f29b5305 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ServerProxyAccount.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ServerProxyAccount.xml @@ -1,29 +1,7 @@ - + - - @account_name is not null - - declare @SysAdminOnly int - exec master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'SOFTWARE\Microsoft\MSSQLServer\SQLServerAgent', N'SysAdminOnly', @SysAdminOnly OUTPUT - set @SysAdminOnly = (case when 0 = @SysAdminOnly then 1 else 0 end) - - -create table #tmpProxyAccountName ( domain sysname, username sysname) -insert into #tmpProxyAccountName exec master.dbo.xp_sqlagent_proxy_account N'GET' - -declare @account_name nvarchar(255) -set @account_name = (select domain + N'\' + username as [UserName] from #tmpProxyAccountName) -if (@account_name is null) -begin - set @account_name=N'' -end - - -drop table #tmpProxyAccountName - - - + @account_name is not null declare @SysAdminOnly int diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ServerRole.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ServerRole.xml index 905eb2b4..8a388211 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/ServerRole.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/ServerRole.xml @@ -1,12 +1,7 @@ - + - - - v1.low=0 and v1.type='SRV' - - - + r.type ='R' v1.name = r.name and v1.low = 0 @@ -23,12 +18,7 @@ - - v1.name - v2.name - - - + r.name r.principal_id N'' diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/Settings.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/Settings.xml index 9abc9299..540f4b78 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/Settings.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/Settings.xml @@ -1,53 +1,10 @@ - + - - - declare @NumErrorLogs int - exec master.dbo.xp_regread N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'NumErrorLogs', @NumErrorLogs OUTPUT - - - declare @SmoDefaultFile nvarchar(512) - exec master.dbo.xp_regread N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'DefaultData', @SmoDefaultFile OUTPUT - - - declare @SmoDefaultLog nvarchar(512) - exec master.dbo.xp_regread N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'DefaultLog', @SmoDefaultLog OUTPUT - - - declare @SmoLoginMode int - exec master.dbo.xp_regread N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'LoginMode', @SmoLoginMode OUTPUT - - - declare @SmoAuditLevel int - exec master.dbo.xp_regread N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'AuditLevel', @SmoAuditLevel OUTPUT - - - declare @SmoTapeLoadWaitTime int - exec master.dbo.xp_regread N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'Tapeloadwaittime', @SmoTapeLoadWaitTime OUTPUT - - - declare @BackupDirectory nvarchar(512) - exec master.dbo.xp_regread N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'BackupDirectory', @BackupDirectory OUTPUT - - - declare @SmoMailProfile nvarchar(512) - exec master.dbo.xp_regread N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'MailAccountName', @SmoMailProfile OUTPUT - - - declare @SmoPerfMonMode int - exec master.dbo.xp_regread N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'Performance', @SmoPerfMonMode OUTPUT - - if @SmoPerfMonMode is null - begin - set @SmoPerfMonMode = 1000 - end - - - + declare @NumErrorLogs int exec master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'NumErrorLogs', @NumErrorLogs OUTPUT @@ -81,13 +38,7 @@ end - - - declare @SmoTapeLoadWaitTime int - exec master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'Tapeloadwaittime', @SmoTapeLoadWaitTime OUTPUT - - - + declare @SmoDefaultFile nvarchar(512) exec master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'DefaultData', @SmoDefaultFile OUTPUT @@ -116,7 +67,7 @@ @SmoAuditLevel ISNULL(@NumErrorLogs, -1) (case when @SmoLoginMode < 3 then @SmoLoginMode else 9 end) - + ISNULL(@SmoDefaultFile,N'') ISNULL(@SmoDefaultLog,N'') @@ -125,9 +76,6 @@ SERVERPROPERTY('instancedefaultlogpath') ISNULL(@ErrorLogSizeKb, 0) - - @SmoTapeLoadWaitTime - -1 diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/SmartAdmin.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/SmartAdmin.xml index fdedef35..3e188cb0 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/SmartAdmin.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/SmartAdmin.xml @@ -1,12 +1,11 @@ - + (SELECT ISNULL(msdb.smart_admin.fn_is_master_switch_on (), 0)) - ISNULL(msdb.smart_admin.fn_is_master_switch_on (), 0) ISNULL(ic.is_managed_backup_enabled, 0) ISNULL(ic.credential_name, N'') ISNULL(ic.retention_days, 0) diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/SqlAssembly.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/SqlAssembly.xml index ce281eaa..624c52cb 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/SqlAssembly.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/SqlAssembly.xml @@ -1,5 +1,5 @@ - + princip.principal_id = asmbl.principal_id diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/SqlAssemblyFile.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/SqlAssemblyFile.xml index f72fa15f..8f60c68b 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/SqlAssemblyFile.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/SqlAssemblyFile.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/SqlBoot.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/SqlBoot.xml index e5cfae19..9f8d6b0d 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/SqlBoot.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/SqlBoot.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/StatisticColumn.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/StatisticColumn.xml index b4d1b76f..43c9f433 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/StatisticColumn.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/StatisticColumn.xml @@ -1,30 +1,17 @@ - + - - - - clmns.id = c.id and clmns.colid = c.colid - - - + - - clmns.name - c.keyno - - - - - + COL_NAME(sic.object_id, sic.column_id) sic.stats_column_id diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/StoredProcedure.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/StoredProcedure.xml index cf1f97fc..283bed85 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/StoredProcedure.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/StoredProcedure.xml @@ -1,10 +1,7 @@ - + - - sp.xtype = <msparam>P</msparam> OR sp.xtype = <msparam>RF</msparam> - - + sp.type = <msparam>P</msparam> OR sp.type = <msparam>RF</msparam> OR sp.type=<msparam>PC</msparam> spp.object_id = sp.object_id sm.object_id = sp.object_id @@ -15,21 +12,11 @@ - - OBJECTPROPERTY(sp.id, N'ExecIsStartup') - CASE sp.xtype WHEN N'RF' THEN 1 ELSE 0 END - 1 - - - - - - - + ISNULL(spp.is_auto_executed,0) CASE WHEN sp.type = N'P' THEN 1 WHEN sp.type = N'PC' THEN 2 ELSE 1 END - + CASE sp.type WHEN N'RF' THEN 1 ELSE 0 END diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/SymmetricKey.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/SymmetricKey.xml index 2df783e3..c2966721 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/SymmetricKey.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/SymmetricKey.xml @@ -1,5 +1,5 @@ - + c.symmetric_key_id <> 101 ok.key_id=c.symmetric_key_id and ok.database_id=db_id() diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/TablePerm.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/TablePerm.xml index 4d3c8eef..48504f63 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/TablePerm.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/TablePerm.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/TapeDevice.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/TapeDevice.xml index 30b98a6f..f3bc4009 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/TapeDevice.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/TapeDevice.xml @@ -1,5 +1,5 @@ - + create table #tpdv ( Name nvarchar(512) NOT NULL) insert #tpdv (Name) EXECUTE master.dbo.xp_get_tape_devices diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/Text.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/Text.xml index 3b7ba45d..5b4c58c1 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/Text.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/Text.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/UDF.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/UDF.xml index 3d9fa7fd..b17e96cf 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/UDF.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/UDF.xml @@ -1,12 +1,7 @@ - + - - udf.xtype in ( 'TF', 'FN', 'IF') and udf.name not like N'#%%' - ret_param.id = udf.id and ret_param.number = <msparam>0</msparam> and ret_param.name='' - - + - - - + OBJECTPROPERTYEX(udf.object_id, N'IsDeterministic') (case when 'FN' = udf.type then 1 when 'FS' = udf.type then 1 when 'IF' = udf.type then 3 when 'TF' = udf.type then 2 when 'FT' = udf.type then 2 else 0 end) CASE WHEN udf.type IN ('FN','IF','TF') THEN 1 WHEN udf.type IN ('FS','FT') THEN 2 ELSE 1 END @@ -53,7 +39,7 @@ - + 0 @@ -64,7 +50,8 @@ ISNULL(sm.is_inlineable,0) - ISNULL(ret_param.vector_dimensions, 0) + + ISNULL(ret_param.vector_dimensions, 0) ISNULL(ret_param.vector_base_type_desc, N'') diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/UDFParams.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/UDFParams.xml index d93d0c35..4abadd49 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/UDFParams.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/UDFParams.xml @@ -1,14 +1,11 @@ - + - - param.number = 1 or (param.number = 0 and 1 = OBJECTPROPERTY(param.id, N'IsScalarFunction') and isnull(param.name, '') != '') - - + param.is_output = 0 @@ -18,7 +15,8 @@ param.is_readonly - ISNULL(param.vector_dimensions, 0) + + ISNULL(param.vector_dimensions, 0) ISNULL(param.vector_base_type_desc, N'') diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/UserDefinedAggregate.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/UserDefinedAggregate.xml index 9d192991..8bd26dc2 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/UserDefinedAggregate.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/UserDefinedAggregate.xml @@ -1,5 +1,5 @@ - + obj.type=N'AF' am.object_id = obj.object_id @@ -10,7 +10,7 @@ - + asmbl.name am.assembly_class diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/UserDefinedAggregateParameter.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/UserDefinedAggregateParameter.xml index d0850ff0..f9b6a367 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/UserDefinedAggregateParameter.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/UserDefinedAggregateParameter.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/UserDefinedTableType.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/UserDefinedTableType.xml index 9735e424..2f05f32c 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/UserDefinedTableType.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/UserDefinedTableType.xml @@ -1,5 +1,5 @@ - + obj.object_id = tt.type_table_object_id diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/UserDefinedType.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/UserDefinedType.xml index a73785b6..dfdf3d0d 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/UserDefinedType.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/UserDefinedType.xml @@ -1,5 +1,5 @@ - + (asmbl.assembly_id = atypes.assembly_id) and (atypes.is_user_defined = 1) diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/UserMessage.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/UserMessage.xml index 1d109976..71a4def0 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/UserMessage.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/UserMessage.xml @@ -1,27 +1,14 @@ - + - - sms.error > 50000 - sms.msglangid = sl.lcid - - + sms.message_id > 50000 sms.language_id = sl.lcid - - sms.error - sms.dlevel - sms.severity - sms.description - sms.msglangid - sl.name - - - + sms.message_id sms.is_event_logged sms.severity @@ -31,5 +18,3 @@ - - diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/UserOption.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/UserOption.xml index 7136fadc..529313ad 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/UserOption.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/UserOption.xml @@ -1,13 +1,7 @@ - - + + - - - declare @UserOption int - select @UserOption=c.value from master.dbo.sysconfigures c, master.dbo.spt_values v where v.type = 'C ' and not c.status is null and v.number = c.config and v.name='user options' - - - + declare @UserOption int select @UserOption=convert(int, c.value) from sys.configurations c where c.name='user options' diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/WorkloadGroup.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/WorkloadGroup.xml index 77961934..7463acfe 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/WorkloadGroup.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/WorkloadGroup.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/WorkloadManagementWorkloadClassifier.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/WorkloadManagementWorkloadClassifier.xml index 0d5fe47d..702cee7a 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/WorkloadManagementWorkloadClassifier.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/WorkloadManagementWorkloadClassifier.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/WorkloadManagementWorkloadGroup.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/WorkloadManagementWorkloadGroup.xml index 153c8cc3..95afecc3 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/WorkloadManagementWorkloadGroup.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/WorkloadManagementWorkloadGroup.xml @@ -1,5 +1,5 @@ - - + + wkg.name = wkc.group_name diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/XStoredProcedure.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/XStoredProcedure.xml index edbfae34..63ecb15d 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/XStoredProcedure.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/XStoredProcedure.xml @@ -1,16 +1,13 @@ - + - - xproc.xtype='X' - - + xproc.type='X' ep.object_id = xproc.object_id - > + @@ -18,13 +15,6 @@ - - - - - - - ISNULL(ep.dll_name,N'') diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/XmlNamespace.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/XmlNamespace.xml index e8d70c05..41608117 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/XmlNamespace.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/XmlNamespace.xml @@ -1,5 +1,5 @@ - + @@ -20,4 +20,3 @@ - diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/XmlSchemaCollection.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/XmlSchemaCollection.xml index 6f0b73e2..b28dd990 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/XmlSchemaCollection.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/XmlSchemaCollection.xml @@ -1,5 +1,5 @@ - + xsc.schema_id <> 4 @@ -25,4 +25,3 @@ - diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/Yukonuserownedobject.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/Yukonuserownedobject.xml index 410f591e..4c8cf414 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/Yukonuserownedobject.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/Yukonuserownedobject.xml @@ -1,67 +1,6 @@ - - - - - - - - - ownobj.type not in ( 'K', 'S' ) - ownobj_parent.id = ownobj.parent_obj - - - - - null - - - - - - - - - - - - - - - - - - - - - - - - - - - - null - - - - - - - - - - - - - - - - - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/YukonuserownedobjectSchema.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/YukonuserownedobjectSchema.xml index c9dfc671..955b6baa 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/YukonuserownedobjectSchema.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/YukonuserownedobjectSchema.xml @@ -1,5 +1,5 @@ - + @@ -7,7 +7,7 @@ - + ownobj.type not in ('PK', 'C ', 'F ', 'UQ') and ( ownobj.type != 'D' or 0 = ownobj.parent_object_id) diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_ErrorLog.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_ErrorLog.xml index 69a1ec5b..e4ff3bd6 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_ErrorLog.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_ErrorLog.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_ErrorLogText.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_ErrorLogText.xml index b6a80ec3..39852bbc 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_ErrorLogText.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_ErrorLogText.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_alert.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_alert.xml index d6dd5527..9cec04c9 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_alert.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_alert.xml @@ -1,15 +1,8 @@ - + - - - create table #tmp_sp_help_alert - (id int null, name nvarchar(128) null, event_source nvarchar(100) null, event_category_id int null, event_id int null, message_id int null, severity int null, enabled tinyint null, delay_between_responses int null, last_occurrence_date int null, last_occurrence_time int null, last_response_date int null, last_response_time int null, notification_message nvarchar(512) null, include_event_description tinyint null, database_name nvarchar(128) null, event_description_keyword nvarchar(100) null, occurrence_count int null, count_reset_date int null, count_reset_time int null, job_id uniqueidentifier null, job_name nvarchar(128) null, has_notification int null, flags int null, performance_condition nvarchar(512) null, category_name nvarchar(128) null, type int null) - insert into #tmp_sp_help_alert exec msdb.dbo.sp_help_alert - - - + create table #tmp_sp_help_alert (id int null, name nvarchar(128) null, event_source nvarchar(100) null, event_category_id int null, event_id int null, message_id int null, severity int null, enabled tinyint null, delay_between_responses int null, last_occurrence_date int null, last_occurrence_time int null, last_response_date int null, last_response_time int null, notification_message nvarchar(512) null, include_event_description tinyint null, database_name nvarchar(128) null, event_description_keyword nvarchar(100) null, occurrence_count int null, count_reset_date int null, count_reset_time int null, job_id uniqueidentifier null, job_name nvarchar(128) null, has_notification int null, flags int null, performance_condition nvarchar(512) null, category_name nvarchar(128) null, wmi_namespace nvarchar(max) null, wmi_query nvarchar(max) null, type int null) @@ -57,7 +50,7 @@ drop table #tmp_sp_help_alert ISNULL(tsha.performance_condition,N'') ISNULL(tsha.category_name,N'') - + ISNULL(tsha.wmi_namespace,N'') ISNULL(tsha.wmi_query,N'') diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_alert_categories.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_alert_categories.xml index f2dfa415..061af62d 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_alert_categories.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_alert_categories.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_alertsystem.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_alertsystem.xml index 241bad38..789362a7 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_alertsystem.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_alertsystem.xml @@ -1,7 +1,7 @@ - + - + declare @FailSafeOperator nvarchar(255) exec master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'SOFTWARE\Microsoft\MSSQLServer\SQLServerAgent', N'AlertFailSafeOperator', @param = @FailSafeOperator OUT, @no_output = N'no_output' @@ -51,57 +51,7 @@ exec master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'SOFTWARE\Microsoft\MSSQLServer\SQLServerAgent', N'AlertFailSafeNetSendAddress', @param = @FailSafeNetSendAddress OUT, @no_output = N'no_output' - - - declare @FailSafeOperator nvarchar(255) - exec master.dbo.xp_regread N'HKEY_LOCAL_MACHINE', N'SOFTWARE\Microsoft\MSSQLServer\SQLServerAgent', N'AlertFailSafeOperator', @param = @FailSafeOperator OUT, @no_output = N'no_output' - - - declare @NotificationMethod int - exec master.dbo.xp_regread N'HKEY_LOCAL_MACHINE', N'SOFTWARE\Microsoft\MSSQLServer\SQLServerAgent', N'AlertNotificationMethod', @param = @NotificationMethod OUT, @no_output = N'no_output' - - - declare @ForwardingServer nvarchar(255) - exec master.dbo.xp_regread N'HKEY_LOCAL_MACHINE', N'SOFTWARE\Microsoft\MSSQLServer\SQLServerAgent', N'AlertForwardingServer', @param = @ForwardingServer OUT, @no_output = N'no_output' - - - declare @ForwardingSeverity int - exec master.dbo.xp_regread N'HKEY_LOCAL_MACHINE', N'SOFTWARE\Microsoft\MSSQLServer\SQLServerAgent', N'AlertForwardingSeverity', @param = @ForwardingSeverity OUT, @no_output = N'no_output' - - - declare @ForwardAlways int - exec master.dbo.xp_regread N'HKEY_LOCAL_MACHINE', N'SOFTWARE\Microsoft\MSSQLServer\SQLServerAgent', N'AlertForwardAlways', @param = @ForwardAlways OUT, @no_output = N'no_output' - - - declare @PagerToTemplate nvarchar(255) - exec master.dbo.xp_regread N'HKEY_LOCAL_MACHINE', N'SOFTWARE\Microsoft\MSSQLServer\SQLServerAgent', N'AlertPagerToTemplate', @param = @PagerToTemplate OUT, @no_output = N'no_output' - - - declare @PagerCCTemplate nvarchar(255) - exec master.dbo.xp_regread N'HKEY_LOCAL_MACHINE', N'SOFTWARE\Microsoft\MSSQLServer\SQLServerAgent', N'AlertPagerCCTemplate', @param = @PagerCCTemplate OUT, @no_output = N'no_output' - - - declare @PagerSubjectTemplate nvarchar(255) - exec master.dbo.xp_regread N'HKEY_LOCAL_MACHINE', N'SOFTWARE\Microsoft\MSSQLServer\SQLServerAgent', N'AlertPagerSubjectTemplate', @param = @PagerSubjectTemplate OUT, @no_output = N'no_output' - - - declare @PagerSendSubjectOnly int - exec master.dbo.xp_regread N'HKEY_LOCAL_MACHINE', N'SOFTWARE\Microsoft\MSSQLServer\SQLServerAgent', N'AlertPagerSendSubjectOnly', @param = @PagerSendSubjectOnly OUT, @no_output = N'no_output' - - - declare @FailSafeEmailAddress nvarchar(255) - exec master.dbo.xp_regread N'HKEY_LOCAL_MACHINE', N'SOFTWARE\Microsoft\MSSQLServer\SQLServerAgent', N'AlertFailSafeEmailAddress', @param = @FailSafeEmailAddress OUT, @no_output = N'no_output' - - - declare @FailSafePagerAddress nvarchar(255) - exec master.dbo.xp_regread N'HKEY_LOCAL_MACHINE', N'SOFTWARE\Microsoft\MSSQLServer\SQLServerAgent', N'AlertFailSafePagerAddress', @param = @FailSafePagerAddress OUT, @no_output = N'no_output' - - - declare @FailSafeNetSendAddress nvarchar(255) - exec master.dbo.xp_regread N'HKEY_LOCAL_MACHINE', N'SOFTWARE\Microsoft\MSSQLServer\SQLServerAgent', N'AlertFailSafeNetSendAddress', @param = @FailSafeNetSendAddress OUT, @no_output = N'no_output' - - - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_job_categories.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_job_categories.xml index 20e8109d..ba712c01 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_job_categories.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_job_categories.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_jobalert.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_jobalert.xml index 92203516..d882f0e7 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_jobalert.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_jobalert.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_jobhistory.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_jobhistory.xml index 9a6ae445..76b333ff 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_jobhistory.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_jobhistory.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_jobschedule.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_jobschedule.xml index 8cc18d6f..0a87e50e 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_jobschedule.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_jobschedule.xml @@ -1,5 +1,5 @@ - + @@ -10,7 +10,7 @@ tshj.schedule_id = sslv.schedule_id - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_operator.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_operator.xml index b7f5accf..ed03a149 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_operator.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_operator.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_operator_categories.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_operator_categories.xml index 9edd3f48..b919b325 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_operator_categories.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_operator_categories.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_targetserver.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_targetserver.xml index 0455d290..e707b57b 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_targetserver.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_targetserver.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_targetservergroup.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_targetservergroup.xml index 5eeb1f61..0ea58104 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_targetservergroup.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_targetservergroup.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_targetservermember.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_targetservermember.xml index 16b629a6..82c46536 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_targetservermember.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/agent_targetservermember.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/backupfile.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/backupfile.xml index 759d66c8..00fa687a 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/backupfile.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/backupfile.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/backupmediafamily.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/backupmediafamily.xml index 94d57735..f5aa05f3 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/backupmediafamily.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/backupmediafamily.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/backupmediaset.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/backupmediaset.xml index 3745a3d3..9d91351a 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/backupmediaset.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/backupmediaset.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/backupset.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/backupset.xml index 2133cb2e..71f5de8e 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/backupset.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/backupset.xml @@ -1,5 +1,5 @@ - + @@ -40,13 +40,13 @@ bkps.database_name bkps.server_name bkps.machine_name - + bkps.flags bkps.unicode_locale bkps.unicode_compare_style bkps.collation_name - + bkps.is_damaged bkps.is_copy_only bkps.is_snapshot diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/certificate.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/certificate.xml index dceb7c4b..876b9965 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/certificate.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/certificate.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/check.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/check.xml index 63c2fcea..2bf91865 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/check.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/check.xml @@ -1,13 +1,10 @@ - - + + - - cstr.type = 'C' - - + @@ -19,10 +16,7 @@ - - - - + CASE WHEN filetableobj.object_id IS NULL THEN 0 ELSE 1 END diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/clusterSubnet.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/clusterSubnet.xml index 7ae4173d..b92ffa24 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/clusterSubnet.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/clusterSubnet.xml @@ -1,5 +1,5 @@ - + @@ -14,4 +14,3 @@ - diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/collation.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/collation.xml index a65f8553..5903b03d 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/collation.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/collation.xml @@ -1,10 +1,7 @@ - - + + - - - - + @@ -16,7 +13,7 @@ COLLATIONPROPERTY(name, 'ComparisonStyle') cl.description - + COLLATIONPROPERTY(name, 'Version') diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/column.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/column.xml index 18f06328..cd3b76b5 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/column.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/column.xml @@ -1,19 +1,10 @@ - + - - - ik.id = clmns.id and 0 != ik.status & 0x0800 - cik.indid = ik.indid and cik.colid = clmns.colid and cik.id = clmns.id - d.id = clmns.cdefault and 0=d.category & 0x0800 - r.id = clmns.domain - dc.xtype='D' and dc.name not like N'#%%' and 0!=convert(bit,cstr.category & 0x0800) - - - + ic.object_id = clmns.object_id and ic.column_id = clmns.column_id cc.object_id = clmns.object_id and cc.column_id = clmns.column_id @@ -43,88 +34,7 @@ - - clmns.name - clmns.colid - - clmns.isnullable - clmns.iscomputed - ISNULL(cik.colid, 0) - ISNULL(COLUMNPROPERTY(clmns.id, clmns.name, N'UsesAnsiTrim'),0) - clmns.colstat & 2 - clmns.colstat & 8 - COLUMNPROPERTY(clmns.id, clmns.name, N'IsFulltextIndexed') - cast(clmns.id as nvarchar(20)) + '_' + cast(clmns.colid as nvarchar(20)) + '_' + cast(db_id() as nvarchar(20)) + '_0' - COLUMNPROPERTY(clmns.id, clmns.name, N'IsIdentity') - ISNULL((select top 1 1 from dbo.sysforeignkeys AS colfk where colfk.fkey = clmns.colid and colfk.fkeyid = clmns.id), 0) - - ISNULL(clmns.collation, N'') - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (case when clmns.cdefault = 0 then N'' else d.name end) - (case when clmns.cdefault = 0 then N'' else user_name(d.uid) end) - - ISNULL(dc.Name, N'') - - (case when clmns.domain = 0 then N'' else r.name end) - (case when clmns.domain = 0 then N'' else user_name(r.uid) end) - - - - - - + clmns.name clmns.column_id @@ -155,25 +65,19 @@ (case when clmns.rule_object_id = 0 then N'' else r.name end) (case when clmns.rule_object_id = 0 then N'' else schema_name(r.schema_id) end) - + ISNULL(COLUMNPROPERTY(clmns.object_id, clmns.name, N'IsDeterministic'),0) ISNULL(COLUMNPROPERTY(clmns.object_id, clmns.name, N'IsPrecise'),0) - + ISNULL(ic.is_not_for_replication, 0) - + COLUMNPROPERTY(clmns.object_id, clmns.name, N'IsFulltextIndexed') COLUMNPROPERTY(clmns.object_id, clmns.name, N'StatisticalSemantics') - - - - - - clmns.encryption_type @@ -199,19 +103,6 @@ - - - - - - + 0 @@ -307,7 +198,8 @@ - ISNULL(clmns.vector_dimensions, 0) + + ISNULL(clmns.vector_dimensions, 0) ISNULL(clmns.vector_base_type_desc, N'') diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/edgeconstraint.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/edgeconstraint.xml index 71aa8fbe..cae6a531 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/edgeconstraint.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/edgeconstraint.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/edgeconstraintclause.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/edgeconstraintclause.xml index 87cfd946..f3dff4fc 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/edgeconstraintclause.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/edgeconstraintclause.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/endpoint/database_mirroring_endpoint.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/endpoint/database_mirroring_endpoint.xml index 7a977387..73c2a755 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/endpoint/database_mirroring_endpoint.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/endpoint/database_mirroring_endpoint.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/endpoint/endpoint.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/endpoint/endpoint.xml index 6e82e77c..0cbed886 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/endpoint/endpoint.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/endpoint/endpoint.xml @@ -1,5 +1,5 @@ - + sp.principal_id = e.principal_id diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/endpoint/http_endpoint.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/endpoint/http_endpoint.xml index f4c3585a..080508c9 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/endpoint/http_endpoint.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/endpoint/http_endpoint.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/endpoint/service_broker_endpoint.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/endpoint/service_broker_endpoint.xml index 3d9984c4..c6674f81 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/endpoint/service_broker_endpoint.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/endpoint/service_broker_endpoint.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/endpoint/soap_endpoint.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/endpoint/soap_endpoint.xml index fab1dccc..0b0802f0 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/endpoint/soap_endpoint.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/endpoint/soap_endpoint.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/endpoint/soap_endpoint_method.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/endpoint/soap_endpoint_method.xml index 26e2780f..330eaba2 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/endpoint/soap_endpoint_method.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/endpoint/soap_endpoint_method.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/endpoint/tcp_endpoint.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/endpoint/tcp_endpoint.xml index 8a9d3990..216fb52d 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/endpoint/tcp_endpoint.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/endpoint/tcp_endpoint.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/endpoint/via_endpoint.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/endpoint/via_endpoint.xml index 447f47fb..fc58dff8 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/endpoint/via_endpoint.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/endpoint/via_endpoint.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/extendedproperty/ExtendedProperty.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/extendedproperty/ExtendedProperty.xml index 8ec59ba0..a534db3e 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/extendedproperty/ExtendedProperty.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/extendedproperty/ExtendedProperty.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/extendedproperty/Level0ExtendedProperty.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/extendedproperty/Level0ExtendedProperty.xml index 87bdec4a..d52b70cb 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/extendedproperty/Level0ExtendedProperty.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/extendedproperty/Level0ExtendedProperty.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/extendedproperty/Level1ExtendedProperty.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/extendedproperty/Level1ExtendedProperty.xml index 101f8947..41b896ed 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/extendedproperty/Level1ExtendedProperty.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/extendedproperty/Level1ExtendedProperty.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/extendedproperty/Level2ExtendedProperty.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/extendedproperty/Level2ExtendedProperty.xml index 48030546..651e7ed7 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/extendedproperty/Level2ExtendedProperty.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/extendedproperty/Level2ExtendedProperty.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/extendedproperty/Level2IndexExtendedProperty.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/extendedproperty/Level2IndexExtendedProperty.xml index 479c7da8..8475c50b 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/extendedproperty/Level2IndexExtendedProperty.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/extendedproperty/Level2IndexExtendedProperty.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/extendedproperty/inc_level2SupportProperties.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/extendedproperty/inc_level2SupportProperties.xml index 034ad916..0f6d823e 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/extendedproperty/inc_level2SupportProperties.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/extendedproperty/inc_level2SupportProperties.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/extendedproperty/inc_shilohExtendedProperty.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/extendedproperty/inc_shilohExtendedProperty.xml index 1104086a..7dac93ac 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/extendedproperty/inc_shilohExtendedProperty.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/extendedproperty/inc_shilohExtendedProperty.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/fulltext_ErrorLog.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/fulltext_ErrorLog.xml index 77d51287..579288fa 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/fulltext_ErrorLog.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/fulltext_ErrorLog.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/fulltext_ErrorLogText.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/fulltext_ErrorLogText.xml index 34384524..8eaf7468 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/fulltext_ErrorLogText.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/fulltext_ErrorLogText.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_DbFile.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_DbFile.xml index 4418462a..99f1a634 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_DbFile.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_DbFile.xml @@ -1,32 +1,13 @@ - + - - - -DECLARE @PageSize float -SELECT @PageSize=v.low/1024.0 FROM master..spt_values v WHERE v.number=1 AND v.type='E' - - - + - - rtrim(s.name) - s.fileid - rtrim(s.filename) - (s.size * @PageSize) - case when s.maxsize=-1 then -1 else s.maxsize * @PageSize end - CASE WHEN (0 <>(s.status & 0x100000)) THEN s.growth ELSE s.growth * @PageSize END - CASE WHEN s.growth=0 THEN 99 WHEN (0 <>(s.status & 0x100000)) THEN 1 ELSE 0 END - - - + s.name s.file_id CASE when s.max_size=-1 then -1 else s.max_size * CONVERT(float,8) END @@ -44,7 +25,7 @@ SELECT @PageSize=v.low/1024.0 FROM master..spt_values v WHERE v.number=1 AND v.t - + s.physical_name s.size * CONVERT(float,8) ISNULL(fs.num_of_reads, 0) @@ -52,10 +33,7 @@ SELECT @PageSize=v.low/1024.0 FROM master..spt_values v WHERE v.number=1 AND v.t ISNULL(fs.num_of_bytes_read, 0) ISNULL(fs.num_of_bytes_written, 0) - - CASE when s.growth=0 THEN 99 ELSE s.is_percent_growth END - - + CASE when s.growth=0 THEN (CASE WHEN s.type = 2 THEN 0 ELSE 99 END) ELSE s.is_percent_growth END diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_DefaultRule_column.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_DefaultRule_column.xml index d4e9c785..4e279d43 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_DefaultRule_column.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_DefaultRule_column.xml @@ -1,14 +1,10 @@ - - + + - - - tbl.id = c.id and OBJECTPROPERTY(tbl.id, N'IsUserTable') = 1 - - + dc.column_id = c.column_id and dc.object_id = c.object_id tbl.object_id = c.object_id @@ -16,10 +12,7 @@ c.name tbl.name - - user_name(tbl.uid) - - + schema_name(tbl.schema_id) diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_IndexFrag.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_IndexFrag.xml index 313031c5..bc2aa821 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_IndexFrag.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_IndexFrag.xml @@ -1,28 +1,7 @@ - + - - - - - - - - - - - - - - - - - drop table #contig_tmp - - - - + @@ -42,48 +21,7 @@ select @database_id = db_id() - - - - - - null - null - null - null - null - null - null - null - - - - fi.Level - fi.Pages - fi.Rows - fi.MinimumRecordSize - fi.MaximumRecordSize - fi.AverageRecordSize - fi.ForwardedRecords - fi.Extents - fi.ExtentSwitches - fi.AverageFreeBytes - fi.AvgPageFullness - fi.ScanDensity - fi.BestCount - fi.ActualCount - fi.LogicalFragmentation - fi.ExtentFragmentation - - + fi.index_depth diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_assembly_module_link.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_assembly_module_link.xml index 4f148bc3..3fa65903 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_assembly_module_link.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_assembly_module_link.xml @@ -1,7 +1,7 @@ - + - + am{0}.object_id = {0}.object_id - + + - - tbl.id = {0}.id - - + tbl.object_id = {0}.object_id @@ -13,10 +9,7 @@ {0}.name tbl.name - - user_name(tbl.uid) - - + schema_name(tbl.schema_id) diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_constraint.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_constraint.xml index 133933d8..ffee2a85 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_constraint.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_constraint.xml @@ -1,28 +1,16 @@ - + - - cstr.status & 4 - 1 - ISNULL(OBJECTPROPERTY(cstr.id, N'CnstIsNotTrusted'),0) - 1 - ISNULL(OBJECTPROPERTY(cstr.id, N'CnstIsDisabled'),0) - ISNULL(OBJECTPROPERTY(cstr.id, N'CnstIsNotRepl'),0) - - - - - - - + cstr.is_system_named ~cstr.is_not_trusted ~cstr.is_disabled - + cstr.is_not_for_replication diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_ddl_trigger_event.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_ddl_trigger_event.xml index 7e7079cc..735b34cb 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_ddl_trigger_event.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_ddl_trigger_event.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_fulltext.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_fulltext.xml index 6879dc43..ba70aafd 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_fulltext.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_fulltext.xml @@ -1,19 +1,9 @@ - + - - - - + - - - - - - - - + {0}.definition diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_hadr_policy_health_state.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_hadr_policy_health_state.xml index d150f033..faea537d 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_hadr_policy_health_state.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_hadr_policy_health_state.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_hadr_setting.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_hadr_setting.xml index af5ab32f..4cd592b4 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_hadr_setting.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_hadr_setting.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_named_object.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_named_object.xml index 19484f1a..8bffc62a 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_named_object.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_named_object.xml @@ -1,27 +1,12 @@ - - + + - + s{0}.principal_id = ISNULL({0}.principal_id, (OBJECTPROPERTY({0}.object_id, 'OwnerId'))) - - {0}.name - {0}.id - {0}.crdate - - - - - - + {0}.name {0}.object_id {0}.create_date @@ -38,7 +23,7 @@ - + ISNULL(s{0}.name, N'') case when {0}.principal_id is null then 1 else 0 end diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_object.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_object.xml index d0e0d2ca..5bb015df 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_object.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_object.xml @@ -1,24 +1,11 @@ - + - - s{0}.uid = {0}.uid - - + - - s{0}.name - s{0}.name - - - - + SCHEMA_NAME({0}.schema_id) diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_objprop_table_view.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_objprop_table_view.xml index e692de45..8fcd77c5 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_objprop_table_view.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/inc_objprop_table_view.xml @@ -1,8 +1,8 @@ - + - + @@ -30,7 +30,7 @@ - + @@ -43,7 +43,7 @@ - + - diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/include/mixed_module_link.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/include/mixed_module_link.xml index 7e4aca7b..9d9b395d 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/include/mixed_module_link.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/include/mixed_module_link.xml @@ -1,5 +1,5 @@ - + - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/include/sql_module_link.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/include/sql_module_link.xml index 279bc407..935b0a13 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/include/sql_module_link.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/include/sql_module_link.xml @@ -1,5 +1,5 @@ - + - i.indid > <msparam>0</msparam> and i.indid < <msparam>255</msparam> and <msparam>1</msparam> != INDEXPROPERTY(i.id,i.name,N'IsStatistics') and <msparam>1</msparam> != INDEXPROPERTY(i.id,i.name,N'IsHypothetical') - k.parent_obj = i.id AND k.name = i.name AND k.xtype IN (N'PK', N'UQ') - - + i.index_id > <msparam>0</msparam> and i.is_hypothetical = <msparam>0</msparam> s.stats_id = i.index_id AND s.object_id = i.object_id @@ -54,12 +49,12 @@ - + i.object_id = vi.object_id AND i.index_id = vi.index_id - + i.object_id = ji.object_id AND i.index_id = ji.index_id @@ -68,10 +63,10 @@ xi.object_id = indexedpaths.object_id AND xi.using_xml_index_id = indexedpaths.index_id AND xi.path_id = indexedpaths.path_id - + declare @PageSize float select @PageSize=v.low/1024.0 from master.dbo.spt_values v where v.number=<msparam>1</msparam> and v.type=<msparam>E</msparam> - + create table #vectorindexes (object_id int, index_id int, distance_metric nvarchar(60), vector_index_type nvarchar(60)); begin try @@ -106,45 +101,7 @@ - - i.name - i.indid - OBJECTPROPERTY(i.id,N'IsMSShipped') - INDEXPROPERTY(i.id,i.name,N'IsFulltextKey') - CASE WHEN (i.status & 0x1000000) <> 0 THEN 1 ELSE 0 END - INDEXPROPERTY(i.id,i.name,N'IndexFillFactor') - CASE WHEN (i.indid = 1) THEN (i.used - i.dpages - ISNULL((SELECT - SUM(j.used) FROM dbo.sysindexes AS j WHERE (j.indid > 1) AND (j.indid < 255) AND (j.id = i.id) AND (j.name = i.name)), 0)) * @PageSize ELSE i.used * @PageSize END - CASE i.indid WHEN 1 THEN 1 ELSE 0 END - CASE WHEN 0 != i.status&0x800 THEN 1 WHEN 0 != i.status&0x1000 THEN 2 ELSE 0 END - i.status&2 - CASE WHEN 0 != (i.status&0x01) THEN 1 ELSE 0 END - INDEXPROPERTY(i.id, i.name, N'IsRowLockDisallowed') - INDEXPROPERTY(i.id, i.name, N'IsPageLockDisallowed') - INDEXPROPERTY(i.id, i.name, N'IsPadIndex') - ISNULL(k.status & 4, 0) - - - - - CASE i.indid WHEN 1 THEN 0 ELSE 1 END - - - - - - - + i.name i.index_id OBJECTPROPERTY(i.object_id,N'IsMSShipped') @@ -191,7 +148,7 @@ - + @@ -200,16 +157,16 @@ JOIN sys.allocation_units as a ON a.container_id = p.partition_id WHERE p.object_id = i.object_id AND p.index_id = i.index_id),0.0) - + INDEXPROPERTY(i.object_id,i.name,N'IsFulltextKey') case when i.type=3 then 1 else 0 end - + case UPPER(ISNULL(xi.secondary_type,'')) when 'P' then 1 when 'V' then 2 when 'R' then 3 else 0 end ISNULL(xi2.name, N'') - + CASE i.type WHEN 1 THEN 0 WHEN 3 THEN CASE WHEN xi.using_xml_index_id IS NULL THEN 2 ELSE 3 END WHEN 4 THEN 4 WHEN 6 THEN 5 ELSE 1 END @@ -225,9 +182,6 @@ ISNULL(si.cells_per_object,0) case when i.type=4 then 1 else 0 end - - 0 - @@ -248,7 +202,7 @@ CASE i.type WHEN 1 THEN 0 WHEN 4 THEN 4 ELSE 1 END - + @@ -433,20 +387,13 @@ - - N'' - N'' - - + ISNULL(vi.distance_metric, N'') ISNULL(vi.vector_index_type, N'') - - 0 - - + ISNULL(ji.optimize_for_array_search, 0) diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/jobstep.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/jobstep.xml index 8500ea72..005e82aa 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/jobstep.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/jobstep.xml @@ -1,5 +1,5 @@ - - + + @@ -10,35 +10,11 @@ - + sp.proxy_id = tshj.proxy_id - - - - - - - - + tshj.flags - + ISNULL(sp.name,N'') diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/language.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/language.xml index 9dcdac98..0f34d1c2 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/language.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/language.xml @@ -1,10 +1,7 @@ - + - - - - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/linkedserver.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/linkedserver.xml index 83643eb8..17cd2043 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/linkedserver.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/linkedserver.xml @@ -1,98 +1,15 @@ - + - - srv.srvid != 0 - - - srv.srvid != 0 AND srv.srvname = so.srvname - - + srv.server_id != 0 - - - create table #tmp_srvoptions([srvname] nvarchar(255) not null, [collationcompatible] bit not null, [dataaccess] bit not null, [dist] bit not null, [dpub] bit not null, [pub] bit not null, [rpc] bit not null, [rpcout] bit not null, [sub] bit not null) - declare @srvname nvarchar(255) - declare @collation_compatible bit - declare @data_access bit - declare @dist bit - declare @pub bit - declare @dpub bit - declare @rpc bit - declare @rpc_out bit - declare @sub bit - create table #tmp(opt nvarchar(100)) - declare srvname_cursor cursor for - select srvname FROM dbo.sysservers WHERE srvid <> 0 - open srvname_cursor - fetch next from srvname_cursor into @srvname - while @@FETCH_STATUS = 0 - begin - truncate table #tmp - insert #tmp exec sp_serveroption @srvname - set @collation_compatible = case when exists ( select * from #tmp where opt = 'collation compatible') then 1 else 0 end - set @data_access = case when exists ( select * from #tmp where opt = 'data access') then 1 else 0 end - set @dist = case when exists ( select * from #tmp where opt = 'dist') then 1 else 0 end - set @dpub = case when exists ( select * from #tmp where opt = 'dpub') then 1 else 0 end - set @pub = case when exists ( select * from #tmp where opt = 'pub') then 1 else 0 end - set @rpc = case when exists ( select * from #tmp where opt = 'rpc') then 1 else 0 end - set @rpc_out = case when exists ( select * from #tmp where opt = 'rpc out') then 1 else 0 end - set @sub = case when exists ( select * from #tmp where opt = 'sub') then 1 else 0 end - insert into #tmp_srvoptions([srvname], [collationcompatible], [dataaccess], [dist], [dpub], [pub], [rpc], [rpcout], [sub]) values (@srvname, @collation_compatible, @data_access, @dist, @dpub, @pub, @rpc, @rpc_out, @sub) - fetch next from srvname_cursor into @srvname - end - close srvname_cursor - deallocate srvname_cursor - drop table #tmp - - - drop table #tmp_srvoptions - - - - srv.srvname - srv.srvid - ISNULL(srv.catalog,N'') - ISNULL(srv.datasource,N'') - ISNULL(srv.location,N'') - srv.srvproduct - srv.providername - - null - - - so.collationcompatible - so.dataaccess - so.dist - so.dpub - so.pub - so.rpc - so.rpcout - so.sub - - - srv.collationcompatible - srv.dataaccess - srv.dist - srv.dpub - srv.pub - srv.rpc - srv.rpcout - srv.sub - - - ISNULL(COLLATIONPROPERTYFROMID(srv.srvcollation, 'name'),N'') - srv.connecttimeout - srv.lazyschemavalidation - srv.querytimeout - srv.useremotecollation - - + + srv.name srv.server_id ISNULL(srv.catalog,N'') diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/linkedservercatalog.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/linkedservercatalog.xml index 97ce5a0b..99f5d593 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/linkedservercatalog.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/linkedservercatalog.xml @@ -1,5 +1,5 @@ - - + + - - - - - - - - drop table #tmp_sp_catalogs - drop table #tmp_catalog_exist_test - - - + - + + - - - lnklgn.ishqoutmap = 1 - - lnklgn.sid=xlnklgn.sid and ISNULL(xlnklgn.ishqoutmap,0) = 0 - - + ll.local_principal_id = sp.principal_id @@ -20,13 +13,7 @@ - - ISNULL(xlnklgn.name, '') - ISNULL(lnklgn.name, N'') - convert(bit,lnklgn.selfoutmap) - - - + ISNULL(sp.name, '') ISNULL(ll.remote_name, N'') ll.uses_self_credential diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/linkedservertable.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/linkedservertable.xml index e9a2b25a..3f2d46df 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/linkedservertable.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/linkedservertable.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/linkedserverview.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/linkedserverview.xml index ebefa89d..532f908d 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/linkedserverview.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/linkedserverview.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/login.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/login.xml index fd0eb2b0..2e89355e 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/login.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/login.xml @@ -1,11 +1,7 @@ - + - - - log.language = l.name - - + log.type in ('U', 'G', 'S', 'C', 'K', 'E', 'X') AND log.principal_id not between 101 and 255 AND log.name <> N'##MS_AgentSigningCertificate##' l.name = log.default_language_name - - log.loginname - ISNULL(log.language, N'') - l.alias - ISNULL(log.dbname,N'') - log.denylogin - CASE WHEN 0 <> log.isntuser THEN 0 WHEN 0 <> log.isntgroup THEN 1 ELSE 2 END - CASE WHEN (0 = log.isntuser AND 0 = log.isntgroup) THEN 99 WHEN (0 = log.denylogin and 0 = log.hasaccess) THEN 0 WHEN (0 = log.denylogin ) THEN 1 ELSE 2 END - log.hasaccess - log.sid - log.createdate - log.updatedate - CASE log.sid WHEN 0x01 THEN 1 ELSE 0 END - - - + log.name ISNULL(log.default_language_name,N'') l.alias @@ -95,7 +76,7 @@ UNION CASE WHEN log.principal_id < 256 THEN 1 ELSE 0 END - + ISNULL(sqllog.is_expiration_checked, 0) diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/ColumnPerm.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/ColumnPerm.xml index 19ee1c25..56283ea1 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/ColumnPerm.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/ColumnPerm.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/DBObjectPerm.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/DBObjectPerm.xml index 502ad0a3..bd28ef22 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/DBObjectPerm.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/DBObjectPerm.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/DBPerm.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/DBPerm.xml index b498f81f..84261251 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/DBPerm.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/DBPerm.xml @@ -1,5 +1,5 @@ - + prmssn.id = 0 diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/ShilohYukonPerm.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/ShilohYukonPerm.xml index a8a11d2b..bc205e1d 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/ShilohYukonPerm.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/ShilohYukonPerm.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/SrvObjectPerm.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/SrvObjectPerm.xml index 9cf8223c..dcf389ae 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/SrvObjectPerm.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/SrvObjectPerm.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/SrvYukonObjectPerm.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/SrvYukonObjectPerm.xml index 79b244cf..413fc034 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/SrvYukonObjectPerm.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/SrvYukonObjectPerm.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/SrvYukonPerm.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/SrvYukonPerm.xml index 289e397f..a659d28b 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/SrvYukonPerm.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/SrvYukonPerm.xml @@ -1,5 +1,5 @@ - + prmssn.class = 100 diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/TablePerm.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/TablePerm.xml index f361bc21..1e9157ec 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/TablePerm.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/TablePerm.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/YukonObjectPerm.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/YukonObjectPerm.xml index 9428b642..5d378518 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/YukonObjectPerm.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/YukonObjectPerm.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/YukonSchemaObjectPerm.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/YukonSchemaObjectPerm.xml index 653f4413..adb26393 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/YukonSchemaObjectPerm.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/YukonSchemaObjectPerm.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/dbfixedroleperm.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/dbfixedroleperm.xml index c4cc1118..6dc11b28 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/dbfixedroleperm.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/dbfixedroleperm.xml @@ -1,5 +1,5 @@ - - + + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/inc_perm.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/inc_perm.xml index 1af97047..a2f1c869 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/inc_perm.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/perm/inc_perm.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/primarychildren.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/primarychildren.xml index ae366c15..71076cd5 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/primarychildren.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/primarychildren.xml @@ -1,5 +1,5 @@ - + declare @command nvarchar(300) diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/primaryfile.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/primaryfile.xml index 28ddb221..036b3faf 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/primaryfile.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/primaryfile.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/restore_plan.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/restore_plan.xml index 813e5117..b420a3aa 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/restore_plan.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/restore_plan.xml @@ -1,199 +1,16 @@ - + bkps.backup_set_id = btmp.backup_set_id - - - declare @server_name nvarchar(512) - set @server_name = @@SERVERNAME - - - + declare @server_name nvarchar(512) set @server_name = cast(serverproperty(N'Servername') as nvarchar(512)) - - - DECLARE - @first_full_backupset_id INTEGER, - @first_full_backup_startdate DATETIME, - @count_entries INTEGER, - @in_restore_plan BIT, - @last_backupset_type CHAR(1), - @last_backupset_id INTEGER, - @last_backupset_family_guid UNIQUEIDENTIFIER, - @last_backupset_diff_base_guid UNIQUEIDENTIFIER, - @last_backupset_recovery_fork_guid UNIQUEIDENTIFIER, - @full_backupset_id INTEGER, - @full_backupset_start_date DATETIME, - @full_backupset_recovery_fork_guid UNIQUEIDENTIFIER, - - - @loop_var BIT, - @loop_backup_set_id INTEGER, - @loop_start_date DATETIME, - @count_unique_fork_guid INTEGER, - - @t1_backup_set_id INTEGER, - @t1_type CHAR(1), - @t1_backup_start_date DATETIME, - @t1_first_recovery_fork_guid UNIQUEIDENTIFIER, - @t1_last_recovery_fork_guid UNIQUEIDENTIFIER, - @t1_first_lsn NUMERIC(25, 0), - @t1_last_lsn NUMERIC(25, 0), - @t1_checkpoint_lsn NUMERIC(25, 0), - @t1_database_backup_lsn NUMERIC(25, 0), - @t1_fork_point_lsn NUMERIC(25, 0), - @t1_backup_set_uuid UNIQUEIDENTIFIER, - @t1_database_guid UNIQUEIDENTIFIER, - @t1_diff_base_guid UNIQUEIDENTIFIER, - - @t2_backup_set_id INTEGER, - @t2_type CHAR(1), - @t2_backup_start_date DATETIME, - @t2_first_recovery_fork_guid UNIQUEIDENTIFIER, - @t2_last_recovery_fork_guid UNIQUEIDENTIFIER, - @t2_first_lsn NUMERIC(25, 0), - @t2_last_lsn NUMERIC(25, 0), - @t2_checkpoint_lsn NUMERIC(25, 0), - @t2_database_backup_lsn NUMERIC(25, 0), - @t2_fork_point_lsn NUMERIC(25, 0), - @t2_backup_set_uuid UNIQUEIDENTIFIER, - @t2_database_guid UNIQUEIDENTIFIER, - @t2_diff_base_guid UNIQUEIDENTIFIER - - - CREATE TABLE #backupset( - backup_set_id INTEGER NOT NULL, - is_in_restore_plan BIT NOT NULL, - backup_start_date DATETIME NOT NULL, - type CHAR(1) NOT NULL, - database_name NVARCHAR(256) NOT NULL, - database_guid UNIQUEIDENTIFIER , - family_guid UNIQUEIDENTIFIER , - first_recovery_fork_guid UNIQUEIDENTIFIER , - last_recovery_fork_guid UNIQUEIDENTIFIER , - first_lsn NUMERIC(25, 0) , - last_lsn NUMERIC(25, 0) , - checkpoint_lsn NUMERIC(25, 0) , - database_backup_lsn NUMERIC(25, 0) , - fork_point_lsn NUMERIC(25, 0) , - restore_till_lsn NUMERIC(25, 0) , - backup_set_uuid UNIQUEIDENTIFIER , - differential_base_guid UNIQUEIDENTIFIER - ) - /**********************************************************************/ - /* Identify the first */ - /**********************************************************************/ - SELECT @first_full_backupset_id = backupset_outer.backup_set_id - ,@first_full_backup_startdate = backupset_outer.backup_start_date - FROM msdb.dbo.backupset backupset_outer - WHERE backupset_outer.database_name = @db_name - AND backupset_outer.server_name = @server_name - AND backupset_outer.type = 'D' -- Full Database Backup - AND backupset_outer.backup_start_date = ( SELECT MAX(backupset_inner.backup_start_date) - FROM msdb.dbo.backupset backupset_inner - WHERE backupset_inner.database_name = backupset_outer.database_name - AND backupset_inner.server_name = @server_name - AND backupset_inner.type = backupset_outer.type AND - backupset_inner.backup_start_date <= @restore_to_datetime) - /*******************************************************************************************/ - /* Find the first full database backup needed in the restore plan and store its attributes */ - /* in #backupset work table */ - /*******************************************************************************************/ - INSERT #backupset( - backup_set_id - ,is_in_restore_plan - ,backup_start_date - ,type - ,database_name - ) - SELECT backup_set_id - ,1 -- The full database backup is always needed for the restore plan - ,backup_start_date - ,type - ,database_name - FROM msdb.dbo.backupset - WHERE msdb.dbo.backupset.backup_set_id = @first_full_backupset_id - AND msdb.dbo.backupset.server_name = @server_name - - /***************************************************************/ - /* Find the log and differential backups that occurred after */ - /* the full backup and store them in #backupset work table */ - /***************************************************************/ - INSERT #backupset( - backup_set_id - ,is_in_restore_plan - ,backup_start_date - ,type - ,database_name - ) - SELECT backup_set_id - ,0 - ,backup_start_date - ,type - ,database_name - FROM msdb.dbo.backupset - WHERE msdb.dbo.backupset.database_name = @db_name - AND msdb.dbo.backupset.server_name = @server_name - AND msdb.dbo.backupset.type IN ('I', 'L') -- Differential, Log backups - AND msdb.dbo.backupset.backup_start_date >= @first_full_backup_startdate - - /**********************************************************************************/ - /* identify and mark the backup logs that need to be included in the restore plan */ - /**********************************************************************************/ - UPDATE #backupset - SET is_in_restore_plan = 1 - WHERE #backupset.type = 'I' - AND #backupset.backup_start_date = (SELECT MAX(backupset_inner.backup_start_date) - FROM #backupset backupset_inner - WHERE backupset_inner.type = #backupset.type - AND backupset_inner.backup_start_date <= @restore_to_datetime) - - /**************************************************************************************/ - /* Log backups that occurred after the different are always part of the restore plan. */ - /**************************************************************************************/ - UPDATE #backupset - SET is_in_restore_plan = 1 - WHERE #backupset.type = 'L' - AND #backupset.backup_start_date <= @restore_to_datetime - AND #backupset.backup_start_date >= (SELECT backupset_inner.backup_start_date - FROM #backupset backupset_inner - WHERE backupset_inner.type = 'I' - AND backupset_inner.is_in_restore_plan = 1) - - /**************************************************************************************/ - /* If @restore_to_datetime is greater than the last startdate of the last log backup, */ - /* include the next log backup in the restore plan */ - /**************************************************************************************/ - UPDATE #backupset - SET is_in_restore_plan = 1 - WHERE #backupset.type = 'L' - AND #backupset.backup_start_date = (SELECT MIN(backupset_inner.backup_start_date) - FROM #backupset backupset_inner - WHERE backupset_inner.type = 'L' - AND backupset_inner.backup_start_date > @restore_to_datetime - AND backupset_inner.is_in_restore_plan = 0) - - /**************************************************************************************/ - /* If there are no differential backups, all log backups that occurred after the full */ - /* backup are needed in the restore plan. */ - /**************************************************************************************/ - UPDATE #backupset - SET is_in_restore_plan = 1 - WHERE #backupset.type = 'L' - AND #backupset.backup_start_date <= @restore_to_datetime - AND NOT EXISTS(SELECT * - FROM #backupset backupset_inner - WHERE backupset_inner.type = 'I') - - - - + DECLARE @first_full_backupset_id INTEGER, @@ -377,7 +194,7 @@ - + /**************************************************************************************/ @@ -964,13 +781,13 @@ bkps.database_name bkps.server_name bkps.machine_name - + bkps.flags bkps.unicode_locale bkps.unicode_compare_style bkps.collation_name - + bkps.is_copy_only diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/restorefile.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/restorefile.xml index 54329064..69d38afb 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/restorefile.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/restorefile.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/restorefilegroup.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/restorefilegroup.xml index 2dc94a50..33c0e7d7 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/restorefilegroup.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/restorefilegroup.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/restorehistory.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/restorehistory.xml index ae4964bc..73314f32 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/restorehistory.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/restorehistory.xml @@ -1,5 +1,5 @@ - + @@ -15,7 +15,7 @@ rthist.restart rthist.stop_at rthist.device_count - + rthist.stop_at_mark_name rthist.stop_before diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/resumableindex.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/resumableindex.xml index dc971894..4bb83b60 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/resumableindex.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/resumableindex.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/schedule.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/schedule.xml index 77374300..4f0be9f8 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/schedule.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/schedule.xml @@ -1,5 +1,5 @@ - + tshs.schedule_id = sslv.schedule_id diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/sdt.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/sdt.xml index a6f74088..61c0a491 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/sdt.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/sdt.xml @@ -1,10 +1,7 @@ - - + + - - st.xusertype = st.xtype or st.name=N'sysname' - - + st.schema_id=4 @@ -23,17 +20,7 @@ CASE WHEN st.name IN (N'decimal', N'int', N'numeric', N'smallint', N'tinyint', N'bigint') THEN 1 ELSE 0 END CASE WHEN st.name IN ( N'char', N'varchar', N'binary', N'varbinary', N'nchar', N'nvarchar' ) THEN 1 ELSE 0 END - - st.allownulls - CASE WHEN st.name IN (N'char', N'varchar', N'binary', N'varbinary', N'nchar', N'nvarchar') THEN st.prec ELSE st.length END - st.xprec - st.xscale - - - ISNULL(st.collation,N'') - - - + st.is_nullable CASE WHEN st.name IN (N'nchar', N'nvarchar') THEN st.max_length/2 ELSE st.max_length END diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/sequence.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/sequence.xml index 56c0e03c..4ab371b9 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/sequence.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/sequence.xml @@ -1,5 +1,5 @@ - - + + @@ -22,6 +22,3 @@ - - - diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/server.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/server.xml index c43f0963..48399bda 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/server.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/server.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/servicemasterkey.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/servicemasterkey.xml index f515b858..7c0a864f 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/servicemasterkey.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/servicemasterkey.xml @@ -1,5 +1,5 @@ - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/sharedschedule.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/sharedschedule.xml index 50e1cb76..a1b4b391 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/sharedschedule.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/sharedschedule.xml @@ -1,10 +1,7 @@ - + - - - - + - + + - - - (st.indid <> 0 and st.indid <> 255) and 0 = OBJECTPROPERTY(st.id,N'IsMSShipped') - - - + - + @@ -21,18 +16,7 @@ st.name - - st.indid - case when (st.status & 16777216) <> 0 then 1 else 0 end - STATS_DATE(st.id, st.indid) - 1 - INDEXPROPERTY(st.id,st.name,N'IsStatistics') - INDEXPROPERTY(st.id,st.name,N'IsAutoStatistics') - '' - - - - - + st.stats_id st.no_recompute STATS_DATE(st.object_id, st.stats_id) @@ -55,7 +39,7 @@ st.auto_drop - + null diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/synonym.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/synonym.xml index 46009e8a..7323dbf6 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/synonym.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/synonym.xml @@ -1,5 +1,5 @@ - - + + - + N'' N'' diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/sysmessage.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/sysmessage.xml index 9ab041b5..bcdde9f9 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/sysmessage.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/sysmessage.xml @@ -1,27 +1,14 @@ - + - - sms.error < 50001 - sms.msglangid = sl.lcid - - + sms.message_id < 50001 sms.language_id = sl.lcid - - sms.error - sms.dlevel - sms.severity - sms.description - sms.msglangid - sl.name - - - + sms.message_id sms.is_event_logged sms.severity @@ -31,4 +18,3 @@ - diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/table.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/table.xml index 71fb1106..2342ecd7 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/table.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/table.xml @@ -1,14 +1,10 @@ - + - - (tbl.type='U' or tbl.type='S') - idx.id = tbl.id and idx.indid < 2 - - + - + idx.object_id = tbl.object_id and (idx.index_id < <msparam>2</msparam>) @@ -28,6 +24,10 @@ fields='#DataSourceName#FileFormatName#FileFormatNameOd#ShardingColumnName#Location#LocationOd#RejectType#RejectValue#RejectSampleValue#ExternalTableDistribution#RemoteSchemaName#RemoteObjectName#' left_join='#external_data AS edt'>edt.object_id = tbl.object_id + + + sc.object_id = tbl.object_id AND sc.column_id = edt.sharding_col_id + et.object_id = tbl.object_id tdp.object_id = tbl.object_id @@ -37,7 +37,7 @@ periods.object_id = tbl.object_id historyTable.object_id = tbl.history_table_id - + tbl.lob_data_space_id = dstext.data_space_id @@ -62,7 +62,7 @@ create table #change_tracking_tables - (object_id int null, is_track_columns_updated_on bit null) + (object_id int not null primary key, is_track_columns_updated_on bit null) insert into #change_tracking_tables select t.object_id, c.is_track_columns_updated_on from sys.tables t @@ -72,7 +72,7 @@ CREATE TABLE #file_tables - (object_id int not null, is_enabled bit null, directory_name nvarchar(256) null, filename_collation_name nvarchar(129) null) + (object_id int not null primary key, is_enabled bit null, directory_name nvarchar(256) null, filename_collation_name nvarchar(129) null) insert into #file_tables select t.object_id, f.is_enabled, f.directory_name, f.filename_collation_name from sys.tables as t @@ -82,7 +82,7 @@ CREATE TABLE #tmp_ledger_details - (table_object_id int not null, ledger_view_name sysname null, ledger_view_schema_name sysname null) + (table_object_id int not null primary key, ledger_view_name sysname null, ledger_view_schema_name sysname null) INSERT INTO #tmp_ledger_details SELECT t.object_id, v.name, s.name from sys.tables as t @@ -91,40 +91,50 @@ CREATE TABLE #tmp_ledger_view_column_names - (table_object_id int not null, ledger_transaction_id_column_name sysname null, ledger_sequence_number_column_name sysname null, ledger_operation_type_column_name sysname null, ledger_operation_type_desc_column_name sysname null) + (table_object_id int not null primary key, ledger_transaction_id_column_name sysname null, ledger_sequence_number_column_name sysname null, ledger_operation_type_column_name sysname null, ledger_operation_type_desc_column_name sysname null) INSERT INTO #tmp_ledger_view_column_names SELECT - t_obj_id, - [ledger_transaction_id_column_name] = MAX(CASE WHEN ledger_view_column_type = 1 THEN c_name ELSE NULL END), - [ledger_sequence_number_column_name] =MAX(CASE WHEN ledger_view_column_type = 2 THEN c_name ELSE NULL END), - [ledger_operation_type_column_name] = MAX(CASE WHEN ledger_view_column_type = 3 THEN c_name ELSE NULL END), - [ledger_operation_type_desc_column_name] = MAX(CASE WHEN ledger_view_column_type = 4 THEN c_name ELSE NULL END) + t_obj_id, + [ledger_transaction_id_column_name] = MAX(CASE WHEN ledger_view_column_type = 1 THEN c_name ELSE NULL END), + [ledger_sequence_number_column_name] =MAX(CASE WHEN ledger_view_column_type = 2 THEN c_name ELSE NULL END), + [ledger_operation_type_column_name] = MAX(CASE WHEN ledger_view_column_type = 3 THEN c_name ELSE NULL END), + [ledger_operation_type_desc_column_name] = MAX(CASE WHEN ledger_view_column_type = 4 THEN c_name ELSE NULL END) FROM ( - SELECT t.object_id as t_obj_id, a.name as c_name, a.ledger_view_column_type FROM sys.tables as t - CROSS APPLY - ( - SELECT name, ledger_view_column_type FROM sys.columns as c - WHERE c.object_id = t.ledger_view_id and t.ledger_view_id!=0 and c.ledger_view_column_type!=0 and t.is_dropped_ledger_table=0 - ) a + SELECT t.object_id as t_obj_id, c.name as c_name, c.ledger_view_column_type FROM sys.tables as t + INNER JOIN sys.columns AS c ON c.object_id = t.ledger_view_id + WHERE t.ledger_view_id != 0 AND c.ledger_view_column_type != 0 AND t.is_dropped_ledger_table=0 ) as x GROUP BY x.t_obj_id - + + + create table #external_data (object_id int not null primary key, data_source_id int , file_format_id int , [location] nvarchar(4000), reject_type nvarchar(20), reject_value float, reject_sample_value float, datasource_name nvarchar(128), fileformat_name nvarchar(128), sharding_col_id int, distribution_type tinyint, remote_schema_name nvarchar(128), remote_object_name nvarchar(128)) + insert into #external_data + select tbl.object_id, eds.data_source_id, eff.file_format_id, et.location, et.reject_type, et.reject_value, et.reject_sample_value, eds.name, eff.name, et.sharding_col_id, et.distribution_type, et.remote_schema_name, et.remote_object_name + from sys.tables tbl + INNER JOIN sys.external_tables AS et ON et.object_id = tbl.object_id + LEFT OUTER JOIN sys.external_data_sources AS eds ON eds.data_source_id = et.data_source_id + LEFT OUTER JOIN sys.external_file_formats AS eff ON eff.file_format_id = et.file_format_id + WHERE + (tbl.is_external = 1) + + + create table #external_data (object_id int not null, data_source_id int , file_format_id int , [location] nvarchar(4000), reject_type nvarchar(20), reject_value float, reject_sample_value float, datasource_name nvarchar(128), fileformat_name nvarchar(128), sharding_col_id int, distribution_type tinyint, remote_schema_name nvarchar(128), remote_object_name nvarchar(128)) insert into #external_data select tbl.object_id, eds.data_source_id, eff.file_format_id, et.location, et.reject_type, et.reject_value, et.reject_sample_value, eds.name, eff.name, et.sharding_col_id, et.distribution_type, et.remote_schema_name, et.remote_object_name from sys.tables tbl - LEFT OUTER JOIN sys.external_tables AS et ON et.object_id = tbl.object_id + INNER JOIN sys.external_tables AS et ON et.object_id = tbl.object_id LEFT OUTER JOIN sys.external_data_sources AS eds ON eds.data_source_id = et.data_source_id LEFT OUTER JOIN sys.external_file_formats AS eff ON eff.file_format_id = et.file_format_id WHERE (tbl.is_external = 1) - + declare @PageSize float select @PageSize=v.low/1024.0 from master.dbo.spt_values v where v.number=<msparam>1</msparam> and v.type=<msparam>E</msparam> @@ -175,7 +185,7 @@ class_name='Microsoft.SqlServer.Management.Smo.PostProcessTable' triggered_fields='#DatabaseName#SchemaName#TableName#'/> - + tbl.name not like '#%' @@ -210,44 +220,7 @@ END - - CASE WHEN (OBJECTPROPERTY(tbl.id, N'tableisfake')=1) THEN 1 ELSE 0 END - - @PageSize*((SELECT sum(sidx.dpages) - FROM dbo.sysindexes sidx - WHERE sidx.indid < <msparam>2</msparam> and sidx.id = tbl.id) - + - (SELECT isnull(sum(sidx.used), 0) - FROM dbo.sysindexes sidx - WHERE sidx.indid = <msparam>255</msparam> and sidx.id = tbl.id)) - - - @PageSize*(SELECT sum(isnull(sidx.used,0)-isnull(sidx.dpages,0)) - FROM dbo.sysindexes sidx - WHERE sidx.indid < <msparam>2</msparam> and sidx.id = tbl.id) - - CASE idx.indid WHEN 1 THEN 1 ELSE 0 END - ISNULL((select top 1 1 from dbo.sysindexes ind where ind.id = tbl.id and ind.indid > 1 and 1 != INDEXPROPERTY(ind.id,ind.name,N'IsStatistics') and 1 != INDEXPROPERTY(ind.id,ind.name,N'IsHypothetical')), 0) - case idx.indid WHEN 1 THEN case when (0 != idx.status&0x800) then 1 else 0 end else 0 end - ISNULL((SELECT top 1 s.groupname FROM dbo.sysfilegroups s, dbo.sysindexes i WHERE i.id = tbl.id and i.indid in (0,1)AND i.groupid = s.groupid), N'') - tbl.replinfo - - - - 0 - 0 - - - idx.rows - - - OBJECTPROPERTY(tbl.id,N'IsAnsiNullsOn') - OBJECTPROPERTY(tbl.id,N'IsQuotedIdentOn') - idx.rowcnt - - - - + CASE idx.index_id WHEN 1 THEN 1 ELSE 0 END ISNULL((select top 1 1 from sys.indexes ind where ind.object_id = tbl.object_id and ind.type > 1 and ind.is_hypothetical = 0 ), 0) case idx.index_id when 1 then case when (idx.is_primary_key + 2*idx.is_unique_constraint = 1) then 1 else 0 end else 0 end @@ -265,12 +238,12 @@ - + ISNULL(dstext.name,N'') - + case when databasepropertyex(DB_NAME(), 'version') < 612 then 0 @@ -278,12 +251,12 @@ end - + 0 0 - + ISNULL( ( select sum (spart.rows) from sys.partitions spart where spart.object_id = tbl.object_id and spart.index_id < <msparam>2</msparam>), 0) @@ -376,7 +349,7 @@ - + tbl.is_replicated @@ -399,10 +372,6 @@ ISNULL(ctt.is_track_columns_updated_on,0) - - 0 - - @@ -455,7 +424,7 @@ 0 - + @@ -547,11 +516,7 @@ ELSE 255 END - - CASE WHEN edt.sharding_col_id IS NULL THEN N'' - ELSE (select name from sys.columns sc where sc.object_id = tbl.object_id AND sc.column_id = edt.sharding_col_id) - END - + ISNULL(sc.name, N'') ISNULL(edt.remote_schema_name,'') ISNULL(edt.remote_object_name,'') diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/temp_table.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/temp_table.xml index fc349403..252e6998 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/temp_table.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/temp_table.xml @@ -1,5 +1,5 @@ - + tbl.name like '#%' diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/transaction.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/transaction.xml index fc9fde94..8008a5e7 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/transaction.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/transaction.xml @@ -1,5 +1,5 @@ - + - - - - - - + + ~trr.is_disabled trr.is_instead_of_trigger ISNULL(tei.object_id,0) @@ -63,7 +39,7 @@ CASE WHEN ted.is_first = 1 THEN 0 WHEN ted.is_last = 1 THEN 2 ELSE 1 END CASE WHEN tr.type = N'TR' THEN 1 WHEN tr.type = N'TA' THEN 2 ELSE 1 END - + trr.is_not_for_replication diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/uddt.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/uddt.xml index d14a3431..014c88f2 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/uddt.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/uddt.xml @@ -1,16 +1,6 @@ - + - - st.xusertype != st.xtype and st.name != N'sysname' - def.id = st.tdefault - rul.id = st.domain - - - st.schema_id!=4 and st.system_type_id!=240 and st.user_type_id != st.system_type_id - def.object_id = st.default_object_id - rul.object_id = st.rule_object_id - st.schema_id!=4 and st.system_type_id!=240 and st.user_type_id != st.system_type_id and st.is_table_type != 1 def.object_id = st.default_object_id @@ -20,10 +10,7 @@ - - st.xusertype - - + st.user_type_id @@ -32,31 +19,7 @@ - - st.length - st.allownulls - st.variable - (case when st.tdefault = 0 then N'' else def.name end) - (case when st.tdefault = 0 then N'' else user_name(def.uid) end) - (case when st.domain = 0 then N'' else rul.name end) - (case when st.domain = 0 then N'' else user_name(rul.uid) end) - - - - - - - ISNULL(st.collation, N'') - - + st.max_length st.is_nullable (case when st.default_object_id = 0 then N'' else def.name end) diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/udfcolumn.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/udfcolumn.xml index 8ebe7ca1..6d9eb054 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/udfcolumn.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/udfcolumn.xml @@ -1,10 +1,7 @@ - + - - clmns.number = <msparam>0</msparam> and <msparam>0</msparam> = OBJECTPROPERTY(clmns.id, N'IsScalarFunction') - - + diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/user.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/user.xml index aa4a00fe..f11fb460 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/user.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/user.xml @@ -1,11 +1,7 @@ - + - - ((u.issqlrole != <msparam>1</msparam> and u.isapprole != <msparam>1</msparam> ) or (u.sid=<msparam>0x00</msparam>)) and u.isaliased != <msparam>1</msparam> and u.hasdbaccess != <msparam>0</msparam> - - + u.type in ('U', 'S', 'G', 'C', 'K' ,'E', 'X') dp.grantee_principal_id = u.principal_id and dp.type = <msparam>CO</msparam> @@ -22,29 +18,7 @@ u.name - - u.uid - ISNULL(suser_sname(u.sid),N'') - CASE WHEN u.uid = 1 OR u.uid = 16382 OR u.uid = 16383 THEN 1 ELSE 0 END - CASE WHEN 0 <> u.isntuser THEN 0 WHEN 0 <> u.isntgroup THEN 1 ELSE 2 END - 0 - u.sid - u.hasdbaccess - - u.createdate - u.updatedate - - - - - - - + u.principal_id CASE WHEN u.principal_id < 5 OR (u.principal_id >= 16384 and u.principal_id < 16400) THEN 1 ELSE 0 END CASE WHEN N'U' = u.type THEN 0 WHEN N'G' = u.type THEN 1 WHEN N'S' = u.type THEN 2 WHEN N'C' = u.type THEN 3 WHEN N'K' = u.type THEN 4 WHEN N'E' = u.type THEN 5 WHEN N'X' = u.type THEN 6 END @@ -57,16 +31,16 @@ - + ISNULL(ak.name,N'') - + ISNULL(cert.name,N'') - + ISNULL(suser_sname(u.sid),N'') - + CASE WHEN N'C' = u.type THEN 1 WHEN N'K' = u.type THEN 2 WHEN N'S' = u.type AND suser_sname(u.sid) IS NULL THEN 3 ELSE 0 END CASE WHEN N'U' = u.type or N'G' = u.type THEN 3 WHEN N'S' = u.type and suser_sname(u.sid) IS NOT NULL THEN 1 ELSE 0 END diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/view.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/view.xml index 61a97ccb..f22f1764 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/view.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/view.xml @@ -1,11 +1,7 @@ - + - - v.type = <msparam>V</msparam> - idx.id = v.id and idx.indid < 2 - - + v.type = <msparam>V</msparam> idx.object_id = v.object_id and (idx.index_id < <msparam>2</msparam>) @@ -22,15 +18,7 @@ 0 - - - - - ISNULL((select top 1 1 from dbo.sysindexes ind where ind.id = v.id and ind.indid > 1 and 1 != INDEXPROPERTY(ind.id,ind.name,N'IsStatistics') and 1 != INDEXPROPERTY(ind.id,ind.name,N'IsHypothetical')), 0) - CASE idx.indid WHEN 1 THEN 1 ELSE 0 END - case idx.indid WHEN 1 THEN case when (0 != idx.status&0x800) then 1 else 0 end else 0 end - - + v.has_opaque_metadata ISNULL((select top 1 1 from sys.indexes ind where ind.object_id = v.object_id and ind.type > 1 and ind.is_hypothetical = 0 ), 0) CASE idx.index_id WHEN 1 THEN 1 ELSE 0 END @@ -58,7 +46,7 @@ ISNULL(v.ledger_view_type, 0) ISNULL(v.is_dropped_ledger_view, 0) - + 0 diff --git a/src/Microsoft/SqlServer/Management/SqlEnum/xml/xmltype.xml b/src/Microsoft/SqlServer/Management/SqlEnum/xml/xmltype.xml index 6b9a5940..34cf97cd 100644 --- a/src/Microsoft/SqlServer/Management/SqlEnum/xml/xmltype.xml +++ b/src/Microsoft/SqlServer/Management/SqlEnum/xml/xmltype.xml @@ -1,5 +1,5 @@ - + @@ -35,4 +35,3 @@ - diff --git a/src/Microsoft/SqlServer/Management/SqlScriptPublish/SqlQueryHandler.cs b/src/Microsoft/SqlServer/Management/SqlScriptPublish/SqlQueryHandler.cs index b7184aef..1c109be3 100644 --- a/src/Microsoft/SqlServer/Management/SqlScriptPublish/SqlQueryHandler.cs +++ b/src/Microsoft/SqlServer/Management/SqlScriptPublish/SqlQueryHandler.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Data; +using System.Diagnostics; using System.Linq; using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.Diagnostics; @@ -84,7 +85,7 @@ public IEnumerable> EnumChildrenForDatabaseObjectTy children = new List>(); QueryInfo info = dicTypes[objectType]; - SqlScriptPublishModelTraceHelper.Assert(info != null, "Unsupported object type:" + objectType); + Debug.Assert(info != null, "Unsupported object type:" + objectType); if (info == null) { throw new SqlScriptPublishException(SR.InvalidObjectType(objectType.ToString())); diff --git a/src/Microsoft/SqlServer/Management/SqlScriptPublish/SqlScriptGenerator.cs b/src/Microsoft/SqlServer/Management/SqlScriptPublish/SqlScriptGenerator.cs index a2335ce2..b197dffe 100644 --- a/src/Microsoft/SqlServer/Management/SqlScriptPublish/SqlScriptGenerator.cs +++ b/src/Microsoft/SqlServer/Management/SqlScriptPublish/SqlScriptGenerator.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Collections.Specialized; +using System.Diagnostics; using System.Globalization; using System.Text; using Microsoft.SqlServer.Management.Common; @@ -137,7 +138,7 @@ internal void GetUrnList() internal void DoScript(ScriptOutputOptions outputOptions) { - SqlScriptPublishModelTraceHelper.Assert(outputOptions != null, "outputOptions is null"); + Debug.Assert(outputOptions != null, "outputOptions is null"); if (outputOptions == null) { throw new ArgumentNullException("outputOptions"); @@ -432,7 +433,7 @@ private void SetScriptingOptions(ScriptingOptions scriptingOptions) { //If you are getting this assertion fail it means you are working for higher //version of SQL Server. You need to update this part of code. - SqlScriptPublishModelTraceHelper.Assert(false, "This part of the code is not updated corresponding to latest version change"); + Debug.Assert(false, "This part of the code is not updated corresponding to latest version change"); } // for cloud scripting to work we also have to have Script Compat set to 105. @@ -477,7 +478,7 @@ private void SetScriptingOptions(ScriptingOptions scriptingOptions) scriptingOptions.TargetDatabaseEngineEdition = DatabaseEngineEdition.SqlOnDemand; break; default: - SqlScriptPublishModelTraceHelper.Assert(scriptingOptions.TargetDatabaseEngineEdition == DatabaseEngineEdition.Standard, "The default database engine edition is Standard."); + Debug.Assert(scriptingOptions.TargetDatabaseEngineEdition == DatabaseEngineEdition.Standard, "The default database engine edition is Standard."); scriptingOptions.TargetDatabaseEngineEdition = DatabaseEngineEdition.Standard; break; } diff --git a/src/Microsoft/SqlServer/Management/SqlScriptPublish/SqlScriptOptions.cs b/src/Microsoft/SqlServer/Management/SqlScriptPublish/SqlScriptOptions.cs index 6e9949bc..5320d65d 100644 --- a/src/Microsoft/SqlServer/Management/SqlScriptPublish/SqlScriptOptions.cs +++ b/src/Microsoft/SqlServer/Management/SqlScriptPublish/SqlScriptOptions.cs @@ -5,6 +5,7 @@ using System.Collections; using System.Collections.Generic; using System.ComponentModel; +using System.Diagnostics; using System.Linq; using Microsoft.SqlServer.Management.Diagnostics; using Microsoft.SqlServer.Management.Sdk.Sfc; @@ -224,7 +225,7 @@ public SqlScriptOptions(Version version) // VBUMP else { - SqlScriptPublishModelTraceHelper.Assert(false, "Unexpected server version. Setting Compatibility Mode to 17.0!"); + Debug.Assert(false, "Unexpected server version. Setting Compatibility Mode to 17.0!"); compatMode = ScriptCompatibilityOptions.Script170Compat; } @@ -847,7 +848,7 @@ public virtual ScriptDatabaseEngineType TargetDatabaseEngineType } else { - SqlScriptPublishModelTraceHelper.Assert(this.engineType == ScriptDatabaseEngineType.SqlAzure, "Unexpected database engine type detected, expecting SQL Azure."); + Debug.Assert(this.engineType == ScriptDatabaseEngineType.SqlAzure, "Unexpected database engine type detected, expecting SQL Azure."); this.TargetDatabaseEngineEdition = ScriptDatabaseEngineEdition.SqlAzureDatabaseEdition; } diff --git a/src/Microsoft/SqlServer/Management/SqlScriptPublish/SqlScriptPublishModel.cs b/src/Microsoft/SqlServer/Management/SqlScriptPublish/SqlScriptPublishModel.cs index af2070b9..b71aeb5b 100644 --- a/src/Microsoft/SqlServer/Management/SqlScriptPublish/SqlScriptPublishModel.cs +++ b/src/Microsoft/SqlServer/Management/SqlScriptPublish/SqlScriptPublishModel.cs @@ -14,6 +14,7 @@ using Microsoft.SqlServer.Management.Sdk.Sfc; using Microsoft.SqlServer.Management.Sdk.Sfc.Metadata; using Microsoft.SqlServer.Management.Common; +using System.Diagnostics; namespace Microsoft.SqlServer.Management.SqlScriptPublish { @@ -79,7 +80,7 @@ public SqlScriptPublishModel(SqlConnectionInfo sqlConnectionInfo, string databas public SqlScriptPublishModel(string connectionString) : this() { - SqlScriptPublishModelTraceHelper.Assert(!string.IsNullOrEmpty(connectionString), "connectionString is empty"); + Debug.Assert(!string.IsNullOrEmpty(connectionString), "connectionString is empty"); if (string.IsNullOrEmpty(connectionString)) { throw new ArgumentNullException("connectionString"); @@ -276,7 +277,7 @@ internal Smo.Server Server { get { - SqlScriptPublishModelTraceHelper.Assert(this.smoServer != null); + Debug.Assert(this.smoServer != null); return this.smoServer; } } @@ -419,7 +420,7 @@ private SqlScriptOptions GetAdvancedScriptingOptions() // this is really dangerous that we just toss out all existing changes to the scriptAdvancedOptions // ideally we would just throw here or change the design but not sure of the impact on existing systems // so we'll assert for now - SqlScriptPublishModelTraceHelper.Assert(false, "WARNING: all changes to AdvancedOptions have been lost due to changes in ScriptAllObjects."); + Debug.Assert(false, "WARNING: all changes to AdvancedOptions have been lost due to changes in ScriptAllObjects."); this.scriptAdvancedOptions = null; return GetAdvancedScriptingOptions(); } diff --git a/src/Microsoft/SqlServer/Management/XEvent/core/Session.cs b/src/Microsoft/SqlServer/Management/XEvent/core/Session.cs index 0967bc9f..3869406a 100644 --- a/src/Microsoft/SqlServer/Management/XEvent/core/Session.cs +++ b/src/Microsoft/SqlServer/Management/XEvent/core/Session.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Globalization; +using Microsoft.SqlServer.Management.Common; using Microsoft.SqlServer.Management.Sdk.Sfc; using Microsoft.SqlServer.Management.Sdk.Sfc.Metadata; @@ -57,6 +58,10 @@ private enum EventCapabilities /// public const string AutoStartProperty = "AutoStart"; /// + /// MaxDuration + /// + public const string MaxDurationProperty = nameof(MaxDuration); + /// /// Type name /// public const string TypeTypeName = "Session"; @@ -1075,6 +1080,40 @@ public DateTime StartTime } } + /// + /// 0 indicates that duration is unlimited. + /// + public const long UnlimitedDuration = 0; + + /// + /// Default duration is unlimited (0). + /// + public const long DefaultMaxDuration = 0; + + /// + /// Gets or sets the max duration (in seconds). + /// MaxDuration is only supported on SQL Server 2025 (version 17) and later. + /// A value of 0 indicates unlimited duration. + /// + /// The max duration in seconds. + [SfcProperty(Data = true)] + public long MaxDuration + { + get + { + object v = this.Properties[Session.MaxDurationProperty].Value; + if (v == null) + { + return Session.DefaultMaxDuration; + } + return Convert.ToInt64(v, CultureInfo.InvariantCulture); + } + set + { + this.Properties[Session.MaxDurationProperty].Value = value; + } + } + #endregion Public properties /// diff --git a/src/Microsoft/SqlServer/Management/XEvent/core/SessionProviderBase.cs b/src/Microsoft/SqlServer/Management/XEvent/core/SessionProviderBase.cs index d6e49dd1..14691527 100644 --- a/src/Microsoft/SqlServer/Management/XEvent/core/SessionProviderBase.cs +++ b/src/Microsoft/SqlServer/Management/XEvent/core/SessionProviderBase.cs @@ -293,6 +293,24 @@ private string GetOptionString(bool create) sb.Append(","); } + // Include MAX_DURATION in the script when: + // 1. It's dirty (user explicitly set it), OR + // 2. We're scripting an existing session and the value is not the default (0/UNLIMITED) + bool includeMaxDuration = this.session.Properties[Session.MaxDurationProperty].Dirty || + (scriptCreateForExistingSession && this.session.MaxDuration != Session.UnlimitedDuration); + + if (includeMaxDuration) + { + if (this.session.MaxDuration == Session.UnlimitedDuration) + { + sb.Append("MAX_DURATION=UNLIMITED,"); + } + else + { + sb.Append($"MAX_DURATION={this.session.MaxDuration} SECONDS,"); + } + } + if (sb.Length > 0) { // remove the last comma diff --git a/src/Microsoft/SqlServer/Management/XEventEnum/xml/Session.xml b/src/Microsoft/SqlServer/Management/XEventEnum/xml/Session.xml index d18f9e67..b7cc7d0a 100644 --- a/src/Microsoft/SqlServer/Management/XEventEnum/xml/Session.xml +++ b/src/Microsoft/SqlServer/Management/XEventEnum/xml/Session.xml @@ -3,13 +3,25 @@ running.name = session.name + maxdur.event_session_id = session.event_session_id create table #rs (name sysname not null, create_time datetimeoffset not null) insert into #rs select name, create_time from sys.dm_xe_sessions + + create table #md (event_session_id int not null, max_duration bigint null) + if exists (select 1 from sys.all_columns where object_id = object_id('sys.server_event_sessions') and name = 'max_duration') + begin + declare @sql nvarchar(max) = 'insert into #md select event_session_id, max_duration from sys.server_event_sessions' + exec sp_executesql @sql + end + drop table #rs + + drop table #md + @@ -24,5 +36,6 @@ session.track_causality session.startup_state running.create_time + ISNULL(maxdur.max_duration, 0) diff --git a/src/TestReferences.proj b/src/TestReferences.proj index f8d46c26..b32ae412 100644 --- a/src/TestReferences.proj +++ b/src/TestReferences.proj @@ -3,12 +3,10 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - - \ No newline at end of file diff --git a/src/UnitTest/ConnectionInfo/ServerInformationTests.cs b/src/UnitTest/ConnectionInfo/ServerInformationTests.cs index 0e9c91a4..205a18bb 100644 --- a/src/UnitTest/ConnectionInfo/ServerInformationTests.cs +++ b/src/UnitTest/ConnectionInfo/ServerInformationTests.cs @@ -39,7 +39,8 @@ public void GetServerInformation_executes_one_query_and_accepts_three_result_tab SERVERPROPERTY('EngineEdition') AS DatabaseEngineEdition, SERVERPROPERTY('ProductVersion') AS ProductVersion, @@MICROSOFTVERSION AS MicrosoftVersion, -case when serverproperty('EngineEdition') = 12 then 1 when serverproperty('EngineEdition') = 11 and @@version like 'Microsoft Azure SQL Data Warehouse%' then 1 else 0 end as IsFabricServer; +case when serverproperty('EngineEdition') = 12 then 1 when serverproperty('EngineEdition') = 11 and @@version like 'Microsoft Azure SQL Data Warehouse%' then 1 else 0 end as IsFabricServer, +convert(sysname, SERVERPROPERTY(N'Collation')) AS Collation; select host_platform from sys.dm_os_host_info if @edition = N'SQL Azure' select 'TCP' as ConnectionProtocol @@ -56,7 +57,7 @@ select host_platform from sys.dm_os_host_info // Note use of a dataset that would never occur in real life (DataSet ds) => { - FillTestDataSet(ds, versionString, DatabaseEngineType.SqlAzureDatabase, DatabaseEngineEdition.SqlDatabase, 0x320104d2, HostPlatformNames.Linux, "TCP", false); + FillTestDataSet(ds, versionString, DatabaseEngineType.SqlAzureDatabase, DatabaseEngineEdition.SqlDatabase, 0x320104d2, HostPlatformNames.Linux, "TCP", false, "SQL_Latin1_General_CP1_CI_AS"); }); var si = ServerInformation.GetServerInformation(connectMock.Object, dataAdapterMock.Object, versionString); @@ -66,6 +67,7 @@ select host_platform from sys.dm_os_host_info Assert.That(si.DatabaseEngineType, Is.EqualTo(DatabaseEngineType.SqlAzureDatabase), "Unexpected DatabaseEngineType"); Assert.That(si.ServerVersion.Major, Is.EqualTo(50), "Unexpected ServerVersion"); Assert.That(si.ConnectionProtocol, Is.EqualTo(NetworkProtocol.TcpIp), "Unexpected ConnectionProtocol"); + Assert.That(si.Collation, Is.EqualTo("SQL_Latin1_General_CP1_CI_AS"), "Unexpected Collation"); connectMock.VerifyAll(); commandMock.VerifyAll(); dataAdapterMock.VerifyAll(); @@ -89,7 +91,8 @@ public void When_ServerVersion_is_less_than_14_HostPlatform_is_hard_coded_Window SERVERPROPERTY('EngineEdition') AS DatabaseEngineEdition, SERVERPROPERTY('ProductVersion') AS ProductVersion, @@MICROSOFTVERSION AS MicrosoftVersion, -case when serverproperty('EngineEdition') = 12 then 1 when serverproperty('EngineEdition') = 11 and @@version like 'Microsoft Azure SQL Data Warehouse%' then 1 else 0 end as IsFabricServer; +case when serverproperty('EngineEdition') = 12 then 1 when serverproperty('EngineEdition') = 11 and @@version like 'Microsoft Azure SQL Data Warehouse%' then 1 else 0 end as IsFabricServer, +convert(sysname, SERVERPROPERTY(N'Collation')) AS Collation; select N'Windows' as host_platform if @edition = N'SQL Azure' select 'TCP' as ConnectionProtocol @@ -106,7 +109,7 @@ select N'Windows' as host_platform dataAdapterMock.Setup(d => d.Fill(It.IsAny())).Callback( (DataSet ds) => { - FillTestDataSet(ds, "12.0.2000.8", DatabaseEngineType.SqlAzureDatabase, DatabaseEngineEdition.SqlDatabase, 0x0A0104d2, HostPlatformNames.Windows, null, false); + FillTestDataSet(ds, "12.0.2000.8", DatabaseEngineType.SqlAzureDatabase, DatabaseEngineEdition.SqlDatabase, 0x0A0104d2, HostPlatformNames.Windows, null, false, "SQL_Latin1_General_CP1_CI_AS"); }); var si = ServerInformation.GetServerInformation(connectMock.Object, dataAdapterMock.Object, "10.01.1234"); @@ -142,7 +145,7 @@ public void Edition_is_handled_properly_for_Azure_servers(DatabaseEngineEdition (DataSet ds) => { // Simulate Azure SQL Database returning various editions - FillTestDataSet(ds, versionString, DatabaseEngineType.SqlAzureDatabase, engineEdition, 0x10000FA0, HostPlatformNames.Windows, "TCP", false); + FillTestDataSet(ds, versionString, DatabaseEngineType.SqlAzureDatabase, engineEdition, 0x10000FA0, HostPlatformNames.Windows, "TCP", false, "SQL_Latin1_General_CP1_CI_AS"); }); var si = ServerInformation.GetServerInformation(connectMock.Object, dataAdapterMock.Object, versionString); @@ -154,7 +157,7 @@ public void Edition_is_handled_properly_for_Azure_servers(DatabaseEngineEdition } private void FillTestDataSet(DataSet ds, string productVersion, DatabaseEngineType databaseEngineType, DatabaseEngineEdition databaseEngineEdition, - int microsoftVersion, string hostPlatform, string protocol, bool isFabricServer) + int microsoftVersion, string hostPlatform, string protocol, bool isFabricServer, string collation) { Trace.TraceInformation("Creating test DataSet"); ds.Tables.Add("Table"); @@ -163,7 +166,8 @@ private void FillTestDataSet(DataSet ds, string productVersion, DatabaseEngineTy ds.Tables["Table"].Columns.Add(new DataColumn("DatabaseEngineEdition", typeof(int))); ds.Tables["Table"].Columns.Add(new DataColumn("MicrosoftVersion", typeof(int))); ds.Tables["Table"].Columns.Add(new DataColumn("IsFabricServer", typeof(bool))); - ds.Tables["Table"].Rows.Add(productVersion, (int)databaseEngineType, (int)databaseEngineEdition, microsoftVersion, isFabricServer); + ds.Tables["Table"].Columns.Add(new DataColumn("Collation", typeof(string))); + ds.Tables["Table"].Rows.Add(productVersion, (int)databaseEngineType, (int)databaseEngineEdition, microsoftVersion, isFabricServer, collation); ds.Tables.Add("Table2"); ds.Tables["Table2"].Columns.Add(new DataColumn("host_platform", typeof(string))); ds.Tables["Table2"].Rows.Add(hostPlatform); diff --git a/src/UnitTest/Smo/DatabaseTests.cs b/src/UnitTest/Smo/DatabaseTests.cs index e89af608..9225a7f2 100644 --- a/src/UnitTest/Smo/DatabaseTests.cs +++ b/src/UnitTest/Smo/DatabaseTests.cs @@ -45,6 +45,7 @@ public class DatabaseTests : UnitTestBase typeof(ExternalFileFormatCollection), typeof(ExternalLanguageCollection), typeof(ExternalLibraryCollection), + typeof(ExternalModelCollection), typeof(ExternalStreamCollection), typeof(ExternalStreamingJobCollection), typeof(FileGroupCollection), diff --git a/src/UnitTest/XEventDbScoped/SessionUnitTest.cs b/src/UnitTest/XEventDbScoped/SessionUnitTest.cs index b62cc4c4..d4bc3043 100644 --- a/src/UnitTest/XEventDbScoped/SessionUnitTest.cs +++ b/src/UnitTest/XEventDbScoped/SessionUnitTest.cs @@ -36,6 +36,7 @@ public void TestDefaultValue() Assert.IsFalse(session.TrackCausality); Assert.IsFalse(session.AutoStart); Assert.AreEqual(Session.NotStarted, session.StartTime); + Assert.AreEqual(Session.DefaultMaxDuration, session.MaxDuration); session = new Session(null, "ut1"); Assert.AreEqual(-1, session.ID); @@ -50,8 +51,26 @@ public void TestDefaultValue() Assert.IsFalse(session.TrackCausality); Assert.IsFalse(session.AutoStart); Assert.AreEqual(Session.NotStarted, session.StartTime); + Assert.AreEqual(Session.DefaultMaxDuration, session.MaxDuration); } + /// + /// Tests the MaxDuration property. + /// + [TestMethod] + [TestCategory("Unit")] + public void TestMaxDuration() + { + Session session = new Session(); + + // Test default value when no parent (version checking unavailable) + Assert.AreEqual(Session.DefaultMaxDuration, session.MaxDuration); + Assert.AreEqual(Session.UnlimitedDuration, session.MaxDuration); + + session.MaxDuration = 3600; + session.MaxDuration = 86400; + session.MaxDuration = Session.UnlimitedDuration; + } [TestMethod] [TestCategory("Unit")]