NaN compares false with both bounds of the documented [0, 1] range, so the shared
validator silently accepted `--frequency-desaturate nan` as a no-op; reject non-finite
values explicitly (the SQL surface was already covered by the generic float setting
parsing, which requires a finite value).
The empty-input `--limit > 0` guard fired only after the output pipeline was started
and finished, so a format with non-trivial framing (`JSON`, `XML`, `Pretty`, ...) had
already emitted a syntactically valid empty result before the exception. Start the
output only once a pass has produced a row, and throw before finalizing it, so a
failing run leaves stdout untouched.
Extract the `obfuscate` table function's parameter checks into a shared
`MarkovModelParameters::validate` in `src/Common/Obfuscator/Models.h` and call it
from both `ObfuscateStep` and `mainEntryClickHouseObfuscator`, so the standalone
`clickhouse obfuscator` tool now rejects `--order 0` (previously a logical error),
absurdly large `--order` values, and `--frequency-desaturate` outside [0, 1] with
the same `BAD_ARGUMENTS` contract as the SQL surface.
Also make the CLI generation loop fail closed: when an explicit --limit is given
and a full generation pass over the input produces no rows (e.g. empty input),
throw instead of rebuilding the input pipeline forever.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The refactoring that moved the obfuscator implementation into the shared
`src/Common/Obfuscator/Models.h` dropped the `file_out.finalize()` call at the
end of `mainEntryClickHouseObfuscator`. Without finalizing the output
`WriteBufferFromFileDescriptor`, its destructor aborts in debug and sanitizer
builds, which made `00092_obfuscator`, `00096_obfuscator_save_load`,
`00175_obfuscator_schema_inference` and `01472_obfuscator_uuid` fail with
`Aborted`, and the resulting core dump was reported as `Server died` in the
targeted stateless runs.
Restore the explicit `file_out.finalize()` after the generation loop.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add `static` to file-local functions and forward declarations
for cross-TU functions to satisfy `-Wmissing-prototypes`.
This ensures all functions have visible prototypes before their
definitions, improving code quality and catching accidental
linkage issues.
Reference: https://github.com/ClickHouse/ClickHouse/issues/76944
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Extract `ErrnoException` into `Common/ErrnoException.h` to reduce the
include footprint of `Exception.h`. This removes `<base/errnoToString.h>`
and `<cerrno>` from `Exception.h`, which is included by ~95% of all
translation units.
All files referencing `ErrnoException` now include the new header
directly. Files that used `errnoToString` without `ErrnoException`
got an explicit `<base/errnoToString.h>` include.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit improves the help output for all ClickHouse applications:
- Add `clickhouse help` command that lists all available subcommands
- Return exit code 0 for all help messages (previously some returned 1)
- Output help messages to stdout instead of stderr
- Use "clickhouse <cmd>" format instead of argv[0] in help messages
- Add dynamic `app_name` detection for `clickhouse client` and `clickhouse local`
to show correct invocation name based on how the binary was called
- Add `--no-sudo` option for `clickhouse start` and `clickhouse restart`
for environments without sudo (e.g., Docker containers)
- Add detailed help headers and footers for client and local with usage examples
Closes#58244
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>