feat: Add --checksum flag for SHA-256 result set hashing (issue #204) - #215
Merged
Conversation
- Add --checksum flag to args.zig with parsing and help text - Implement BufferWriter in main.zig with custom vtable for output buffering - Add emitChecksum() function computing SHA-256 via std.crypto.hash.sha2.Sha256 - Wire checksum into all output paths: CSV/TSV/JSON/NDJSON/XML/HTML/SQL/table/markdown - Add --checksum to bash, zsh, and fish completion scripts - Add 25 integration tests (204a-204y) covering all formats and flag combinations - Update README.md and docs/sql-pipe.1.scd with documentation
- Remove global current_buffer_writer anti-pattern - Simplify BufferWriter using std.Io.Writer.Allocating - Extract computeChecksum() and emitChecksum() helpers - Thread stderr_writer through call chain - Add 4 unit tests for computeChecksum() with known SHA-256 vectors - Add memory warning to README.md and man page - Create portable checksum-verify tool (replaces sha256sum/awk) - Update all 23 integration tests (204a-204w) to use portable tool - All 15 output formats verified, all 5 inspect modes correctly skip checksum
- Removed duplicated SHA-256 logic (src/checksum_verify.zig deleted) - Collapsed 3 duplicated if/else checksum blocks into writeWithChecksum helper - Parameterized 25 integration tests into ChecksumTest struct array - Fixed /tmp/checksum_err race (mktemp per test) - Replaced manual hex loop with std.fmt.bytesToHex - Reordered writeTable/writeMarkdown to writer-last convention - Net: -266 lines
- writeWithChecksum: buffer ArrayList never freed after toArrayList(); in --repl mode this leaked per query. Added defer buffer.deinit(allocator). - run(): execQuery catch now switches on error type like repl.zig; OutOfMemory gets specific message, not misleading SQL error. - Extended ponytail comment: --checksum defeats --disk (all in RAM).
… tests (ora-3) - README/man page: --max-rows caps input rows, not output rows. Suggest LIMIT clause instead. Note --disk defeated by --checksum. - Tests: --checksum --silent verifies checksum still emits. --checksum --repl multi-query verifies per-query behavior.
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.
Closes #204.
Summary
Adds a flag that computes the SHA-256 hash of the result set and emits it to stderr as
checksum: <hash>. The hash covers only stdout output (the result set), making it compatible with all output formats and other stderr-writing flags.Changes
Behavior