MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / isValidIdentifier

Function isValidIdentifier

programs/docker-init/docker-init.cpp:227–237  ·  view source on GitHub ↗

Returns true if the string is a safe ClickHouse identifier: alphanumeric + underscore, not starting with a digit. Used to validate CLICKHOUSE_USER and CLICKHOUSE_DB before embedding in SQL/XML.

Source from the content-addressed store, hash-verified

225/// alphanumeric + underscore, not starting with a digit.
226/// Used to validate CLICKHOUSE_USER and CLICKHOUSE_DB before embedding in SQL/XML.
227bool isValidIdentifier(const std::string & s)
228{
229 if (s.empty())
230 return false;
231 if (std::isdigit(static_cast<unsigned char>(s[0])))
232 return false;
233 for (unsigned char c : s)
234 if (!std::isalnum(c) && c != '_')
235 return false;
236 return true;
237}
238
239/// Extract a single value from a ClickHouse config key via `clickhouse extract-from-config`.
240/// Returns an empty string if the key is absent (--try flag suppresses errors).

Callers 2

manageClickHouseUserFunction · 0.70
createClickHouseDatabaseFunction · 0.70

Calls 1

emptyMethod · 0.45

Tested by

no test coverage detected