39 Commits
Author SHA1 Message Date
zooqueen 0f1e1b5143 merge: ClickHouse 26.6.1.1 into datastore — preserve debrand + ZAP + gRPC/gcloud removal
Merge upstream/changelog-26.6 (9593 commits) into our debranded fork.
- 190 conflicts resolved: 24 delete-side kept-removed (grpc/arrowflight/gcloud), submodules+version→26.6,
  contrib/CMakeLists keeps zap + new libpng, drops capnproto (zap provides kj), Server.cpp/CMakeLists
  re-apply the ZAP wiring + gRPC/arrowflight/gcloud removal.
- Full-tree debrand re-swept over the new 26.6 code (uniform Datastore naming; Azure fork Clickhouse*
  symbols preserved). 0 clickhouse in product src/programs/CMakeLists.
- Version now 26.6.1.1. gRPC/google-cloud/chdig stay removed; ZAP remains the transport.
2026-06-23 12:23:48 -07:00
zooqueen f9f34ad947 datastore: rename program source/completion files clickhouse-* -> datastore-*
The lowercase sweep renamed source-file references inside programs/*/CMakeLists.txt
(clickhouse-su.cpp -> datastore-su.cpp etc.) but not the physical files -> 'Cannot find source
file datastore-su.cpp'. Renamed all 19 program entry-point sources, the client config xml, and
bash-completion scripts to match. Completes the program-file rebrand.
2026-06-21 23:57:41 -07:00
zooqueen 0357c7e3ff datastore rebrand: lowercase clickhouse -> datastore in commands/prose/help
Completes the user-facing branding: lowercase `clickhouse` command/symlink names
(clickhouse-server/-client/-local/...), `clickhouse <subcommand>` usage strings, and bare-word
prose in messages/comments -> datastore (~238 occurrences across 227 files).

Intentionally KEPT (not branding):
- SQL dict-source keyword "clickhouse" (SOURCE(CLICKHOUSE(...)) compat) - 4 sites
- external URLs (clickhouse.com / github.com/ClickHouse)
- filesystem / ZooKeeper path conventions (/var/lib/clickhouse fallback default, /clickhouse/tables/
  ReplicatedMergeTree ZK path) - deployment convention, overridden by our datastore-* config

String/comment-literal changes only; no identifiers touched (verified no bare lowercase clickhouse
C++ symbol exists). Build was already green; verifying this is still green.
2026-06-21 23:46:30 -07:00
zooqueen 06f45b6529 datastore rebrand: compound symbols + CMake targets/macros (clickhouse -> datastore)
The deep internal rebrand (user: "rename all compound symbols", "datastore_ good", "DB:: fine"):
- CamelCase symbols ClickHouse* -> Datastore* (358 distinct): mainEntryDatastoreServer,
  DatastoreDictionarySource, DatastoreRevision, DatastoreVersion, etc. URL/repo lines skipped.
- snake targets + macros clickhouse_* -> datastore_* (850 occ): datastore_common_io,
  datastore_add_executable, datastore_program_install, datastore_functions, etc. — uniform
  across src + cmake + all CMakeLists, and the contrib wrappers that link/use them
  (croaring, nuraft, corrosion, chdig, delta-kernel-rs, mongo-cxx).
- CLICKHOUSE_* macros -> DATASTORE_* (DATASTORE_OFFICIAL_BUILD, ENABLE_DATASTORE_*, etc.).
- project(ClickHouse) -> project(Datastore) so ${Datastore_SOURCE_DIR}/${Datastore_BINARY_DIR}
  (45 refs) resolve.

Replace (not drop) -> collision-free. DB:: namespace kept (per direction). lowercase SQL
`clickhouse` dictionary-source keyword + clickhouse.com / github.com/ClickHouse URLs kept.
NEEDS BUILD VERIFICATION on spark/CI — uniform + inspected-consistent but uncompiled here.
2026-06-21 20:38:05 -07:00
zooqueen 332335ddb4 datastore rebrand: standalone "ClickHouse" word -> "Datastore" (prose, strings, comments)
The correct, safe broad rebrand: renames "ClickHouse" only as a whole word (boundary on
BOTH sides), so it rewrites display strings/messages/comments but leaves every compound
C++ symbol intact — `ClickHouseDictionarySource`, `getInfoIfClickHouseDictionarySource`,
`mainEntryClickHouseServer`, `ClickHouseRevision`, `ClickHouse_SOURCE_DIR` are untouched
(an earlier one-sided heuristic mangled suffix symbols like `manageClickHouse`; reverted).
1677 occurrences across 482 files. Compile-safe (string/comment content; symbols preserved).

Still NOT renamed (would be a build-coupled symbol rename, needs build-host iteration): the
199 compound identifiers containing ClickHouse, the `DB::` namespace, the `clickhouse_*`
CMake targets/macros, the lowercase `clickhouse` SQL dictionary-source keyword. Needs build
verification.
2026-06-21 20:10:25 -07:00
Alexey Milovidov ab6cd89b58 Merge remote-tracking branch 'origin/master' into fix-compiler-warnings
# Conflicts:
#	src/AggregateFunctions/fuzzers/aggregate_function_state_deserialization_fuzzer.cpp
#	src/Client/BuzzHouse/AST/SQLProtoStr.cpp
#	src/Functions/UserDefined/UserDefinedWebAssembly.cpp
#	src/IO/examples/parse_int_perf.cpp
#	src/Processors/QueryPlan/Optimizations/removeUnusedColumns.cpp
#	src/TableFunctions/TableFunctionMergeTreeAnalyzeIndexes.cpp
2026-05-29 02:17:22 +00:00
Raúl Marín 405b0d8a1b Reject unknown user/group names instead of silently falling back to uid/gid 0
When `arg_uid` (or `arg_gid`) is a non-numeric name that does not exist in
the passwd/group database, `tryParse` fails and leaves the local `uid`/`gid`
at its default-initialized value of 0. The "name not found" branch then
called `getpwuid_r(uid)` / `getgrgid_r(gid)`, which resolved to root and
its primary group, so `clickhouse su nosuchuser cmd` and
`clickhouse su user:nosuchgroup cmd` silently kept UID/GID 0 instead of
reporting the typo.

Only retry the numeric lookup when `tryParse` actually parsed the input as
a number (covering the legitimate `clickhouse su 0 …` / `clickhouse su :0 …`
cases). Otherwise the lookup falls through to the existing
`BAD_ARGUMENTS` "not found in the system" exception.
2026-05-18 17:34:59 +00:00
Raúl Marín d809629460 Skip supplementary-group reset when caller is not root, surface NSS errors
Address review feedback on the supplementary-group reset:

- `initgroups`/`setgroups` require `CAP_SETGID`. Calling them unconditionally
  regressed non-root invocations such as the Docker `--user` path, where
  `docker/server/entrypoint.sh` invokes `clickhouse su clickhouse:clickhouse`
  even though the process is already running as the target user — that used
  to succeed as a no-op privilege drop and now threw `SYSTEM_ERROR`. Gate
  the reset on `geteuid() == 0` so it runs only when we actually have the
  capability; non-root callers cannot taint their own supplementary list
  anyway.
- The numeric-UID `getpwuid_r` call swallowed nonzero return codes,
  treating NSS errors (`ERANGE` / `ENOMEM` / backend failures) as
  "no passwd entry" and falling through to `setgroups(0, nullptr)`. Throw
  on nonzero return so real lookup failures surface instead of silently
  changing behavior; the `rc == 0 && result == nullptr` "no entry" case is
  still allowed and clears the supplementary list.
2026-05-18 16:38:26 +00:00
Raúl Marín 997a6520b1 Reset supplementary groups in clickhouse su before dropping privileges
`programs/su/su.cpp` resolves the target user and group, then calls `setgid`
followed by `setuid`. Neither syscall touches the supplementary group list,
so the dropped process silently inherits the supplementary groups of the
invoker. On a system where root has been granted membership in groups like
`disk`, `adm`, `wheel`, `docker`, `sudo`, or where the systemd unit / Docker
entrypoint configures supplementary groups, those memberships leak into the
unprivileged process and defeat the intent of the privilege drop. For
comparison, `/bin/su(1)` and `sudo(8)` both reset the supplementary list
via `initgroups` as part of dropping privileges.

Restructure `setUserAndGroup` so the passwd database is consulted even when
the UID is supplied numerically (to recover the user name), and invoke
`initgroups(user_name, group)` before `setgid`/`setuid` so the supplementary
group list reflects the target user's `/etc/group` memberships. When the
target UID has no passwd entry the supplementary list is cleared with
`setgroups(0, nullptr)` instead.
2026-05-18 16:03:01 +00:00
Alexey Milovidov 7d54e33c7c Merge remote-tracking branch 'origin/master' into fix-compiler-warnings
# Conflicts:
#	programs/main.cpp
2026-05-06 03:18:15 +00:00
Alexey MilovidovandClaude Opus 4.6 8b47d200d5 Enable -Wmissing-prototypes compiler warning
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) <[email protected]>
2026-03-27 20:11:07 +00:00
Alexey MilovidovandGitHub 85164c93d4 Revert "Revert "Improve help output for ClickHouse applications"" 2026-02-27 00:49:00 +01:00
Alexey MilovidovandGitHub e8654c51eb Revert "Improve help output for ClickHouse applications" 2026-02-26 07:51:17 +01:00
Raúl MarínandClaude Opus 4.6 9aa8e4ed27 Move ErrnoException from Exception.h to its own header
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 <[email protected]>
2026-02-20 13:47:23 +01:00
Alexey MilovidovandClaude Opus 4.5 62ccfbd3aa Improve help output for ClickHouse applications
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 <[email protected]>
2026-02-05 07:12:44 +01:00
Raúl Marín e50265bae5 Optimize includes of Exception.h 2024-12-02 22:26:41 +01:00
Konstantin Bogdanov b2c81981fb Use clang-19 2024-11-20 23:08:47 +01:00
Mikhail f. Shiryaev 298b172c49 Add fallback to getgrgid_r and getpwuid_r for UID and GID arguments of clickhouse-su 2024-11-08 14:09:22 +01:00
Azat Khuzhin 7fb31fe160 Remove ability to disable generic clickhouse components
Components like client/server/... are very generic, and there is no
point in disabling them, since it does not reduce amount of compiled
code a lot anyway (just a few modules for entrypoints, everything else
is already included in the clickhouse binary), and eventually they are
just symlinks to the clickhouse binary.

But there are few, that requires extra libraries, like ODBC bridge or
keeper components (and there is also standalone keeper binary compiled
with musl), those had been kept.

Also add some descriptions for some utils and change exit code to 0 for
--help.

Signed-off-by: Azat Khuzhin <[email protected]>
2024-02-12 11:10:00 +01:00
Raúl Marín b269f87f4c Better text_log with ErrnoException 2023-12-15 19:27:56 +01:00
Alexey MilovidovandGitHub 98ae9be734 Revert "Added tests for ClickHouse apps help and fixed help issues" 2023-04-21 01:54:34 +03:00
Yatsishin Ilya 98edb9f06b Update help for clickhouse tools and add test 2023-01-31 12:19:37 +00:00
Alexander TokmakovandGitHub 70d1adfe4b Better formatting for exception messages (#45449)
* save format string for NetException

* format exceptions

* format exceptions 2

* format exceptions 3

* format exceptions 4

* format exceptions 5

* format exceptions 6

* fix

* format exceptions 7

* format exceptions 8

* Update MergeTreeIndexGin.cpp

* Update AggregateFunctionMap.cpp

* Update AggregateFunctionMap.cpp

* fix
2023-01-24 00:13:58 +03:00
Alexey Milovidov 35cce03125 Remove dlopen 2022-09-17 03:02:34 +02:00
Robert Schulze e8b3f56733 Limit suppression to a specific warning 2022-08-21 18:24:17 +00:00
Alexey Milovidov 74e1f4dc61 Fix clang-tidy 2022-08-20 17:09:20 +02:00
Azat Khuzhin b90152b6ec Fix clickhouse-su building in splitted build
- Add status log message
- Add it to clickhouse-bundle in shared build
- Move clickhouse-su.cpp into su.cpp, since executable does not have
  include directories of linked libraries (dbms here), only
  clickhouse-lib-su does, hence it cannot find includes

CI: https://github.com/ClickHouse/ClickHouse/runs/7566319416?check_suite_focus=true
Signed-off-by: Azat Khuzhin <[email protected]>
2022-07-29 11:36:51 +03:00
Nikita MikhaylovandGitHub e66114984c Update programs/su/clickhouse-su.cpp 2022-06-30 12:44:59 +02:00
Nikita MikhaylovandGitHub b2cc6787ee Update programs/su/clickhouse-su.cpp 2022-06-30 12:44:30 +02:00
filimonovandGitHub 3949480ed3 Fix exception messages in clickhouse su
Fix exception messages in
2022-06-30 11:38:05 +02:00
Alexey Milovidov 0b5cfa4094 Fix split build 2022-05-25 04:24:02 +02:00
Alexey Milovidov 4556904dae Fix stress test 2022-05-25 04:21:25 +02:00
Alexey Milovidov 5b1bdfc353 Fix error 2022-05-24 02:02:18 +02:00
Alexey Milovidov e8c08cda0d Fix error in static-files-disk-uploader 2022-05-24 01:38:17 +02:00
Alexey Milovidov ee0a8f3251 Fix exception messages 2022-05-24 01:37:17 +02:00
Alexey Milovidov 03b118557c Fix error 2022-05-23 03:52:44 +02:00
Alexey Milovidov 39d157b9fb Fix error 2022-05-23 03:52:00 +02:00
Alexey Milovidov b432ca93a1 Fix error 2022-05-23 03:11:12 +02:00
Alexey Milovidov 2f93f11144 Maybe better 2022-05-23 02:03:13 +02:00