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.
| 225 | /// alphanumeric + underscore, not starting with a digit. |
| 226 | /// Used to validate CLICKHOUSE_USER and CLICKHOUSE_DB before embedding in SQL/XML. |
| 227 | bool 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). |
no test coverage detected