-
Notifications
You must be signed in to change notification settings - Fork 79
Implement -p flag for print statistics #631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Add support for the -p flag which prints performance statistics after each batch execution: - -p (or -p0): Standard human-readable format - -p1: Colon-separated format for parsing Statistics include network packet size, transaction count, and timing information (total ms, average ms, transactions per second). This improves compatibility with legacy ODBC sqlcmd.
There was a problem hiding this 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 adds support for a -p flag that prints per-batch performance statistics, improving compatibility with legacy ODBC sqlcmd and documenting the feature and its formats.
Changes:
- Extend the
Sqlcmdengine with aPrintStatisticsoption and aprintStatisticshelper that measures batch execution time and prints statistics in standard or colon-separated format. - Wire the new
-p/--print-statisticsflag through the CLI argument parsing pipeline, including normalization and propagation into theSqlcmdinstance. - Add unit tests for the statistics output formats and disabled behavior, and document usage and sample output in the README.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| pkg/sqlcmd/sqlcmd.go | Adds PrintStatistics support, measures batch duration in runQuery, and implements printStatistics for both human-readable and colon-separated output. |
| pkg/sqlcmd/sqlcmd_test.go | Adds tests that verify standard-format output, colon-separated output, and the disabled case when PrintStatistics is nil. |
| cmd/sqlcmd/sqlcmd.go | Introduces the -p/--print-statistics CLI flag, integrates it into argument parsing, normalization, and run, and passes the option into the Sqlcmd core. |
| README.md | Documents the new -p behavior and shows an example of the standard statistics output format. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Add 'p' to checkDefaultValue for bare -p flag support - Fix error message to show both '0' and '1' as valid values - Remove trailing space in colon-separated format output - Add test cases for -p and -p 1 flags
There was a problem hiding this 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.
There was a problem hiding this 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.
There was a problem hiding this 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.
There was a problem hiding this 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.
Summary
Adds support for the
-pflag which prints performance statistics after each batch execution, improving compatibility with legacy ODBC sqlcmd.Changes
-pflag parsing with validation for values 0 or 1printStatistics()methodUsage
Output Formats
Standard format (
-por-p0)Colon-separated format (
-p1)Testing
golangci-lint runpasses