Add /M command-line switch for importer selection#524
Open
PiJoCoder wants to merge 1 commit into
Open
Conversation
Adds a new /M command-line argument to sqlnexus.exe that lets automation
scripts select which importers to run without modifying saved UI settings
(user.config is never touched by this path).
Changes:
sqlnexus/Program.cs
- Parse /M<tokens> where tokens are '+'-separated importer names or the
special value "All"
- Populate Globals.EnabledImporters (null when /M is absent, so GUI
sessions are completely unaffected)
- Extend ShowUsage() to document /M
sqlnexus/Globals.cs
- Add static HashSet<string> EnabledImporters as the in-memory-only
/M override state
sqlnexus/fmImport.cs
- Add READTRACE_IMPORTER_NAME and TRACEEVENT_IMPORTER_NAME constants
- Add TraceEventImporter token to ImporterTokenToName dictionary
- Order TraceEventImporter.dll at priority 150 (after Rowset=100,
before ReadTrace=200) in OrderedImporterFiles()
- EnumImporters() now calls EnforceTraceImporterExclusivity() so that
if both trace importers are saved as enabled, ReadTrace is
automatically disabled (TraceEventImporter is preferred)
- Add helpers: EnforceTraceImporterExclusivity(), IsImporterEnabled(),
DisableImporterByName()
- EnumFiles() /M override block:
- Rowset Importer is always forced on (it populates core tables
required by all importers and post-processing scripts)
- Other importers are gated by the token set
- If both ReadTrace and TraceEventImporter are requested,
TraceEventImporter wins
- tsiBool_Click() enforces mutual exclusivity in the UI: enabling one
trace importer automatically disables the other and shows a dialog
- RunPostScripts() now runs ReadTracePostProcessing.sql for both
ReadTrace and TraceEventImporter (both write to the ReadTrace schema)
sqlnexus/Properties/Resources.resx + Resources.Designer.cs
- Add Usage_Importers help string documenting /M tokens and examples
Supported /M tokens:
ReadTrace, Perfmon, Linux, Errorlog, TraceEventImporter, CustomXEL, All
Rowset Importer always runs regardless of /M selection.
ReadTrace and TraceEventImporter are mutually exclusive;
TraceEventImporter takes precedence when both are specified.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a new /M command-line argument to sqlnexus.exe that lets automation scripts select which importers to run without modifying saved UI settings (user.config is never touched by this path).
Changes:
sqlnexus/Program.cs
sqlnexus/Globals.cs
sqlnexus/fmImport.cs
sqlnexus/Properties/Resources.resx + Resources.Designer.cs
Supported /M tokens:
ReadTrace, Perfmon, Linux, Errorlog, TraceEventImporter, CustomXEL, All
Rowset Importer always runs regardless of /M selection. ReadTrace and TraceEventImporter are mutually exclusive; TraceEventImporter takes precedence when both are specified.
Testing:
1. Default behavior — no /M switch (regression check)
Launch SQLNexus normally through the GUI or via a console run without /M. Verify that all importers respect their saved user.config / AppConfig.xml settings exactly as before and that no user.config values are modified after the run.
2. /MReadTrace — single importer selection
sqlnexus.exe /S.\SQL2025 /dsqlnexus /E /I"D:\SQLLogScout\output" /X /MReadTrace /NExpected:
• Log shows Rowset Importer enabled = True (forced on as core dependency)
• Log shows ReadTrace (SQL XEL/TRC Files) enabled = True
• All other importers show enabled = False
• ReadTracePostProcessing.sql executes without schema errors
• PerfStatsAnalysis.sql executes without missing-table errors
3. /MReadTrace — single importer selection
sqlnexus.exe /S.\SQL2025 /dsqlnexus /E /I"D:\SQLLogScout\output" /X /MReadTrace /NExpected:
• Log shows Rowset Importer enabled = True (forced on as core dependency)
• Log shows ReadTrace (SQL XEL/TRC Files) enabled = True
• All other importers show enabled = False
• ReadTracePostProcessing.sql executes without schema errors
• PerfStatsAnalysis.sql executes without missing-table errors
4. /MAll — all importers enabled
sqlnexus.exe /S.\SQL2025 /dsqlnexus /E /I"D:\SQLLogScout\output" /X /MAll /NExpected:
• Log shows all importers as enabled = True
• Full import completes including CustomXEL, RawFileImport, PostProcess, PerfStatsAnalysis
5. /MReadTrace+Errorlog — multiple importers
sqlnexus.exe /S.\SQL2025 /dsqlnexus /E /I"D:\SQLLogScout\output" /X /MReadTrace+Errorlog /NExpected:
• Rowset Importer, ReadTrace, and ERRORLOG Importer are enabled
• Perfmon, Linux, TraceEventImporter are disabled
• Both ReadTrace and ERRORLOG data appear in the database
6. /MTraceEventImporter — managed trace importer
sqlnexus.exe /S.\SQL2025 /dsqlnexus /E /I"D:\SQLLogScout\output" /X /MTraceEventImporter /NExpected:
• Rowset Importer and TraceEventImporter are enabled
• ReadTrace is disabled (mutual exclusivity)
• ReadTracePostProcessing.sql executes (TraceEventImporter also uses the ReadTrace schema)
7. /MReadTrace+TraceEventImporter — mutual exclusivity via /M
sqlnexus.exe /S.\SQL2025 /dsqlnexus /E /I"D:\SQLLogScout\output" /X /MReadTrace+TraceEventImporter /NExpected:
• Log shows: /M override; both trace importers selected — disabling 'ReadTrace (SQL XEL/TRC Files)' in favour of 'Trace Event Importer (Managed)'
• Only TraceEventImporter runs; ReadTrace is suppressed
8. GUI mutual exclusivity — enabling one trace importer disables the other
Open the GUI, go to Options → Importers, enable ReadTrace. Then enable Trace Event Importer (Managed).
Expected:
• A dialog appears: "You have enabled 'Trace Event Importer (Managed)'. The 'ReadTrace (SQL XEL/TRC Files)' importer has been automatically disabled..."
• ReadTrace Enabled checkbox becomes unchecked automatically
• Reverse direction (enabling ReadTrace while TraceEventImporter is on) behaves the same way
9. user.config is not modified by /M runs
Run any /M variant, then inspect user.config (typically in %LOCALAPPDATA%...\user.config).
Expected:
• The Enabled values for all importers in user.config are identical before and after the console run