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

Function validateSQLiteDatabasePath

src/Databases/SQLite/SQLiteUtils.cpp:27–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25}
26
27static String validateSQLiteDatabasePath(const String & path, const String & user_files_path, bool need_check, bool throw_on_error)
28{
29 String absolute_path = fs::absolute(path).lexically_normal();
30
31 if (fs::path(path).is_relative())
32 absolute_path = fs::absolute(fs::path(user_files_path) / path).lexically_normal();
33
34 String absolute_user_files_path = fs::absolute(user_files_path).lexically_normal();
35
36 if (need_check && !absolute_path.starts_with(absolute_user_files_path))
37 {
38 processSQLiteError(fmt::format("SQLite database file path '{}' must be inside 'user_files' directory", path), throw_on_error);
39 return "";
40 }
41 return absolute_path;
42}
43
44SQLitePtr openSQLiteDB(const String & path, ContextPtr context, bool throw_on_error)
45{

Callers 1

openSQLiteDBFunction · 0.85

Calls 2

processSQLiteErrorFunction · 0.85
formatFunction · 0.50

Tested by

no test coverage detected