Skip to content

Add /M command-line switch for importer selection#524

Open
PiJoCoder wants to merge 1 commit into
masterfrom
ImporterCmdLineParam-pijocoder-051526
Open

Add /M command-line switch for importer selection#524
PiJoCoder wants to merge 1 commit into
masterfrom
ImporterCmdLineParam-pijocoder-051526

Conversation

@PiJoCoder
Copy link
Copy Markdown
Collaborator

@PiJoCoder PiJoCoder commented May 15, 2026

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 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 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.

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.

  • Use this query for all scenarios to validate presence of a representative table
    select top 10 * from tbl_SQL_Base_SystemHealthXEL_Startup --validates CustomXEL
    select top 10 * from dbo.CounterData --validates Perfmon
    select top 10 * from tbl_fltmc_instances --validates Rowset importer
    select top 10 * from tbl_ERRORLOG --validates Errorlog
    select top 10 * from ReadTrace.tblBatches --validates ReadTrace or TraceEventImporter

2. /MReadTrace — single importer selection

sqlnexus.exe /S.\SQL2025 /dsqlnexus /E /I"D:\SQLLogScout\output" /X /MReadTrace /N

Expected:

• 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 /N

Expected:

• 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 /N

Expected:

• 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 /N

Expected:

• 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 /N

Expected:

• 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 /N

Expected:

• 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

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.
Comment thread sqlnexus/fmImport.cs Dismissed
@PiJoCoder PiJoCoder marked this pull request as ready for review May 15, 2026 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create command line arguments for sqlnexus.exe to enable or disable the various importers

2 participants