Skip to content

Conversation

@dlevy-msft-sql
Copy link
Contributor

@dlevy-msft-sql dlevy-msft-sql commented Jan 25, 2026

Summary

Adds the :perftrace command to redirect performance statistics output to a file, stderr, or stdout. This works in conjunction with the -p flag (PR #631) to control where timing statistics are written.

Syntax

sqlcmd -S server -Q "SELECT 1" -p
:perftrace <filename>|stderr|stdout

Changes

  • pkg/sqlcmd/sqlcmd.go: Added stat writer field and GetStat/SetStat methods
  • pkg/sqlcmd/commands.go: Added PERFTRACE command with file/stdout/stderr support
  • pkg/sqlcmd/commands_test.go: Added tests for command parsing and functionality
  • README.md: Added documentation with usage example

Testing

  • All tests pass
  • golangci-lint run passes (pre-existing warnings only)
  • Build succeeds

Related

Add the :perftrace command to redirect performance statistics output
to a file, stderr, or stdout. This works in conjunction with the -p
flag to control where timing statistics are written.

Syntax: :perftrace <filename>|stderr|stdout

Changes:
- Added stat writer field to Sqlcmd struct
- Added GetStat/SetStat methods
- Added PERFTRACE command with file/stdout/stderr support
- Added tests for command parsing and functionality

This improves compatibility with legacy ODBC sqlcmd.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements the :perftrace command to redirect performance statistics output to a file, stderr, or stdout, working in conjunction with the -p flag from PR #631.

Changes:

  • Added stat writer infrastructure with GetStat/SetStat methods following the established pattern for output/error writers
  • Implemented PERFTRACE command supporting file paths, "stdout", and "stderr" with variable substitution
  • Added comprehensive test coverage for the command functionality

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
pkg/sqlcmd/sqlcmd.go Added stat field and GetStat()/SetStat() methods for managing performance statistics output writer
pkg/sqlcmd/commands.go Registered PERFTRACE command and implemented perftraceCommand() function with file/stdout/stderr support
pkg/sqlcmd/commands_test.go Added TestPerftraceCommand() with comprehensive test scenarios and added PERFTRACE parsing tests
README.md Documented the :perftrace command with usage example

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Add the :help command to display available sqlcmd commands.
This improves compatibility with legacy ODBC sqlcmd.

Changes:
- Added HELP command to command registry
- Added helpCommand function with full command list
- Added tests for command parsing and functionality
- Updated README.md
- Remove :serverlist and :perftrace from help text
- These commands are in separate PRs and not yet merged
- Help text should only list commands that exist in this branch
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

- Fix regex pattern for consistency with other commands
- Fix README path to use forward slashes for cross-platform
- Add test cases for :PERFTRACE command parsing
- Add :perftrace assertion in TestHelpCommand
- Add TestPerftraceCommand for comprehensive testing
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@dlevy-msft-sql dlevy-msft-sql self-assigned this Jan 25, 2026
@dlevy-msft-sql dlevy-msft-sql added sqlcmd switch switch in existing sqlcmd Size: S Small issue (less than one week effort) labels Jan 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Size: S Small issue (less than one week effort) sqlcmd switch switch in existing sqlcmd

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant